@grackle-ai/web 0.53.4 → 0.54.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.
@@ -33,7 +33,7 @@ Error generating stack: `+o.message+`
33
33
  * @license MIT
34
34
  */var ey="popstate";function ty(n){return typeof n=="object"&&n!=null&&"pathname"in n&&"search"in n&&"hash"in n&&"state"in n&&"key"in n}function gT(n={}){function a(l,r){var g;let d=(g=r.state)==null?void 0:g.masked,{pathname:u,search:p,hash:m}=d||l.location;return gf("",{pathname:u,search:p,hash:m},r.state&&r.state.usr||null,r.state&&r.state.key||"default",d?{pathname:l.location.pathname,search:l.location.search,hash:l.location.hash}:void 0)}function i(l,r){return typeof r=="string"?r:al(r)}return yT(a,i,null,n)}function ft(n,a){if(n===!1||n===null||typeof n>"u")throw new Error(a)}function Un(n,a){if(!n){typeof console<"u"&&console.warn(a);try{throw new Error(a)}catch{}}}function vT(){return Math.random().toString(36).substring(2,10)}function ny(n,a){return{usr:n.state,key:n.key,idx:a,masked:n.unstable_mask?{pathname:n.pathname,search:n.search,hash:n.hash}:void 0}}function gf(n,a,i=null,l,r){return{pathname:typeof n=="string"?n:n.pathname,search:"",hash:"",...typeof a=="string"?Vi(a):a,state:i,key:a&&a.key||l||vT(),unstable_mask:r}}function al({pathname:n="/",search:a="",hash:i=""}){return a&&a!=="?"&&(n+=a.charAt(0)==="?"?a:"?"+a),i&&i!=="#"&&(n+=i.charAt(0)==="#"?i:"#"+i),n}function Vi(n){let a={};if(n){let i=n.indexOf("#");i>=0&&(a.hash=n.substring(i),n=n.substring(0,i));let l=n.indexOf("?");l>=0&&(a.search=n.substring(l),n=n.substring(0,l)),n&&(a.pathname=n)}return a}function yT(n,a,i,l={}){let{window:r=document.defaultView,v5Compat:d=!1}=l,u=r.history,p="POP",m=null,g=y();g==null&&(g=0,u.replaceState({...u.state,idx:g},""));function y(){return(u.state||{idx:null}).idx}function v(){p="POP";let E=y(),k=E==null?null:E-g;g=E,m&&m({action:p,location:w.location,delta:k})}function x(E,k){p="PUSH";let N=ty(E)?E:gf(w.location,E,k);g=y()+1;let j=ny(N,g),U=w.createHref(N.unstable_mask||N);try{u.pushState(j,"",U)}catch(L){if(L instanceof DOMException&&L.name==="DataCloneError")throw L;r.location.assign(U)}d&&m&&m({action:p,location:w.location,delta:1})}function S(E,k){p="REPLACE";let N=ty(E)?E:gf(w.location,E,k);g=y();let j=ny(N,g),U=w.createHref(N.unstable_mask||N);u.replaceState(j,"",U),d&&m&&m({action:p,location:w.location,delta:0})}function C(E){return bT(E)}let w={get action(){return p},get location(){return n(r,u)},listen(E){if(m)throw new Error("A history only accepts one active listener");return r.addEventListener(ey,v),m=E,()=>{r.removeEventListener(ey,v),m=null}},createHref(E){return a(r,E)},createURL:C,encodeLocation(E){let k=C(E);return{pathname:k.pathname,search:k.search,hash:k.hash}},push:x,replace:S,go(E){return u.go(E)}};return w}function bT(n,a=!1){let i="http://localhost";typeof window<"u"&&(i=window.location.origin!=="null"?window.location.origin:window.location.href),ft(i,"No window.location.(origin|href) available to create URL");let l=typeof n=="string"?n:al(n);return l=l.replace(/ $/,"%20"),!a&&l.startsWith("//")&&(l=i+l),new URL(l,i)}function Q0(n,a,i="/"){return xT(n,a,i,!1)}function xT(n,a,i,l){let r=typeof a=="string"?Vi(a):a,d=Ea(r.pathname||"/",i);if(d==null)return null;let u=W0(n);_T(u);let p=null;for(let m=0;p==null&&m<u.length;++m){let g=eb(d);p=jT(u[m],g,l)}return p}function W0(n,a=[],i=[],l="",r=!1){let d=(u,p,m=r,g)=>{let y={relativePath:g===void 0?u.path||"":g,caseSensitive:u.caseSensitive===!0,childrenIndex:p,route:u};if(y.relativePath.startsWith("/")){if(!y.relativePath.startsWith(l)&&m)return;ft(y.relativePath.startsWith(l),`Absolute route path "${y.relativePath}" nested under path "${l}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),y.relativePath=y.relativePath.slice(l.length)}let v=ta([l,y.relativePath]),x=i.concat(y);u.children&&u.children.length>0&&(ft(u.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${v}".`),W0(u.children,a,x,v,m)),!(u.path==null&&!u.index)&&a.push({path:v,score:NT(v,u.index),routesMeta:x})};return n.forEach((u,p)=>{var m;if(u.path===""||!((m=u.path)!=null&&m.includes("?")))d(u,p);else for(let g of J0(u.path))d(u,p,!0,g)}),a}function J0(n){let a=n.split("/");if(a.length===0)return[];let[i,...l]=a,r=i.endsWith("?"),d=i.replace(/\?$/,"");if(l.length===0)return r?[d,""]:[d];let u=J0(l.join("/")),p=[];return p.push(...u.map(m=>m===""?d:[d,m].join("/"))),r&&p.push(...u),p.map(m=>n.startsWith("/")&&m===""?"/":m)}function _T(n){n.sort((a,i)=>a.score!==i.score?i.score-a.score:AT(a.routesMeta.map(l=>l.childrenIndex),i.routesMeta.map(l=>l.childrenIndex)))}var ST=/^:[\w-]+$/,TT=3,kT=2,CT=1,wT=10,ET=-2,ay=n=>n==="*";function NT(n,a){let i=n.split("/"),l=i.length;return i.some(ay)&&(l+=ET),a&&(l+=kT),i.filter(r=>!ay(r)).reduce((r,d)=>r+(ST.test(d)?TT:d===""?CT:wT),l)}function AT(n,a){return n.length===a.length&&n.slice(0,-1).every((l,r)=>l===a[r])?n[n.length-1]-a[a.length-1]:0}function jT(n,a,i=!1){let{routesMeta:l}=n,r={},d="/",u=[];for(let p=0;p<l.length;++p){let m=l[p],g=p===l.length-1,y=d==="/"?a:a.slice(d.length)||"/",v=sl({path:m.relativePath,caseSensitive:m.caseSensitive,end:g},y),x=m.route;if(!v&&g&&i&&!l[l.length-1].route.index&&(v=sl({path:m.relativePath,caseSensitive:m.caseSensitive,end:!1},y)),!v)return null;Object.assign(r,v.params),u.push({params:r,pathname:ta([d,v.pathname]),pathnameBase:OT(ta([d,v.pathnameBase])),route:x}),v.pathnameBase!=="/"&&(d=ta([d,v.pathnameBase]))}return u}function sl(n,a){typeof n=="string"&&(n={path:n,caseSensitive:!1,end:!0});let[i,l]=DT(n.path,n.caseSensitive,n.end),r=a.match(i);if(!r)return null;let d=r[0],u=d.replace(/(.)\/+$/,"$1"),p=r.slice(1);return{params:l.reduce((g,{paramName:y,isOptional:v},x)=>{if(y==="*"){let C=p[x]||"";u=d.slice(0,d.length-C.length).replace(/(.)\/+$/,"$1")}const S=p[x];return v&&!S?g[y]=void 0:g[y]=(S||"").replace(/%2F/g,"/"),g},{}),pathname:d,pathnameBase:u,pattern:n}}function DT(n,a=!1,i=!0){Un(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 l=[],r="^"+n.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(u,p,m,g,y)=>{if(l.push({paramName:p,isOptional:m!=null}),m){let v=y.charAt(g+u.length);return v&&v!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return n.endsWith("*")?(l.push({paramName:"*"}),r+=n==="*"||n==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):i?r+="\\/*$":n!==""&&n!=="/"&&(r+="(?:(?=\\/|$))"),[new RegExp(r,a?void 0:"i"),l]}function eb(n){try{return n.split("/").map(a=>decodeURIComponent(a).replace(/\//g,"%2F")).join("/")}catch(a){return Un(!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 (${a}).`),n}}function Ea(n,a){if(a==="/")return n;if(!n.toLowerCase().startsWith(a.toLowerCase()))return null;let i=a.endsWith("/")?a.length-1:a.length,l=n.charAt(i);return l&&l!=="/"?null:n.slice(i)||"/"}var MT=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function RT(n,a="/"){let{pathname:i,search:l="",hash:r=""}=typeof n=="string"?Vi(n):n,d;return i?(i=i.replace(/\/\/+/g,"/"),i.startsWith("/")?d=sy(i.substring(1),"/"):d=sy(i,a)):d=a,{pathname:d,search:IT(l),hash:LT(r)}}function sy(n,a){let i=a.replace(/\/+$/,"").split("/");return n.split("/").forEach(r=>{r===".."?i.length>1&&i.pop():r!=="."&&i.push(r)}),i.length>1?i.join("/"):"/"}function Gd(n,a,i,l){return`Cannot include a '${n}' character in a manually specified \`to.${a}\` field [${JSON.stringify(l)}]. 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 BT(n){return n.filter((a,i)=>i===0||a.route.path&&a.route.path.length>0)}function Qf(n){let a=BT(n);return a.map((i,l)=>l===a.length-1?i.pathname:i.pathnameBase)}function fc(n,a,i,l=!1){let r;typeof n=="string"?r=Vi(n):(r={...n},ft(!r.pathname||!r.pathname.includes("?"),Gd("?","pathname","search",r)),ft(!r.pathname||!r.pathname.includes("#"),Gd("#","pathname","hash",r)),ft(!r.search||!r.search.includes("#"),Gd("#","search","hash",r)));let d=n===""||r.pathname==="",u=d?"/":r.pathname,p;if(u==null)p=i;else{let v=a.length-1;if(!l&&u.startsWith("..")){let x=u.split("/");for(;x[0]==="..";)x.shift(),v-=1;r.pathname=x.join("/")}p=v>=0?a[v]:"/"}let m=RT(r,p),g=u&&u!=="/"&&u.endsWith("/"),y=(d||u===".")&&i.endsWith("/");return!m.pathname.endsWith("/")&&(g||y)&&(m.pathname+="/"),m}var ta=n=>n.join("/").replace(/\/\/+/g,"/"),OT=n=>n.replace(/\/+$/,"").replace(/^\/*/,"/"),IT=n=>!n||n==="?"?"":n.startsWith("?")?n:"?"+n,LT=n=>!n||n==="#"?"":n.startsWith("#")?n:"#"+n,zT=class{constructor(n,a,i,l=!1){this.status=n,this.statusText=a||"",this.internal=l,i instanceof Error?(this.data=i.toString(),this.error=i):this.data=i}};function UT(n){return n!=null&&typeof n.status=="number"&&typeof n.statusText=="string"&&typeof n.internal=="boolean"&&"data"in n}function VT(n){return n.map(a=>a.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var tb=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function nb(n,a){let i=n;if(typeof i!="string"||!MT.test(i))return{absoluteURL:void 0,isExternal:!1,to:i};let l=i,r=!1;if(tb)try{let d=new URL(window.location.href),u=i.startsWith("//")?new URL(d.protocol+i):new URL(i),p=Ea(u.pathname,a);u.origin===d.origin&&p!=null?i=p+u.search+u.hash:r=!0}catch{Un(!1,`<Link to="${i}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:l,isExternal:r,to:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var ab=["POST","PUT","PATCH","DELETE"];new Set(ab);var HT=["GET",...ab];new Set(HT);var Hi=b.createContext(null);Hi.displayName="DataRouter";var hc=b.createContext(null);hc.displayName="DataRouterState";var GT=b.createContext(!1),sb=b.createContext({isTransitioning:!1});sb.displayName="ViewTransition";var PT=b.createContext(new Map);PT.displayName="Fetchers";var $T=b.createContext(null);$T.displayName="Await";var Cn=b.createContext(null);Cn.displayName="Navigation";var dl=b.createContext(null);dl.displayName="Location";var Vn=b.createContext({outlet:null,matches:[],isDataRoute:!1});Vn.displayName="Route";var Wf=b.createContext(null);Wf.displayName="RouteError";var ib="REACT_ROUTER_ERROR",FT="REDIRECT",qT="ROUTE_ERROR_RESPONSE";function YT(n){if(n.startsWith(`${ib}:${FT}:{`))try{let a=JSON.parse(n.slice(28));if(typeof a=="object"&&a&&typeof a.status=="number"&&typeof a.statusText=="string"&&typeof a.location=="string"&&typeof a.reloadDocument=="boolean"&&typeof a.replace=="boolean")return a}catch{}}function KT(n){if(n.startsWith(`${ib}:${qT}:{`))try{let a=JSON.parse(n.slice(40));if(typeof a=="object"&&a&&typeof a.status=="number"&&typeof a.statusText=="string")return new zT(a.status,a.statusText,a.data)}catch{}}function ZT(n,{relative:a}={}){ft(Vs(),"useHref() may be used only in the context of a <Router> component.");let{basename:i,navigator:l}=b.useContext(Cn),{hash:r,pathname:d,search:u}=hl(n,{relative:a}),p=d;return i!=="/"&&(p=d==="/"?i:ta([i,d])),l.createHref({pathname:p,search:u,hash:r})}function Vs(){return b.useContext(dl)!=null}function Vt(){return ft(Vs(),"useLocation() may be used only in the context of a <Router> component."),b.useContext(dl).location}function kt(n){ft(Vs(),"useMatch() may be used only in the context of a <Router> component.");let{pathname:a}=Vt();return b.useMemo(()=>sl(n,eb(a)),[a,n])}var ob="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function lb(n){b.useContext(Cn).static||b.useLayoutEffect(n)}function pc(){let{isDataRoute:n}=b.useContext(Vn);return n?uk():XT()}function XT(){ft(Vs(),"useNavigate() may be used only in the context of a <Router> component.");let n=b.useContext(Hi),{basename:a,navigator:i}=b.useContext(Cn),{matches:l}=b.useContext(Vn),{pathname:r}=Vt(),d=JSON.stringify(Qf(l)),u=b.useRef(!1);return lb(()=>{u.current=!0}),b.useCallback((m,g={})=>{if(Un(u.current,ob),!u.current)return;if(typeof m=="number"){i.go(m);return}let y=fc(m,JSON.parse(d),r,g.relative==="path");n==null&&a!=="/"&&(y.pathname=y.pathname==="/"?a:ta([a,y.pathname])),(g.replace?i.replace:i.push)(y,g.state,g)},[a,i,d,r,n])}var QT=b.createContext(null);function WT(n){let a=b.useContext(Vn).outlet;return b.useMemo(()=>a&&b.createElement(QT.Provider,{value:n},a),[a,n])}function fl(){let{matches:n}=b.useContext(Vn),a=n[n.length-1];return a?a.params:{}}function hl(n,{relative:a}={}){let{matches:i}=b.useContext(Vn),{pathname:l}=Vt(),r=JSON.stringify(Qf(i));return b.useMemo(()=>fc(n,JSON.parse(r),l,a==="path"),[n,r,l,a])}function JT(n,a){return rb(n,a)}function rb(n,a,i){var E;ft(Vs(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:l}=b.useContext(Cn),{matches:r}=b.useContext(Vn),d=r[r.length-1],u=d?d.params:{},p=d?d.pathname:"/",m=d?d.pathnameBase:"/",g=d&&d.route;{let k=g&&g.path||"";ub(p,!g||k.endsWith("*")||k.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${p}" (under <Route path="${k}">) 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.
35
35
 
36
- Please change the parent <Route path="${k}"> to <Route path="${k==="/"?"*":`${k}/*`}">.`)}let y=Vt(),v;if(a){let k=typeof a=="string"?Vi(a):a;ft(m==="/"||((E=k.pathname)==null?void 0:E.startsWith(m)),`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 "${m}" but pathname "${k.pathname}" was given in the \`location\` prop.`),v=k}else v=y;let x=v.pathname||"/",S=x;if(m!=="/"){let k=m.replace(/^\//,"").split("/");S="/"+x.replace(/^\//,"").split("/").slice(k.length).join("/")}let C=Q0(n,{pathname:S});Un(g||C!=null,`No routes matched location "${v.pathname}${v.search}${v.hash}" `),Un(C==null||C[C.length-1].route.element!==void 0||C[C.length-1].route.Component!==void 0||C[C.length-1].route.lazy!==void 0,`Matched leaf route at location "${v.pathname}${v.search}${v.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 w=sk(C&&C.map(k=>Object.assign({},k,{params:Object.assign({},u,k.params),pathname:ta([m,l.encodeLocation?l.encodeLocation(k.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:k.pathname]),pathnameBase:k.pathnameBase==="/"?m:ta([m,l.encodeLocation?l.encodeLocation(k.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:k.pathnameBase])})),r,i);return a&&w?b.createElement(dl.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...v},navigationType:"POP"}},w):w}function ek(){let n=ck(),a=UT(n)?`${n.status} ${n.statusText}`:n instanceof Error?n.message:JSON.stringify(n),i=n instanceof Error?n.stack:null,l="rgba(200,200,200, 0.5)",r={padding:"0.5rem",backgroundColor:l},d={padding:"2px 4px",backgroundColor:l},u=null;return console.error("Error handled by React Router default ErrorBoundary:",n),u=b.createElement(b.Fragment,null,b.createElement("p",null,"💿 Hey developer 👋"),b.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",b.createElement("code",{style:d},"ErrorBoundary")," or"," ",b.createElement("code",{style:d},"errorElement")," prop on your route.")),b.createElement(b.Fragment,null,b.createElement("h2",null,"Unexpected Application Error!"),b.createElement("h3",{style:{fontStyle:"italic"}},a),i?b.createElement("pre",{style:r},i):null,u)}var tk=b.createElement(ek,null),cb=class extends b.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,a){return a.location!==n.location||a.revalidation!=="idle"&&n.revalidation==="idle"?{error:n.error,location:n.location,revalidation:n.revalidation}:{error:n.error!==void 0?n.error:a.error,location:a.location,revalidation:n.revalidation||a.revalidation}}componentDidCatch(n,a){this.props.onError?this.props.onError(n,a):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=KT(n.digest);i&&(n=i)}let a=n!==void 0?b.createElement(Vn.Provider,{value:this.props.routeContext},b.createElement(Wf.Provider,{value:n,children:this.props.component})):this.props.children;return this.context?b.createElement(nk,{error:n},a):a}};cb.contextType=GT;var Pd=new WeakMap;function nk({children:n,error:a}){let{basename:i}=b.useContext(Cn);if(typeof a=="object"&&a&&"digest"in a&&typeof a.digest=="string"){let l=YT(a.digest);if(l){let r=Pd.get(a);if(r)throw r;let d=nb(l.location,i);if(tb&&!Pd.get(a))if(d.isExternal||l.reloadDocument)window.location.href=d.absoluteURL||d.to;else{const u=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(d.to,{replace:l.replace}));throw Pd.set(a,u),u}return b.createElement("meta",{httpEquiv:"refresh",content:`0;url=${d.absoluteURL||d.to}`})}}return n}function ak({routeContext:n,match:a,children:i}){let l=b.useContext(Hi);return l&&l.static&&l.staticContext&&(a.route.errorElement||a.route.ErrorBoundary)&&(l.staticContext._deepestRenderedBoundaryId=a.route.id),b.createElement(Vn.Provider,{value:n},i)}function sk(n,a=[],i){let l=i==null?void 0:i.state;if(n==null){if(!l)return null;if(l.errors)n=l.matches;else if(a.length===0&&!l.initialized&&l.matches.length>0)n=l.matches;else return null}let r=n,d=l==null?void 0:l.errors;if(d!=null){let y=r.findIndex(v=>v.route.id&&(d==null?void 0:d[v.route.id])!==void 0);ft(y>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(d).join(",")}`),r=r.slice(0,Math.min(r.length,y+1))}let u=!1,p=-1;if(i&&l){u=l.renderFallback;for(let y=0;y<r.length;y++){let v=r[y];if((v.route.HydrateFallback||v.route.hydrateFallbackElement)&&(p=y),v.route.id){let{loaderData:x,errors:S}=l,C=v.route.loader&&!x.hasOwnProperty(v.route.id)&&(!S||S[v.route.id]===void 0);if(v.route.lazy||C){i.isStatic&&(u=!0),p>=0?r=r.slice(0,p+1):r=[r[0]];break}}}}let m=i==null?void 0:i.onError,g=l&&m?(y,v)=>{var x,S;m(y,{location:l.location,params:((S=(x=l.matches)==null?void 0:x[0])==null?void 0:S.params)??{},unstable_pattern:VT(l.matches),errorInfo:v})}:void 0;return r.reduceRight((y,v,x)=>{let S,C=!1,w=null,E=null;l&&(S=d&&v.route.id?d[v.route.id]:void 0,w=v.route.errorElement||tk,u&&(p<0&&x===0?(ub("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),C=!0,E=null):p===x&&(C=!0,E=v.route.hydrateFallbackElement||null)));let k=a.concat(r.slice(0,x+1)),N=()=>{let j;return S?j=w:C?j=E:v.route.Component?j=b.createElement(v.route.Component,null):v.route.element?j=v.route.element:j=y,b.createElement(ak,{match:v,routeContext:{outlet:y,matches:k,isDataRoute:l!=null},children:j})};return l&&(v.route.ErrorBoundary||v.route.errorElement||x===0)?b.createElement(cb,{location:l.location,revalidation:l.revalidation,component:w,error:S,children:N(),routeContext:{outlet:null,matches:k,isDataRoute:!0},onError:g}):N()},null)}function Jf(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ik(n){let a=b.useContext(Hi);return ft(a,Jf(n)),a}function ok(n){let a=b.useContext(hc);return ft(a,Jf(n)),a}function lk(n){let a=b.useContext(Vn);return ft(a,Jf(n)),a}function eh(n){let a=lk(n),i=a.matches[a.matches.length-1];return ft(i.route.id,`${n} can only be used on routes that contain a unique "id"`),i.route.id}function rk(){return eh("useRouteId")}function ck(){var l;let n=b.useContext(Wf),a=ok("useRouteError"),i=eh("useRouteError");return n!==void 0?n:(l=a.errors)==null?void 0:l[i]}function uk(){let{router:n}=ik("useNavigate"),a=eh("useNavigate"),i=b.useRef(!1);return lb(()=>{i.current=!0}),b.useCallback(async(r,d={})=>{Un(i.current,ob),i.current&&(typeof r=="number"?await n.navigate(r):await n.navigate(r,{fromRouteId:a,...d}))},[n,a])}var iy={};function ub(n,a,i){!a&&!iy[n]&&(iy[n]=!0,Un(!1,i))}b.memo(dk);function dk({routes:n,future:a,state:i,isStatic:l,onError:r}){return rb(n,void 0,{state:i,isStatic:l,onError:r})}function Zo({to:n,replace:a,state:i,relative:l}){ft(Vs(),"<Navigate> may be used only in the context of a <Router> component.");let{static:r}=b.useContext(Cn);Un(!r,"<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:d}=b.useContext(Vn),{pathname:u}=Vt(),p=pc(),m=fc(n,Qf(d),u,l==="path"),g=JSON.stringify(m);return b.useEffect(()=>{p(JSON.parse(g),{replace:a,state:i,relative:l})},[p,g,l,a,i]),null}function db(n){return WT(n.context)}function Qe(n){ft(!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 fk({basename:n="/",children:a=null,location:i,navigationType:l="POP",navigator:r,static:d=!1,unstable_useTransitions:u}){ft(!Vs(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let p=n.replace(/^\/*/,"/"),m=b.useMemo(()=>({basename:p,navigator:r,static:d,unstable_useTransitions:u,future:{}}),[p,r,d,u]);typeof i=="string"&&(i=Vi(i));let{pathname:g="/",search:y="",hash:v="",state:x=null,key:S="default",unstable_mask:C}=i,w=b.useMemo(()=>{let E=Ea(g,p);return E==null?null:{location:{pathname:E,search:y,hash:v,state:x,key:S,unstable_mask:C},navigationType:l}},[p,g,y,v,x,S,l,C]);return Un(w!=null,`<Router basename="${p}"> is not able to match the URL "${g}${y}${v}" because it does not start with the basename, so the <Router> won't render anything.`),w==null?null:b.createElement(Cn.Provider,{value:m},b.createElement(dl.Provider,{children:a,value:w}))}function hk({children:n,location:a}){return JT(vf(n),a)}function vf(n,a=[]){let i=[];return b.Children.forEach(n,(l,r)=>{if(!b.isValidElement(l))return;let d=[...a,r];if(l.type===b.Fragment){i.push.apply(i,vf(l.props.children,d));return}ft(l.type===Qe,`[${typeof l.type=="string"?l.type:l.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),ft(!l.props.index||!l.props.children,"An index route cannot have child routes.");let u={id:l.props.id||d.join("-"),caseSensitive:l.props.caseSensitive,element:l.props.element,Component:l.props.Component,index:l.props.index,path:l.props.path,middleware:l.props.middleware,loader:l.props.loader,action:l.props.action,hydrateFallbackElement:l.props.hydrateFallbackElement,HydrateFallback:l.props.HydrateFallback,errorElement:l.props.errorElement,ErrorBoundary:l.props.ErrorBoundary,hasErrorBoundary:l.props.hasErrorBoundary===!0||l.props.ErrorBoundary!=null||l.props.errorElement!=null,shouldRevalidate:l.props.shouldRevalidate,handle:l.props.handle,lazy:l.props.lazy};l.props.children&&(u.children=vf(l.props.children,d)),i.push(u)}),i}var Fr="get",qr="application/x-www-form-urlencoded";function mc(n){return typeof HTMLElement<"u"&&n instanceof HTMLElement}function pk(n){return mc(n)&&n.tagName.toLowerCase()==="button"}function mk(n){return mc(n)&&n.tagName.toLowerCase()==="form"}function gk(n){return mc(n)&&n.tagName.toLowerCase()==="input"}function vk(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function yk(n,a){return n.button===0&&(!a||a==="_self")&&!vk(n)}function yf(n=""){return new URLSearchParams(typeof n=="string"||Array.isArray(n)||n instanceof URLSearchParams?n:Object.keys(n).reduce((a,i)=>{let l=n[i];return a.concat(Array.isArray(l)?l.map(r=>[i,r]):[[i,l]])},[]))}function bk(n,a){let i=yf(n);return a&&a.forEach((l,r)=>{i.has(r)||a.getAll(r).forEach(d=>{i.append(r,d)})}),i}var Or=null;function xk(){if(Or===null)try{new FormData(document.createElement("form"),0),Or=!1}catch{Or=!0}return Or}var _k=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function $d(n){return n!=null&&!_k.has(n)?(Un(!1,`"${n}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${qr}"`),null):n}function Sk(n,a){let i,l,r,d,u;if(mk(n)){let p=n.getAttribute("action");l=p?Ea(p,a):null,i=n.getAttribute("method")||Fr,r=$d(n.getAttribute("enctype"))||qr,d=new FormData(n)}else if(pk(n)||gk(n)&&(n.type==="submit"||n.type==="image")){let p=n.form;if(p==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let m=n.getAttribute("formaction")||p.getAttribute("action");if(l=m?Ea(m,a):null,i=n.getAttribute("formmethod")||p.getAttribute("method")||Fr,r=$d(n.getAttribute("formenctype"))||$d(p.getAttribute("enctype"))||qr,d=new FormData(p,n),!xk()){let{name:g,type:y,value:v}=n;if(y==="image"){let x=g?`${g}.`:"";d.append(`${x}x`,"0"),d.append(`${x}y`,"0")}else g&&d.append(g,v)}}else{if(mc(n))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');i=Fr,l=null,r=qr,u=n}return d&&r==="text/plain"&&(u=d,d=void 0),{action:l,method:i.toLowerCase(),encType:r,formData:d,body:u}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function th(n,a){if(n===!1||n===null||typeof n>"u")throw new Error(a)}function Tk(n,a,i,l){let r=typeof n=="string"?new URL(n,typeof window>"u"?"server://singlefetch/":window.location.origin):n;return i?r.pathname.endsWith("/")?r.pathname=`${r.pathname}_.${l}`:r.pathname=`${r.pathname}.${l}`:r.pathname==="/"?r.pathname=`_root.${l}`:a&&Ea(r.pathname,a)==="/"?r.pathname=`${a.replace(/\/$/,"")}/_root.${l}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${l}`,r}async function kk(n,a){if(n.id in a)return a[n.id];try{let i=await import(n.module);return a[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 Ck(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 wk(n,a,i){let l=await Promise.all(n.map(async r=>{let d=a.routes[r.route.id];if(d){let u=await kk(d,i);return u.links?u.links():[]}return[]}));return jk(l.flat(1).filter(Ck).filter(r=>r.rel==="stylesheet"||r.rel==="preload").map(r=>r.rel==="stylesheet"?{...r,rel:"prefetch",as:"style"}:{...r,rel:"prefetch"}))}function oy(n,a,i,l,r,d){let u=(m,g)=>i[g]?m.route.id!==i[g].route.id:!0,p=(m,g)=>{var y;return i[g].pathname!==m.pathname||((y=i[g].route.path)==null?void 0:y.endsWith("*"))&&i[g].params["*"]!==m.params["*"]};return d==="assets"?a.filter((m,g)=>u(m,g)||p(m,g)):d==="data"?a.filter((m,g)=>{var v;let y=l.routes[m.route.id];if(!y||!y.hasLoader)return!1;if(u(m,g)||p(m,g))return!0;if(m.route.shouldRevalidate){let x=m.route.shouldRevalidate({currentUrl:new URL(r.pathname+r.search+r.hash,window.origin),currentParams:((v=i[0])==null?void 0:v.params)||{},nextUrl:new URL(n,window.origin),nextParams:m.params,defaultShouldRevalidate:!0});if(typeof x=="boolean")return x}return!0}):[]}function Ek(n,a,{includeHydrateFallback:i}={}){return Nk(n.map(l=>{let r=a.routes[l.route.id];if(!r)return[];let d=[r.module];return r.clientActionModule&&(d=d.concat(r.clientActionModule)),r.clientLoaderModule&&(d=d.concat(r.clientLoaderModule)),i&&r.hydrateFallbackModule&&(d=d.concat(r.hydrateFallbackModule)),r.imports&&(d=d.concat(r.imports)),d}).flat(1))}function Nk(n){return[...new Set(n)]}function Ak(n){let a={},i=Object.keys(n).sort();for(let l of i)a[l]=n[l];return a}function jk(n,a){let i=new Set;return new Set(a),n.reduce((l,r)=>{let d=JSON.stringify(Ak(r));return i.has(d)||(i.add(d),l.push({key:d,link:r})),l},[])}function fb(){let n=b.useContext(Hi);return th(n,"You must render this element inside a <DataRouterContext.Provider> element"),n}function Dk(){let n=b.useContext(hc);return th(n,"You must render this element inside a <DataRouterStateContext.Provider> element"),n}var nh=b.createContext(void 0);nh.displayName="FrameworkContext";function hb(){let n=b.useContext(nh);return th(n,"You must render this element inside a <HydratedRouter> element"),n}function Mk(n,a){let i=b.useContext(nh),[l,r]=b.useState(!1),[d,u]=b.useState(!1),{onFocus:p,onBlur:m,onMouseEnter:g,onMouseLeave:y,onTouchStart:v}=a,x=b.useRef(null);b.useEffect(()=>{if(n==="render"&&u(!0),n==="viewport"){let w=k=>{k.forEach(N=>{u(N.isIntersecting)})},E=new IntersectionObserver(w,{threshold:.5});return x.current&&E.observe(x.current),()=>{E.disconnect()}}},[n]),b.useEffect(()=>{if(l){let w=setTimeout(()=>{u(!0)},100);return()=>{clearTimeout(w)}}},[l]);let S=()=>{r(!0)},C=()=>{r(!1),u(!1)};return i?n!=="intent"?[d,x,{}]:[d,x,{onFocus:Uo(p,S),onBlur:Uo(m,C),onMouseEnter:Uo(g,S),onMouseLeave:Uo(y,C),onTouchStart:Uo(v,S)}]:[!1,x,{}]}function Uo(n,a){return i=>{n&&n(i),i.defaultPrevented||a(i)}}function Rk({page:n,...a}){let{router:i}=fb(),l=b.useMemo(()=>Q0(i.routes,n,i.basename),[i.routes,n,i.basename]);return l?b.createElement(Ok,{page:n,matches:l,...a}):null}function Bk(n){let{manifest:a,routeModules:i}=hb(),[l,r]=b.useState([]);return b.useEffect(()=>{let d=!1;return wk(n,a,i).then(u=>{d||r(u)}),()=>{d=!0}},[n,a,i]),l}function Ok({page:n,matches:a,...i}){let l=Vt(),{future:r,manifest:d,routeModules:u}=hb(),{basename:p}=fb(),{loaderData:m,matches:g}=Dk(),y=b.useMemo(()=>oy(n,a,g,d,l,"data"),[n,a,g,d,l]),v=b.useMemo(()=>oy(n,a,g,d,l,"assets"),[n,a,g,d,l]),x=b.useMemo(()=>{if(n===l.pathname+l.search+l.hash)return[];let w=new Set,E=!1;if(a.forEach(N=>{var U;let j=d.routes[N.route.id];!j||!j.hasLoader||(!y.some(L=>L.route.id===N.route.id)&&N.route.id in m&&((U=u[N.route.id])!=null&&U.shouldRevalidate)||j.hasClientLoader?E=!0:w.add(N.route.id))}),w.size===0)return[];let k=Tk(n,p,r.unstable_trailingSlashAwareDataRequests,"data");return E&&w.size>0&&k.searchParams.set("_routes",a.filter(N=>w.has(N.route.id)).map(N=>N.route.id).join(",")),[k.pathname+k.search]},[p,r.unstable_trailingSlashAwareDataRequests,m,l,d,y,a,n,u]),S=b.useMemo(()=>Ek(v,d),[v,d]),C=Bk(v);return b.createElement(b.Fragment,null,x.map(w=>b.createElement("link",{key:w,rel:"prefetch",as:"fetch",href:w,...i})),S.map(w=>b.createElement("link",{key:w,rel:"modulepreload",href:w,...i})),C.map(({key:w,link:E})=>b.createElement("link",{key:w,nonce:i.nonce,...E,crossOrigin:E.crossOrigin??i.crossOrigin})))}function Ik(...n){return a=>{n.forEach(i=>{typeof i=="function"?i(a):i!=null&&(i.current=a)})}}var Lk=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Lk&&(window.__reactRouterVersion="7.13.1")}catch{}function zk({basename:n,children:a,unstable_useTransitions:i,window:l}){let r=b.useRef();r.current==null&&(r.current=gT({window:l,v5Compat:!0}));let d=r.current,[u,p]=b.useState({action:d.action,location:d.location}),m=b.useCallback(g=>{i===!1?p(g):b.startTransition(()=>p(g))},[i]);return b.useLayoutEffect(()=>d.listen(m),[d,m]),b.createElement(fk,{basename:n,children:a,location:u.location,navigationType:u.action,navigator:d,unstable_useTransitions:i})}var pb=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ah=b.forwardRef(function({onClick:a,discover:i="render",prefetch:l="none",relative:r,reloadDocument:d,replace:u,unstable_mask:p,state:m,target:g,to:y,preventScrollReset:v,viewTransition:x,unstable_defaultShouldRevalidate:S,...C},w){let{basename:E,navigator:k,unstable_useTransitions:N}=b.useContext(Cn),j=typeof y=="string"&&pb.test(y),U=nb(y,E);y=U.to;let L=ZT(y,{relative:r}),q=Vt(),R=null;if(p){let ie=fc(p,[],q.unstable_mask?q.unstable_mask.pathname:"/",!0);E!=="/"&&(ie.pathname=ie.pathname==="/"?E:ta([E,ie.pathname])),R=k.createHref(ie)}let[B,$,ae]=Mk(l,C),oe=Gk(y,{replace:u,unstable_mask:p,state:m,target:g,preventScrollReset:v,relative:r,viewTransition:x,unstable_defaultShouldRevalidate:S,unstable_useTransitions:N});function ne(ie){a&&a(ie),ie.defaultPrevented||oe(ie)}let ce=!(U.isExternal||d),Q=b.createElement("a",{...C,...ae,href:(ce?R:void 0)||U.absoluteURL||L,onClick:ce?ne:a,ref:Ik(w,$),target:g,"data-discover":!j&&i==="render"?"true":void 0});return B&&!j?b.createElement(b.Fragment,null,Q,b.createElement(Rk,{page:L})):Q});ah.displayName="Link";var Uk=b.forwardRef(function({"aria-current":a="page",caseSensitive:i=!1,className:l="",end:r=!1,style:d,to:u,viewTransition:p,children:m,...g},y){let v=hl(u,{relative:g.relative}),x=Vt(),S=b.useContext(hc),{navigator:C,basename:w}=b.useContext(Cn),E=S!=null&&Yk(v)&&p===!0,k=C.encodeLocation?C.encodeLocation(v).pathname:v.pathname,N=x.pathname,j=S&&S.navigation&&S.navigation.location?S.navigation.location.pathname:null;i||(N=N.toLowerCase(),j=j?j.toLowerCase():null,k=k.toLowerCase()),j&&w&&(j=Ea(j,w)||j);const U=k!=="/"&&k.endsWith("/")?k.length-1:k.length;let L=N===k||!r&&N.startsWith(k)&&N.charAt(U)==="/",q=j!=null&&(j===k||!r&&j.startsWith(k)&&j.charAt(k.length)==="/"),R={isActive:L,isPending:q,isTransitioning:E},B=L?a:void 0,$;typeof l=="function"?$=l(R):$=[l,L?"active":null,q?"pending":null,E?"transitioning":null].filter(Boolean).join(" ");let ae=typeof d=="function"?d(R):d;return b.createElement(ah,{...g,"aria-current":B,className:$,ref:y,style:ae,to:u,viewTransition:p},typeof m=="function"?m(R):m)});Uk.displayName="NavLink";var Vk=b.forwardRef(({discover:n="render",fetcherKey:a,navigate:i,reloadDocument:l,replace:r,state:d,method:u=Fr,action:p,onSubmit:m,relative:g,preventScrollReset:y,viewTransition:v,unstable_defaultShouldRevalidate:x,...S},C)=>{let{unstable_useTransitions:w}=b.useContext(Cn),E=Fk(),k=qk(p,{relative:g}),N=u.toLowerCase()==="get"?"get":"post",j=typeof p=="string"&&pb.test(p),U=L=>{if(m&&m(L),L.defaultPrevented)return;L.preventDefault();let q=L.nativeEvent.submitter,R=(q==null?void 0:q.getAttribute("formmethod"))||u,B=()=>E(q||L.currentTarget,{fetcherKey:a,method:R,navigate:i,replace:r,state:d,relative:g,preventScrollReset:y,viewTransition:v,unstable_defaultShouldRevalidate:x});w&&i!==!1?b.startTransition(()=>B()):B()};return b.createElement("form",{ref:C,method:N,action:k,onSubmit:l?m:U,...S,"data-discover":!j&&n==="render"?"true":void 0})});Vk.displayName="Form";function Hk(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function mb(n){let a=b.useContext(Hi);return ft(a,Hk(n)),a}function Gk(n,{target:a,replace:i,unstable_mask:l,state:r,preventScrollReset:d,relative:u,viewTransition:p,unstable_defaultShouldRevalidate:m,unstable_useTransitions:g}={}){let y=pc(),v=Vt(),x=hl(n,{relative:u});return b.useCallback(S=>{if(yk(S,a)){S.preventDefault();let C=i!==void 0?i:al(v)===al(x),w=()=>y(n,{replace:C,unstable_mask:l,state:r,preventScrollReset:d,relative:u,viewTransition:p,unstable_defaultShouldRevalidate:m});g?b.startTransition(()=>w()):w()}},[v,y,x,i,l,r,a,n,d,u,p,m,g])}function sh(n){Un(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 a=b.useRef(yf(n)),i=b.useRef(!1),l=Vt(),r=b.useMemo(()=>bk(l.search,i.current?null:a.current),[l.search]),d=pc(),u=b.useCallback((p,m)=>{const g=yf(typeof p=="function"?p(new URLSearchParams(r)):p);i.current=!0,d("?"+g,m)},[d,r]);return[r,u]}var Pk=0,$k=()=>`__${String(++Pk)}__`;function Fk(){let{router:n}=mb("useSubmit"),{basename:a}=b.useContext(Cn),i=rk(),l=n.fetch,r=n.navigate;return b.useCallback(async(d,u={})=>{let{action:p,method:m,encType:g,formData:y,body:v}=Sk(d,a);if(u.navigate===!1){let x=u.fetcherKey||$k();await l(x,i,u.action||p,{unstable_defaultShouldRevalidate:u.unstable_defaultShouldRevalidate,preventScrollReset:u.preventScrollReset,formData:y,body:v,formMethod:u.method||m,formEncType:u.encType||g,flushSync:u.flushSync})}else await r(u.action||p,{unstable_defaultShouldRevalidate:u.unstable_defaultShouldRevalidate,preventScrollReset:u.preventScrollReset,formData:y,body:v,formMethod:u.method||m,formEncType:u.encType||g,replace:u.replace,state:u.state,fromRouteId:i,flushSync:u.flushSync,viewTransition:u.viewTransition})},[l,r,a,i])}function qk(n,{relative:a}={}){let{basename:i}=b.useContext(Cn),l=b.useContext(Vn);ft(l,"useFormAction must be used inside a RouteContext");let[r]=l.matches.slice(-1),d={...hl(n||".",{relative:a})},u=Vt();if(n==null){d.search=u.search;let p=new URLSearchParams(d.search),m=p.getAll("index");if(m.some(y=>y==="")){p.delete("index"),m.filter(v=>v).forEach(v=>p.append("index",v));let y=p.toString();d.search=y?`?${y}`:""}}return(!n||n===".")&&r.route.index&&(d.search=d.search?d.search.replace(/^\?/,"?index&"):"?index"),i!=="/"&&(d.pathname=d.pathname==="/"?i:ta([i,d.pathname])),al(d)}function Yk(n,{relative:a}={}){let i=b.useContext(sb);ft(i!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:l}=mb("useViewTransitionState"),r=hl(n,{relative:a});if(!i.isTransitioning)return!1;let d=Ea(i.currentLocation.pathname,l)||i.currentLocation.pathname,u=Ea(i.nextLocation.pathname,l)||i.nextLocation.pathname;return sl(r.pathname,u)!=null||sl(r.pathname,d)!=null}function Wt(){const n=pc();return b.useCallback((a,i)=>{typeof a=="number"?n(a):n(a,i)},[n])}function ih(n){return`/sessions/${encodeURIComponent(n)}`}function Ii(n){return`/workspaces/${encodeURIComponent(n)}`}function Fn(n,a,i){const l=encodeURIComponent(n),r=i?`/workspaces/${encodeURIComponent(i)}/tasks/${l}`:`/tasks/${l}`;return a?`${r}/${a}`:r}function Kk(n,a){return a?`/workspaces/${encodeURIComponent(a)}/tasks/${encodeURIComponent(n)}/edit`:`/tasks/${encodeURIComponent(n)}/edit`}function Na(n,a){const i=new URLSearchParams;n&&i.set("workspace",n),a&&i.set("parent",a);const l=i.toString();return l?`/tasks/new?${l}`:"/tasks/new"}function gb(n){return`/sessions/new?${new URLSearchParams({env:n}).toString()}`}const ly="/environments/new";function Zk(n){return`/environments/${encodeURIComponent(n)}`}const Xo="/settings",bf="/settings/environments",Xk="/pair",Qk="/chat",Us="/",Wk="/tasks",Jk="/workspaces";function eC(n,a){const i=typeof window<"u"?`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}`:"ws://localhost:3000",l=b.useRef(void 0),[r,d]=b.useState(!1),u=b.useRef(a.onMessage);u.current=a.onMessage;const p=b.useRef(a.onConnect);p.current=a.onConnect;const m=b.useRef(a.onDisconnect);m.current=a.onDisconnect;const g=b.useCallback(y=>{var v;((v=l.current)==null?void 0:v.readyState)===WebSocket.OPEN&&l.current.send(JSON.stringify(y))},[]);return b.useEffect(()=>{let y,v;function x(){y=new WebSocket(i),l.current=y,y.onopen=()=>{d(!0),p.current(g)},y.onmessage=S=>{if(typeof S.data!="string"){console.warn("[ws] Received non-string WebSocket message; ignoring");return}const C=fT(S.data);C&&u.current(C)},y.onclose=S=>{var C;if(d(!1),l.current=void 0,(C=m.current)==null||C.call(m),clearTimeout(v),S.code===mT){window.location.href=Xk;return}v=setTimeout(x,pT)},y.onerror=()=>{y.close()}}return x(),()=>{clearTimeout(v),y==null||y.close()}},[i,g]),{connected:r,send:g}}const tC=5e3;function nC(n){const[a,i]=b.useState([]),[l,r]=b.useState({}),d=b.useCallback(x=>{switch(x.type){case"environment.added":return!0;case"environment.removed":{const S=x.payload.environmentId;return S&&(i(C=>C.filter(w=>w.id!==S)),r(C=>{const w={...C};return delete w[S],w})),n({type:"list_sessions"}),!0}case"environment.changed":return n({type:"list_environments"}),!0;case"environment.provision_progress":{const S=x.payload;if(typeof S.environmentId!="string"||typeof S.stage!="string"||typeof S.message!="string"||typeof S.progress!="number")return nl("environment.provision_progress","invalid payload"),!0;if(r(C=>({...C,[S.environmentId]:{stage:S.stage,message:S.message,progress:S.progress}})),S.stage==="ready"){const C=S.environmentId;setTimeout(()=>{r(w=>{const E={...w};return delete E[C],E})},tC)}return!0}default:return!1}},[n]),u=b.useCallback(x=>{var S;switch(x.type){case"environments":return i(ea((S=x.payload)==null?void 0:S.environments,aT,"environments","environments").map(sT)),!0;default:return!1}},[]),p=b.useCallback((x,S,C)=>{n({type:"add_environment",payload:{displayName:x,adapterType:S,adapterConfig:C||{}}})},[n]),m=b.useCallback((x,S)=>{const C={environmentId:x,...S};n({type:"update_environment",payload:C})},[n]),g=b.useCallback(x=>{n({type:"provision_environment",payload:{environmentId:x}})},[n]),y=b.useCallback(x=>{n({type:"stop_environment",payload:{environmentId:x}})},[n]),v=b.useCallback(x=>{n({type:"remove_environment",payload:{environmentId:x}})},[n]);return{environments:a,provisionStatus:l,addEnvironment:p,updateEnvironment:m,provisionEnvironment:g,stopEnvironment:y,removeEnvironment:v,handleMessage:u,handleEvent:d}}const Fd=new Set(["pending","running","idle"]),aC=new Set(["completed","failed","interrupted"]),ry=["pending","running","idle"];function sC(n){const[a,i]=b.useState([]),[l,r]=b.useState([]),[d,u]=b.useState(0),[p,m]=b.useState(void 0),[g,y]=b.useState({}),v=b.useCallback(N=>{var j,U,L,q,R;switch(N.type){case"sessions":return i(B=>{var oe;const $=ea((oe=N.payload)==null?void 0:oe.sessions,Qv,"sessions","sessions"),ae=new Map(B.map(ne=>[ne.id,ne.status]));return $.map(ne=>{const ce=ae.get(ne.id);return!ce||ce===ne.status?ne:aC.has(ce)&&Fd.has(ne.status)?{...ne,status:ce}:Fd.has(ce)&&Fd.has(ne.status)&&ry.indexOf(ce)>ry.indexOf(ne.status)?{...ne,status:ce}:ne})}),!0;case"session_event":{if(!Wv(N.payload))return nl("session_event","payload is not a valid SessionEvent"),!0;const B=N.payload;let $=0;if(r(ae=>{const oe=[...ae,B];return oe.length>wi?($=oe.length-wi,oe.slice(-wi)):oe}),$>0&&u(ae=>ae+$),B.eventType==="status"){const ae=hT(B.content);i(oe=>oe.some(ce=>ce.id===B.sessionId)?oe.map(ce=>ce.id===B.sessionId?{...ce,status:ae}:ce):[...oe,{id:B.sessionId,environmentId:"",runtime:"",status:ae,prompt:"",startedAt:B.timestamp}])}return!0}case"session_events":{const B=ea((j=N.payload)==null?void 0:j.events,Wv,"session_events","events"),$=(U=N.payload)==null?void 0:U.sessionId;if(typeof $!="string")return nl("session_events","missing or non-string sessionId"),!0;if(B.length>0){let ae=0;r(oe=>{const ne=new Set;for(const ie of oe)ie.sessionId===$&&ne.add(`${ie.timestamp}|${ie.eventType}`);const ce=B.filter(ie=>!ne.has(`${ie.timestamp}|${ie.eventType}`)),Q=[...oe,...ce].sort((ie,V)=>ie.sessionId!==V.sessionId?0:ie.timestamp.localeCompare(V.timestamp));return Q.length>wi?(ae=Q.length-wi,Q.slice(-wi)):Q}),ae>0&&u(oe=>oe+ae)}return!0}case"spawned":{const B=(L=N.payload)==null?void 0:L.sessionId;return typeof B=="string"&&B&&m(B),n({type:"list_sessions"}),!0}case"task_sessions":{const B=(q=N.payload)==null?void 0:q.taskId;if(typeof B!="string"||!B)return!0;const $=ea((R=N.payload)==null?void 0:R.sessions,Qv,"task_sessions","sessions");return y(ae=>({...ae,[B]:$})),!0}default:return!1}},[n]),x=b.useCallback((N,j,U,L)=>{n({type:"spawn",payload:{environmentId:N,prompt:j,personaId:U||"",worktreeBasePath:L||""}})},[n]),S=b.useCallback((N,j)=>{n({type:"send_input",payload:{sessionId:N,text:j}})},[n]),C=b.useCallback(N=>{n({type:"kill",payload:{sessionId:N}})},[n]),w=b.useCallback(N=>{n({type:"get_session_events",payload:{sessionId:N}})},[n]),E=b.useCallback(()=>{r([]),u(0)},[]),k=b.useCallback(N=>{n({type:"get_task_sessions",payload:{taskId:N}})},[n]);return{sessions:a,events:l,eventsDropped:d,lastSpawnedId:p,taskSessions:g,spawn:x,sendInput:S,kill:C,loadSessionEvents:w,clearEvents:E,loadTaskSessions:k,handleMessage:v}}function iC(n){const[a,i]=b.useState([]),[l,r]=b.useState(!1),d=b.useCallback(v=>{switch(v.type){case"workspace.created":return r(!1),n({type:"list_workspaces"}),!0;case"workspace.archived":case"workspace.updated":return n({type:"list_workspaces"}),!0;default:return!1}},[n]),u=b.useCallback(v=>{var x;switch(v.type){case"workspaces":return i(ea((x=v.payload)==null?void 0:x.workspaces,iT,"workspaces","workspaces")),!0;default:return!1}},[]),p=b.useCallback(()=>{r(!1)},[]),m=b.useCallback((v,x,S,C,w)=>{r(!0),n({type:"create_workspace",payload:{name:v,description:x||"",repoUrl:S||"",environmentId:C||"",defaultPersonaId:w||""}})},[n]),g=b.useCallback(v=>{n({type:"archive_workspace",payload:{workspaceId:v}})},[n]),y=b.useCallback((v,x)=>{n({type:"update_workspace",payload:{workspaceId:v,...x}})},[n]);return{workspaces:a,workspaceCreating:l,createWorkspace:m,archiveWorkspace:g,updateWorkspace:y,handleMessage:u,handleEvent:d,onDisconnect:p}}const oC=15e3;function lC(n){const[a,i]=b.useState([]),[l,r]=b.useState(void 0),d=b.useRef(new Map),u=b.useCallback(N=>{const j=N.payload;switch(N.type){case"task.created":{const U=typeof j.requestId=="string"?j.requestId:"";if(U){const q=d.current.get(U);q&&(clearTimeout(q.timer),d.current.delete(U),q.onSuccess())}const L=typeof j.workspaceId=="string"?j.workspaceId:"";return L&&n({type:"list_tasks",payload:{workspaceId:L}}),!0}case"task.started":{const U=typeof j.taskId=="string"?j.taskId:"",L=typeof j.sessionId=="string"?j.sessionId:"",q=typeof j.workspaceId=="string"?j.workspaceId:"";return r(R=>U&&R===U?void 0:R),L&&(n({type:"list_sessions"}),U&&i(R=>R.map(B=>B.id===U?{...B,latestSessionId:L}:B))),q?n({type:"list_tasks",payload:{workspaceId:q}}):U&&i(R=>{const B=R.find($=>$.id===U);return B!=null&&B.workspaceId?n({type:"list_tasks",payload:{workspaceId:B.workspaceId}}):n({type:"list_tasks",payload:{}}),R}),!0}case"task.completed":case"task.deleted":case"task.updated":{const U=typeof j.workspaceId=="string"?j.workspaceId:"",L=typeof j.taskId=="string"?j.taskId:"";return U?n({type:"list_tasks",payload:{workspaceId:U}}):L&&i(q=>{const R=q.find(B=>B.id===L);return R!=null&&R.workspaceId?n({type:"list_tasks",payload:{workspaceId:R.workspaceId}}):n({type:"list_tasks",payload:{}}),q}),!0}default:return!1}},[n]),p=b.useCallback(N=>{var j,U,L,q;switch(N.type){case"tasks":{const R=ea((j=N.payload)==null?void 0:j.tasks,oT,"tasks","tasks"),B=typeof((U=N.payload)==null?void 0:U.workspaceId)=="string"&&N.payload.workspaceId?N.payload.workspaceId:"";return B?(i($=>[...$.filter(ae=>ae.workspaceId!==B),...R]),!0):(i($=>{const ae=new Set(R.map(oe=>oe.id));return[...$.filter(oe=>!ae.has(oe.id)),...R]}),!0)}case"create_task_error":{const R=typeof((L=N.payload)==null?void 0:L.requestId)=="string"?N.payload.requestId:"",B=typeof((q=N.payload)==null?void 0:q.message)=="string"?N.payload.message:"Failed to create task";if(R){const $=d.current.get(R);$?(clearTimeout($.timer),d.current.delete(R),$.onError(B)):console.error("[useTasks] create_task_error with unknown requestId:",B)}else console.error("[useTasks] create_task_error:",B);return!0}default:return!1}},[]),m=b.useCallback(()=>{r(void 0);for(const[,N]of d.current)clearTimeout(N.timer),N.onError("Disconnected");d.current.clear()},[]),g=b.useCallback(N=>{n({type:"list_tasks",payload:{workspaceId:N}})},[n]),y=b.useCallback(()=>{n({type:"list_tasks",payload:{}})},[n]),v=b.useCallback((N,j,U,L,q,R,B,$,ae)=>{const oe={workspaceId:N,title:j,description:U||"",dependsOn:L||[],parentTaskId:q||"",defaultPersonaId:R||"",canDecompose:B||!1};if($||ae){const ne=crypto.randomUUID();oe.requestId=ne;const ce=ae??(()=>{}),Q=setTimeout(()=>{d.current.delete(ne)&&ce("Request timed out")},oC);d.current.set(ne,{onSuccess:$??(()=>{}),onError:ce,timer:Q})}n({type:"create_task",payload:oe})},[n]),x=b.useCallback((N,j,U,L)=>{r(N),n({type:"start_task",payload:{taskId:N,personaId:j||"",environmentId:U||"",notes:L||""}})},[n]),S=b.useCallback(N=>{n({type:"stop_task",payload:{taskId:N}})},[n]),C=b.useCallback(N=>{n({type:"complete_task",payload:{taskId:N}})},[n]),w=b.useCallback(N=>{n({type:"resume_task",payload:{taskId:N}})},[n]),E=b.useCallback((N,j,U,L,q)=>{const R={taskId:N,title:j,description:U,dependsOn:L};q!==void 0&&(R.defaultPersonaId=q),n({type:"update_task",payload:R})},[n]),k=b.useCallback(N=>{n({type:"delete_task",payload:{taskId:N}})},[n]);return{tasks:a,taskStartingId:l,loadTasks:g,loadAllTasks:y,createTask:v,startTask:x,stopTask:S,completeTask:C,resumeTask:w,updateTask:E,deleteTask:k,handleMessage:p,handleEvent:u,onDisconnect:m}}function rC(n){const[a,i]=b.useState([]),l=b.useCallback(p=>{if(p.type==="finding.posted"){const m=typeof p.payload.workspaceId=="string"?p.payload.workspaceId:"";return m&&n({type:"list_findings",payload:{workspaceId:m}}),!0}return!1},[n]),r=b.useCallback(p=>{var m;switch(p.type){case"findings":return i(ea((m=p.payload)==null?void 0:m.findings,lT,"findings","findings")),!0;default:return!1}},[]),d=b.useCallback(p=>{n({type:"list_findings",payload:{workspaceId:p}})},[n]),u=b.useCallback((p,m,g,y,v)=>{n({type:"post_finding",payload:{workspaceId:p,title:m,content:g,category:y||"general",tags:v||[]}})},[n]);return{findings:a,loadFindings:d,postFinding:u,handleMessage:r,handleEvent:l}}function cC(n){const[a,i]=b.useState([]),l=b.useCallback(m=>m.type==="token.changed"?(n({type:"list_tokens"}),!0):!1,[n]),r=b.useCallback(m=>{var g;switch(m.type){case"tokens":return i(ea((g=m.payload)==null?void 0:g.tokens,rT,"tokens","tokens")),!0;default:return!1}},[]),d=b.useCallback(()=>{n({type:"list_tokens"})},[n]),u=b.useCallback((m,g,y,v,x)=>{n({type:"set_token",payload:{name:m,value:g,tokenType:y,envVar:v,filePath:x}})},[n]),p=b.useCallback(m=>{n({type:"delete_token",payload:{name:m}})},[n]);return{tokens:a,loadTokens:d,setToken:u,deleteToken:p,handleMessage:r,handleEvent:l}}function uC(n){const[a,i]=b.useState({claude:"off",github:"off",copilot:"off",codex:"off"}),l=b.useCallback(u=>u.type==="credential.providers_changed"?(Jv(u.payload)&&i(u.payload),!0):!1,[]),r=b.useCallback(u=>{switch(u.type){case"credential_providers":return Jv(u.payload)&&i(u.payload),!0;default:return!1}},[]),d=b.useCallback(u=>{n({type:"set_credential_providers",payload:u})},[n]);return{credentialProviders:a,updateCredentialProviders:d,handleMessage:r,handleEvent:l}}function dC(n,a){const[i,l]=b.useState([]),[r,d]=b.useState(""),[u,p]=b.useState(""),[m,g]=b.useState(!1),y=b.useCallback(S=>{var C,w,E;switch(S.type){case"codespaces_list":{const k=ea((C=S.payload)==null?void 0:C.codespaces,uT,"codespaces_list","codespaces"),N=typeof((w=S.payload)==null?void 0:w.error)=="string"?S.payload.error:"";return l(k),p(N),!0}case"codespace_created":return g(!1),n({type:"list_codespaces"}),!0;case"codespace_create_error":{g(!1);const k=typeof((E=S.payload)==null?void 0:E.message)=="string"?S.payload.message:"Failed to create codespace";return d(k),!0}default:return!1}},[n]),v=b.useCallback(()=>{n({type:"list_codespaces"})},[n]),x=b.useCallback((S,C)=>{if(!a){d("Not connected to server. Please try again once the connection is restored.");return}g(!0),d("");const w={repo:S};C&&(w.machine=C),n({type:"create_codespace",payload:w})},[n,a]);return{codespaces:i,codespaceError:r,codespaceListError:u,codespaceCreating:m,listCodespaces:v,createCodespace:x,handleMessage:y}}function fC(n){const[a,i]=b.useState([]),l=b.useCallback(m=>{switch(m.type){case"persona.created":case"persona.updated":case"persona.deleted":return n({type:"list_personas"}),!0;default:return!1}},[n]),r=b.useCallback(m=>{var g;switch(m.type){case"personas":{const y=ea((g=m.payload)==null?void 0:g.personas,dT,"personas","personas");return i(y),!0}default:return!1}},[]),d=b.useCallback((m,g,y,v,x,S,C,w)=>{n({type:"create_persona",payload:{name:m,description:g,systemPrompt:y,runtime:v||"",model:x||"",maxTurns:S||0,type:C||"agent",script:w||""}})},[n]),u=b.useCallback((m,g,y,v,x,S,C,w,E)=>{const k={personaId:m};g!==void 0&&(k.name=g),y!==void 0&&(k.description=y),v!==void 0&&(k.systemPrompt=v),x!==void 0&&(k.runtime=x),S!==void 0&&(k.model=S),C!==void 0&&(k.maxTurns=C),w!==void 0&&(k.type=w),E!==void 0&&(k.script=E),n({type:"update_persona",payload:k})},[n]),p=b.useCallback(m=>{n({type:"delete_persona",payload:{personaId:m}})},[n]);return{personas:a,createPersona:d,updatePersona:u,deletePersona:p,handleMessage:r,handleEvent:l}}function hC(n){const[a,i]=b.useState(""),[l,r]=b.useState(void 0),{connected:d,send:u}=eC(n,{onMessage:L,onConnect:q,onDisconnect:R}),p=nC(u),m=sC(u),g=iC(u),y=lC(u),v=rC(u),x=cC(u),S=uC(u),C=dC(u,d),w=fC(u),E="default_persona_id",k="onboarding_completed",N=b.useCallback($=>{i($),u({type:"set_setting",payload:{key:E,value:$}})},[u]),j=b.useCallback(()=>{r(!0),u({type:"set_setting",payload:{key:k,value:"true"}})},[u]);function U($){const ae=$.payload.key,oe=$.payload.value;if($.type==="setting.changed"){ae===E&&i(oe??""),ae===k&&r(oe==="true");return}p.handleEvent($)||g.handleEvent($)||y.handleEvent($)||v.handleEvent($)||x.handleEvent($)||S.handleEvent($)||w.handleEvent($)}function L($){var ae,oe,ne;if(nT($)){U($);return}if($.type==="setting"){const ce=(ae=$.payload)==null?void 0:ae.key,Q=(oe=$.payload)==null?void 0:oe.value;ce===E&&i(Q??""),ce===k&&r(Q==="true");return}if(!p.handleMessage($)&&!m.handleMessage($)&&!g.handleMessage($)&&!y.handleMessage($)&&!v.handleMessage($)&&!x.handleMessage($)&&!S.handleMessage($)&&!C.handleMessage($)&&!w.handleMessage($)&&$.type==="error"){console.error("[ws]",(ne=$.payload)==null?void 0:ne.message);return}}function q($){$({type:"list_environments"}),$({type:"list_sessions"}),$({type:"list_workspaces"}),$({type:"list_tokens"}),$({type:"get_credential_providers"}),$({type:"list_personas"}),$({type:"get_setting",payload:{key:E}}),$({type:"get_setting",payload:{key:k}}),$({type:"list_tasks",payload:{}}),$({type:"subscribe_all"})}function R(){g.onDisconnect(),y.onDisconnect()}const B=b.useCallback(()=>{u({type:"list_environments"}),u({type:"list_sessions"}),u({type:"list_workspaces"}),u({type:"list_tokens"})},[u]);return{connected:d,environments:p.environments,sessions:m.sessions,events:m.events,eventsDropped:m.eventsDropped,lastSpawnedId:m.lastSpawnedId,workspaces:g.workspaces,tasks:y.tasks,findings:v.findings,tokens:x.tokens,spawn:m.spawn,sendInput:m.sendInput,kill:m.kill,refresh:B,loadSessionEvents:m.loadSessionEvents,clearEvents:m.clearEvents,createWorkspace:g.createWorkspace,archiveWorkspace:g.archiveWorkspace,updateWorkspace:g.updateWorkspace,loadTasks:y.loadTasks,loadAllTasks:y.loadAllTasks,createTask:y.createTask,startTask:y.startTask,stopTask:y.stopTask,completeTask:y.completeTask,resumeTask:y.resumeTask,updateTask:y.updateTask,deleteTask:y.deleteTask,loadFindings:v.loadFindings,postFinding:v.postFinding,addEnvironment:p.addEnvironment,updateEnvironment:p.updateEnvironment,loadTokens:x.loadTokens,setToken:x.setToken,deleteToken:x.deleteToken,credentialProviders:S.credentialProviders,updateCredentialProviders:S.updateCredentialProviders,provisionStatus:p.provisionStatus,provisionEnvironment:p.provisionEnvironment,stopEnvironment:p.stopEnvironment,removeEnvironment:p.removeEnvironment,codespaces:C.codespaces,codespaceError:C.codespaceError,codespaceListError:C.codespaceListError,codespaceCreating:C.codespaceCreating,listCodespaces:C.listCodespaces,createCodespace:C.createCodespace,workspaceCreating:g.workspaceCreating,taskStartingId:y.taskStartingId,personas:w.personas,createPersona:w.createPersona,updatePersona:w.updatePersona,deletePersona:w.deletePersona,taskSessions:m.taskSessions,loadTaskSessions:m.loadTaskSessions,appDefaultPersonaId:a,setAppDefaultPersonaId:N,onboardingCompleted:l,completeOnboarding:j}}const oh=b.createContext(void 0);function pC({children:n}){const a=hC();return c.jsx(oh.Provider,{value:a,children:n})}function yt(){const n=b.useContext(oh);if(!n)throw new Error("useGrackle must be used within GrackleProvider");return n}const mC=[{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}],gC=[{id:"sess-001-prev",environmentId:"env-local-01",runtime:"claude-code",status:"failed",prompt:"Implement auth middleware",startedAt:"2026-02-26T14:00:00Z",endedAt:"2026-02-26T15:12:00Z",error:"Context window exceeded before completing implementation"},{id:"sess-001",environmentId:"env-local-01",runtime:"node",status:"running",prompt:"Refactor the authentication middleware to use JWT tokens",startedAt:"2026-02-27T08:15:00Z"},{id:"sess-002",environmentId:"env-docker-01",runtime:"python",status:"completed",prompt:"Write unit tests for the user registration endpoint",startedAt:"2026-02-27T07:30:00Z"},{id:"sess-003",environmentId:"env-local-01",runtime:"node",status:"failed",prompt:"Migrate database schema to add audit_log table",startedAt:"2026-02-26T22:45:00Z"},{id:"sess-004",environmentId:"env-docker-01",runtime:"python",status:"running",prompt:"Implement rate limiting for the public API",startedAt:"2026-02-27T09:00:00Z"}],vC=[{sessionId:"sess-001-prev",eventType:"status",timestamp:"2026-02-26T14:00:01Z",content:"running"},{sessionId:"sess-001-prev",eventType:"output",timestamp:"2026-02-26T14:00:05Z",content:"Reading src/middleware/auth.ts to understand the current authentication flow..."},{sessionId:"sess-001-prev",eventType:"error",timestamp:"2026-02-26T15:12:00Z",content:"Context window exceeded before completing implementation"},{sessionId:"sess-001",eventType:"status",timestamp:"2026-02-27T08:15:01Z",content:"running"},{sessionId:"sess-001",eventType:"output",timestamp:"2026-02-27T08:15:02Z",content:"Analyzing current authentication middleware in src/middleware/auth.ts..."},{sessionId:"sess-001",eventType:"output",timestamp:"2026-02-27T08:15:04Z",content:`Found 3 files using session-based auth:
36
+ Please change the parent <Route path="${k}"> to <Route path="${k==="/"?"*":`${k}/*`}">.`)}let y=Vt(),v;if(a){let k=typeof a=="string"?Vi(a):a;ft(m==="/"||((E=k.pathname)==null?void 0:E.startsWith(m)),`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 "${m}" but pathname "${k.pathname}" was given in the \`location\` prop.`),v=k}else v=y;let x=v.pathname||"/",S=x;if(m!=="/"){let k=m.replace(/^\//,"").split("/");S="/"+x.replace(/^\//,"").split("/").slice(k.length).join("/")}let C=Q0(n,{pathname:S});Un(g||C!=null,`No routes matched location "${v.pathname}${v.search}${v.hash}" `),Un(C==null||C[C.length-1].route.element!==void 0||C[C.length-1].route.Component!==void 0||C[C.length-1].route.lazy!==void 0,`Matched leaf route at location "${v.pathname}${v.search}${v.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 w=sk(C&&C.map(k=>Object.assign({},k,{params:Object.assign({},u,k.params),pathname:ta([m,l.encodeLocation?l.encodeLocation(k.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:k.pathname]),pathnameBase:k.pathnameBase==="/"?m:ta([m,l.encodeLocation?l.encodeLocation(k.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:k.pathnameBase])})),r,i);return a&&w?b.createElement(dl.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...v},navigationType:"POP"}},w):w}function ek(){let n=ck(),a=UT(n)?`${n.status} ${n.statusText}`:n instanceof Error?n.message:JSON.stringify(n),i=n instanceof Error?n.stack:null,l="rgba(200,200,200, 0.5)",r={padding:"0.5rem",backgroundColor:l},d={padding:"2px 4px",backgroundColor:l},u=null;return console.error("Error handled by React Router default ErrorBoundary:",n),u=b.createElement(b.Fragment,null,b.createElement("p",null,"💿 Hey developer 👋"),b.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",b.createElement("code",{style:d},"ErrorBoundary")," or"," ",b.createElement("code",{style:d},"errorElement")," prop on your route.")),b.createElement(b.Fragment,null,b.createElement("h2",null,"Unexpected Application Error!"),b.createElement("h3",{style:{fontStyle:"italic"}},a),i?b.createElement("pre",{style:r},i):null,u)}var tk=b.createElement(ek,null),cb=class extends b.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,a){return a.location!==n.location||a.revalidation!=="idle"&&n.revalidation==="idle"?{error:n.error,location:n.location,revalidation:n.revalidation}:{error:n.error!==void 0?n.error:a.error,location:a.location,revalidation:n.revalidation||a.revalidation}}componentDidCatch(n,a){this.props.onError?this.props.onError(n,a):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=KT(n.digest);i&&(n=i)}let a=n!==void 0?b.createElement(Vn.Provider,{value:this.props.routeContext},b.createElement(Wf.Provider,{value:n,children:this.props.component})):this.props.children;return this.context?b.createElement(nk,{error:n},a):a}};cb.contextType=GT;var Pd=new WeakMap;function nk({children:n,error:a}){let{basename:i}=b.useContext(Cn);if(typeof a=="object"&&a&&"digest"in a&&typeof a.digest=="string"){let l=YT(a.digest);if(l){let r=Pd.get(a);if(r)throw r;let d=nb(l.location,i);if(tb&&!Pd.get(a))if(d.isExternal||l.reloadDocument)window.location.href=d.absoluteURL||d.to;else{const u=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(d.to,{replace:l.replace}));throw Pd.set(a,u),u}return b.createElement("meta",{httpEquiv:"refresh",content:`0;url=${d.absoluteURL||d.to}`})}}return n}function ak({routeContext:n,match:a,children:i}){let l=b.useContext(Hi);return l&&l.static&&l.staticContext&&(a.route.errorElement||a.route.ErrorBoundary)&&(l.staticContext._deepestRenderedBoundaryId=a.route.id),b.createElement(Vn.Provider,{value:n},i)}function sk(n,a=[],i){let l=i==null?void 0:i.state;if(n==null){if(!l)return null;if(l.errors)n=l.matches;else if(a.length===0&&!l.initialized&&l.matches.length>0)n=l.matches;else return null}let r=n,d=l==null?void 0:l.errors;if(d!=null){let y=r.findIndex(v=>v.route.id&&(d==null?void 0:d[v.route.id])!==void 0);ft(y>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(d).join(",")}`),r=r.slice(0,Math.min(r.length,y+1))}let u=!1,p=-1;if(i&&l){u=l.renderFallback;for(let y=0;y<r.length;y++){let v=r[y];if((v.route.HydrateFallback||v.route.hydrateFallbackElement)&&(p=y),v.route.id){let{loaderData:x,errors:S}=l,C=v.route.loader&&!x.hasOwnProperty(v.route.id)&&(!S||S[v.route.id]===void 0);if(v.route.lazy||C){i.isStatic&&(u=!0),p>=0?r=r.slice(0,p+1):r=[r[0]];break}}}}let m=i==null?void 0:i.onError,g=l&&m?(y,v)=>{var x,S;m(y,{location:l.location,params:((S=(x=l.matches)==null?void 0:x[0])==null?void 0:S.params)??{},unstable_pattern:VT(l.matches),errorInfo:v})}:void 0;return r.reduceRight((y,v,x)=>{let S,C=!1,w=null,E=null;l&&(S=d&&v.route.id?d[v.route.id]:void 0,w=v.route.errorElement||tk,u&&(p<0&&x===0?(ub("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),C=!0,E=null):p===x&&(C=!0,E=v.route.hydrateFallbackElement||null)));let k=a.concat(r.slice(0,x+1)),N=()=>{let j;return S?j=w:C?j=E:v.route.Component?j=b.createElement(v.route.Component,null):v.route.element?j=v.route.element:j=y,b.createElement(ak,{match:v,routeContext:{outlet:y,matches:k,isDataRoute:l!=null},children:j})};return l&&(v.route.ErrorBoundary||v.route.errorElement||x===0)?b.createElement(cb,{location:l.location,revalidation:l.revalidation,component:w,error:S,children:N(),routeContext:{outlet:null,matches:k,isDataRoute:!0},onError:g}):N()},null)}function Jf(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ik(n){let a=b.useContext(Hi);return ft(a,Jf(n)),a}function ok(n){let a=b.useContext(hc);return ft(a,Jf(n)),a}function lk(n){let a=b.useContext(Vn);return ft(a,Jf(n)),a}function eh(n){let a=lk(n),i=a.matches[a.matches.length-1];return ft(i.route.id,`${n} can only be used on routes that contain a unique "id"`),i.route.id}function rk(){return eh("useRouteId")}function ck(){var l;let n=b.useContext(Wf),a=ok("useRouteError"),i=eh("useRouteError");return n!==void 0?n:(l=a.errors)==null?void 0:l[i]}function uk(){let{router:n}=ik("useNavigate"),a=eh("useNavigate"),i=b.useRef(!1);return lb(()=>{i.current=!0}),b.useCallback(async(r,d={})=>{Un(i.current,ob),i.current&&(typeof r=="number"?await n.navigate(r):await n.navigate(r,{fromRouteId:a,...d}))},[n,a])}var iy={};function ub(n,a,i){!a&&!iy[n]&&(iy[n]=!0,Un(!1,i))}b.memo(dk);function dk({routes:n,future:a,state:i,isStatic:l,onError:r}){return rb(n,void 0,{state:i,isStatic:l,onError:r})}function Zo({to:n,replace:a,state:i,relative:l}){ft(Vs(),"<Navigate> may be used only in the context of a <Router> component.");let{static:r}=b.useContext(Cn);Un(!r,"<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:d}=b.useContext(Vn),{pathname:u}=Vt(),p=pc(),m=fc(n,Qf(d),u,l==="path"),g=JSON.stringify(m);return b.useEffect(()=>{p(JSON.parse(g),{replace:a,state:i,relative:l})},[p,g,l,a,i]),null}function db(n){return WT(n.context)}function Qe(n){ft(!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 fk({basename:n="/",children:a=null,location:i,navigationType:l="POP",navigator:r,static:d=!1,unstable_useTransitions:u}){ft(!Vs(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let p=n.replace(/^\/*/,"/"),m=b.useMemo(()=>({basename:p,navigator:r,static:d,unstable_useTransitions:u,future:{}}),[p,r,d,u]);typeof i=="string"&&(i=Vi(i));let{pathname:g="/",search:y="",hash:v="",state:x=null,key:S="default",unstable_mask:C}=i,w=b.useMemo(()=>{let E=Ea(g,p);return E==null?null:{location:{pathname:E,search:y,hash:v,state:x,key:S,unstable_mask:C},navigationType:l}},[p,g,y,v,x,S,l,C]);return Un(w!=null,`<Router basename="${p}"> is not able to match the URL "${g}${y}${v}" because it does not start with the basename, so the <Router> won't render anything.`),w==null?null:b.createElement(Cn.Provider,{value:m},b.createElement(dl.Provider,{children:a,value:w}))}function hk({children:n,location:a}){return JT(vf(n),a)}function vf(n,a=[]){let i=[];return b.Children.forEach(n,(l,r)=>{if(!b.isValidElement(l))return;let d=[...a,r];if(l.type===b.Fragment){i.push.apply(i,vf(l.props.children,d));return}ft(l.type===Qe,`[${typeof l.type=="string"?l.type:l.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),ft(!l.props.index||!l.props.children,"An index route cannot have child routes.");let u={id:l.props.id||d.join("-"),caseSensitive:l.props.caseSensitive,element:l.props.element,Component:l.props.Component,index:l.props.index,path:l.props.path,middleware:l.props.middleware,loader:l.props.loader,action:l.props.action,hydrateFallbackElement:l.props.hydrateFallbackElement,HydrateFallback:l.props.HydrateFallback,errorElement:l.props.errorElement,ErrorBoundary:l.props.ErrorBoundary,hasErrorBoundary:l.props.hasErrorBoundary===!0||l.props.ErrorBoundary!=null||l.props.errorElement!=null,shouldRevalidate:l.props.shouldRevalidate,handle:l.props.handle,lazy:l.props.lazy};l.props.children&&(u.children=vf(l.props.children,d)),i.push(u)}),i}var Fr="get",qr="application/x-www-form-urlencoded";function mc(n){return typeof HTMLElement<"u"&&n instanceof HTMLElement}function pk(n){return mc(n)&&n.tagName.toLowerCase()==="button"}function mk(n){return mc(n)&&n.tagName.toLowerCase()==="form"}function gk(n){return mc(n)&&n.tagName.toLowerCase()==="input"}function vk(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function yk(n,a){return n.button===0&&(!a||a==="_self")&&!vk(n)}function yf(n=""){return new URLSearchParams(typeof n=="string"||Array.isArray(n)||n instanceof URLSearchParams?n:Object.keys(n).reduce((a,i)=>{let l=n[i];return a.concat(Array.isArray(l)?l.map(r=>[i,r]):[[i,l]])},[]))}function bk(n,a){let i=yf(n);return a&&a.forEach((l,r)=>{i.has(r)||a.getAll(r).forEach(d=>{i.append(r,d)})}),i}var Or=null;function xk(){if(Or===null)try{new FormData(document.createElement("form"),0),Or=!1}catch{Or=!0}return Or}var _k=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function $d(n){return n!=null&&!_k.has(n)?(Un(!1,`"${n}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${qr}"`),null):n}function Sk(n,a){let i,l,r,d,u;if(mk(n)){let p=n.getAttribute("action");l=p?Ea(p,a):null,i=n.getAttribute("method")||Fr,r=$d(n.getAttribute("enctype"))||qr,d=new FormData(n)}else if(pk(n)||gk(n)&&(n.type==="submit"||n.type==="image")){let p=n.form;if(p==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let m=n.getAttribute("formaction")||p.getAttribute("action");if(l=m?Ea(m,a):null,i=n.getAttribute("formmethod")||p.getAttribute("method")||Fr,r=$d(n.getAttribute("formenctype"))||$d(p.getAttribute("enctype"))||qr,d=new FormData(p,n),!xk()){let{name:g,type:y,value:v}=n;if(y==="image"){let x=g?`${g}.`:"";d.append(`${x}x`,"0"),d.append(`${x}y`,"0")}else g&&d.append(g,v)}}else{if(mc(n))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');i=Fr,l=null,r=qr,u=n}return d&&r==="text/plain"&&(u=d,d=void 0),{action:l,method:i.toLowerCase(),encType:r,formData:d,body:u}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function th(n,a){if(n===!1||n===null||typeof n>"u")throw new Error(a)}function Tk(n,a,i,l){let r=typeof n=="string"?new URL(n,typeof window>"u"?"server://singlefetch/":window.location.origin):n;return i?r.pathname.endsWith("/")?r.pathname=`${r.pathname}_.${l}`:r.pathname=`${r.pathname}.${l}`:r.pathname==="/"?r.pathname=`_root.${l}`:a&&Ea(r.pathname,a)==="/"?r.pathname=`${a.replace(/\/$/,"")}/_root.${l}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${l}`,r}async function kk(n,a){if(n.id in a)return a[n.id];try{let i=await import(n.module);return a[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 Ck(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 wk(n,a,i){let l=await Promise.all(n.map(async r=>{let d=a.routes[r.route.id];if(d){let u=await kk(d,i);return u.links?u.links():[]}return[]}));return jk(l.flat(1).filter(Ck).filter(r=>r.rel==="stylesheet"||r.rel==="preload").map(r=>r.rel==="stylesheet"?{...r,rel:"prefetch",as:"style"}:{...r,rel:"prefetch"}))}function oy(n,a,i,l,r,d){let u=(m,g)=>i[g]?m.route.id!==i[g].route.id:!0,p=(m,g)=>{var y;return i[g].pathname!==m.pathname||((y=i[g].route.path)==null?void 0:y.endsWith("*"))&&i[g].params["*"]!==m.params["*"]};return d==="assets"?a.filter((m,g)=>u(m,g)||p(m,g)):d==="data"?a.filter((m,g)=>{var v;let y=l.routes[m.route.id];if(!y||!y.hasLoader)return!1;if(u(m,g)||p(m,g))return!0;if(m.route.shouldRevalidate){let x=m.route.shouldRevalidate({currentUrl:new URL(r.pathname+r.search+r.hash,window.origin),currentParams:((v=i[0])==null?void 0:v.params)||{},nextUrl:new URL(n,window.origin),nextParams:m.params,defaultShouldRevalidate:!0});if(typeof x=="boolean")return x}return!0}):[]}function Ek(n,a,{includeHydrateFallback:i}={}){return Nk(n.map(l=>{let r=a.routes[l.route.id];if(!r)return[];let d=[r.module];return r.clientActionModule&&(d=d.concat(r.clientActionModule)),r.clientLoaderModule&&(d=d.concat(r.clientLoaderModule)),i&&r.hydrateFallbackModule&&(d=d.concat(r.hydrateFallbackModule)),r.imports&&(d=d.concat(r.imports)),d}).flat(1))}function Nk(n){return[...new Set(n)]}function Ak(n){let a={},i=Object.keys(n).sort();for(let l of i)a[l]=n[l];return a}function jk(n,a){let i=new Set;return new Set(a),n.reduce((l,r)=>{let d=JSON.stringify(Ak(r));return i.has(d)||(i.add(d),l.push({key:d,link:r})),l},[])}function fb(){let n=b.useContext(Hi);return th(n,"You must render this element inside a <DataRouterContext.Provider> element"),n}function Dk(){let n=b.useContext(hc);return th(n,"You must render this element inside a <DataRouterStateContext.Provider> element"),n}var nh=b.createContext(void 0);nh.displayName="FrameworkContext";function hb(){let n=b.useContext(nh);return th(n,"You must render this element inside a <HydratedRouter> element"),n}function Mk(n,a){let i=b.useContext(nh),[l,r]=b.useState(!1),[d,u]=b.useState(!1),{onFocus:p,onBlur:m,onMouseEnter:g,onMouseLeave:y,onTouchStart:v}=a,x=b.useRef(null);b.useEffect(()=>{if(n==="render"&&u(!0),n==="viewport"){let w=k=>{k.forEach(N=>{u(N.isIntersecting)})},E=new IntersectionObserver(w,{threshold:.5});return x.current&&E.observe(x.current),()=>{E.disconnect()}}},[n]),b.useEffect(()=>{if(l){let w=setTimeout(()=>{u(!0)},100);return()=>{clearTimeout(w)}}},[l]);let S=()=>{r(!0)},C=()=>{r(!1),u(!1)};return i?n!=="intent"?[d,x,{}]:[d,x,{onFocus:Uo(p,S),onBlur:Uo(m,C),onMouseEnter:Uo(g,S),onMouseLeave:Uo(y,C),onTouchStart:Uo(v,S)}]:[!1,x,{}]}function Uo(n,a){return i=>{n&&n(i),i.defaultPrevented||a(i)}}function Rk({page:n,...a}){let{router:i}=fb(),l=b.useMemo(()=>Q0(i.routes,n,i.basename),[i.routes,n,i.basename]);return l?b.createElement(Ok,{page:n,matches:l,...a}):null}function Bk(n){let{manifest:a,routeModules:i}=hb(),[l,r]=b.useState([]);return b.useEffect(()=>{let d=!1;return wk(n,a,i).then(u=>{d||r(u)}),()=>{d=!0}},[n,a,i]),l}function Ok({page:n,matches:a,...i}){let l=Vt(),{future:r,manifest:d,routeModules:u}=hb(),{basename:p}=fb(),{loaderData:m,matches:g}=Dk(),y=b.useMemo(()=>oy(n,a,g,d,l,"data"),[n,a,g,d,l]),v=b.useMemo(()=>oy(n,a,g,d,l,"assets"),[n,a,g,d,l]),x=b.useMemo(()=>{if(n===l.pathname+l.search+l.hash)return[];let w=new Set,E=!1;if(a.forEach(N=>{var U;let j=d.routes[N.route.id];!j||!j.hasLoader||(!y.some(L=>L.route.id===N.route.id)&&N.route.id in m&&((U=u[N.route.id])!=null&&U.shouldRevalidate)||j.hasClientLoader?E=!0:w.add(N.route.id))}),w.size===0)return[];let k=Tk(n,p,r.unstable_trailingSlashAwareDataRequests,"data");return E&&w.size>0&&k.searchParams.set("_routes",a.filter(N=>w.has(N.route.id)).map(N=>N.route.id).join(",")),[k.pathname+k.search]},[p,r.unstable_trailingSlashAwareDataRequests,m,l,d,y,a,n,u]),S=b.useMemo(()=>Ek(v,d),[v,d]),C=Bk(v);return b.createElement(b.Fragment,null,x.map(w=>b.createElement("link",{key:w,rel:"prefetch",as:"fetch",href:w,...i})),S.map(w=>b.createElement("link",{key:w,rel:"modulepreload",href:w,...i})),C.map(({key:w,link:E})=>b.createElement("link",{key:w,nonce:i.nonce,...E,crossOrigin:E.crossOrigin??i.crossOrigin})))}function Ik(...n){return a=>{n.forEach(i=>{typeof i=="function"?i(a):i!=null&&(i.current=a)})}}var Lk=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Lk&&(window.__reactRouterVersion="7.13.1")}catch{}function zk({basename:n,children:a,unstable_useTransitions:i,window:l}){let r=b.useRef();r.current==null&&(r.current=gT({window:l,v5Compat:!0}));let d=r.current,[u,p]=b.useState({action:d.action,location:d.location}),m=b.useCallback(g=>{i===!1?p(g):b.startTransition(()=>p(g))},[i]);return b.useLayoutEffect(()=>d.listen(m),[d,m]),b.createElement(fk,{basename:n,children:a,location:u.location,navigationType:u.action,navigator:d,unstable_useTransitions:i})}var pb=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ah=b.forwardRef(function({onClick:a,discover:i="render",prefetch:l="none",relative:r,reloadDocument:d,replace:u,unstable_mask:p,state:m,target:g,to:y,preventScrollReset:v,viewTransition:x,unstable_defaultShouldRevalidate:S,...C},w){let{basename:E,navigator:k,unstable_useTransitions:N}=b.useContext(Cn),j=typeof y=="string"&&pb.test(y),U=nb(y,E);y=U.to;let L=ZT(y,{relative:r}),q=Vt(),R=null;if(p){let ie=fc(p,[],q.unstable_mask?q.unstable_mask.pathname:"/",!0);E!=="/"&&(ie.pathname=ie.pathname==="/"?E:ta([E,ie.pathname])),R=k.createHref(ie)}let[B,$,ae]=Mk(l,C),oe=Gk(y,{replace:u,unstable_mask:p,state:m,target:g,preventScrollReset:v,relative:r,viewTransition:x,unstable_defaultShouldRevalidate:S,unstable_useTransitions:N});function ne(ie){a&&a(ie),ie.defaultPrevented||oe(ie)}let ce=!(U.isExternal||d),Q=b.createElement("a",{...C,...ae,href:(ce?R:void 0)||U.absoluteURL||L,onClick:ce?ne:a,ref:Ik(w,$),target:g,"data-discover":!j&&i==="render"?"true":void 0});return B&&!j?b.createElement(b.Fragment,null,Q,b.createElement(Rk,{page:L})):Q});ah.displayName="Link";var Uk=b.forwardRef(function({"aria-current":a="page",caseSensitive:i=!1,className:l="",end:r=!1,style:d,to:u,viewTransition:p,children:m,...g},y){let v=hl(u,{relative:g.relative}),x=Vt(),S=b.useContext(hc),{navigator:C,basename:w}=b.useContext(Cn),E=S!=null&&Yk(v)&&p===!0,k=C.encodeLocation?C.encodeLocation(v).pathname:v.pathname,N=x.pathname,j=S&&S.navigation&&S.navigation.location?S.navigation.location.pathname:null;i||(N=N.toLowerCase(),j=j?j.toLowerCase():null,k=k.toLowerCase()),j&&w&&(j=Ea(j,w)||j);const U=k!=="/"&&k.endsWith("/")?k.length-1:k.length;let L=N===k||!r&&N.startsWith(k)&&N.charAt(U)==="/",q=j!=null&&(j===k||!r&&j.startsWith(k)&&j.charAt(k.length)==="/"),R={isActive:L,isPending:q,isTransitioning:E},B=L?a:void 0,$;typeof l=="function"?$=l(R):$=[l,L?"active":null,q?"pending":null,E?"transitioning":null].filter(Boolean).join(" ");let ae=typeof d=="function"?d(R):d;return b.createElement(ah,{...g,"aria-current":B,className:$,ref:y,style:ae,to:u,viewTransition:p},typeof m=="function"?m(R):m)});Uk.displayName="NavLink";var Vk=b.forwardRef(({discover:n="render",fetcherKey:a,navigate:i,reloadDocument:l,replace:r,state:d,method:u=Fr,action:p,onSubmit:m,relative:g,preventScrollReset:y,viewTransition:v,unstable_defaultShouldRevalidate:x,...S},C)=>{let{unstable_useTransitions:w}=b.useContext(Cn),E=Fk(),k=qk(p,{relative:g}),N=u.toLowerCase()==="get"?"get":"post",j=typeof p=="string"&&pb.test(p),U=L=>{if(m&&m(L),L.defaultPrevented)return;L.preventDefault();let q=L.nativeEvent.submitter,R=(q==null?void 0:q.getAttribute("formmethod"))||u,B=()=>E(q||L.currentTarget,{fetcherKey:a,method:R,navigate:i,replace:r,state:d,relative:g,preventScrollReset:y,viewTransition:v,unstable_defaultShouldRevalidate:x});w&&i!==!1?b.startTransition(()=>B()):B()};return b.createElement("form",{ref:C,method:N,action:k,onSubmit:l?m:U,...S,"data-discover":!j&&n==="render"?"true":void 0})});Vk.displayName="Form";function Hk(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function mb(n){let a=b.useContext(Hi);return ft(a,Hk(n)),a}function Gk(n,{target:a,replace:i,unstable_mask:l,state:r,preventScrollReset:d,relative:u,viewTransition:p,unstable_defaultShouldRevalidate:m,unstable_useTransitions:g}={}){let y=pc(),v=Vt(),x=hl(n,{relative:u});return b.useCallback(S=>{if(yk(S,a)){S.preventDefault();let C=i!==void 0?i:al(v)===al(x),w=()=>y(n,{replace:C,unstable_mask:l,state:r,preventScrollReset:d,relative:u,viewTransition:p,unstable_defaultShouldRevalidate:m});g?b.startTransition(()=>w()):w()}},[v,y,x,i,l,r,a,n,d,u,p,m,g])}function sh(n){Un(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 a=b.useRef(yf(n)),i=b.useRef(!1),l=Vt(),r=b.useMemo(()=>bk(l.search,i.current?null:a.current),[l.search]),d=pc(),u=b.useCallback((p,m)=>{const g=yf(typeof p=="function"?p(new URLSearchParams(r)):p);i.current=!0,d("?"+g,m)},[d,r]);return[r,u]}var Pk=0,$k=()=>`__${String(++Pk)}__`;function Fk(){let{router:n}=mb("useSubmit"),{basename:a}=b.useContext(Cn),i=rk(),l=n.fetch,r=n.navigate;return b.useCallback(async(d,u={})=>{let{action:p,method:m,encType:g,formData:y,body:v}=Sk(d,a);if(u.navigate===!1){let x=u.fetcherKey||$k();await l(x,i,u.action||p,{unstable_defaultShouldRevalidate:u.unstable_defaultShouldRevalidate,preventScrollReset:u.preventScrollReset,formData:y,body:v,formMethod:u.method||m,formEncType:u.encType||g,flushSync:u.flushSync})}else await r(u.action||p,{unstable_defaultShouldRevalidate:u.unstable_defaultShouldRevalidate,preventScrollReset:u.preventScrollReset,formData:y,body:v,formMethod:u.method||m,formEncType:u.encType||g,replace:u.replace,state:u.state,fromRouteId:i,flushSync:u.flushSync,viewTransition:u.viewTransition})},[l,r,a,i])}function qk(n,{relative:a}={}){let{basename:i}=b.useContext(Cn),l=b.useContext(Vn);ft(l,"useFormAction must be used inside a RouteContext");let[r]=l.matches.slice(-1),d={...hl(n||".",{relative:a})},u=Vt();if(n==null){d.search=u.search;let p=new URLSearchParams(d.search),m=p.getAll("index");if(m.some(y=>y==="")){p.delete("index"),m.filter(v=>v).forEach(v=>p.append("index",v));let y=p.toString();d.search=y?`?${y}`:""}}return(!n||n===".")&&r.route.index&&(d.search=d.search?d.search.replace(/^\?/,"?index&"):"?index"),i!=="/"&&(d.pathname=d.pathname==="/"?i:ta([i,d.pathname])),al(d)}function Yk(n,{relative:a}={}){let i=b.useContext(sb);ft(i!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:l}=mb("useViewTransitionState"),r=hl(n,{relative:a});if(!i.isTransitioning)return!1;let d=Ea(i.currentLocation.pathname,l)||i.currentLocation.pathname,u=Ea(i.nextLocation.pathname,l)||i.nextLocation.pathname;return sl(r.pathname,u)!=null||sl(r.pathname,d)!=null}function Wt(){const n=pc();return b.useCallback((a,i)=>{typeof a=="number"?n(a):n(a,i)},[n])}function ih(n){return`/sessions/${encodeURIComponent(n)}`}function Ii(n){return`/workspaces/${encodeURIComponent(n)}`}function Fn(n,a,i){const l=encodeURIComponent(n),r=i?`/workspaces/${encodeURIComponent(i)}/tasks/${l}`:`/tasks/${l}`;return a?`${r}/${a}`:r}function Kk(n,a){return a?`/workspaces/${encodeURIComponent(a)}/tasks/${encodeURIComponent(n)}/edit`:`/tasks/${encodeURIComponent(n)}/edit`}function Na(n,a){const i=new URLSearchParams;n&&i.set("workspace",n),a&&i.set("parent",a);const l=i.toString();return l?`/tasks/new?${l}`:"/tasks/new"}function gb(n){return`/sessions/new?${new URLSearchParams({env:n}).toString()}`}const ly="/environments/new";function Zk(n){return`/environments/${encodeURIComponent(n)}`}const Xo="/settings",bf="/settings/environments",Xk="/pair",Qk="/chat",Us="/",Wk="/tasks",Jk="/workspaces";function eC(n,a){const i=typeof window<"u"?`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}`:"ws://localhost:3000",l=b.useRef(void 0),[r,d]=b.useState(!1),u=b.useRef(a.onMessage);u.current=a.onMessage;const p=b.useRef(a.onConnect);p.current=a.onConnect;const m=b.useRef(a.onDisconnect);m.current=a.onDisconnect;const g=b.useCallback(y=>{var v;((v=l.current)==null?void 0:v.readyState)===WebSocket.OPEN&&l.current.send(JSON.stringify(y))},[]);return b.useEffect(()=>{let y,v;function x(){y=new WebSocket(i),l.current=y,y.onopen=()=>{d(!0),p.current(g)},y.onmessage=S=>{if(typeof S.data!="string"){console.warn("[ws] Received non-string WebSocket message; ignoring");return}const C=fT(S.data);C&&u.current(C)},y.onclose=S=>{var C;if(d(!1),l.current=void 0,(C=m.current)==null||C.call(m),clearTimeout(v),S.code===mT){window.location.href=Xk;return}v=setTimeout(x,pT)},y.onerror=()=>{y.close()}}return x(),()=>{clearTimeout(v),y==null||y.close()}},[i,g]),{connected:r,send:g}}const tC=5e3;function nC(n){const[a,i]=b.useState([]),[l,r]=b.useState({}),d=b.useCallback(x=>{switch(x.type){case"environment.added":return!0;case"environment.removed":{const S=x.payload.environmentId;return S&&(i(C=>C.filter(w=>w.id!==S)),r(C=>{const w={...C};return delete w[S],w})),n({type:"list_sessions"}),!0}case"environment.changed":return n({type:"list_environments"}),!0;case"environment.provision_progress":{const S=x.payload;if(typeof S.environmentId!="string"||typeof S.stage!="string"||typeof S.message!="string"||typeof S.progress!="number")return nl("environment.provision_progress","invalid payload"),!0;if(r(C=>({...C,[S.environmentId]:{stage:S.stage,message:S.message,progress:S.progress}})),S.stage==="ready"){const C=S.environmentId;setTimeout(()=>{r(w=>{const E={...w};return delete E[C],E})},tC)}return!0}default:return!1}},[n]),u=b.useCallback(x=>{var S;switch(x.type){case"environments":return i(ea((S=x.payload)==null?void 0:S.environments,aT,"environments","environments").map(sT)),!0;default:return!1}},[]),p=b.useCallback((x,S,C)=>{n({type:"add_environment",payload:{displayName:x,adapterType:S,adapterConfig:C||{}}})},[n]),m=b.useCallback((x,S)=>{const C={environmentId:x,...S};n({type:"update_environment",payload:C})},[n]),g=b.useCallback(x=>{n({type:"provision_environment",payload:{environmentId:x}})},[n]),y=b.useCallback(x=>{n({type:"stop_environment",payload:{environmentId:x}})},[n]),v=b.useCallback(x=>{n({type:"remove_environment",payload:{environmentId:x}})},[n]);return{environments:a,provisionStatus:l,addEnvironment:p,updateEnvironment:m,provisionEnvironment:g,stopEnvironment:y,removeEnvironment:v,handleMessage:u,handleEvent:d}}const Fd=new Set(["pending","running","idle"]),aC=new Set(["completed","failed","interrupted","hibernating"]),ry=["pending","running","idle"];function sC(n){const[a,i]=b.useState([]),[l,r]=b.useState([]),[d,u]=b.useState(0),[p,m]=b.useState(void 0),[g,y]=b.useState({}),v=b.useCallback(N=>{var j,U,L,q,R;switch(N.type){case"sessions":return i(B=>{var oe;const $=ea((oe=N.payload)==null?void 0:oe.sessions,Qv,"sessions","sessions"),ae=new Map(B.map(ne=>[ne.id,ne.status]));return $.map(ne=>{const ce=ae.get(ne.id);return!ce||ce===ne.status?ne:aC.has(ce)&&Fd.has(ne.status)?{...ne,status:ce}:Fd.has(ce)&&Fd.has(ne.status)&&ry.indexOf(ce)>ry.indexOf(ne.status)?{...ne,status:ce}:ne})}),!0;case"session_event":{if(!Wv(N.payload))return nl("session_event","payload is not a valid SessionEvent"),!0;const B=N.payload;let $=0;if(r(ae=>{const oe=[...ae,B];return oe.length>wi?($=oe.length-wi,oe.slice(-wi)):oe}),$>0&&u(ae=>ae+$),B.eventType==="status"){const ae=hT(B.content);i(oe=>oe.some(ce=>ce.id===B.sessionId)?oe.map(ce=>ce.id===B.sessionId?{...ce,status:ae}:ce):[...oe,{id:B.sessionId,environmentId:"",runtime:"",status:ae,prompt:"",startedAt:B.timestamp}])}return!0}case"session_events":{const B=ea((j=N.payload)==null?void 0:j.events,Wv,"session_events","events"),$=(U=N.payload)==null?void 0:U.sessionId;if(typeof $!="string")return nl("session_events","missing or non-string sessionId"),!0;if(B.length>0){let ae=0;r(oe=>{const ne=new Set;for(const ie of oe)ie.sessionId===$&&ne.add(`${ie.timestamp}|${ie.eventType}`);const ce=B.filter(ie=>!ne.has(`${ie.timestamp}|${ie.eventType}`)),Q=[...oe,...ce].sort((ie,V)=>ie.sessionId!==V.sessionId?0:ie.timestamp.localeCompare(V.timestamp));return Q.length>wi?(ae=Q.length-wi,Q.slice(-wi)):Q}),ae>0&&u(oe=>oe+ae)}return!0}case"spawned":{const B=(L=N.payload)==null?void 0:L.sessionId;return typeof B=="string"&&B&&m(B),n({type:"list_sessions"}),!0}case"task_sessions":{const B=(q=N.payload)==null?void 0:q.taskId;if(typeof B!="string"||!B)return!0;const $=ea((R=N.payload)==null?void 0:R.sessions,Qv,"task_sessions","sessions");return y(ae=>({...ae,[B]:$})),!0}default:return!1}},[n]),x=b.useCallback((N,j,U,L)=>{n({type:"spawn",payload:{environmentId:N,prompt:j,personaId:U||"",worktreeBasePath:L||""}})},[n]),S=b.useCallback((N,j)=>{n({type:"send_input",payload:{sessionId:N,text:j}})},[n]),C=b.useCallback(N=>{n({type:"kill",payload:{sessionId:N}})},[n]),w=b.useCallback(N=>{n({type:"get_session_events",payload:{sessionId:N}})},[n]),E=b.useCallback(()=>{r([]),u(0)},[]),k=b.useCallback(N=>{n({type:"get_task_sessions",payload:{taskId:N}})},[n]);return{sessions:a,events:l,eventsDropped:d,lastSpawnedId:p,taskSessions:g,spawn:x,sendInput:S,kill:C,loadSessionEvents:w,clearEvents:E,loadTaskSessions:k,handleMessage:v}}function iC(n){const[a,i]=b.useState([]),[l,r]=b.useState(!1),d=b.useCallback(v=>{switch(v.type){case"workspace.created":return r(!1),n({type:"list_workspaces"}),!0;case"workspace.archived":case"workspace.updated":return n({type:"list_workspaces"}),!0;default:return!1}},[n]),u=b.useCallback(v=>{var x;switch(v.type){case"workspaces":return i(ea((x=v.payload)==null?void 0:x.workspaces,iT,"workspaces","workspaces")),!0;default:return!1}},[]),p=b.useCallback(()=>{r(!1)},[]),m=b.useCallback((v,x,S,C,w)=>{r(!0),n({type:"create_workspace",payload:{name:v,description:x||"",repoUrl:S||"",environmentId:C||"",defaultPersonaId:w||""}})},[n]),g=b.useCallback(v=>{n({type:"archive_workspace",payload:{workspaceId:v}})},[n]),y=b.useCallback((v,x)=>{n({type:"update_workspace",payload:{workspaceId:v,...x}})},[n]);return{workspaces:a,workspaceCreating:l,createWorkspace:m,archiveWorkspace:g,updateWorkspace:y,handleMessage:u,handleEvent:d,onDisconnect:p}}const oC=15e3;function lC(n){const[a,i]=b.useState([]),[l,r]=b.useState(void 0),d=b.useRef(new Map),u=b.useCallback(N=>{const j=N.payload;switch(N.type){case"task.created":{const U=typeof j.requestId=="string"?j.requestId:"";if(U){const q=d.current.get(U);q&&(clearTimeout(q.timer),d.current.delete(U),q.onSuccess())}const L=typeof j.workspaceId=="string"?j.workspaceId:"";return L&&n({type:"list_tasks",payload:{workspaceId:L}}),!0}case"task.started":{const U=typeof j.taskId=="string"?j.taskId:"",L=typeof j.sessionId=="string"?j.sessionId:"",q=typeof j.workspaceId=="string"?j.workspaceId:"";return r(R=>U&&R===U?void 0:R),L&&(n({type:"list_sessions"}),U&&i(R=>R.map(B=>B.id===U?{...B,latestSessionId:L}:B))),q?n({type:"list_tasks",payload:{workspaceId:q}}):U&&i(R=>{const B=R.find($=>$.id===U);return B!=null&&B.workspaceId?n({type:"list_tasks",payload:{workspaceId:B.workspaceId}}):n({type:"list_tasks",payload:{}}),R}),!0}case"task.completed":case"task.deleted":case"task.updated":{const U=typeof j.workspaceId=="string"?j.workspaceId:"",L=typeof j.taskId=="string"?j.taskId:"";return U?n({type:"list_tasks",payload:{workspaceId:U}}):L&&i(q=>{const R=q.find(B=>B.id===L);return R!=null&&R.workspaceId?n({type:"list_tasks",payload:{workspaceId:R.workspaceId}}):n({type:"list_tasks",payload:{}}),q}),!0}default:return!1}},[n]),p=b.useCallback(N=>{var j,U,L,q;switch(N.type){case"tasks":{const R=ea((j=N.payload)==null?void 0:j.tasks,oT,"tasks","tasks"),B=typeof((U=N.payload)==null?void 0:U.workspaceId)=="string"&&N.payload.workspaceId?N.payload.workspaceId:"";return B?(i($=>[...$.filter(ae=>ae.workspaceId!==B),...R]),!0):(i($=>{const ae=new Set(R.map(oe=>oe.id));return[...$.filter(oe=>!ae.has(oe.id)),...R]}),!0)}case"create_task_error":{const R=typeof((L=N.payload)==null?void 0:L.requestId)=="string"?N.payload.requestId:"",B=typeof((q=N.payload)==null?void 0:q.message)=="string"?N.payload.message:"Failed to create task";if(R){const $=d.current.get(R);$?(clearTimeout($.timer),d.current.delete(R),$.onError(B)):console.error("[useTasks] create_task_error with unknown requestId:",B)}else console.error("[useTasks] create_task_error:",B);return!0}default:return!1}},[]),m=b.useCallback(()=>{r(void 0);for(const[,N]of d.current)clearTimeout(N.timer),N.onError("Disconnected");d.current.clear()},[]),g=b.useCallback(N=>{n({type:"list_tasks",payload:{workspaceId:N}})},[n]),y=b.useCallback(()=>{n({type:"list_tasks",payload:{}})},[n]),v=b.useCallback((N,j,U,L,q,R,B,$,ae)=>{const oe={workspaceId:N,title:j,description:U||"",dependsOn:L||[],parentTaskId:q||"",defaultPersonaId:R||"",canDecompose:B||!1};if($||ae){const ne=crypto.randomUUID();oe.requestId=ne;const ce=ae??(()=>{}),Q=setTimeout(()=>{d.current.delete(ne)&&ce("Request timed out")},oC);d.current.set(ne,{onSuccess:$??(()=>{}),onError:ce,timer:Q})}n({type:"create_task",payload:oe})},[n]),x=b.useCallback((N,j,U,L)=>{r(N),n({type:"start_task",payload:{taskId:N,personaId:j||"",environmentId:U||"",notes:L||""}})},[n]),S=b.useCallback(N=>{n({type:"stop_task",payload:{taskId:N}})},[n]),C=b.useCallback(N=>{n({type:"complete_task",payload:{taskId:N}})},[n]),w=b.useCallback(N=>{n({type:"resume_task",payload:{taskId:N}})},[n]),E=b.useCallback((N,j,U,L,q)=>{const R={taskId:N,title:j,description:U,dependsOn:L};q!==void 0&&(R.defaultPersonaId=q),n({type:"update_task",payload:R})},[n]),k=b.useCallback(N=>{n({type:"delete_task",payload:{taskId:N}})},[n]);return{tasks:a,taskStartingId:l,loadTasks:g,loadAllTasks:y,createTask:v,startTask:x,stopTask:S,completeTask:C,resumeTask:w,updateTask:E,deleteTask:k,handleMessage:p,handleEvent:u,onDisconnect:m}}function rC(n){const[a,i]=b.useState([]),l=b.useCallback(p=>{if(p.type==="finding.posted"){const m=typeof p.payload.workspaceId=="string"?p.payload.workspaceId:"";return m&&n({type:"list_findings",payload:{workspaceId:m}}),!0}return!1},[n]),r=b.useCallback(p=>{var m;switch(p.type){case"findings":return i(ea((m=p.payload)==null?void 0:m.findings,lT,"findings","findings")),!0;default:return!1}},[]),d=b.useCallback(p=>{n({type:"list_findings",payload:{workspaceId:p}})},[n]),u=b.useCallback((p,m,g,y,v)=>{n({type:"post_finding",payload:{workspaceId:p,title:m,content:g,category:y||"general",tags:v||[]}})},[n]);return{findings:a,loadFindings:d,postFinding:u,handleMessage:r,handleEvent:l}}function cC(n){const[a,i]=b.useState([]),l=b.useCallback(m=>m.type==="token.changed"?(n({type:"list_tokens"}),!0):!1,[n]),r=b.useCallback(m=>{var g;switch(m.type){case"tokens":return i(ea((g=m.payload)==null?void 0:g.tokens,rT,"tokens","tokens")),!0;default:return!1}},[]),d=b.useCallback(()=>{n({type:"list_tokens"})},[n]),u=b.useCallback((m,g,y,v,x)=>{n({type:"set_token",payload:{name:m,value:g,tokenType:y,envVar:v,filePath:x}})},[n]),p=b.useCallback(m=>{n({type:"delete_token",payload:{name:m}})},[n]);return{tokens:a,loadTokens:d,setToken:u,deleteToken:p,handleMessage:r,handleEvent:l}}function uC(n){const[a,i]=b.useState({claude:"off",github:"off",copilot:"off",codex:"off"}),l=b.useCallback(u=>u.type==="credential.providers_changed"?(Jv(u.payload)&&i(u.payload),!0):!1,[]),r=b.useCallback(u=>{switch(u.type){case"credential_providers":return Jv(u.payload)&&i(u.payload),!0;default:return!1}},[]),d=b.useCallback(u=>{n({type:"set_credential_providers",payload:u})},[n]);return{credentialProviders:a,updateCredentialProviders:d,handleMessage:r,handleEvent:l}}function dC(n,a){const[i,l]=b.useState([]),[r,d]=b.useState(""),[u,p]=b.useState(""),[m,g]=b.useState(!1),y=b.useCallback(S=>{var C,w,E;switch(S.type){case"codespaces_list":{const k=ea((C=S.payload)==null?void 0:C.codespaces,uT,"codespaces_list","codespaces"),N=typeof((w=S.payload)==null?void 0:w.error)=="string"?S.payload.error:"";return l(k),p(N),!0}case"codespace_created":return g(!1),n({type:"list_codespaces"}),!0;case"codespace_create_error":{g(!1);const k=typeof((E=S.payload)==null?void 0:E.message)=="string"?S.payload.message:"Failed to create codespace";return d(k),!0}default:return!1}},[n]),v=b.useCallback(()=>{n({type:"list_codespaces"})},[n]),x=b.useCallback((S,C)=>{if(!a){d("Not connected to server. Please try again once the connection is restored.");return}g(!0),d("");const w={repo:S};C&&(w.machine=C),n({type:"create_codespace",payload:w})},[n,a]);return{codespaces:i,codespaceError:r,codespaceListError:u,codespaceCreating:m,listCodespaces:v,createCodespace:x,handleMessage:y}}function fC(n){const[a,i]=b.useState([]),l=b.useCallback(m=>{switch(m.type){case"persona.created":case"persona.updated":case"persona.deleted":return n({type:"list_personas"}),!0;default:return!1}},[n]),r=b.useCallback(m=>{var g;switch(m.type){case"personas":{const y=ea((g=m.payload)==null?void 0:g.personas,dT,"personas","personas");return i(y),!0}default:return!1}},[]),d=b.useCallback((m,g,y,v,x,S,C,w)=>{n({type:"create_persona",payload:{name:m,description:g,systemPrompt:y,runtime:v||"",model:x||"",maxTurns:S||0,type:C||"agent",script:w||""}})},[n]),u=b.useCallback((m,g,y,v,x,S,C,w,E)=>{const k={personaId:m};g!==void 0&&(k.name=g),y!==void 0&&(k.description=y),v!==void 0&&(k.systemPrompt=v),x!==void 0&&(k.runtime=x),S!==void 0&&(k.model=S),C!==void 0&&(k.maxTurns=C),w!==void 0&&(k.type=w),E!==void 0&&(k.script=E),n({type:"update_persona",payload:k})},[n]),p=b.useCallback(m=>{n({type:"delete_persona",payload:{personaId:m}})},[n]);return{personas:a,createPersona:d,updatePersona:u,deletePersona:p,handleMessage:r,handleEvent:l}}function hC(n){const[a,i]=b.useState(""),[l,r]=b.useState(void 0),{connected:d,send:u}=eC(n,{onMessage:L,onConnect:q,onDisconnect:R}),p=nC(u),m=sC(u),g=iC(u),y=lC(u),v=rC(u),x=cC(u),S=uC(u),C=dC(u,d),w=fC(u),E="default_persona_id",k="onboarding_completed",N=b.useCallback($=>{i($),u({type:"set_setting",payload:{key:E,value:$}})},[u]),j=b.useCallback(()=>{r(!0),u({type:"set_setting",payload:{key:k,value:"true"}})},[u]);function U($){const ae=$.payload.key,oe=$.payload.value;if($.type==="setting.changed"){ae===E&&i(oe??""),ae===k&&r(oe==="true");return}p.handleEvent($)||g.handleEvent($)||y.handleEvent($)||v.handleEvent($)||x.handleEvent($)||S.handleEvent($)||w.handleEvent($)}function L($){var ae,oe,ne;if(nT($)){U($);return}if($.type==="setting"){const ce=(ae=$.payload)==null?void 0:ae.key,Q=(oe=$.payload)==null?void 0:oe.value;ce===E&&i(Q??""),ce===k&&r(Q==="true");return}if(!p.handleMessage($)&&!m.handleMessage($)&&!g.handleMessage($)&&!y.handleMessage($)&&!v.handleMessage($)&&!x.handleMessage($)&&!S.handleMessage($)&&!C.handleMessage($)&&!w.handleMessage($)&&$.type==="error"){console.error("[ws]",(ne=$.payload)==null?void 0:ne.message);return}}function q($){$({type:"list_environments"}),$({type:"list_sessions"}),$({type:"list_workspaces"}),$({type:"list_tokens"}),$({type:"get_credential_providers"}),$({type:"list_personas"}),$({type:"get_setting",payload:{key:E}}),$({type:"get_setting",payload:{key:k}}),$({type:"list_tasks",payload:{}}),$({type:"subscribe_all"})}function R(){g.onDisconnect(),y.onDisconnect()}const B=b.useCallback(()=>{u({type:"list_environments"}),u({type:"list_sessions"}),u({type:"list_workspaces"}),u({type:"list_tokens"})},[u]);return{connected:d,environments:p.environments,sessions:m.sessions,events:m.events,eventsDropped:m.eventsDropped,lastSpawnedId:m.lastSpawnedId,workspaces:g.workspaces,tasks:y.tasks,findings:v.findings,tokens:x.tokens,spawn:m.spawn,sendInput:m.sendInput,kill:m.kill,refresh:B,loadSessionEvents:m.loadSessionEvents,clearEvents:m.clearEvents,createWorkspace:g.createWorkspace,archiveWorkspace:g.archiveWorkspace,updateWorkspace:g.updateWorkspace,loadTasks:y.loadTasks,loadAllTasks:y.loadAllTasks,createTask:y.createTask,startTask:y.startTask,stopTask:y.stopTask,completeTask:y.completeTask,resumeTask:y.resumeTask,updateTask:y.updateTask,deleteTask:y.deleteTask,loadFindings:v.loadFindings,postFinding:v.postFinding,addEnvironment:p.addEnvironment,updateEnvironment:p.updateEnvironment,loadTokens:x.loadTokens,setToken:x.setToken,deleteToken:x.deleteToken,credentialProviders:S.credentialProviders,updateCredentialProviders:S.updateCredentialProviders,provisionStatus:p.provisionStatus,provisionEnvironment:p.provisionEnvironment,stopEnvironment:p.stopEnvironment,removeEnvironment:p.removeEnvironment,codespaces:C.codespaces,codespaceError:C.codespaceError,codespaceListError:C.codespaceListError,codespaceCreating:C.codespaceCreating,listCodespaces:C.listCodespaces,createCodespace:C.createCodespace,workspaceCreating:g.workspaceCreating,taskStartingId:y.taskStartingId,personas:w.personas,createPersona:w.createPersona,updatePersona:w.updatePersona,deletePersona:w.deletePersona,taskSessions:m.taskSessions,loadTaskSessions:m.loadTaskSessions,appDefaultPersonaId:a,setAppDefaultPersonaId:N,onboardingCompleted:l,completeOnboarding:j}}const oh=b.createContext(void 0);function pC({children:n}){const a=hC();return c.jsx(oh.Provider,{value:a,children:n})}function yt(){const n=b.useContext(oh);if(!n)throw new Error("useGrackle must be used within GrackleProvider");return n}const mC=[{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}],gC=[{id:"sess-001-prev",environmentId:"env-local-01",runtime:"claude-code",status:"failed",prompt:"Implement auth middleware",startedAt:"2026-02-26T14:00:00Z",endedAt:"2026-02-26T15:12:00Z",error:"Context window exceeded before completing implementation"},{id:"sess-001",environmentId:"env-local-01",runtime:"node",status:"running",prompt:"Refactor the authentication middleware to use JWT tokens",startedAt:"2026-02-27T08:15:00Z"},{id:"sess-002",environmentId:"env-docker-01",runtime:"python",status:"completed",prompt:"Write unit tests for the user registration endpoint",startedAt:"2026-02-27T07:30:00Z"},{id:"sess-003",environmentId:"env-local-01",runtime:"node",status:"failed",prompt:"Migrate database schema to add audit_log table",startedAt:"2026-02-26T22:45:00Z"},{id:"sess-004",environmentId:"env-docker-01",runtime:"python",status:"running",prompt:"Implement rate limiting for the public API",startedAt:"2026-02-27T09:00:00Z"}],vC=[{sessionId:"sess-001-prev",eventType:"status",timestamp:"2026-02-26T14:00:01Z",content:"running"},{sessionId:"sess-001-prev",eventType:"output",timestamp:"2026-02-26T14:00:05Z",content:"Reading src/middleware/auth.ts to understand the current authentication flow..."},{sessionId:"sess-001-prev",eventType:"error",timestamp:"2026-02-26T15:12:00Z",content:"Context window exceeded before completing implementation"},{sessionId:"sess-001",eventType:"status",timestamp:"2026-02-27T08:15:01Z",content:"running"},{sessionId:"sess-001",eventType:"output",timestamp:"2026-02-27T08:15:02Z",content:"Analyzing current authentication middleware in src/middleware/auth.ts..."},{sessionId:"sess-001",eventType:"output",timestamp:"2026-02-27T08:15:04Z",content:`Found 3 files using session-based auth:
37
37
  - src/middleware/auth.ts
38
38
  - src/routes/login.ts
39
39
  - src/routes/protected.ts`},{sessionId:"sess-001",eventType:"output",timestamp:"2026-02-27T08:15:07Z",content:"Installing jsonwebtoken and @types/jsonwebtoken..."},{sessionId:"sess-001",eventType:"output",timestamp:"2026-02-27T08:15:12Z",content:`Rewriting auth middleware:
@@ -97,4 +97,4 @@ const grackle = await host.mcpServer({
97
97
  url: env.vars.GRACKLE_MCP_URL,
98
98
  });
99
99
 
100
- $\`Summarize the current tasks.\`;`,rows:20,className:Ze.scriptEditor,required:!0,"data-testid":"persona-script-editor"})]})]}),c.jsxs("div",{className:Ze.formActions,children:[c.jsx("button",{type:"submit",className:Ze.btnPrimary,children:u?"Save":"Create"}),c.jsx("button",{type:"button",onClick:te,className:Ze.btnSecondary,children:"Cancel"})]})]});return c.jsxs("div",{className:Ze.container,children:[c.jsxs("div",{className:Ze.header,children:[c.jsx("h2",{children:"Personas"}),c.jsx("button",{onClick:ce,className:Ze.btnPrimary,children:"+ New Persona"})]}),(m||u)&&re(),n.length===0&&!m?c.jsx("p",{className:Ze.empty,children:"No personas yet. Create one to get started."}):c.jsx("div",{className:Ze.list,children:n.map(O=>{const W=r===O.id,we=O.type==="script";return c.jsxs("div",{className:`${Ze.card} ${(u==null?void 0:u.id)===O.id?Ze.active:""}`,"data-testid":`persona-card-${O.id}`,children:[c.jsxs("div",{className:Ze.cardHeader,children:[c.jsxs("span",{className:Ze.cardTitle,children:[c.jsx("strong",{children:O.name}),c.jsx("span",{className:Ze.typeBadge,"data-testid":`persona-type-badge-${O.id}`,children:we?"Script":"Agent"}),W&&c.jsx("span",{className:Ze.defaultBadge,"data-testid":`persona-default-badge-${O.id}`,children:"App Default"})]}),c.jsxs("div",{className:Ze.cardActions,children:[!W&&c.jsx("button",{onClick:()=>d(O.id),className:Ze.btnSmall,"data-testid":`persona-set-default-${O.id}`,title:"Set as app default persona",children:"Set Default"}),c.jsx("button",{onClick:()=>Q(O),className:Ze.btnSmall,children:"Edit"}),y===O.id?c.jsxs(c.Fragment,{children:[c.jsx("button",{onClick:()=>M(O.id),className:Ze.btnDanger,children:"Confirm"}),c.jsx("button",{onClick:()=>v(null),className:Ze.btnSmall,children:"Cancel"})]}):c.jsx("button",{onClick:()=>v(O.id),className:Ze.btnSmall,children:"Delete"})]})]}),O.description&&c.jsx("p",{className:Ze.description,children:O.description}),c.jsxs("div",{className:Ze.meta,children:[O.runtime&&c.jsxs("span",{children:["Runtime: ",O.runtime]}),O.model&&c.jsxs("span",{children:["Model: ",O.model]}),O.maxTurns>0&&c.jsxs("span",{children:["Max turns: ",O.maxTurns]})]}),we?c.jsxs("details",{className:Ze.promptDetails,children:[c.jsx("summary",{children:"Script"}),c.jsx("pre",{className:Ze.promptText,children:O.script})]}):c.jsxs("details",{className:Ze.promptDetails,children:[c.jsx("summary",{children:"System Prompt"}),c.jsx("pre",{className:Ze.promptText,children:O.systemPrompt})]})]},O.id)})})]})}function eL(){return c.jsx(JI,{})}function tL(){const{themeId:n,resolvedThemeId:a,setTheme:i,preferSystem:l,setPreferSystem:r}=Tb();return c.jsxs("section",{className:fe.section,children:[c.jsx("h3",{className:fe.sectionTitle,children:"Appearance"}),c.jsx("p",{className:fe.sectionDescription,children:"Choose how Grackle looks across the app."}),c.jsx("div",{className:fe.themeOptions,children:gc.filter(d=>!d.hidden).map(d=>{const u=!!(d.variantLightId&&d.variantDarkId),p=u?n===d.id||n===d.variantLightId||n===d.variantDarkId:n===d.id,m=u&&a===d.variantLightId;return c.jsxs("button",{type:"button",className:`${fe.themeOption} ${p?fe.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>i(d.id),children:[c.jsxs("span",{className:fe.themeOptionHeader,children:[c.jsxs("span",{children:[c.jsx("span",{className:fe.themeOptionLabel,children:d.label}),c.jsx("span",{className:fe.themeOptionDesc,children:d.description})]}),u&&c.jsxs("span",{className:fe.variantToggle,children:[c.jsx("span",{role:"button",tabIndex:0,className:`${fe.variantButton} ${p&&m?fe.variantActive:""}`,onClick:g=>{g.stopPropagation(),r(!1),i(d.variantLightId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),r(!1),i(d.variantLightId))},"aria-label":"Light variant","aria-pressed":p&&m,children:"☼"}),c.jsx("span",{role:"button",tabIndex:0,className:`${fe.variantButton} ${p&&!m?fe.variantActive:""}`,onClick:g=>{g.stopPropagation(),r(!1),i(d.variantDarkId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),r(!1),i(d.variantDarkId))},"aria-label":"Dark variant","aria-pressed":p&&!m,children:"☾"})]})]}),d.swatches&&c.jsx("span",{className:fe.themeSwatches,children:d.swatches.map((g,y)=>c.jsx("span",{className:fe.themeSwatch,style:{background:g}},y))})]},d.id)})}),c.jsxs("label",{className:fe.systemToggle,children:[c.jsx("input",{type:"checkbox",checked:l,onChange:d=>r(d.target.checked)}),c.jsx("span",{children:"Match system light/dark preference"})]}),c.jsx("p",{className:fe.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),c.jsxs("p",{className:fe.themeActive,children:["Active theme: ",c.jsx("strong",{children:a})]})]})}function nL(){return c.jsx(tL,{})}function aL(){const{connected:n,environments:a,sessions:i}=yt(),l=a.filter(u=>u.status==="connected").length,r=a.length,d=i.filter(u=>["running","idle"].includes(u.status)).length;return c.jsxs("section",{className:fe.section,"data-testid":"about-panel",children:[c.jsx("h3",{className:fe.sectionTitle,children:"About"}),c.jsx("p",{className:fe.sectionDescription,children:"Connection status and application information."}),c.jsxs("div",{className:fe.aboutGrid,children:[c.jsxs("div",{className:fe.aboutItem,children:[c.jsx("span",{className:fe.aboutLabel,children:"Connection"}),c.jsxs("span",{className:fe.aboutValue,children:[c.jsx("span",{className:`${fe.aboutDot} ${n?fe.aboutDotConnected:fe.aboutDotDisconnected}`}),n?"Connected":"Disconnected"]})]}),c.jsxs("div",{className:fe.aboutItem,children:[c.jsx("span",{className:fe.aboutLabel,children:"Environments"}),c.jsxs("span",{className:fe.aboutValue,children:[l,"/",r," connected"]})]}),c.jsxs("div",{className:fe.aboutItem,children:[c.jsx("span",{className:fe.aboutLabel,children:"Active Sessions"}),c.jsx("span",{className:fe.aboutValue,children:d})]}),c.jsxs("div",{className:fe.aboutItem,children:[c.jsx("span",{className:fe.aboutLabel,children:"Version"}),c.jsx("span",{className:fe.aboutValue,children:"0.53.3"})]})]})]})}function sL(){return c.jsx(aL,{})}const iL="_wizard_1260s_1",oL="_container_1260s_10",lL="_stepContent_1260s_19",rL="_logoArea_1260s_28",cL="_logoImage_1260s_32",uL="_heading_1260s_41",dL="_tagline_1260s_49",fL="_subtitle_1260s_56",hL="_featureList_1260s_64",pL="_runtimeGrid_1260s_89",mL="_runtimeCard_1260s_101",gL="_runtimeName_1260s_133",vL="_runtimeDescription_1260s_139",yL="_buttonRow_1260s_144",bL="_primaryButton_1260s_151",xL="_ghostButton_1260s_185",_L="_dots_1260s_213",SL="_dot_1260s_213",rt={wizard:iL,container:oL,stepContent:lL,logoArea:rL,logoImage:cL,heading:uL,tagline:dL,subtitle:fL,featureList:hL,runtimeGrid:pL,runtimeCard:mL,runtimeName:gL,runtimeDescription:vL,buttonRow:yL,primaryButton:bL,ghostButton:xL,dots:_L,dot:SL};function TL({onNext:n}){return c.jsxs("div",{className:rt.stepContent,"data-testid":"setup-welcome",children:[c.jsx("div",{className:rt.logoArea,children:c.jsx("img",{src:"/grackle-logo.png",alt:"Grackle",className:rt.logoImage})}),c.jsx("h1",{className:rt.heading,children:"Welcome to Grackle"}),c.jsx("p",{className:rt.tagline,children:"Multi-agent orchestration for software teams"}),c.jsx("button",{type:"button",className:rt.primaryButton,onClick:n,"data-testid":"setup-get-started",children:"Get Started"})]})}function kL({onNext:n,onBack:a}){return c.jsxs("div",{className:rt.stepContent,"data-testid":"setup-about",children:[c.jsx("h2",{className:rt.heading,children:"What is Grackle?"}),c.jsxs("ul",{className:rt.featureList,children:[c.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),c.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),c.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),c.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),c.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),c.jsxs("div",{className:rt.buttonRow,children:[c.jsx("button",{type:"button",className:rt.ghostButton,onClick:a,children:"Back"}),c.jsx("button",{type:"button",className:rt.primaryButton,onClick:n,"data-testid":"setup-about-next",children:"Next"})]})]})}const CL=[{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"}];function wL({currentRuntime:n,onFinish:a,onBack:i,finishDisabled:l}){const[r,d]=b.useState(n||"claude-code");return b.useEffect(()=>{n&&d(n)},[n]),c.jsxs("div",{className:rt.stepContent,"data-testid":"setup-runtime",children:[c.jsx("h2",{className:rt.heading,children:"Choose Your Runtime"}),c.jsx("p",{className:rt.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),c.jsx("div",{className:rt.runtimeGrid,children:CL.map(u=>c.jsxs("button",{type:"button",className:rt.runtimeCard,"data-selected":r===u.id,"aria-pressed":r===u.id,"data-testid":`runtime-card-${u.id}`,onClick:()=>d(u.id),children:[c.jsx("span",{className:rt.runtimeName,children:u.name}),c.jsx("span",{className:rt.runtimeDescription,children:u.description})]},u.id))}),c.jsxs("div",{className:rt.buttonRow,children:[c.jsx("button",{type:"button",className:rt.ghostButton,onClick:i,children:"Back"}),c.jsx("button",{type:"button",className:rt.primaryButton,onClick:()=>a(r),disabled:l,"data-testid":"setup-finish",children:"Finish"})]})]})}const EL=3,X0={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3"};function NL(){const{personas:n,updatePersona:a,completeOnboarding:i,onboardingCompleted:l}=yt(),r=Wt(),[d,u]=b.useState(0),p=n.find(g=>g.id==="claude-code"),m=b.useCallback(g=>{if(p&&g!==p.runtime){const v=X0[g]??"sonnet";a(p.id,void 0,void 0,void 0,g,v)}const y=n.find(v=>v.id===N0);if(y&&g!==y.runtime){const v=X0[g]??"sonnet";a(N0,void 0,void 0,void 0,g,v)}i(),r("/",{replace:!0})},[p,n,a,i,r]);return l===!0?c.jsx(Zo,{to:"/",replace:!0}):c.jsx("div",{className:rt.wizard,"data-testid":"setup-wizard",children:c.jsxs("div",{className:rt.container,children:[c.jsx(fn,{mode:"wait",children:c.jsxs(vt.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[d===0&&c.jsx(TL,{onNext:()=>u(1)}),d===1&&c.jsx(kL,{onNext:()=>u(2),onBack:()=>u(0)}),d===2&&c.jsx(wL,{currentRuntime:(p==null?void 0:p.runtime)??"claude-code",onFinish:m,onBack:()=>u(1),finishDisabled:!p})]},d)}),c.jsx("div",{className:rt.dots,children:Array.from({length:EL},(g,y)=>c.jsx("span",{className:rt.dot,"data-active":y===d},y))})]})})}const AL="_root_zndgp_1",jL="_body_zndgp_7",DL="_main_zndgp_19",ML="_sidebarWrapper_zndgp_26",RL="_overlay_zndgp_51",Po={root:AL,body:jL,main:DL,sidebarWrapper:ML,overlay:RL},BL=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function OL(){const{lastSpawnedId:n,environments:a,connected:i,onboardingCompleted:l}=yt(),{showToast:r}=Gi();wR(a,r);const d=Wt(),u=Vt(),[p,m]=b.useState(!1),g=b.useCallback(()=>m(y=>!y),[]);return b.useEffect(()=>{m(!1)},[u.pathname]),b.useEffect(()=>{if(!p)return;const y=v=>{v.key==="Escape"&&m(!1)};return document.addEventListener("keydown",y),()=>{document.removeEventListener("keydown",y)}},[p]),b.useEffect(()=>{n&&!u.pathname.includes("/tasks/")&&d(ih(n),{replace:!0})},[n,d,u.pathname]),i&&l===!1?c.jsx(Zo,{to:"/setup",replace:!0}):c.jsxs("div",{className:Po.root,children:[c.jsx(UC,{onToggleSidebar:g,sidebarOpen:p}),c.jsx(FC,{}),c.jsxs("div",{className:Po.body,children:[c.jsx("div",{className:Po.sidebarWrapper,"data-sidebar-open":p,children:c.jsx(WM,{})}),p&&c.jsx("div",{className:Po.overlay,"data-testid":"drawer-overlay",onClick:()=>m(!1)}),c.jsxs("div",{className:Po.main,children:[c.jsx(db,{}),c.jsx(fR,{})]})]}),c.jsx(CR,{})]})}function IL(){return c.jsxs(hk,{children:[c.jsx(Qe,{path:"setup",element:c.jsx(NL,{})}),c.jsxs(Qe,{element:c.jsx(OL,{}),children:[c.jsx(Qe,{index:!0,element:c.jsx(JB,{})}),c.jsx(Qe,{path:"chat",element:c.jsx(yO,{})}),c.jsx(Qe,{path:"tasks",element:c.jsx(QB,{})}),c.jsx(Qe,{path:"tasks/new",element:c.jsx(p4,{})}),c.jsx(Qe,{path:"tasks/:taskId",element:c.jsx(Ni,{})}),c.jsx(Qe,{path:"tasks/:taskId/stream",element:c.jsx(Ni,{})}),c.jsx(Qe,{path:"tasks/:taskId/findings",element:c.jsx(Ni,{})}),c.jsx(Qe,{path:"tasks/:taskId/edit",element:c.jsx(q0,{})}),c.jsx(Qe,{path:"workspaces",element:c.jsx(WB,{})}),c.jsx(Qe,{path:"workspaces/:workspaceId",element:c.jsx(q6,{})}),c.jsx(Qe,{path:"workspaces/:workspaceId/tasks/:taskId",element:c.jsx(Ni,{})}),c.jsx(Qe,{path:"workspaces/:workspaceId/tasks/:taskId/stream",element:c.jsx(Ni,{})}),c.jsx(Qe,{path:"workspaces/:workspaceId/tasks/:taskId/findings",element:c.jsx(Ni,{})}),c.jsx(Qe,{path:"workspaces/:workspaceId/tasks/:taskId/edit",element:c.jsx(q0,{})}),c.jsx(Qe,{path:"sessions/new",element:c.jsx(kO,{})}),c.jsx(Qe,{path:"sessions/:sessionId",element:c.jsx(EO,{})}),c.jsx(Qe,{path:"environments/new",element:c.jsx(Q4,{})}),c.jsx(Qe,{path:"environments/:environmentId",element:c.jsx(W4,{})}),c.jsxs(Qe,{path:"settings",element:c.jsx(a5,{}),children:[c.jsx(Qe,{index:!0,element:c.jsx(Zo,{to:"environments",replace:!0})}),c.jsx(Qe,{path:"environments",element:c.jsx(H5,{})}),c.jsx(Qe,{path:"credentials",element:c.jsx(NI,{})}),c.jsx(Qe,{path:"tokens",element:c.jsx(Zo,{to:"../credentials",replace:!0})}),c.jsx(Qe,{path:"personas",element:c.jsx(eL,{})}),c.jsx(Qe,{path:"appearance",element:c.jsx(nL,{})}),c.jsx(Qe,{path:"about",element:c.jsx(sL,{})})]}),c.jsx(Qe,{path:"*",element:c.jsx(Zo,{to:"/",replace:!0})})]})]})}const LL=1e4;function zL(){const{onboardingCompleted:n}=yt(),[a,i]=b.useState(!1);b.useEffect(()=>{if(n!==void 0)return;const r=setTimeout(()=>i(!0),LL);return()=>clearTimeout(r)},[n]);const l=n===void 0&&!a;return c.jsx(fn,{mode:"wait",children:l?c.jsx(vt.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:c.jsx(QD,{})},"splash"):c.jsx(vt.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:c.jsx(zk,{children:c.jsx(IL,{})})},"app")})}function UL(){const n=BL?TC:pC;return c.jsx(AC,{children:c.jsx(CC,{children:c.jsx(n,{children:c.jsx(zL,{})})})})}tT.createRoot(document.getElementById("root")).render(c.jsx(b.StrictMode,{children:c.jsx(UL,{})}));
100
+ $\`Summarize the current tasks.\`;`,rows:20,className:Ze.scriptEditor,required:!0,"data-testid":"persona-script-editor"})]})]}),c.jsxs("div",{className:Ze.formActions,children:[c.jsx("button",{type:"submit",className:Ze.btnPrimary,children:u?"Save":"Create"}),c.jsx("button",{type:"button",onClick:te,className:Ze.btnSecondary,children:"Cancel"})]})]});return c.jsxs("div",{className:Ze.container,children:[c.jsxs("div",{className:Ze.header,children:[c.jsx("h2",{children:"Personas"}),c.jsx("button",{onClick:ce,className:Ze.btnPrimary,children:"+ New Persona"})]}),(m||u)&&re(),n.length===0&&!m?c.jsx("p",{className:Ze.empty,children:"No personas yet. Create one to get started."}):c.jsx("div",{className:Ze.list,children:n.map(O=>{const W=r===O.id,we=O.type==="script";return c.jsxs("div",{className:`${Ze.card} ${(u==null?void 0:u.id)===O.id?Ze.active:""}`,"data-testid":`persona-card-${O.id}`,children:[c.jsxs("div",{className:Ze.cardHeader,children:[c.jsxs("span",{className:Ze.cardTitle,children:[c.jsx("strong",{children:O.name}),c.jsx("span",{className:Ze.typeBadge,"data-testid":`persona-type-badge-${O.id}`,children:we?"Script":"Agent"}),W&&c.jsx("span",{className:Ze.defaultBadge,"data-testid":`persona-default-badge-${O.id}`,children:"App Default"})]}),c.jsxs("div",{className:Ze.cardActions,children:[!W&&c.jsx("button",{onClick:()=>d(O.id),className:Ze.btnSmall,"data-testid":`persona-set-default-${O.id}`,title:"Set as app default persona",children:"Set Default"}),c.jsx("button",{onClick:()=>Q(O),className:Ze.btnSmall,children:"Edit"}),y===O.id?c.jsxs(c.Fragment,{children:[c.jsx("button",{onClick:()=>M(O.id),className:Ze.btnDanger,children:"Confirm"}),c.jsx("button",{onClick:()=>v(null),className:Ze.btnSmall,children:"Cancel"})]}):c.jsx("button",{onClick:()=>v(O.id),className:Ze.btnSmall,children:"Delete"})]})]}),O.description&&c.jsx("p",{className:Ze.description,children:O.description}),c.jsxs("div",{className:Ze.meta,children:[O.runtime&&c.jsxs("span",{children:["Runtime: ",O.runtime]}),O.model&&c.jsxs("span",{children:["Model: ",O.model]}),O.maxTurns>0&&c.jsxs("span",{children:["Max turns: ",O.maxTurns]})]}),we?c.jsxs("details",{className:Ze.promptDetails,children:[c.jsx("summary",{children:"Script"}),c.jsx("pre",{className:Ze.promptText,children:O.script})]}):c.jsxs("details",{className:Ze.promptDetails,children:[c.jsx("summary",{children:"System Prompt"}),c.jsx("pre",{className:Ze.promptText,children:O.systemPrompt})]})]},O.id)})})]})}function eL(){return c.jsx(JI,{})}function tL(){const{themeId:n,resolvedThemeId:a,setTheme:i,preferSystem:l,setPreferSystem:r}=Tb();return c.jsxs("section",{className:fe.section,children:[c.jsx("h3",{className:fe.sectionTitle,children:"Appearance"}),c.jsx("p",{className:fe.sectionDescription,children:"Choose how Grackle looks across the app."}),c.jsx("div",{className:fe.themeOptions,children:gc.filter(d=>!d.hidden).map(d=>{const u=!!(d.variantLightId&&d.variantDarkId),p=u?n===d.id||n===d.variantLightId||n===d.variantDarkId:n===d.id,m=u&&a===d.variantLightId;return c.jsxs("button",{type:"button",className:`${fe.themeOption} ${p?fe.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>i(d.id),children:[c.jsxs("span",{className:fe.themeOptionHeader,children:[c.jsxs("span",{children:[c.jsx("span",{className:fe.themeOptionLabel,children:d.label}),c.jsx("span",{className:fe.themeOptionDesc,children:d.description})]}),u&&c.jsxs("span",{className:fe.variantToggle,children:[c.jsx("span",{role:"button",tabIndex:0,className:`${fe.variantButton} ${p&&m?fe.variantActive:""}`,onClick:g=>{g.stopPropagation(),r(!1),i(d.variantLightId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),r(!1),i(d.variantLightId))},"aria-label":"Light variant","aria-pressed":p&&m,children:"☼"}),c.jsx("span",{role:"button",tabIndex:0,className:`${fe.variantButton} ${p&&!m?fe.variantActive:""}`,onClick:g=>{g.stopPropagation(),r(!1),i(d.variantDarkId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),r(!1),i(d.variantDarkId))},"aria-label":"Dark variant","aria-pressed":p&&!m,children:"☾"})]})]}),d.swatches&&c.jsx("span",{className:fe.themeSwatches,children:d.swatches.map((g,y)=>c.jsx("span",{className:fe.themeSwatch,style:{background:g}},y))})]},d.id)})}),c.jsxs("label",{className:fe.systemToggle,children:[c.jsx("input",{type:"checkbox",checked:l,onChange:d=>r(d.target.checked)}),c.jsx("span",{children:"Match system light/dark preference"})]}),c.jsx("p",{className:fe.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),c.jsxs("p",{className:fe.themeActive,children:["Active theme: ",c.jsx("strong",{children:a})]})]})}function nL(){return c.jsx(tL,{})}function aL(){const{connected:n,environments:a,sessions:i}=yt(),l=a.filter(u=>u.status==="connected").length,r=a.length,d=i.filter(u=>["running","idle"].includes(u.status)).length;return c.jsxs("section",{className:fe.section,"data-testid":"about-panel",children:[c.jsx("h3",{className:fe.sectionTitle,children:"About"}),c.jsx("p",{className:fe.sectionDescription,children:"Connection status and application information."}),c.jsxs("div",{className:fe.aboutGrid,children:[c.jsxs("div",{className:fe.aboutItem,children:[c.jsx("span",{className:fe.aboutLabel,children:"Connection"}),c.jsxs("span",{className:fe.aboutValue,children:[c.jsx("span",{className:`${fe.aboutDot} ${n?fe.aboutDotConnected:fe.aboutDotDisconnected}`}),n?"Connected":"Disconnected"]})]}),c.jsxs("div",{className:fe.aboutItem,children:[c.jsx("span",{className:fe.aboutLabel,children:"Environments"}),c.jsxs("span",{className:fe.aboutValue,children:[l,"/",r," connected"]})]}),c.jsxs("div",{className:fe.aboutItem,children:[c.jsx("span",{className:fe.aboutLabel,children:"Active Sessions"}),c.jsx("span",{className:fe.aboutValue,children:d})]}),c.jsxs("div",{className:fe.aboutItem,children:[c.jsx("span",{className:fe.aboutLabel,children:"Version"}),c.jsx("span",{className:fe.aboutValue,children:"0.53.5"})]})]})]})}function sL(){return c.jsx(aL,{})}const iL="_wizard_1260s_1",oL="_container_1260s_10",lL="_stepContent_1260s_19",rL="_logoArea_1260s_28",cL="_logoImage_1260s_32",uL="_heading_1260s_41",dL="_tagline_1260s_49",fL="_subtitle_1260s_56",hL="_featureList_1260s_64",pL="_runtimeGrid_1260s_89",mL="_runtimeCard_1260s_101",gL="_runtimeName_1260s_133",vL="_runtimeDescription_1260s_139",yL="_buttonRow_1260s_144",bL="_primaryButton_1260s_151",xL="_ghostButton_1260s_185",_L="_dots_1260s_213",SL="_dot_1260s_213",rt={wizard:iL,container:oL,stepContent:lL,logoArea:rL,logoImage:cL,heading:uL,tagline:dL,subtitle:fL,featureList:hL,runtimeGrid:pL,runtimeCard:mL,runtimeName:gL,runtimeDescription:vL,buttonRow:yL,primaryButton:bL,ghostButton:xL,dots:_L,dot:SL};function TL({onNext:n}){return c.jsxs("div",{className:rt.stepContent,"data-testid":"setup-welcome",children:[c.jsx("div",{className:rt.logoArea,children:c.jsx("img",{src:"/grackle-logo.png",alt:"Grackle",className:rt.logoImage})}),c.jsx("h1",{className:rt.heading,children:"Welcome to Grackle"}),c.jsx("p",{className:rt.tagline,children:"Multi-agent orchestration for software teams"}),c.jsx("button",{type:"button",className:rt.primaryButton,onClick:n,"data-testid":"setup-get-started",children:"Get Started"})]})}function kL({onNext:n,onBack:a}){return c.jsxs("div",{className:rt.stepContent,"data-testid":"setup-about",children:[c.jsx("h2",{className:rt.heading,children:"What is Grackle?"}),c.jsxs("ul",{className:rt.featureList,children:[c.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),c.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),c.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),c.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),c.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),c.jsxs("div",{className:rt.buttonRow,children:[c.jsx("button",{type:"button",className:rt.ghostButton,onClick:a,children:"Back"}),c.jsx("button",{type:"button",className:rt.primaryButton,onClick:n,"data-testid":"setup-about-next",children:"Next"})]})]})}const CL=[{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"}];function wL({currentRuntime:n,onFinish:a,onBack:i,finishDisabled:l}){const[r,d]=b.useState(n||"claude-code");return b.useEffect(()=>{n&&d(n)},[n]),c.jsxs("div",{className:rt.stepContent,"data-testid":"setup-runtime",children:[c.jsx("h2",{className:rt.heading,children:"Choose Your Runtime"}),c.jsx("p",{className:rt.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),c.jsx("div",{className:rt.runtimeGrid,children:CL.map(u=>c.jsxs("button",{type:"button",className:rt.runtimeCard,"data-selected":r===u.id,"aria-pressed":r===u.id,"data-testid":`runtime-card-${u.id}`,onClick:()=>d(u.id),children:[c.jsx("span",{className:rt.runtimeName,children:u.name}),c.jsx("span",{className:rt.runtimeDescription,children:u.description})]},u.id))}),c.jsxs("div",{className:rt.buttonRow,children:[c.jsx("button",{type:"button",className:rt.ghostButton,onClick:i,children:"Back"}),c.jsx("button",{type:"button",className:rt.primaryButton,onClick:()=>a(r),disabled:l,"data-testid":"setup-finish",children:"Finish"})]})]})}const EL=3,X0={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3"};function NL(){const{personas:n,updatePersona:a,completeOnboarding:i,onboardingCompleted:l}=yt(),r=Wt(),[d,u]=b.useState(0),p=n.find(g=>g.id==="claude-code"),m=b.useCallback(g=>{if(p&&g!==p.runtime){const v=X0[g]??"sonnet";a(p.id,void 0,void 0,void 0,g,v)}const y=n.find(v=>v.id===N0);if(y&&g!==y.runtime){const v=X0[g]??"sonnet";a(N0,void 0,void 0,void 0,g,v)}i(),r("/",{replace:!0})},[p,n,a,i,r]);return l===!0?c.jsx(Zo,{to:"/",replace:!0}):c.jsx("div",{className:rt.wizard,"data-testid":"setup-wizard",children:c.jsxs("div",{className:rt.container,children:[c.jsx(fn,{mode:"wait",children:c.jsxs(vt.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[d===0&&c.jsx(TL,{onNext:()=>u(1)}),d===1&&c.jsx(kL,{onNext:()=>u(2),onBack:()=>u(0)}),d===2&&c.jsx(wL,{currentRuntime:(p==null?void 0:p.runtime)??"claude-code",onFinish:m,onBack:()=>u(1),finishDisabled:!p})]},d)}),c.jsx("div",{className:rt.dots,children:Array.from({length:EL},(g,y)=>c.jsx("span",{className:rt.dot,"data-active":y===d},y))})]})})}const AL="_root_zndgp_1",jL="_body_zndgp_7",DL="_main_zndgp_19",ML="_sidebarWrapper_zndgp_26",RL="_overlay_zndgp_51",Po={root:AL,body:jL,main:DL,sidebarWrapper:ML,overlay:RL},BL=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function OL(){const{lastSpawnedId:n,environments:a,connected:i,onboardingCompleted:l}=yt(),{showToast:r}=Gi();wR(a,r);const d=Wt(),u=Vt(),[p,m]=b.useState(!1),g=b.useCallback(()=>m(y=>!y),[]);return b.useEffect(()=>{m(!1)},[u.pathname]),b.useEffect(()=>{if(!p)return;const y=v=>{v.key==="Escape"&&m(!1)};return document.addEventListener("keydown",y),()=>{document.removeEventListener("keydown",y)}},[p]),b.useEffect(()=>{n&&!u.pathname.includes("/tasks/")&&d(ih(n),{replace:!0})},[n,d,u.pathname]),i&&l===!1?c.jsx(Zo,{to:"/setup",replace:!0}):c.jsxs("div",{className:Po.root,children:[c.jsx(UC,{onToggleSidebar:g,sidebarOpen:p}),c.jsx(FC,{}),c.jsxs("div",{className:Po.body,children:[c.jsx("div",{className:Po.sidebarWrapper,"data-sidebar-open":p,children:c.jsx(WM,{})}),p&&c.jsx("div",{className:Po.overlay,"data-testid":"drawer-overlay",onClick:()=>m(!1)}),c.jsxs("div",{className:Po.main,children:[c.jsx(db,{}),c.jsx(fR,{})]})]}),c.jsx(CR,{})]})}function IL(){return c.jsxs(hk,{children:[c.jsx(Qe,{path:"setup",element:c.jsx(NL,{})}),c.jsxs(Qe,{element:c.jsx(OL,{}),children:[c.jsx(Qe,{index:!0,element:c.jsx(JB,{})}),c.jsx(Qe,{path:"chat",element:c.jsx(yO,{})}),c.jsx(Qe,{path:"tasks",element:c.jsx(QB,{})}),c.jsx(Qe,{path:"tasks/new",element:c.jsx(p4,{})}),c.jsx(Qe,{path:"tasks/:taskId",element:c.jsx(Ni,{})}),c.jsx(Qe,{path:"tasks/:taskId/stream",element:c.jsx(Ni,{})}),c.jsx(Qe,{path:"tasks/:taskId/findings",element:c.jsx(Ni,{})}),c.jsx(Qe,{path:"tasks/:taskId/edit",element:c.jsx(q0,{})}),c.jsx(Qe,{path:"workspaces",element:c.jsx(WB,{})}),c.jsx(Qe,{path:"workspaces/:workspaceId",element:c.jsx(q6,{})}),c.jsx(Qe,{path:"workspaces/:workspaceId/tasks/:taskId",element:c.jsx(Ni,{})}),c.jsx(Qe,{path:"workspaces/:workspaceId/tasks/:taskId/stream",element:c.jsx(Ni,{})}),c.jsx(Qe,{path:"workspaces/:workspaceId/tasks/:taskId/findings",element:c.jsx(Ni,{})}),c.jsx(Qe,{path:"workspaces/:workspaceId/tasks/:taskId/edit",element:c.jsx(q0,{})}),c.jsx(Qe,{path:"sessions/new",element:c.jsx(kO,{})}),c.jsx(Qe,{path:"sessions/:sessionId",element:c.jsx(EO,{})}),c.jsx(Qe,{path:"environments/new",element:c.jsx(Q4,{})}),c.jsx(Qe,{path:"environments/:environmentId",element:c.jsx(W4,{})}),c.jsxs(Qe,{path:"settings",element:c.jsx(a5,{}),children:[c.jsx(Qe,{index:!0,element:c.jsx(Zo,{to:"environments",replace:!0})}),c.jsx(Qe,{path:"environments",element:c.jsx(H5,{})}),c.jsx(Qe,{path:"credentials",element:c.jsx(NI,{})}),c.jsx(Qe,{path:"tokens",element:c.jsx(Zo,{to:"../credentials",replace:!0})}),c.jsx(Qe,{path:"personas",element:c.jsx(eL,{})}),c.jsx(Qe,{path:"appearance",element:c.jsx(nL,{})}),c.jsx(Qe,{path:"about",element:c.jsx(sL,{})})]}),c.jsx(Qe,{path:"*",element:c.jsx(Zo,{to:"/",replace:!0})})]})]})}const LL=1e4;function zL(){const{onboardingCompleted:n}=yt(),[a,i]=b.useState(!1);b.useEffect(()=>{if(n!==void 0)return;const r=setTimeout(()=>i(!0),LL);return()=>clearTimeout(r)},[n]);const l=n===void 0&&!a;return c.jsx(fn,{mode:"wait",children:l?c.jsx(vt.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:c.jsx(QD,{})},"splash"):c.jsx(vt.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:c.jsx(zk,{children:c.jsx(IL,{})})},"app")})}function UL(){const n=BL?TC:pC;return c.jsx(AC,{children:c.jsx(CC,{children:c.jsx(n,{children:c.jsx(zL,{})})})})}tT.createRoot(document.getElementById("root")).render(c.jsx(b.StrictMode,{children:c.jsx(UL,{})}));
package/dist/index.html CHANGED
@@ -10,7 +10,7 @@
10
10
  <link rel="icon" type="image/x-icon" href="/favicon.ico" />
11
11
  <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
12
12
  <link rel="manifest" href="/manifest.json" />
13
- <script type="module" crossorigin src="/assets/index-Do5zZpQF.js"></script>
13
+ <script type="module" crossorigin src="/assets/index-_W6RuVGC.js"></script>
14
14
  <link rel="modulepreload" crossorigin href="/assets/markdown-gcy1Jmzi.js">
15
15
  <link rel="modulepreload" crossorigin href="/assets/dagview-EHk2VaeR.js">
16
16
  <link rel="stylesheet" crossorigin href="/assets/index-Ini4xe5_.css">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grackle-ai/web",
3
- "version": "0.53.4",
3
+ "version": "0.54.0",
4
4
  "description": "React web UI for the Grackle multi-agent coordination platform",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -31,7 +31,7 @@
31
31
  "rehype-prism-plus": "^2.0.0",
32
32
  "remark-gfm": "^4.0.0",
33
33
  "react-router": "^7.0.0",
34
- "@grackle-ai/common": "0.53.4"
34
+ "@grackle-ai/common": "0.54.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@rushstack/heft": "1.2.4",