@elizaos/cli 1.0.0-alpha.61 → 1.0.0-alpha.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{index-D7hBpXxf.js → index-B99AydFo.js} +2 -2
- package/dist/assets/index-B99AydFo.js.br +0 -0
- package/dist/assets/{index-B87uCoX3.js → index-Daaf1vE3.js} +1 -1
- package/dist/assets/index-Daaf1vE3.js.br +0 -0
- package/dist/{chunk-LKK6GVNQ.js → chunk-I4AIOIG5.js} +36 -62
- package/dist/{chunk-W7T2ACUN.js → chunk-NLAUSC3K.js} +2 -22
- package/dist/commands/start.js +1 -1
- package/dist/commands/test.js +2 -2
- package/dist/index.html +1 -1
- package/dist/index.js +2 -2
- package/package.json +6 -6
- package/templates/plugin-starter/package.json +1 -1
- package/templates/project-starter/package.json +6 -6
- package/dist/assets/index-B87uCoX3.js.br +0 -0
- package/dist/assets/index-D7hBpXxf.js.br +0 -0
|
@@ -296,7 +296,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${e.do
|
|
|
296
296
|
* @license MIT
|
|
297
297
|
*/var Vw="popstate";function vD(t={}){function e(s,i){let{pathname:l,search:c,hash:f}=s.location;return kv("",{pathname:l,search:c,hash:f},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function n(s,i){return typeof i=="string"?i:du(i)}return bD(e,n,null,t)}function ut(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function _r(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function yD(){return Math.random().toString(36).substring(2,10)}function $w(t,e){return{usr:t.state,key:t.key,idx:e}}function kv(t,e,n=null,s){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?Po(e):e,state:n,key:e&&e.key||s||yD()}}function du({pathname:t="/",search:e="",hash:n=""}){return e&&e!=="?"&&(t+=e.charAt(0)==="?"?e:"?"+e),n&&n!=="#"&&(t+=n.charAt(0)==="#"?n:"#"+n),t}function Po(t){let e={};if(t){let n=t.indexOf("#");n>=0&&(e.hash=t.substring(n),t=t.substring(0,n));let s=t.indexOf("?");s>=0&&(e.search=t.substring(s),t=t.substring(0,s)),t&&(e.pathname=t)}return e}function bD(t,e,n,s={}){let{window:i=document.defaultView,v5Compat:l=!1}=s,c=i.history,f="POP",d=null,h=p();h==null&&(h=0,c.replaceState({...c.state,idx:h},""));function p(){return(c.state||{idx:null}).idx}function b(){f="POP";let w=p(),C=w==null?null:w-h;h=w,d&&d({action:f,location:x.location,delta:C})}function m(w,C){f="PUSH";let T=kv(x.location,w,C);h=p()+1;let A=$w(T,h),R=x.createHref(T);try{c.pushState(A,"",R)}catch(k){if(k instanceof DOMException&&k.name==="DataCloneError")throw k;i.location.assign(R)}l&&d&&d({action:f,location:x.location,delta:1})}function v(w,C){f="REPLACE";let T=kv(x.location,w,C);h=p();let A=$w(T,h),R=x.createHref(T);c.replaceState(A,"",R),l&&d&&d({action:f,location:x.location,delta:0})}function g(w){let C=i.location.origin!=="null"?i.location.origin:i.location.href,T=typeof w=="string"?w:du(w);return T=T.replace(/ $/,"%20"),ut(C,`No window.location.(origin|href) available to create URL for href: ${T}`),new URL(T,C)}let x={get action(){return f},get location(){return t(i,c)},listen(w){if(d)throw new Error("A history only accepts one active listener");return i.addEventListener(Vw,b),d=w,()=>{i.removeEventListener(Vw,b),d=null}},createHref(w){return e(i,w)},createURL:g,encodeLocation(w){let C=g(w);return{pathname:C.pathname,search:C.search,hash:C.hash}},push:m,replace:v,go(w){return c.go(w)}};return x}function LC(t,e,n="/"){return xD(t,e,n,!1)}function xD(t,e,n,s){let i=typeof e=="string"?Po(e):e,l=ps(i.pathname||"/",n);if(l==null)return null;let c=DC(t);wD(c);let f=null;for(let d=0;f==null&&d<c.length;++d){let h=MD(l);f=ND(c[d],h,s)}return f}function DC(t,e=[],n=[],s=""){let i=(l,c,f)=>{let d={relativePath:f===void 0?l.path||"":f,caseSensitive:l.caseSensitive===!0,childrenIndex:c,route:l};d.relativePath.startsWith("/")&&(ut(d.relativePath.startsWith(s),`Absolute route path "${d.relativePath}" nested under path "${s}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),d.relativePath=d.relativePath.slice(s.length));let h=cs([s,d.relativePath]),p=n.concat(d);l.children&&l.children.length>0&&(ut(l.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),DC(l.children,e,p,h)),!(l.path==null&&!l.index)&&e.push({path:h,score:AD(h,l.index),routesMeta:p})};return t.forEach((l,c)=>{var f;if(l.path===""||!((f=l.path)!=null&&f.includes("?")))i(l,c);else for(let d of jC(l.path))i(l,c,d)}),e}function jC(t){let e=t.split("/");if(e.length===0)return[];let[n,...s]=e,i=n.endsWith("?"),l=n.replace(/\?$/,"");if(s.length===0)return i?[l,""]:[l];let c=jC(s.join("/")),f=[];return f.push(...c.map(d=>d===""?l:[l,d].join("/"))),i&&f.push(...c),f.map(d=>t.startsWith("/")&&d===""?"/":d)}function wD(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:OD(e.routesMeta.map(s=>s.childrenIndex),n.routesMeta.map(s=>s.childrenIndex)))}var SD=/^:[\w-]+$/,_D=3,ED=2,CD=1,TD=10,RD=-2,Gw=t=>t==="*";function AD(t,e){let n=t.split("/"),s=n.length;return n.some(Gw)&&(s+=RD),e&&(s+=ED),n.filter(i=>!Gw(i)).reduce((i,l)=>i+(SD.test(l)?_D:l===""?CD:TD),s)}function OD(t,e){return t.length===e.length&&t.slice(0,-1).every((s,i)=>s===e[i])?t[t.length-1]-e[e.length-1]:0}function ND(t,e,n=!1){let{routesMeta:s}=t,i={},l="/",c=[];for(let f=0;f<s.length;++f){let d=s[f],h=f===s.length-1,p=l==="/"?e:e.slice(l.length)||"/",b=_d({path:d.relativePath,caseSensitive:d.caseSensitive,end:h},p),m=d.route;if(!b&&h&&n&&!s[s.length-1].route.index&&(b=_d({path:d.relativePath,caseSensitive:d.caseSensitive,end:!1},p)),!b)return null;Object.assign(i,b.params),c.push({params:i,pathname:cs([l,b.pathname]),pathnameBase:PD(cs([l,b.pathnameBase])),route:m}),b.pathnameBase!=="/"&&(l=cs([l,b.pathnameBase]))}return c}function _d(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,s]=kD(t.path,t.caseSensitive,t.end),i=e.match(n);if(!i)return null;let l=i[0],c=l.replace(/(.)\/+$/,"$1"),f=i.slice(1);return{params:s.reduce((h,{paramName:p,isOptional:b},m)=>{if(p==="*"){let g=f[m]||"";c=l.slice(0,l.length-g.length).replace(/(.)\/+$/,"$1")}const v=f[m];return b&&!v?h[p]=void 0:h[p]=(v||"").replace(/%2F/g,"/"),h},{}),pathname:l,pathnameBase:c,pattern:t}}function kD(t,e=!1,n=!0){_r(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let s=[],i="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(c,f,d)=>(s.push({paramName:f,isOptional:d!=null}),d?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(s.push({paramName:"*"}),i+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":t!==""&&t!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,e?void 0:"i"),s]}function MD(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return _r(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${e}).`),t}}function ps(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let n=e.endsWith("/")?e.length-1:e.length,s=t.charAt(n);return s&&s!=="/"?null:t.slice(n)||"/"}function LD(t,e="/"){let{pathname:n,search:s="",hash:i=""}=typeof t=="string"?Po(t):t;return{pathname:n?n.startsWith("/")?n:DD(n,e):e,search:ID(s),hash:BD(i)}}function DD(t,e){let n=e.replace(/\/+$/,"").split("/");return t.split("/").forEach(i=>{i===".."?n.length>1&&n.pop():i!=="."&&n.push(i)}),n.length>1?n.join("/"):"/"}function Fm(t,e,n,s){return`Cannot include a '${t}' character in a manually specified \`to.${e}\` field [${JSON.stringify(s)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function jD(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function PC(t){let e=jD(t);return e.map((n,s)=>s===e.length-1?n.pathname:n.pathnameBase)}function IC(t,e,n,s=!1){let i;typeof t=="string"?i=Po(t):(i={...t},ut(!i.pathname||!i.pathname.includes("?"),Fm("?","pathname","search",i)),ut(!i.pathname||!i.pathname.includes("#"),Fm("#","pathname","hash",i)),ut(!i.search||!i.search.includes("#"),Fm("#","search","hash",i)));let l=t===""||i.pathname==="",c=l?"/":i.pathname,f;if(c==null)f=n;else{let b=e.length-1;if(!s&&c.startsWith("..")){let m=c.split("/");for(;m[0]==="..";)m.shift(),b-=1;i.pathname=m.join("/")}f=b>=0?e[b]:"/"}let d=LD(i,f),h=c&&c!=="/"&&c.endsWith("/"),p=(l||c===".")&&n.endsWith("/");return!d.pathname.endsWith("/")&&(h||p)&&(d.pathname+="/"),d}var cs=t=>t.join("/").replace(/\/\/+/g,"/"),PD=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),ID=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,BD=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function zD(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}var BC=["POST","PUT","PATCH","DELETE"];new Set(BC);var qD=["GET",...BC];new Set(qD);var Io=E.createContext(null);Io.displayName="DataRouter";var Kd=E.createContext(null);Kd.displayName="DataRouterState";var zC=E.createContext({isTransitioning:!1});zC.displayName="ViewTransition";var UD=E.createContext(new Map);UD.displayName="Fetchers";var HD=E.createContext(null);HD.displayName="Await";var Nr=E.createContext(null);Nr.displayName="Navigation";var qu=E.createContext(null);qu.displayName="Location";var kr=E.createContext({outlet:null,matches:[],isDataRoute:!1});kr.displayName="Route";var Ny=E.createContext(null);Ny.displayName="RouteError";function FD(t,{relative:e}={}){ut(Uu(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:s}=E.useContext(Nr),{hash:i,pathname:l,search:c}=Hu(t,{relative:e}),f=l;return n!=="/"&&(f=l==="/"?n:cs([n,l])),s.createHref({pathname:f,search:c,hash:i})}function Uu(){return E.useContext(qu)!=null}function ha(){return ut(Uu(),"useLocation() may be used only in the context of a <Router> component."),E.useContext(qu).location}var qC="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function UC(t){E.useContext(Nr).static||E.useLayoutEffect(t)}function Bo(){let{isDataRoute:t}=E.useContext(kr);return t?nj():VD()}function VD(){ut(Uu(),"useNavigate() may be used only in the context of a <Router> component.");let t=E.useContext(Io),{basename:e,navigator:n}=E.useContext(Nr),{matches:s}=E.useContext(kr),{pathname:i}=ha(),l=JSON.stringify(PC(s)),c=E.useRef(!1);return UC(()=>{c.current=!0}),E.useCallback((d,h={})=>{if(_r(c.current,qC),!c.current)return;if(typeof d=="number"){n.go(d);return}let p=IC(d,JSON.parse(l),i,h.relative==="path");t==null&&e!=="/"&&(p.pathname=p.pathname==="/"?e:cs([e,p.pathname])),(h.replace?n.replace:n.push)(p,h.state,h)},[e,n,l,i,t])}E.createContext(null);function HC(){let{matches:t}=E.useContext(kr),e=t[t.length-1];return e?e.params:{}}function Hu(t,{relative:e}={}){let{matches:n}=E.useContext(kr),{pathname:s}=ha(),i=JSON.stringify(PC(n));return E.useMemo(()=>IC(t,JSON.parse(i),s,e==="path"),[t,i,s,e])}function $D(t,e){return FC(t,e)}function FC(t,e,n,s){var T;ut(Uu(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:i,static:l}=E.useContext(Nr),{matches:c}=E.useContext(kr),f=c[c.length-1],d=f?f.params:{},h=f?f.pathname:"/",p=f?f.pathnameBase:"/",b=f&&f.route;{let A=b&&b.path||"";VC(h,!b||A.endsWith("*")||A.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${h}" (under <Route path="${A}">) 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.
|
|
298
298
|
|
|
299
|
-
Please change the parent <Route path="${A}"> to <Route path="${A==="/"?"*":`${A}/*`}">.`)}let m=ha(),v;if(e){let A=typeof e=="string"?Po(e):e;ut(p==="/"||((T=A.pathname)==null?void 0:T.startsWith(p)),`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 "${p}" but pathname "${A.pathname}" was given in the \`location\` prop.`),v=A}else v=m;let g=v.pathname||"/",x=g;if(p!=="/"){let A=p.replace(/^\//,"").split("/");x="/"+g.replace(/^\//,"").split("/").slice(A.length).join("/")}let w=!l&&n&&n.matches&&n.matches.length>0?n.matches:LC(t,{pathname:x});_r(b||w!=null,`No routes matched location "${v.pathname}${v.search}${v.hash}" `),_r(w==null||w[w.length-1].route.element!==void 0||w[w.length-1].route.Component!==void 0||w[w.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 C=KD(w&&w.map(A=>Object.assign({},A,{params:Object.assign({},d,A.params),pathname:cs([p,i.encodeLocation?i.encodeLocation(A.pathname).pathname:A.pathname]),pathnameBase:A.pathnameBase==="/"?p:cs([p,i.encodeLocation?i.encodeLocation(A.pathnameBase).pathname:A.pathnameBase])})),c,n,s);return e&&C?E.createElement(qu.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...v},navigationType:"POP"}},C):C}function GD(){let t=tj(),e=zD(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,s="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:s},l={padding:"2px 4px",backgroundColor:s},c=null;return console.error("Error handled by React Router default ErrorBoundary:",t),c=E.createElement(E.Fragment,null,E.createElement("p",null,"💿 Hey developer 👋"),E.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",E.createElement("code",{style:l},"ErrorBoundary")," or"," ",E.createElement("code",{style:l},"errorElement")," prop on your route.")),E.createElement(E.Fragment,null,E.createElement("h2",null,"Unexpected Application Error!"),E.createElement("h3",{style:{fontStyle:"italic"}},e),n?E.createElement("pre",{style:i},n):null,c)}var YD=E.createElement(GD,null),QD=class extends E.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,e){return e.location!==t.location||e.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:e.error,location:e.location,revalidation:t.revalidation||e.revalidation}}componentDidCatch(t,e){console.error("React Router caught the following error during render",t,e)}render(){return this.state.error!==void 0?E.createElement(kr.Provider,{value:this.props.routeContext},E.createElement(Ny.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function WD({routeContext:t,match:e,children:n}){let s=E.useContext(Io);return s&&s.static&&s.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=e.route.id),E.createElement(kr.Provider,{value:t},n)}function KD(t,e=[],n=null,s=null){if(t==null){if(!n)return null;if(n.errors)t=n.matches;else if(e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let i=t,l=n==null?void 0:n.errors;if(l!=null){let d=i.findIndex(h=>h.route.id&&(l==null?void 0:l[h.route.id])!==void 0);ut(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(l).join(",")}`),i=i.slice(0,Math.min(i.length,d+1))}let c=!1,f=-1;if(n)for(let d=0;d<i.length;d++){let h=i[d];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(f=d),h.route.id){let{loaderData:p,errors:b}=n,m=h.route.loader&&!p.hasOwnProperty(h.route.id)&&(!b||b[h.route.id]===void 0);if(h.route.lazy||m){c=!0,f>=0?i=i.slice(0,f+1):i=[i[0]];break}}}return i.reduceRight((d,h,p)=>{let b,m=!1,v=null,g=null;n&&(b=l&&h.route.id?l[h.route.id]:void 0,v=h.route.errorElement||YD,c&&(f<0&&p===0?(VC("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),m=!0,g=null):f===p&&(m=!0,g=h.route.hydrateFallbackElement||null)));let x=e.concat(i.slice(0,p+1)),w=()=>{let C;return b?C=v:m?C=g:h.route.Component?C=E.createElement(h.route.Component,null):h.route.element?C=h.route.element:C=d,E.createElement(WD,{match:h,routeContext:{outlet:d,matches:x,isDataRoute:n!=null},children:C})};return n&&(h.route.ErrorBoundary||h.route.errorElement||p===0)?E.createElement(QD,{location:n.location,revalidation:n.revalidation,component:v,error:b,children:w(),routeContext:{outlet:null,matches:x,isDataRoute:!0}}):w()},null)}function ky(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ZD(t){let e=E.useContext(Io);return ut(e,ky(t)),e}function XD(t){let e=E.useContext(Kd);return ut(e,ky(t)),e}function JD(t){let e=E.useContext(kr);return ut(e,ky(t)),e}function My(t){let e=JD(t),n=e.matches[e.matches.length-1];return ut(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function ej(){return My("useRouteId")}function tj(){var s;let t=E.useContext(Ny),e=XD("useRouteError"),n=My("useRouteError");return t!==void 0?t:(s=e.errors)==null?void 0:s[n]}function nj(){let{router:t}=ZD("useNavigate"),e=My("useNavigate"),n=E.useRef(!1);return UC(()=>{n.current=!0}),E.useCallback(async(i,l={})=>{_r(n.current,qC),n.current&&(typeof i=="number"?t.navigate(i):await t.navigate(i,{fromRouteId:e,...l}))},[t,e])}var Yw={};function VC(t,e,n){!e&&!Yw[t]&&(Yw[t]=!0,_r(!1,n))}E.memo(rj);function rj({routes:t,future:e,state:n}){return FC(t,void 0,n,e)}function za(t){ut(!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 sj({basename:t="/",children:e=null,location:n,navigationType:s="POP",navigator:i,static:l=!1}){ut(!Uu(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let c=t.replace(/^\/*/,"/"),f=E.useMemo(()=>({basename:c,navigator:i,static:l,future:{}}),[c,i,l]);typeof n=="string"&&(n=Po(n));let{pathname:d="/",search:h="",hash:p="",state:b=null,key:m="default"}=n,v=E.useMemo(()=>{let g=ps(d,c);return g==null?null:{location:{pathname:g,search:h,hash:p,state:b,key:m},navigationType:s}},[c,d,h,p,b,m,s]);return _r(v!=null,`<Router basename="${c}"> is not able to match the URL "${d}${h}${p}" because it does not start with the basename, so the <Router> won't render anything.`),v==null?null:E.createElement(Nr.Provider,{value:f},E.createElement(qu.Provider,{children:e,value:v}))}function aj({children:t,location:e}){return $D(Mv(t),e)}function Mv(t,e=[]){let n=[];return E.Children.forEach(t,(s,i)=>{if(!E.isValidElement(s))return;let l=[...e,i];if(s.type===E.Fragment){n.push.apply(n,Mv(s.props.children,l));return}ut(s.type===za,`[${typeof s.type=="string"?s.type:s.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),ut(!s.props.index||!s.props.children,"An index route cannot have child routes.");let c={id:s.props.id||l.join("-"),caseSensitive:s.props.caseSensitive,element:s.props.element,Component:s.props.Component,index:s.props.index,path:s.props.path,loader:s.props.loader,action:s.props.action,hydrateFallbackElement:s.props.hydrateFallbackElement,HydrateFallback:s.props.HydrateFallback,errorElement:s.props.errorElement,ErrorBoundary:s.props.ErrorBoundary,hasErrorBoundary:s.props.hasErrorBoundary===!0||s.props.ErrorBoundary!=null||s.props.errorElement!=null,shouldRevalidate:s.props.shouldRevalidate,handle:s.props.handle,lazy:s.props.lazy};s.props.children&&(c.children=Mv(s.props.children,l)),n.push(c)}),n}var nd="get",rd="application/x-www-form-urlencoded";function Zd(t){return t!=null&&typeof t.tagName=="string"}function ij(t){return Zd(t)&&t.tagName.toLowerCase()==="button"}function oj(t){return Zd(t)&&t.tagName.toLowerCase()==="form"}function lj(t){return Zd(t)&&t.tagName.toLowerCase()==="input"}function uj(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function cj(t,e){return t.button===0&&(!e||e==="_self")&&!uj(t)}var pf=null;function fj(){if(pf===null)try{new FormData(document.createElement("form"),0),pf=!1}catch{pf=!0}return pf}var dj=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Vm(t){return t!=null&&!dj.has(t)?(_r(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${rd}"`),null):t}function hj(t,e){let n,s,i,l,c;if(oj(t)){let f=t.getAttribute("action");s=f?ps(f,e):null,n=t.getAttribute("method")||nd,i=Vm(t.getAttribute("enctype"))||rd,l=new FormData(t)}else if(ij(t)||lj(t)&&(t.type==="submit"||t.type==="image")){let f=t.form;if(f==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let d=t.getAttribute("formaction")||f.getAttribute("action");if(s=d?ps(d,e):null,n=t.getAttribute("formmethod")||f.getAttribute("method")||nd,i=Vm(t.getAttribute("formenctype"))||Vm(f.getAttribute("enctype"))||rd,l=new FormData(f,t),!fj()){let{name:h,type:p,value:b}=t;if(p==="image"){let m=h?`${h}.`:"";l.append(`${m}x`,"0"),l.append(`${m}y`,"0")}else h&&l.append(h,b)}}else{if(Zd(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=nd,s=null,i=rd,c=t}return l&&i==="text/plain"&&(c=l,l=void 0),{action:s,method:n.toLowerCase(),encType:i,formData:l,body:c}}function Ly(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}async function pj(t,e){if(t.id in e)return e[t.id];try{let n=await import(t.module);return e[t.id]=n,n}catch(n){return console.error(`Error loading route module \`${t.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function mj(t){return t==null?!1:t.href==null?t.rel==="preload"&&typeof t.imageSrcSet=="string"&&typeof t.imageSizes=="string":typeof t.rel=="string"&&typeof t.href=="string"}async function gj(t,e,n){let s=await Promise.all(t.map(async i=>{let l=e.routes[i.route.id];if(l){let c=await pj(l,n);return c.links?c.links():[]}return[]}));return xj(s.flat(1).filter(mj).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function Qw(t,e,n,s,i,l){let c=(d,h)=>n[h]?d.route.id!==n[h].route.id:!0,f=(d,h)=>{var p;return n[h].pathname!==d.pathname||((p=n[h].route.path)==null?void 0:p.endsWith("*"))&&n[h].params["*"]!==d.params["*"]};return l==="assets"?e.filter((d,h)=>c(d,h)||f(d,h)):l==="data"?e.filter((d,h)=>{var b;let p=s.routes[d.route.id];if(!p||!p.hasLoader)return!1;if(c(d,h)||f(d,h))return!0;if(d.route.shouldRevalidate){let m=d.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:((b=n[0])==null?void 0:b.params)||{},nextUrl:new URL(t,window.origin),nextParams:d.params,defaultShouldRevalidate:!0});if(typeof m=="boolean")return m}return!0}):[]}function vj(t,e,{includeHydrateFallback:n}={}){return yj(t.map(s=>{let i=e.routes[s.route.id];if(!i)return[];let l=[i.module];return i.clientActionModule&&(l=l.concat(i.clientActionModule)),i.clientLoaderModule&&(l=l.concat(i.clientLoaderModule)),n&&i.hydrateFallbackModule&&(l=l.concat(i.hydrateFallbackModule)),i.imports&&(l=l.concat(i.imports)),l}).flat(1))}function yj(t){return[...new Set(t)]}function bj(t){let e={},n=Object.keys(t).sort();for(let s of n)e[s]=t[s];return e}function xj(t,e){let n=new Set;return new Set(e),t.reduce((s,i)=>{let l=JSON.stringify(bj(i));return n.has(l)||(n.add(l),s.push({key:l,link:i})),s},[])}function wj(t,e){let n=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return n.pathname==="/"?n.pathname="_root.data":e&&ps(n.pathname,e)==="/"?n.pathname=`${e.replace(/\/$/,"")}/_root.data`:n.pathname=`${n.pathname.replace(/\/$/,"")}.data`,n}function $C(){let t=E.useContext(Io);return Ly(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Sj(){let t=E.useContext(Kd);return Ly(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var Dy=E.createContext(void 0);Dy.displayName="FrameworkContext";function GC(){let t=E.useContext(Dy);return Ly(t,"You must render this element inside a <HydratedRouter> element"),t}function _j(t,e){let n=E.useContext(Dy),[s,i]=E.useState(!1),[l,c]=E.useState(!1),{onFocus:f,onBlur:d,onMouseEnter:h,onMouseLeave:p,onTouchStart:b}=e,m=E.useRef(null);E.useEffect(()=>{if(t==="render"&&c(!0),t==="viewport"){let x=C=>{C.forEach(T=>{c(T.isIntersecting)})},w=new IntersectionObserver(x,{threshold:.5});return m.current&&w.observe(m.current),()=>{w.disconnect()}}},[t]),E.useEffect(()=>{if(s){let x=setTimeout(()=>{c(!0)},100);return()=>{clearTimeout(x)}}},[s]);let v=()=>{i(!0)},g=()=>{i(!1),c(!1)};return n?t!=="intent"?[l,m,{}]:[l,m,{onFocus:Fl(f,v),onBlur:Fl(d,g),onMouseEnter:Fl(h,v),onMouseLeave:Fl(p,g),onTouchStart:Fl(b,v)}]:[!1,m,{}]}function Fl(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function Ej({page:t,...e}){let{router:n}=$C(),s=E.useMemo(()=>LC(n.routes,t,n.basename),[n.routes,t,n.basename]);return s?E.createElement(Tj,{page:t,matches:s,...e}):null}function Cj(t){let{manifest:e,routeModules:n}=GC(),[s,i]=E.useState([]);return E.useEffect(()=>{let l=!1;return gj(t,e,n).then(c=>{l||i(c)}),()=>{l=!0}},[t,e,n]),s}function Tj({page:t,matches:e,...n}){let s=ha(),{manifest:i,routeModules:l}=GC(),{basename:c}=$C(),{loaderData:f,matches:d}=Sj(),h=E.useMemo(()=>Qw(t,e,d,i,s,"data"),[t,e,d,i,s]),p=E.useMemo(()=>Qw(t,e,d,i,s,"assets"),[t,e,d,i,s]),b=E.useMemo(()=>{if(t===s.pathname+s.search+s.hash)return[];let g=new Set,x=!1;if(e.forEach(C=>{var A;let T=i.routes[C.route.id];!T||!T.hasLoader||(!h.some(R=>R.route.id===C.route.id)&&C.route.id in f&&((A=l[C.route.id])!=null&&A.shouldRevalidate)||T.hasClientLoader?x=!0:g.add(C.route.id))}),g.size===0)return[];let w=wj(t,c);return x&&g.size>0&&w.searchParams.set("_routes",e.filter(C=>g.has(C.route.id)).map(C=>C.route.id).join(",")),[w.pathname+w.search]},[c,f,s,i,h,e,t,l]),m=E.useMemo(()=>vj(p,i),[p,i]),v=Cj(p);return E.createElement(E.Fragment,null,b.map(g=>E.createElement("link",{key:g,rel:"prefetch",as:"fetch",href:g,...n})),m.map(g=>E.createElement("link",{key:g,rel:"modulepreload",href:g,...n})),v.map(({key:g,link:x})=>E.createElement("link",{key:g,...x})))}function Rj(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var YC=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{YC&&(window.__reactRouterVersion="7.3.0")}catch{}function Aj({basename:t,children:e,window:n}){let s=E.useRef();s.current==null&&(s.current=vD({window:n,v5Compat:!0}));let i=s.current,[l,c]=E.useState({action:i.action,location:i.location}),f=E.useCallback(d=>{E.startTransition(()=>c(d))},[c]);return E.useLayoutEffect(()=>i.listen(f),[i,f]),E.createElement(sj,{basename:t,children:e,location:l.location,navigationType:l.action,navigator:i})}var QC=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,WC=E.forwardRef(function({onClick:e,discover:n="render",prefetch:s="none",relative:i,reloadDocument:l,replace:c,state:f,target:d,to:h,preventScrollReset:p,viewTransition:b,...m},v){let{basename:g}=E.useContext(Nr),x=typeof h=="string"&&QC.test(h),w,C=!1;if(typeof h=="string"&&x&&(w=h,YC))try{let M=new URL(window.location.href),P=h.startsWith("//")?new URL(M.protocol+h):new URL(h),q=ps(P.pathname,g);P.origin===M.origin&&q!=null?h=q+P.search+P.hash:C=!0}catch{_r(!1,`<Link to="${h}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let T=FD(h,{relative:i}),[A,R,k]=_j(s,m),j=kj(h,{replace:c,state:f,target:d,preventScrollReset:p,relative:i,viewTransition:b});function D(M){e&&e(M),M.defaultPrevented||j(M)}let F=E.createElement("a",{...m,...k,href:w||T,onClick:C||l?e:D,ref:Rj(v,R),target:d,"data-discover":!x&&n==="render"?"true":void 0});return A&&!x?E.createElement(E.Fragment,null,F,E.createElement(Ej,{page:T})):F});WC.displayName="Link";var no=E.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:s="",end:i=!1,style:l,to:c,viewTransition:f,children:d,...h},p){let b=Hu(c,{relative:h.relative}),m=ha(),v=E.useContext(Kd),{navigator:g,basename:x}=E.useContext(Nr),w=v!=null&&Pj(b)&&f===!0,C=g.encodeLocation?g.encodeLocation(b).pathname:b.pathname,T=m.pathname,A=v&&v.navigation&&v.navigation.location?v.navigation.location.pathname:null;n||(T=T.toLowerCase(),A=A?A.toLowerCase():null,C=C.toLowerCase()),A&&x&&(A=ps(A,x)||A);const R=C!=="/"&&C.endsWith("/")?C.length-1:C.length;let k=T===C||!i&&T.startsWith(C)&&T.charAt(R)==="/",j=A!=null&&(A===C||!i&&A.startsWith(C)&&A.charAt(C.length)==="/"),D={isActive:k,isPending:j,isTransitioning:w},F=k?e:void 0,M;typeof s=="function"?M=s(D):M=[s,k?"active":null,j?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let P=typeof l=="function"?l(D):l;return E.createElement(WC,{...h,"aria-current":F,className:M,ref:p,style:P,to:c,viewTransition:f},typeof d=="function"?d(D):d)});no.displayName="NavLink";var Oj=E.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:s,replace:i,state:l,method:c=nd,action:f,onSubmit:d,relative:h,preventScrollReset:p,viewTransition:b,...m},v)=>{let g=Dj(),x=jj(f,{relative:h}),w=c.toLowerCase()==="get"?"get":"post",C=typeof f=="string"&&QC.test(f),T=A=>{if(d&&d(A),A.defaultPrevented)return;A.preventDefault();let R=A.nativeEvent.submitter,k=(R==null?void 0:R.getAttribute("formmethod"))||c;g(R||A.currentTarget,{fetcherKey:e,method:k,navigate:n,replace:i,state:l,relative:h,preventScrollReset:p,viewTransition:b})};return E.createElement("form",{ref:v,method:w,action:x,onSubmit:s?d:T,...m,"data-discover":!C&&t==="render"?"true":void 0})});Oj.displayName="Form";function Nj(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function KC(t){let e=E.useContext(Io);return ut(e,Nj(t)),e}function kj(t,{target:e,replace:n,state:s,preventScrollReset:i,relative:l,viewTransition:c}={}){let f=Bo(),d=ha(),h=Hu(t,{relative:l});return E.useCallback(p=>{if(cj(p,e)){p.preventDefault();let b=n!==void 0?n:du(d)===du(h);f(t,{replace:b,state:s,preventScrollReset:i,relative:l,viewTransition:c})}},[d,f,h,n,s,e,t,i,l,c])}var Mj=0,Lj=()=>`__${String(++Mj)}__`;function Dj(){let{router:t}=KC("useSubmit"),{basename:e}=E.useContext(Nr),n=ej();return E.useCallback(async(s,i={})=>{let{action:l,method:c,encType:f,formData:d,body:h}=hj(s,e);if(i.navigate===!1){let p=i.fetcherKey||Lj();await t.fetch(p,n,i.action||l,{preventScrollReset:i.preventScrollReset,formData:d,body:h,formMethod:i.method||c,formEncType:i.encType||f,flushSync:i.flushSync})}else await t.navigate(i.action||l,{preventScrollReset:i.preventScrollReset,formData:d,body:h,formMethod:i.method||c,formEncType:i.encType||f,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[t,e,n])}function jj(t,{relative:e}={}){let{basename:n}=E.useContext(Nr),s=E.useContext(kr);ut(s,"useFormAction must be used inside a RouteContext");let[i]=s.matches.slice(-1),l={...Hu(t||".",{relative:e})},c=ha();if(t==null){l.search=c.search;let f=new URLSearchParams(l.search),d=f.getAll("index");if(d.some(p=>p==="")){f.delete("index"),d.filter(b=>b).forEach(b=>f.append("index",b));let p=f.toString();l.search=p?`?${p}`:""}}return(!t||t===".")&&i.route.index&&(l.search=l.search?l.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(l.pathname=l.pathname==="/"?n:cs([n,l.pathname])),du(l)}function Pj(t,e={}){let n=E.useContext(zC);ut(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:s}=KC("useViewTransitionState"),i=Hu(t,{relative:e.relative});if(!n.isTransitioning)return!1;let l=ps(n.currentLocation.pathname,s)||n.currentLocation.pathname,c=ps(n.nextLocation.pathname,s)||n.nextLocation.pathname;return _d(i.pathname,c)!=null||_d(i.pathname,l)!=null}new TextEncoder;const Ij=fa("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Ed({className:t,variant:e,...n}){return S.jsx("div",{className:fe(Ij({variant:e}),t),...n})}var Bj="Label",ZC=E.forwardRef((t,e)=>S.jsx(Ne.label,{...t,ref:e,onMouseDown:n=>{var i;n.target.closest("button, input, select, textarea")||((i=t.onMouseDown)==null||i.call(t,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));ZC.displayName=Bj;var XC=ZC;const zj=fa("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Cd=E.forwardRef(({className:t,...e},n)=>S.jsx(XC,{ref:n,className:fe(zj(),t),...e}));Cd.displayName=XC.displayName;const qj=({tag:t,onRemove:e})=>S.jsxs(Ed,{variant:"outline",className:"flex items-center gap-1.5 pr-1.5 text-sm py-1 px-2 transition-colors hover:bg-white hover:text-black dark:hover:text-black",children:[t,S.jsxs(Ze,{type:"button",variant:"ghost",size:"icon",onClick:()=>e(t),className:"hover:bg-muted/20 rounded-full p-0.5 transition-colors h-auto w-auto min-w-0 min-h-0",children:[S.jsx(ui,{className:"h-3 w-3"}),S.jsxs("span",{className:"sr-only",children:["Remove ",t]})]})]}),Uj=({tags:t,onRemove:e})=>S.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:t.map(n=>S.jsx(qj,{tag:n,onRemove:e},n))}),Hj=({value:t,onChange:e,onKeyDown:n})=>S.jsx(is,{value:t,onChange:e,onKeyDown:n,placeholder:"Type and press Enter to add...",className:fe("bg-background",!t&&"text-muted-foreground")});function Fj({title:t,data:e,onChange:n}){const[s,i]=E.useState(""),l=f=>{if(f.key==="Enter"){f.preventDefault();const d=s.trim();d&&!e.includes(d)&&(n([...e,d]),i(""))}},c=f=>{n(e.filter(d=>d!==f))};return S.jsxs("div",{className:"space-y-2",children:[S.jsx(Cd,{children:t}),S.jsxs("div",{className:"p-2 bg-card rounded-md border",children:[S.jsx(Uj,{tags:e,onRemove:c}),S.jsx(Hj,{value:s,onChange:f=>i(f.target.value),onKeyDown:l})]})]})}const Fu=E.forwardRef(({className:t,...e},n)=>S.jsx("div",{ref:n,className:fe("rounded-xl border bg-card text-card-foreground shadow",t),...e}));Fu.displayName="Card";const JC=E.forwardRef(({className:t,...e},n)=>S.jsx("div",{ref:n,className:fe("flex flex-col space-y-1.5 p-6",t),...e}));JC.displayName="CardHeader";const eT=E.forwardRef(({className:t,...e},n)=>S.jsx("div",{ref:n,className:fe("font-semibold leading-none tracking-tight",t),...e}));eT.displayName="CardTitle";const Vj=E.forwardRef(({className:t,...e},n)=>S.jsx("div",{ref:n,className:fe("text-sm text-muted-foreground",t),...e}));Vj.displayName="CardDescription";const Xd=E.forwardRef(({className:t,...e},n)=>S.jsx("div",{ref:n,className:fe("p-6 pt-0",t),...e}));Xd.displayName="CardContent";const tT=E.forwardRef(({className:t,...e},n)=>S.jsx("div",{ref:n,className:fe("flex items-center p-6 pt-0",t),...e}));tT.displayName="CardFooter";function jy(t){const e=t+"CollectionProvider",[n,s]=Ar(e),[i,l]=n(e,{collectionRef:{current:null},itemMap:new Map}),c=v=>{const{scope:g,children:x}=v,w=es.useRef(null),C=es.useRef(new Map).current;return S.jsx(i,{scope:g,itemMap:C,collectionRef:w,children:x})};c.displayName=e;const f=t+"CollectionSlot",d=es.forwardRef((v,g)=>{const{scope:x,children:w}=v,C=l(f,x),T=We(g,C.collectionRef);return S.jsx(Mn,{ref:T,children:w})});d.displayName=f;const h=t+"CollectionItemSlot",p="data-radix-collection-item",b=es.forwardRef((v,g)=>{const{scope:x,children:w,...C}=v,T=es.useRef(null),A=We(g,T),R=l(h,x);return es.useEffect(()=>(R.itemMap.set(T,{ref:T,...C}),()=>void R.itemMap.delete(T))),S.jsx(Mn,{[p]:"",ref:A,children:w})});b.displayName=h;function m(v){const g=l(t+"CollectionConsumer",v);return es.useCallback(()=>{const w=g.collectionRef.current;if(!w)return[];const C=Array.from(w.querySelectorAll(`[${p}]`));return Array.from(g.itemMap.values()).sort((R,k)=>C.indexOf(R.ref.current)-C.indexOf(k.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:c,Slot:d,ItemSlot:b},m,s]}var $j=E.createContext(void 0);function Jd(t){const e=E.useContext($j);return t||e||"ltr"}var $m="rovingFocusGroup.onEntryFocus",Gj={bubbles:!1,cancelable:!0},eh="RovingFocusGroup",[Lv,nT,Yj]=jy(eh),[Qj,rT]=Ar(eh,[Yj]),[Wj,Kj]=Qj(eh),sT=E.forwardRef((t,e)=>S.jsx(Lv.Provider,{scope:t.__scopeRovingFocusGroup,children:S.jsx(Lv.Slot,{scope:t.__scopeRovingFocusGroup,children:S.jsx(Zj,{...t,ref:e})})}));sT.displayName=eh;var Zj=E.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:i=!1,dir:l,currentTabStopId:c,defaultCurrentTabStopId:f,onCurrentTabStopIdChange:d,onEntryFocus:h,preventScrollOnEntryFocus:p=!1,...b}=t,m=E.useRef(null),v=We(e,m),g=Jd(l),[x=null,w]=ei({prop:c,defaultProp:f,onChange:d}),[C,T]=E.useState(!1),A=pt(h),R=nT(n),k=E.useRef(!1),[j,D]=E.useState(0);return E.useEffect(()=>{const F=m.current;if(F)return F.addEventListener($m,A),()=>F.removeEventListener($m,A)},[A]),S.jsx(Wj,{scope:n,orientation:s,dir:g,loop:i,currentTabStopId:x,onItemFocus:E.useCallback(F=>w(F),[w]),onItemShiftTab:E.useCallback(()=>T(!0),[]),onFocusableItemAdd:E.useCallback(()=>D(F=>F+1),[]),onFocusableItemRemove:E.useCallback(()=>D(F=>F-1),[]),children:S.jsx(Ne.div,{tabIndex:C||j===0?-1:0,"data-orientation":s,...b,ref:v,style:{outline:"none",...t.style},onMouseDown:_e(t.onMouseDown,()=>{k.current=!0}),onFocus:_e(t.onFocus,F=>{const M=!k.current;if(F.target===F.currentTarget&&M&&!C){const P=new CustomEvent($m,Gj);if(F.currentTarget.dispatchEvent(P),!P.defaultPrevented){const q=R().filter(N=>N.focusable),U=q.find(N=>N.active),G=q.find(N=>N.id===x),L=[U,G,...q].filter(Boolean).map(N=>N.ref.current);oT(L,p)}}k.current=!1}),onBlur:_e(t.onBlur,()=>T(!1))})})}),aT="RovingFocusGroupItem",iT=E.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:i=!1,tabStopId:l,...c}=t,f=os(),d=l||f,h=Kj(aT,n),p=h.currentTabStopId===d,b=nT(n),{onFocusableItemAdd:m,onFocusableItemRemove:v}=h;return E.useEffect(()=>{if(s)return m(),()=>v()},[s,m,v]),S.jsx(Lv.ItemSlot,{scope:n,id:d,focusable:s,active:i,children:S.jsx(Ne.span,{tabIndex:p?0:-1,"data-orientation":h.orientation,...c,ref:e,onMouseDown:_e(t.onMouseDown,g=>{s?h.onItemFocus(d):g.preventDefault()}),onFocus:_e(t.onFocus,()=>h.onItemFocus(d)),onKeyDown:_e(t.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){h.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const x=e8(g,h.orientation,h.dir);if(x!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let C=b().filter(T=>T.focusable).map(T=>T.ref.current);if(x==="last")C.reverse();else if(x==="prev"||x==="next"){x==="prev"&&C.reverse();const T=C.indexOf(g.currentTarget);C=h.loop?t8(C,T+1):C.slice(T+1)}setTimeout(()=>oT(C))}})})})});iT.displayName=aT;var Xj={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Jj(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function e8(t,e,n){const s=Jj(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return Xj[s]}function oT(t,e=!1){const n=document.activeElement;for(const s of t)if(s===n||(s.focus({preventScroll:e}),document.activeElement!==n))return}function t8(t,e){return t.map((n,s)=>t[(e+s)%t.length])}var n8=sT,r8=iT,Py="Tabs",[s8,Uz]=Ar(Py,[rT]),lT=rT(),[a8,Iy]=s8(Py),uT=E.forwardRef((t,e)=>{const{__scopeTabs:n,value:s,onValueChange:i,defaultValue:l,orientation:c="horizontal",dir:f,activationMode:d="automatic",...h}=t,p=Jd(f),[b,m]=ei({prop:s,onChange:i,defaultProp:l});return S.jsx(a8,{scope:n,baseId:os(),value:b,onValueChange:m,orientation:c,dir:p,activationMode:d,children:S.jsx(Ne.div,{dir:p,"data-orientation":c,...h,ref:e})})});uT.displayName=Py;var cT="TabsList",fT=E.forwardRef((t,e)=>{const{__scopeTabs:n,loop:s=!0,...i}=t,l=Iy(cT,n),c=lT(n);return S.jsx(n8,{asChild:!0,...c,orientation:l.orientation,dir:l.dir,loop:s,children:S.jsx(Ne.div,{role:"tablist","aria-orientation":l.orientation,...i,ref:e})})});fT.displayName=cT;var dT="TabsTrigger",hT=E.forwardRef((t,e)=>{const{__scopeTabs:n,value:s,disabled:i=!1,...l}=t,c=Iy(dT,n),f=lT(n),d=gT(c.baseId,s),h=vT(c.baseId,s),p=s===c.value;return S.jsx(r8,{asChild:!0,...f,focusable:!i,active:p,children:S.jsx(Ne.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":h,"data-state":p?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:d,...l,ref:e,onMouseDown:_e(t.onMouseDown,b=>{!i&&b.button===0&&b.ctrlKey===!1?c.onValueChange(s):b.preventDefault()}),onKeyDown:_e(t.onKeyDown,b=>{[" ","Enter"].includes(b.key)&&c.onValueChange(s)}),onFocus:_e(t.onFocus,()=>{const b=c.activationMode!=="manual";!p&&!i&&b&&c.onValueChange(s)})})})});hT.displayName=dT;var pT="TabsContent",mT=E.forwardRef((t,e)=>{const{__scopeTabs:n,value:s,forceMount:i,children:l,...c}=t,f=Iy(pT,n),d=gT(f.baseId,s),h=vT(f.baseId,s),p=s===f.value,b=E.useRef(p);return E.useEffect(()=>{const m=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(m)},[]),S.jsx(Ln,{present:i||p,children:({present:m})=>S.jsx(Ne.div,{"data-state":p?"active":"inactive","data-orientation":f.orientation,role:"tabpanel","aria-labelledby":d,hidden:!m,id:h,tabIndex:0,...c,ref:e,style:{...t.style,animationDuration:b.current?"0s":void 0},children:m&&l})})});mT.displayName=pT;function gT(t,e){return`${t}-trigger-${e}`}function vT(t,e){return`${t}-content-${e}`}var i8=uT,yT=fT,bT=hT,xT=mT;const wT=i8,By=E.forwardRef(({className:t,...e},n)=>S.jsx(yT,{ref:n,className:fe("inline-flex h-9 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...e}));By.displayName=yT.displayName;const hu=E.forwardRef(({className:t,...e},n)=>S.jsx(bT,{ref:n,className:fe("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",t),...e}));hu.displayName=bT.displayName;const pu=E.forwardRef(({className:t,...e},n)=>S.jsx(xT,{ref:n,className:fe("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));pu.displayName=xT.displayName;const zy=E.forwardRef(({className:t,...e},n)=>S.jsx("textarea",{className:fe("flex min-h-[60px] select-none w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:n,...e}));zy.displayName="Textarea";const o8=1,l8=1e6;let Gm=0;function u8(){return Gm=(Gm+1)%Number.MAX_SAFE_INTEGER,Gm.toString()}const Ym=new Map,Ww=t=>{if(Ym.has(t))return;const e=setTimeout(()=>{Ym.delete(t),lu({type:"REMOVE_TOAST",toastId:t})},l8);Ym.set(t,e)},c8=(t,e)=>{switch(e.type){case"ADD_TOAST":return{...t,toasts:[e.toast,...t.toasts].slice(0,o8)};case"UPDATE_TOAST":return{...t,toasts:t.toasts.map(n=>n.id===e.toast.id?{...n,...e.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=e;if(n)Ww(n);else for(const s of t.toasts)Ww(s.id);return{...t,toasts:t.toasts.map(s=>s.id===n||n===void 0?{...s,open:!1}:s)}}case"REMOVE_TOAST":return e.toastId===void 0?{...t,toasts:[]}:{...t,toasts:t.toasts.filter(n=>n.id!==e.toastId)}}},sd=[];let ad={toasts:[]};function lu(t){ad=c8(ad,t);for(const e of sd)e(ad)}function f8({...t}){const e=u8(),n=i=>lu({type:"UPDATE_TOAST",toast:{...i,id:e}}),s=()=>lu({type:"DISMISS_TOAST",toastId:e});return lu({type:"ADD_TOAST",toast:{...t,id:e,open:!0,onOpenChange:i=>{i||s()}}}),{id:e,dismiss:s,update:n}}function tr(){const[t,e]=E.useState(ad);return E.useEffect(()=>(sd.push(e),()=>{const n=sd.indexOf(e);n>-1&&sd.splice(n,1)}),[]),{...t,toast:f8,dismiss:n=>lu({type:"DISMISS_TOAST",toastId:n})}}const Kw=[{sectionTitle:"Basic Info",sectionValue:"basic",sectionType:"input",fields:[{title:"Name",name:"name",description:"The display name of your character",fieldType:"text",getValue:t=>t.name||""},{title:"Username",name:"username",description:"Unique identifier for your character",fieldType:"text",getValue:t=>t.username||""},{title:"System",name:"system",description:"System prompt for character behavior",fieldType:"textarea",getValue:t=>t.system||""},{title:"Voice Model",name:"settings.voice.model",description:"Voice model used for speech synthesis",fieldType:"text",getValue:t=>{var e,n;return((n=(e=t.settings)==null?void 0:e.voice)==null?void 0:n.model)||""}}]},{sectionTitle:"Content",sectionValue:"content",sectionType:"array",fields:[{title:"Bio",description:"Key information about your character",path:"bio",getData:t=>Array.isArray(t.bio)?t.bio:[]},{title:"Topics",description:"Topics your character is knowledgeable about",path:"topics",getData:t=>t.topics||[]},{title:"Adjectives",description:"Words that describe your character's personality",path:"adjectives",getData:t=>t.adjectives||[]}]},{sectionTitle:"Style",sectionValue:"style",sectionType:"array",fields:[{title:"All",description:"Style rules applied to all interactions",path:"style.all",getData:t=>{var e;return((e=t.style)==null?void 0:e.all)||[]}},{title:"Chat",description:"Style rules for chat interactions",path:"style.chat",getData:t=>{var e;return((e=t.style)==null?void 0:e.chat)||[]}},{title:"Post",description:"Style rules for social media posts",path:"style.post",getData:t=>{var e;return((e=t.style)==null?void 0:e.post)||[]}}]}];function ST({characterValue:t,setCharacterValue:e,title:n,description:s,onSubmit:i,onDelete:l,onReset:c,customComponents:f=[]}){const{toast:d}=tr(),[h,p]=E.useState(!1),b=w=>{const{name:C,value:T,type:A}=w.target,R=w.target.checked;if(C.includes(".")){const k=C.split(".");e(j=>{const D={...j};let F=D;for(let M=0;M<k.length-1;M++)F[k[M]]||(F[k[M]]={}),F=F[k[M]];return F[k[k.length-1]]=A==="checkbox"?R:T,D})}else e(k=>({...k,[C]:A==="checkbox"?R:T}))},m=(w,C)=>{e(T=>{const A={...T},R=w.split(".");let k=A;for(let j=0;j<R.length-1;j++){const D=R[j];(!k[D]||typeof k[D]!="object")&&(k[D]={}),k=k[D]}return k[R[R.length-1]]=C,A})},v=async w=>{w.preventDefault(),p(!0);try{await i(t)}catch(C){d({title:"Error",description:C instanceof Error?C.message:"Failed to update",variant:"destructive"})}finally{p(!1)}},g=w=>S.jsxs("div",{className:"space-y-2",children:[S.jsx(Cd,{htmlFor:w.name,children:w.title}),w.description&&S.jsx("p",{className:"text-sm text-muted-foreground",children:w.description}),w.fieldType==="textarea"?S.jsx(zy,{id:w.name,name:w.name,value:w.getValue(t),onChange:b,className:"min-h-[120px] resize-y"}):w.fieldType==="checkbox"?S.jsx(is,{id:w.name,name:w.name,type:"checkbox",checked:t[w.name]==="true",onChange:b}):S.jsx(is,{id:w.name,name:w.name,type:w.fieldType,value:w.getValue(t),onChange:b})]},w.name),x=w=>S.jsxs("div",{className:"space-y-2",children:[S.jsx(Cd,{htmlFor:w.path,children:w.title}),w.description&&S.jsx("p",{className:"text-sm text-muted-foreground",children:w.description}),S.jsx(Fj,{data:w.getData(t),onChange:C=>m(w.path,C)})]},w.path);return S.jsxs("div",{className:"container max-w-4xl mx-auto p-6",children:[S.jsx("div",{className:"flex items-center justify-between mb-6",children:S.jsxs("div",{children:[S.jsx("h1",{className:"text-3xl font-bold",children:n}),S.jsx("p",{className:"text-muted-foreground mt-1",children:s})]})}),S.jsxs("form",{onSubmit:v,children:[S.jsxs(wT,{defaultValue:"basic",className:"w-full",children:[S.jsxs(By,{className:"grid w-full mb-6",style:{gridTemplateColumns:`repeat(${f.length+3}, minmax(0, 1fr))`},children:[Kw.map(w=>S.jsx(hu,{value:w.sectionValue,children:w.sectionTitle},w.sectionValue)),f.map(w=>S.jsx(hu,{value:`custom-${w.name}`,children:w.name},`custom-${w.name}`))]}),S.jsx(Fu,{children:S.jsxs(Xd,{className:"p-6",children:[Kw.map(w=>S.jsx(pu,{value:w.sectionValue,className:"space-y-6",children:w.sectionType==="input"?w.fields.map(g):w.fields.map(x)},w.sectionValue)),f.map(w=>S.jsx(pu,{value:`custom-${w.name}`,children:w.component},`custom-${w.name}`))]})})]}),S.jsxs("div",{className:"flex justify-between gap-4 mt-6",children:[S.jsx("div",{className:"flex gap-4 text-red-500",children:S.jsx(Ze,{type:"button",variant:"outline",onClick:()=>{l==null||l()},children:"Delete Character"})}),S.jsxs("div",{className:"flex gap-4",children:[S.jsx(Ze,{type:"button",variant:"outline",onClick:()=>{c==null||c()},children:"Reset Changes"}),S.jsx(Ze,{type:"submit",disabled:h,children:h?"Saving...":"Save Changes"})]})]})]})]})}const Qm="elizaos-world-id",Za={getWorldId:()=>{const t=localStorage.getItem(Qm);if(t)return t;const e=crypto.randomUUID();return localStorage.setItem(Qm,e),e},resetWorldId:()=>{const t=crypto.randomUUID();return localStorage.setItem(Qm,t),t},getRoomStorageKey:t=>`room-${Za.getWorldId()}-${t}`},gt=async({url:t,method:e,body:n,headers:s})=>{const i={method:e??"GET",headers:s||{Accept:"application/json","Content-Type":"application/json"}};return(e==="POST"||e==="PUT"||e==="PATCH")&&(n instanceof FormData?(i.headers&&typeof i.headers=="object"&&(i.headers=Object.fromEntries(Object.entries(i.headers).filter(([l])=>l!=="Content-Type"))),i.body=n):i.body=JSON.stringify(n)),fetch(`${t}`,i).then(async l=>{if(l.headers.get("Content-Type")==="audio/mpeg")return await l.blob();if(!l.ok){const f=await l.text();console.error("Error: ",f);let d="An error occurred.";try{d=JSON.parse(f).message||d}catch{d=f||d}throw new Error(d)}try{return await l.json()}catch(f){return console.error("JSON Parse Error:",f),null}})},kt={getAgents:()=>gt({url:"/agents"}),getAgent:t=>gt({url:`/agents/${t}`}),tts:(t,e)=>gt({url:`/agents/${t}/speech/generate`,method:"POST",body:{text:e},headers:{"Content-Type":"application/json",Accept:"audio/mpeg","Transfer-Encoding":"chunked"}}),whisper:async(t,e)=>{const n=new FormData;return n.append("file",e,"recording.wav"),gt({url:`/agents/${t}/transcriptions`,method:"POST",body:n})},sendAudioMessage:async(t,e,n)=>{const s=new FormData;if(s.append("file",e,"recording.wav"),n)for(const[i,l]of Object.entries(n))l&&s.append(i,l);return gt({url:`/agents/${t}/audio-messages`,method:"POST",body:s})},speechConversation:async(t,e,n)=>gt({url:`/agents/${t}/speech/conversation`,method:"POST",body:{text:e,...n},headers:{"Content-Type":"application/json",Accept:"audio/mpeg","Transfer-Encoding":"chunked"}}),deleteAgent:t=>gt({url:`/agents/${t}`,method:"DELETE"}),updateAgent:(t,e)=>gt({url:`/agents/${t}`,method:"PATCH",body:e}),createAgent:t=>gt({url:"/agents/",method:"POST",body:t}),startAgent:t=>gt({url:`/agents/${t}`,method:"POST",body:{start:!0}}),stopAgent:t=>gt({url:`/agents/${t}`,method:"PUT"}),getMemories:(t,e,n)=>{const i={worldId:Za.getWorldId()};return n!=null&&n.limit&&(i.limit=n.limit),n!=null&&n.before&&(i.end=n.before),gt({url:`/agents/${t}/rooms/${e}/memories`,method:"GET",body:i})},getRooms:t=>{const e=Za.getWorldId();return gt({url:`/agents/${t}/rooms`,method:"GET",body:{worldId:e}})},createRoom:(t,e)=>{const n=Za.getWorldId();return gt({url:`/agents/${t}/rooms`,method:"POST",body:{name:e,worldId:n}})},getRoom:(t,e)=>gt({url:`/agents/${t}/rooms/${e}`,method:"GET"}),updateRoom:(t,e,n)=>gt({url:`/agents/${t}/rooms/${e}`,method:"PATCH",body:n}),deleteRoom:(t,e)=>gt({url:`/agents/${t}/rooms/${e}`,method:"DELETE"}),getLogs:({level:t="",agentName:e="all",agentId:n="all"})=>{const s=new URLSearchParams;t&&t!=="all"&&s.append("level",t),e&&e!=="all"&&s.append("agentName",e),n&&n!=="all"&&s.append("agentId",n);const i=`/logs${s.toString()?`?${s.toString()}`:""}`;return gt({url:i,method:"GET"})},getAgentCompletion:(t,e,n,s,i)=>gt({url:`/agents/${t}/message`,method:"POST",body:{text:n,roomId:s,senderId:e,source:i}}),getAgentLogs:(t,e)=>{const n=new URLSearchParams;return e!=null&&e.roomId&&n.append("roomId",e.roomId),e!=null&&e.type&&n.append("type",e.type),e!=null&&e.count&&n.append("count",e.count.toString()),e!=null&&e.offset&&n.append("offset",e.offset.toString()),gt({url:`/agents/${t}/logs${n.toString()?`?${n.toString()}`:""}`,method:"GET"})},deleteLog:(t,e)=>gt({url:`/agents/${t}/logs/${e}`,method:"DELETE"})};function _T({characterValue:t,setCharacterValue:e}){var c;const[n,s]=E.useState(((c=t==null?void 0:t.settings)==null?void 0:c.avatar)||null),i=E.useRef(null),l=f=>{var h;const d=(h=f.target.files)==null?void 0:h[0];if(d){const p=new FileReader;p.onload=b=>{var m;if((m=b.target)!=null&&m.result){const v=new Image;v.src=b.target.result,v.onload=()=>{const g=document.createElement("canvas"),x=300;let w=v.width,C=v.height;w>C?w>x&&(C*=x/w,w=x):C>x&&(w*=x/C,C=x),g.width=w,g.height=C;const T=g.getContext("2d");T==null||T.drawImage(v,0,0,w,C);const A=g.toDataURL("image/jpeg",.8);s(A)}}},p.readAsDataURL(d)}};return E.useEffect(()=>{e(f=>({...f,settings:{...f.settings,avatar:n}}))},[n,e]),S.jsxs("div",{className:"rounded-lg w-full",children:[S.jsx("h2",{className:"text-xl font-bold mb-4 pb-5 ml-1",children:"Avatar Settings"}),S.jsxs("div",{className:"flex flex-col items-center gap-4 pb-4",children:[n?S.jsxs("div",{className:"relative w-64 h-64",children:[S.jsx("img",{src:n,alt:"Character Avatar",className:"object-cover rounded-lg border"}),S.jsx("button",{className:"absolute -top-2 -right-2 bg-white p-1 rounded-full shadow-md",onClick:()=>s(null),type:"button",children:S.jsx(ui,{className:"w-5 h-5 text-card"})})]}):S.jsx("div",{className:"w-64 h-64 flex items-center justify-center border border-dashed rounded-lg text-gray-500",children:S.jsx(RM,{className:"w-10 h-10"})}),S.jsx("input",{type:"file",accept:"image/*",className:"hidden",ref:i,onChange:l}),S.jsxs(Ze,{className:"flex items-center gap-2",onClick:()=>{var f;return(f=i.current)==null?void 0:f.click()},children:[S.jsx(qM,{className:"w-5 h-5"})," Upload Avatar"]})]})]})}const d8=SE,h8=hM,p8=_E,ET=E.forwardRef(({className:t,...e},n)=>S.jsx(Bd,{ref:n,className:fe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e}));ET.displayName=Bd.displayName;const CT=E.forwardRef(({className:t,children:e,...n},s)=>S.jsxs(p8,{children:[S.jsx(ET,{}),S.jsxs(zd,{ref:s,className:fe("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...n,children:[e,S.jsxs(EE,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[S.jsx(ui,{className:"h-4 w-4"}),S.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));CT.displayName=zd.displayName;const TT=({className:t,...e})=>S.jsx("div",{className:fe("flex flex-col space-y-1.5 text-center sm:text-left",t),...e});TT.displayName="DialogHeader";const RT=E.forwardRef(({className:t,...e},n)=>S.jsx(qd,{ref:n,className:fe("text-lg font-semibold leading-none tracking-tight",t),...e}));RT.displayName=qd.displayName;const m8=E.forwardRef(({className:t,...e},n)=>S.jsx(Ud,{ref:n,className:fe("text-sm text-muted-foreground",t),...e}));m8.displayName=Ud.displayName;function g8(){return da({queryKey:["plugins"],queryFn:async()=>(await fetch("https://raw.githubusercontent.com/elizaos/registry/refs/heads/main/index.json")).json()})}function AT({characterValue:t,setCharacterValue:e}){const{data:n,error:s}=g8(),[i,l]=E.useState(""),[c,f]=E.useState(!1),d=E.useMemo(()=>n?Object.keys(n).map(m=>m.replace(/^@elizaos-plugins\//,"@elizaos/")):[],[n]),h=E.useMemo(()=>Array.isArray(t==null?void 0:t.plugins)?t.plugins:[],[t==null?void 0:t.plugins]),p=E.useMemo(()=>d.filter(m=>!h.includes(m)).filter(m=>m.toLowerCase().includes(i.toLowerCase())),[d,h,i]),b=m=>{e(v=>{const g=Array.isArray(v.plugins)?v.plugins:[],x=g.includes(m)?g.filter(w=>w!==m):[...g,m];return{...v,plugins:x}})};return S.jsx("div",{className:"space-y-6",children:S.jsx("div",{className:"space-y-4",children:S.jsxs("div",{children:[S.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Plugins"}),s?S.jsxs("p",{className:"text-destructive",children:["Failed to load plugins: ",s.message]}):S.jsxs("div",{className:"space-y-4",children:[h.length>0&&S.jsxs("div",{className:"rounded-md bg-muted p-4",children:[S.jsx("h4",{className:"text-sm font-medium mb-2",children:"Currently Enabled"}),S.jsx("div",{className:"flex flex-wrap gap-2",children:h.map(m=>S.jsxs(Ze,{type:"button",variant:"ghost",size:"sm",className:"inline-flex items-center rounded-full bg-primary/10 px-2.5 py-0.5 text-xs font-medium text-primary hover:bg-primary/20 h-auto",onClick:()=>b(m),children:[m," ×"]},m))})]}),S.jsx("div",{className:"space-y-2",children:S.jsxs(d8,{open:c,onOpenChange:f,children:[S.jsx(h8,{asChild:!0,children:S.jsx(Ze,{variant:"outline",className:"w-full justify-start",children:"Search and add plugins..."})}),S.jsxs(CT,{className:"max-w-[400px]",children:[S.jsx(TT,{children:S.jsx(RT,{children:"Add Plugins"})}),S.jsxs("div",{className:"space-y-4 py-4",children:[S.jsx("div",{className:"space-y-2",children:S.jsx(is,{type:"search",placeholder:"Search plugins...",value:i,onChange:m=>l(m.target.value)})}),S.jsx("div",{className:"max-h-[300px] overflow-y-auto space-y-2",children:p.length===0?S.jsx("p",{className:"text-sm text-muted-foreground",children:"No plugins found."}):p.map(m=>S.jsx(Ze,{variant:"ghost",className:"w-full justify-start font-normal",onClick:()=>{b(m),l(""),f(!1)},children:m},m))})]})]})]})})]})]})})})}function OT({characterValue:t,setCharacterValue:e}){var k;const[n,s]=E.useState(Object.entries(((k=t==null?void 0:t.settings)==null?void 0:k.secrets)||{}).map(([j,D])=>({name:j,value:String(D)}))),[i,l]=E.useState(""),[c,f]=E.useState(""),[d,h]=E.useState(!1),[p,b]=E.useState(null),[m,v]=E.useState(null),[g,x]=E.useState(""),w=E.useRef(null),C=()=>{i&&c&&(s([...n,{name:i,value:c}]),l(""),f(""))},T=j=>{v(j),x(n[j].value),b(null)},A=j=>{const D=[...n];D[j].value=g,s(D),v(null)},R=j=>{s(n.filter((D,F)=>F!==j)),b(null),v(null)};return E.useEffect(()=>{const j=D=>{w.current&&!w.current.contains(D.target)&&b(null)};return document.addEventListener("mousedown",j),()=>{document.removeEventListener("mousedown",j)}},[]),E.useEffect(()=>{e(j=>({...j,settings:{...j.settings,secrets:Object.fromEntries(n.map(({name:D,value:F})=>[D,F]))}}))},[n,e]),S.jsxs("div",{className:"rounded-lg w-full",children:[S.jsx("h2",{className:"text-xl font-bold mb-4 pb-5 ml-1",children:"Environment Settings"}),S.jsxs("div",{className:"grid grid-cols-[1fr_2fr_auto] gap-4 items-end w-full pb-4",children:[S.jsxs("div",{className:"flex flex-col gap-1",children:[S.jsx("label",{htmlFor:"secret-name",className:"ml-2 text-xs font-medium text-gray-400",children:"NAME"}),S.jsx(is,{id:"secret-name",placeholder:"VARIABLE_NAME",value:i,onChange:j=>l(j.target.value)})]}),S.jsxs("div",{className:"flex flex-col gap-1 relative",children:[S.jsx("label",{htmlFor:"secret-value",className:"ml-2 text-xs font-medium text-gray-400",children:"VALUE"}),S.jsxs("div",{className:"relative",children:[S.jsx(is,{id:"secret-value",type:d?"text":"password",placeholder:"i9ju23nfsdf56",value:c,onChange:j=>f(j.target.value),className:"pr-10"}),S.jsx("div",{className:"absolute inset-y-0 right-3 flex items-center cursor-pointer text-gray-500",onClick:()=>h(!d),onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&h(!d)},children:d?S.jsx(EM,{}):S.jsx(CM,{})})]})]}),S.jsx(Ze,{className:"shrink-0",onClick:C,children:"Add"})]}),n.length>0&&S.jsxs("div",{className:"grid grid-cols-[1fr_2fr_auto] gap-4 mt-6 font-medium text-gray-400 border-b pb-2 ml-1",children:[S.jsx("div",{children:"Name"}),S.jsx("div",{children:"Value"}),S.jsx("div",{children:"Action"})]}),S.jsx("div",{className:"mt-2",children:n.map((j,D)=>S.jsxs("div",{className:"grid grid-cols-[1fr_2fr_auto] gap-4 items-center border-b py-2 ml-1 relative",children:[S.jsx("div",{children:j.name}),S.jsx("div",{children:m===D?S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx(is,{value:g,onChange:F=>x(F.target.value),className:"w-full"}),S.jsx(Ze,{variant:"ghost",onClick:()=>A(D),children:S.jsx(hy,{className:"w-5 h-5 text-green-500"})}),S.jsx(Ze,{variant:"ghost",onClick:()=>v(null),children:S.jsx(ui,{className:"w-5 h-5 text-red-500"})})]}):S.jsx("div",{className:"truncate text-gray-500",children:"Encrypted"})}),S.jsxs("div",{className:"relative",children:[S.jsx(Ze,{variant:"ghost",className:"p-2 text-gray-500",onClick:()=>b(p===D?null:D),children:S.jsx(_M,{className:"w-5 h-5"})}),p===D&&S.jsxs("div",{className:"absolute right-0 -top-2 mt-2 w-24 bg-muted border rounded shadow-md z-10",ref:w,children:[S.jsx("button",{className:"w-full px-4 py-2 text-left hover:opacity-50",onClick:()=>T(D),type:"button",children:"Edit"}),S.jsx("div",{className:"w-full px-4 py-2 text-left text-red-500 hover:opacity-50 cursor-pointer",onClick:()=>R(D),children:"Remove"})]})]})]},D))})]})}const Zw={name:"",username:"",system:"",bio:[],topics:[],adjectives:[]};function NT(){const t=Bo(),{toast:e}=tr(),n=er(),[s,i]=E.useState({...Zw}),l=f=>{var d,h,p;return{...f,bio:f.bio??[],messageExamples:f.messageExamples??[],postExamples:f.postExamples??[],topics:f.topics??[],adjectives:f.adjectives??[],plugins:f.plugins??[],style:{all:((d=f.style)==null?void 0:d.all)??[],chat:((h=f.style)==null?void 0:h.chat)??[],post:((p=f.style)==null?void 0:p.post)??[]}}},c=async f=>{try{const d=l(f);await kt.createAgent({characterJson:d}),n.invalidateQueries({queryKey:["characters"]}),e({title:"Success",description:"Character created successfully!"}),n.invalidateQueries({queryKey:["agents"]}),t("/")}catch(d){e({title:"Error",description:d instanceof Error?d.message:"Failed to create character",variant:"destructive"})}};return S.jsx(ST,{characterValue:s,setCharacterValue:i,title:"Character Settings",description:"Configure your AI character's behavior and capabilities",onSubmit:c,onReset:()=>i(Zw),onDelete:()=>{t("/")},isAgent:!0,customComponents:[{name:"Plugins",component:S.jsx(AT,{characterValue:s,setCharacterValue:i})},{name:"Secret",component:S.jsx(OT,{characterValue:s,setCharacterValue:i})},{name:"Avatar",component:S.jsx(_T,{characterValue:s,setCharacterValue:i})}]})}const as="user",Qn={FREQUENT:30*1e3,STANDARD:2*60*1e3,RARE:10*60*1e3,NEVER:Number.POSITIVE_INFINITY},kT=()=>{const t=typeof navigator<"u"&&"connection"in navigator?navigator.connection:null;return{isOffline:typeof navigator<"u"&&!navigator.onLine,effectiveType:(t==null?void 0:t.effectiveType)||"unknown",saveData:(t==null?void 0:t.saveData)||!1}};function qy(t={}){const e=kT();return da({queryKey:["agents"],queryFn:()=>kt.getAgents(),staleTime:Qn.FREQUENT,refetchInterval:e.isOffline?!1:Qn.FREQUENT,refetchIntervalInBackground:!1,...!e.isOffline&&e.effectiveType==="slow-2g"&&{refetchInterval:Qn.STANDARD},...t})}function v8(t,e={}){const n=kT();return da({queryKey:["agent",t],queryFn:()=>kt.getAgent(t||""),staleTime:Qn.FREQUENT,enabled:!!t,refetchInterval:!n.isOffline&&t?Qn.FREQUENT:!1,refetchIntervalInBackground:!1,...!n.isOffline&&n.effectiveType==="slow-2g"&&{refetchInterval:Qn.STANDARD},...e})}function y8(){const t=er(),{toast:e}=tr();return zu({mutationFn:async n=>{try{return await kt.startAgent(n)}catch(s){if(s instanceof Error){if(s.message.includes("network"))throw new Error("Network error: Please check your connection and try again.");if(s.message.includes("already running"))throw new Error("Agent is already running.")}throw s}},onMutate:async n=>(e({title:"Starting Agent",description:"Initializing agent..."}),{agentId:n}),onSuccess:n=>{t.invalidateQueries({queryKey:["agents"]}),t.invalidateQueries({queryKey:["active-agents"]}),n!=null&&n.id&&t.invalidateQueries({queryKey:["agent",n.id]}),e({title:"Agent Started",description:`${(n==null?void 0:n.name)||"Agent"} is now running`})},onError:n=>{const s=n instanceof Error?n.message:"Failed to start agent";e({title:"Error Starting Agent",description:`${s}. Please try again.`,variant:"destructive"})}})}function b8(){const t=er(),{toast:e}=tr();return zu({mutationFn:n=>kt.stopAgent(n),onMutate:async n=>{const s=t.getQueryData(["agent",n]);s&&e({title:"Stopping Agent",description:`Stopping ${s.name}...`})},onSuccess:(n,s)=>{t.invalidateQueries({queryKey:["agents"]}),t.invalidateQueries({queryKey:["agent",s]}),e({title:"Agent Stopped",description:"The agent has been successfully stopped"})},onError:(n,s)=>{t.invalidateQueries({queryKey:["agents"]}),t.invalidateQueries({queryKey:["agent",s]}),e({title:"Error",description:n instanceof Error?n.message:"Failed to stop agent",variant:"destructive"})}})}function x8(t,e){const n=er(),s=Za.getWorldId(),[i,l]=E.useState(null),[c,f]=E.useState(!0),[d,h]=E.useState(!1);return{...da({queryKey:["messages",t,e,s],queryFn:async()=>(await kt.getMemories(t,e)).data.memories.map(v=>{const g={text:v.content.text,roomId:v.roomId,user:v.entityId===t?"agent":as,name:v.entityId===t?"agent":as,createdAt:v.createdAt||0,attachments:v.content.attachments,source:v.content.source,worldId:s,id:v.id};return v.content&&Object.keys(v.content).forEach(x=>{!g[x]&&v.content[x]!==void 0&&(g[x]=v.content[x])}),g}).sort((v,g)=>v.createdAt===void 0||g.createdAt===void 0?0:v.createdAt-g.createdAt),enabled:!!(t&&e),staleTime:Qn.FREQUENT}),loadOlderMessages:async()=>{if(!i||!c||d)return!1;try{h(!0);const m=await kt.getMemories(t,e,{before:i,limit:20});if(m!=null&&m.memories&&m.memories.length>0){const v=m.memories.map(T=>T.createdAt??0),g=Math.min(...v);l(g);const x=n.getQueryData(["messages",t,e,s])||[],w=new Map;x.forEach(T=>{w.set(T.id,T)}),m.memories.forEach(T=>{const A={text:T.content.text,roomId:T.roomId,user:T.entityId===t?"agent":as,name:T.entityId===t?"agent":as,createdAt:T.createdAt||0,attachments:T.content.attachments,source:T.content.source,worldId:s,id:T.id};T.content&&Object.keys(T.content).forEach(R=>{!A[R]&&T.content[R]!==void 0&&(A[R]=T.content[R])}),w.set(T.id,A)});const C=Array.from(w.values());return C.sort((T,A)=>(T.createdAt??0)-(A.createdAt??0)),n.setQueryData(["messages",t,e,s],C),f(m.memories.length>=20),!0}return f(!1),!1}catch(m){return console.error("Error loading older messages:",m),!1}finally{h(!1)}},hasOlderMessages:c,isLoadingMore:d}}function w8(t,e){return da({queryKey:["agentActions",t,e],queryFn:async()=>(await kt.getAgentLogs(t,{roomId:e,count:50})).data||[],refetchInterval:1e3,staleTime:1e3})}function S8(){const t=er(),{toast:e}=tr();return zu({mutationFn:({agentId:n,logId:s})=>kt.deleteLog(n,s),onMutate:async({agentId:n,logId:s})=>{const i=t.getQueryData(["agentActions",n]);return i&&t.setQueryData(["agentActions",n],l=>l.filter(c=>c.id!==s)),{previousLogs:i,agentId:n,logId:s}},onSuccess:(n,{agentId:s})=>{t.invalidateQueries({queryKey:["agentActions",s]}),e({title:"Log Deleted",description:"The log entry has been successfully removed"})},onError:(n,{agentId:s},i)=>{i!=null&&i.previousLogs&&t.setQueryData(["agentActions",s],i.previousLogs),e({title:"Error",description:n instanceof Error?n.message:"Failed to delete log",variant:"destructive"}),t.invalidateQueries({queryKey:["agentActions",s]})}})}const _8="1.0.0-alpha.60",uo={version:_8},E8="modulepreload",C8=function(t){return"/"+t},Xw={},T8=function(e,n,s){let i=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),f=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));i=Promise.allSettled(n.map(d=>{if(d=C8(d),d in Xw)return;Xw[d]=!0;const h=d.endsWith(".css"),p=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${p}`))return;const b=document.createElement("link");if(b.rel=h?"stylesheet":E8,h||(b.as="script"),b.crossOrigin="",b.href=d,f&&b.setAttribute("nonce",f),document.head.appendChild(b),h)return new Promise((m,v)=>{b.addEventListener("load",m),b.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${d}`)))})}))}function l(c){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=c,window.dispatchEvent(f),!f.defaultPrevented)throw c}return i.then(c=>{for(const f of c||[])f.status==="rejected"&&l(f.reason);return e().catch(l)})};var mf={exports:{}},gf={exports:{}},qn={},Xt={},Jw;function tn(){if(Jw)return Xt;Jw=1,Xt.__esModule=!0,Xt.extend=i,Xt.indexOf=d,Xt.escapeExpression=h,Xt.isEmpty=p,Xt.createFrame=b,Xt.blockParams=m,Xt.appendContextPath=v;var t={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`","=":"="},e=/[&<>"'`=]/g,n=/[&<>"'`=]/;function s(g){return t[g]}function i(g){for(var x=1;x<arguments.length;x++)for(var w in arguments[x])Object.prototype.hasOwnProperty.call(arguments[x],w)&&(g[w]=arguments[x][w]);return g}var l=Object.prototype.toString;Xt.toString=l;var c=function(x){return typeof x=="function"};c(/x/)&&(Xt.isFunction=c=function(g){return typeof g=="function"&&l.call(g)==="[object Function]"}),Xt.isFunction=c;var f=Array.isArray||function(g){return g&&typeof g=="object"?l.call(g)==="[object Array]":!1};Xt.isArray=f;function d(g,x){for(var w=0,C=g.length;w<C;w++)if(g[w]===x)return w;return-1}function h(g){if(typeof g!="string"){if(g&&g.toHTML)return g.toHTML();if(g==null)return"";if(!g)return g+"";g=""+g}return n.test(g)?g.replace(e,s):g}function p(g){return!g&&g!==0?!0:!!(f(g)&&g.length===0)}function b(g){var x=i({},g);return x._parent=g,x}function m(g,x){return g.path=x,g}function v(g,x){return(g?g+".":"")+x}return Xt}var vf={exports:{}},e2;function nr(){return e2||(e2=1,function(t,e){e.__esModule=!0;var n=["description","fileName","lineNumber","endLineNumber","message","name","number","stack"];function s(i,l){var c=l&&l.loc,f=void 0,d=void 0,h=void 0,p=void 0;c&&(f=c.start.line,d=c.end.line,h=c.start.column,p=c.end.column,i+=" - "+f+":"+h);for(var b=Error.prototype.constructor.call(this,i),m=0;m<n.length;m++)this[n[m]]=b[n[m]];Error.captureStackTrace&&Error.captureStackTrace(this,s);try{c&&(this.lineNumber=f,this.endLineNumber=d,Object.defineProperty?(Object.defineProperty(this,"column",{value:h,enumerable:!0}),Object.defineProperty(this,"endColumn",{value:p,enumerable:!0})):(this.column=h,this.endColumn=p))}catch{}}s.prototype=new Error,e.default=s,t.exports=e.default}(vf,vf.exports)),vf.exports}var Vl={},yf={exports:{}},t2;function R8(){return t2||(t2=1,function(t,e){e.__esModule=!0;var n=tn();e.default=function(s){s.registerHelper("blockHelperMissing",function(i,l){var c=l.inverse,f=l.fn;if(i===!0)return f(this);if(i===!1||i==null)return c(this);if(n.isArray(i))return i.length>0?(l.ids&&(l.ids=[l.name]),s.helpers.each(i,l)):c(this);if(l.data&&l.ids){var d=n.createFrame(l.data);d.contextPath=n.appendContextPath(l.data.contextPath,l.name),l={data:d}}return f(i,l)})},t.exports=e.default}(yf,yf.exports)),yf.exports}var bf={exports:{}},n2;function A8(){return n2||(n2=1,function(t,e){e.__esModule=!0;function n(c){return c&&c.__esModule?c:{default:c}}var s=tn(),i=nr(),l=n(i);e.default=function(c){c.registerHelper("each",function(f,d){if(!d)throw new l.default("Must pass iterator to #each");var h=d.fn,p=d.inverse,b=0,m="",v=void 0,g=void 0;d.data&&d.ids&&(g=s.appendContextPath(d.data.contextPath,d.ids[0])+"."),s.isFunction(f)&&(f=f.call(this)),d.data&&(v=s.createFrame(d.data));function x(R,k,j){v&&(v.key=R,v.index=k,v.first=k===0,v.last=!!j,g&&(v.contextPath=g+R)),m=m+h(f[R],{data:v,blockParams:s.blockParams([f[R],R],[g+R,null])})}if(f&&typeof f=="object")if(s.isArray(f))for(var w=f.length;b<w;b++)b in f&&x(b,b,b===f.length-1);else if(typeof Symbol=="function"&&f[Symbol.iterator]){for(var C=[],T=f[Symbol.iterator](),A=T.next();!A.done;A=T.next())C.push(A.value);f=C;for(var w=f.length;b<w;b++)x(b,b,b===f.length-1)}else(function(){var R=void 0;Object.keys(f).forEach(function(k){R!==void 0&&x(R,b-1),R=k,b++}),R!==void 0&&x(R,b-1,!0)})();return b===0&&(m=p(this)),m})},t.exports=e.default}(bf,bf.exports)),bf.exports}var xf={exports:{}},r2;function O8(){return r2||(r2=1,function(t,e){e.__esModule=!0;function n(l){return l&&l.__esModule?l:{default:l}}var s=nr(),i=n(s);e.default=function(l){l.registerHelper("helperMissing",function(){if(arguments.length!==1)throw new i.default('Missing helper: "'+arguments[arguments.length-1].name+'"')})},t.exports=e.default}(xf,xf.exports)),xf.exports}var wf={exports:{}},s2;function N8(){return s2||(s2=1,function(t,e){e.__esModule=!0;function n(c){return c&&c.__esModule?c:{default:c}}var s=tn(),i=nr(),l=n(i);e.default=function(c){c.registerHelper("if",function(f,d){if(arguments.length!=2)throw new l.default("#if requires exactly one argument");return s.isFunction(f)&&(f=f.call(this)),!d.hash.includeZero&&!f||s.isEmpty(f)?d.inverse(this):d.fn(this)}),c.registerHelper("unless",function(f,d){if(arguments.length!=2)throw new l.default("#unless requires exactly one argument");return c.helpers.if.call(this,f,{fn:d.inverse,inverse:d.fn,hash:d.hash})})},t.exports=e.default}(wf,wf.exports)),wf.exports}var Sf={exports:{}},a2;function k8(){return a2||(a2=1,function(t,e){e.__esModule=!0,e.default=function(n){n.registerHelper("log",function(){for(var s=[void 0],i=arguments[arguments.length-1],l=0;l<arguments.length-1;l++)s.push(arguments[l]);var c=1;i.hash.level!=null?c=i.hash.level:i.data&&i.data.level!=null&&(c=i.data.level),s[0]=c,n.log.apply(n,s)})},t.exports=e.default}(Sf,Sf.exports)),Sf.exports}var _f={exports:{}},i2;function M8(){return i2||(i2=1,function(t,e){e.__esModule=!0,e.default=function(n){n.registerHelper("lookup",function(s,i,l){return s&&l.lookupProperty(s,i)})},t.exports=e.default}(_f,_f.exports)),_f.exports}var Ef={exports:{}},o2;function L8(){return o2||(o2=1,function(t,e){e.__esModule=!0;function n(c){return c&&c.__esModule?c:{default:c}}var s=tn(),i=nr(),l=n(i);e.default=function(c){c.registerHelper("with",function(f,d){if(arguments.length!=2)throw new l.default("#with requires exactly one argument");s.isFunction(f)&&(f=f.call(this));var h=d.fn;if(s.isEmpty(f))return d.inverse(this);var p=d.data;return d.data&&d.ids&&(p=s.createFrame(d.data),p.contextPath=s.appendContextPath(d.data.contextPath,d.ids[0])),h(f,{data:p,blockParams:s.blockParams([f],[p&&p.contextPath])})})},t.exports=e.default}(Ef,Ef.exports)),Ef.exports}var l2;function MT(){if(l2)return Vl;l2=1,Vl.__esModule=!0,Vl.registerDefaultHelpers=x,Vl.moveHelperToHooks=w;function t(C){return C&&C.__esModule?C:{default:C}}var e=R8(),n=t(e),s=A8(),i=t(s),l=O8(),c=t(l),f=N8(),d=t(f),h=k8(),p=t(h),b=M8(),m=t(b),v=L8(),g=t(v);function x(C){n.default(C),i.default(C),c.default(C),d.default(C),p.default(C),m.default(C),g.default(C)}function w(C,T,A){C.helpers[T]&&(C.hooks[T]=C.helpers[T],A||delete C.helpers[T])}return Vl}var Cf={},Tf={exports:{}},u2;function D8(){return u2||(u2=1,function(t,e){e.__esModule=!0;var n=tn();e.default=function(s){s.registerDecorator("inline",function(i,l,c,f){var d=i;return l.partials||(l.partials={},d=function(h,p){var b=c.partials;c.partials=n.extend({},b,l.partials);var m=i(h,p);return c.partials=b,m}),l.partials[f.args[0]]=f.fn,d})},t.exports=e.default}(Tf,Tf.exports)),Tf.exports}var c2;function j8(){if(c2)return Cf;c2=1,Cf.__esModule=!0,Cf.registerDefaultDecorators=s;function t(i){return i&&i.__esModule?i:{default:i}}var e=D8(),n=t(e);function s(i){n.default(i)}return Cf}var Rf={exports:{}},f2;function LT(){return f2||(f2=1,function(t,e){e.__esModule=!0;var n=tn(),s={methodMap:["debug","info","warn","error"],level:"info",lookupLevel:function(l){if(typeof l=="string"){var c=n.indexOf(s.methodMap,l.toLowerCase());c>=0?l=c:l=parseInt(l,10)}return l},log:function(l){if(l=s.lookupLevel(l),typeof console<"u"&&s.lookupLevel(s.level)<=l){var c=s.methodMap[l];console[c]||(c="log");for(var f=arguments.length,d=Array(f>1?f-1:0),h=1;h<f;h++)d[h-1]=arguments[h];console[c].apply(console,d)}}};e.default=s,t.exports=e.default}(Rf,Rf.exports)),Rf.exports}var Qi={},Af={},d2;function P8(){if(d2)return Af;d2=1,Af.__esModule=!0,Af.createNewLookupObject=e;var t=tn();function e(){for(var n=arguments.length,s=Array(n),i=0;i<n;i++)s[i]=arguments[i];return t.extend.apply(void 0,[Object.create(null)].concat(s))}return Af}var h2;function DT(){if(h2)return Qi;h2=1,Qi.__esModule=!0,Qi.createProtoAccessControl=l,Qi.resultIsAllowed=c,Qi.resetLoggedProperties=h;function t(p){return p&&p.__esModule?p:{default:p}}var e=P8(),n=LT(),s=t(n),i=Object.create(null);function l(p){var b=Object.create(null);b.constructor=!1,b.__defineGetter__=!1,b.__defineSetter__=!1,b.__lookupGetter__=!1;var m=Object.create(null);return m.__proto__=!1,{properties:{whitelist:e.createNewLookupObject(m,p.allowedProtoProperties),defaultValue:p.allowProtoPropertiesByDefault},methods:{whitelist:e.createNewLookupObject(b,p.allowedProtoMethods),defaultValue:p.allowProtoMethodsByDefault}}}function c(p,b,m){return f(typeof p=="function"?b.methods:b.properties,m)}function f(p,b){return p.whitelist[b]!==void 0?p.whitelist[b]===!0:p.defaultValue!==void 0?p.defaultValue:(d(b),!1)}function d(p){i[p]!==!0&&(i[p]=!0,s.default.log("error",'Handlebars: Access has been denied to resolve the property "'+p+`" because it is not an "own property" of its parent.
|
|
299
|
+
Please change the parent <Route path="${A}"> to <Route path="${A==="/"?"*":`${A}/*`}">.`)}let m=ha(),v;if(e){let A=typeof e=="string"?Po(e):e;ut(p==="/"||((T=A.pathname)==null?void 0:T.startsWith(p)),`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 "${p}" but pathname "${A.pathname}" was given in the \`location\` prop.`),v=A}else v=m;let g=v.pathname||"/",x=g;if(p!=="/"){let A=p.replace(/^\//,"").split("/");x="/"+g.replace(/^\//,"").split("/").slice(A.length).join("/")}let w=!l&&n&&n.matches&&n.matches.length>0?n.matches:LC(t,{pathname:x});_r(b||w!=null,`No routes matched location "${v.pathname}${v.search}${v.hash}" `),_r(w==null||w[w.length-1].route.element!==void 0||w[w.length-1].route.Component!==void 0||w[w.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 C=KD(w&&w.map(A=>Object.assign({},A,{params:Object.assign({},d,A.params),pathname:cs([p,i.encodeLocation?i.encodeLocation(A.pathname).pathname:A.pathname]),pathnameBase:A.pathnameBase==="/"?p:cs([p,i.encodeLocation?i.encodeLocation(A.pathnameBase).pathname:A.pathnameBase])})),c,n,s);return e&&C?E.createElement(qu.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...v},navigationType:"POP"}},C):C}function GD(){let t=tj(),e=zD(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,s="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:s},l={padding:"2px 4px",backgroundColor:s},c=null;return console.error("Error handled by React Router default ErrorBoundary:",t),c=E.createElement(E.Fragment,null,E.createElement("p",null,"💿 Hey developer 👋"),E.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",E.createElement("code",{style:l},"ErrorBoundary")," or"," ",E.createElement("code",{style:l},"errorElement")," prop on your route.")),E.createElement(E.Fragment,null,E.createElement("h2",null,"Unexpected Application Error!"),E.createElement("h3",{style:{fontStyle:"italic"}},e),n?E.createElement("pre",{style:i},n):null,c)}var YD=E.createElement(GD,null),QD=class extends E.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,e){return e.location!==t.location||e.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:e.error,location:e.location,revalidation:t.revalidation||e.revalidation}}componentDidCatch(t,e){console.error("React Router caught the following error during render",t,e)}render(){return this.state.error!==void 0?E.createElement(kr.Provider,{value:this.props.routeContext},E.createElement(Ny.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function WD({routeContext:t,match:e,children:n}){let s=E.useContext(Io);return s&&s.static&&s.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=e.route.id),E.createElement(kr.Provider,{value:t},n)}function KD(t,e=[],n=null,s=null){if(t==null){if(!n)return null;if(n.errors)t=n.matches;else if(e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let i=t,l=n==null?void 0:n.errors;if(l!=null){let d=i.findIndex(h=>h.route.id&&(l==null?void 0:l[h.route.id])!==void 0);ut(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(l).join(",")}`),i=i.slice(0,Math.min(i.length,d+1))}let c=!1,f=-1;if(n)for(let d=0;d<i.length;d++){let h=i[d];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(f=d),h.route.id){let{loaderData:p,errors:b}=n,m=h.route.loader&&!p.hasOwnProperty(h.route.id)&&(!b||b[h.route.id]===void 0);if(h.route.lazy||m){c=!0,f>=0?i=i.slice(0,f+1):i=[i[0]];break}}}return i.reduceRight((d,h,p)=>{let b,m=!1,v=null,g=null;n&&(b=l&&h.route.id?l[h.route.id]:void 0,v=h.route.errorElement||YD,c&&(f<0&&p===0?(VC("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),m=!0,g=null):f===p&&(m=!0,g=h.route.hydrateFallbackElement||null)));let x=e.concat(i.slice(0,p+1)),w=()=>{let C;return b?C=v:m?C=g:h.route.Component?C=E.createElement(h.route.Component,null):h.route.element?C=h.route.element:C=d,E.createElement(WD,{match:h,routeContext:{outlet:d,matches:x,isDataRoute:n!=null},children:C})};return n&&(h.route.ErrorBoundary||h.route.errorElement||p===0)?E.createElement(QD,{location:n.location,revalidation:n.revalidation,component:v,error:b,children:w(),routeContext:{outlet:null,matches:x,isDataRoute:!0}}):w()},null)}function ky(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ZD(t){let e=E.useContext(Io);return ut(e,ky(t)),e}function XD(t){let e=E.useContext(Kd);return ut(e,ky(t)),e}function JD(t){let e=E.useContext(kr);return ut(e,ky(t)),e}function My(t){let e=JD(t),n=e.matches[e.matches.length-1];return ut(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function ej(){return My("useRouteId")}function tj(){var s;let t=E.useContext(Ny),e=XD("useRouteError"),n=My("useRouteError");return t!==void 0?t:(s=e.errors)==null?void 0:s[n]}function nj(){let{router:t}=ZD("useNavigate"),e=My("useNavigate"),n=E.useRef(!1);return UC(()=>{n.current=!0}),E.useCallback(async(i,l={})=>{_r(n.current,qC),n.current&&(typeof i=="number"?t.navigate(i):await t.navigate(i,{fromRouteId:e,...l}))},[t,e])}var Yw={};function VC(t,e,n){!e&&!Yw[t]&&(Yw[t]=!0,_r(!1,n))}E.memo(rj);function rj({routes:t,future:e,state:n}){return FC(t,void 0,n,e)}function za(t){ut(!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 sj({basename:t="/",children:e=null,location:n,navigationType:s="POP",navigator:i,static:l=!1}){ut(!Uu(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let c=t.replace(/^\/*/,"/"),f=E.useMemo(()=>({basename:c,navigator:i,static:l,future:{}}),[c,i,l]);typeof n=="string"&&(n=Po(n));let{pathname:d="/",search:h="",hash:p="",state:b=null,key:m="default"}=n,v=E.useMemo(()=>{let g=ps(d,c);return g==null?null:{location:{pathname:g,search:h,hash:p,state:b,key:m},navigationType:s}},[c,d,h,p,b,m,s]);return _r(v!=null,`<Router basename="${c}"> is not able to match the URL "${d}${h}${p}" because it does not start with the basename, so the <Router> won't render anything.`),v==null?null:E.createElement(Nr.Provider,{value:f},E.createElement(qu.Provider,{children:e,value:v}))}function aj({children:t,location:e}){return $D(Mv(t),e)}function Mv(t,e=[]){let n=[];return E.Children.forEach(t,(s,i)=>{if(!E.isValidElement(s))return;let l=[...e,i];if(s.type===E.Fragment){n.push.apply(n,Mv(s.props.children,l));return}ut(s.type===za,`[${typeof s.type=="string"?s.type:s.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),ut(!s.props.index||!s.props.children,"An index route cannot have child routes.");let c={id:s.props.id||l.join("-"),caseSensitive:s.props.caseSensitive,element:s.props.element,Component:s.props.Component,index:s.props.index,path:s.props.path,loader:s.props.loader,action:s.props.action,hydrateFallbackElement:s.props.hydrateFallbackElement,HydrateFallback:s.props.HydrateFallback,errorElement:s.props.errorElement,ErrorBoundary:s.props.ErrorBoundary,hasErrorBoundary:s.props.hasErrorBoundary===!0||s.props.ErrorBoundary!=null||s.props.errorElement!=null,shouldRevalidate:s.props.shouldRevalidate,handle:s.props.handle,lazy:s.props.lazy};s.props.children&&(c.children=Mv(s.props.children,l)),n.push(c)}),n}var nd="get",rd="application/x-www-form-urlencoded";function Zd(t){return t!=null&&typeof t.tagName=="string"}function ij(t){return Zd(t)&&t.tagName.toLowerCase()==="button"}function oj(t){return Zd(t)&&t.tagName.toLowerCase()==="form"}function lj(t){return Zd(t)&&t.tagName.toLowerCase()==="input"}function uj(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function cj(t,e){return t.button===0&&(!e||e==="_self")&&!uj(t)}var pf=null;function fj(){if(pf===null)try{new FormData(document.createElement("form"),0),pf=!1}catch{pf=!0}return pf}var dj=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Vm(t){return t!=null&&!dj.has(t)?(_r(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${rd}"`),null):t}function hj(t,e){let n,s,i,l,c;if(oj(t)){let f=t.getAttribute("action");s=f?ps(f,e):null,n=t.getAttribute("method")||nd,i=Vm(t.getAttribute("enctype"))||rd,l=new FormData(t)}else if(ij(t)||lj(t)&&(t.type==="submit"||t.type==="image")){let f=t.form;if(f==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let d=t.getAttribute("formaction")||f.getAttribute("action");if(s=d?ps(d,e):null,n=t.getAttribute("formmethod")||f.getAttribute("method")||nd,i=Vm(t.getAttribute("formenctype"))||Vm(f.getAttribute("enctype"))||rd,l=new FormData(f,t),!fj()){let{name:h,type:p,value:b}=t;if(p==="image"){let m=h?`${h}.`:"";l.append(`${m}x`,"0"),l.append(`${m}y`,"0")}else h&&l.append(h,b)}}else{if(Zd(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=nd,s=null,i=rd,c=t}return l&&i==="text/plain"&&(c=l,l=void 0),{action:s,method:n.toLowerCase(),encType:i,formData:l,body:c}}function Ly(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}async function pj(t,e){if(t.id in e)return e[t.id];try{let n=await import(t.module);return e[t.id]=n,n}catch(n){return console.error(`Error loading route module \`${t.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function mj(t){return t==null?!1:t.href==null?t.rel==="preload"&&typeof t.imageSrcSet=="string"&&typeof t.imageSizes=="string":typeof t.rel=="string"&&typeof t.href=="string"}async function gj(t,e,n){let s=await Promise.all(t.map(async i=>{let l=e.routes[i.route.id];if(l){let c=await pj(l,n);return c.links?c.links():[]}return[]}));return xj(s.flat(1).filter(mj).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function Qw(t,e,n,s,i,l){let c=(d,h)=>n[h]?d.route.id!==n[h].route.id:!0,f=(d,h)=>{var p;return n[h].pathname!==d.pathname||((p=n[h].route.path)==null?void 0:p.endsWith("*"))&&n[h].params["*"]!==d.params["*"]};return l==="assets"?e.filter((d,h)=>c(d,h)||f(d,h)):l==="data"?e.filter((d,h)=>{var b;let p=s.routes[d.route.id];if(!p||!p.hasLoader)return!1;if(c(d,h)||f(d,h))return!0;if(d.route.shouldRevalidate){let m=d.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:((b=n[0])==null?void 0:b.params)||{},nextUrl:new URL(t,window.origin),nextParams:d.params,defaultShouldRevalidate:!0});if(typeof m=="boolean")return m}return!0}):[]}function vj(t,e,{includeHydrateFallback:n}={}){return yj(t.map(s=>{let i=e.routes[s.route.id];if(!i)return[];let l=[i.module];return i.clientActionModule&&(l=l.concat(i.clientActionModule)),i.clientLoaderModule&&(l=l.concat(i.clientLoaderModule)),n&&i.hydrateFallbackModule&&(l=l.concat(i.hydrateFallbackModule)),i.imports&&(l=l.concat(i.imports)),l}).flat(1))}function yj(t){return[...new Set(t)]}function bj(t){let e={},n=Object.keys(t).sort();for(let s of n)e[s]=t[s];return e}function xj(t,e){let n=new Set;return new Set(e),t.reduce((s,i)=>{let l=JSON.stringify(bj(i));return n.has(l)||(n.add(l),s.push({key:l,link:i})),s},[])}function wj(t,e){let n=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return n.pathname==="/"?n.pathname="_root.data":e&&ps(n.pathname,e)==="/"?n.pathname=`${e.replace(/\/$/,"")}/_root.data`:n.pathname=`${n.pathname.replace(/\/$/,"")}.data`,n}function $C(){let t=E.useContext(Io);return Ly(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Sj(){let t=E.useContext(Kd);return Ly(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var Dy=E.createContext(void 0);Dy.displayName="FrameworkContext";function GC(){let t=E.useContext(Dy);return Ly(t,"You must render this element inside a <HydratedRouter> element"),t}function _j(t,e){let n=E.useContext(Dy),[s,i]=E.useState(!1),[l,c]=E.useState(!1),{onFocus:f,onBlur:d,onMouseEnter:h,onMouseLeave:p,onTouchStart:b}=e,m=E.useRef(null);E.useEffect(()=>{if(t==="render"&&c(!0),t==="viewport"){let x=C=>{C.forEach(T=>{c(T.isIntersecting)})},w=new IntersectionObserver(x,{threshold:.5});return m.current&&w.observe(m.current),()=>{w.disconnect()}}},[t]),E.useEffect(()=>{if(s){let x=setTimeout(()=>{c(!0)},100);return()=>{clearTimeout(x)}}},[s]);let v=()=>{i(!0)},g=()=>{i(!1),c(!1)};return n?t!=="intent"?[l,m,{}]:[l,m,{onFocus:Fl(f,v),onBlur:Fl(d,g),onMouseEnter:Fl(h,v),onMouseLeave:Fl(p,g),onTouchStart:Fl(b,v)}]:[!1,m,{}]}function Fl(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function Ej({page:t,...e}){let{router:n}=$C(),s=E.useMemo(()=>LC(n.routes,t,n.basename),[n.routes,t,n.basename]);return s?E.createElement(Tj,{page:t,matches:s,...e}):null}function Cj(t){let{manifest:e,routeModules:n}=GC(),[s,i]=E.useState([]);return E.useEffect(()=>{let l=!1;return gj(t,e,n).then(c=>{l||i(c)}),()=>{l=!0}},[t,e,n]),s}function Tj({page:t,matches:e,...n}){let s=ha(),{manifest:i,routeModules:l}=GC(),{basename:c}=$C(),{loaderData:f,matches:d}=Sj(),h=E.useMemo(()=>Qw(t,e,d,i,s,"data"),[t,e,d,i,s]),p=E.useMemo(()=>Qw(t,e,d,i,s,"assets"),[t,e,d,i,s]),b=E.useMemo(()=>{if(t===s.pathname+s.search+s.hash)return[];let g=new Set,x=!1;if(e.forEach(C=>{var A;let T=i.routes[C.route.id];!T||!T.hasLoader||(!h.some(R=>R.route.id===C.route.id)&&C.route.id in f&&((A=l[C.route.id])!=null&&A.shouldRevalidate)||T.hasClientLoader?x=!0:g.add(C.route.id))}),g.size===0)return[];let w=wj(t,c);return x&&g.size>0&&w.searchParams.set("_routes",e.filter(C=>g.has(C.route.id)).map(C=>C.route.id).join(",")),[w.pathname+w.search]},[c,f,s,i,h,e,t,l]),m=E.useMemo(()=>vj(p,i),[p,i]),v=Cj(p);return E.createElement(E.Fragment,null,b.map(g=>E.createElement("link",{key:g,rel:"prefetch",as:"fetch",href:g,...n})),m.map(g=>E.createElement("link",{key:g,rel:"modulepreload",href:g,...n})),v.map(({key:g,link:x})=>E.createElement("link",{key:g,...x})))}function Rj(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var YC=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{YC&&(window.__reactRouterVersion="7.3.0")}catch{}function Aj({basename:t,children:e,window:n}){let s=E.useRef();s.current==null&&(s.current=vD({window:n,v5Compat:!0}));let i=s.current,[l,c]=E.useState({action:i.action,location:i.location}),f=E.useCallback(d=>{E.startTransition(()=>c(d))},[c]);return E.useLayoutEffect(()=>i.listen(f),[i,f]),E.createElement(sj,{basename:t,children:e,location:l.location,navigationType:l.action,navigator:i})}var QC=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,WC=E.forwardRef(function({onClick:e,discover:n="render",prefetch:s="none",relative:i,reloadDocument:l,replace:c,state:f,target:d,to:h,preventScrollReset:p,viewTransition:b,...m},v){let{basename:g}=E.useContext(Nr),x=typeof h=="string"&&QC.test(h),w,C=!1;if(typeof h=="string"&&x&&(w=h,YC))try{let M=new URL(window.location.href),P=h.startsWith("//")?new URL(M.protocol+h):new URL(h),q=ps(P.pathname,g);P.origin===M.origin&&q!=null?h=q+P.search+P.hash:C=!0}catch{_r(!1,`<Link to="${h}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let T=FD(h,{relative:i}),[A,R,k]=_j(s,m),j=kj(h,{replace:c,state:f,target:d,preventScrollReset:p,relative:i,viewTransition:b});function D(M){e&&e(M),M.defaultPrevented||j(M)}let F=E.createElement("a",{...m,...k,href:w||T,onClick:C||l?e:D,ref:Rj(v,R),target:d,"data-discover":!x&&n==="render"?"true":void 0});return A&&!x?E.createElement(E.Fragment,null,F,E.createElement(Ej,{page:T})):F});WC.displayName="Link";var no=E.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:s="",end:i=!1,style:l,to:c,viewTransition:f,children:d,...h},p){let b=Hu(c,{relative:h.relative}),m=ha(),v=E.useContext(Kd),{navigator:g,basename:x}=E.useContext(Nr),w=v!=null&&Pj(b)&&f===!0,C=g.encodeLocation?g.encodeLocation(b).pathname:b.pathname,T=m.pathname,A=v&&v.navigation&&v.navigation.location?v.navigation.location.pathname:null;n||(T=T.toLowerCase(),A=A?A.toLowerCase():null,C=C.toLowerCase()),A&&x&&(A=ps(A,x)||A);const R=C!=="/"&&C.endsWith("/")?C.length-1:C.length;let k=T===C||!i&&T.startsWith(C)&&T.charAt(R)==="/",j=A!=null&&(A===C||!i&&A.startsWith(C)&&A.charAt(C.length)==="/"),D={isActive:k,isPending:j,isTransitioning:w},F=k?e:void 0,M;typeof s=="function"?M=s(D):M=[s,k?"active":null,j?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let P=typeof l=="function"?l(D):l;return E.createElement(WC,{...h,"aria-current":F,className:M,ref:p,style:P,to:c,viewTransition:f},typeof d=="function"?d(D):d)});no.displayName="NavLink";var Oj=E.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:s,replace:i,state:l,method:c=nd,action:f,onSubmit:d,relative:h,preventScrollReset:p,viewTransition:b,...m},v)=>{let g=Dj(),x=jj(f,{relative:h}),w=c.toLowerCase()==="get"?"get":"post",C=typeof f=="string"&&QC.test(f),T=A=>{if(d&&d(A),A.defaultPrevented)return;A.preventDefault();let R=A.nativeEvent.submitter,k=(R==null?void 0:R.getAttribute("formmethod"))||c;g(R||A.currentTarget,{fetcherKey:e,method:k,navigate:n,replace:i,state:l,relative:h,preventScrollReset:p,viewTransition:b})};return E.createElement("form",{ref:v,method:w,action:x,onSubmit:s?d:T,...m,"data-discover":!C&&t==="render"?"true":void 0})});Oj.displayName="Form";function Nj(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function KC(t){let e=E.useContext(Io);return ut(e,Nj(t)),e}function kj(t,{target:e,replace:n,state:s,preventScrollReset:i,relative:l,viewTransition:c}={}){let f=Bo(),d=ha(),h=Hu(t,{relative:l});return E.useCallback(p=>{if(cj(p,e)){p.preventDefault();let b=n!==void 0?n:du(d)===du(h);f(t,{replace:b,state:s,preventScrollReset:i,relative:l,viewTransition:c})}},[d,f,h,n,s,e,t,i,l,c])}var Mj=0,Lj=()=>`__${String(++Mj)}__`;function Dj(){let{router:t}=KC("useSubmit"),{basename:e}=E.useContext(Nr),n=ej();return E.useCallback(async(s,i={})=>{let{action:l,method:c,encType:f,formData:d,body:h}=hj(s,e);if(i.navigate===!1){let p=i.fetcherKey||Lj();await t.fetch(p,n,i.action||l,{preventScrollReset:i.preventScrollReset,formData:d,body:h,formMethod:i.method||c,formEncType:i.encType||f,flushSync:i.flushSync})}else await t.navigate(i.action||l,{preventScrollReset:i.preventScrollReset,formData:d,body:h,formMethod:i.method||c,formEncType:i.encType||f,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[t,e,n])}function jj(t,{relative:e}={}){let{basename:n}=E.useContext(Nr),s=E.useContext(kr);ut(s,"useFormAction must be used inside a RouteContext");let[i]=s.matches.slice(-1),l={...Hu(t||".",{relative:e})},c=ha();if(t==null){l.search=c.search;let f=new URLSearchParams(l.search),d=f.getAll("index");if(d.some(p=>p==="")){f.delete("index"),d.filter(b=>b).forEach(b=>f.append("index",b));let p=f.toString();l.search=p?`?${p}`:""}}return(!t||t===".")&&i.route.index&&(l.search=l.search?l.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(l.pathname=l.pathname==="/"?n:cs([n,l.pathname])),du(l)}function Pj(t,e={}){let n=E.useContext(zC);ut(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:s}=KC("useViewTransitionState"),i=Hu(t,{relative:e.relative});if(!n.isTransitioning)return!1;let l=ps(n.currentLocation.pathname,s)||n.currentLocation.pathname,c=ps(n.nextLocation.pathname,s)||n.nextLocation.pathname;return _d(i.pathname,c)!=null||_d(i.pathname,l)!=null}new TextEncoder;const Ij=fa("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Ed({className:t,variant:e,...n}){return S.jsx("div",{className:fe(Ij({variant:e}),t),...n})}var Bj="Label",ZC=E.forwardRef((t,e)=>S.jsx(Ne.label,{...t,ref:e,onMouseDown:n=>{var i;n.target.closest("button, input, select, textarea")||((i=t.onMouseDown)==null||i.call(t,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));ZC.displayName=Bj;var XC=ZC;const zj=fa("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Cd=E.forwardRef(({className:t,...e},n)=>S.jsx(XC,{ref:n,className:fe(zj(),t),...e}));Cd.displayName=XC.displayName;const qj=({tag:t,onRemove:e})=>S.jsxs(Ed,{variant:"outline",className:"flex items-center gap-1.5 pr-1.5 text-sm py-1 px-2 transition-colors hover:bg-white hover:text-black dark:hover:text-black",children:[t,S.jsxs(Ze,{type:"button",variant:"ghost",size:"icon",onClick:()=>e(t),className:"hover:bg-muted/20 rounded-full p-0.5 transition-colors h-auto w-auto min-w-0 min-h-0",children:[S.jsx(ui,{className:"h-3 w-3"}),S.jsxs("span",{className:"sr-only",children:["Remove ",t]})]})]}),Uj=({tags:t,onRemove:e})=>S.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:t.map(n=>S.jsx(qj,{tag:n,onRemove:e},n))}),Hj=({value:t,onChange:e,onKeyDown:n})=>S.jsx(is,{value:t,onChange:e,onKeyDown:n,placeholder:"Type and press Enter to add...",className:fe("bg-background",!t&&"text-muted-foreground")});function Fj({title:t,data:e,onChange:n}){const[s,i]=E.useState(""),l=f=>{if(f.key==="Enter"){f.preventDefault();const d=s.trim();d&&!e.includes(d)&&(n([...e,d]),i(""))}},c=f=>{n(e.filter(d=>d!==f))};return S.jsxs("div",{className:"space-y-2",children:[S.jsx(Cd,{children:t}),S.jsxs("div",{className:"p-2 bg-card rounded-md border",children:[S.jsx(Uj,{tags:e,onRemove:c}),S.jsx(Hj,{value:s,onChange:f=>i(f.target.value),onKeyDown:l})]})]})}const Fu=E.forwardRef(({className:t,...e},n)=>S.jsx("div",{ref:n,className:fe("rounded-xl border bg-card text-card-foreground shadow",t),...e}));Fu.displayName="Card";const JC=E.forwardRef(({className:t,...e},n)=>S.jsx("div",{ref:n,className:fe("flex flex-col space-y-1.5 p-6",t),...e}));JC.displayName="CardHeader";const eT=E.forwardRef(({className:t,...e},n)=>S.jsx("div",{ref:n,className:fe("font-semibold leading-none tracking-tight",t),...e}));eT.displayName="CardTitle";const Vj=E.forwardRef(({className:t,...e},n)=>S.jsx("div",{ref:n,className:fe("text-sm text-muted-foreground",t),...e}));Vj.displayName="CardDescription";const Xd=E.forwardRef(({className:t,...e},n)=>S.jsx("div",{ref:n,className:fe("p-6 pt-0",t),...e}));Xd.displayName="CardContent";const tT=E.forwardRef(({className:t,...e},n)=>S.jsx("div",{ref:n,className:fe("flex items-center p-6 pt-0",t),...e}));tT.displayName="CardFooter";function jy(t){const e=t+"CollectionProvider",[n,s]=Ar(e),[i,l]=n(e,{collectionRef:{current:null},itemMap:new Map}),c=v=>{const{scope:g,children:x}=v,w=es.useRef(null),C=es.useRef(new Map).current;return S.jsx(i,{scope:g,itemMap:C,collectionRef:w,children:x})};c.displayName=e;const f=t+"CollectionSlot",d=es.forwardRef((v,g)=>{const{scope:x,children:w}=v,C=l(f,x),T=We(g,C.collectionRef);return S.jsx(Mn,{ref:T,children:w})});d.displayName=f;const h=t+"CollectionItemSlot",p="data-radix-collection-item",b=es.forwardRef((v,g)=>{const{scope:x,children:w,...C}=v,T=es.useRef(null),A=We(g,T),R=l(h,x);return es.useEffect(()=>(R.itemMap.set(T,{ref:T,...C}),()=>void R.itemMap.delete(T))),S.jsx(Mn,{[p]:"",ref:A,children:w})});b.displayName=h;function m(v){const g=l(t+"CollectionConsumer",v);return es.useCallback(()=>{const w=g.collectionRef.current;if(!w)return[];const C=Array.from(w.querySelectorAll(`[${p}]`));return Array.from(g.itemMap.values()).sort((R,k)=>C.indexOf(R.ref.current)-C.indexOf(k.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:c,Slot:d,ItemSlot:b},m,s]}var $j=E.createContext(void 0);function Jd(t){const e=E.useContext($j);return t||e||"ltr"}var $m="rovingFocusGroup.onEntryFocus",Gj={bubbles:!1,cancelable:!0},eh="RovingFocusGroup",[Lv,nT,Yj]=jy(eh),[Qj,rT]=Ar(eh,[Yj]),[Wj,Kj]=Qj(eh),sT=E.forwardRef((t,e)=>S.jsx(Lv.Provider,{scope:t.__scopeRovingFocusGroup,children:S.jsx(Lv.Slot,{scope:t.__scopeRovingFocusGroup,children:S.jsx(Zj,{...t,ref:e})})}));sT.displayName=eh;var Zj=E.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:i=!1,dir:l,currentTabStopId:c,defaultCurrentTabStopId:f,onCurrentTabStopIdChange:d,onEntryFocus:h,preventScrollOnEntryFocus:p=!1,...b}=t,m=E.useRef(null),v=We(e,m),g=Jd(l),[x=null,w]=ei({prop:c,defaultProp:f,onChange:d}),[C,T]=E.useState(!1),A=pt(h),R=nT(n),k=E.useRef(!1),[j,D]=E.useState(0);return E.useEffect(()=>{const F=m.current;if(F)return F.addEventListener($m,A),()=>F.removeEventListener($m,A)},[A]),S.jsx(Wj,{scope:n,orientation:s,dir:g,loop:i,currentTabStopId:x,onItemFocus:E.useCallback(F=>w(F),[w]),onItemShiftTab:E.useCallback(()=>T(!0),[]),onFocusableItemAdd:E.useCallback(()=>D(F=>F+1),[]),onFocusableItemRemove:E.useCallback(()=>D(F=>F-1),[]),children:S.jsx(Ne.div,{tabIndex:C||j===0?-1:0,"data-orientation":s,...b,ref:v,style:{outline:"none",...t.style},onMouseDown:_e(t.onMouseDown,()=>{k.current=!0}),onFocus:_e(t.onFocus,F=>{const M=!k.current;if(F.target===F.currentTarget&&M&&!C){const P=new CustomEvent($m,Gj);if(F.currentTarget.dispatchEvent(P),!P.defaultPrevented){const q=R().filter(N=>N.focusable),U=q.find(N=>N.active),G=q.find(N=>N.id===x),L=[U,G,...q].filter(Boolean).map(N=>N.ref.current);oT(L,p)}}k.current=!1}),onBlur:_e(t.onBlur,()=>T(!1))})})}),aT="RovingFocusGroupItem",iT=E.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:i=!1,tabStopId:l,...c}=t,f=os(),d=l||f,h=Kj(aT,n),p=h.currentTabStopId===d,b=nT(n),{onFocusableItemAdd:m,onFocusableItemRemove:v}=h;return E.useEffect(()=>{if(s)return m(),()=>v()},[s,m,v]),S.jsx(Lv.ItemSlot,{scope:n,id:d,focusable:s,active:i,children:S.jsx(Ne.span,{tabIndex:p?0:-1,"data-orientation":h.orientation,...c,ref:e,onMouseDown:_e(t.onMouseDown,g=>{s?h.onItemFocus(d):g.preventDefault()}),onFocus:_e(t.onFocus,()=>h.onItemFocus(d)),onKeyDown:_e(t.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){h.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const x=e8(g,h.orientation,h.dir);if(x!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let C=b().filter(T=>T.focusable).map(T=>T.ref.current);if(x==="last")C.reverse();else if(x==="prev"||x==="next"){x==="prev"&&C.reverse();const T=C.indexOf(g.currentTarget);C=h.loop?t8(C,T+1):C.slice(T+1)}setTimeout(()=>oT(C))}})})})});iT.displayName=aT;var Xj={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Jj(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function e8(t,e,n){const s=Jj(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return Xj[s]}function oT(t,e=!1){const n=document.activeElement;for(const s of t)if(s===n||(s.focus({preventScroll:e}),document.activeElement!==n))return}function t8(t,e){return t.map((n,s)=>t[(e+s)%t.length])}var n8=sT,r8=iT,Py="Tabs",[s8,Uz]=Ar(Py,[rT]),lT=rT(),[a8,Iy]=s8(Py),uT=E.forwardRef((t,e)=>{const{__scopeTabs:n,value:s,onValueChange:i,defaultValue:l,orientation:c="horizontal",dir:f,activationMode:d="automatic",...h}=t,p=Jd(f),[b,m]=ei({prop:s,onChange:i,defaultProp:l});return S.jsx(a8,{scope:n,baseId:os(),value:b,onValueChange:m,orientation:c,dir:p,activationMode:d,children:S.jsx(Ne.div,{dir:p,"data-orientation":c,...h,ref:e})})});uT.displayName=Py;var cT="TabsList",fT=E.forwardRef((t,e)=>{const{__scopeTabs:n,loop:s=!0,...i}=t,l=Iy(cT,n),c=lT(n);return S.jsx(n8,{asChild:!0,...c,orientation:l.orientation,dir:l.dir,loop:s,children:S.jsx(Ne.div,{role:"tablist","aria-orientation":l.orientation,...i,ref:e})})});fT.displayName=cT;var dT="TabsTrigger",hT=E.forwardRef((t,e)=>{const{__scopeTabs:n,value:s,disabled:i=!1,...l}=t,c=Iy(dT,n),f=lT(n),d=gT(c.baseId,s),h=vT(c.baseId,s),p=s===c.value;return S.jsx(r8,{asChild:!0,...f,focusable:!i,active:p,children:S.jsx(Ne.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":h,"data-state":p?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:d,...l,ref:e,onMouseDown:_e(t.onMouseDown,b=>{!i&&b.button===0&&b.ctrlKey===!1?c.onValueChange(s):b.preventDefault()}),onKeyDown:_e(t.onKeyDown,b=>{[" ","Enter"].includes(b.key)&&c.onValueChange(s)}),onFocus:_e(t.onFocus,()=>{const b=c.activationMode!=="manual";!p&&!i&&b&&c.onValueChange(s)})})})});hT.displayName=dT;var pT="TabsContent",mT=E.forwardRef((t,e)=>{const{__scopeTabs:n,value:s,forceMount:i,children:l,...c}=t,f=Iy(pT,n),d=gT(f.baseId,s),h=vT(f.baseId,s),p=s===f.value,b=E.useRef(p);return E.useEffect(()=>{const m=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(m)},[]),S.jsx(Ln,{present:i||p,children:({present:m})=>S.jsx(Ne.div,{"data-state":p?"active":"inactive","data-orientation":f.orientation,role:"tabpanel","aria-labelledby":d,hidden:!m,id:h,tabIndex:0,...c,ref:e,style:{...t.style,animationDuration:b.current?"0s":void 0},children:m&&l})})});mT.displayName=pT;function gT(t,e){return`${t}-trigger-${e}`}function vT(t,e){return`${t}-content-${e}`}var i8=uT,yT=fT,bT=hT,xT=mT;const wT=i8,By=E.forwardRef(({className:t,...e},n)=>S.jsx(yT,{ref:n,className:fe("inline-flex h-9 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...e}));By.displayName=yT.displayName;const hu=E.forwardRef(({className:t,...e},n)=>S.jsx(bT,{ref:n,className:fe("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",t),...e}));hu.displayName=bT.displayName;const pu=E.forwardRef(({className:t,...e},n)=>S.jsx(xT,{ref:n,className:fe("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));pu.displayName=xT.displayName;const zy=E.forwardRef(({className:t,...e},n)=>S.jsx("textarea",{className:fe("flex min-h-[60px] select-none w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:n,...e}));zy.displayName="Textarea";const o8=1,l8=1e6;let Gm=0;function u8(){return Gm=(Gm+1)%Number.MAX_SAFE_INTEGER,Gm.toString()}const Ym=new Map,Ww=t=>{if(Ym.has(t))return;const e=setTimeout(()=>{Ym.delete(t),lu({type:"REMOVE_TOAST",toastId:t})},l8);Ym.set(t,e)},c8=(t,e)=>{switch(e.type){case"ADD_TOAST":return{...t,toasts:[e.toast,...t.toasts].slice(0,o8)};case"UPDATE_TOAST":return{...t,toasts:t.toasts.map(n=>n.id===e.toast.id?{...n,...e.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=e;if(n)Ww(n);else for(const s of t.toasts)Ww(s.id);return{...t,toasts:t.toasts.map(s=>s.id===n||n===void 0?{...s,open:!1}:s)}}case"REMOVE_TOAST":return e.toastId===void 0?{...t,toasts:[]}:{...t,toasts:t.toasts.filter(n=>n.id!==e.toastId)}}},sd=[];let ad={toasts:[]};function lu(t){ad=c8(ad,t);for(const e of sd)e(ad)}function f8({...t}){const e=u8(),n=i=>lu({type:"UPDATE_TOAST",toast:{...i,id:e}}),s=()=>lu({type:"DISMISS_TOAST",toastId:e});return lu({type:"ADD_TOAST",toast:{...t,id:e,open:!0,onOpenChange:i=>{i||s()}}}),{id:e,dismiss:s,update:n}}function tr(){const[t,e]=E.useState(ad);return E.useEffect(()=>(sd.push(e),()=>{const n=sd.indexOf(e);n>-1&&sd.splice(n,1)}),[]),{...t,toast:f8,dismiss:n=>lu({type:"DISMISS_TOAST",toastId:n})}}const Kw=[{sectionTitle:"Basic Info",sectionValue:"basic",sectionType:"input",fields:[{title:"Name",name:"name",description:"The display name of your character",fieldType:"text",getValue:t=>t.name||""},{title:"Username",name:"username",description:"Unique identifier for your character",fieldType:"text",getValue:t=>t.username||""},{title:"System",name:"system",description:"System prompt for character behavior",fieldType:"textarea",getValue:t=>t.system||""},{title:"Voice Model",name:"settings.voice.model",description:"Voice model used for speech synthesis",fieldType:"text",getValue:t=>{var e,n;return((n=(e=t.settings)==null?void 0:e.voice)==null?void 0:n.model)||""}}]},{sectionTitle:"Content",sectionValue:"content",sectionType:"array",fields:[{title:"Bio",description:"Key information about your character",path:"bio",getData:t=>Array.isArray(t.bio)?t.bio:[]},{title:"Topics",description:"Topics your character is knowledgeable about",path:"topics",getData:t=>t.topics||[]},{title:"Adjectives",description:"Words that describe your character's personality",path:"adjectives",getData:t=>t.adjectives||[]}]},{sectionTitle:"Style",sectionValue:"style",sectionType:"array",fields:[{title:"All",description:"Style rules applied to all interactions",path:"style.all",getData:t=>{var e;return((e=t.style)==null?void 0:e.all)||[]}},{title:"Chat",description:"Style rules for chat interactions",path:"style.chat",getData:t=>{var e;return((e=t.style)==null?void 0:e.chat)||[]}},{title:"Post",description:"Style rules for social media posts",path:"style.post",getData:t=>{var e;return((e=t.style)==null?void 0:e.post)||[]}}]}];function ST({characterValue:t,setCharacterValue:e,title:n,description:s,onSubmit:i,onDelete:l,onReset:c,customComponents:f=[]}){const{toast:d}=tr(),[h,p]=E.useState(!1),b=w=>{const{name:C,value:T,type:A}=w.target,R=w.target.checked;if(C.includes(".")){const k=C.split(".");e(j=>{const D={...j};let F=D;for(let M=0;M<k.length-1;M++)F[k[M]]||(F[k[M]]={}),F=F[k[M]];return F[k[k.length-1]]=A==="checkbox"?R:T,D})}else e(k=>({...k,[C]:A==="checkbox"?R:T}))},m=(w,C)=>{e(T=>{const A={...T},R=w.split(".");let k=A;for(let j=0;j<R.length-1;j++){const D=R[j];(!k[D]||typeof k[D]!="object")&&(k[D]={}),k=k[D]}return k[R[R.length-1]]=C,A})},v=async w=>{w.preventDefault(),p(!0);try{await i(t)}catch(C){d({title:"Error",description:C instanceof Error?C.message:"Failed to update",variant:"destructive"})}finally{p(!1)}},g=w=>S.jsxs("div",{className:"space-y-2",children:[S.jsx(Cd,{htmlFor:w.name,children:w.title}),w.description&&S.jsx("p",{className:"text-sm text-muted-foreground",children:w.description}),w.fieldType==="textarea"?S.jsx(zy,{id:w.name,name:w.name,value:w.getValue(t),onChange:b,className:"min-h-[120px] resize-y"}):w.fieldType==="checkbox"?S.jsx(is,{id:w.name,name:w.name,type:"checkbox",checked:t[w.name]==="true",onChange:b}):S.jsx(is,{id:w.name,name:w.name,type:w.fieldType,value:w.getValue(t),onChange:b})]},w.name),x=w=>S.jsxs("div",{className:"space-y-2",children:[S.jsx(Cd,{htmlFor:w.path,children:w.title}),w.description&&S.jsx("p",{className:"text-sm text-muted-foreground",children:w.description}),S.jsx(Fj,{data:w.getData(t),onChange:C=>m(w.path,C)})]},w.path);return S.jsxs("div",{className:"container max-w-4xl mx-auto p-6",children:[S.jsx("div",{className:"flex items-center justify-between mb-6",children:S.jsxs("div",{children:[S.jsx("h1",{className:"text-3xl font-bold",children:n}),S.jsx("p",{className:"text-muted-foreground mt-1",children:s})]})}),S.jsxs("form",{onSubmit:v,children:[S.jsxs(wT,{defaultValue:"basic",className:"w-full",children:[S.jsxs(By,{className:"grid w-full mb-6",style:{gridTemplateColumns:`repeat(${f.length+3}, minmax(0, 1fr))`},children:[Kw.map(w=>S.jsx(hu,{value:w.sectionValue,children:w.sectionTitle},w.sectionValue)),f.map(w=>S.jsx(hu,{value:`custom-${w.name}`,children:w.name},`custom-${w.name}`))]}),S.jsx(Fu,{children:S.jsxs(Xd,{className:"p-6",children:[Kw.map(w=>S.jsx(pu,{value:w.sectionValue,className:"space-y-6",children:w.sectionType==="input"?w.fields.map(g):w.fields.map(x)},w.sectionValue)),f.map(w=>S.jsx(pu,{value:`custom-${w.name}`,children:w.component},`custom-${w.name}`))]})})]}),S.jsxs("div",{className:"flex justify-between gap-4 mt-6",children:[S.jsx("div",{className:"flex gap-4 text-red-500",children:S.jsx(Ze,{type:"button",variant:"outline",onClick:()=>{l==null||l()},children:"Delete Character"})}),S.jsxs("div",{className:"flex gap-4",children:[S.jsx(Ze,{type:"button",variant:"outline",onClick:()=>{c==null||c()},children:"Reset Changes"}),S.jsx(Ze,{type:"submit",disabled:h,children:h?"Saving...":"Save Changes"})]})]})]})]})}const Qm="elizaos-world-id",Za={getWorldId:()=>{const t=localStorage.getItem(Qm);if(t)return t;const e=crypto.randomUUID();return localStorage.setItem(Qm,e),e},resetWorldId:()=>{const t=crypto.randomUUID();return localStorage.setItem(Qm,t),t},getRoomStorageKey:t=>`room-${Za.getWorldId()}-${t}`},gt=async({url:t,method:e,body:n,headers:s})=>{const i={method:e??"GET",headers:s||{Accept:"application/json","Content-Type":"application/json"}};return(e==="POST"||e==="PUT"||e==="PATCH")&&(n instanceof FormData?(i.headers&&typeof i.headers=="object"&&(i.headers=Object.fromEntries(Object.entries(i.headers).filter(([l])=>l!=="Content-Type"))),i.body=n):i.body=JSON.stringify(n)),fetch(`${t}`,i).then(async l=>{if(l.headers.get("Content-Type")==="audio/mpeg")return await l.blob();if(!l.ok){const f=await l.text();console.error("Error: ",f);let d="An error occurred.";try{d=JSON.parse(f).message||d}catch{d=f||d}throw new Error(d)}try{return await l.json()}catch(f){return console.error("JSON Parse Error:",f),null}})},kt={getAgents:()=>gt({url:"/agents"}),getAgent:t=>gt({url:`/agents/${t}`}),tts:(t,e)=>gt({url:`/agents/${t}/speech/generate`,method:"POST",body:{text:e},headers:{"Content-Type":"application/json",Accept:"audio/mpeg","Transfer-Encoding":"chunked"}}),whisper:async(t,e)=>{const n=new FormData;return n.append("file",e,"recording.wav"),gt({url:`/agents/${t}/transcriptions`,method:"POST",body:n})},sendAudioMessage:async(t,e,n)=>{const s=new FormData;if(s.append("file",e,"recording.wav"),n)for(const[i,l]of Object.entries(n))l&&s.append(i,l);return gt({url:`/agents/${t}/audio-messages`,method:"POST",body:s})},speechConversation:async(t,e,n)=>gt({url:`/agents/${t}/speech/conversation`,method:"POST",body:{text:e,...n},headers:{"Content-Type":"application/json",Accept:"audio/mpeg","Transfer-Encoding":"chunked"}}),deleteAgent:t=>gt({url:`/agents/${t}`,method:"DELETE"}),updateAgent:(t,e)=>gt({url:`/agents/${t}`,method:"PATCH",body:e}),createAgent:t=>gt({url:"/agents/",method:"POST",body:t}),startAgent:t=>gt({url:`/agents/${t}`,method:"POST",body:{start:!0}}),stopAgent:t=>gt({url:`/agents/${t}`,method:"PUT"}),getMemories:(t,e,n)=>{const i={worldId:Za.getWorldId()};return n!=null&&n.limit&&(i.limit=n.limit),n!=null&&n.before&&(i.end=n.before),gt({url:`/agents/${t}/rooms/${e}/memories`,method:"GET",body:i})},getRooms:t=>{const e=Za.getWorldId();return gt({url:`/agents/${t}/rooms`,method:"GET",body:{worldId:e}})},createRoom:(t,e)=>{const n=Za.getWorldId();return gt({url:`/agents/${t}/rooms`,method:"POST",body:{name:e,worldId:n}})},getRoom:(t,e)=>gt({url:`/agents/${t}/rooms/${e}`,method:"GET"}),updateRoom:(t,e,n)=>gt({url:`/agents/${t}/rooms/${e}`,method:"PATCH",body:n}),deleteRoom:(t,e)=>gt({url:`/agents/${t}/rooms/${e}`,method:"DELETE"}),getLogs:({level:t="",agentName:e="all",agentId:n="all"})=>{const s=new URLSearchParams;t&&t!=="all"&&s.append("level",t),e&&e!=="all"&&s.append("agentName",e),n&&n!=="all"&&s.append("agentId",n);const i=`/logs${s.toString()?`?${s.toString()}`:""}`;return gt({url:i,method:"GET"})},getAgentCompletion:(t,e,n,s,i)=>gt({url:`/agents/${t}/message`,method:"POST",body:{text:n,roomId:s,senderId:e,source:i}}),getAgentLogs:(t,e)=>{const n=new URLSearchParams;return e!=null&&e.roomId&&n.append("roomId",e.roomId),e!=null&&e.type&&n.append("type",e.type),e!=null&&e.count&&n.append("count",e.count.toString()),e!=null&&e.offset&&n.append("offset",e.offset.toString()),gt({url:`/agents/${t}/logs${n.toString()?`?${n.toString()}`:""}`,method:"GET"})},deleteLog:(t,e)=>gt({url:`/agents/${t}/logs/${e}`,method:"DELETE"})};function _T({characterValue:t,setCharacterValue:e}){var c;const[n,s]=E.useState(((c=t==null?void 0:t.settings)==null?void 0:c.avatar)||null),i=E.useRef(null),l=f=>{var h;const d=(h=f.target.files)==null?void 0:h[0];if(d){const p=new FileReader;p.onload=b=>{var m;if((m=b.target)!=null&&m.result){const v=new Image;v.src=b.target.result,v.onload=()=>{const g=document.createElement("canvas"),x=300;let w=v.width,C=v.height;w>C?w>x&&(C*=x/w,w=x):C>x&&(w*=x/C,C=x),g.width=w,g.height=C;const T=g.getContext("2d");T==null||T.drawImage(v,0,0,w,C);const A=g.toDataURL("image/jpeg",.8);s(A)}}},p.readAsDataURL(d)}};return E.useEffect(()=>{e(f=>({...f,settings:{...f.settings,avatar:n}}))},[n,e]),S.jsxs("div",{className:"rounded-lg w-full",children:[S.jsx("h2",{className:"text-xl font-bold mb-4 pb-5 ml-1",children:"Avatar Settings"}),S.jsxs("div",{className:"flex flex-col items-center gap-4 pb-4",children:[n?S.jsxs("div",{className:"relative w-64 h-64",children:[S.jsx("img",{src:n,alt:"Character Avatar",className:"object-cover rounded-lg border"}),S.jsx("button",{className:"absolute -top-2 -right-2 bg-white p-1 rounded-full shadow-md",onClick:()=>s(null),type:"button",children:S.jsx(ui,{className:"w-5 h-5 text-card"})})]}):S.jsx("div",{className:"w-64 h-64 flex items-center justify-center border border-dashed rounded-lg text-gray-500",children:S.jsx(RM,{className:"w-10 h-10"})}),S.jsx("input",{type:"file",accept:"image/*",className:"hidden",ref:i,onChange:l}),S.jsxs(Ze,{className:"flex items-center gap-2",onClick:()=>{var f;return(f=i.current)==null?void 0:f.click()},children:[S.jsx(qM,{className:"w-5 h-5"})," Upload Avatar"]})]})]})}const d8=SE,h8=hM,p8=_E,ET=E.forwardRef(({className:t,...e},n)=>S.jsx(Bd,{ref:n,className:fe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e}));ET.displayName=Bd.displayName;const CT=E.forwardRef(({className:t,children:e,...n},s)=>S.jsxs(p8,{children:[S.jsx(ET,{}),S.jsxs(zd,{ref:s,className:fe("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...n,children:[e,S.jsxs(EE,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[S.jsx(ui,{className:"h-4 w-4"}),S.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));CT.displayName=zd.displayName;const TT=({className:t,...e})=>S.jsx("div",{className:fe("flex flex-col space-y-1.5 text-center sm:text-left",t),...e});TT.displayName="DialogHeader";const RT=E.forwardRef(({className:t,...e},n)=>S.jsx(qd,{ref:n,className:fe("text-lg font-semibold leading-none tracking-tight",t),...e}));RT.displayName=qd.displayName;const m8=E.forwardRef(({className:t,...e},n)=>S.jsx(Ud,{ref:n,className:fe("text-sm text-muted-foreground",t),...e}));m8.displayName=Ud.displayName;function g8(){return da({queryKey:["plugins"],queryFn:async()=>(await fetch("https://raw.githubusercontent.com/elizaos/registry/refs/heads/main/index.json")).json()})}function AT({characterValue:t,setCharacterValue:e}){const{data:n,error:s}=g8(),[i,l]=E.useState(""),[c,f]=E.useState(!1),d=E.useMemo(()=>n?Object.keys(n).map(m=>m.replace(/^@elizaos-plugins\//,"@elizaos/")):[],[n]),h=E.useMemo(()=>Array.isArray(t==null?void 0:t.plugins)?t.plugins:[],[t==null?void 0:t.plugins]),p=E.useMemo(()=>d.filter(m=>!h.includes(m)).filter(m=>m.toLowerCase().includes(i.toLowerCase())),[d,h,i]),b=m=>{e(v=>{const g=Array.isArray(v.plugins)?v.plugins:[],x=g.includes(m)?g.filter(w=>w!==m):[...g,m];return{...v,plugins:x}})};return S.jsx("div",{className:"space-y-6",children:S.jsx("div",{className:"space-y-4",children:S.jsxs("div",{children:[S.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Plugins"}),s?S.jsxs("p",{className:"text-destructive",children:["Failed to load plugins: ",s.message]}):S.jsxs("div",{className:"space-y-4",children:[h.length>0&&S.jsxs("div",{className:"rounded-md bg-muted p-4",children:[S.jsx("h4",{className:"text-sm font-medium mb-2",children:"Currently Enabled"}),S.jsx("div",{className:"flex flex-wrap gap-2",children:h.map(m=>S.jsxs(Ze,{type:"button",variant:"ghost",size:"sm",className:"inline-flex items-center rounded-full bg-primary/10 px-2.5 py-0.5 text-xs font-medium text-primary hover:bg-primary/20 h-auto",onClick:()=>b(m),children:[m," ×"]},m))})]}),S.jsx("div",{className:"space-y-2",children:S.jsxs(d8,{open:c,onOpenChange:f,children:[S.jsx(h8,{asChild:!0,children:S.jsx(Ze,{variant:"outline",className:"w-full justify-start",children:"Search and add plugins..."})}),S.jsxs(CT,{className:"max-w-[400px]",children:[S.jsx(TT,{children:S.jsx(RT,{children:"Add Plugins"})}),S.jsxs("div",{className:"space-y-4 py-4",children:[S.jsx("div",{className:"space-y-2",children:S.jsx(is,{type:"search",placeholder:"Search plugins...",value:i,onChange:m=>l(m.target.value)})}),S.jsx("div",{className:"max-h-[300px] overflow-y-auto space-y-2",children:p.length===0?S.jsx("p",{className:"text-sm text-muted-foreground",children:"No plugins found."}):p.map(m=>S.jsx(Ze,{variant:"ghost",className:"w-full justify-start font-normal",onClick:()=>{b(m),l(""),f(!1)},children:m},m))})]})]})]})})]})]})})})}function OT({characterValue:t,setCharacterValue:e}){var k;const[n,s]=E.useState(Object.entries(((k=t==null?void 0:t.settings)==null?void 0:k.secrets)||{}).map(([j,D])=>({name:j,value:String(D)}))),[i,l]=E.useState(""),[c,f]=E.useState(""),[d,h]=E.useState(!1),[p,b]=E.useState(null),[m,v]=E.useState(null),[g,x]=E.useState(""),w=E.useRef(null),C=()=>{i&&c&&(s([...n,{name:i,value:c}]),l(""),f(""))},T=j=>{v(j),x(n[j].value),b(null)},A=j=>{const D=[...n];D[j].value=g,s(D),v(null)},R=j=>{s(n.filter((D,F)=>F!==j)),b(null),v(null)};return E.useEffect(()=>{const j=D=>{w.current&&!w.current.contains(D.target)&&b(null)};return document.addEventListener("mousedown",j),()=>{document.removeEventListener("mousedown",j)}},[]),E.useEffect(()=>{e(j=>({...j,settings:{...j.settings,secrets:Object.fromEntries(n.map(({name:D,value:F})=>[D,F]))}}))},[n,e]),S.jsxs("div",{className:"rounded-lg w-full",children:[S.jsx("h2",{className:"text-xl font-bold mb-4 pb-5 ml-1",children:"Environment Settings"}),S.jsxs("div",{className:"grid grid-cols-[1fr_2fr_auto] gap-4 items-end w-full pb-4",children:[S.jsxs("div",{className:"flex flex-col gap-1",children:[S.jsx("label",{htmlFor:"secret-name",className:"ml-2 text-xs font-medium text-gray-400",children:"NAME"}),S.jsx(is,{id:"secret-name",placeholder:"VARIABLE_NAME",value:i,onChange:j=>l(j.target.value)})]}),S.jsxs("div",{className:"flex flex-col gap-1 relative",children:[S.jsx("label",{htmlFor:"secret-value",className:"ml-2 text-xs font-medium text-gray-400",children:"VALUE"}),S.jsxs("div",{className:"relative",children:[S.jsx(is,{id:"secret-value",type:d?"text":"password",placeholder:"i9ju23nfsdf56",value:c,onChange:j=>f(j.target.value),className:"pr-10"}),S.jsx("div",{className:"absolute inset-y-0 right-3 flex items-center cursor-pointer text-gray-500",onClick:()=>h(!d),onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&h(!d)},children:d?S.jsx(EM,{}):S.jsx(CM,{})})]})]}),S.jsx(Ze,{className:"shrink-0",onClick:C,children:"Add"})]}),n.length>0&&S.jsxs("div",{className:"grid grid-cols-[1fr_2fr_auto] gap-4 mt-6 font-medium text-gray-400 border-b pb-2 ml-1",children:[S.jsx("div",{children:"Name"}),S.jsx("div",{children:"Value"}),S.jsx("div",{children:"Action"})]}),S.jsx("div",{className:"mt-2",children:n.map((j,D)=>S.jsxs("div",{className:"grid grid-cols-[1fr_2fr_auto] gap-4 items-center border-b py-2 ml-1 relative",children:[S.jsx("div",{children:j.name}),S.jsx("div",{children:m===D?S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx(is,{value:g,onChange:F=>x(F.target.value),className:"w-full"}),S.jsx(Ze,{variant:"ghost",onClick:()=>A(D),children:S.jsx(hy,{className:"w-5 h-5 text-green-500"})}),S.jsx(Ze,{variant:"ghost",onClick:()=>v(null),children:S.jsx(ui,{className:"w-5 h-5 text-red-500"})})]}):S.jsx("div",{className:"truncate text-gray-500",children:"Encrypted"})}),S.jsxs("div",{className:"relative",children:[S.jsx(Ze,{variant:"ghost",className:"p-2 text-gray-500",onClick:()=>b(p===D?null:D),children:S.jsx(_M,{className:"w-5 h-5"})}),p===D&&S.jsxs("div",{className:"absolute right-0 -top-2 mt-2 w-24 bg-muted border rounded shadow-md z-10",ref:w,children:[S.jsx("button",{className:"w-full px-4 py-2 text-left hover:opacity-50",onClick:()=>T(D),type:"button",children:"Edit"}),S.jsx("div",{className:"w-full px-4 py-2 text-left text-red-500 hover:opacity-50 cursor-pointer",onClick:()=>R(D),children:"Remove"})]})]})]},D))})]})}const Zw={name:"",username:"",system:"",bio:[],topics:[],adjectives:[]};function NT(){const t=Bo(),{toast:e}=tr(),n=er(),[s,i]=E.useState({...Zw}),l=f=>{var d,h,p;return{...f,bio:f.bio??[],messageExamples:f.messageExamples??[],postExamples:f.postExamples??[],topics:f.topics??[],adjectives:f.adjectives??[],plugins:f.plugins??[],style:{all:((d=f.style)==null?void 0:d.all)??[],chat:((h=f.style)==null?void 0:h.chat)??[],post:((p=f.style)==null?void 0:p.post)??[]}}},c=async f=>{try{const d=l(f);await kt.createAgent({characterJson:d}),n.invalidateQueries({queryKey:["characters"]}),e({title:"Success",description:"Character created successfully!"}),n.invalidateQueries({queryKey:["agents"]}),t("/")}catch(d){e({title:"Error",description:d instanceof Error?d.message:"Failed to create character",variant:"destructive"})}};return S.jsx(ST,{characterValue:s,setCharacterValue:i,title:"Character Settings",description:"Configure your AI character's behavior and capabilities",onSubmit:c,onReset:()=>i(Zw),onDelete:()=>{t("/")},isAgent:!0,customComponents:[{name:"Plugins",component:S.jsx(AT,{characterValue:s,setCharacterValue:i})},{name:"Secret",component:S.jsx(OT,{characterValue:s,setCharacterValue:i})},{name:"Avatar",component:S.jsx(_T,{characterValue:s,setCharacterValue:i})}]})}const as="user",Qn={FREQUENT:30*1e3,STANDARD:2*60*1e3,RARE:10*60*1e3,NEVER:Number.POSITIVE_INFINITY},kT=()=>{const t=typeof navigator<"u"&&"connection"in navigator?navigator.connection:null;return{isOffline:typeof navigator<"u"&&!navigator.onLine,effectiveType:(t==null?void 0:t.effectiveType)||"unknown",saveData:(t==null?void 0:t.saveData)||!1}};function qy(t={}){const e=kT();return da({queryKey:["agents"],queryFn:()=>kt.getAgents(),staleTime:Qn.FREQUENT,refetchInterval:e.isOffline?!1:Qn.FREQUENT,refetchIntervalInBackground:!1,...!e.isOffline&&e.effectiveType==="slow-2g"&&{refetchInterval:Qn.STANDARD},...t})}function v8(t,e={}){const n=kT();return da({queryKey:["agent",t],queryFn:()=>kt.getAgent(t||""),staleTime:Qn.FREQUENT,enabled:!!t,refetchInterval:!n.isOffline&&t?Qn.FREQUENT:!1,refetchIntervalInBackground:!1,...!n.isOffline&&n.effectiveType==="slow-2g"&&{refetchInterval:Qn.STANDARD},...e})}function y8(){const t=er(),{toast:e}=tr();return zu({mutationFn:async n=>{try{return await kt.startAgent(n)}catch(s){if(s instanceof Error){if(s.message.includes("network"))throw new Error("Network error: Please check your connection and try again.");if(s.message.includes("already running"))throw new Error("Agent is already running.")}throw s}},onMutate:async n=>(e({title:"Starting Agent",description:"Initializing agent..."}),{agentId:n}),onSuccess:n=>{t.invalidateQueries({queryKey:["agents"]}),t.invalidateQueries({queryKey:["active-agents"]}),n!=null&&n.id&&t.invalidateQueries({queryKey:["agent",n.id]}),e({title:"Agent Started",description:`${(n==null?void 0:n.name)||"Agent"} is now running`})},onError:n=>{const s=n instanceof Error?n.message:"Failed to start agent";e({title:"Error Starting Agent",description:`${s}. Please try again.`,variant:"destructive"})}})}function b8(){const t=er(),{toast:e}=tr();return zu({mutationFn:n=>kt.stopAgent(n),onMutate:async n=>{const s=t.getQueryData(["agent",n]);s&&e({title:"Stopping Agent",description:`Stopping ${s.name}...`})},onSuccess:(n,s)=>{t.invalidateQueries({queryKey:["agents"]}),t.invalidateQueries({queryKey:["agent",s]}),e({title:"Agent Stopped",description:"The agent has been successfully stopped"})},onError:(n,s)=>{t.invalidateQueries({queryKey:["agents"]}),t.invalidateQueries({queryKey:["agent",s]}),e({title:"Error",description:n instanceof Error?n.message:"Failed to stop agent",variant:"destructive"})}})}function x8(t,e){const n=er(),s=Za.getWorldId(),[i,l]=E.useState(null),[c,f]=E.useState(!0),[d,h]=E.useState(!1);return{...da({queryKey:["messages",t,e,s],queryFn:async()=>(await kt.getMemories(t,e)).data.memories.map(v=>{const g={text:v.content.text,roomId:v.roomId,user:v.entityId===t?"agent":as,name:v.entityId===t?"agent":as,createdAt:v.createdAt||0,attachments:v.content.attachments,source:v.content.source,worldId:s,id:v.id};return v.content&&Object.keys(v.content).forEach(x=>{!g[x]&&v.content[x]!==void 0&&(g[x]=v.content[x])}),g}).sort((v,g)=>v.createdAt===void 0||g.createdAt===void 0?0:v.createdAt-g.createdAt),enabled:!!(t&&e),staleTime:Qn.FREQUENT}),loadOlderMessages:async()=>{if(!i||!c||d)return!1;try{h(!0);const m=await kt.getMemories(t,e,{before:i,limit:20});if(m!=null&&m.memories&&m.memories.length>0){const v=m.memories.map(T=>T.createdAt??0),g=Math.min(...v);l(g);const x=n.getQueryData(["messages",t,e,s])||[],w=new Map;x.forEach(T=>{w.set(T.id,T)}),m.memories.forEach(T=>{const A={text:T.content.text,roomId:T.roomId,user:T.entityId===t?"agent":as,name:T.entityId===t?"agent":as,createdAt:T.createdAt||0,attachments:T.content.attachments,source:T.content.source,worldId:s,id:T.id};T.content&&Object.keys(T.content).forEach(R=>{!A[R]&&T.content[R]!==void 0&&(A[R]=T.content[R])}),w.set(T.id,A)});const C=Array.from(w.values());return C.sort((T,A)=>(T.createdAt??0)-(A.createdAt??0)),n.setQueryData(["messages",t,e,s],C),f(m.memories.length>=20),!0}return f(!1),!1}catch(m){return console.error("Error loading older messages:",m),!1}finally{h(!1)}},hasOlderMessages:c,isLoadingMore:d}}function w8(t,e){return da({queryKey:["agentActions",t,e],queryFn:async()=>(await kt.getAgentLogs(t,{roomId:e,count:50})).data||[],refetchInterval:1e3,staleTime:1e3})}function S8(){const t=er(),{toast:e}=tr();return zu({mutationFn:({agentId:n,logId:s})=>kt.deleteLog(n,s),onMutate:async({agentId:n,logId:s})=>{const i=t.getQueryData(["agentActions",n]);return i&&t.setQueryData(["agentActions",n],l=>l.filter(c=>c.id!==s)),{previousLogs:i,agentId:n,logId:s}},onSuccess:(n,{agentId:s})=>{t.invalidateQueries({queryKey:["agentActions",s]}),e({title:"Log Deleted",description:"The log entry has been successfully removed"})},onError:(n,{agentId:s},i)=>{i!=null&&i.previousLogs&&t.setQueryData(["agentActions",s],i.previousLogs),e({title:"Error",description:n instanceof Error?n.message:"Failed to delete log",variant:"destructive"}),t.invalidateQueries({queryKey:["agentActions",s]})}})}const _8="1.0.0-alpha.62",uo={version:_8},E8="modulepreload",C8=function(t){return"/"+t},Xw={},T8=function(e,n,s){let i=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),f=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));i=Promise.allSettled(n.map(d=>{if(d=C8(d),d in Xw)return;Xw[d]=!0;const h=d.endsWith(".css"),p=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${p}`))return;const b=document.createElement("link");if(b.rel=h?"stylesheet":E8,h||(b.as="script"),b.crossOrigin="",b.href=d,f&&b.setAttribute("nonce",f),document.head.appendChild(b),h)return new Promise((m,v)=>{b.addEventListener("load",m),b.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${d}`)))})}))}function l(c){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=c,window.dispatchEvent(f),!f.defaultPrevented)throw c}return i.then(c=>{for(const f of c||[])f.status==="rejected"&&l(f.reason);return e().catch(l)})};var mf={exports:{}},gf={exports:{}},qn={},Xt={},Jw;function tn(){if(Jw)return Xt;Jw=1,Xt.__esModule=!0,Xt.extend=i,Xt.indexOf=d,Xt.escapeExpression=h,Xt.isEmpty=p,Xt.createFrame=b,Xt.blockParams=m,Xt.appendContextPath=v;var t={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`","=":"="},e=/[&<>"'`=]/g,n=/[&<>"'`=]/;function s(g){return t[g]}function i(g){for(var x=1;x<arguments.length;x++)for(var w in arguments[x])Object.prototype.hasOwnProperty.call(arguments[x],w)&&(g[w]=arguments[x][w]);return g}var l=Object.prototype.toString;Xt.toString=l;var c=function(x){return typeof x=="function"};c(/x/)&&(Xt.isFunction=c=function(g){return typeof g=="function"&&l.call(g)==="[object Function]"}),Xt.isFunction=c;var f=Array.isArray||function(g){return g&&typeof g=="object"?l.call(g)==="[object Array]":!1};Xt.isArray=f;function d(g,x){for(var w=0,C=g.length;w<C;w++)if(g[w]===x)return w;return-1}function h(g){if(typeof g!="string"){if(g&&g.toHTML)return g.toHTML();if(g==null)return"";if(!g)return g+"";g=""+g}return n.test(g)?g.replace(e,s):g}function p(g){return!g&&g!==0?!0:!!(f(g)&&g.length===0)}function b(g){var x=i({},g);return x._parent=g,x}function m(g,x){return g.path=x,g}function v(g,x){return(g?g+".":"")+x}return Xt}var vf={exports:{}},e2;function nr(){return e2||(e2=1,function(t,e){e.__esModule=!0;var n=["description","fileName","lineNumber","endLineNumber","message","name","number","stack"];function s(i,l){var c=l&&l.loc,f=void 0,d=void 0,h=void 0,p=void 0;c&&(f=c.start.line,d=c.end.line,h=c.start.column,p=c.end.column,i+=" - "+f+":"+h);for(var b=Error.prototype.constructor.call(this,i),m=0;m<n.length;m++)this[n[m]]=b[n[m]];Error.captureStackTrace&&Error.captureStackTrace(this,s);try{c&&(this.lineNumber=f,this.endLineNumber=d,Object.defineProperty?(Object.defineProperty(this,"column",{value:h,enumerable:!0}),Object.defineProperty(this,"endColumn",{value:p,enumerable:!0})):(this.column=h,this.endColumn=p))}catch{}}s.prototype=new Error,e.default=s,t.exports=e.default}(vf,vf.exports)),vf.exports}var Vl={},yf={exports:{}},t2;function R8(){return t2||(t2=1,function(t,e){e.__esModule=!0;var n=tn();e.default=function(s){s.registerHelper("blockHelperMissing",function(i,l){var c=l.inverse,f=l.fn;if(i===!0)return f(this);if(i===!1||i==null)return c(this);if(n.isArray(i))return i.length>0?(l.ids&&(l.ids=[l.name]),s.helpers.each(i,l)):c(this);if(l.data&&l.ids){var d=n.createFrame(l.data);d.contextPath=n.appendContextPath(l.data.contextPath,l.name),l={data:d}}return f(i,l)})},t.exports=e.default}(yf,yf.exports)),yf.exports}var bf={exports:{}},n2;function A8(){return n2||(n2=1,function(t,e){e.__esModule=!0;function n(c){return c&&c.__esModule?c:{default:c}}var s=tn(),i=nr(),l=n(i);e.default=function(c){c.registerHelper("each",function(f,d){if(!d)throw new l.default("Must pass iterator to #each");var h=d.fn,p=d.inverse,b=0,m="",v=void 0,g=void 0;d.data&&d.ids&&(g=s.appendContextPath(d.data.contextPath,d.ids[0])+"."),s.isFunction(f)&&(f=f.call(this)),d.data&&(v=s.createFrame(d.data));function x(R,k,j){v&&(v.key=R,v.index=k,v.first=k===0,v.last=!!j,g&&(v.contextPath=g+R)),m=m+h(f[R],{data:v,blockParams:s.blockParams([f[R],R],[g+R,null])})}if(f&&typeof f=="object")if(s.isArray(f))for(var w=f.length;b<w;b++)b in f&&x(b,b,b===f.length-1);else if(typeof Symbol=="function"&&f[Symbol.iterator]){for(var C=[],T=f[Symbol.iterator](),A=T.next();!A.done;A=T.next())C.push(A.value);f=C;for(var w=f.length;b<w;b++)x(b,b,b===f.length-1)}else(function(){var R=void 0;Object.keys(f).forEach(function(k){R!==void 0&&x(R,b-1),R=k,b++}),R!==void 0&&x(R,b-1,!0)})();return b===0&&(m=p(this)),m})},t.exports=e.default}(bf,bf.exports)),bf.exports}var xf={exports:{}},r2;function O8(){return r2||(r2=1,function(t,e){e.__esModule=!0;function n(l){return l&&l.__esModule?l:{default:l}}var s=nr(),i=n(s);e.default=function(l){l.registerHelper("helperMissing",function(){if(arguments.length!==1)throw new i.default('Missing helper: "'+arguments[arguments.length-1].name+'"')})},t.exports=e.default}(xf,xf.exports)),xf.exports}var wf={exports:{}},s2;function N8(){return s2||(s2=1,function(t,e){e.__esModule=!0;function n(c){return c&&c.__esModule?c:{default:c}}var s=tn(),i=nr(),l=n(i);e.default=function(c){c.registerHelper("if",function(f,d){if(arguments.length!=2)throw new l.default("#if requires exactly one argument");return s.isFunction(f)&&(f=f.call(this)),!d.hash.includeZero&&!f||s.isEmpty(f)?d.inverse(this):d.fn(this)}),c.registerHelper("unless",function(f,d){if(arguments.length!=2)throw new l.default("#unless requires exactly one argument");return c.helpers.if.call(this,f,{fn:d.inverse,inverse:d.fn,hash:d.hash})})},t.exports=e.default}(wf,wf.exports)),wf.exports}var Sf={exports:{}},a2;function k8(){return a2||(a2=1,function(t,e){e.__esModule=!0,e.default=function(n){n.registerHelper("log",function(){for(var s=[void 0],i=arguments[arguments.length-1],l=0;l<arguments.length-1;l++)s.push(arguments[l]);var c=1;i.hash.level!=null?c=i.hash.level:i.data&&i.data.level!=null&&(c=i.data.level),s[0]=c,n.log.apply(n,s)})},t.exports=e.default}(Sf,Sf.exports)),Sf.exports}var _f={exports:{}},i2;function M8(){return i2||(i2=1,function(t,e){e.__esModule=!0,e.default=function(n){n.registerHelper("lookup",function(s,i,l){return s&&l.lookupProperty(s,i)})},t.exports=e.default}(_f,_f.exports)),_f.exports}var Ef={exports:{}},o2;function L8(){return o2||(o2=1,function(t,e){e.__esModule=!0;function n(c){return c&&c.__esModule?c:{default:c}}var s=tn(),i=nr(),l=n(i);e.default=function(c){c.registerHelper("with",function(f,d){if(arguments.length!=2)throw new l.default("#with requires exactly one argument");s.isFunction(f)&&(f=f.call(this));var h=d.fn;if(s.isEmpty(f))return d.inverse(this);var p=d.data;return d.data&&d.ids&&(p=s.createFrame(d.data),p.contextPath=s.appendContextPath(d.data.contextPath,d.ids[0])),h(f,{data:p,blockParams:s.blockParams([f],[p&&p.contextPath])})})},t.exports=e.default}(Ef,Ef.exports)),Ef.exports}var l2;function MT(){if(l2)return Vl;l2=1,Vl.__esModule=!0,Vl.registerDefaultHelpers=x,Vl.moveHelperToHooks=w;function t(C){return C&&C.__esModule?C:{default:C}}var e=R8(),n=t(e),s=A8(),i=t(s),l=O8(),c=t(l),f=N8(),d=t(f),h=k8(),p=t(h),b=M8(),m=t(b),v=L8(),g=t(v);function x(C){n.default(C),i.default(C),c.default(C),d.default(C),p.default(C),m.default(C),g.default(C)}function w(C,T,A){C.helpers[T]&&(C.hooks[T]=C.helpers[T],A||delete C.helpers[T])}return Vl}var Cf={},Tf={exports:{}},u2;function D8(){return u2||(u2=1,function(t,e){e.__esModule=!0;var n=tn();e.default=function(s){s.registerDecorator("inline",function(i,l,c,f){var d=i;return l.partials||(l.partials={},d=function(h,p){var b=c.partials;c.partials=n.extend({},b,l.partials);var m=i(h,p);return c.partials=b,m}),l.partials[f.args[0]]=f.fn,d})},t.exports=e.default}(Tf,Tf.exports)),Tf.exports}var c2;function j8(){if(c2)return Cf;c2=1,Cf.__esModule=!0,Cf.registerDefaultDecorators=s;function t(i){return i&&i.__esModule?i:{default:i}}var e=D8(),n=t(e);function s(i){n.default(i)}return Cf}var Rf={exports:{}},f2;function LT(){return f2||(f2=1,function(t,e){e.__esModule=!0;var n=tn(),s={methodMap:["debug","info","warn","error"],level:"info",lookupLevel:function(l){if(typeof l=="string"){var c=n.indexOf(s.methodMap,l.toLowerCase());c>=0?l=c:l=parseInt(l,10)}return l},log:function(l){if(l=s.lookupLevel(l),typeof console<"u"&&s.lookupLevel(s.level)<=l){var c=s.methodMap[l];console[c]||(c="log");for(var f=arguments.length,d=Array(f>1?f-1:0),h=1;h<f;h++)d[h-1]=arguments[h];console[c].apply(console,d)}}};e.default=s,t.exports=e.default}(Rf,Rf.exports)),Rf.exports}var Qi={},Af={},d2;function P8(){if(d2)return Af;d2=1,Af.__esModule=!0,Af.createNewLookupObject=e;var t=tn();function e(){for(var n=arguments.length,s=Array(n),i=0;i<n;i++)s[i]=arguments[i];return t.extend.apply(void 0,[Object.create(null)].concat(s))}return Af}var h2;function DT(){if(h2)return Qi;h2=1,Qi.__esModule=!0,Qi.createProtoAccessControl=l,Qi.resultIsAllowed=c,Qi.resetLoggedProperties=h;function t(p){return p&&p.__esModule?p:{default:p}}var e=P8(),n=LT(),s=t(n),i=Object.create(null);function l(p){var b=Object.create(null);b.constructor=!1,b.__defineGetter__=!1,b.__defineSetter__=!1,b.__lookupGetter__=!1;var m=Object.create(null);return m.__proto__=!1,{properties:{whitelist:e.createNewLookupObject(m,p.allowedProtoProperties),defaultValue:p.allowProtoPropertiesByDefault},methods:{whitelist:e.createNewLookupObject(b,p.allowedProtoMethods),defaultValue:p.allowProtoMethodsByDefault}}}function c(p,b,m){return f(typeof p=="function"?b.methods:b.properties,m)}function f(p,b){return p.whitelist[b]!==void 0?p.whitelist[b]===!0:p.defaultValue!==void 0?p.defaultValue:(d(b),!1)}function d(p){i[p]!==!0&&(i[p]=!0,s.default.log("error",'Handlebars: Access has been denied to resolve the property "'+p+`" because it is not an "own property" of its parent.
|
|
300
300
|
You can add a runtime option to disable the check or this warning:
|
|
301
301
|
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details`))}function h(){Object.keys(i).forEach(function(p){delete i[p]})}return Qi}var p2;function Uy(){if(p2)return qn;p2=1,qn.__esModule=!0,qn.HandlebarsEnvironment=g;function t(w){return w&&w.__esModule?w:{default:w}}var e=tn(),n=nr(),s=t(n),i=MT(),l=j8(),c=LT(),f=t(c),d=DT(),h="4.7.8";qn.VERSION=h;var p=8;qn.COMPILER_REVISION=p;var b=7;qn.LAST_COMPATIBLE_COMPILER_REVISION=b;var m={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",3:"== 1.0.0-rc.4",4:"== 1.x.x",5:"== 2.0.0-alpha.x",6:">= 2.0.0-beta.1",7:">= 4.0.0 <4.3.0",8:">= 4.3.0"};qn.REVISION_CHANGES=m;var v="[object Object]";function g(w,C,T){this.helpers=w||{},this.partials=C||{},this.decorators=T||{},i.registerDefaultHelpers(this),l.registerDefaultDecorators(this)}g.prototype={constructor:g,logger:f.default,log:f.default.log,registerHelper:function(C,T){if(e.toString.call(C)===v){if(T)throw new s.default("Arg not supported with multiple helpers");e.extend(this.helpers,C)}else this.helpers[C]=T},unregisterHelper:function(C){delete this.helpers[C]},registerPartial:function(C,T){if(e.toString.call(C)===v)e.extend(this.partials,C);else{if(typeof T>"u")throw new s.default('Attempting to register a partial called "'+C+'" as undefined');this.partials[C]=T}},unregisterPartial:function(C){delete this.partials[C]},registerDecorator:function(C,T){if(e.toString.call(C)===v){if(T)throw new s.default("Arg not supported with multiple decorators");e.extend(this.decorators,C)}else this.decorators[C]=T},unregisterDecorator:function(C){delete this.decorators[C]},resetLoggedPropertyAccesses:function(){d.resetLoggedProperties()}};var x=f.default.log;return qn.log=x,qn.createFrame=e.createFrame,qn.logger=f.default,qn}var Of={exports:{}},m2;function I8(){return m2||(m2=1,function(t,e){e.__esModule=!0;function n(s){this.string=s}n.prototype.toString=n.prototype.toHTML=function(){return""+this.string},e.default=n,t.exports=e.default}(Of,Of.exports)),Of.exports}var Zr={},Nf={},g2;function B8(){if(g2)return Nf;g2=1,Nf.__esModule=!0,Nf.wrapHelper=t;function t(e,n){if(typeof e!="function")return e;var s=function(){var l=arguments[arguments.length-1];return arguments[arguments.length-1]=n(l),e.apply(this,arguments)};return s}return Nf}var v2;function z8(){if(v2)return Zr;v2=1,Zr.__esModule=!0,Zr.checkRevision=p,Zr.template=b,Zr.wrapProgram=m,Zr.resolvePartial=v,Zr.invokePartial=g,Zr.noop=x;function t(R){return R&&R.__esModule?R:{default:R}}function e(R){if(R&&R.__esModule)return R;var k={};if(R!=null)for(var j in R)Object.prototype.hasOwnProperty.call(R,j)&&(k[j]=R[j]);return k.default=R,k}var n=tn(),s=e(n),i=nr(),l=t(i),c=Uy(),f=MT(),d=B8(),h=DT();function p(R){var k=R&&R[0]||1,j=c.COMPILER_REVISION;if(!(k>=c.LAST_COMPATIBLE_COMPILER_REVISION&&k<=c.COMPILER_REVISION))if(k<c.LAST_COMPATIBLE_COMPILER_REVISION){var D=c.REVISION_CHANGES[j],F=c.REVISION_CHANGES[k];throw new l.default("Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version ("+D+") or downgrade your runtime to an older version ("+F+").")}else throw new l.default("Template was precompiled with a newer version of Handlebars than the current runtime. Please update your runtime to a newer version ("+R[1]+").")}function b(R,k){if(!k)throw new l.default("No environment passed to template");if(!R||!R.main)throw new l.default("Unknown template object: "+typeof R);R.main.decorator=R.main_d,k.VM.checkRevision(R.compiler);var j=R.compiler&&R.compiler[0]===7;function D(P,q,U){U.hash&&(q=s.extend({},q,U.hash),U.ids&&(U.ids[0]=!0)),P=k.VM.resolvePartial.call(this,P,q,U);var G=s.extend({},U,{hooks:this.hooks,protoAccessControl:this.protoAccessControl}),I=k.VM.invokePartial.call(this,P,q,G);if(I==null&&k.compile&&(U.partials[U.name]=k.compile(P,R.compilerOptions,k),I=U.partials[U.name](q,G)),I!=null){if(U.indent){for(var L=I.split(`
|
|
302
302
|
`),N=0,H=L.length;N<H&&!(!L[N]&&N+1===H);N++)L[N]=U.indent+L[N];I=L.join(`
|
|
@@ -330,6 +330,6 @@ Expecting `+q.join(", ")+", got '"+(this.terminals_[A]||A)+"'":U="Parse error on
|
|
|
330
330
|
*/var ZS;function b7(){return ZS||(ZS=1,function(t){(function(){var e="input is invalid type",n="finalize already called",s=typeof window=="object",i=s?window:{};i.JS_SHA1_NO_WINDOW&&(s=!1);var l=!s&&typeof self=="object",c=!i.JS_SHA1_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;c?i=U4:l&&(i=self);var f=!i.JS_SHA1_NO_COMMON_JS&&!0&&t.exports,d=!i.JS_SHA1_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",h="0123456789abcdef".split(""),p=[-2147483648,8388608,32768,128],b=[24,16,8,0],m=["hex","array","digest","arrayBuffer"],v=[],g=Array.isArray;(i.JS_SHA1_NO_NODE_JS||!g)&&(g=function(M){return Object.prototype.toString.call(M)==="[object Array]"});var x=ArrayBuffer.isView;d&&(i.JS_SHA1_NO_ARRAY_BUFFER_IS_VIEW||!x)&&(x=function(M){return typeof M=="object"&&M.buffer&&M.buffer.constructor===ArrayBuffer});var w=function(M){var P=typeof M;if(P==="string")return[M,!0];if(P!=="object"||M===null)throw new Error(e);if(d&&M.constructor===ArrayBuffer)return[new Uint8Array(M),!1];if(!g(M)&&!x(M))throw new Error(e);return[M,!1]},C=function(M){return function(P){return new j(!0).update(P)[M]()}},T=function(){var M=C("hex");c&&(M=A(M)),M.create=function(){return new j},M.update=function(U){return M.create().update(U)};for(var P=0;P<m.length;++P){var q=m[P];M[q]=C(q)}return M},A=function(M){var P=so,q=so.Buffer,U;q.from&&!i.JS_SHA1_NO_BUFFER_FROM?U=q.from:U=function(I){return new q(I)};var G=function(I){if(typeof I=="string")return P.createHash("sha1").update(I,"utf8").digest("hex");if(I==null)throw new Error(e);return I.constructor===ArrayBuffer&&(I=new Uint8Array(I)),g(I)||x(I)||I.constructor===q?P.createHash("sha1").update(U(I)).digest("hex"):M(I)};return G},R=function(M){return function(P,q){return new D(P,!0).update(q)[M]()}},k=function(){var M=R("hex");M.create=function(U){return new D(U)},M.update=function(U,G){return M.create(U).update(G)};for(var P=0;P<m.length;++P){var q=m[P];M[q]=R(q)}return M};function j(M){M?(v[0]=v[16]=v[1]=v[2]=v[3]=v[4]=v[5]=v[6]=v[7]=v[8]=v[9]=v[10]=v[11]=v[12]=v[13]=v[14]=v[15]=0,this.blocks=v):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.h0=1732584193,this.h1=4023233417,this.h2=2562383102,this.h3=271733878,this.h4=3285377520,this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}j.prototype.update=function(M){if(this.finalized)throw new Error(n);var P=w(M);M=P[0];for(var q=P[1],U,G=0,I,L=M.length||0,N=this.blocks;G<L;){if(this.hashed&&(this.hashed=!1,N[0]=this.block,this.block=N[16]=N[1]=N[2]=N[3]=N[4]=N[5]=N[6]=N[7]=N[8]=N[9]=N[10]=N[11]=N[12]=N[13]=N[14]=N[15]=0),q)for(I=this.start;G<L&&I<64;++G)U=M.charCodeAt(G),U<128?N[I>>>2]|=U<<b[I++&3]:U<2048?(N[I>>>2]|=(192|U>>>6)<<b[I++&3],N[I>>>2]|=(128|U&63)<<b[I++&3]):U<55296||U>=57344?(N[I>>>2]|=(224|U>>>12)<<b[I++&3],N[I>>>2]|=(128|U>>>6&63)<<b[I++&3],N[I>>>2]|=(128|U&63)<<b[I++&3]):(U=65536+((U&1023)<<10|M.charCodeAt(++G)&1023),N[I>>>2]|=(240|U>>>18)<<b[I++&3],N[I>>>2]|=(128|U>>>12&63)<<b[I++&3],N[I>>>2]|=(128|U>>>6&63)<<b[I++&3],N[I>>>2]|=(128|U&63)<<b[I++&3]);else for(I=this.start;G<L&&I<64;++G)N[I>>>2]|=M[G]<<b[I++&3];this.lastByteIndex=I,this.bytes+=I-this.start,I>=64?(this.block=N[16],this.start=I-64,this.hash(),this.hashed=!0):this.start=I}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this},j.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var M=this.blocks,P=this.lastByteIndex;M[16]=this.block,M[P>>>2]|=p[P&3],this.block=M[16],P>=56&&(this.hashed||this.hash(),M[0]=this.block,M[16]=M[1]=M[2]=M[3]=M[4]=M[5]=M[6]=M[7]=M[8]=M[9]=M[10]=M[11]=M[12]=M[13]=M[14]=M[15]=0),M[14]=this.hBytes<<3|this.bytes>>>29,M[15]=this.bytes<<3,this.hash()}},j.prototype.hash=function(){var M=this.h0,P=this.h1,q=this.h2,U=this.h3,G=this.h4,I,L,N,H=this.blocks;for(L=16;L<80;++L)N=H[L-3]^H[L-8]^H[L-14]^H[L-16],H[L]=N<<1|N>>>31;for(L=0;L<20;L+=5)I=P&q|~P&U,N=M<<5|M>>>27,G=N+I+G+1518500249+H[L]<<0,P=P<<30|P>>>2,I=M&P|~M&q,N=G<<5|G>>>27,U=N+I+U+1518500249+H[L+1]<<0,M=M<<30|M>>>2,I=G&M|~G&P,N=U<<5|U>>>27,q=N+I+q+1518500249+H[L+2]<<0,G=G<<30|G>>>2,I=U&G|~U&M,N=q<<5|q>>>27,P=N+I+P+1518500249+H[L+3]<<0,U=U<<30|U>>>2,I=q&U|~q&G,N=P<<5|P>>>27,M=N+I+M+1518500249+H[L+4]<<0,q=q<<30|q>>>2;for(;L<40;L+=5)I=P^q^U,N=M<<5|M>>>27,G=N+I+G+1859775393+H[L]<<0,P=P<<30|P>>>2,I=M^P^q,N=G<<5|G>>>27,U=N+I+U+1859775393+H[L+1]<<0,M=M<<30|M>>>2,I=G^M^P,N=U<<5|U>>>27,q=N+I+q+1859775393+H[L+2]<<0,G=G<<30|G>>>2,I=U^G^M,N=q<<5|q>>>27,P=N+I+P+1859775393+H[L+3]<<0,U=U<<30|U>>>2,I=q^U^G,N=P<<5|P>>>27,M=N+I+M+1859775393+H[L+4]<<0,q=q<<30|q>>>2;for(;L<60;L+=5)I=P&q|P&U|q&U,N=M<<5|M>>>27,G=N+I+G-1894007588+H[L]<<0,P=P<<30|P>>>2,I=M&P|M&q|P&q,N=G<<5|G>>>27,U=N+I+U-1894007588+H[L+1]<<0,M=M<<30|M>>>2,I=G&M|G&P|M&P,N=U<<5|U>>>27,q=N+I+q-1894007588+H[L+2]<<0,G=G<<30|G>>>2,I=U&G|U&M|G&M,N=q<<5|q>>>27,P=N+I+P-1894007588+H[L+3]<<0,U=U<<30|U>>>2,I=q&U|q&G|U&G,N=P<<5|P>>>27,M=N+I+M-1894007588+H[L+4]<<0,q=q<<30|q>>>2;for(;L<80;L+=5)I=P^q^U,N=M<<5|M>>>27,G=N+I+G-899497514+H[L]<<0,P=P<<30|P>>>2,I=M^P^q,N=G<<5|G>>>27,U=N+I+U-899497514+H[L+1]<<0,M=M<<30|M>>>2,I=G^M^P,N=U<<5|U>>>27,q=N+I+q-899497514+H[L+2]<<0,G=G<<30|G>>>2,I=U^G^M,N=q<<5|q>>>27,P=N+I+P-899497514+H[L+3]<<0,U=U<<30|U>>>2,I=q^U^G,N=P<<5|P>>>27,M=N+I+M-899497514+H[L+4]<<0,q=q<<30|q>>>2;this.h0=this.h0+M<<0,this.h1=this.h1+P<<0,this.h2=this.h2+q<<0,this.h3=this.h3+U<<0,this.h4=this.h4+G<<0},j.prototype.hex=function(){this.finalize();var M=this.h0,P=this.h1,q=this.h2,U=this.h3,G=this.h4;return h[M>>>28&15]+h[M>>>24&15]+h[M>>>20&15]+h[M>>>16&15]+h[M>>>12&15]+h[M>>>8&15]+h[M>>>4&15]+h[M&15]+h[P>>>28&15]+h[P>>>24&15]+h[P>>>20&15]+h[P>>>16&15]+h[P>>>12&15]+h[P>>>8&15]+h[P>>>4&15]+h[P&15]+h[q>>>28&15]+h[q>>>24&15]+h[q>>>20&15]+h[q>>>16&15]+h[q>>>12&15]+h[q>>>8&15]+h[q>>>4&15]+h[q&15]+h[U>>>28&15]+h[U>>>24&15]+h[U>>>20&15]+h[U>>>16&15]+h[U>>>12&15]+h[U>>>8&15]+h[U>>>4&15]+h[U&15]+h[G>>>28&15]+h[G>>>24&15]+h[G>>>20&15]+h[G>>>16&15]+h[G>>>12&15]+h[G>>>8&15]+h[G>>>4&15]+h[G&15]},j.prototype.toString=j.prototype.hex,j.prototype.digest=function(){this.finalize();var M=this.h0,P=this.h1,q=this.h2,U=this.h3,G=this.h4;return[M>>>24&255,M>>>16&255,M>>>8&255,M&255,P>>>24&255,P>>>16&255,P>>>8&255,P&255,q>>>24&255,q>>>16&255,q>>>8&255,q&255,U>>>24&255,U>>>16&255,U>>>8&255,U&255,G>>>24&255,G>>>16&255,G>>>8&255,G&255]},j.prototype.array=j.prototype.digest,j.prototype.arrayBuffer=function(){this.finalize();var M=new ArrayBuffer(20),P=new DataView(M);return P.setUint32(0,this.h0),P.setUint32(4,this.h1),P.setUint32(8,this.h2),P.setUint32(12,this.h3),P.setUint32(16,this.h4),M};function D(M,P){var q,U=w(M);if(M=U[0],U[1]){var G=[],I=M.length,L=0,N;for(q=0;q<I;++q)N=M.charCodeAt(q),N<128?G[L++]=N:N<2048?(G[L++]=192|N>>>6,G[L++]=128|N&63):N<55296||N>=57344?(G[L++]=224|N>>>12,G[L++]=128|N>>>6&63,G[L++]=128|N&63):(N=65536+((N&1023)<<10|M.charCodeAt(++q)&1023),G[L++]=240|N>>>18,G[L++]=128|N>>>12&63,G[L++]=128|N>>>6&63,G[L++]=128|N&63);M=G}M.length>64&&(M=new j(!0).update(M).array());var H=[],V=[];for(q=0;q<64;++q){var Q=M[q]||0;H[q]=92^Q,V[q]=54^Q}j.call(this,P),this.update(V),this.oKeyPad=H,this.inner=!0,this.sharedMemory=P}D.prototype=new j,D.prototype.finalize=function(){if(j.prototype.finalize.call(this),this.inner){this.inner=!1;var M=this.array();j.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(M),j.prototype.finalize.call(this)}};var F=T();F.sha1=F,F.sha1.hmac=k(),f?t.exports=F:i.sha1=F})()}(tv)),tv.exports}var x7=b7();const w7={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_SERVER_PORT:"3000"};var Gn={},S7=Object.create,nR=Object.defineProperty,_7=Object.getOwnPropertyDescriptor,rR=Object.getOwnPropertyNames,E7=Object.getPrototypeOf,C7=Object.prototype.hasOwnProperty,T7=(t,e)=>function(){return e||(0,t[rR(t)[0]])((e={exports:{}}).exports,e),e.exports},R7=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of rR(e))!C7.call(t,i)&&i!==n&&nR(t,i,{get:()=>e[i],enumerable:!(s=_7(e,i))||s.enumerable});return t},sR=(t,e,n)=>(n=t!=null?S7(E7(t)):{},R7(nR(n,"default",{value:t,enumerable:!0}),t)),aR=T7({"../../node_modules/dedent/dist/dedent.js"(t,e){function n(s){var i=void 0;typeof s=="string"?i=[s]:i=s.raw;for(var l="",c=0;c<i.length;c++)l+=i[c].replace(/\\\n[ \t]*/g,"").replace(/\\`/g,"`"),c<(arguments.length<=1?0:arguments.length-1)&&(l+=arguments.length<=c+1?void 0:arguments[c+1]);var f=l.split(`
|
|
331
331
|
`),d=null;return f.forEach(function(h){var p=h.match(/^(\s+)\S+/);if(p){var b=p[1].length;d?d=Math.min(d,b):d=b}}),d!==null&&(l=f.map(function(h){return h[0]===" "?h.slice(d):h}).join(`
|
|
332
332
|
`)),l=l.trim(),l.replace(/\\n/g,`
|
|
333
|
-
`)}typeof e<"u"&&(e.exports=n)}}),XS={TASK:"task"},iR=class{constructor(t){t&&(this.runtime=t)}static async start(t){throw new Error("Not implemented")}static async stop(t){throw new Error("Not implemented")}},Nn=(t=>(t.ACTIVE="active",t.INACTIVE="inactive",t))(Nn||{}),od=(t=>(t[t.ROOM_JOINING=1]="ROOM_JOINING",t[t.SEND_MESSAGE=2]="SEND_MESSAGE",t))(od||{});function A7(t){if(!t)return!1;const e=["YES","Y","TRUE","T","1","ON","ENABLE"],n=["NO","N","FALSE","F","0","OFF","DISABLE"],s=t.trim().toUpperCase();return e.includes(s)?!0:(n.includes(s),!1)}var O7=class{constructor(t){this.logs=[],this.maxLogs=1e3,this.stream=t}write(t){const e=typeof t=="string"?JSON.parse(t):t;if(e.time||(e.time=Date.now()),this.logs.push(e),this.logs.length>this.maxLogs&&this.logs.shift(),this.stream){const n=typeof t=="string"?t:JSON.stringify(t);this.stream.write(n)}}recentLogs(){return this.logs}},N7={fatal:60,error:50,warn:40,info:30,log:29,progress:28,success:27,debug:20,trace:10},k7=A7(Gn==null?void 0:Gn.LOG_JSON_FORMAT)||!1,M7=async()=>k7?void 0:(await T8(()=>import("./index-B87uCoX3.js").then(e=>e.i),[])).default({colorize:!0,translateTime:"yyyy-mm-dd HH:MM:ss",ignore:"pid,hostname"}),L7=(Gn==null?void 0:Gn.DEFAULT_LOG_LEVEL)||(Gn==null?void 0:Gn.LOG_LEVEL)||"info",oR={level:L7,customLevels:N7,hooks:{logMethod(t,e){const[n,...s]=t;if(typeof n=="object"){const l=s.map(c=>typeof c=="string"?c:JSON.stringify(c)).join(" ");e.apply(this,[n,l])}else{const i={},l=[n,...s].map(d=>d),c=l.filter(d=>typeof d=="string").join(" "),f=l.filter(d=>typeof d=="object");Object.assign(i,...f),e.apply(this,[i,c])}}}},zv=tR(oR);typeof process<"u"&&M7().then(t=>{const e=new O7(t);zv=tR(oR,e),zv[Symbol.for("pino-destination")]=e});var Et=zv,D7=(t,e)=>{if(e===t.agentId)return t.agentId;const n=`${e}:${t.agentId}`;return U7(n)},lR={},Wy=()=>typeof window<"u"&&typeof window.document<"u";function j7(t=process.cwd()){if(Wy())return null;let e=t;for(;e!==$s.parse(e).root;){const s=$s.join(e,".env");if($s.existsSync(s))return s;e=$s.dirname(e)}const n=$s.join($s.parse(e).root,".env");return $s.existsSync(n)?n:null}function P7(){if(Wy())return lR;const t=j7();p7.config(t?{path:t}:{}).error||Et.log(`Loaded .env file from: ${t}`);const n=typeof process<"u"?Gn:w7,s=I7(n);return typeof process<"u"&&Object.entries(s).forEach(([i,l])=>{Gn[`__namespaced_${i}`]=JSON.stringify(l)}),n}function I7(t){const e={};for(const[n,s]of Object.entries(t)){if(!s)continue;const[i,...l]=n.split(".");if(!i||l.length===0)continue;const c=l.join(".");e[i]=e[i]||{},e[i][c]=s}return e}Wy()||P7();var B7=ue.object({name:ue.string(),content:ue.object({text:ue.string(),action:ue.string().optional(),source:ue.string().optional(),url:ue.string().optional(),inReplyTo:ue.string().uuid().optional(),attachments:ue.array(ue.any()).optional()}).and(ue.record(ue.string(),ue.unknown()))}),z7=ue.object({name:ue.string(),description:ue.string(),actions:ue.array(ue.any()).optional(),providers:ue.array(ue.any()).optional(),evaluators:ue.array(ue.any()).optional(),services:ue.array(ue.any()).optional(),clients:ue.array(ue.any()).optional()});ue.object({id:ue.string().uuid().optional(),name:ue.string(),system:ue.string().optional(),templates:ue.record(ue.string()).optional(),bio:ue.union([ue.string(),ue.array(ue.string())]),messageExamples:ue.array(ue.array(B7)),postExamples:ue.array(ue.string()),topics:ue.array(ue.string()),adjectives:ue.array(ue.string()),knowledge:ue.array(ue.union([ue.string(),ue.object({path:ue.string(),shared:ue.boolean().optional()}),ue.object({directory:ue.string(),shared:ue.boolean().optional()})])).optional(),plugins:ue.union([ue.array(ue.string()),ue.array(z7)]),settings:ue.object({secrets:ue.record(ue.string()).optional(),voice:ue.object({model:ue.string().optional(),url:ue.string().optional()}).optional(),model:ue.string().optional(),modelConfig:ue.object({maxInputTokens:ue.number().optional(),maxOutputTokens:ue.number().optional(),temperature:ue.number().optional(),frequency_penalty:ue.number().optional(),presence_penalty:ue.number().optional()}).optional(),embeddingModel:ue.string().optional()}).optional(),style:ue.object({all:ue.array(ue.string()),chat:ue.array(ue.string()),post:ue.array(ue.string())})});sR(aR());sR(aR());var q7=ue.object({sourceEntityId:ue.string(),targetEntityId:ue.string(),tags:ue.array(ue.string()),metadata:ue.object({interactions:ue.number()}).optional()});ue.object({facts:ue.array(ue.object({claim:ue.string(),type:ue.string(),in_bio:ue.boolean(),already_known:ue.boolean()})),relationships:ue.array(q7)});var na;na=class extends iR{constructor(e){super(e),this.runtime=e,this.capabilityDescription="The agent is currently in a scenario testing environment. It can create rooms, send messages, and talk to other agents in a live interactive testing environment.",this.messageHandlers=new Map,this.worlds=new Map,this.activeActions=new Map,this.activeEvaluators=new Map,this.setupEventListeners()}setupEventListeners(){this.runtime.registerEvent("ACTION_STARTED",async e=>(this.activeActions.set(e.actionId,{actionId:e.actionId,actionName:e.actionName,startTime:Date.now(),completed:!1}),Promise.resolve())),this.runtime.registerEvent("ACTION_COMPLETED",async e=>{const n=this.activeActions.get(e.actionId);return n&&(n.completed=!0,n.error=e.error),Promise.resolve()}),this.runtime.registerEvent("EVALUATOR_STARTED",async e=>(this.activeEvaluators.set(e.evaluatorId,{evaluatorId:e.evaluatorId,evaluatorName:e.evaluatorName,startTime:Date.now(),completed:!1}),Et.debug("Evaluator started",e),Promise.resolve())),this.runtime.registerEvent("EVALUATOR_COMPLETED",async e=>{const n=this.activeEvaluators.get(e.evaluatorId);return n&&(n.completed=!0,n.error=e.error),Et.debug("Evaluator completed",e),Promise.resolve()})}static async start(e){return new na(e)}static async stop(e){const n=e.getService(na.serviceType);if(!n)throw new Error("Scenario service not found");n.stop()}async stop(){this.messageHandlers.clear(),this.worlds.clear(),this.activeActions.clear(),this.activeEvaluators.clear()}async createWorld(e,n){const s=D7(this.runtime.agentId,e),i=ev(),l=ev(),c={id:i,name:e,serverId:s,agentId:this.runtime.agentId,metadata:{owner:{id:l,name:n}}};return this.worlds.set(i,c),i}async createRoom(e,n){if(!this.worlds.get(e))throw new Error(`World ${e} not found`);const i=ev();return await this.runtime.ensureRoomExists({id:i,name:n,source:"scenario",type:"GROUP",channelId:i,serverId:e}),i}async addParticipant(e,n,s){if(!this.worlds.get(e))throw new Error(`World ${e} not found`);if(!this.runtime.getRoom(n))throw new Error(`Room ${n} not found in world ${e}`);await this.runtime.addParticipant(n,s)}async sendMessage(e,n,s,i){if(!this.worlds.get(n))throw new Error(`World ${n} not found`);const c={entityId:e.agentId,agentId:e.agentId,roomId:s,content:{text:i,source:"scenario",name:e.character.name,userName:e.character.name,channelType:"GROUP"}},f=await this.runtime.getParticipantsForRoom(s);for(const d of f)this.runtime.emitEvent("MESSAGE_RECEIVED",{runtime:this.runtime,message:c,roomId:s,entityId:d,source:"scenario",type:"GROUP"})}async waitForCompletion(e=3e4){const n=Date.now();for(;Date.now()-n<e;){const s=Array.from(this.activeActions.values()).every(l=>l.completed),i=Array.from(this.activeEvaluators.values()).every(l=>l.completed);if(s&&i)return!0;await new Promise(l=>setTimeout(l,100))}return!1}getActiveState(){return{actions:Array.from(this.activeActions.values()),evaluators:Array.from(this.activeEvaluators.values())}}async cleanup(){this.worlds.clear(),this.activeActions.clear(),this.activeEvaluators.clear(),this.messageHandlers.clear()}},na.serviceType="scenario";var Ja;Ja=class extends iR{constructor(){super(...arguments),this.timer=null,this.TICK_INTERVAL=1e3,this.capabilityDescription="The agent is able to schedule and execute tasks"}static async start(e){const n=new Ja(e);return await n.startTimer(),n}async createTestTasks(){this.runtime.registerTaskWorker({name:"REPEATING_TEST_TASK",validate:async(n,s,i)=>(Et.debug("Validating repeating test task"),!0),execute:async(n,s)=>{Et.debug("Executing repeating test task")}}),this.runtime.registerTaskWorker({name:"ONETIME_TEST_TASK",validate:async(n,s,i)=>(Et.debug("Validating one-time test task"),!0),execute:async(n,s)=>{Et.debug("Executing one-time test task")}}),(await this.runtime.getTasksByName("REPEATING_TEST_TASK")).length===0&&await this.runtime.createTask({name:"REPEATING_TEST_TASK",description:"A test task that repeats every minute",metadata:{updatedAt:Date.now(),updateInterval:1e3*60},tags:["queue","repeat","test"]}),await this.runtime.createTask({name:"ONETIME_TEST_TASK",description:"A test task that runs once",metadata:{updatedAt:Date.now()},tags:["queue","test"]})}startTimer(){this.timer&&clearInterval(this.timer),this.timer=setInterval(async()=>{try{await this.checkTasks()}catch(e){Et.error("Error checking tasks:",e)}},this.TICK_INTERVAL)}async validateTasks(e){const n=[];for(const s of e){if(!s.id)continue;const i=this.runtime.getTaskWorker(s.name);if(i){if(i.validate)try{if(!await i.validate(this.runtime,{},{}))continue}catch(l){Et.error(`Error validating task ${s.name}:`,l);continue}n.push(s)}}return n}async checkTasks(){var e,n,s;try{const i=await this.runtime.getTasks({tags:["queue"]}),l=await this.validateTasks(i);l.length>0&&Et.debug(`Found ${l.length} queued tasks`);const c=Date.now();for(const f of l){let d;typeof f.updatedAt=="number"?d=f.updatedAt:(e=f.metadata)!=null&&e.updatedAt&&typeof f.metadata.updatedAt=="number"?d=f.metadata.updatedAt:f.updatedAt?d=new Date(f.updatedAt).getTime():d=0;const h=((n=f.metadata)==null?void 0:n.updateInterval)??0;if(!((s=f.tags)!=null&&s.includes("repeat"))){await this.executeTask(f);continue}c-d>=h&&(Et.debug(`Executing task ${f.name} - interval of ${h}ms has elapsed`),await this.executeTask(f))}}catch(i){Et.error("Error checking tasks:",i)}}async executeTask(e){var n;try{if(!e){Et.debug(`Task ${e.id} not found`);return}const s=this.runtime.getTaskWorker(e.name);if(!s){Et.debug(`No worker found for task type: ${e.name}`);return}Et.debug(`Executing task ${e.name} (${e.id})`),await s.execute(this.runtime,e.metadata||{},e),Et.debug("task.tags are",e.tags),(n=e.tags)!=null&&n.includes("repeat")?(await this.runtime.updateTask(e.id,{metadata:{...e.metadata,updatedAt:Date.now()}}),Et.debug(`Updated repeating task ${e.name} (${e.id}) with new timestamp`)):(await this.runtime.deleteTask(e.id),Et.debug(`Deleted non-repeating task ${e.name} (${e.id}) after execution`))}catch(s){Et.error(`Error executing task ${e.id}:`,s)}}static async stop(e){const n=e.getService(XS.TASK);n&&await n.stop()}async stop(){this.timer&&(clearInterval(this.timer),this.timer=null)}},Ja.serviceType=XS.TASK;ue.string().uuid();function U7(t){if(typeof t=="number"&&(t=t.toString()),typeof t!="string")throw TypeError("Value must be string");const e=f=>{const d=f>>4,h=f-(d<<4),p="0123456789abcdef".split("");return p[d]+p[h]},n=f=>{let d="";for(let h=0;h<f.length;h++)d+=e(f[h]);return d},s=encodeURIComponent(t),i=new Uint8Array(s.length);for(let f=0;f<s.length;f++)i[f]=s[f].charCodeAt(0);const l=x7.sha1(i),c=new Uint8Array(l.length/2);for(let f=0;f<l.length;f+=2)c[f/2]=Number.parseInt(l.slice(f,f+2),16);return`${n(c.slice(0,4))}-${n(c.slice(4,6))}-${e(c[6]&15)}${e(c[7])}-${e(c[8]&63|128)}${e(c[9])}-${n(c.slice(10,16))}`}function H7(){const[t,e]=E.useState(null),[n,s]=E.useState(!0),[i,l]=E.useState(typeof navigator<"u"?navigator.onLine:!0),[c,f]=E.useState(!1),d=er(),[h,p]=E.useState(Date.now()),b=E.useRef(0),m=E.useRef(Date.now());E.useEffect(()=>{const j=()=>{s(document.visibilityState==="visible"),document.visibilityState==="visible"&&(b.current=0,Date.now()-h>1e4&&d.invalidateQueries({queryKey:["status"]}))},D=()=>{l(navigator.onLine),navigator.onLine&&(b.current=0,d.invalidateQueries({queryKey:["status"]}))};return document.addEventListener("visibilitychange",j),window.addEventListener("online",D),window.addEventListener("offline",D),s(document.visibilityState==="visible"),()=>{document.removeEventListener("visibilitychange",j),window.removeEventListener("online",D),window.removeEventListener("offline",D)}},[d,h]);const g=da({queryKey:["status"],queryFn:async()=>{try{const j=performance.now(),D=await kt.getAgents(),F=performance.now();return b.current=0,m.current=Date.now(),e(F-j),p(Date.now()),D}catch(j){throw b.current+=1,console.error("Connection check failed:",j),j}},refetchInterval:i?b.current>0?Math.min(5e3*2**(b.current-1),6e4):n?3e3:15e3:!1,retry:3,retryDelay:j=>Math.min(1e3*1.5**j,1e4),refetchOnWindowFocus:!0,refetchOnReconnect:!0,staleTime:500,gcTime:Qn.STANDARD}),x=(g==null?void 0:g.isSuccess)&&!(g!=null&&g.isError),w=(g==null?void 0:g.isRefetching)||(g==null?void 0:g.isPending),C=x===!1&&b.current>5&&Date.now()-m.current>6e4,T=()=>i?C?"bg-yellow-600":w?"bg-muted-foreground":x?"bg-green-600":"bg-red-600":"bg-orange-600",A=()=>i?C?"Reconnecting...":w?"Connecting...":x?"Connected":"Disconnected":"Offline",R=()=>i?C?"text-yellow-600":w?"text-muted-foreground":x?"text-green-600":"text-red-600":"text-orange-600",k=()=>{b.current=0,d.invalidateQueries({queryKey:["agents"]}),d.invalidateQueries({queryKey:["status"]})};return S.jsx(ts,{children:S.jsxs(ls,{children:[S.jsx(us,{asChild:!0,children:S.jsx(Ua,{onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),onClick:k,children:S.jsx("div",{className:"flex flex-col gap-1 select-none transition-all duration-200",children:S.jsxs("div",{className:"flex items-center gap-1",children:[c?S.jsx(PM,{className:"h-3.5 w-3.5 text-muted-foreground animate-pulse"}):S.jsx("div",{className:fe(["h-2.5 w-2.5 rounded-full",T()])}),S.jsx("span",{className:fe(["text-xs",c?"text-muted-foreground":R()]),children:c?"Refresh":A()})]})})})}),x&&!c?S.jsx(br,{side:"top",children:S.jsxs("div",{className:"flex items-center gap-1",children:[S.jsx(TE,{className:"size-4"}),S.jsxs("span",{children:[t==null?void 0:t.toFixed(2)," ms"]})]})}):null]})})}function F7(){const t=ha(),{data:{data:e}={},isPending:n}=qy();return S.jsxs(dC,{className:"bg-background",children:[S.jsx(pC,{children:S.jsx(ed,{children:S.jsx(ts,{children:S.jsx(Ua,{size:"lg",asChild:!0,children:S.jsx(no,{to:"/",className:"px-6 py-2 h-full",children:S.jsxs("div",{className:"flex flex-col pt-2 gap-1 items-start justify-center",children:[S.jsx("img",{alt:"elizaos-logo",src:"/elizaos-logo-light.png",width:"90%"}),S.jsxs("span",{className:"text-xs font-mono text-muted-foreground text-center",children:["v",uo==null?void 0:uo.version]})]})})})})})}),S.jsx(gC,{children:S.jsx(vC,{children:S.jsx(yC,{className:"px-2",children:S.jsx(ed,{children:n?S.jsx("div",{children:Array.from({length:5}).map((s,i)=>S.jsx(ts,{children:S.jsx(bC,{})},`skeleton-item-${i}`))}):S.jsx("div",{children:(()=>{const s=[...(e==null?void 0:e.agents)||[]].sort((c,f)=>c.status===Nn.ACTIVE&&f.status!==Nn.ACTIVE?-1:c.status!==Nn.ACTIVE&&f.status===Nn.ACTIVE?1:c.name.localeCompare(f.name)),i=s.filter(c=>c.status===Nn.ACTIVE),l=s.filter(c=>c.status===Nn.INACTIVE);return S.jsxs(S.Fragment,{children:[i.length>0&&S.jsx("div",{className:"px-4 py-1",children:S.jsx("div",{className:"flex items-center space-x-2",children:S.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Online"})})}),i.map(c=>{var f,d;return S.jsx(ts,{children:S.jsx(no,{to:`/chat/${c.id}`,children:S.jsx(Ua,{isActive:t.pathname.includes(c.id),className:"transition-colors px-4 my-4 rounded-md",children:S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("div",{className:"w-8 h-8 flex justify-center items-center",children:S.jsx("div",{className:"relative bg-muted rounded-full w-full h-full",children:c&&S.jsxs("div",{className:"text-sm rounded-full h-full w-full flex justify-center items-center overflow-hidden",children:[(f=c.settings)!=null&&f.avatar?S.jsx("img",{src:(d=c.settings)==null?void 0:d.avatar,alt:"Agent Avatar",className:"w-full h-full object-contain"}):dd(c.name),S.jsx("div",{className:"absolute bottom-0 right-0 w-[10px] h-[10px] rounded-full border-[1px] border-white bg-green-500"})]})})}),S.jsx("span",{className:"text-base",children:c.name})]})})})},c.id)}),l.length>0&&S.jsx("div",{className:"px-4 py-1 mt-8",children:S.jsx("div",{className:"flex items-center space-x-2",children:S.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Offline"})})}),l.map(c=>{var f;return S.jsx(ts,{children:S.jsx("div",{className:"transition-colors px-4 my-4 rounded-md",children:S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("div",{className:"w-8 h-8 flex justify-center items-center",children:S.jsx("div",{className:"relative bg-muted rounded-full w-full h-full",children:c&&S.jsxs("div",{className:"text-sm rounded-full h-full w-full flex justify-center items-center overflow-hidden",children:[(f=c.settings)!=null&&f.avatar?S.jsx("img",{src:c.settings.avatar,alt:"Agent Avatar",className:"w-full h-full object-contain"}):dd(c.name),S.jsx("div",{className:"absolute bottom-0 right-0 w-[10px] h-[10px] rounded-full border-[1px] border-white bg-muted-foreground"})]})})}),S.jsx("span",{className:"text-base truncate max-w-24",children:c.name})]})})},c.id)})]})})()})})})})}),S.jsx(mC,{className:"px-4 py-4",children:S.jsxs(ed,{children:[S.jsx(ts,{children:S.jsx(no,{to:"https://elizaos.github.io/eliza/docs/intro/",target:"_blank",children:S.jsxs(Ua,{className:"text-muted-foreground rounded-md",children:[S.jsx(yM,{className:"size-5"}),S.jsx("span",{children:"Documentation"})]})})}),S.jsx(ts,{children:S.jsx(no,{to:"/logs",children:S.jsxs(Ua,{className:"text-muted-foreground rounded-md",children:[S.jsx(NE,{className:"size-5"}),S.jsx("span",{children:"Logs"})]})})}),S.jsx(ts,{children:S.jsxs(Ua,{disabled:!0,className:"text-muted-foreground/50 rounded-md",children:[S.jsx(py,{className:"size-5"}),S.jsx("span",{children:"Settings"})]})}),S.jsx(H7,{})]})})]})}const uR=6048e5,V7=864e5,JS=Symbol.for("constructDateFrom");function ca(t,e){return typeof t=="function"?t(e):t&&typeof t=="object"&&JS in t?t[JS](e):t instanceof Date?new t.constructor(e):new Date(e)}function ar(t,e){return ca(e||t,t)}let $7={};function oh(){return $7}function Au(t,e){var f,d,h,p;const n=oh(),s=(e==null?void 0:e.weekStartsOn)??((d=(f=e==null?void 0:e.locale)==null?void 0:f.options)==null?void 0:d.weekStartsOn)??n.weekStartsOn??((p=(h=n.locale)==null?void 0:h.options)==null?void 0:p.weekStartsOn)??0,i=ar(t,e==null?void 0:e.in),l=i.getDay(),c=(l<s?7:0)+l-s;return i.setDate(i.getDate()-c),i.setHours(0,0,0,0),i}function Ld(t,e){return Au(t,{...e,weekStartsOn:1})}function cR(t,e){const n=ar(t,e==null?void 0:e.in),s=n.getFullYear(),i=ca(n,0);i.setFullYear(s+1,0,4),i.setHours(0,0,0,0);const l=Ld(i),c=ca(n,0);c.setFullYear(s,0,4),c.setHours(0,0,0,0);const f=Ld(c);return n.getTime()>=l.getTime()?s+1:n.getTime()>=f.getTime()?s:s-1}function e_(t){const e=ar(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function G7(t,...e){const n=ca.bind(null,e.find(s=>typeof s=="object"));return e.map(n)}function t_(t,e){const n=ar(t,e==null?void 0:e.in);return n.setHours(0,0,0,0),n}function Y7(t,e,n){const[s,i]=G7(n==null?void 0:n.in,t,e),l=t_(s),c=t_(i),f=+l-e_(l),d=+c-e_(c);return Math.round((f-d)/V7)}function Q7(t,e){const n=cR(t,e),s=ca(t,0);return s.setFullYear(n,0,4),s.setHours(0,0,0,0),Ld(s)}function W7(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function K7(t){return!(!W7(t)&&typeof t!="number"||isNaN(+ar(t)))}function Z7(t,e){const n=ar(t,e==null?void 0:e.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}const X7={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},J7=(t,e,n)=>{let s;const i=X7[t];return typeof i=="string"?s=i:e===1?s=i.one:s=i.other.replace("{{count}}",e.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+s:s+" ago":s};function nv(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const e9={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},t9={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},n9={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},r9={date:nv({formats:e9,defaultWidth:"full"}),time:nv({formats:t9,defaultWidth:"full"}),dateTime:nv({formats:n9,defaultWidth:"full"})},s9={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},a9=(t,e,n,s)=>s9[t];function Zl(t){return(e,n)=>{const s=n!=null&&n.context?String(n.context):"standalone";let i;if(s==="formatting"&&t.formattingValues){const c=t.defaultFormattingWidth||t.defaultWidth,f=n!=null&&n.width?String(n.width):c;i=t.formattingValues[f]||t.formattingValues[c]}else{const c=t.defaultWidth,f=n!=null&&n.width?String(n.width):t.defaultWidth;i=t.values[f]||t.values[c]}const l=t.argumentCallback?t.argumentCallback(e):e;return i[l]}}const i9={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},o9={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},l9={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},u9={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},c9={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},f9={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},d9=(t,e)=>{const n=Number(t),s=n%100;if(s>20||s<10)switch(s%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},h9={ordinalNumber:d9,era:Zl({values:i9,defaultWidth:"wide"}),quarter:Zl({values:o9,defaultWidth:"wide",argumentCallback:t=>t-1}),month:Zl({values:l9,defaultWidth:"wide"}),day:Zl({values:u9,defaultWidth:"wide"}),dayPeriod:Zl({values:c9,defaultWidth:"wide",formattingValues:f9,defaultFormattingWidth:"wide"})};function Xl(t){return(e,n={})=>{const s=n.width,i=s&&t.matchPatterns[s]||t.matchPatterns[t.defaultMatchWidth],l=e.match(i);if(!l)return null;const c=l[0],f=s&&t.parsePatterns[s]||t.parsePatterns[t.defaultParseWidth],d=Array.isArray(f)?m9(f,b=>b.test(c)):p9(f,b=>b.test(c));let h;h=t.valueCallback?t.valueCallback(d):d,h=n.valueCallback?n.valueCallback(h):h;const p=e.slice(c.length);return{value:h,rest:p}}}function p9(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function m9(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n}function g9(t){return(e,n={})=>{const s=e.match(t.matchPattern);if(!s)return null;const i=s[0],l=e.match(t.parsePattern);if(!l)return null;let c=t.valueCallback?t.valueCallback(l[0]):l[0];c=n.valueCallback?n.valueCallback(c):c;const f=e.slice(i.length);return{value:c,rest:f}}}const v9=/^(\d+)(th|st|nd|rd)?/i,y9=/\d+/i,b9={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},x9={any:[/^b/i,/^(a|c)/i]},w9={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},S9={any:[/1/i,/2/i,/3/i,/4/i]},_9={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},E9={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},C9={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},T9={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},R9={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},A9={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},O9={ordinalNumber:g9({matchPattern:v9,parsePattern:y9,valueCallback:t=>parseInt(t,10)}),era:Xl({matchPatterns:b9,defaultMatchWidth:"wide",parsePatterns:x9,defaultParseWidth:"any"}),quarter:Xl({matchPatterns:w9,defaultMatchWidth:"wide",parsePatterns:S9,defaultParseWidth:"any",valueCallback:t=>t+1}),month:Xl({matchPatterns:_9,defaultMatchWidth:"wide",parsePatterns:E9,defaultParseWidth:"any"}),day:Xl({matchPatterns:C9,defaultMatchWidth:"wide",parsePatterns:T9,defaultParseWidth:"any"}),dayPeriod:Xl({matchPatterns:R9,defaultMatchWidth:"any",parsePatterns:A9,defaultParseWidth:"any"})},N9={code:"en-US",formatDistance:J7,formatLong:r9,formatRelative:a9,localize:h9,match:O9,options:{weekStartsOn:0,firstWeekContainsDate:1}};function k9(t,e){const n=ar(t,e==null?void 0:e.in);return Y7(n,Z7(n))+1}function M9(t,e){const n=ar(t,e==null?void 0:e.in),s=+Ld(n)-+Q7(n);return Math.round(s/uR)+1}function fR(t,e){var p,b,m,v;const n=ar(t,e==null?void 0:e.in),s=n.getFullYear(),i=oh(),l=(e==null?void 0:e.firstWeekContainsDate)??((b=(p=e==null?void 0:e.locale)==null?void 0:p.options)==null?void 0:b.firstWeekContainsDate)??i.firstWeekContainsDate??((v=(m=i.locale)==null?void 0:m.options)==null?void 0:v.firstWeekContainsDate)??1,c=ca((e==null?void 0:e.in)||t,0);c.setFullYear(s+1,0,l),c.setHours(0,0,0,0);const f=Au(c,e),d=ca((e==null?void 0:e.in)||t,0);d.setFullYear(s,0,l),d.setHours(0,0,0,0);const h=Au(d,e);return+n>=+f?s+1:+n>=+h?s:s-1}function L9(t,e){var f,d,h,p;const n=oh(),s=(e==null?void 0:e.firstWeekContainsDate)??((d=(f=e==null?void 0:e.locale)==null?void 0:f.options)==null?void 0:d.firstWeekContainsDate)??n.firstWeekContainsDate??((p=(h=n.locale)==null?void 0:h.options)==null?void 0:p.firstWeekContainsDate)??1,i=fR(t,e),l=ca((e==null?void 0:e.in)||t,0);return l.setFullYear(i,0,s),l.setHours(0,0,0,0),Au(l,e)}function D9(t,e){const n=ar(t,e==null?void 0:e.in),s=+Au(n,e)-+L9(n,e);return Math.round(s/uR)+1}function Je(t,e){const n=t<0?"-":"",s=Math.abs(t).toString().padStart(e,"0");return n+s}const Hs={y(t,e){const n=t.getFullYear(),s=n>0?n:1-n;return Je(e==="yy"?s%100:s,e.length)},M(t,e){const n=t.getMonth();return e==="M"?String(n+1):Je(n+1,2)},d(t,e){return Je(t.getDate(),e.length)},a(t,e){const n=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(t,e){return Je(t.getHours()%12||12,e.length)},H(t,e){return Je(t.getHours(),e.length)},m(t,e){return Je(t.getMinutes(),e.length)},s(t,e){return Je(t.getSeconds(),e.length)},S(t,e){const n=e.length,s=t.getMilliseconds(),i=Math.trunc(s*Math.pow(10,n-3));return Je(i,e.length)}},Zi={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},n_={G:function(t,e,n){const s=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(s,{width:"abbreviated"});case"GGGGG":return n.era(s,{width:"narrow"});case"GGGG":default:return n.era(s,{width:"wide"})}},y:function(t,e,n){if(e==="yo"){const s=t.getFullYear(),i=s>0?s:1-s;return n.ordinalNumber(i,{unit:"year"})}return Hs.y(t,e)},Y:function(t,e,n,s){const i=fR(t,s),l=i>0?i:1-i;if(e==="YY"){const c=l%100;return Je(c,2)}return e==="Yo"?n.ordinalNumber(l,{unit:"year"}):Je(l,e.length)},R:function(t,e){const n=cR(t);return Je(n,e.length)},u:function(t,e){const n=t.getFullYear();return Je(n,e.length)},Q:function(t,e,n){const s=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(s);case"QQ":return Je(s,2);case"Qo":return n.ordinalNumber(s,{unit:"quarter"});case"QQQ":return n.quarter(s,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(s,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(s,{width:"wide",context:"formatting"})}},q:function(t,e,n){const s=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(s);case"qq":return Je(s,2);case"qo":return n.ordinalNumber(s,{unit:"quarter"});case"qqq":return n.quarter(s,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(s,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(s,{width:"wide",context:"standalone"})}},M:function(t,e,n){const s=t.getMonth();switch(e){case"M":case"MM":return Hs.M(t,e);case"Mo":return n.ordinalNumber(s+1,{unit:"month"});case"MMM":return n.month(s,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(s,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(s,{width:"wide",context:"formatting"})}},L:function(t,e,n){const s=t.getMonth();switch(e){case"L":return String(s+1);case"LL":return Je(s+1,2);case"Lo":return n.ordinalNumber(s+1,{unit:"month"});case"LLL":return n.month(s,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(s,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(s,{width:"wide",context:"standalone"})}},w:function(t,e,n,s){const i=D9(t,s);return e==="wo"?n.ordinalNumber(i,{unit:"week"}):Je(i,e.length)},I:function(t,e,n){const s=M9(t);return e==="Io"?n.ordinalNumber(s,{unit:"week"}):Je(s,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):Hs.d(t,e)},D:function(t,e,n){const s=k9(t);return e==="Do"?n.ordinalNumber(s,{unit:"dayOfYear"}):Je(s,e.length)},E:function(t,e,n){const s=t.getDay();switch(e){case"E":case"EE":case"EEE":return n.day(s,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(s,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(s,{width:"short",context:"formatting"});case"EEEE":default:return n.day(s,{width:"wide",context:"formatting"})}},e:function(t,e,n,s){const i=t.getDay(),l=(i-s.weekStartsOn+8)%7||7;switch(e){case"e":return String(l);case"ee":return Je(l,2);case"eo":return n.ordinalNumber(l,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});case"eeee":default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(t,e,n,s){const i=t.getDay(),l=(i-s.weekStartsOn+8)%7||7;switch(e){case"c":return String(l);case"cc":return Je(l,e.length);case"co":return n.ordinalNumber(l,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});case"cccc":default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(t,e,n){const s=t.getDay(),i=s===0?7:s;switch(e){case"i":return String(i);case"ii":return Je(i,e.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(s,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(s,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(s,{width:"short",context:"formatting"});case"iiii":default:return n.day(s,{width:"wide",context:"formatting"})}},a:function(t,e,n){const i=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(t,e,n){const s=t.getHours();let i;switch(s===12?i=Zi.noon:s===0?i=Zi.midnight:i=s/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},B:function(t,e,n){const s=t.getHours();let i;switch(s>=17?i=Zi.evening:s>=12?i=Zi.afternoon:s>=4?i=Zi.morning:i=Zi.night,e){case"B":case"BB":case"BBB":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},h:function(t,e,n){if(e==="ho"){let s=t.getHours()%12;return s===0&&(s=12),n.ordinalNumber(s,{unit:"hour"})}return Hs.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):Hs.H(t,e)},K:function(t,e,n){const s=t.getHours()%12;return e==="Ko"?n.ordinalNumber(s,{unit:"hour"}):Je(s,e.length)},k:function(t,e,n){let s=t.getHours();return s===0&&(s=24),e==="ko"?n.ordinalNumber(s,{unit:"hour"}):Je(s,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):Hs.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):Hs.s(t,e)},S:function(t,e){return Hs.S(t,e)},X:function(t,e,n){const s=t.getTimezoneOffset();if(s===0)return"Z";switch(e){case"X":return s_(s);case"XXXX":case"XX":return qa(s);case"XXXXX":case"XXX":default:return qa(s,":")}},x:function(t,e,n){const s=t.getTimezoneOffset();switch(e){case"x":return s_(s);case"xxxx":case"xx":return qa(s);case"xxxxx":case"xxx":default:return qa(s,":")}},O:function(t,e,n){const s=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+r_(s,":");case"OOOO":default:return"GMT"+qa(s,":")}},z:function(t,e,n){const s=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+r_(s,":");case"zzzz":default:return"GMT"+qa(s,":")}},t:function(t,e,n){const s=Math.trunc(+t/1e3);return Je(s,e.length)},T:function(t,e,n){return Je(+t,e.length)}};function r_(t,e=""){const n=t>0?"-":"+",s=Math.abs(t),i=Math.trunc(s/60),l=s%60;return l===0?n+String(i):n+String(i)+e+Je(l,2)}function s_(t,e){return t%60===0?(t>0?"-":"+")+Je(Math.abs(t)/60,2):qa(t,e)}function qa(t,e=""){const n=t>0?"-":"+",s=Math.abs(t),i=Je(Math.trunc(s/60),2),l=Je(s%60,2);return n+i+e+l}const a_=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},dR=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},j9=(t,e)=>{const n=t.match(/(P+)(p+)?/)||[],s=n[1],i=n[2];if(!i)return a_(t,e);let l;switch(s){case"P":l=e.dateTime({width:"short"});break;case"PP":l=e.dateTime({width:"medium"});break;case"PPP":l=e.dateTime({width:"long"});break;case"PPPP":default:l=e.dateTime({width:"full"});break}return l.replace("{{date}}",a_(s,e)).replace("{{time}}",dR(i,e))},P9={p:dR,P:j9},I9=/^D+$/,B9=/^Y+$/,z9=["D","DD","YY","YYYY"];function q9(t){return I9.test(t)}function U9(t){return B9.test(t)}function H9(t,e,n){const s=F9(t,e,n);if(console.warn(s),z9.includes(t))throw new RangeError(s)}function F9(t,e,n){const s=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${s} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const V9=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,$9=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,G9=/^'([^]*?)'?$/,Y9=/''/g,Q9=/[a-zA-Z]/;function W9(t,e,n){var p,b,m,v;const s=oh(),i=s.locale??N9,l=s.firstWeekContainsDate??((b=(p=s.locale)==null?void 0:p.options)==null?void 0:b.firstWeekContainsDate)??1,c=s.weekStartsOn??((v=(m=s.locale)==null?void 0:m.options)==null?void 0:v.weekStartsOn)??0,f=ar(t,n==null?void 0:n.in);if(!K7(f))throw new RangeError("Invalid time value");let d=e.match($9).map(g=>{const x=g[0];if(x==="p"||x==="P"){const w=P9[x];return w(g,i.formatLong)}return g}).join("").match(V9).map(g=>{if(g==="''")return{isToken:!1,value:"'"};const x=g[0];if(x==="'")return{isToken:!1,value:K9(g)};if(n_[x])return{isToken:!0,value:g};if(x.match(Q9))throw new RangeError("Format string contains an unescaped latin alphabet character `"+x+"`");return{isToken:!1,value:g}});i.localize.preprocessor&&(d=i.localize.preprocessor(f,d));const h={firstWeekContainsDate:l,weekStartsOn:c,locale:i};return d.map(g=>{if(!g.isToken)return g.value;const x=g.value;(U9(x)||q9(x))&&H9(x,e,String(t));const w=n_[x[0]];return w(f,x,i.localize,h)}).join("")}function K9(t){const e=t.match(G9);return e?e[1].replace(Y9,"'"):t}function hR({title:t,subtitle:e}){return S.jsxs("div",{className:"space-y-0.5",children:[S.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:t}),e?S.jsx("p",{className:"text-muted-foreground",children:e}):null]})}function qv(t,[e,n]){return Math.min(n,Math.max(e,t))}function Z9(t,e){return E.useReducer((n,s)=>e[n][s]??n,t)}var Ky="ScrollArea",[pR,Fz]=Ar(Ky),[X9,Dn]=pR(Ky),mR=E.forwardRef((t,e)=>{const{__scopeScrollArea:n,type:s="hover",dir:i,scrollHideDelay:l=600,...c}=t,[f,d]=E.useState(null),[h,p]=E.useState(null),[b,m]=E.useState(null),[v,g]=E.useState(null),[x,w]=E.useState(null),[C,T]=E.useState(0),[A,R]=E.useState(0),[k,j]=E.useState(!1),[D,F]=E.useState(!1),M=We(e,q=>d(q)),P=Jd(i);return S.jsx(X9,{scope:n,type:s,dir:P,scrollHideDelay:l,scrollArea:f,viewport:h,onViewportChange:p,content:b,onContentChange:m,scrollbarX:v,onScrollbarXChange:g,scrollbarXEnabled:k,onScrollbarXEnabledChange:j,scrollbarY:x,onScrollbarYChange:w,scrollbarYEnabled:D,onScrollbarYEnabledChange:F,onCornerWidthChange:T,onCornerHeightChange:R,children:S.jsx(Ne.div,{dir:P,...c,ref:M,style:{position:"relative","--radix-scroll-area-corner-width":C+"px","--radix-scroll-area-corner-height":A+"px",...t.style}})})});mR.displayName=Ky;var gR="ScrollAreaViewport",vR=E.forwardRef((t,e)=>{const{__scopeScrollArea:n,children:s,nonce:i,...l}=t,c=Dn(gR,n),f=E.useRef(null),d=We(e,f,c.onViewportChange);return S.jsxs(S.Fragment,{children:[S.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),S.jsx(Ne.div,{"data-radix-scroll-area-viewport":"",...l,ref:d,style:{overflowX:c.scrollbarXEnabled?"scroll":"hidden",overflowY:c.scrollbarYEnabled?"scroll":"hidden",...t.style},children:S.jsx("div",{ref:c.onContentChange,style:{minWidth:"100%",display:"table"},children:s})})]})});vR.displayName=gR;var Mr="ScrollAreaScrollbar",Zy=E.forwardRef((t,e)=>{const{forceMount:n,...s}=t,i=Dn(Mr,t.__scopeScrollArea),{onScrollbarXEnabledChange:l,onScrollbarYEnabledChange:c}=i,f=t.orientation==="horizontal";return E.useEffect(()=>(f?l(!0):c(!0),()=>{f?l(!1):c(!1)}),[f,l,c]),i.type==="hover"?S.jsx(J9,{...s,ref:e,forceMount:n}):i.type==="scroll"?S.jsx(eI,{...s,ref:e,forceMount:n}):i.type==="auto"?S.jsx(yR,{...s,ref:e,forceMount:n}):i.type==="always"?S.jsx(Xy,{...s,ref:e}):null});Zy.displayName=Mr;var J9=E.forwardRef((t,e)=>{const{forceMount:n,...s}=t,i=Dn(Mr,t.__scopeScrollArea),[l,c]=E.useState(!1);return E.useEffect(()=>{const f=i.scrollArea;let d=0;if(f){const h=()=>{window.clearTimeout(d),c(!0)},p=()=>{d=window.setTimeout(()=>c(!1),i.scrollHideDelay)};return f.addEventListener("pointerenter",h),f.addEventListener("pointerleave",p),()=>{window.clearTimeout(d),f.removeEventListener("pointerenter",h),f.removeEventListener("pointerleave",p)}}},[i.scrollArea,i.scrollHideDelay]),S.jsx(Ln,{present:n||l,children:S.jsx(yR,{"data-state":l?"visible":"hidden",...s,ref:e})})}),eI=E.forwardRef((t,e)=>{const{forceMount:n,...s}=t,i=Dn(Mr,t.__scopeScrollArea),l=t.orientation==="horizontal",c=uh(()=>d("SCROLL_END"),100),[f,d]=Z9("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return E.useEffect(()=>{if(f==="idle"){const h=window.setTimeout(()=>d("HIDE"),i.scrollHideDelay);return()=>window.clearTimeout(h)}},[f,i.scrollHideDelay,d]),E.useEffect(()=>{const h=i.viewport,p=l?"scrollLeft":"scrollTop";if(h){let b=h[p];const m=()=>{const v=h[p];b!==v&&(d("SCROLL"),c()),b=v};return h.addEventListener("scroll",m),()=>h.removeEventListener("scroll",m)}},[i.viewport,l,d,c]),S.jsx(Ln,{present:n||f!=="hidden",children:S.jsx(Xy,{"data-state":f==="hidden"?"hidden":"visible",...s,ref:e,onPointerEnter:_e(t.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:_e(t.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),yR=E.forwardRef((t,e)=>{const n=Dn(Mr,t.__scopeScrollArea),{forceMount:s,...i}=t,[l,c]=E.useState(!1),f=t.orientation==="horizontal",d=uh(()=>{if(n.viewport){const h=n.viewport.offsetWidth<n.viewport.scrollWidth,p=n.viewport.offsetHeight<n.viewport.scrollHeight;c(f?h:p)}},10);return No(n.viewport,d),No(n.content,d),S.jsx(Ln,{present:s||l,children:S.jsx(Xy,{"data-state":l?"visible":"hidden",...i,ref:e})})}),Xy=E.forwardRef((t,e)=>{const{orientation:n="vertical",...s}=t,i=Dn(Mr,t.__scopeScrollArea),l=E.useRef(null),c=E.useRef(0),[f,d]=E.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),h=_R(f.viewport,f.content),p={...s,sizes:f,onSizesChange:d,hasThumb:h>0&&h<1,onThumbChange:m=>l.current=m,onThumbPointerUp:()=>c.current=0,onThumbPointerDown:m=>c.current=m};function b(m,v){return iI(m,c.current,f,v)}return n==="horizontal"?S.jsx(tI,{...p,ref:e,onThumbPositionChange:()=>{if(i.viewport&&l.current){const m=i.viewport.scrollLeft,v=i_(m,f,i.dir);l.current.style.transform=`translate3d(${v}px, 0, 0)`}},onWheelScroll:m=>{i.viewport&&(i.viewport.scrollLeft=m)},onDragScroll:m=>{i.viewport&&(i.viewport.scrollLeft=b(m,i.dir))}}):n==="vertical"?S.jsx(nI,{...p,ref:e,onThumbPositionChange:()=>{if(i.viewport&&l.current){const m=i.viewport.scrollTop,v=i_(m,f);l.current.style.transform=`translate3d(0, ${v}px, 0)`}},onWheelScroll:m=>{i.viewport&&(i.viewport.scrollTop=m)},onDragScroll:m=>{i.viewport&&(i.viewport.scrollTop=b(m))}}):null}),tI=E.forwardRef((t,e)=>{const{sizes:n,onSizesChange:s,...i}=t,l=Dn(Mr,t.__scopeScrollArea),[c,f]=E.useState(),d=E.useRef(null),h=We(e,d,l.onScrollbarXChange);return E.useEffect(()=>{d.current&&f(getComputedStyle(d.current))},[d]),S.jsx(xR,{"data-orientation":"horizontal",...i,ref:h,sizes:n,style:{bottom:0,left:l.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:l.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":lh(n)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.x),onDragScroll:p=>t.onDragScroll(p.x),onWheelScroll:(p,b)=>{if(l.viewport){const m=l.viewport.scrollLeft+p.deltaX;t.onWheelScroll(m),CR(m,b)&&p.preventDefault()}},onResize:()=>{d.current&&l.viewport&&c&&s({content:l.viewport.scrollWidth,viewport:l.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:jd(c.paddingLeft),paddingEnd:jd(c.paddingRight)}})}})}),nI=E.forwardRef((t,e)=>{const{sizes:n,onSizesChange:s,...i}=t,l=Dn(Mr,t.__scopeScrollArea),[c,f]=E.useState(),d=E.useRef(null),h=We(e,d,l.onScrollbarYChange);return E.useEffect(()=>{d.current&&f(getComputedStyle(d.current))},[d]),S.jsx(xR,{"data-orientation":"vertical",...i,ref:h,sizes:n,style:{top:0,right:l.dir==="ltr"?0:void 0,left:l.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":lh(n)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.y),onDragScroll:p=>t.onDragScroll(p.y),onWheelScroll:(p,b)=>{if(l.viewport){const m=l.viewport.scrollTop+p.deltaY;t.onWheelScroll(m),CR(m,b)&&p.preventDefault()}},onResize:()=>{d.current&&l.viewport&&c&&s({content:l.viewport.scrollHeight,viewport:l.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:jd(c.paddingTop),paddingEnd:jd(c.paddingBottom)}})}})}),[rI,bR]=pR(Mr),xR=E.forwardRef((t,e)=>{const{__scopeScrollArea:n,sizes:s,hasThumb:i,onThumbChange:l,onThumbPointerUp:c,onThumbPointerDown:f,onThumbPositionChange:d,onDragScroll:h,onWheelScroll:p,onResize:b,...m}=t,v=Dn(Mr,n),[g,x]=E.useState(null),w=We(e,M=>x(M)),C=E.useRef(null),T=E.useRef(""),A=v.viewport,R=s.content-s.viewport,k=pt(p),j=pt(d),D=uh(b,10);function F(M){if(C.current){const P=M.clientX-C.current.left,q=M.clientY-C.current.top;h({x:P,y:q})}}return E.useEffect(()=>{const M=P=>{const q=P.target;(g==null?void 0:g.contains(q))&&k(P,R)};return document.addEventListener("wheel",M,{passive:!1}),()=>document.removeEventListener("wheel",M,{passive:!1})},[A,g,R,k]),E.useEffect(j,[s,j]),No(g,D),No(v.content,D),S.jsx(rI,{scope:n,scrollbar:g,hasThumb:i,onThumbChange:pt(l),onThumbPointerUp:pt(c),onThumbPositionChange:j,onThumbPointerDown:pt(f),children:S.jsx(Ne.div,{...m,ref:w,style:{position:"absolute",...m.style},onPointerDown:_e(t.onPointerDown,M=>{M.button===0&&(M.target.setPointerCapture(M.pointerId),C.current=g.getBoundingClientRect(),T.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",v.viewport&&(v.viewport.style.scrollBehavior="auto"),F(M))}),onPointerMove:_e(t.onPointerMove,F),onPointerUp:_e(t.onPointerUp,M=>{const P=M.target;P.hasPointerCapture(M.pointerId)&&P.releasePointerCapture(M.pointerId),document.body.style.webkitUserSelect=T.current,v.viewport&&(v.viewport.style.scrollBehavior=""),C.current=null})})})}),Dd="ScrollAreaThumb",wR=E.forwardRef((t,e)=>{const{forceMount:n,...s}=t,i=bR(Dd,t.__scopeScrollArea);return S.jsx(Ln,{present:n||i.hasThumb,children:S.jsx(sI,{ref:e,...s})})}),sI=E.forwardRef((t,e)=>{const{__scopeScrollArea:n,style:s,...i}=t,l=Dn(Dd,n),c=bR(Dd,n),{onThumbPositionChange:f}=c,d=We(e,b=>c.onThumbChange(b)),h=E.useRef(void 0),p=uh(()=>{h.current&&(h.current(),h.current=void 0)},100);return E.useEffect(()=>{const b=l.viewport;if(b){const m=()=>{if(p(),!h.current){const v=oI(b,f);h.current=v,f()}};return f(),b.addEventListener("scroll",m),()=>b.removeEventListener("scroll",m)}},[l.viewport,p,f]),S.jsx(Ne.div,{"data-state":c.hasThumb?"visible":"hidden",...i,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...s},onPointerDownCapture:_e(t.onPointerDownCapture,b=>{const v=b.target.getBoundingClientRect(),g=b.clientX-v.left,x=b.clientY-v.top;c.onThumbPointerDown({x:g,y:x})}),onPointerUp:_e(t.onPointerUp,c.onThumbPointerUp)})});wR.displayName=Dd;var Jy="ScrollAreaCorner",SR=E.forwardRef((t,e)=>{const n=Dn(Jy,t.__scopeScrollArea),s=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&s?S.jsx(aI,{...t,ref:e}):null});SR.displayName=Jy;var aI=E.forwardRef((t,e)=>{const{__scopeScrollArea:n,...s}=t,i=Dn(Jy,n),[l,c]=E.useState(0),[f,d]=E.useState(0),h=!!(l&&f);return No(i.scrollbarX,()=>{var b;const p=((b=i.scrollbarX)==null?void 0:b.offsetHeight)||0;i.onCornerHeightChange(p),d(p)}),No(i.scrollbarY,()=>{var b;const p=((b=i.scrollbarY)==null?void 0:b.offsetWidth)||0;i.onCornerWidthChange(p),c(p)}),h?S.jsx(Ne.div,{...s,ref:e,style:{width:l,height:f,position:"absolute",right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null});function jd(t){return t?parseInt(t,10):0}function _R(t,e){const n=t/e;return isNaN(n)?0:n}function lh(t){const e=_R(t.viewport,t.content),n=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=(t.scrollbar.size-n)*e;return Math.max(s,18)}function iI(t,e,n,s="ltr"){const i=lh(n),l=i/2,c=e||l,f=i-c,d=n.scrollbar.paddingStart+c,h=n.scrollbar.size-n.scrollbar.paddingEnd-f,p=n.content-n.viewport,b=s==="ltr"?[0,p]:[p*-1,0];return ER([d,h],b)(t)}function i_(t,e,n="ltr"){const s=lh(e),i=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,l=e.scrollbar.size-i,c=e.content-e.viewport,f=l-s,d=n==="ltr"?[0,c]:[c*-1,0],h=qv(t,d);return ER([0,c],[0,f])(h)}function ER(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const s=(e[1]-e[0])/(t[1]-t[0]);return e[0]+s*(n-t[0])}}function CR(t,e){return t>0&&t<e}var oI=(t,e=()=>{})=>{let n={left:t.scrollLeft,top:t.scrollTop},s=0;return function i(){const l={left:t.scrollLeft,top:t.scrollTop},c=n.left!==l.left,f=n.top!==l.top;(c||f)&&e(),n=l,s=window.requestAnimationFrame(i)}(),()=>window.cancelAnimationFrame(s)};function uh(t,e){const n=pt(t),s=E.useRef(0);return E.useEffect(()=>()=>window.clearTimeout(s.current),[]),E.useCallback(()=>{window.clearTimeout(s.current),s.current=window.setTimeout(n,e)},[n,e])}function No(t,e){const n=pt(e);Tt(()=>{let s=0;if(t){const i=new ResizeObserver(()=>{cancelAnimationFrame(s),s=window.requestAnimationFrame(n)});return i.observe(t),()=>{window.cancelAnimationFrame(s),i.unobserve(t)}}},[t,n])}var TR=mR,lI=vR,uI=SR;const RR=E.forwardRef(({className:t,children:e,...n},s)=>S.jsxs(TR,{ref:s,className:fe("relative overflow-hidden",t),...n,children:[S.jsx(lI,{className:"h-full w-full rounded-[inherit]",children:e}),S.jsx(AR,{}),S.jsx(uI,{})]}));RR.displayName=TR.displayName;const AR=E.forwardRef(({className:t,orientation:e="vertical",...n},s)=>S.jsx(Zy,{ref:s,orientation:e,className:fe("flex touch-none select-none transition-colors",e==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",e==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...n,children:S.jsx(wR,{className:"relative flex-1 rounded-full bg-border"})}));AR.displayName=Zy.displayName;function cI(t){const e=E.useRef({value:t,previous:t});return E.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var fI=[" ","Enter","ArrowUp","ArrowDown"],dI=[" ","Enter"],Yu="Select",[ch,fh,hI]=jy(Yu),[qo,Vz]=Ar(Yu,[hI,$d]),dh=$d(),[pI,pa]=qo(Yu),[mI,gI]=qo(Yu),OR=t=>{const{__scopeSelect:e,children:n,open:s,defaultOpen:i,onOpenChange:l,value:c,defaultValue:f,onValueChange:d,dir:h,name:p,autoComplete:b,disabled:m,required:v,form:g}=t,x=dh(e),[w,C]=E.useState(null),[T,A]=E.useState(null),[R,k]=E.useState(!1),j=Jd(h),[D=!1,F]=ei({prop:s,defaultProp:i,onChange:l}),[M,P]=ei({prop:c,defaultProp:f,onChange:d}),q=E.useRef(null),U=w?g||!!w.closest("form"):!0,[G,I]=E.useState(new Set),L=Array.from(G).map(N=>N.props.value).join(";");return S.jsx(JE,{...x,children:S.jsxs(pI,{required:v,scope:e,trigger:w,onTriggerChange:C,valueNode:T,onValueNodeChange:A,valueNodeHasChildren:R,onValueNodeHasChildrenChange:k,contentId:os(),value:M,onValueChange:P,open:D,onOpenChange:F,dir:j,triggerPointerDownPosRef:q,disabled:m,children:[S.jsx(ch.Provider,{scope:e,children:S.jsx(mI,{scope:t.__scopeSelect,onNativeOptionAdd:E.useCallback(N=>{I(H=>new Set(H).add(N))},[]),onNativeOptionRemove:E.useCallback(N=>{I(H=>{const V=new Set(H);return V.delete(N),V})},[]),children:n})}),U?S.jsxs(eA,{"aria-hidden":!0,required:v,tabIndex:-1,name:p,autoComplete:b,value:M,onChange:N=>P(N.target.value),disabled:m,form:g,children:[M===void 0?S.jsx("option",{value:""}):null,Array.from(G)]},L):null]})})};OR.displayName=Yu;var NR="SelectTrigger",kR=E.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:s=!1,...i}=t,l=dh(n),c=pa(NR,n),f=c.disabled||s,d=We(e,c.onTriggerChange),h=fh(n),p=E.useRef("touch"),[b,m,v]=tA(x=>{const w=h().filter(A=>!A.disabled),C=w.find(A=>A.value===c.value),T=nA(w,x,C);T!==void 0&&c.onValueChange(T.value)}),g=x=>{f||(c.onOpenChange(!0),v()),x&&(c.triggerPointerDownPosRef.current={x:Math.round(x.pageX),y:Math.round(x.pageY)})};return S.jsx(eC,{asChild:!0,...l,children:S.jsx(Ne.button,{type:"button",role:"combobox","aria-controls":c.contentId,"aria-expanded":c.open,"aria-required":c.required,"aria-autocomplete":"none",dir:c.dir,"data-state":c.open?"open":"closed",disabled:f,"data-disabled":f?"":void 0,"data-placeholder":JR(c.value)?"":void 0,...i,ref:d,onClick:_e(i.onClick,x=>{x.currentTarget.focus(),p.current!=="mouse"&&g(x)}),onPointerDown:_e(i.onPointerDown,x=>{p.current=x.pointerType;const w=x.target;w.hasPointerCapture(x.pointerId)&&w.releasePointerCapture(x.pointerId),x.button===0&&x.ctrlKey===!1&&x.pointerType==="mouse"&&(g(x),x.preventDefault())}),onKeyDown:_e(i.onKeyDown,x=>{const w=b.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&m(x.key),!(w&&x.key===" ")&&fI.includes(x.key)&&(g(),x.preventDefault())})})})});kR.displayName=NR;var MR="SelectValue",LR=E.forwardRef((t,e)=>{const{__scopeSelect:n,className:s,style:i,children:l,placeholder:c="",...f}=t,d=pa(MR,n),{onValueNodeHasChildrenChange:h}=d,p=l!==void 0,b=We(e,d.onValueNodeChange);return Tt(()=>{h(p)},[h,p]),S.jsx(Ne.span,{...f,ref:b,style:{pointerEvents:"none"},children:JR(d.value)?S.jsx(S.Fragment,{children:c}):l})});LR.displayName=MR;var vI="SelectIcon",DR=E.forwardRef((t,e)=>{const{__scopeSelect:n,children:s,...i}=t;return S.jsx(Ne.span,{"aria-hidden":!0,...i,ref:e,children:s||"▼"})});DR.displayName=vI;var yI="SelectPortal",jR=t=>S.jsx(ju,{asChild:!0,...t});jR.displayName=yI;var li="SelectContent",PR=E.forwardRef((t,e)=>{const n=pa(li,t.__scopeSelect),[s,i]=E.useState();if(Tt(()=>{i(new DocumentFragment)},[]),!n.open){const l=s;return l?Mo.createPortal(S.jsx(IR,{scope:t.__scopeSelect,children:S.jsx(ch.Slot,{scope:t.__scopeSelect,children:S.jsx("div",{children:t.children})})}),l):null}return S.jsx(BR,{...t,ref:e})});PR.displayName=li;var Un=10,[IR,ma]=qo(li),bI="SelectContentImpl",BR=E.forwardRef((t,e)=>{const{__scopeSelect:n,position:s="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:l,onPointerDownOutside:c,side:f,sideOffset:d,align:h,alignOffset:p,arrowPadding:b,collisionBoundary:m,collisionPadding:v,sticky:g,hideWhenDetached:x,avoidCollisions:w,...C}=t,T=pa(li,n),[A,R]=E.useState(null),[k,j]=E.useState(null),D=We(e,he=>R(he)),[F,M]=E.useState(null),[P,q]=E.useState(null),U=fh(n),[G,I]=E.useState(!1),L=E.useRef(!1);E.useEffect(()=>{if(A)return aE(A)},[A]),K_();const N=E.useCallback(he=>{const[ve,...Ae]=U().map(ke=>ke.ref.current),[de]=Ae.slice(-1),Se=document.activeElement;for(const ke of he)if(ke===Se||(ke==null||ke.scrollIntoView({block:"nearest"}),ke===ve&&k&&(k.scrollTop=0),ke===de&&k&&(k.scrollTop=k.scrollHeight),ke==null||ke.focus(),document.activeElement!==Se))return},[U,k]),H=E.useCallback(()=>N([F,A]),[N,F,A]);E.useEffect(()=>{G&&H()},[G,H]);const{onOpenChange:V,triggerPointerDownPosRef:Q}=T;E.useEffect(()=>{if(A){let he={x:0,y:0};const ve=de=>{var Se,ke;he={x:Math.abs(Math.round(de.pageX)-(((Se=Q.current)==null?void 0:Se.x)??0)),y:Math.abs(Math.round(de.pageY)-(((ke=Q.current)==null?void 0:ke.y)??0))}},Ae=de=>{he.x<=10&&he.y<=10?de.preventDefault():A.contains(de.target)||V(!1),document.removeEventListener("pointermove",ve),Q.current=null};return Q.current!==null&&(document.addEventListener("pointermove",ve),document.addEventListener("pointerup",Ae,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ve),document.removeEventListener("pointerup",Ae,{capture:!0})}}},[A,V,Q]),E.useEffect(()=>{const he=()=>V(!1);return window.addEventListener("blur",he),window.addEventListener("resize",he),()=>{window.removeEventListener("blur",he),window.removeEventListener("resize",he)}},[V]);const[z,Z]=tA(he=>{const ve=U().filter(Se=>!Se.disabled),Ae=ve.find(Se=>Se.ref.current===document.activeElement),de=nA(ve,he,Ae);de&&setTimeout(()=>de.ref.current.focus())}),ne=E.useCallback((he,ve,Ae)=>{const de=!L.current&&!Ae;(T.value!==void 0&&T.value===ve||de)&&(M(he),de&&(L.current=!0))},[T.value]),se=E.useCallback(()=>A==null?void 0:A.focus(),[A]),J=E.useCallback((he,ve,Ae)=>{const de=!L.current&&!Ae;(T.value!==void 0&&T.value===ve||de)&&q(he)},[T.value]),ce=s==="popper"?Uv:zR,ye=ce===Uv?{side:f,sideOffset:d,align:h,alignOffset:p,arrowPadding:b,collisionBoundary:m,collisionPadding:v,sticky:g,hideWhenDetached:x,avoidCollisions:w}:{};return S.jsx(IR,{scope:n,content:A,viewport:k,onViewportChange:j,itemRefCallback:ne,selectedItem:F,onItemLeave:se,itemTextRefCallback:J,focusSelectedItem:H,selectedItemText:P,position:s,isPositioned:G,searchRef:z,children:S.jsx(ly,{as:Mn,allowPinchZoom:!0,children:S.jsx(oy,{asChild:!0,trapped:T.open,onMountAutoFocus:he=>{he.preventDefault()},onUnmountAutoFocus:_e(i,he=>{var ve;(ve=T.trigger)==null||ve.focus({preventScroll:!0}),he.preventDefault()}),children:S.jsx(Du,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:he=>he.preventDefault(),onDismiss:()=>T.onOpenChange(!1),children:S.jsx(ce,{role:"listbox",id:T.contentId,"data-state":T.open?"open":"closed",dir:T.dir,onContextMenu:he=>he.preventDefault(),...C,...ye,onPlaced:()=>I(!0),ref:D,style:{display:"flex",flexDirection:"column",outline:"none",...C.style},onKeyDown:_e(C.onKeyDown,he=>{const ve=he.ctrlKey||he.altKey||he.metaKey;if(he.key==="Tab"&&he.preventDefault(),!ve&&he.key.length===1&&Z(he.key),["ArrowUp","ArrowDown","Home","End"].includes(he.key)){let de=U().filter(Se=>!Se.disabled).map(Se=>Se.ref.current);if(["ArrowUp","End"].includes(he.key)&&(de=de.slice().reverse()),["ArrowUp","ArrowDown"].includes(he.key)){const Se=he.target,ke=de.indexOf(Se);de=de.slice(ke+1)}setTimeout(()=>N(de)),he.preventDefault()}})})})})})})});BR.displayName=bI;var xI="SelectItemAlignedPosition",zR=E.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:s,...i}=t,l=pa(li,n),c=ma(li,n),[f,d]=E.useState(null),[h,p]=E.useState(null),b=We(e,D=>p(D)),m=fh(n),v=E.useRef(!1),g=E.useRef(!0),{viewport:x,selectedItem:w,selectedItemText:C,focusSelectedItem:T}=c,A=E.useCallback(()=>{if(l.trigger&&l.valueNode&&f&&h&&x&&w&&C){const D=l.trigger.getBoundingClientRect(),F=h.getBoundingClientRect(),M=l.valueNode.getBoundingClientRect(),P=C.getBoundingClientRect();if(l.dir!=="rtl"){const Se=P.left-F.left,ke=M.left-Se,Ke=D.left-ke,vt=D.width+Ke,nn=Math.max(vt,F.width),Ut=window.innerWidth-Un,Ht=qv(ke,[Un,Math.max(Un,Ut-nn)]);f.style.minWidth=vt+"px",f.style.left=Ht+"px"}else{const Se=F.right-P.right,ke=window.innerWidth-M.right-Se,Ke=window.innerWidth-D.right-ke,vt=D.width+Ke,nn=Math.max(vt,F.width),Ut=window.innerWidth-Un,Ht=qv(ke,[Un,Math.max(Un,Ut-nn)]);f.style.minWidth=vt+"px",f.style.right=Ht+"px"}const q=m(),U=window.innerHeight-Un*2,G=x.scrollHeight,I=window.getComputedStyle(h),L=parseInt(I.borderTopWidth,10),N=parseInt(I.paddingTop,10),H=parseInt(I.borderBottomWidth,10),V=parseInt(I.paddingBottom,10),Q=L+N+G+V+H,z=Math.min(w.offsetHeight*5,Q),Z=window.getComputedStyle(x),ne=parseInt(Z.paddingTop,10),se=parseInt(Z.paddingBottom,10),J=D.top+D.height/2-Un,ce=U-J,ye=w.offsetHeight/2,he=w.offsetTop+ye,ve=L+N+he,Ae=Q-ve;if(ve<=J){const Se=q.length>0&&w===q[q.length-1].ref.current;f.style.bottom="0px";const ke=h.clientHeight-x.offsetTop-x.offsetHeight,Ke=Math.max(ce,ye+(Se?se:0)+ke+H),vt=ve+Ke;f.style.height=vt+"px"}else{const Se=q.length>0&&w===q[0].ref.current;f.style.top="0px";const Ke=Math.max(J,L+x.offsetTop+(Se?ne:0)+ye)+Ae;f.style.height=Ke+"px",x.scrollTop=ve-J+x.offsetTop}f.style.margin=`${Un}px 0`,f.style.minHeight=z+"px",f.style.maxHeight=U+"px",s==null||s(),requestAnimationFrame(()=>v.current=!0)}},[m,l.trigger,l.valueNode,f,h,x,w,C,l.dir,s]);Tt(()=>A(),[A]);const[R,k]=E.useState();Tt(()=>{h&&k(window.getComputedStyle(h).zIndex)},[h]);const j=E.useCallback(D=>{D&&g.current===!0&&(A(),T==null||T(),g.current=!1)},[A,T]);return S.jsx(SI,{scope:n,contentWrapper:f,shouldExpandOnScrollRef:v,onScrollButtonChange:j,children:S.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:R},children:S.jsx(Ne.div,{...i,ref:b,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});zR.displayName=xI;var wI="SelectPopperPosition",Uv=E.forwardRef((t,e)=>{const{__scopeSelect:n,align:s="start",collisionPadding:i=Un,...l}=t,c=dh(n);return S.jsx(tC,{...c,...l,ref:e,align:s,collisionPadding:i,style:{boxSizing:"border-box",...l.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Uv.displayName=wI;var[SI,e0]=qo(li,{}),Hv="SelectViewport",qR=E.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:s,...i}=t,l=ma(Hv,n),c=e0(Hv,n),f=We(e,l.onViewportChange),d=E.useRef(0);return S.jsxs(S.Fragment,{children:[S.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),S.jsx(ch.Slot,{scope:n,children:S.jsx(Ne.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:f,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:_e(i.onScroll,h=>{const p=h.currentTarget,{contentWrapper:b,shouldExpandOnScrollRef:m}=c;if(m!=null&&m.current&&b){const v=Math.abs(d.current-p.scrollTop);if(v>0){const g=window.innerHeight-Un*2,x=parseFloat(b.style.minHeight),w=parseFloat(b.style.height),C=Math.max(x,w);if(C<g){const T=C+v,A=Math.min(g,T),R=T-A;b.style.height=A+"px",b.style.bottom==="0px"&&(p.scrollTop=R>0?R:0,b.style.justifyContent="flex-end")}}}d.current=p.scrollTop})})})]})});qR.displayName=Hv;var UR="SelectGroup",[_I,EI]=qo(UR),CI=E.forwardRef((t,e)=>{const{__scopeSelect:n,...s}=t,i=os();return S.jsx(_I,{scope:n,id:i,children:S.jsx(Ne.div,{role:"group","aria-labelledby":i,...s,ref:e})})});CI.displayName=UR;var HR="SelectLabel",FR=E.forwardRef((t,e)=>{const{__scopeSelect:n,...s}=t,i=EI(HR,n);return S.jsx(Ne.div,{id:i.id,...s,ref:e})});FR.displayName=HR;var Pd="SelectItem",[TI,VR]=qo(Pd),$R=E.forwardRef((t,e)=>{const{__scopeSelect:n,value:s,disabled:i=!1,textValue:l,...c}=t,f=pa(Pd,n),d=ma(Pd,n),h=f.value===s,[p,b]=E.useState(l??""),[m,v]=E.useState(!1),g=We(e,T=>{var A;return(A=d.itemRefCallback)==null?void 0:A.call(d,T,s,i)}),x=os(),w=E.useRef("touch"),C=()=>{i||(f.onValueChange(s),f.onOpenChange(!1))};if(s==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return S.jsx(TI,{scope:n,value:s,disabled:i,textId:x,isSelected:h,onItemTextChange:E.useCallback(T=>{b(A=>A||((T==null?void 0:T.textContent)??"").trim())},[]),children:S.jsx(ch.ItemSlot,{scope:n,value:s,disabled:i,textValue:p,children:S.jsx(Ne.div,{role:"option","aria-labelledby":x,"data-highlighted":m?"":void 0,"aria-selected":h&&m,"data-state":h?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...c,ref:g,onFocus:_e(c.onFocus,()=>v(!0)),onBlur:_e(c.onBlur,()=>v(!1)),onClick:_e(c.onClick,()=>{w.current!=="mouse"&&C()}),onPointerUp:_e(c.onPointerUp,()=>{w.current==="mouse"&&C()}),onPointerDown:_e(c.onPointerDown,T=>{w.current=T.pointerType}),onPointerMove:_e(c.onPointerMove,T=>{var A;w.current=T.pointerType,i?(A=d.onItemLeave)==null||A.call(d):w.current==="mouse"&&T.currentTarget.focus({preventScroll:!0})}),onPointerLeave:_e(c.onPointerLeave,T=>{var A;T.currentTarget===document.activeElement&&((A=d.onItemLeave)==null||A.call(d))}),onKeyDown:_e(c.onKeyDown,T=>{var R;((R=d.searchRef)==null?void 0:R.current)!==""&&T.key===" "||(dI.includes(T.key)&&C(),T.key===" "&&T.preventDefault())})})})})});$R.displayName=Pd;var au="SelectItemText",GR=E.forwardRef((t,e)=>{const{__scopeSelect:n,className:s,style:i,...l}=t,c=pa(au,n),f=ma(au,n),d=VR(au,n),h=gI(au,n),[p,b]=E.useState(null),m=We(e,C=>b(C),d.onItemTextChange,C=>{var T;return(T=f.itemTextRefCallback)==null?void 0:T.call(f,C,d.value,d.disabled)}),v=p==null?void 0:p.textContent,g=E.useMemo(()=>S.jsx("option",{value:d.value,disabled:d.disabled,children:v},d.value),[d.disabled,d.value,v]),{onNativeOptionAdd:x,onNativeOptionRemove:w}=h;return Tt(()=>(x(g),()=>w(g)),[x,w,g]),S.jsxs(S.Fragment,{children:[S.jsx(Ne.span,{id:d.textId,...l,ref:m}),d.isSelected&&c.valueNode&&!c.valueNodeHasChildren?Mo.createPortal(l.children,c.valueNode):null]})});GR.displayName=au;var YR="SelectItemIndicator",QR=E.forwardRef((t,e)=>{const{__scopeSelect:n,...s}=t;return VR(YR,n).isSelected?S.jsx(Ne.span,{"aria-hidden":!0,...s,ref:e}):null});QR.displayName=YR;var Fv="SelectScrollUpButton",WR=E.forwardRef((t,e)=>{const n=ma(Fv,t.__scopeSelect),s=e0(Fv,t.__scopeSelect),[i,l]=E.useState(!1),c=We(e,s.onScrollButtonChange);return Tt(()=>{if(n.viewport&&n.isPositioned){let f=function(){const h=d.scrollTop>0;l(h)};const d=n.viewport;return f(),d.addEventListener("scroll",f),()=>d.removeEventListener("scroll",f)}},[n.viewport,n.isPositioned]),i?S.jsx(ZR,{...t,ref:c,onAutoScroll:()=>{const{viewport:f,selectedItem:d}=n;f&&d&&(f.scrollTop=f.scrollTop-d.offsetHeight)}}):null});WR.displayName=Fv;var Vv="SelectScrollDownButton",KR=E.forwardRef((t,e)=>{const n=ma(Vv,t.__scopeSelect),s=e0(Vv,t.__scopeSelect),[i,l]=E.useState(!1),c=We(e,s.onScrollButtonChange);return Tt(()=>{if(n.viewport&&n.isPositioned){let f=function(){const h=d.scrollHeight-d.clientHeight,p=Math.ceil(d.scrollTop)<h;l(p)};const d=n.viewport;return f(),d.addEventListener("scroll",f),()=>d.removeEventListener("scroll",f)}},[n.viewport,n.isPositioned]),i?S.jsx(ZR,{...t,ref:c,onAutoScroll:()=>{const{viewport:f,selectedItem:d}=n;f&&d&&(f.scrollTop=f.scrollTop+d.offsetHeight)}}):null});KR.displayName=Vv;var ZR=E.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:s,...i}=t,l=ma("SelectScrollButton",n),c=E.useRef(null),f=fh(n),d=E.useCallback(()=>{c.current!==null&&(window.clearInterval(c.current),c.current=null)},[]);return E.useEffect(()=>()=>d(),[d]),Tt(()=>{var p;const h=f().find(b=>b.ref.current===document.activeElement);(p=h==null?void 0:h.ref.current)==null||p.scrollIntoView({block:"nearest"})},[f]),S.jsx(Ne.div,{"aria-hidden":!0,...i,ref:e,style:{flexShrink:0,...i.style},onPointerDown:_e(i.onPointerDown,()=>{c.current===null&&(c.current=window.setInterval(s,50))}),onPointerMove:_e(i.onPointerMove,()=>{var h;(h=l.onItemLeave)==null||h.call(l),c.current===null&&(c.current=window.setInterval(s,50))}),onPointerLeave:_e(i.onPointerLeave,()=>{d()})})}),RI="SelectSeparator",XR=E.forwardRef((t,e)=>{const{__scopeSelect:n,...s}=t;return S.jsx(Ne.div,{"aria-hidden":!0,...s,ref:e})});XR.displayName=RI;var $v="SelectArrow",AI=E.forwardRef((t,e)=>{const{__scopeSelect:n,...s}=t,i=dh(n),l=pa($v,n),c=ma($v,n);return l.open&&c.position==="popper"?S.jsx(nC,{...i,...s,ref:e}):null});AI.displayName=$v;function JR(t){return t===""||t===void 0}var eA=E.forwardRef((t,e)=>{const{value:n,...s}=t,i=E.useRef(null),l=We(e,i),c=cI(n);return E.useEffect(()=>{const f=i.current,d=window.HTMLSelectElement.prototype,p=Object.getOwnPropertyDescriptor(d,"value").set;if(c!==n&&p){const b=new Event("change",{bubbles:!0});p.call(f,n),f.dispatchEvent(b)}},[c,n]),S.jsx(Iu,{asChild:!0,children:S.jsx("select",{...s,ref:l,defaultValue:n})})});eA.displayName="BubbleSelect";function tA(t){const e=pt(t),n=E.useRef(""),s=E.useRef(0),i=E.useCallback(c=>{const f=n.current+c;e(f),function d(h){n.current=h,window.clearTimeout(s.current),h!==""&&(s.current=window.setTimeout(()=>d(""),1e3))}(f)},[e]),l=E.useCallback(()=>{n.current="",window.clearTimeout(s.current)},[]);return E.useEffect(()=>()=>window.clearTimeout(s.current),[]),[n,i,l]}function nA(t,e,n){const i=e.length>1&&Array.from(e).every(h=>h===e[0])?e[0]:e,l=n?t.indexOf(n):-1;let c=OI(t,Math.max(l,0));i.length===1&&(c=c.filter(h=>h!==n));const d=c.find(h=>h.textValue.toLowerCase().startsWith(i.toLowerCase()));return d!==n?d:void 0}function OI(t,e){return t.map((n,s)=>t[(e+s)%t.length])}var NI=OR,rA=kR,kI=LR,MI=DR,LI=jR,sA=PR,DI=qR,aA=FR,iA=$R,jI=GR,PI=QR,oA=WR,lA=KR,uA=XR;const o_=NI,l_=kI,Gv=E.forwardRef(({className:t,children:e,...n},s)=>S.jsxs(rA,{ref:s,className:fe("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...n,children:[e,S.jsx(MI,{asChild:!0,children:S.jsx(RE,{className:"h-4 w-4 opacity-50"})})]}));Gv.displayName=rA.displayName;const cA=E.forwardRef(({className:t,...e},n)=>S.jsx(oA,{ref:n,className:fe("flex cursor-default items-center justify-center py-1",t),...e,children:S.jsx(xM,{className:"h-4 w-4"})}));cA.displayName=oA.displayName;const fA=E.forwardRef(({className:t,...e},n)=>S.jsx(lA,{ref:n,className:fe("flex cursor-default items-center justify-center py-1",t),...e,children:S.jsx(RE,{className:"h-4 w-4"})}));fA.displayName=lA.displayName;const Yv=E.forwardRef(({className:t,children:e,position:n="popper",...s},i)=>S.jsx(LI,{children:S.jsxs(sA,{ref:i,className:fe("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:n,...s,children:[S.jsx(cA,{}),S.jsx(DI,{className:fe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:e}),S.jsx(fA,{})]})}));Yv.displayName=sA.displayName;const II=E.forwardRef(({className:t,...e},n)=>S.jsx(aA,{ref:n,className:fe("px-2 py-1.5 text-sm font-semibold",t),...e}));II.displayName=aA.displayName;const iu=E.forwardRef(({className:t,children:e,...n},s)=>S.jsxs(iA,{ref:s,className:fe("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...n,children:[S.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:S.jsx(PI,{children:S.jsx(hy,{className:"h-4 w-4"})})}),S.jsx(jI,{children:e})]}));iu.displayName=iA.displayName;const BI=E.forwardRef(({className:t,...e},n)=>S.jsx(uA,{ref:n,className:fe("-mx-1 my-1 h-px bg-muted",t),...e}));BI.displayName=uA.displayName;const zI={10:"TRACE",20:"DEBUG",27:"SUCCESS",28:"PROGRESS",29:"LOG",30:"INFO",40:"WARN",50:"ERROR",60:"FATAL"},qI={10:"text-gray-400",20:"text-blue-400",27:"text-green-600",28:"text-purple-400",29:"text-gray-300",30:"text-emerald-400",40:"text-yellow-400",50:"text-red-400",60:"text-red-600"};function dA({agentName:t,level:e,hideTitle:n}={}){var D,F;const[s,i]=E.useState(e||"all"),[l,c]=E.useState(t||"all"),[f,d]=E.useState(!0),h=E.useRef(null),p=E.useRef(!1),b=E.useRef(""),{data:m,error:v,isLoading:g}=da({queryKey:["logs",s,l],queryFn:()=>kt.getLogs({level:s==="all"?"":s,agentName:l==="all"?void 0:l}),refetchInterval:1e3,staleTime:1e3}),{data:x}=qy(),w=((F=(D=x==null?void 0:x.data)==null?void 0:D.agents)==null?void 0:F.map(M=>M.name))??[],C=()=>{if(!h.current)return;const M=h.current,P=M.scrollHeight,q=M.clientHeight;M.scrollTo({top:P-q,behavior:"instant"})};E.useEffect(()=>{var q;if(!((q=m==null?void 0:m.logs)!=null&&q.length))return;const M=m.logs[m.logs.length-1],P=`${M.time}-${M.msg}`;f&&P!==b.current&&(setTimeout(C,0),b.current=P)},[m==null?void 0:m.logs,f]);const T=M=>{if(p.current)return;const{scrollTop:P,scrollHeight:q,clientHeight:U}=M.currentTarget,I=q-(P+U)<100;d(I),p.current=!0,setTimeout(()=>{p.current=!1},150)},A=()=>{d(!0),C()};E.useEffect(()=>{setTimeout(C,100)},[m==null?void 0:m.logs]);const R=M=>zI[M]||"UNKNOWN",k=M=>qI[M]||"text-gray-400",j=M=>{const P=W9(M.time,"yyyy-MM-dd HH:mm:ss"),q=R(M.level),U=Object.entries(M).filter(([I])=>!Number.isNaN(Number(I))).sort((I,L)=>Number(I[0])-Number(L[0])),G=U.length>0?`
|
|
333
|
+
`)}typeof e<"u"&&(e.exports=n)}}),XS={TASK:"task"},iR=class{constructor(t){t&&(this.runtime=t)}static async start(t){throw new Error("Not implemented")}static async stop(t){throw new Error("Not implemented")}},Nn=(t=>(t.ACTIVE="active",t.INACTIVE="inactive",t))(Nn||{}),od=(t=>(t[t.ROOM_JOINING=1]="ROOM_JOINING",t[t.SEND_MESSAGE=2]="SEND_MESSAGE",t))(od||{});function A7(t){if(!t)return!1;const e=["YES","Y","TRUE","T","1","ON","ENABLE"],n=["NO","N","FALSE","F","0","OFF","DISABLE"],s=t.trim().toUpperCase();return e.includes(s)?!0:(n.includes(s),!1)}var O7=class{constructor(t){this.logs=[],this.maxLogs=1e3,this.stream=t}write(t){const e=typeof t=="string"?JSON.parse(t):t;if(e.time||(e.time=Date.now()),this.logs.push(e),this.logs.length>this.maxLogs&&this.logs.shift(),this.stream){const n=typeof t=="string"?t:JSON.stringify(t);this.stream.write(n)}}recentLogs(){return this.logs}},N7={fatal:60,error:50,warn:40,info:30,log:29,progress:28,success:27,debug:20,trace:10},k7=A7(Gn==null?void 0:Gn.LOG_JSON_FORMAT)||!1,M7=async()=>k7?void 0:(await T8(()=>import("./index-Daaf1vE3.js").then(e=>e.i),[])).default({colorize:!0,translateTime:"yyyy-mm-dd HH:MM:ss",ignore:"pid,hostname"}),L7=(Gn==null?void 0:Gn.DEFAULT_LOG_LEVEL)||(Gn==null?void 0:Gn.LOG_LEVEL)||"info",oR={level:L7,customLevels:N7,hooks:{logMethod(t,e){const[n,...s]=t;if(typeof n=="object"){const l=s.map(c=>typeof c=="string"?c:JSON.stringify(c)).join(" ");e.apply(this,[n,l])}else{const i={},l=[n,...s].map(d=>d),c=l.filter(d=>typeof d=="string").join(" "),f=l.filter(d=>typeof d=="object");Object.assign(i,...f),e.apply(this,[i,c])}}}},zv=tR(oR);typeof process<"u"&&M7().then(t=>{const e=new O7(t);zv=tR(oR,e),zv[Symbol.for("pino-destination")]=e});var Et=zv,D7=(t,e)=>{if(e===t.agentId)return t.agentId;const n=`${e}:${t.agentId}`;return U7(n)},lR={},Wy=()=>typeof window<"u"&&typeof window.document<"u";function j7(t=process.cwd()){if(Wy())return null;let e=t;for(;e!==$s.parse(e).root;){const s=$s.join(e,".env");if($s.existsSync(s))return s;e=$s.dirname(e)}const n=$s.join($s.parse(e).root,".env");return $s.existsSync(n)?n:null}function P7(){if(Wy())return lR;const t=j7();p7.config(t?{path:t}:{}).error||Et.log(`Loaded .env file from: ${t}`);const n=typeof process<"u"?Gn:w7,s=I7(n);return typeof process<"u"&&Object.entries(s).forEach(([i,l])=>{Gn[`__namespaced_${i}`]=JSON.stringify(l)}),n}function I7(t){const e={};for(const[n,s]of Object.entries(t)){if(!s)continue;const[i,...l]=n.split(".");if(!i||l.length===0)continue;const c=l.join(".");e[i]=e[i]||{},e[i][c]=s}return e}Wy()||P7();var B7=ue.object({name:ue.string(),content:ue.object({text:ue.string(),action:ue.string().optional(),source:ue.string().optional(),url:ue.string().optional(),inReplyTo:ue.string().uuid().optional(),attachments:ue.array(ue.any()).optional()}).and(ue.record(ue.string(),ue.unknown()))}),z7=ue.object({name:ue.string(),description:ue.string(),actions:ue.array(ue.any()).optional(),providers:ue.array(ue.any()).optional(),evaluators:ue.array(ue.any()).optional(),services:ue.array(ue.any()).optional(),clients:ue.array(ue.any()).optional()});ue.object({id:ue.string().uuid().optional(),name:ue.string(),system:ue.string().optional(),templates:ue.record(ue.string()).optional(),bio:ue.union([ue.string(),ue.array(ue.string())]),messageExamples:ue.array(ue.array(B7)),postExamples:ue.array(ue.string()),topics:ue.array(ue.string()),adjectives:ue.array(ue.string()),knowledge:ue.array(ue.union([ue.string(),ue.object({path:ue.string(),shared:ue.boolean().optional()}),ue.object({directory:ue.string(),shared:ue.boolean().optional()})])).optional(),plugins:ue.union([ue.array(ue.string()),ue.array(z7)]),settings:ue.object({secrets:ue.record(ue.string()).optional(),voice:ue.object({model:ue.string().optional(),url:ue.string().optional()}).optional(),model:ue.string().optional(),modelConfig:ue.object({maxInputTokens:ue.number().optional(),maxOutputTokens:ue.number().optional(),temperature:ue.number().optional(),frequency_penalty:ue.number().optional(),presence_penalty:ue.number().optional()}).optional(),embeddingModel:ue.string().optional()}).optional(),style:ue.object({all:ue.array(ue.string()),chat:ue.array(ue.string()),post:ue.array(ue.string())})});sR(aR());sR(aR());var q7=ue.object({sourceEntityId:ue.string(),targetEntityId:ue.string(),tags:ue.array(ue.string()),metadata:ue.object({interactions:ue.number()}).optional()});ue.object({facts:ue.array(ue.object({claim:ue.string(),type:ue.string(),in_bio:ue.boolean(),already_known:ue.boolean()})),relationships:ue.array(q7)});var na;na=class extends iR{constructor(e){super(e),this.runtime=e,this.capabilityDescription="The agent is currently in a scenario testing environment. It can create rooms, send messages, and talk to other agents in a live interactive testing environment.",this.messageHandlers=new Map,this.worlds=new Map,this.activeActions=new Map,this.activeEvaluators=new Map,this.setupEventListeners()}setupEventListeners(){this.runtime.registerEvent("ACTION_STARTED",async e=>(this.activeActions.set(e.actionId,{actionId:e.actionId,actionName:e.actionName,startTime:Date.now(),completed:!1}),Promise.resolve())),this.runtime.registerEvent("ACTION_COMPLETED",async e=>{const n=this.activeActions.get(e.actionId);return n&&(n.completed=!0,n.error=e.error),Promise.resolve()}),this.runtime.registerEvent("EVALUATOR_STARTED",async e=>(this.activeEvaluators.set(e.evaluatorId,{evaluatorId:e.evaluatorId,evaluatorName:e.evaluatorName,startTime:Date.now(),completed:!1}),Et.debug("Evaluator started",e),Promise.resolve())),this.runtime.registerEvent("EVALUATOR_COMPLETED",async e=>{const n=this.activeEvaluators.get(e.evaluatorId);return n&&(n.completed=!0,n.error=e.error),Et.debug("Evaluator completed",e),Promise.resolve()})}static async start(e){return new na(e)}static async stop(e){const n=e.getService(na.serviceType);if(!n)throw new Error("Scenario service not found");n.stop()}async stop(){this.messageHandlers.clear(),this.worlds.clear(),this.activeActions.clear(),this.activeEvaluators.clear()}async createWorld(e,n){const s=D7(this.runtime.agentId,e),i=ev(),l=ev(),c={id:i,name:e,serverId:s,agentId:this.runtime.agentId,metadata:{owner:{id:l,name:n}}};return this.worlds.set(i,c),i}async createRoom(e,n){if(!this.worlds.get(e))throw new Error(`World ${e} not found`);const i=ev();return await this.runtime.ensureRoomExists({id:i,name:n,source:"scenario",type:"GROUP",channelId:i,serverId:e}),i}async addParticipant(e,n,s){if(!this.worlds.get(e))throw new Error(`World ${e} not found`);if(!this.runtime.getRoom(n))throw new Error(`Room ${n} not found in world ${e}`);await this.runtime.addParticipant(n,s)}async sendMessage(e,n,s,i){if(!this.worlds.get(n))throw new Error(`World ${n} not found`);const c={entityId:e.agentId,agentId:e.agentId,roomId:s,content:{text:i,source:"scenario",name:e.character.name,userName:e.character.name,channelType:"GROUP"}},f=await this.runtime.getParticipantsForRoom(s);for(const d of f)this.runtime.emitEvent("MESSAGE_RECEIVED",{runtime:this.runtime,message:c,roomId:s,entityId:d,source:"scenario",type:"GROUP"})}async waitForCompletion(e=3e4){const n=Date.now();for(;Date.now()-n<e;){const s=Array.from(this.activeActions.values()).every(l=>l.completed),i=Array.from(this.activeEvaluators.values()).every(l=>l.completed);if(s&&i)return!0;await new Promise(l=>setTimeout(l,100))}return!1}getActiveState(){return{actions:Array.from(this.activeActions.values()),evaluators:Array.from(this.activeEvaluators.values())}}async cleanup(){this.worlds.clear(),this.activeActions.clear(),this.activeEvaluators.clear(),this.messageHandlers.clear()}},na.serviceType="scenario";var Ja;Ja=class extends iR{constructor(){super(...arguments),this.timer=null,this.TICK_INTERVAL=1e3,this.capabilityDescription="The agent is able to schedule and execute tasks"}static async start(e){const n=new Ja(e);return await n.startTimer(),n}async createTestTasks(){this.runtime.registerTaskWorker({name:"REPEATING_TEST_TASK",validate:async(n,s,i)=>(Et.debug("Validating repeating test task"),!0),execute:async(n,s)=>{Et.debug("Executing repeating test task")}}),this.runtime.registerTaskWorker({name:"ONETIME_TEST_TASK",validate:async(n,s,i)=>(Et.debug("Validating one-time test task"),!0),execute:async(n,s)=>{Et.debug("Executing one-time test task")}}),(await this.runtime.getTasksByName("REPEATING_TEST_TASK")).length===0&&await this.runtime.createTask({name:"REPEATING_TEST_TASK",description:"A test task that repeats every minute",metadata:{updatedAt:Date.now(),updateInterval:1e3*60},tags:["queue","repeat","test"]}),await this.runtime.createTask({name:"ONETIME_TEST_TASK",description:"A test task that runs once",metadata:{updatedAt:Date.now()},tags:["queue","test"]})}startTimer(){this.timer&&clearInterval(this.timer),this.timer=setInterval(async()=>{try{await this.checkTasks()}catch(e){Et.error("Error checking tasks:",e)}},this.TICK_INTERVAL)}async validateTasks(e){const n=[];for(const s of e){if(!s.id)continue;const i=this.runtime.getTaskWorker(s.name);if(i){if(i.validate)try{if(!await i.validate(this.runtime,{},{}))continue}catch(l){Et.error(`Error validating task ${s.name}:`,l);continue}n.push(s)}}return n}async checkTasks(){var e,n,s;try{const i=await this.runtime.getTasks({tags:["queue"]}),l=await this.validateTasks(i);l.length>0&&Et.debug(`Found ${l.length} queued tasks`);const c=Date.now();for(const f of l){let d;typeof f.updatedAt=="number"?d=f.updatedAt:(e=f.metadata)!=null&&e.updatedAt&&typeof f.metadata.updatedAt=="number"?d=f.metadata.updatedAt:f.updatedAt?d=new Date(f.updatedAt).getTime():d=0;const h=((n=f.metadata)==null?void 0:n.updateInterval)??0;if(!((s=f.tags)!=null&&s.includes("repeat"))){await this.executeTask(f);continue}c-d>=h&&(Et.debug(`Executing task ${f.name} - interval of ${h}ms has elapsed`),await this.executeTask(f))}}catch(i){Et.error("Error checking tasks:",i)}}async executeTask(e){var n;try{if(!e){Et.debug(`Task ${e.id} not found`);return}const s=this.runtime.getTaskWorker(e.name);if(!s){Et.debug(`No worker found for task type: ${e.name}`);return}Et.debug(`Executing task ${e.name} (${e.id})`),await s.execute(this.runtime,e.metadata||{},e),Et.debug("task.tags are",e.tags),(n=e.tags)!=null&&n.includes("repeat")?(await this.runtime.updateTask(e.id,{metadata:{...e.metadata,updatedAt:Date.now()}}),Et.debug(`Updated repeating task ${e.name} (${e.id}) with new timestamp`)):(await this.runtime.deleteTask(e.id),Et.debug(`Deleted non-repeating task ${e.name} (${e.id}) after execution`))}catch(s){Et.error(`Error executing task ${e.id}:`,s)}}static async stop(e){const n=e.getService(XS.TASK);n&&await n.stop()}async stop(){this.timer&&(clearInterval(this.timer),this.timer=null)}},Ja.serviceType=XS.TASK;ue.string().uuid();function U7(t){if(typeof t=="number"&&(t=t.toString()),typeof t!="string")throw TypeError("Value must be string");const e=f=>{const d=f>>4,h=f-(d<<4),p="0123456789abcdef".split("");return p[d]+p[h]},n=f=>{let d="";for(let h=0;h<f.length;h++)d+=e(f[h]);return d},s=encodeURIComponent(t),i=new Uint8Array(s.length);for(let f=0;f<s.length;f++)i[f]=s[f].charCodeAt(0);const l=x7.sha1(i),c=new Uint8Array(l.length/2);for(let f=0;f<l.length;f+=2)c[f/2]=Number.parseInt(l.slice(f,f+2),16);return`${n(c.slice(0,4))}-${n(c.slice(4,6))}-${e(c[6]&15)}${e(c[7])}-${e(c[8]&63|128)}${e(c[9])}-${n(c.slice(10,16))}`}function H7(){const[t,e]=E.useState(null),[n,s]=E.useState(!0),[i,l]=E.useState(typeof navigator<"u"?navigator.onLine:!0),[c,f]=E.useState(!1),d=er(),[h,p]=E.useState(Date.now()),b=E.useRef(0),m=E.useRef(Date.now());E.useEffect(()=>{const j=()=>{s(document.visibilityState==="visible"),document.visibilityState==="visible"&&(b.current=0,Date.now()-h>1e4&&d.invalidateQueries({queryKey:["status"]}))},D=()=>{l(navigator.onLine),navigator.onLine&&(b.current=0,d.invalidateQueries({queryKey:["status"]}))};return document.addEventListener("visibilitychange",j),window.addEventListener("online",D),window.addEventListener("offline",D),s(document.visibilityState==="visible"),()=>{document.removeEventListener("visibilitychange",j),window.removeEventListener("online",D),window.removeEventListener("offline",D)}},[d,h]);const g=da({queryKey:["status"],queryFn:async()=>{try{const j=performance.now(),D=await kt.getAgents(),F=performance.now();return b.current=0,m.current=Date.now(),e(F-j),p(Date.now()),D}catch(j){throw b.current+=1,console.error("Connection check failed:",j),j}},refetchInterval:i?b.current>0?Math.min(5e3*2**(b.current-1),6e4):n?3e3:15e3:!1,retry:3,retryDelay:j=>Math.min(1e3*1.5**j,1e4),refetchOnWindowFocus:!0,refetchOnReconnect:!0,staleTime:500,gcTime:Qn.STANDARD}),x=(g==null?void 0:g.isSuccess)&&!(g!=null&&g.isError),w=(g==null?void 0:g.isRefetching)||(g==null?void 0:g.isPending),C=x===!1&&b.current>5&&Date.now()-m.current>6e4,T=()=>i?C?"bg-yellow-600":w?"bg-muted-foreground":x?"bg-green-600":"bg-red-600":"bg-orange-600",A=()=>i?C?"Reconnecting...":w?"Connecting...":x?"Connected":"Disconnected":"Offline",R=()=>i?C?"text-yellow-600":w?"text-muted-foreground":x?"text-green-600":"text-red-600":"text-orange-600",k=()=>{b.current=0,d.invalidateQueries({queryKey:["agents"]}),d.invalidateQueries({queryKey:["status"]})};return S.jsx(ts,{children:S.jsxs(ls,{children:[S.jsx(us,{asChild:!0,children:S.jsx(Ua,{onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),onClick:k,children:S.jsx("div",{className:"flex flex-col gap-1 select-none transition-all duration-200",children:S.jsxs("div",{className:"flex items-center gap-1",children:[c?S.jsx(PM,{className:"h-3.5 w-3.5 text-muted-foreground animate-pulse"}):S.jsx("div",{className:fe(["h-2.5 w-2.5 rounded-full",T()])}),S.jsx("span",{className:fe(["text-xs",c?"text-muted-foreground":R()]),children:c?"Refresh":A()})]})})})}),x&&!c?S.jsx(br,{side:"top",children:S.jsxs("div",{className:"flex items-center gap-1",children:[S.jsx(TE,{className:"size-4"}),S.jsxs("span",{children:[t==null?void 0:t.toFixed(2)," ms"]})]})}):null]})})}function F7(){const t=ha(),{data:{data:e}={},isPending:n}=qy();return S.jsxs(dC,{className:"bg-background",children:[S.jsx(pC,{children:S.jsx(ed,{children:S.jsx(ts,{children:S.jsx(Ua,{size:"lg",asChild:!0,children:S.jsx(no,{to:"/",className:"px-6 py-2 h-full",children:S.jsxs("div",{className:"flex flex-col pt-2 gap-1 items-start justify-center",children:[S.jsx("img",{alt:"elizaos-logo",src:"/elizaos-logo-light.png",width:"90%"}),S.jsxs("span",{className:"text-xs font-mono text-muted-foreground text-center",children:["v",uo==null?void 0:uo.version]})]})})})})})}),S.jsx(gC,{children:S.jsx(vC,{children:S.jsx(yC,{className:"px-2",children:S.jsx(ed,{children:n?S.jsx("div",{children:Array.from({length:5}).map((s,i)=>S.jsx(ts,{children:S.jsx(bC,{})},`skeleton-item-${i}`))}):S.jsx("div",{children:(()=>{const s=[...(e==null?void 0:e.agents)||[]].sort((c,f)=>c.status===Nn.ACTIVE&&f.status!==Nn.ACTIVE?-1:c.status!==Nn.ACTIVE&&f.status===Nn.ACTIVE?1:c.name.localeCompare(f.name)),i=s.filter(c=>c.status===Nn.ACTIVE),l=s.filter(c=>c.status===Nn.INACTIVE);return S.jsxs(S.Fragment,{children:[i.length>0&&S.jsx("div",{className:"px-4 py-1",children:S.jsx("div",{className:"flex items-center space-x-2",children:S.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Online"})})}),i.map(c=>{var f,d;return S.jsx(ts,{children:S.jsx(no,{to:`/chat/${c.id}`,children:S.jsx(Ua,{isActive:t.pathname.includes(c.id),className:"transition-colors px-4 my-4 rounded-md",children:S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("div",{className:"w-8 h-8 flex justify-center items-center",children:S.jsx("div",{className:"relative bg-muted rounded-full w-full h-full",children:c&&S.jsxs("div",{className:"text-sm rounded-full h-full w-full flex justify-center items-center overflow-hidden",children:[(f=c.settings)!=null&&f.avatar?S.jsx("img",{src:(d=c.settings)==null?void 0:d.avatar,alt:"Agent Avatar",className:"w-full h-full object-contain"}):dd(c.name),S.jsx("div",{className:"absolute bottom-0 right-0 w-[10px] h-[10px] rounded-full border-[1px] border-white bg-green-500"})]})})}),S.jsx("span",{className:"text-base",children:c.name})]})})})},c.id)}),l.length>0&&S.jsx("div",{className:"px-4 py-1 mt-8",children:S.jsx("div",{className:"flex items-center space-x-2",children:S.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Offline"})})}),l.map(c=>{var f;return S.jsx(ts,{children:S.jsx("div",{className:"transition-colors px-4 my-4 rounded-md",children:S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("div",{className:"w-8 h-8 flex justify-center items-center",children:S.jsx("div",{className:"relative bg-muted rounded-full w-full h-full",children:c&&S.jsxs("div",{className:"text-sm rounded-full h-full w-full flex justify-center items-center overflow-hidden",children:[(f=c.settings)!=null&&f.avatar?S.jsx("img",{src:c.settings.avatar,alt:"Agent Avatar",className:"w-full h-full object-contain"}):dd(c.name),S.jsx("div",{className:"absolute bottom-0 right-0 w-[10px] h-[10px] rounded-full border-[1px] border-white bg-muted-foreground"})]})})}),S.jsx("span",{className:"text-base truncate max-w-24",children:c.name})]})})},c.id)})]})})()})})})})}),S.jsx(mC,{className:"px-4 py-4",children:S.jsxs(ed,{children:[S.jsx(ts,{children:S.jsx(no,{to:"https://elizaos.github.io/eliza/docs/intro/",target:"_blank",children:S.jsxs(Ua,{className:"text-muted-foreground rounded-md",children:[S.jsx(yM,{className:"size-5"}),S.jsx("span",{children:"Documentation"})]})})}),S.jsx(ts,{children:S.jsx(no,{to:"/logs",children:S.jsxs(Ua,{className:"text-muted-foreground rounded-md",children:[S.jsx(NE,{className:"size-5"}),S.jsx("span",{children:"Logs"})]})})}),S.jsx(ts,{children:S.jsxs(Ua,{disabled:!0,className:"text-muted-foreground/50 rounded-md",children:[S.jsx(py,{className:"size-5"}),S.jsx("span",{children:"Settings"})]})}),S.jsx(H7,{})]})})]})}const uR=6048e5,V7=864e5,JS=Symbol.for("constructDateFrom");function ca(t,e){return typeof t=="function"?t(e):t&&typeof t=="object"&&JS in t?t[JS](e):t instanceof Date?new t.constructor(e):new Date(e)}function ar(t,e){return ca(e||t,t)}let $7={};function oh(){return $7}function Au(t,e){var f,d,h,p;const n=oh(),s=(e==null?void 0:e.weekStartsOn)??((d=(f=e==null?void 0:e.locale)==null?void 0:f.options)==null?void 0:d.weekStartsOn)??n.weekStartsOn??((p=(h=n.locale)==null?void 0:h.options)==null?void 0:p.weekStartsOn)??0,i=ar(t,e==null?void 0:e.in),l=i.getDay(),c=(l<s?7:0)+l-s;return i.setDate(i.getDate()-c),i.setHours(0,0,0,0),i}function Ld(t,e){return Au(t,{...e,weekStartsOn:1})}function cR(t,e){const n=ar(t,e==null?void 0:e.in),s=n.getFullYear(),i=ca(n,0);i.setFullYear(s+1,0,4),i.setHours(0,0,0,0);const l=Ld(i),c=ca(n,0);c.setFullYear(s,0,4),c.setHours(0,0,0,0);const f=Ld(c);return n.getTime()>=l.getTime()?s+1:n.getTime()>=f.getTime()?s:s-1}function e_(t){const e=ar(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function G7(t,...e){const n=ca.bind(null,e.find(s=>typeof s=="object"));return e.map(n)}function t_(t,e){const n=ar(t,e==null?void 0:e.in);return n.setHours(0,0,0,0),n}function Y7(t,e,n){const[s,i]=G7(n==null?void 0:n.in,t,e),l=t_(s),c=t_(i),f=+l-e_(l),d=+c-e_(c);return Math.round((f-d)/V7)}function Q7(t,e){const n=cR(t,e),s=ca(t,0);return s.setFullYear(n,0,4),s.setHours(0,0,0,0),Ld(s)}function W7(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function K7(t){return!(!W7(t)&&typeof t!="number"||isNaN(+ar(t)))}function Z7(t,e){const n=ar(t,e==null?void 0:e.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}const X7={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},J7=(t,e,n)=>{let s;const i=X7[t];return typeof i=="string"?s=i:e===1?s=i.one:s=i.other.replace("{{count}}",e.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+s:s+" ago":s};function nv(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const e9={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},t9={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},n9={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},r9={date:nv({formats:e9,defaultWidth:"full"}),time:nv({formats:t9,defaultWidth:"full"}),dateTime:nv({formats:n9,defaultWidth:"full"})},s9={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},a9=(t,e,n,s)=>s9[t];function Zl(t){return(e,n)=>{const s=n!=null&&n.context?String(n.context):"standalone";let i;if(s==="formatting"&&t.formattingValues){const c=t.defaultFormattingWidth||t.defaultWidth,f=n!=null&&n.width?String(n.width):c;i=t.formattingValues[f]||t.formattingValues[c]}else{const c=t.defaultWidth,f=n!=null&&n.width?String(n.width):t.defaultWidth;i=t.values[f]||t.values[c]}const l=t.argumentCallback?t.argumentCallback(e):e;return i[l]}}const i9={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},o9={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},l9={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},u9={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},c9={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},f9={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},d9=(t,e)=>{const n=Number(t),s=n%100;if(s>20||s<10)switch(s%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},h9={ordinalNumber:d9,era:Zl({values:i9,defaultWidth:"wide"}),quarter:Zl({values:o9,defaultWidth:"wide",argumentCallback:t=>t-1}),month:Zl({values:l9,defaultWidth:"wide"}),day:Zl({values:u9,defaultWidth:"wide"}),dayPeriod:Zl({values:c9,defaultWidth:"wide",formattingValues:f9,defaultFormattingWidth:"wide"})};function Xl(t){return(e,n={})=>{const s=n.width,i=s&&t.matchPatterns[s]||t.matchPatterns[t.defaultMatchWidth],l=e.match(i);if(!l)return null;const c=l[0],f=s&&t.parsePatterns[s]||t.parsePatterns[t.defaultParseWidth],d=Array.isArray(f)?m9(f,b=>b.test(c)):p9(f,b=>b.test(c));let h;h=t.valueCallback?t.valueCallback(d):d,h=n.valueCallback?n.valueCallback(h):h;const p=e.slice(c.length);return{value:h,rest:p}}}function p9(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function m9(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n}function g9(t){return(e,n={})=>{const s=e.match(t.matchPattern);if(!s)return null;const i=s[0],l=e.match(t.parsePattern);if(!l)return null;let c=t.valueCallback?t.valueCallback(l[0]):l[0];c=n.valueCallback?n.valueCallback(c):c;const f=e.slice(i.length);return{value:c,rest:f}}}const v9=/^(\d+)(th|st|nd|rd)?/i,y9=/\d+/i,b9={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},x9={any:[/^b/i,/^(a|c)/i]},w9={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},S9={any:[/1/i,/2/i,/3/i,/4/i]},_9={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},E9={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},C9={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},T9={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},R9={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},A9={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},O9={ordinalNumber:g9({matchPattern:v9,parsePattern:y9,valueCallback:t=>parseInt(t,10)}),era:Xl({matchPatterns:b9,defaultMatchWidth:"wide",parsePatterns:x9,defaultParseWidth:"any"}),quarter:Xl({matchPatterns:w9,defaultMatchWidth:"wide",parsePatterns:S9,defaultParseWidth:"any",valueCallback:t=>t+1}),month:Xl({matchPatterns:_9,defaultMatchWidth:"wide",parsePatterns:E9,defaultParseWidth:"any"}),day:Xl({matchPatterns:C9,defaultMatchWidth:"wide",parsePatterns:T9,defaultParseWidth:"any"}),dayPeriod:Xl({matchPatterns:R9,defaultMatchWidth:"any",parsePatterns:A9,defaultParseWidth:"any"})},N9={code:"en-US",formatDistance:J7,formatLong:r9,formatRelative:a9,localize:h9,match:O9,options:{weekStartsOn:0,firstWeekContainsDate:1}};function k9(t,e){const n=ar(t,e==null?void 0:e.in);return Y7(n,Z7(n))+1}function M9(t,e){const n=ar(t,e==null?void 0:e.in),s=+Ld(n)-+Q7(n);return Math.round(s/uR)+1}function fR(t,e){var p,b,m,v;const n=ar(t,e==null?void 0:e.in),s=n.getFullYear(),i=oh(),l=(e==null?void 0:e.firstWeekContainsDate)??((b=(p=e==null?void 0:e.locale)==null?void 0:p.options)==null?void 0:b.firstWeekContainsDate)??i.firstWeekContainsDate??((v=(m=i.locale)==null?void 0:m.options)==null?void 0:v.firstWeekContainsDate)??1,c=ca((e==null?void 0:e.in)||t,0);c.setFullYear(s+1,0,l),c.setHours(0,0,0,0);const f=Au(c,e),d=ca((e==null?void 0:e.in)||t,0);d.setFullYear(s,0,l),d.setHours(0,0,0,0);const h=Au(d,e);return+n>=+f?s+1:+n>=+h?s:s-1}function L9(t,e){var f,d,h,p;const n=oh(),s=(e==null?void 0:e.firstWeekContainsDate)??((d=(f=e==null?void 0:e.locale)==null?void 0:f.options)==null?void 0:d.firstWeekContainsDate)??n.firstWeekContainsDate??((p=(h=n.locale)==null?void 0:h.options)==null?void 0:p.firstWeekContainsDate)??1,i=fR(t,e),l=ca((e==null?void 0:e.in)||t,0);return l.setFullYear(i,0,s),l.setHours(0,0,0,0),Au(l,e)}function D9(t,e){const n=ar(t,e==null?void 0:e.in),s=+Au(n,e)-+L9(n,e);return Math.round(s/uR)+1}function Je(t,e){const n=t<0?"-":"",s=Math.abs(t).toString().padStart(e,"0");return n+s}const Hs={y(t,e){const n=t.getFullYear(),s=n>0?n:1-n;return Je(e==="yy"?s%100:s,e.length)},M(t,e){const n=t.getMonth();return e==="M"?String(n+1):Je(n+1,2)},d(t,e){return Je(t.getDate(),e.length)},a(t,e){const n=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(t,e){return Je(t.getHours()%12||12,e.length)},H(t,e){return Je(t.getHours(),e.length)},m(t,e){return Je(t.getMinutes(),e.length)},s(t,e){return Je(t.getSeconds(),e.length)},S(t,e){const n=e.length,s=t.getMilliseconds(),i=Math.trunc(s*Math.pow(10,n-3));return Je(i,e.length)}},Zi={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},n_={G:function(t,e,n){const s=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(s,{width:"abbreviated"});case"GGGGG":return n.era(s,{width:"narrow"});case"GGGG":default:return n.era(s,{width:"wide"})}},y:function(t,e,n){if(e==="yo"){const s=t.getFullYear(),i=s>0?s:1-s;return n.ordinalNumber(i,{unit:"year"})}return Hs.y(t,e)},Y:function(t,e,n,s){const i=fR(t,s),l=i>0?i:1-i;if(e==="YY"){const c=l%100;return Je(c,2)}return e==="Yo"?n.ordinalNumber(l,{unit:"year"}):Je(l,e.length)},R:function(t,e){const n=cR(t);return Je(n,e.length)},u:function(t,e){const n=t.getFullYear();return Je(n,e.length)},Q:function(t,e,n){const s=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(s);case"QQ":return Je(s,2);case"Qo":return n.ordinalNumber(s,{unit:"quarter"});case"QQQ":return n.quarter(s,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(s,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(s,{width:"wide",context:"formatting"})}},q:function(t,e,n){const s=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(s);case"qq":return Je(s,2);case"qo":return n.ordinalNumber(s,{unit:"quarter"});case"qqq":return n.quarter(s,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(s,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(s,{width:"wide",context:"standalone"})}},M:function(t,e,n){const s=t.getMonth();switch(e){case"M":case"MM":return Hs.M(t,e);case"Mo":return n.ordinalNumber(s+1,{unit:"month"});case"MMM":return n.month(s,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(s,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(s,{width:"wide",context:"formatting"})}},L:function(t,e,n){const s=t.getMonth();switch(e){case"L":return String(s+1);case"LL":return Je(s+1,2);case"Lo":return n.ordinalNumber(s+1,{unit:"month"});case"LLL":return n.month(s,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(s,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(s,{width:"wide",context:"standalone"})}},w:function(t,e,n,s){const i=D9(t,s);return e==="wo"?n.ordinalNumber(i,{unit:"week"}):Je(i,e.length)},I:function(t,e,n){const s=M9(t);return e==="Io"?n.ordinalNumber(s,{unit:"week"}):Je(s,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):Hs.d(t,e)},D:function(t,e,n){const s=k9(t);return e==="Do"?n.ordinalNumber(s,{unit:"dayOfYear"}):Je(s,e.length)},E:function(t,e,n){const s=t.getDay();switch(e){case"E":case"EE":case"EEE":return n.day(s,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(s,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(s,{width:"short",context:"formatting"});case"EEEE":default:return n.day(s,{width:"wide",context:"formatting"})}},e:function(t,e,n,s){const i=t.getDay(),l=(i-s.weekStartsOn+8)%7||7;switch(e){case"e":return String(l);case"ee":return Je(l,2);case"eo":return n.ordinalNumber(l,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});case"eeee":default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(t,e,n,s){const i=t.getDay(),l=(i-s.weekStartsOn+8)%7||7;switch(e){case"c":return String(l);case"cc":return Je(l,e.length);case"co":return n.ordinalNumber(l,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});case"cccc":default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(t,e,n){const s=t.getDay(),i=s===0?7:s;switch(e){case"i":return String(i);case"ii":return Je(i,e.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(s,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(s,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(s,{width:"short",context:"formatting"});case"iiii":default:return n.day(s,{width:"wide",context:"formatting"})}},a:function(t,e,n){const i=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(t,e,n){const s=t.getHours();let i;switch(s===12?i=Zi.noon:s===0?i=Zi.midnight:i=s/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},B:function(t,e,n){const s=t.getHours();let i;switch(s>=17?i=Zi.evening:s>=12?i=Zi.afternoon:s>=4?i=Zi.morning:i=Zi.night,e){case"B":case"BB":case"BBB":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},h:function(t,e,n){if(e==="ho"){let s=t.getHours()%12;return s===0&&(s=12),n.ordinalNumber(s,{unit:"hour"})}return Hs.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):Hs.H(t,e)},K:function(t,e,n){const s=t.getHours()%12;return e==="Ko"?n.ordinalNumber(s,{unit:"hour"}):Je(s,e.length)},k:function(t,e,n){let s=t.getHours();return s===0&&(s=24),e==="ko"?n.ordinalNumber(s,{unit:"hour"}):Je(s,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):Hs.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):Hs.s(t,e)},S:function(t,e){return Hs.S(t,e)},X:function(t,e,n){const s=t.getTimezoneOffset();if(s===0)return"Z";switch(e){case"X":return s_(s);case"XXXX":case"XX":return qa(s);case"XXXXX":case"XXX":default:return qa(s,":")}},x:function(t,e,n){const s=t.getTimezoneOffset();switch(e){case"x":return s_(s);case"xxxx":case"xx":return qa(s);case"xxxxx":case"xxx":default:return qa(s,":")}},O:function(t,e,n){const s=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+r_(s,":");case"OOOO":default:return"GMT"+qa(s,":")}},z:function(t,e,n){const s=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+r_(s,":");case"zzzz":default:return"GMT"+qa(s,":")}},t:function(t,e,n){const s=Math.trunc(+t/1e3);return Je(s,e.length)},T:function(t,e,n){return Je(+t,e.length)}};function r_(t,e=""){const n=t>0?"-":"+",s=Math.abs(t),i=Math.trunc(s/60),l=s%60;return l===0?n+String(i):n+String(i)+e+Je(l,2)}function s_(t,e){return t%60===0?(t>0?"-":"+")+Je(Math.abs(t)/60,2):qa(t,e)}function qa(t,e=""){const n=t>0?"-":"+",s=Math.abs(t),i=Je(Math.trunc(s/60),2),l=Je(s%60,2);return n+i+e+l}const a_=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},dR=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},j9=(t,e)=>{const n=t.match(/(P+)(p+)?/)||[],s=n[1],i=n[2];if(!i)return a_(t,e);let l;switch(s){case"P":l=e.dateTime({width:"short"});break;case"PP":l=e.dateTime({width:"medium"});break;case"PPP":l=e.dateTime({width:"long"});break;case"PPPP":default:l=e.dateTime({width:"full"});break}return l.replace("{{date}}",a_(s,e)).replace("{{time}}",dR(i,e))},P9={p:dR,P:j9},I9=/^D+$/,B9=/^Y+$/,z9=["D","DD","YY","YYYY"];function q9(t){return I9.test(t)}function U9(t){return B9.test(t)}function H9(t,e,n){const s=F9(t,e,n);if(console.warn(s),z9.includes(t))throw new RangeError(s)}function F9(t,e,n){const s=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${s} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const V9=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,$9=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,G9=/^'([^]*?)'?$/,Y9=/''/g,Q9=/[a-zA-Z]/;function W9(t,e,n){var p,b,m,v;const s=oh(),i=s.locale??N9,l=s.firstWeekContainsDate??((b=(p=s.locale)==null?void 0:p.options)==null?void 0:b.firstWeekContainsDate)??1,c=s.weekStartsOn??((v=(m=s.locale)==null?void 0:m.options)==null?void 0:v.weekStartsOn)??0,f=ar(t,n==null?void 0:n.in);if(!K7(f))throw new RangeError("Invalid time value");let d=e.match($9).map(g=>{const x=g[0];if(x==="p"||x==="P"){const w=P9[x];return w(g,i.formatLong)}return g}).join("").match(V9).map(g=>{if(g==="''")return{isToken:!1,value:"'"};const x=g[0];if(x==="'")return{isToken:!1,value:K9(g)};if(n_[x])return{isToken:!0,value:g};if(x.match(Q9))throw new RangeError("Format string contains an unescaped latin alphabet character `"+x+"`");return{isToken:!1,value:g}});i.localize.preprocessor&&(d=i.localize.preprocessor(f,d));const h={firstWeekContainsDate:l,weekStartsOn:c,locale:i};return d.map(g=>{if(!g.isToken)return g.value;const x=g.value;(U9(x)||q9(x))&&H9(x,e,String(t));const w=n_[x[0]];return w(f,x,i.localize,h)}).join("")}function K9(t){const e=t.match(G9);return e?e[1].replace(Y9,"'"):t}function hR({title:t,subtitle:e}){return S.jsxs("div",{className:"space-y-0.5",children:[S.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:t}),e?S.jsx("p",{className:"text-muted-foreground",children:e}):null]})}function qv(t,[e,n]){return Math.min(n,Math.max(e,t))}function Z9(t,e){return E.useReducer((n,s)=>e[n][s]??n,t)}var Ky="ScrollArea",[pR,Fz]=Ar(Ky),[X9,Dn]=pR(Ky),mR=E.forwardRef((t,e)=>{const{__scopeScrollArea:n,type:s="hover",dir:i,scrollHideDelay:l=600,...c}=t,[f,d]=E.useState(null),[h,p]=E.useState(null),[b,m]=E.useState(null),[v,g]=E.useState(null),[x,w]=E.useState(null),[C,T]=E.useState(0),[A,R]=E.useState(0),[k,j]=E.useState(!1),[D,F]=E.useState(!1),M=We(e,q=>d(q)),P=Jd(i);return S.jsx(X9,{scope:n,type:s,dir:P,scrollHideDelay:l,scrollArea:f,viewport:h,onViewportChange:p,content:b,onContentChange:m,scrollbarX:v,onScrollbarXChange:g,scrollbarXEnabled:k,onScrollbarXEnabledChange:j,scrollbarY:x,onScrollbarYChange:w,scrollbarYEnabled:D,onScrollbarYEnabledChange:F,onCornerWidthChange:T,onCornerHeightChange:R,children:S.jsx(Ne.div,{dir:P,...c,ref:M,style:{position:"relative","--radix-scroll-area-corner-width":C+"px","--radix-scroll-area-corner-height":A+"px",...t.style}})})});mR.displayName=Ky;var gR="ScrollAreaViewport",vR=E.forwardRef((t,e)=>{const{__scopeScrollArea:n,children:s,nonce:i,...l}=t,c=Dn(gR,n),f=E.useRef(null),d=We(e,f,c.onViewportChange);return S.jsxs(S.Fragment,{children:[S.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),S.jsx(Ne.div,{"data-radix-scroll-area-viewport":"",...l,ref:d,style:{overflowX:c.scrollbarXEnabled?"scroll":"hidden",overflowY:c.scrollbarYEnabled?"scroll":"hidden",...t.style},children:S.jsx("div",{ref:c.onContentChange,style:{minWidth:"100%",display:"table"},children:s})})]})});vR.displayName=gR;var Mr="ScrollAreaScrollbar",Zy=E.forwardRef((t,e)=>{const{forceMount:n,...s}=t,i=Dn(Mr,t.__scopeScrollArea),{onScrollbarXEnabledChange:l,onScrollbarYEnabledChange:c}=i,f=t.orientation==="horizontal";return E.useEffect(()=>(f?l(!0):c(!0),()=>{f?l(!1):c(!1)}),[f,l,c]),i.type==="hover"?S.jsx(J9,{...s,ref:e,forceMount:n}):i.type==="scroll"?S.jsx(eI,{...s,ref:e,forceMount:n}):i.type==="auto"?S.jsx(yR,{...s,ref:e,forceMount:n}):i.type==="always"?S.jsx(Xy,{...s,ref:e}):null});Zy.displayName=Mr;var J9=E.forwardRef((t,e)=>{const{forceMount:n,...s}=t,i=Dn(Mr,t.__scopeScrollArea),[l,c]=E.useState(!1);return E.useEffect(()=>{const f=i.scrollArea;let d=0;if(f){const h=()=>{window.clearTimeout(d),c(!0)},p=()=>{d=window.setTimeout(()=>c(!1),i.scrollHideDelay)};return f.addEventListener("pointerenter",h),f.addEventListener("pointerleave",p),()=>{window.clearTimeout(d),f.removeEventListener("pointerenter",h),f.removeEventListener("pointerleave",p)}}},[i.scrollArea,i.scrollHideDelay]),S.jsx(Ln,{present:n||l,children:S.jsx(yR,{"data-state":l?"visible":"hidden",...s,ref:e})})}),eI=E.forwardRef((t,e)=>{const{forceMount:n,...s}=t,i=Dn(Mr,t.__scopeScrollArea),l=t.orientation==="horizontal",c=uh(()=>d("SCROLL_END"),100),[f,d]=Z9("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return E.useEffect(()=>{if(f==="idle"){const h=window.setTimeout(()=>d("HIDE"),i.scrollHideDelay);return()=>window.clearTimeout(h)}},[f,i.scrollHideDelay,d]),E.useEffect(()=>{const h=i.viewport,p=l?"scrollLeft":"scrollTop";if(h){let b=h[p];const m=()=>{const v=h[p];b!==v&&(d("SCROLL"),c()),b=v};return h.addEventListener("scroll",m),()=>h.removeEventListener("scroll",m)}},[i.viewport,l,d,c]),S.jsx(Ln,{present:n||f!=="hidden",children:S.jsx(Xy,{"data-state":f==="hidden"?"hidden":"visible",...s,ref:e,onPointerEnter:_e(t.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:_e(t.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),yR=E.forwardRef((t,e)=>{const n=Dn(Mr,t.__scopeScrollArea),{forceMount:s,...i}=t,[l,c]=E.useState(!1),f=t.orientation==="horizontal",d=uh(()=>{if(n.viewport){const h=n.viewport.offsetWidth<n.viewport.scrollWidth,p=n.viewport.offsetHeight<n.viewport.scrollHeight;c(f?h:p)}},10);return No(n.viewport,d),No(n.content,d),S.jsx(Ln,{present:s||l,children:S.jsx(Xy,{"data-state":l?"visible":"hidden",...i,ref:e})})}),Xy=E.forwardRef((t,e)=>{const{orientation:n="vertical",...s}=t,i=Dn(Mr,t.__scopeScrollArea),l=E.useRef(null),c=E.useRef(0),[f,d]=E.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),h=_R(f.viewport,f.content),p={...s,sizes:f,onSizesChange:d,hasThumb:h>0&&h<1,onThumbChange:m=>l.current=m,onThumbPointerUp:()=>c.current=0,onThumbPointerDown:m=>c.current=m};function b(m,v){return iI(m,c.current,f,v)}return n==="horizontal"?S.jsx(tI,{...p,ref:e,onThumbPositionChange:()=>{if(i.viewport&&l.current){const m=i.viewport.scrollLeft,v=i_(m,f,i.dir);l.current.style.transform=`translate3d(${v}px, 0, 0)`}},onWheelScroll:m=>{i.viewport&&(i.viewport.scrollLeft=m)},onDragScroll:m=>{i.viewport&&(i.viewport.scrollLeft=b(m,i.dir))}}):n==="vertical"?S.jsx(nI,{...p,ref:e,onThumbPositionChange:()=>{if(i.viewport&&l.current){const m=i.viewport.scrollTop,v=i_(m,f);l.current.style.transform=`translate3d(0, ${v}px, 0)`}},onWheelScroll:m=>{i.viewport&&(i.viewport.scrollTop=m)},onDragScroll:m=>{i.viewport&&(i.viewport.scrollTop=b(m))}}):null}),tI=E.forwardRef((t,e)=>{const{sizes:n,onSizesChange:s,...i}=t,l=Dn(Mr,t.__scopeScrollArea),[c,f]=E.useState(),d=E.useRef(null),h=We(e,d,l.onScrollbarXChange);return E.useEffect(()=>{d.current&&f(getComputedStyle(d.current))},[d]),S.jsx(xR,{"data-orientation":"horizontal",...i,ref:h,sizes:n,style:{bottom:0,left:l.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:l.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":lh(n)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.x),onDragScroll:p=>t.onDragScroll(p.x),onWheelScroll:(p,b)=>{if(l.viewport){const m=l.viewport.scrollLeft+p.deltaX;t.onWheelScroll(m),CR(m,b)&&p.preventDefault()}},onResize:()=>{d.current&&l.viewport&&c&&s({content:l.viewport.scrollWidth,viewport:l.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:jd(c.paddingLeft),paddingEnd:jd(c.paddingRight)}})}})}),nI=E.forwardRef((t,e)=>{const{sizes:n,onSizesChange:s,...i}=t,l=Dn(Mr,t.__scopeScrollArea),[c,f]=E.useState(),d=E.useRef(null),h=We(e,d,l.onScrollbarYChange);return E.useEffect(()=>{d.current&&f(getComputedStyle(d.current))},[d]),S.jsx(xR,{"data-orientation":"vertical",...i,ref:h,sizes:n,style:{top:0,right:l.dir==="ltr"?0:void 0,left:l.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":lh(n)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.y),onDragScroll:p=>t.onDragScroll(p.y),onWheelScroll:(p,b)=>{if(l.viewport){const m=l.viewport.scrollTop+p.deltaY;t.onWheelScroll(m),CR(m,b)&&p.preventDefault()}},onResize:()=>{d.current&&l.viewport&&c&&s({content:l.viewport.scrollHeight,viewport:l.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:jd(c.paddingTop),paddingEnd:jd(c.paddingBottom)}})}})}),[rI,bR]=pR(Mr),xR=E.forwardRef((t,e)=>{const{__scopeScrollArea:n,sizes:s,hasThumb:i,onThumbChange:l,onThumbPointerUp:c,onThumbPointerDown:f,onThumbPositionChange:d,onDragScroll:h,onWheelScroll:p,onResize:b,...m}=t,v=Dn(Mr,n),[g,x]=E.useState(null),w=We(e,M=>x(M)),C=E.useRef(null),T=E.useRef(""),A=v.viewport,R=s.content-s.viewport,k=pt(p),j=pt(d),D=uh(b,10);function F(M){if(C.current){const P=M.clientX-C.current.left,q=M.clientY-C.current.top;h({x:P,y:q})}}return E.useEffect(()=>{const M=P=>{const q=P.target;(g==null?void 0:g.contains(q))&&k(P,R)};return document.addEventListener("wheel",M,{passive:!1}),()=>document.removeEventListener("wheel",M,{passive:!1})},[A,g,R,k]),E.useEffect(j,[s,j]),No(g,D),No(v.content,D),S.jsx(rI,{scope:n,scrollbar:g,hasThumb:i,onThumbChange:pt(l),onThumbPointerUp:pt(c),onThumbPositionChange:j,onThumbPointerDown:pt(f),children:S.jsx(Ne.div,{...m,ref:w,style:{position:"absolute",...m.style},onPointerDown:_e(t.onPointerDown,M=>{M.button===0&&(M.target.setPointerCapture(M.pointerId),C.current=g.getBoundingClientRect(),T.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",v.viewport&&(v.viewport.style.scrollBehavior="auto"),F(M))}),onPointerMove:_e(t.onPointerMove,F),onPointerUp:_e(t.onPointerUp,M=>{const P=M.target;P.hasPointerCapture(M.pointerId)&&P.releasePointerCapture(M.pointerId),document.body.style.webkitUserSelect=T.current,v.viewport&&(v.viewport.style.scrollBehavior=""),C.current=null})})})}),Dd="ScrollAreaThumb",wR=E.forwardRef((t,e)=>{const{forceMount:n,...s}=t,i=bR(Dd,t.__scopeScrollArea);return S.jsx(Ln,{present:n||i.hasThumb,children:S.jsx(sI,{ref:e,...s})})}),sI=E.forwardRef((t,e)=>{const{__scopeScrollArea:n,style:s,...i}=t,l=Dn(Dd,n),c=bR(Dd,n),{onThumbPositionChange:f}=c,d=We(e,b=>c.onThumbChange(b)),h=E.useRef(void 0),p=uh(()=>{h.current&&(h.current(),h.current=void 0)},100);return E.useEffect(()=>{const b=l.viewport;if(b){const m=()=>{if(p(),!h.current){const v=oI(b,f);h.current=v,f()}};return f(),b.addEventListener("scroll",m),()=>b.removeEventListener("scroll",m)}},[l.viewport,p,f]),S.jsx(Ne.div,{"data-state":c.hasThumb?"visible":"hidden",...i,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...s},onPointerDownCapture:_e(t.onPointerDownCapture,b=>{const v=b.target.getBoundingClientRect(),g=b.clientX-v.left,x=b.clientY-v.top;c.onThumbPointerDown({x:g,y:x})}),onPointerUp:_e(t.onPointerUp,c.onThumbPointerUp)})});wR.displayName=Dd;var Jy="ScrollAreaCorner",SR=E.forwardRef((t,e)=>{const n=Dn(Jy,t.__scopeScrollArea),s=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&s?S.jsx(aI,{...t,ref:e}):null});SR.displayName=Jy;var aI=E.forwardRef((t,e)=>{const{__scopeScrollArea:n,...s}=t,i=Dn(Jy,n),[l,c]=E.useState(0),[f,d]=E.useState(0),h=!!(l&&f);return No(i.scrollbarX,()=>{var b;const p=((b=i.scrollbarX)==null?void 0:b.offsetHeight)||0;i.onCornerHeightChange(p),d(p)}),No(i.scrollbarY,()=>{var b;const p=((b=i.scrollbarY)==null?void 0:b.offsetWidth)||0;i.onCornerWidthChange(p),c(p)}),h?S.jsx(Ne.div,{...s,ref:e,style:{width:l,height:f,position:"absolute",right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null});function jd(t){return t?parseInt(t,10):0}function _R(t,e){const n=t/e;return isNaN(n)?0:n}function lh(t){const e=_R(t.viewport,t.content),n=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=(t.scrollbar.size-n)*e;return Math.max(s,18)}function iI(t,e,n,s="ltr"){const i=lh(n),l=i/2,c=e||l,f=i-c,d=n.scrollbar.paddingStart+c,h=n.scrollbar.size-n.scrollbar.paddingEnd-f,p=n.content-n.viewport,b=s==="ltr"?[0,p]:[p*-1,0];return ER([d,h],b)(t)}function i_(t,e,n="ltr"){const s=lh(e),i=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,l=e.scrollbar.size-i,c=e.content-e.viewport,f=l-s,d=n==="ltr"?[0,c]:[c*-1,0],h=qv(t,d);return ER([0,c],[0,f])(h)}function ER(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const s=(e[1]-e[0])/(t[1]-t[0]);return e[0]+s*(n-t[0])}}function CR(t,e){return t>0&&t<e}var oI=(t,e=()=>{})=>{let n={left:t.scrollLeft,top:t.scrollTop},s=0;return function i(){const l={left:t.scrollLeft,top:t.scrollTop},c=n.left!==l.left,f=n.top!==l.top;(c||f)&&e(),n=l,s=window.requestAnimationFrame(i)}(),()=>window.cancelAnimationFrame(s)};function uh(t,e){const n=pt(t),s=E.useRef(0);return E.useEffect(()=>()=>window.clearTimeout(s.current),[]),E.useCallback(()=>{window.clearTimeout(s.current),s.current=window.setTimeout(n,e)},[n,e])}function No(t,e){const n=pt(e);Tt(()=>{let s=0;if(t){const i=new ResizeObserver(()=>{cancelAnimationFrame(s),s=window.requestAnimationFrame(n)});return i.observe(t),()=>{window.cancelAnimationFrame(s),i.unobserve(t)}}},[t,n])}var TR=mR,lI=vR,uI=SR;const RR=E.forwardRef(({className:t,children:e,...n},s)=>S.jsxs(TR,{ref:s,className:fe("relative overflow-hidden",t),...n,children:[S.jsx(lI,{className:"h-full w-full rounded-[inherit]",children:e}),S.jsx(AR,{}),S.jsx(uI,{})]}));RR.displayName=TR.displayName;const AR=E.forwardRef(({className:t,orientation:e="vertical",...n},s)=>S.jsx(Zy,{ref:s,orientation:e,className:fe("flex touch-none select-none transition-colors",e==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",e==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...n,children:S.jsx(wR,{className:"relative flex-1 rounded-full bg-border"})}));AR.displayName=Zy.displayName;function cI(t){const e=E.useRef({value:t,previous:t});return E.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var fI=[" ","Enter","ArrowUp","ArrowDown"],dI=[" ","Enter"],Yu="Select",[ch,fh,hI]=jy(Yu),[qo,Vz]=Ar(Yu,[hI,$d]),dh=$d(),[pI,pa]=qo(Yu),[mI,gI]=qo(Yu),OR=t=>{const{__scopeSelect:e,children:n,open:s,defaultOpen:i,onOpenChange:l,value:c,defaultValue:f,onValueChange:d,dir:h,name:p,autoComplete:b,disabled:m,required:v,form:g}=t,x=dh(e),[w,C]=E.useState(null),[T,A]=E.useState(null),[R,k]=E.useState(!1),j=Jd(h),[D=!1,F]=ei({prop:s,defaultProp:i,onChange:l}),[M,P]=ei({prop:c,defaultProp:f,onChange:d}),q=E.useRef(null),U=w?g||!!w.closest("form"):!0,[G,I]=E.useState(new Set),L=Array.from(G).map(N=>N.props.value).join(";");return S.jsx(JE,{...x,children:S.jsxs(pI,{required:v,scope:e,trigger:w,onTriggerChange:C,valueNode:T,onValueNodeChange:A,valueNodeHasChildren:R,onValueNodeHasChildrenChange:k,contentId:os(),value:M,onValueChange:P,open:D,onOpenChange:F,dir:j,triggerPointerDownPosRef:q,disabled:m,children:[S.jsx(ch.Provider,{scope:e,children:S.jsx(mI,{scope:t.__scopeSelect,onNativeOptionAdd:E.useCallback(N=>{I(H=>new Set(H).add(N))},[]),onNativeOptionRemove:E.useCallback(N=>{I(H=>{const V=new Set(H);return V.delete(N),V})},[]),children:n})}),U?S.jsxs(eA,{"aria-hidden":!0,required:v,tabIndex:-1,name:p,autoComplete:b,value:M,onChange:N=>P(N.target.value),disabled:m,form:g,children:[M===void 0?S.jsx("option",{value:""}):null,Array.from(G)]},L):null]})})};OR.displayName=Yu;var NR="SelectTrigger",kR=E.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:s=!1,...i}=t,l=dh(n),c=pa(NR,n),f=c.disabled||s,d=We(e,c.onTriggerChange),h=fh(n),p=E.useRef("touch"),[b,m,v]=tA(x=>{const w=h().filter(A=>!A.disabled),C=w.find(A=>A.value===c.value),T=nA(w,x,C);T!==void 0&&c.onValueChange(T.value)}),g=x=>{f||(c.onOpenChange(!0),v()),x&&(c.triggerPointerDownPosRef.current={x:Math.round(x.pageX),y:Math.round(x.pageY)})};return S.jsx(eC,{asChild:!0,...l,children:S.jsx(Ne.button,{type:"button",role:"combobox","aria-controls":c.contentId,"aria-expanded":c.open,"aria-required":c.required,"aria-autocomplete":"none",dir:c.dir,"data-state":c.open?"open":"closed",disabled:f,"data-disabled":f?"":void 0,"data-placeholder":JR(c.value)?"":void 0,...i,ref:d,onClick:_e(i.onClick,x=>{x.currentTarget.focus(),p.current!=="mouse"&&g(x)}),onPointerDown:_e(i.onPointerDown,x=>{p.current=x.pointerType;const w=x.target;w.hasPointerCapture(x.pointerId)&&w.releasePointerCapture(x.pointerId),x.button===0&&x.ctrlKey===!1&&x.pointerType==="mouse"&&(g(x),x.preventDefault())}),onKeyDown:_e(i.onKeyDown,x=>{const w=b.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&m(x.key),!(w&&x.key===" ")&&fI.includes(x.key)&&(g(),x.preventDefault())})})})});kR.displayName=NR;var MR="SelectValue",LR=E.forwardRef((t,e)=>{const{__scopeSelect:n,className:s,style:i,children:l,placeholder:c="",...f}=t,d=pa(MR,n),{onValueNodeHasChildrenChange:h}=d,p=l!==void 0,b=We(e,d.onValueNodeChange);return Tt(()=>{h(p)},[h,p]),S.jsx(Ne.span,{...f,ref:b,style:{pointerEvents:"none"},children:JR(d.value)?S.jsx(S.Fragment,{children:c}):l})});LR.displayName=MR;var vI="SelectIcon",DR=E.forwardRef((t,e)=>{const{__scopeSelect:n,children:s,...i}=t;return S.jsx(Ne.span,{"aria-hidden":!0,...i,ref:e,children:s||"▼"})});DR.displayName=vI;var yI="SelectPortal",jR=t=>S.jsx(ju,{asChild:!0,...t});jR.displayName=yI;var li="SelectContent",PR=E.forwardRef((t,e)=>{const n=pa(li,t.__scopeSelect),[s,i]=E.useState();if(Tt(()=>{i(new DocumentFragment)},[]),!n.open){const l=s;return l?Mo.createPortal(S.jsx(IR,{scope:t.__scopeSelect,children:S.jsx(ch.Slot,{scope:t.__scopeSelect,children:S.jsx("div",{children:t.children})})}),l):null}return S.jsx(BR,{...t,ref:e})});PR.displayName=li;var Un=10,[IR,ma]=qo(li),bI="SelectContentImpl",BR=E.forwardRef((t,e)=>{const{__scopeSelect:n,position:s="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:l,onPointerDownOutside:c,side:f,sideOffset:d,align:h,alignOffset:p,arrowPadding:b,collisionBoundary:m,collisionPadding:v,sticky:g,hideWhenDetached:x,avoidCollisions:w,...C}=t,T=pa(li,n),[A,R]=E.useState(null),[k,j]=E.useState(null),D=We(e,he=>R(he)),[F,M]=E.useState(null),[P,q]=E.useState(null),U=fh(n),[G,I]=E.useState(!1),L=E.useRef(!1);E.useEffect(()=>{if(A)return aE(A)},[A]),K_();const N=E.useCallback(he=>{const[ve,...Ae]=U().map(ke=>ke.ref.current),[de]=Ae.slice(-1),Se=document.activeElement;for(const ke of he)if(ke===Se||(ke==null||ke.scrollIntoView({block:"nearest"}),ke===ve&&k&&(k.scrollTop=0),ke===de&&k&&(k.scrollTop=k.scrollHeight),ke==null||ke.focus(),document.activeElement!==Se))return},[U,k]),H=E.useCallback(()=>N([F,A]),[N,F,A]);E.useEffect(()=>{G&&H()},[G,H]);const{onOpenChange:V,triggerPointerDownPosRef:Q}=T;E.useEffect(()=>{if(A){let he={x:0,y:0};const ve=de=>{var Se,ke;he={x:Math.abs(Math.round(de.pageX)-(((Se=Q.current)==null?void 0:Se.x)??0)),y:Math.abs(Math.round(de.pageY)-(((ke=Q.current)==null?void 0:ke.y)??0))}},Ae=de=>{he.x<=10&&he.y<=10?de.preventDefault():A.contains(de.target)||V(!1),document.removeEventListener("pointermove",ve),Q.current=null};return Q.current!==null&&(document.addEventListener("pointermove",ve),document.addEventListener("pointerup",Ae,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ve),document.removeEventListener("pointerup",Ae,{capture:!0})}}},[A,V,Q]),E.useEffect(()=>{const he=()=>V(!1);return window.addEventListener("blur",he),window.addEventListener("resize",he),()=>{window.removeEventListener("blur",he),window.removeEventListener("resize",he)}},[V]);const[z,Z]=tA(he=>{const ve=U().filter(Se=>!Se.disabled),Ae=ve.find(Se=>Se.ref.current===document.activeElement),de=nA(ve,he,Ae);de&&setTimeout(()=>de.ref.current.focus())}),ne=E.useCallback((he,ve,Ae)=>{const de=!L.current&&!Ae;(T.value!==void 0&&T.value===ve||de)&&(M(he),de&&(L.current=!0))},[T.value]),se=E.useCallback(()=>A==null?void 0:A.focus(),[A]),J=E.useCallback((he,ve,Ae)=>{const de=!L.current&&!Ae;(T.value!==void 0&&T.value===ve||de)&&q(he)},[T.value]),ce=s==="popper"?Uv:zR,ye=ce===Uv?{side:f,sideOffset:d,align:h,alignOffset:p,arrowPadding:b,collisionBoundary:m,collisionPadding:v,sticky:g,hideWhenDetached:x,avoidCollisions:w}:{};return S.jsx(IR,{scope:n,content:A,viewport:k,onViewportChange:j,itemRefCallback:ne,selectedItem:F,onItemLeave:se,itemTextRefCallback:J,focusSelectedItem:H,selectedItemText:P,position:s,isPositioned:G,searchRef:z,children:S.jsx(ly,{as:Mn,allowPinchZoom:!0,children:S.jsx(oy,{asChild:!0,trapped:T.open,onMountAutoFocus:he=>{he.preventDefault()},onUnmountAutoFocus:_e(i,he=>{var ve;(ve=T.trigger)==null||ve.focus({preventScroll:!0}),he.preventDefault()}),children:S.jsx(Du,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:he=>he.preventDefault(),onDismiss:()=>T.onOpenChange(!1),children:S.jsx(ce,{role:"listbox",id:T.contentId,"data-state":T.open?"open":"closed",dir:T.dir,onContextMenu:he=>he.preventDefault(),...C,...ye,onPlaced:()=>I(!0),ref:D,style:{display:"flex",flexDirection:"column",outline:"none",...C.style},onKeyDown:_e(C.onKeyDown,he=>{const ve=he.ctrlKey||he.altKey||he.metaKey;if(he.key==="Tab"&&he.preventDefault(),!ve&&he.key.length===1&&Z(he.key),["ArrowUp","ArrowDown","Home","End"].includes(he.key)){let de=U().filter(Se=>!Se.disabled).map(Se=>Se.ref.current);if(["ArrowUp","End"].includes(he.key)&&(de=de.slice().reverse()),["ArrowUp","ArrowDown"].includes(he.key)){const Se=he.target,ke=de.indexOf(Se);de=de.slice(ke+1)}setTimeout(()=>N(de)),he.preventDefault()}})})})})})})});BR.displayName=bI;var xI="SelectItemAlignedPosition",zR=E.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:s,...i}=t,l=pa(li,n),c=ma(li,n),[f,d]=E.useState(null),[h,p]=E.useState(null),b=We(e,D=>p(D)),m=fh(n),v=E.useRef(!1),g=E.useRef(!0),{viewport:x,selectedItem:w,selectedItemText:C,focusSelectedItem:T}=c,A=E.useCallback(()=>{if(l.trigger&&l.valueNode&&f&&h&&x&&w&&C){const D=l.trigger.getBoundingClientRect(),F=h.getBoundingClientRect(),M=l.valueNode.getBoundingClientRect(),P=C.getBoundingClientRect();if(l.dir!=="rtl"){const Se=P.left-F.left,ke=M.left-Se,Ke=D.left-ke,vt=D.width+Ke,nn=Math.max(vt,F.width),Ut=window.innerWidth-Un,Ht=qv(ke,[Un,Math.max(Un,Ut-nn)]);f.style.minWidth=vt+"px",f.style.left=Ht+"px"}else{const Se=F.right-P.right,ke=window.innerWidth-M.right-Se,Ke=window.innerWidth-D.right-ke,vt=D.width+Ke,nn=Math.max(vt,F.width),Ut=window.innerWidth-Un,Ht=qv(ke,[Un,Math.max(Un,Ut-nn)]);f.style.minWidth=vt+"px",f.style.right=Ht+"px"}const q=m(),U=window.innerHeight-Un*2,G=x.scrollHeight,I=window.getComputedStyle(h),L=parseInt(I.borderTopWidth,10),N=parseInt(I.paddingTop,10),H=parseInt(I.borderBottomWidth,10),V=parseInt(I.paddingBottom,10),Q=L+N+G+V+H,z=Math.min(w.offsetHeight*5,Q),Z=window.getComputedStyle(x),ne=parseInt(Z.paddingTop,10),se=parseInt(Z.paddingBottom,10),J=D.top+D.height/2-Un,ce=U-J,ye=w.offsetHeight/2,he=w.offsetTop+ye,ve=L+N+he,Ae=Q-ve;if(ve<=J){const Se=q.length>0&&w===q[q.length-1].ref.current;f.style.bottom="0px";const ke=h.clientHeight-x.offsetTop-x.offsetHeight,Ke=Math.max(ce,ye+(Se?se:0)+ke+H),vt=ve+Ke;f.style.height=vt+"px"}else{const Se=q.length>0&&w===q[0].ref.current;f.style.top="0px";const Ke=Math.max(J,L+x.offsetTop+(Se?ne:0)+ye)+Ae;f.style.height=Ke+"px",x.scrollTop=ve-J+x.offsetTop}f.style.margin=`${Un}px 0`,f.style.minHeight=z+"px",f.style.maxHeight=U+"px",s==null||s(),requestAnimationFrame(()=>v.current=!0)}},[m,l.trigger,l.valueNode,f,h,x,w,C,l.dir,s]);Tt(()=>A(),[A]);const[R,k]=E.useState();Tt(()=>{h&&k(window.getComputedStyle(h).zIndex)},[h]);const j=E.useCallback(D=>{D&&g.current===!0&&(A(),T==null||T(),g.current=!1)},[A,T]);return S.jsx(SI,{scope:n,contentWrapper:f,shouldExpandOnScrollRef:v,onScrollButtonChange:j,children:S.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:R},children:S.jsx(Ne.div,{...i,ref:b,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});zR.displayName=xI;var wI="SelectPopperPosition",Uv=E.forwardRef((t,e)=>{const{__scopeSelect:n,align:s="start",collisionPadding:i=Un,...l}=t,c=dh(n);return S.jsx(tC,{...c,...l,ref:e,align:s,collisionPadding:i,style:{boxSizing:"border-box",...l.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Uv.displayName=wI;var[SI,e0]=qo(li,{}),Hv="SelectViewport",qR=E.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:s,...i}=t,l=ma(Hv,n),c=e0(Hv,n),f=We(e,l.onViewportChange),d=E.useRef(0);return S.jsxs(S.Fragment,{children:[S.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),S.jsx(ch.Slot,{scope:n,children:S.jsx(Ne.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:f,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:_e(i.onScroll,h=>{const p=h.currentTarget,{contentWrapper:b,shouldExpandOnScrollRef:m}=c;if(m!=null&&m.current&&b){const v=Math.abs(d.current-p.scrollTop);if(v>0){const g=window.innerHeight-Un*2,x=parseFloat(b.style.minHeight),w=parseFloat(b.style.height),C=Math.max(x,w);if(C<g){const T=C+v,A=Math.min(g,T),R=T-A;b.style.height=A+"px",b.style.bottom==="0px"&&(p.scrollTop=R>0?R:0,b.style.justifyContent="flex-end")}}}d.current=p.scrollTop})})})]})});qR.displayName=Hv;var UR="SelectGroup",[_I,EI]=qo(UR),CI=E.forwardRef((t,e)=>{const{__scopeSelect:n,...s}=t,i=os();return S.jsx(_I,{scope:n,id:i,children:S.jsx(Ne.div,{role:"group","aria-labelledby":i,...s,ref:e})})});CI.displayName=UR;var HR="SelectLabel",FR=E.forwardRef((t,e)=>{const{__scopeSelect:n,...s}=t,i=EI(HR,n);return S.jsx(Ne.div,{id:i.id,...s,ref:e})});FR.displayName=HR;var Pd="SelectItem",[TI,VR]=qo(Pd),$R=E.forwardRef((t,e)=>{const{__scopeSelect:n,value:s,disabled:i=!1,textValue:l,...c}=t,f=pa(Pd,n),d=ma(Pd,n),h=f.value===s,[p,b]=E.useState(l??""),[m,v]=E.useState(!1),g=We(e,T=>{var A;return(A=d.itemRefCallback)==null?void 0:A.call(d,T,s,i)}),x=os(),w=E.useRef("touch"),C=()=>{i||(f.onValueChange(s),f.onOpenChange(!1))};if(s==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return S.jsx(TI,{scope:n,value:s,disabled:i,textId:x,isSelected:h,onItemTextChange:E.useCallback(T=>{b(A=>A||((T==null?void 0:T.textContent)??"").trim())},[]),children:S.jsx(ch.ItemSlot,{scope:n,value:s,disabled:i,textValue:p,children:S.jsx(Ne.div,{role:"option","aria-labelledby":x,"data-highlighted":m?"":void 0,"aria-selected":h&&m,"data-state":h?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...c,ref:g,onFocus:_e(c.onFocus,()=>v(!0)),onBlur:_e(c.onBlur,()=>v(!1)),onClick:_e(c.onClick,()=>{w.current!=="mouse"&&C()}),onPointerUp:_e(c.onPointerUp,()=>{w.current==="mouse"&&C()}),onPointerDown:_e(c.onPointerDown,T=>{w.current=T.pointerType}),onPointerMove:_e(c.onPointerMove,T=>{var A;w.current=T.pointerType,i?(A=d.onItemLeave)==null||A.call(d):w.current==="mouse"&&T.currentTarget.focus({preventScroll:!0})}),onPointerLeave:_e(c.onPointerLeave,T=>{var A;T.currentTarget===document.activeElement&&((A=d.onItemLeave)==null||A.call(d))}),onKeyDown:_e(c.onKeyDown,T=>{var R;((R=d.searchRef)==null?void 0:R.current)!==""&&T.key===" "||(dI.includes(T.key)&&C(),T.key===" "&&T.preventDefault())})})})})});$R.displayName=Pd;var au="SelectItemText",GR=E.forwardRef((t,e)=>{const{__scopeSelect:n,className:s,style:i,...l}=t,c=pa(au,n),f=ma(au,n),d=VR(au,n),h=gI(au,n),[p,b]=E.useState(null),m=We(e,C=>b(C),d.onItemTextChange,C=>{var T;return(T=f.itemTextRefCallback)==null?void 0:T.call(f,C,d.value,d.disabled)}),v=p==null?void 0:p.textContent,g=E.useMemo(()=>S.jsx("option",{value:d.value,disabled:d.disabled,children:v},d.value),[d.disabled,d.value,v]),{onNativeOptionAdd:x,onNativeOptionRemove:w}=h;return Tt(()=>(x(g),()=>w(g)),[x,w,g]),S.jsxs(S.Fragment,{children:[S.jsx(Ne.span,{id:d.textId,...l,ref:m}),d.isSelected&&c.valueNode&&!c.valueNodeHasChildren?Mo.createPortal(l.children,c.valueNode):null]})});GR.displayName=au;var YR="SelectItemIndicator",QR=E.forwardRef((t,e)=>{const{__scopeSelect:n,...s}=t;return VR(YR,n).isSelected?S.jsx(Ne.span,{"aria-hidden":!0,...s,ref:e}):null});QR.displayName=YR;var Fv="SelectScrollUpButton",WR=E.forwardRef((t,e)=>{const n=ma(Fv,t.__scopeSelect),s=e0(Fv,t.__scopeSelect),[i,l]=E.useState(!1),c=We(e,s.onScrollButtonChange);return Tt(()=>{if(n.viewport&&n.isPositioned){let f=function(){const h=d.scrollTop>0;l(h)};const d=n.viewport;return f(),d.addEventListener("scroll",f),()=>d.removeEventListener("scroll",f)}},[n.viewport,n.isPositioned]),i?S.jsx(ZR,{...t,ref:c,onAutoScroll:()=>{const{viewport:f,selectedItem:d}=n;f&&d&&(f.scrollTop=f.scrollTop-d.offsetHeight)}}):null});WR.displayName=Fv;var Vv="SelectScrollDownButton",KR=E.forwardRef((t,e)=>{const n=ma(Vv,t.__scopeSelect),s=e0(Vv,t.__scopeSelect),[i,l]=E.useState(!1),c=We(e,s.onScrollButtonChange);return Tt(()=>{if(n.viewport&&n.isPositioned){let f=function(){const h=d.scrollHeight-d.clientHeight,p=Math.ceil(d.scrollTop)<h;l(p)};const d=n.viewport;return f(),d.addEventListener("scroll",f),()=>d.removeEventListener("scroll",f)}},[n.viewport,n.isPositioned]),i?S.jsx(ZR,{...t,ref:c,onAutoScroll:()=>{const{viewport:f,selectedItem:d}=n;f&&d&&(f.scrollTop=f.scrollTop+d.offsetHeight)}}):null});KR.displayName=Vv;var ZR=E.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:s,...i}=t,l=ma("SelectScrollButton",n),c=E.useRef(null),f=fh(n),d=E.useCallback(()=>{c.current!==null&&(window.clearInterval(c.current),c.current=null)},[]);return E.useEffect(()=>()=>d(),[d]),Tt(()=>{var p;const h=f().find(b=>b.ref.current===document.activeElement);(p=h==null?void 0:h.ref.current)==null||p.scrollIntoView({block:"nearest"})},[f]),S.jsx(Ne.div,{"aria-hidden":!0,...i,ref:e,style:{flexShrink:0,...i.style},onPointerDown:_e(i.onPointerDown,()=>{c.current===null&&(c.current=window.setInterval(s,50))}),onPointerMove:_e(i.onPointerMove,()=>{var h;(h=l.onItemLeave)==null||h.call(l),c.current===null&&(c.current=window.setInterval(s,50))}),onPointerLeave:_e(i.onPointerLeave,()=>{d()})})}),RI="SelectSeparator",XR=E.forwardRef((t,e)=>{const{__scopeSelect:n,...s}=t;return S.jsx(Ne.div,{"aria-hidden":!0,...s,ref:e})});XR.displayName=RI;var $v="SelectArrow",AI=E.forwardRef((t,e)=>{const{__scopeSelect:n,...s}=t,i=dh(n),l=pa($v,n),c=ma($v,n);return l.open&&c.position==="popper"?S.jsx(nC,{...i,...s,ref:e}):null});AI.displayName=$v;function JR(t){return t===""||t===void 0}var eA=E.forwardRef((t,e)=>{const{value:n,...s}=t,i=E.useRef(null),l=We(e,i),c=cI(n);return E.useEffect(()=>{const f=i.current,d=window.HTMLSelectElement.prototype,p=Object.getOwnPropertyDescriptor(d,"value").set;if(c!==n&&p){const b=new Event("change",{bubbles:!0});p.call(f,n),f.dispatchEvent(b)}},[c,n]),S.jsx(Iu,{asChild:!0,children:S.jsx("select",{...s,ref:l,defaultValue:n})})});eA.displayName="BubbleSelect";function tA(t){const e=pt(t),n=E.useRef(""),s=E.useRef(0),i=E.useCallback(c=>{const f=n.current+c;e(f),function d(h){n.current=h,window.clearTimeout(s.current),h!==""&&(s.current=window.setTimeout(()=>d(""),1e3))}(f)},[e]),l=E.useCallback(()=>{n.current="",window.clearTimeout(s.current)},[]);return E.useEffect(()=>()=>window.clearTimeout(s.current),[]),[n,i,l]}function nA(t,e,n){const i=e.length>1&&Array.from(e).every(h=>h===e[0])?e[0]:e,l=n?t.indexOf(n):-1;let c=OI(t,Math.max(l,0));i.length===1&&(c=c.filter(h=>h!==n));const d=c.find(h=>h.textValue.toLowerCase().startsWith(i.toLowerCase()));return d!==n?d:void 0}function OI(t,e){return t.map((n,s)=>t[(e+s)%t.length])}var NI=OR,rA=kR,kI=LR,MI=DR,LI=jR,sA=PR,DI=qR,aA=FR,iA=$R,jI=GR,PI=QR,oA=WR,lA=KR,uA=XR;const o_=NI,l_=kI,Gv=E.forwardRef(({className:t,children:e,...n},s)=>S.jsxs(rA,{ref:s,className:fe("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...n,children:[e,S.jsx(MI,{asChild:!0,children:S.jsx(RE,{className:"h-4 w-4 opacity-50"})})]}));Gv.displayName=rA.displayName;const cA=E.forwardRef(({className:t,...e},n)=>S.jsx(oA,{ref:n,className:fe("flex cursor-default items-center justify-center py-1",t),...e,children:S.jsx(xM,{className:"h-4 w-4"})}));cA.displayName=oA.displayName;const fA=E.forwardRef(({className:t,...e},n)=>S.jsx(lA,{ref:n,className:fe("flex cursor-default items-center justify-center py-1",t),...e,children:S.jsx(RE,{className:"h-4 w-4"})}));fA.displayName=lA.displayName;const Yv=E.forwardRef(({className:t,children:e,position:n="popper",...s},i)=>S.jsx(LI,{children:S.jsxs(sA,{ref:i,className:fe("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:n,...s,children:[S.jsx(cA,{}),S.jsx(DI,{className:fe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:e}),S.jsx(fA,{})]})}));Yv.displayName=sA.displayName;const II=E.forwardRef(({className:t,...e},n)=>S.jsx(aA,{ref:n,className:fe("px-2 py-1.5 text-sm font-semibold",t),...e}));II.displayName=aA.displayName;const iu=E.forwardRef(({className:t,children:e,...n},s)=>S.jsxs(iA,{ref:s,className:fe("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...n,children:[S.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:S.jsx(PI,{children:S.jsx(hy,{className:"h-4 w-4"})})}),S.jsx(jI,{children:e})]}));iu.displayName=iA.displayName;const BI=E.forwardRef(({className:t,...e},n)=>S.jsx(uA,{ref:n,className:fe("-mx-1 my-1 h-px bg-muted",t),...e}));BI.displayName=uA.displayName;const zI={10:"TRACE",20:"DEBUG",27:"SUCCESS",28:"PROGRESS",29:"LOG",30:"INFO",40:"WARN",50:"ERROR",60:"FATAL"},qI={10:"text-gray-400",20:"text-blue-400",27:"text-green-600",28:"text-purple-400",29:"text-gray-300",30:"text-emerald-400",40:"text-yellow-400",50:"text-red-400",60:"text-red-600"};function dA({agentName:t,level:e,hideTitle:n}={}){var D,F;const[s,i]=E.useState(e||"all"),[l,c]=E.useState(t||"all"),[f,d]=E.useState(!0),h=E.useRef(null),p=E.useRef(!1),b=E.useRef(""),{data:m,error:v,isLoading:g}=da({queryKey:["logs",s,l],queryFn:()=>kt.getLogs({level:s==="all"?"":s,agentName:l==="all"?void 0:l}),refetchInterval:1e3,staleTime:1e3}),{data:x}=qy(),w=((F=(D=x==null?void 0:x.data)==null?void 0:D.agents)==null?void 0:F.map(M=>M.name))??[],C=()=>{if(!h.current)return;const M=h.current,P=M.scrollHeight,q=M.clientHeight;M.scrollTo({top:P-q,behavior:"instant"})};E.useEffect(()=>{var q;if(!((q=m==null?void 0:m.logs)!=null&&q.length))return;const M=m.logs[m.logs.length-1],P=`${M.time}-${M.msg}`;f&&P!==b.current&&(setTimeout(C,0),b.current=P)},[m==null?void 0:m.logs,f]);const T=M=>{if(p.current)return;const{scrollTop:P,scrollHeight:q,clientHeight:U}=M.currentTarget,I=q-(P+U)<100;d(I),p.current=!0,setTimeout(()=>{p.current=!1},150)},A=()=>{d(!0),C()};E.useEffect(()=>{setTimeout(C,100)},[m==null?void 0:m.logs]);const R=M=>zI[M]||"UNKNOWN",k=M=>qI[M]||"text-gray-400",j=M=>{const P=W9(M.time,"yyyy-MM-dd HH:mm:ss"),q=R(M.level),U=Object.entries(M).filter(([I])=>!Number.isNaN(Number(I))).sort((I,L)=>Number(I[0])-Number(L[0])),G=U.length>0?`
|
|
334
334
|
${U.map(([I,L])=>L).join(`
|
|
335
335
|
`)}`:"";return S.jsxs("div",{className:"whitespace-pre-wrap font-mono",children:[S.jsxs("span",{className:"text-gray-500",children:["[",P,"]"]})," ",M.agentName&&S.jsxs("span",{className:"text-gray-500",children:["[",M.agentName,"]"]})," ",S.jsxs("span",{className:k(M.level),children:[q,":"]})," ",S.jsx("span",{className:"text-white",children:M.msg}),S.jsx("span",{className:"text-gray-300",children:G})]},`${M.time}-${M.msg}`)};return S.jsxs("div",{className:"p-4",children:[S.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[!n&&S.jsx(hR,{title:"System Logs"}),S.jsxs("div",{className:"flex items-center gap-4",children:[!f&&S.jsx("button",{type:"button",onClick:A,className:"text-xs text-gray-400 hover:text-white transition-colors",children:"Resume auto-scroll"}),S.jsxs(o_,{value:s,onValueChange:i,children:[S.jsx(Gv,{className:"w-32",children:S.jsx(l_,{placeholder:"Select level"})}),S.jsxs(Yv,{children:[S.jsx(iu,{value:"all",children:"ALL"}),m==null?void 0:m.levels.map(M=>S.jsx(iu,{value:M,children:M.toUpperCase()},M))]})]}),w&&w.length>0&&!t&&S.jsxs(o_,{value:l,onValueChange:c,children:[S.jsx(Gv,{className:"w-40",children:S.jsx(l_,{placeholder:"Filter by agent"})}),S.jsxs(Yv,{children:[S.jsx(iu,{value:"all",children:"ALL AGENTS"}),w.map(M=>S.jsx(iu,{value:M,children:M},M))]})]})]})]}),g?S.jsx("div",{className:"font-mono p-4",children:"Loading logs..."}):v?S.jsx("div",{className:"text-red-500 font-mono p-4",children:v instanceof Error?v.message:"Failed to fetch logs"}):S.jsx(RR,{className:"h-[600px] rounded-md border bg-black",children:S.jsx("div",{ref:h,onScroll:T,className:"p-4 text-sm space-y-1 h-full overflow-auto",children:(m==null?void 0:m.logs.length)===0?S.jsxs("div",{className:"text-gray-500 font-mono",children:["No ",s==="all"?"":s.toUpperCase()," ","logs found"]}):m==null?void 0:m.logs.map(M=>j(M))})})]})}var t0="ToastProvider",[n0,UI,HI]=jy("Toast"),[hA,$z]=Ar("Toast",[HI]),[FI,hh]=hA(t0),pA=t=>{const{__scopeToast:e,label:n="Notification",duration:s=5e3,swipeDirection:i="right",swipeThreshold:l=50,children:c}=t,[f,d]=E.useState(null),[h,p]=E.useState(0),b=E.useRef(!1),m=E.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${t0}\`. Expected non-empty \`string\`.`),S.jsx(n0.Provider,{scope:e,children:S.jsx(FI,{scope:e,label:n,duration:s,swipeDirection:i,swipeThreshold:l,toastCount:h,viewport:f,onViewportChange:d,onToastAdd:E.useCallback(()=>p(v=>v+1),[]),onToastRemove:E.useCallback(()=>p(v=>v-1),[]),isFocusedToastEscapeKeyDownRef:b,isClosePausedRef:m,children:c})})};pA.displayName=t0;var mA="ToastViewport",VI=["F8"],Qv="toast.viewportPause",Wv="toast.viewportResume",gA=E.forwardRef((t,e)=>{const{__scopeToast:n,hotkey:s=VI,label:i="Notifications ({hotkey})",...l}=t,c=hh(mA,n),f=UI(n),d=E.useRef(null),h=E.useRef(null),p=E.useRef(null),b=E.useRef(null),m=We(e,b,c.onViewportChange),v=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),g=c.toastCount>0;E.useEffect(()=>{const w=C=>{var A;s.length!==0&&s.every(R=>C[R]||C.code===R)&&((A=b.current)==null||A.focus())};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[s]),E.useEffect(()=>{const w=d.current,C=b.current;if(g&&w&&C){const T=()=>{if(!c.isClosePausedRef.current){const j=new CustomEvent(Qv);C.dispatchEvent(j),c.isClosePausedRef.current=!0}},A=()=>{if(c.isClosePausedRef.current){const j=new CustomEvent(Wv);C.dispatchEvent(j),c.isClosePausedRef.current=!1}},R=j=>{!w.contains(j.relatedTarget)&&A()},k=()=>{w.contains(document.activeElement)||A()};return w.addEventListener("focusin",T),w.addEventListener("focusout",R),w.addEventListener("pointermove",T),w.addEventListener("pointerleave",k),window.addEventListener("blur",T),window.addEventListener("focus",A),()=>{w.removeEventListener("focusin",T),w.removeEventListener("focusout",R),w.removeEventListener("pointermove",T),w.removeEventListener("pointerleave",k),window.removeEventListener("blur",T),window.removeEventListener("focus",A)}}},[g,c.isClosePausedRef]);const x=E.useCallback(({tabbingDirection:w})=>{const T=f().map(A=>{const R=A.ref.current,k=[R,...rB(R)];return w==="forwards"?k:k.reverse()});return(w==="forwards"?T.reverse():T).flat()},[f]);return E.useEffect(()=>{const w=b.current;if(w){const C=T=>{var k,j,D;const A=T.altKey||T.ctrlKey||T.metaKey;if(T.key==="Tab"&&!A){const F=document.activeElement,M=T.shiftKey;if(T.target===w&&M){(k=h.current)==null||k.focus();return}const U=x({tabbingDirection:M?"backwards":"forwards"}),G=U.findIndex(I=>I===F);rv(U.slice(G+1))?T.preventDefault():M?(j=h.current)==null||j.focus():(D=p.current)==null||D.focus()}};return w.addEventListener("keydown",C),()=>w.removeEventListener("keydown",C)}},[f,x]),S.jsxs(lk,{ref:d,role:"region","aria-label":i.replace("{hotkey}",v),tabIndex:-1,style:{pointerEvents:g?void 0:"none"},children:[g&&S.jsx(Kv,{ref:h,onFocusFromOutsideViewport:()=>{const w=x({tabbingDirection:"forwards"});rv(w)}}),S.jsx(n0.Slot,{scope:n,children:S.jsx(Ne.ol,{tabIndex:-1,...l,ref:m})}),g&&S.jsx(Kv,{ref:p,onFocusFromOutsideViewport:()=>{const w=x({tabbingDirection:"backwards"});rv(w)}})]})});gA.displayName=mA;var vA="ToastFocusProxy",Kv=E.forwardRef((t,e)=>{const{__scopeToast:n,onFocusFromOutsideViewport:s,...i}=t,l=hh(vA,n);return S.jsx(Iu,{"aria-hidden":!0,tabIndex:0,...i,ref:e,style:{position:"fixed"},onFocus:c=>{var h;const f=c.relatedTarget;!((h=l.viewport)!=null&&h.contains(f))&&s()}})});Kv.displayName=vA;var ph="Toast",$I="toast.swipeStart",GI="toast.swipeMove",YI="toast.swipeCancel",QI="toast.swipeEnd",yA=E.forwardRef((t,e)=>{const{forceMount:n,open:s,defaultOpen:i,onOpenChange:l,...c}=t,[f=!0,d]=ei({prop:s,defaultProp:i,onChange:l});return S.jsx(Ln,{present:n||f,children:S.jsx(ZI,{open:f,...c,ref:e,onClose:()=>d(!1),onPause:pt(t.onPause),onResume:pt(t.onResume),onSwipeStart:_e(t.onSwipeStart,h=>{h.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:_e(t.onSwipeMove,h=>{const{x:p,y:b}=h.detail.delta;h.currentTarget.setAttribute("data-swipe","move"),h.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${p}px`),h.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${b}px`)}),onSwipeCancel:_e(t.onSwipeCancel,h=>{h.currentTarget.setAttribute("data-swipe","cancel"),h.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),h.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),h.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),h.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:_e(t.onSwipeEnd,h=>{const{x:p,y:b}=h.detail.delta;h.currentTarget.setAttribute("data-swipe","end"),h.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),h.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),h.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${p}px`),h.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${b}px`),d(!1)})})})});yA.displayName=ph;var[WI,KI]=hA(ph,{onClose(){}}),ZI=E.forwardRef((t,e)=>{const{__scopeToast:n,type:s="foreground",duration:i,open:l,onClose:c,onEscapeKeyDown:f,onPause:d,onResume:h,onSwipeStart:p,onSwipeMove:b,onSwipeCancel:m,onSwipeEnd:v,...g}=t,x=hh(ph,n),[w,C]=E.useState(null),T=We(e,I=>C(I)),A=E.useRef(null),R=E.useRef(null),k=i||x.duration,j=E.useRef(0),D=E.useRef(k),F=E.useRef(0),{onToastAdd:M,onToastRemove:P}=x,q=pt(()=>{var L;(w==null?void 0:w.contains(document.activeElement))&&((L=x.viewport)==null||L.focus()),c()}),U=E.useCallback(I=>{!I||I===1/0||(window.clearTimeout(F.current),j.current=new Date().getTime(),F.current=window.setTimeout(q,I))},[q]);E.useEffect(()=>{const I=x.viewport;if(I){const L=()=>{U(D.current),h==null||h()},N=()=>{const H=new Date().getTime()-j.current;D.current=D.current-H,window.clearTimeout(F.current),d==null||d()};return I.addEventListener(Qv,N),I.addEventListener(Wv,L),()=>{I.removeEventListener(Qv,N),I.removeEventListener(Wv,L)}}},[x.viewport,k,d,h,U]),E.useEffect(()=>{l&&!x.isClosePausedRef.current&&U(k)},[l,k,x.isClosePausedRef,U]),E.useEffect(()=>(M(),()=>P()),[M,P]);const G=E.useMemo(()=>w?CA(w):null,[w]);return x.viewport?S.jsxs(S.Fragment,{children:[G&&S.jsx(XI,{__scopeToast:n,role:"status","aria-live":s==="foreground"?"assertive":"polite","aria-atomic":!0,children:G}),S.jsx(WI,{scope:n,onClose:q,children:Mo.createPortal(S.jsx(n0.ItemSlot,{scope:n,children:S.jsx(ok,{asChild:!0,onEscapeKeyDown:_e(f,()=>{x.isFocusedToastEscapeKeyDownRef.current||q(),x.isFocusedToastEscapeKeyDownRef.current=!1}),children:S.jsx(Ne.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":l?"open":"closed","data-swipe-direction":x.swipeDirection,...g,ref:T,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:_e(t.onKeyDown,I=>{I.key==="Escape"&&(f==null||f(I.nativeEvent),I.nativeEvent.defaultPrevented||(x.isFocusedToastEscapeKeyDownRef.current=!0,q()))}),onPointerDown:_e(t.onPointerDown,I=>{I.button===0&&(A.current={x:I.clientX,y:I.clientY})}),onPointerMove:_e(t.onPointerMove,I=>{if(!A.current)return;const L=I.clientX-A.current.x,N=I.clientY-A.current.y,H=!!R.current,V=["left","right"].includes(x.swipeDirection),Q=["left","up"].includes(x.swipeDirection)?Math.min:Math.max,z=V?Q(0,L):0,Z=V?0:Q(0,N),ne=I.pointerType==="touch"?10:2,se={x:z,y:Z},J={originalEvent:I,delta:se};H?(R.current=se,$f(GI,b,J,{discrete:!1})):u_(se,x.swipeDirection,ne)?(R.current=se,$f($I,p,J,{discrete:!1}),I.target.setPointerCapture(I.pointerId)):(Math.abs(L)>ne||Math.abs(N)>ne)&&(A.current=null)}),onPointerUp:_e(t.onPointerUp,I=>{const L=R.current,N=I.target;if(N.hasPointerCapture(I.pointerId)&&N.releasePointerCapture(I.pointerId),R.current=null,A.current=null,L){const H=I.currentTarget,V={originalEvent:I,delta:L};u_(L,x.swipeDirection,x.swipeThreshold)?$f(QI,v,V,{discrete:!0}):$f(YI,m,V,{discrete:!0}),H.addEventListener("click",Q=>Q.preventDefault(),{once:!0})}})})})}),x.viewport)})]}):null}),XI=t=>{const{__scopeToast:e,children:n,...s}=t,i=hh(ph,e),[l,c]=E.useState(!1),[f,d]=E.useState(!1);return tB(()=>c(!0)),E.useEffect(()=>{const h=window.setTimeout(()=>d(!0),1e3);return()=>window.clearTimeout(h)},[]),f?null:S.jsx(ju,{asChild:!0,children:S.jsx(Iu,{...s,children:l&&S.jsxs(S.Fragment,{children:[i.label," ",n]})})})},JI="ToastTitle",bA=E.forwardRef((t,e)=>{const{__scopeToast:n,...s}=t;return S.jsx(Ne.div,{...s,ref:e})});bA.displayName=JI;var eB="ToastDescription",xA=E.forwardRef((t,e)=>{const{__scopeToast:n,...s}=t;return S.jsx(Ne.div,{...s,ref:e})});xA.displayName=eB;var wA="ToastAction",SA=E.forwardRef((t,e)=>{const{altText:n,...s}=t;return n.trim()?S.jsx(EA,{altText:n,asChild:!0,children:S.jsx(r0,{...s,ref:e})}):(console.error(`Invalid prop \`altText\` supplied to \`${wA}\`. Expected non-empty \`string\`.`),null)});SA.displayName=wA;var _A="ToastClose",r0=E.forwardRef((t,e)=>{const{__scopeToast:n,...s}=t,i=KI(_A,n);return S.jsx(EA,{asChild:!0,children:S.jsx(Ne.button,{type:"button",...s,ref:e,onClick:_e(t.onClick,i.onClose)})})});r0.displayName=_A;var EA=E.forwardRef((t,e)=>{const{__scopeToast:n,altText:s,...i}=t;return S.jsx(Ne.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":s||void 0,...i,ref:e})});function CA(t){const e=[];return Array.from(t.childNodes).forEach(s=>{if(s.nodeType===s.TEXT_NODE&&s.textContent&&e.push(s.textContent),nB(s)){const i=s.ariaHidden||s.hidden||s.style.display==="none",l=s.dataset.radixToastAnnounceExclude==="";if(!i)if(l){const c=s.dataset.radixToastAnnounceAlt;c&&e.push(c)}else e.push(...CA(s))}}),e}function $f(t,e,n,{discrete:s}){const i=n.originalEvent.currentTarget,l=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:n});e&&i.addEventListener(t,e,{once:!0}),s?H_(i,l):i.dispatchEvent(l)}var u_=(t,e,n=0)=>{const s=Math.abs(t.x),i=Math.abs(t.y),l=s>i;return e==="left"||e==="right"?l&&s>n:!l&&i>n};function tB(t=()=>{}){const e=pt(t);Tt(()=>{let n=0,s=0;return n=window.requestAnimationFrame(()=>s=window.requestAnimationFrame(e)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(s)}},[e])}function nB(t){return t.nodeType===t.ELEMENT_NODE}function rB(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const i=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||i?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function rv(t){const e=document.activeElement;return t.some(n=>n===e?!0:(n.focus(),document.activeElement!==e))}var sB=pA,TA=gA,RA=yA,AA=bA,OA=xA,NA=SA,kA=r0;const aB=sB,MA=E.forwardRef(({className:t,...e},n)=>S.jsx(TA,{ref:n,className:fe("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",t),...e}));MA.displayName=TA.displayName;const iB=fa("group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),LA=E.forwardRef(({className:t,variant:e,...n},s)=>S.jsx(RA,{ref:s,className:fe(iB({variant:e}),t),...n}));LA.displayName=RA.displayName;const DA=E.forwardRef(({className:t,...e},n)=>S.jsx(NA,{ref:n,className:fe("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",t),...e}));DA.displayName=NA.displayName;const jA=E.forwardRef(({className:t,...e},n)=>S.jsx(kA,{ref:n,className:fe("absolute right-1 top-1 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",t),"toast-close":"",...e,children:S.jsx(ui,{className:"h-4 w-4"})}));jA.displayName=kA.displayName;const PA=E.forwardRef(({className:t,...e},n)=>S.jsx(AA,{ref:n,className:fe("text-sm font-semibold [&+div]:text-xs",t),...e}));PA.displayName=AA.displayName;const IA=E.forwardRef(({className:t,...e},n)=>S.jsx(OA,{ref:n,className:fe("text-sm opacity-90",t),...e}));IA.displayName=OA.displayName;function oB(){const{toasts:t}=tr();return S.jsxs(aB,{children:[t.map(({id:e,title:n,description:s,action:i,...l})=>S.jsxs(LA,{...l,children:[S.jsxs("div",{className:"grid gap-1",children:[n&&S.jsx(PA,{children:n}),s&&S.jsx(IA,{children:s})]}),i,S.jsx(jA,{})]},e)),S.jsx(MA,{})]})}function lB(){const{toast:t}=tr();async function e(s){const i=`https://api.github.com/repos/${s}/releases/latest`;try{const l=await fetch(i,{headers:{Accept:"application/vnd.github.v3+json","User-Agent":"fetch-latest-release"}});if(!l.ok)throw new Error(`Failed to fetch latest release: ${l.status} ${l.statusText}`);return(await l.json()).tag_name}catch{}}const n=async()=>{try{const s=await e("elizaos/eliza"),i=uo==null?void 0:uo.version;s&&i&&GP.gt(s.replace("v",""),i.replace("v",""))&&t({variant:"default",title:`New version ${s} is available.`,description:"Visit GitHub for more information.",action:S.jsx(no,{to:"https://github.com/elizaos/eliza/releases",target:"_blank",children:S.jsx(DA,{altText:"Update",children:"Update"})})})}catch(s){console.error(`Unable to retrieve latest version from GitHub: ${s}`)}};return E.useEffect(()=>{n()},[n]),null}var s0="Avatar",[uB,Gz]=Ar(s0),[cB,BA]=uB(s0),zA=E.forwardRef((t,e)=>{const{__scopeAvatar:n,...s}=t,[i,l]=E.useState("idle");return S.jsx(cB,{scope:n,imageLoadingStatus:i,onImageLoadingStatusChange:l,children:S.jsx(Ne.span,{...s,ref:e})})});zA.displayName=s0;var qA="AvatarImage",UA=E.forwardRef((t,e)=>{const{__scopeAvatar:n,src:s,onLoadingStatusChange:i=()=>{},...l}=t,c=BA(qA,n),f=fB(s,l.referrerPolicy),d=pt(h=>{i(h),c.onImageLoadingStatusChange(h)});return Tt(()=>{f!=="idle"&&d(f)},[f,d]),f==="loaded"?S.jsx(Ne.img,{...l,ref:e,src:s}):null});UA.displayName=qA;var HA="AvatarFallback",FA=E.forwardRef((t,e)=>{const{__scopeAvatar:n,delayMs:s,...i}=t,l=BA(HA,n),[c,f]=E.useState(s===void 0);return E.useEffect(()=>{if(s!==void 0){const d=window.setTimeout(()=>f(!0),s);return()=>window.clearTimeout(d)}},[s]),c&&l.imageLoadingStatus!=="loaded"?S.jsx(Ne.span,{...i,ref:e}):null});FA.displayName=HA;function fB(t,e){const[n,s]=E.useState("idle");return Tt(()=>{if(!t){s("error");return}let i=!0;const l=new window.Image,c=f=>()=>{i&&s(f)};return s("loading"),l.onload=c("loaded"),l.onerror=c("error"),l.src=t,e&&(l.referrerPolicy=e),()=>{i=!1}},[t,e]),n}var VA=zA,$A=UA,GA=FA;const Zv=E.forwardRef(({className:t,...e},n)=>S.jsx(VA,{ref:n,className:fe("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-md",t),...e}));Zv.displayName=VA.displayName;const Xv=E.forwardRef(({className:t,...e},n)=>S.jsx($A,{ref:n,className:fe("aspect-square h-full w-full",t),...e}));Xv.displayName=$A.displayName;const YA=E.forwardRef(({className:t,...e},n)=>S.jsx(GA,{ref:n,className:fe("flex h-full w-full items-center justify-center rounded-md bg-muted",t),...e}));YA.displayName=GA.displayName;function dB(){return S.jsxs("svg",{role:"img","aria-label":"Loading animation",width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"text-foreground",children:[S.jsx("circle",{cx:"4",cy:"12",r:"2",fill:"currentColor",children:S.jsx("animate",{id:"spinner_qFRN",begin:"0;spinner_OcgL.end+0.25s",attributeName:"cy",calcMode:"spline",dur:"0.6s",values:"12;6;12",keySplines:".33,.66,.66,1;.33,0,.66,.33"})}),S.jsx("circle",{cx:"12",cy:"12",r:"2",fill:"currentColor",children:S.jsx("animate",{begin:"spinner_qFRN.begin+0.1s",attributeName:"cy",calcMode:"spline",dur:"0.6s",values:"12;6;12",keySplines:".33,.66,.66,1;.33,0,.66,.33"})}),S.jsx("circle",{cx:"20",cy:"12",r:"2",fill:"currentColor",children:S.jsx("animate",{id:"spinner_OcgL",begin:"spinner_qFRN.begin+0.2s",attributeName:"cy",calcMode:"spline",dur:"0.6s",values:"12;6;12",keySplines:".33,.66,.66,1;.33,0,.66,.33"})})]})}const hB=fa("flex gap-2 max-w-[60%] items-end relative group",{variants:{variant:{received:"self-start",sent:"self-end flex-row-reverse"},layout:{default:"",ai:"max-w-full w-full items-center"}},defaultVariants:{variant:"received",layout:"default"}}),QA=E.forwardRef(({className:t,variant:e,layout:n,children:s,...i},l)=>S.jsx("div",{className:fe(hB({variant:e,layout:n,className:t}),"relative group"),ref:l,...i,children:E.Children.map(s,c=>E.isValidElement(c)&&typeof c.type!="string"&&c.type!==E.Fragment?E.cloneElement(c,{variant:e,layout:n}):c)}));QA.displayName="ChatBubble";const pB=fa("p-4",{variants:{variant:{received:"bg-secondary text-secondary-foreground rounded-lg rounded-bl-none",sent:"bg-primary text-primary-foreground rounded-lg rounded-br-none"},layout:{default:"",ai:"border-t w-full rounded-none bg-transparent"}},defaultVariants:{variant:"received",layout:"default"}}),WA=E.forwardRef(({className:t,variant:e,layout:n,isLoading:s=!1,children:i,...l},c)=>S.jsx("div",{className:fe(pB({variant:e,layout:n,className:t}),"break-words max-w-full whitespace-pre-wrap"),ref:c,...l,children:s?S.jsx("div",{className:"flex items-center space-x-2",children:S.jsx(dB,{})}):i}));WA.displayName="ChatBubbleMessage";const mB=({timestamp:t,className:e,...n})=>S.jsx("div",{className:fe("text-xs text-right select-none",e),...n,children:t}),gB=E.forwardRef(({variant:t,className:e,children:n,...s},i)=>S.jsx("div",{ref:i,className:fe("absolute top-1/2 -translate-y-1/2 flex opacity-0 group-hover:opacity-100 transition-opacity duration-200",t==="sent"?"-left-1 -translate-x-full flex-row-reverse":"-right-1 translate-x-full",e),...s,children:n}));gB.displayName="ChatBubbleActionWrapper";const KA=E.forwardRef(({className:t,...e},n)=>S.jsx(zy,{autoComplete:"off",ref:n,name:"message",className:fe("max-h-12 px-4 py-3 bg-background text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 w-full rounded-md flex items-center h-16 resize-none",t),...e}));KA.displayName="ChatInput";const ZA=E.forwardRef(({className:t,children:e,scrollRef:n,isAtBottom:s,scrollToBottom:i,disableAutoScroll:l,...c},f)=>S.jsxs("div",{className:"relative w-full overflow-hidden",children:[S.jsx("div",{className:`flex flex-col w-full h-full p-4 overflow-y-auto ${t}`,ref:n,onWheel:l,onTouchMove:l,...c,children:S.jsx("div",{className:"flex flex-col gap-6",children:e})}),!s&&S.jsx(Ze,{onClick:()=>{i()},size:"icon",variant:"outline",className:"absolute bottom-2 left-1/2 transform -translate-x-1/2 inline-flex rounded-full shadow-md",children:S.jsx(vM,{className:"h-4 w-4"})})]}));ZA.displayName="ChatMessageList";var sv={exports:{}},c_;function vB(){return c_||(c_=1,function(t){var e=Object.prototype.hasOwnProperty,n="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(n=!1));function i(d,h,p){this.fn=d,this.context=h,this.once=p||!1}function l(d,h,p,b,m){if(typeof p!="function")throw new TypeError("The listener must be a function");var v=new i(p,b||d,m),g=n?n+h:h;return d._events[g]?d._events[g].fn?d._events[g]=[d._events[g],v]:d._events[g].push(v):(d._events[g]=v,d._eventsCount++),d}function c(d,h){--d._eventsCount===0?d._events=new s:delete d._events[h]}function f(){this._events=new s,this._eventsCount=0}f.prototype.eventNames=function(){var h=[],p,b;if(this._eventsCount===0)return h;for(b in p=this._events)e.call(p,b)&&h.push(n?b.slice(1):b);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(p)):h},f.prototype.listeners=function(h){var p=n?n+h:h,b=this._events[p];if(!b)return[];if(b.fn)return[b.fn];for(var m=0,v=b.length,g=new Array(v);m<v;m++)g[m]=b[m].fn;return g},f.prototype.listenerCount=function(h){var p=n?n+h:h,b=this._events[p];return b?b.fn?1:b.length:0},f.prototype.emit=function(h,p,b,m,v,g){var x=n?n+h:h;if(!this._events[x])return!1;var w=this._events[x],C=arguments.length,T,A;if(w.fn){switch(w.once&&this.removeListener(h,w.fn,void 0,!0),C){case 1:return w.fn.call(w.context),!0;case 2:return w.fn.call(w.context,p),!0;case 3:return w.fn.call(w.context,p,b),!0;case 4:return w.fn.call(w.context,p,b,m),!0;case 5:return w.fn.call(w.context,p,b,m,v),!0;case 6:return w.fn.call(w.context,p,b,m,v,g),!0}for(A=1,T=new Array(C-1);A<C;A++)T[A-1]=arguments[A];w.fn.apply(w.context,T)}else{var R=w.length,k;for(A=0;A<R;A++)switch(w[A].once&&this.removeListener(h,w[A].fn,void 0,!0),C){case 1:w[A].fn.call(w[A].context);break;case 2:w[A].fn.call(w[A].context,p);break;case 3:w[A].fn.call(w[A].context,p,b);break;case 4:w[A].fn.call(w[A].context,p,b,m);break;default:if(!T)for(k=1,T=new Array(C-1);k<C;k++)T[k-1]=arguments[k];w[A].fn.apply(w[A].context,T)}}return!0},f.prototype.on=function(h,p,b){return l(this,h,p,b,!1)},f.prototype.once=function(h,p,b){return l(this,h,p,b,!0)},f.prototype.removeListener=function(h,p,b,m){var v=n?n+h:h;if(!this._events[v])return this;if(!p)return c(this,v),this;var g=this._events[v];if(g.fn)g.fn===p&&(!m||g.once)&&(!b||g.context===b)&&c(this,v);else{for(var x=0,w=[],C=g.length;x<C;x++)(g[x].fn!==p||m&&!g[x].once||b&&g[x].context!==b)&&w.push(g[x]);w.length?this._events[v]=w.length===1?w[0]:w:c(this,v)}return this},f.prototype.removeAllListeners=function(h){var p;return h?(p=n?n+h:h,this._events[p]&&c(this,p)):(this._events=new s,this._eventsCount=0),this},f.prototype.off=f.prototype.removeListener,f.prototype.addListener=f.prototype.on,f.prefixed=n,f.EventEmitter=f,t.exports=f}(sv)),sv.exports}var yB=vB();const bB=Rr(yB),Tr=Object.create(null);Tr.open="0";Tr.close="1";Tr.ping="2";Tr.pong="3";Tr.message="4";Tr.upgrade="5";Tr.noop="6";const ld=Object.create(null);Object.keys(Tr).forEach(t=>{ld[Tr[t]]=t});const Jv={type:"error",data:"parser error"},XA=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",JA=typeof ArrayBuffer=="function",eO=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,a0=({type:t,data:e},n,s)=>XA&&e instanceof Blob?n?s(e):f_(e,s):JA&&(e instanceof ArrayBuffer||eO(e))?n?s(e):f_(new Blob([e]),s):s(Tr[t]+(e||"")),f_=(t,e)=>{const n=new FileReader;return n.onload=function(){const s=n.result.split(",")[1];e("b"+(s||""))},n.readAsDataURL(t)};function d_(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let av;function xB(t,e){if(XA&&t.data instanceof Blob)return t.data.arrayBuffer().then(d_).then(e);if(JA&&(t.data instanceof ArrayBuffer||eO(t.data)))return e(d_(t.data));a0(t,!1,n=>{av||(av=new TextEncoder),e(av.encode(n))})}const h_="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ou=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t<h_.length;t++)ou[h_.charCodeAt(t)]=t;const wB=t=>{let e=t.length*.75,n=t.length,s,i=0,l,c,f,d;t[t.length-1]==="="&&(e--,t[t.length-2]==="="&&e--);const h=new ArrayBuffer(e),p=new Uint8Array(h);for(s=0;s<n;s+=4)l=ou[t.charCodeAt(s)],c=ou[t.charCodeAt(s+1)],f=ou[t.charCodeAt(s+2)],d=ou[t.charCodeAt(s+3)],p[i++]=l<<2|c>>4,p[i++]=(c&15)<<4|f>>2,p[i++]=(f&3)<<6|d&63;return h},SB=typeof ArrayBuffer=="function",i0=(t,e)=>{if(typeof t!="string")return{type:"message",data:tO(t,e)};const n=t.charAt(0);return n==="b"?{type:"message",data:_B(t.substring(1),e)}:ld[n]?t.length>1?{type:ld[n],data:t.substring(1)}:{type:ld[n]}:Jv},_B=(t,e)=>{if(SB){const n=wB(t);return tO(n,e)}else return{base64:!0,data:t}},tO=(t,e)=>{switch(e){case"blob":return t instanceof Blob?t:new Blob([t]);case"arraybuffer":default:return t instanceof ArrayBuffer?t:t.buffer}},nO="",EB=(t,e)=>{const n=t.length,s=new Array(n);let i=0;t.forEach((l,c)=>{a0(l,!1,f=>{s[c]=f,++i===n&&e(s.join(nO))})})},CB=(t,e)=>{const n=t.split(nO),s=[];for(let i=0;i<n.length;i++){const l=i0(n[i],e);if(s.push(l),l.type==="error")break}return s};function TB(){return new TransformStream({transform(t,e){xB(t,n=>{const s=n.length;let i;if(s<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,s);else if(s<65536){i=new Uint8Array(3);const l=new DataView(i.buffer);l.setUint8(0,126),l.setUint16(1,s)}else{i=new Uint8Array(9);const l=new DataView(i.buffer);l.setUint8(0,127),l.setBigUint64(1,BigInt(s))}t.data&&typeof t.data!="string"&&(i[0]|=128),e.enqueue(i),e.enqueue(n)})}})}let iv;function Gf(t){return t.reduce((e,n)=>e+n.length,0)}function Yf(t,e){if(t[0].length===e)return t.shift();const n=new Uint8Array(e);let s=0;for(let i=0;i<e;i++)n[i]=t[0][s++],s===t[0].length&&(t.shift(),s=0);return t.length&&s<t[0].length&&(t[0]=t[0].slice(s)),n}function RB(t,e){iv||(iv=new TextDecoder);const n=[];let s=0,i=-1,l=!1;return new TransformStream({transform(c,f){for(n.push(c);;){if(s===0){if(Gf(n)<1)break;const d=Yf(n,1);l=(d[0]&128)===128,i=d[0]&127,i<126?s=3:i===126?s=1:s=2}else if(s===1){if(Gf(n)<2)break;const d=Yf(n,2);i=new DataView(d.buffer,d.byteOffset,d.length).getUint16(0),s=3}else if(s===2){if(Gf(n)<8)break;const d=Yf(n,8),h=new DataView(d.buffer,d.byteOffset,d.length),p=h.getUint32(0);if(p>Math.pow(2,21)-1){f.enqueue(Jv);break}i=p*Math.pow(2,32)+h.getUint32(4),s=3}else{if(Gf(n)<i)break;const d=Yf(n,i);f.enqueue(i0(l?d:iv.decode(d),e)),s=0}if(i===0||i>t){f.enqueue(Jv);break}}}})}const rO=4;function wt(t){if(t)return AB(t)}function AB(t){for(var e in wt.prototype)t[e]=wt.prototype[e];return t}wt.prototype.on=wt.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this};wt.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this};wt.prototype.off=wt.prototype.removeListener=wt.prototype.removeAllListeners=wt.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+t];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+t],this;for(var s,i=0;i<n.length;i++)if(s=n[i],s===e||s.fn===e){n.splice(i,1);break}return n.length===0&&delete this._callbacks["$"+t],this};wt.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),n=this._callbacks["$"+t],s=1;s<arguments.length;s++)e[s-1]=arguments[s];if(n){n=n.slice(0);for(var s=0,i=n.length;s<i;++s)n[s].apply(this,e)}return this};wt.prototype.emitReserved=wt.prototype.emit;wt.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]};wt.prototype.hasListeners=function(t){return!!this.listeners(t).length};const mh=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,n)=>n(e,0),kn=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),OB="arraybuffer";function sO(t,...e){return e.reduce((n,s)=>(t.hasOwnProperty(s)&&(n[s]=t[s]),n),{})}const NB=kn.setTimeout,kB=kn.clearTimeout;function gh(t,e){e.useNativeTimers?(t.setTimeoutFn=NB.bind(kn),t.clearTimeoutFn=kB.bind(kn)):(t.setTimeoutFn=kn.setTimeout.bind(kn),t.clearTimeoutFn=kn.clearTimeout.bind(kn))}const MB=1.33;function LB(t){return typeof t=="string"?DB(t):Math.ceil((t.byteLength||t.size)*MB)}function DB(t){let e=0,n=0;for(let s=0,i=t.length;s<i;s++)e=t.charCodeAt(s),e<128?n+=1:e<2048?n+=2:e<55296||e>=57344?n+=3:(s++,n+=4);return n}function aO(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function jB(t){let e="";for(let n in t)t.hasOwnProperty(n)&&(e.length&&(e+="&"),e+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e}function PB(t){let e={},n=t.split("&");for(let s=0,i=n.length;s<i;s++){let l=n[s].split("=");e[decodeURIComponent(l[0])]=decodeURIComponent(l[1])}return e}class IB extends Error{constructor(e,n,s){super(e),this.description=n,this.context=s,this.type="TransportError"}}class o0 extends wt{constructor(e){super(),this.writable=!1,gh(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,n,s){return super.emitReserved("error",new IB(e,n,s)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const n=i0(e,this.socket.binaryType);this.onPacket(n)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,n={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const n=jB(e);return n.length?"?"+n:""}}class BB extends o0{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const n=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let s=0;this._polling&&(s++,this.once("pollComplete",function(){--s||n()})),this.writable||(s++,this.once("drain",function(){--s||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const n=s=>{if(this.readyState==="opening"&&s.type==="open"&&this.onOpen(),s.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(s)};CB(e,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,EB(e,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=aO()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(e,n)}}let iO=!1;try{iO=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const zB=iO;function qB(){}class UB extends BB{constructor(e){if(super(e),typeof location<"u"){const n=location.protocol==="https:";let s=location.port;s||(s=n?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||s!==e.port}}doWrite(e,n){const s=this.request({method:"POST",data:e});s.on("success",n),s.on("error",(i,l)=>{this.onError("xhr post error",i,l)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(n,s)=>{this.onError("xhr poll error",n,s)}),this.pollXhr=e}}class wr extends wt{constructor(e,n,s){super(),this.createRequest=e,gh(this,s),this._opts=s,this._method=s.method||"GET",this._uri=n,this._data=s.data!==void 0?s.data:null,this._create()}_create(){var e;const n=sO(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const s=this._xhr=this.createRequest(n);try{s.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let i in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(i)&&s.setRequestHeader(i,this._opts.extraHeaders[i])}}catch{}if(this._method==="POST")try{s.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{s.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(s),"withCredentials"in s&&(s.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(s.timeout=this._opts.requestTimeout),s.onreadystatechange=()=>{var i;s.readyState===3&&((i=this._opts.cookieJar)===null||i===void 0||i.parseCookies(s.getResponseHeader("set-cookie"))),s.readyState===4&&(s.status===200||s.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof s.status=="number"?s.status:0)},0))},s.send(this._data)}catch(i){this.setTimeoutFn(()=>{this._onError(i)},0);return}typeof document<"u"&&(this._index=wr.requestsCount++,wr.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=qB,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete wr.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}wr.requestsCount=0;wr.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",p_);else if(typeof addEventListener=="function"){const t="onpagehide"in kn?"pagehide":"unload";addEventListener(t,p_,!1)}}function p_(){for(let t in wr.requests)wr.requests.hasOwnProperty(t)&&wr.requests[t].abort()}const HB=function(){const t=oO({xdomain:!1});return t&&t.responseType!==null}();class FB extends UB{constructor(e){super(e);const n=e&&e.forceBase64;this.supportsBinary=HB&&!n}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new wr(oO,this.uri(),e)}}function oO(t){const e=t.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||zB))return new XMLHttpRequest}catch{}if(!e)try{return new kn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const lO=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class VB extends o0{get name(){return"websocket"}doOpen(){const e=this.uri(),n=this.opts.protocols,s=lO?{}:sO(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,n,s)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const s=e[n],i=n===e.length-1;a0(s,this.supportsBinary,l=>{try{this.doWrite(s,l)}catch{}i&&mh(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=aO()),this.supportsBinary||(n.b64=1),this.createUri(e,n)}}const ov=kn.WebSocket||kn.MozWebSocket;class $B extends VB{createSocket(e,n,s){return lO?new ov(e,n,s):n?new ov(e,n):new ov(e)}doWrite(e,n){this.ws.send(n)}}class GB extends o0{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const n=RB(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=e.readable.pipeThrough(n).getReader(),i=TB();i.readable.pipeTo(e.writable),this._writer=i.writable.getWriter();const l=()=>{s.read().then(({done:f,value:d})=>{f||(this.onPacket(d),l())}).catch(f=>{})};l();const c={type:"open"};this.query.sid&&(c.data=`{"sid":"${this.query.sid}"}`),this._writer.write(c).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const s=e[n],i=n===e.length-1;this._writer.write(s).then(()=>{i&&mh(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const YB={websocket:$B,webtransport:GB,polling:FB},QB=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,WB=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ey(t){if(t.length>8e3)throw"URI too long";const e=t,n=t.indexOf("["),s=t.indexOf("]");n!=-1&&s!=-1&&(t=t.substring(0,n)+t.substring(n,s).replace(/:/g,";")+t.substring(s,t.length));let i=QB.exec(t||""),l={},c=14;for(;c--;)l[WB[c]]=i[c]||"";return n!=-1&&s!=-1&&(l.source=e,l.host=l.host.substring(1,l.host.length-1).replace(/;/g,":"),l.authority=l.authority.replace("[","").replace("]","").replace(/;/g,":"),l.ipv6uri=!0),l.pathNames=KB(l,l.path),l.queryKey=ZB(l,l.query),l}function KB(t,e){const n=/\/{2,9}/g,s=e.replace(n,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&s.splice(0,1),e.slice(-1)=="/"&&s.splice(s.length-1,1),s}function ZB(t,e){const n={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(s,i,l){i&&(n[i]=l)}),n}const ty=typeof addEventListener=="function"&&typeof removeEventListener=="function",ud=[];ty&&addEventListener("offline",()=>{ud.forEach(t=>t())},!1);class ta extends wt{constructor(e,n){if(super(),this.binaryType=OB,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(n=e,e=null),e){const s=ey(e);n.hostname=s.host,n.secure=s.protocol==="https"||s.protocol==="wss",n.port=s.port,s.query&&(n.query=s.query)}else n.host&&(n.hostname=ey(n.host).host);gh(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(s=>{const i=s.prototype.name;this.transports.push(i),this._transportsByName[i]=s}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=PB(this.opts.query)),ty&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},ud.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const n=Object.assign({},this.opts.query);n.EIO=rO,n.transport=e,this.id&&(n.sid=this.id);const s=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](s)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const e=this.opts.rememberUpgrade&&ta.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(e);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",ta.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=e.data,this._onError(n);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let s=0;s<this.writeBuffer.length;s++){const i=this.writeBuffer[s].data;if(i&&(n+=LB(i)),s>0&&n>this._maxPayload)return this.writeBuffer.slice(0,s);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,mh(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,n,s){return this._sendPacket("message",e,n,s),this}send(e,n,s){return this._sendPacket("message",e,n,s),this}_sendPacket(e,n,s,i){if(typeof n=="function"&&(i=n,n=void 0),typeof s=="function"&&(i=s,s=null),this.readyState==="closing"||this.readyState==="closed")return;s=s||{},s.compress=s.compress!==!1;const l={type:e,data:n,options:s};this.emitReserved("packetCreate",l),this.writeBuffer.push(l),i&&this.once("flush",i),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),e()},s=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?s():e()}):this.upgrading?s():e()),this}_onError(e){if(ta.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),ty&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const s=ud.indexOf(this._offlineEventListener);s!==-1&&ud.splice(s,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,n),this.writeBuffer=[],this._prevBufferLen=0}}}ta.protocol=rO;class XB extends ta{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let n=this.createTransport(e),s=!1;ta.priorWebsocketSuccess=!1;const i=()=>{s||(n.send([{type:"ping",data:"probe"}]),n.once("packet",b=>{if(!s)if(b.type==="pong"&&b.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;ta.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{s||this.readyState!=="closed"&&(p(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const m=new Error("probe error");m.transport=n.name,this.emitReserved("upgradeError",m)}}))};function l(){s||(s=!0,p(),n.close(),n=null)}const c=b=>{const m=new Error("probe error: "+b);m.transport=n.name,l(),this.emitReserved("upgradeError",m)};function f(){c("transport closed")}function d(){c("socket closed")}function h(b){n&&b.name!==n.name&&l()}const p=()=>{n.removeListener("open",i),n.removeListener("error",c),n.removeListener("close",f),this.off("close",d),this.off("upgrading",h)};n.once("open",i),n.once("error",c),n.once("close",f),this.once("close",d),this.once("upgrading",h),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{s||n.open()},200):n.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const n=[];for(let s=0;s<e.length;s++)~this.transports.indexOf(e[s])&&n.push(e[s]);return n}}let JB=class extends XB{constructor(e,n={}){const s=typeof e=="object"?e:n;(!s.transports||s.transports&&typeof s.transports[0]=="string")&&(s.transports=(s.transports||["polling","websocket","webtransport"]).map(i=>YB[i]).filter(i=>!!i)),super(e,s)}};function ez(t,e="",n){let s=t;n=n||typeof location<"u"&&location,t==null&&(t=n.protocol+"//"+n.host),typeof t=="string"&&(t.charAt(0)==="/"&&(t.charAt(1)==="/"?t=n.protocol+t:t=n.host+t),/^(https?|wss?):\/\//.test(t)||(typeof n<"u"?t=n.protocol+"//"+t:t="https://"+t),s=ey(t)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";const l=s.host.indexOf(":")!==-1?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+l+":"+s.port+e,s.href=s.protocol+"://"+l+(n&&n.port===s.port?"":":"+s.port),s}const tz=typeof ArrayBuffer=="function",nz=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,uO=Object.prototype.toString,rz=typeof Blob=="function"||typeof Blob<"u"&&uO.call(Blob)==="[object BlobConstructor]",sz=typeof File=="function"||typeof File<"u"&&uO.call(File)==="[object FileConstructor]";function l0(t){return tz&&(t instanceof ArrayBuffer||nz(t))||rz&&t instanceof Blob||sz&&t instanceof File}function cd(t,e){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let n=0,s=t.length;n<s;n++)if(cd(t[n]))return!0;return!1}if(l0(t))return!0;if(t.toJSON&&typeof t.toJSON=="function"&&arguments.length===1)return cd(t.toJSON(),!0);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&cd(t[n]))return!0;return!1}function az(t){const e=[],n=t.data,s=t;return s.data=ny(n,e),s.attachments=e.length,{packet:s,buffers:e}}function ny(t,e){if(!t)return t;if(l0(t)){const n={_placeholder:!0,num:e.length};return e.push(t),n}else if(Array.isArray(t)){const n=new Array(t.length);for(let s=0;s<t.length;s++)n[s]=ny(t[s],e);return n}else if(typeof t=="object"&&!(t instanceof Date)){const n={};for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[s]=ny(t[s],e));return n}return t}function iz(t,e){return t.data=ry(t.data,e),delete t.attachments,t}function ry(t,e){if(!t)return t;if(t&&t._placeholder===!0){if(typeof t.num=="number"&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}else if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]=ry(t[n],e);else if(typeof t=="object")for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(t[n]=ry(t[n],e));return t}const oz=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],lz=5;var Fe;(function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"})(Fe||(Fe={}));class uz{constructor(e){this.replacer=e}encode(e){return(e.type===Fe.EVENT||e.type===Fe.ACK)&&cd(e)?this.encodeAsBinary({type:e.type===Fe.EVENT?Fe.BINARY_EVENT:Fe.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let n=""+e.type;return(e.type===Fe.BINARY_EVENT||e.type===Fe.BINARY_ACK)&&(n+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(n+=e.nsp+","),e.id!=null&&(n+=e.id),e.data!=null&&(n+=JSON.stringify(e.data,this.replacer)),n}encodeAsBinary(e){const n=az(e),s=this.encodeAsString(n.packet),i=n.buffers;return i.unshift(s),i}}function m_(t){return Object.prototype.toString.call(t)==="[object Object]"}class u0 extends wt{constructor(e){super(),this.reviver=e}add(e){let n;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(e);const s=n.type===Fe.BINARY_EVENT;s||n.type===Fe.BINARY_ACK?(n.type=s?Fe.EVENT:Fe.ACK,this.reconstructor=new cz(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(l0(e)||e.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(e),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let n=0;const s={type:Number(e.charAt(0))};if(Fe[s.type]===void 0)throw new Error("unknown packet type "+s.type);if(s.type===Fe.BINARY_EVENT||s.type===Fe.BINARY_ACK){const l=n+1;for(;e.charAt(++n)!=="-"&&n!=e.length;);const c=e.substring(l,n);if(c!=Number(c)||e.charAt(n)!=="-")throw new Error("Illegal attachments");s.attachments=Number(c)}if(e.charAt(n+1)==="/"){const l=n+1;for(;++n&&!(e.charAt(n)===","||n===e.length););s.nsp=e.substring(l,n)}else s.nsp="/";const i=e.charAt(n+1);if(i!==""&&Number(i)==i){const l=n+1;for(;++n;){const c=e.charAt(n);if(c==null||Number(c)!=c){--n;break}if(n===e.length)break}s.id=Number(e.substring(l,n+1))}if(e.charAt(++n)){const l=this.tryParse(e.substr(n));if(u0.isPayloadValid(s.type,l))s.data=l;else throw new Error("invalid payload")}return s}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,n){switch(e){case Fe.CONNECT:return m_(n);case Fe.DISCONNECT:return n===void 0;case Fe.CONNECT_ERROR:return typeof n=="string"||m_(n);case Fe.EVENT:case Fe.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&oz.indexOf(n[0])===-1);case Fe.ACK:case Fe.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class cz{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const n=iz(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const fz=Object.freeze(Object.defineProperty({__proto__:null,Decoder:u0,Encoder:uz,get PacketType(){return Fe},protocol:lz},Symbol.toStringTag,{value:"Module"}));function Vn(t,e,n){return t.on(e,n),function(){t.off(e,n)}}const dz=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class cO extends wt{constructor(e,n,s){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=n,s&&s.auth&&(this.auth=s.auth),this._opts=Object.assign({},s),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Vn(e,"open",this.onopen.bind(this)),Vn(e,"packet",this.onpacket.bind(this)),Vn(e,"error",this.onerror.bind(this)),Vn(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...n){var s,i,l;if(dz.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(n.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const c={type:Fe.EVENT,data:n};if(c.options={},c.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const p=this.ids++,b=n.pop();this._registerAckCallback(p,b),c.id=p}const f=(i=(s=this.io.engine)===null||s===void 0?void 0:s.transport)===null||i===void 0?void 0:i.writable,d=this.connected&&!(!((l=this.io.engine)===null||l===void 0)&&l._hasPingExpired());return this.flags.volatile&&!f||(d?(this.notifyOutgoingListeners(c),this.packet(c)):this.sendBuffer.push(c)),this.flags={},this}_registerAckCallback(e,n){var s;const i=(s=this.flags.timeout)!==null&&s!==void 0?s:this._opts.ackTimeout;if(i===void 0){this.acks[e]=n;return}const l=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let f=0;f<this.sendBuffer.length;f++)this.sendBuffer[f].id===e&&this.sendBuffer.splice(f,1);n.call(this,new Error("operation has timed out"))},i),c=(...f)=>{this.io.clearTimeoutFn(l),n.apply(this,f)};c.withError=!0,this.acks[e]=c}emitWithAck(e,...n){return new Promise((s,i)=>{const l=(c,f)=>c?i(c):s(f);l.withError=!0,n.push(l),this.emit(e,...n)})}_addToQueue(e){let n;typeof e[e.length-1]=="function"&&(n=e.pop());const s={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((i,...l)=>s!==this._queue[0]?void 0:(i!==null?s.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(i)):(this._queue.shift(),n&&n(null,...l)),s.pending=!1,this._drainQueue())),this._queue.push(s),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!e||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:Fe.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(s=>String(s.id)===e)){const s=this.acks[e];delete this.acks[e],s.withError&&s.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case Fe.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Fe.EVENT:case Fe.BINARY_EVENT:this.onevent(e);break;case Fe.ACK:case Fe.BINARY_ACK:this.onack(e);break;case Fe.DISCONNECT:this.ondisconnect();break;case Fe.CONNECT_ERROR:this.destroy();const s=new Error(e.data.message);s.data=e.data.data,this.emitReserved("connect_error",s);break}}onevent(e){const n=e.data||[];e.id!=null&&n.push(this.ack(e.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const s of n)s.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const n=this;let s=!1;return function(...i){s||(s=!0,n.packet({type:Fe.ACK,id:e,data:i}))}}onack(e){const n=this.acks[e.id];typeof n=="function"&&(delete this.acks[e.id],n.withError&&e.data.unshift(null),n.apply(this,e.data))}onconnect(e,n){this.id=e,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Fe.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const n=this._anyListeners;for(let s=0;s<n.length;s++)if(e===n[s])return n.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const n=this._anyOutgoingListeners;for(let s=0;s<n.length;s++)if(e===n[s])return n.splice(s,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const s of n)s.apply(this,e.data)}}}function Uo(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}Uo.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),n=Math.floor(e*this.jitter*t);t=(Math.floor(e*10)&1)==0?t-n:t+n}return Math.min(t,this.max)|0};Uo.prototype.reset=function(){this.attempts=0};Uo.prototype.setMin=function(t){this.ms=t};Uo.prototype.setMax=function(t){this.max=t};Uo.prototype.setJitter=function(t){this.jitter=t};class sy extends wt{constructor(e,n){var s;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(n=e,e=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,gh(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((s=n.randomizationFactor)!==null&&s!==void 0?s:.5),this.backoff=new Uo({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=e;const i=n.parser||fz;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var n;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(n=this.backoff)===null||n===void 0||n.setMin(e),this)}randomizationFactor(e){var n;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(n=this.backoff)===null||n===void 0||n.setJitter(e),this)}reconnectionDelayMax(e){var n;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(n=this.backoff)===null||n===void 0||n.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new JB(this.uri,this.opts);const n=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const i=Vn(n,"open",function(){s.onopen(),e&&e()}),l=f=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",f),e?e(f):this.maybeReconnectOnOpen()},c=Vn(n,"error",l);if(this._timeout!==!1){const f=this._timeout,d=this.setTimeoutFn(()=>{i(),l(new Error("timeout")),n.close()},f);this.opts.autoUnref&&d.unref(),this.subs.push(()=>{this.clearTimeoutFn(d)})}return this.subs.push(i),this.subs.push(c),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(Vn(e,"ping",this.onping.bind(this)),Vn(e,"data",this.ondata.bind(this)),Vn(e,"error",this.onerror.bind(this)),Vn(e,"close",this.onclose.bind(this)),Vn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(n){this.onclose("parse error",n)}}ondecoded(e){mh(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,n){let s=this.nsps[e];return s?this._autoConnect&&!s.active&&s.connect():(s=new cO(this,e,n),this.nsps[e]=s),s}_destroy(e){const n=Object.keys(this.nsps);for(const s of n)if(this.nsps[s].active)return;this._close()}_packet(e){const n=this.encoder.encode(e);for(let s=0;s<n.length;s++)this.engine.write(n[s],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,n){var s;this.cleanup(),(s=this.engine)===null||s===void 0||s.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const s=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(i=>{i?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",i)):e.onreconnect()}))},n);this.opts.autoUnref&&s.unref(),this.subs.push(()=>{this.clearTimeoutFn(s)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const Jl={};function fd(t,e){typeof t=="object"&&(e=t,t=void 0),e=e||{};const n=ez(t,e.path||"/socket.io"),s=n.source,i=n.id,l=n.path,c=Jl[i]&&l in Jl[i].nsps,f=e.forceNew||e["force new connection"]||e.multiplex===!1||c;let d;return f?d=new sy(s,e):(Jl[i]||(Jl[i]=new sy(s,e)),d=Jl[i]),n.query&&!e.query&&(e.query=n.queryKey),d.socket(n.path,e)}Object.assign(fd,{Manager:sy,Socket:cO,io:fd,connect:fd});const hz="http://localhost:3000",Ha=class Ha extends bB{constructor(){super();Rn(this,"sockets");Rn(this,"readyPromises");Rn(this,"resolveReadyMap");this.sockets=new Map,this.readyPromises=new Map,this.resolveReadyMap=new Map}static getInstance(){return Ha.instance||(Ha.instance=new Ha),Ha.instance}connect(n,s){if(this.sockets.has(n)){console.warn(`[SocketIO] Socket for agent ${n} already exists.`);return}const i=fd(hz,{query:{agentId:n,roomId:s},autoConnect:!0,reconnection:!0}),l=new Promise(c=>{this.resolveReadyMap.set(n,c)});this.readyPromises.set(n,l),i.on("connect",()=>{var f;console.log(`[SocketIO] Connected for agent ${n}`),(f=this.resolveReadyMap.get(n))==null||f();const c={type:od.ROOM_JOINING,payload:{agentId:n,roomId:s}};this.sendMessage(n,c)}),i.on("message",async c=>{var d,h,p;console.log(`[SocketIO] Message for agent ${n}:`,c,c.type);const f=c.payload;if(c.type===od.SEND_MESSAGE){const b=await kt.getAgentCompletion(n,f.senderId,f.message,f.roomId,f.source);(h=(d=b==null?void 0:b.data)==null?void 0:d.message)!=null&&h.text&&this.handleBroadcastMessage(n,(p=b==null?void 0:b.data)==null?void 0:p.name,b.data.message.text,b.data.roomId,b.data.source)}}),i.on("connect_error",c=>{console.error(`[SocketIO] Connection error for agent ${n}:`,c)}),i.on("disconnect",c=>{console.log(`[SocketIO] Disconnected for agent ${n}. Reason:`,c),c==="io server disconnect"&&i.connect()}),this.sockets.set(n,i)}async sendMessage(n,s){const i=this.sockets.get(n),l=this.readyPromises.get(n);if(!i){console.warn(`[SocketIO] Cannot send message, Socket for agent ${n} does not exist.`);return}await l,i.connected?i.emit("message",s):console.warn(`[SocketIO] Socket for agent ${n} is not connected.`)}cleanupSocket(n){this.sockets.delete(n),this.readyPromises.delete(n),this.resolveReadyMap.delete(n)}handleBroadcastMessage(n,s,i,l,c){console.log(`[SocketIO] Broadcasting: ${n} sent "${i}" to room ${l}`),this.emit("messageBroadcast",{senderId:n,senderName:s,text:i,roomId:l,createdAt:Date.now(),source:c}),this.sendMessage(n,{type:od.SEND_MESSAGE,payload:{senderId:n,senderName:s,message:i,roomId:l,worldId:Za.getWorldId(),source:c}})}disconnect(n){const s=this.sockets.get(n);s?(s.disconnect(),this.cleanupSocket(n),console.log(`[SocketIO] Socket for agent ${n} disconnected.`)):console.warn(`[SocketIO] No Socket found for agent ${n}.`)}disconnectAll(){this.sockets.forEach((n,s)=>{console.log(`[SocketIO] Closing Socket for agent ${s}`),n.connected?(n.disconnect(),this.cleanupSocket(s)):(this.cleanupSocket(s),console.warn(`[SocketIO] Socket for agent ${s} is already disconnected.`))})}};Rn(Ha,"instance",null);let ay=Ha;var Xi={},Ji={},eo={},g_;function pz(){if(g_)return eo;g_=1;var t=eo&&eo.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(eo,"__esModule",{value:!0});var e=t(Lu()),n=function(s,i){var l=e.default.useRef(null),c=e.default.useRef(s);return e.default.useEffect(function(){c.current=s},[s]),e.default.useEffect(function(){var f=function(){return c.current()};if(typeof i=="number")return l.current=window.setInterval(f,i),function(){return window.clearInterval(l.current)}},[i]),l};return eo.default=n,eo}var Ba={},v_;function mz(){if(v_)return Ba;v_=1,Object.defineProperty(Ba,"__esModule",{value:!0}),Ba.getCurrentNodeOverflow=Ba.getStringPosition=void 0;var t=function(n,s,i){return n.split(s,i).join(" ").length};Ba.getStringPosition=t;var e=function(n,s){for(var i=0,l=0,c=0;c<n.length&&!(i+n[c]>s);c++)l++,i=i+n[c];return[l,s-i]};return Ba.getCurrentNodeOverflow=e,Ba}var y_;function gz(){if(y_)return Ji;y_=1;var t=Ji&&Ji.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(Ji,"__esModule",{value:!0});var e=t(Lu()),n=t(pz()),s=mz(),i=e.default.memo(function(l){var c=l.children,f=l.delay,d=f===void 0?25:f,h=l.onEnd,p=h===void 0?function(){}:h,b=e.default.useState(0),m=b[0],v=b[1],g=e.default.useMemo(function(){var C=[],T=function(A){var R,k=(R=A==null?void 0:A.props)===null||R===void 0?void 0:R.children;return Array.isArray(A)&&A.forEach(function(j){typeof j=="object"?T(j):typeof j=="string"&&C.push(j.split(" ").length)}),k===void 0&&typeof A=="string"&&C.push(A.split(" ").length),typeof k=="object"&&T(k),typeof k=="string"&&C.push(k.split(" ").length),C};return T(c)},[c]),x=e.default.useMemo(function(){return g.reduce(function(C,T){return C+T},0)},[g]),w=e.default.useMemo(function(){var C=0,T=0,A=function(R){var k;if(C>m)return null;var j=(k=R==null?void 0:R.props)===null||k===void 0?void 0:k.children;if(Array.isArray(R)){var D=[];return R.forEach(function(U){if(typeof U=="object")D.push(A(U));else if(typeof U=="string"){C+=U.split(" ").length,T++;var G=(0,s.getCurrentNodeOverflow)(g,m),I=G[0],L=G[1];I<T&&D.push(U.slice(0,(0,s.getStringPosition)(U," ",L))),D.push(U)}}),D}if(j===void 0&&typeof R=="string"){C+=R.split(" ").length,T++;var F=(0,s.getCurrentNodeOverflow)(g,m),M=F[0],P=F[1];return M<T?R.slice(0,(0,s.getStringPosition)(R," ",P)):R}if(typeof j=="object")return e.default.createElement(R.type,R==null?void 0:R.props,A(j));if(typeof j=="string"){C+=j.split(" ").length,T++;var q=(0,s.getCurrentNodeOverflow)(g,m),M=q[0],P=q[1];return M<T?e.default.createElement(R.type,R==null?void 0:R.props,j.slice(0,(0,s.getStringPosition)(j," ",P))):R}};return A(c)},[c,m,g]);return(0,n.default)(function(){v(function(C){return C+1>=x&&p(),C+1})},x>m?d:null),e.default.useEffect(function(){console.log("hmmm"),v(0)},[c]),w});return i.displayName="AIWriter",Ji.default=i,Ji}var b_;function vz(){if(b_)return Xi;b_=1;var t=Xi&&Xi.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(Xi,"__esModule",{value:!0});var e=t(gz());return Xi.default=e.default,Xi}var yz=vz();const bz=Rr(yz);function xz({agentId:t,roomId:e}){const{data:n=[],isLoading:s,error:i}=w8(t,e),{mutate:l}=S8();if(s&&(!n||n.length===0))return S.jsx("div",{className:"flex items-center justify-center h-40",children:"Loading actions..."});if(i)return S.jsx("div",{className:"flex items-center justify-center h-40 text-destructive",children:"Error loading agent actions"});const c=h=>{const p=new Date(h);return`${p.toLocaleDateString()} ${p.toLocaleTimeString()}`},f=h=>h!=null&&h.includes("TEXT_EMBEDDING")?S.jsx(_w,{className:"w-4 h-4"}):h!=null&&h.includes("LLM")?S.jsx(bM,{className:"w-4 h-4"}):h!=null&&h.includes("IMAGE")?S.jsx(TM,{className:"w-4 h-4"}):S.jsx(_w,{className:"w-4 h-4"}),d=h=>{h&&window.confirm("Are you sure you want to delete this log entry?")&&l({agentId:t,logId:h})};return S.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[S.jsx("h3",{className:"text-lg font-medium mb-4",children:"Agent Actions"}),n.length===0?S.jsx("div",{className:"text-muted-foreground text-center p-4",children:"No actions recorded yet"}):S.jsx("div",{className:"space-y-3",children:n.map((h,p)=>{var v,g,x,w;const b=((v=h.body)==null?void 0:v.modelType)||"",m=h.type||"Action";return S.jsxs("div",{className:"border rounded-md p-3 bg-card hover:bg-accent/10 transition-colors relative group",children:[h.id&&S.jsx(Ze,{variant:"secondary",size:"icon",className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity z-50",onClick:()=>d(h.id),title:"Delete log entry",children:S.jsx(BM,{className:"h-4 w-4 text-regular"})}),S.jsxs("div",{className:"flex items-center justify-between",children:[S.jsxs("span",{className:"text-sm font-medium flex items-center gap-2",children:[f(b)," ",m]}),S.jsx(Ed,{variant:"outline",className:"text-xs group-hover:mr-8 transition-all",children:c(h.createdAt)})]}),S.jsxs("div",{className:"mt-2 grid gap-2 rounded-full",children:[((g=h.body)==null?void 0:g.modelKey)&&S.jsxs("div",{className:"text-xs bg-muted px-2 py-1 rounded",children:[S.jsx("span",{className:"font-semibold",children:"Model: "}),h.body.modelKey]}),((x=h.body)==null?void 0:x.params)&&S.jsxs("div",{className:"text-xs overflow-hidden",children:[S.jsx("span",{className:"font-semibold",children:"Params: "}),typeof h.body.params=="object"?JSON.stringify(h.body.params,null,2):h.body.params]}),((w=h.body)==null?void 0:w.response)&&S.jsx("div",{className:h.body.response==="[array]"?"text-xs italic text-muted-foreground":"text-xs overflow-hidden max-h-24 overflow-y-auto",children:h.body.response==="[array]"?"Response contains array data":S.jsxs(S.Fragment,{children:[S.jsx("span",{className:"font-semibold",children:"Response: "}),typeof h.body.response=="object"?JSON.stringify(h.body.response,null,2):h.body.response]})})]})]},h.id||p)})})]})}let eu,tu=[],Qf;const x_=(t,e)=>String(t).padStart(e,"0"),wz=({className:t,timerClassName:e,agentId:n,onChange:s})=>{const{toast:i}=tr(),[l,c]=E.useState(!1),[f,d]=E.useState(!1),[h,p]=E.useState(0),[b,m]=E.useState({id:-1,name:"",file:null}),v=Math.floor(h%3600/60),g=h%60,[x,w]=E.useMemo(()=>x_(v,2).split(""),[v]),[C,T]=E.useMemo(()=>x_(g,2).split(""),[g]),A=E.useRef({stream:null,analyser:null,mediaRecorder:null,audioContext:null}),R=zu({mutationKey:["whisper"],mutationFn:M=>kt.whisper(n,M),onSuccess:M=>{var P;(P=M==null?void 0:M.data)!=null&&P.text&&s(M.data.text)},onError:M=>{i({variant:"destructive",title:"Unable to start recording",description:M.message}),console.log(M)}});function k(){var M;(M=navigator.mediaDevices)!=null&&M.getUserMedia&&navigator.mediaDevices.getUserMedia({audio:!0}).then(P=>{c(!0);const q=window.AudioContext,U=new q,G=U.createAnalyser();U.createMediaStreamSource(P).connect(G),A.current={stream:P,analyser:G,mediaRecorder:null,audioContext:U};const N={mimeType:MediaRecorder.isTypeSupported("audio/mpeg")?"audio/mpeg":MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/wav"};A.current.mediaRecorder=new MediaRecorder(P,N),A.current.mediaRecorder.start(),tu=[],eu=new MediaRecorder(P),eu.start(),eu.ondataavailable=H=>{tu.push(H.data)}}).catch(P=>{i({variant:"destructive",title:"Unable to start recording",description:P.message}),console.log(P)})}function j(){eu.onstop=()=>{const M=new Blob(tu,{type:"audio/wav"});R.mutate(M),m({...b,file:window.URL.createObjectURL(M)}),tu=[]},eu.stop(),c(!1),d(!0),p(0),clearTimeout(Qf)}function D(){const{mediaRecorder:M,stream:P,analyser:q,audioContext:U}=A.current;if(M&&(M.onstop=()=>{tu=[]},M.stop()),q&&q.disconnect(),P)for(const G of P.getTracks())G.stop();U&&U.close(),c(!1),d(!0),p(0),clearTimeout(Qf)}const F=()=>{j()};return E.useEffect(()=>(l&&(Qf=setTimeout(()=>{p(h+1)},1e3)),()=>clearTimeout(Qf)),[l,h]),R!=null&&R.isPending?S.jsx(Ze,{variant:"ghost",disabled:!0,size:"icon",children:S.jsx(AE,{className:"size-4"})}):S.jsxs("div",{className:fe("flex items-center justify-center gap-2 border-l border-l-transparent border-opacity-0 transition-all duration-300",{"border-opacity-100 border-l-border pl-2":l},t),children:[l?S.jsxs("div",{className:"flex gap-1 items-center",children:[S.jsx("div",{className:"bg-red-500 rounded-full h-2.5 w-2.5 animate-pulse"}),S.jsx(fO,{minuteLeft:x,minuteRight:w,secondLeft:C,secondRight:T,timerClassName:e})]}):null,S.jsxs("div",{className:"flex items-center",children:[l?S.jsxs(ls,{children:[S.jsx(us,{asChild:!0,children:S.jsx(Ze,{onClick:D,size:"icon",variant:"ghost",children:S.jsx(zM,{className:"size-4"})})}),S.jsx(br,{className:"m-2",children:S.jsx("span",{children:" Reset recording"})})]}):null,S.jsxs(ls,{children:[S.jsx(us,{asChild:!0,children:l?S.jsx(Ze,{onClick:F,variant:"ghost",size:"icon",children:S.jsx(OE,{className:"size-4"})}):S.jsxs(Ze,{variant:"ghost",size:"icon",onClick:()=>k(),children:[S.jsx(kM,{className:"size-4"}),S.jsx("span",{className:"sr-only",children:"Use Microphone"})]})}),S.jsx(br,{side:"right",children:S.jsxs("span",{children:[l?"Send":"Start"," "]})})]})]})]})},fO=es.memo(({minuteLeft:t,minuteRight:e,secondLeft:n,secondRight:s,timerClassName:i})=>S.jsx("div",{className:fe("text-sm animate-in duration-1000 fade-in-0 select-none",i),children:S.jsxs("p",{children:[t,e,":",n,s]})}));fO.displayName="Timer";const Sz=({text:t})=>{const[e,n]=E.useState(!1),s=()=>{navigator.clipboard.writeText(t).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})};return S.jsxs(ls,{children:[S.jsx(us,{asChild:!0,children:S.jsx(Ze,{onClick:s,variant:"ghost",size:"icon",className:"flex items-center space-x-2 text-muted-foreground",children:e?S.jsx(hy,{className:"size-4"}):S.jsx(SM,{className:"size-4"})})}),S.jsx(br,{side:"bottom",children:S.jsx("p",{children:"Copy"})})]})};function _z({agentId:t,text:e}){const{toast:n}=tr(),[s,i]=E.useState(!1),[l,c]=E.useState(null),f=E.useRef(null),d=zu({mutationKey:["tts",e],mutationFn:()=>kt.tts(t,e),onSuccess:v=>{c(v),h()},onError:v=>{n({variant:"destructive",title:"Unable to read message aloud",description:v.message})}}),h=()=>{f.current&&f.current.play().catch(v=>{console.error("Error playing audio:",v)}),i(!0)},p=()=>{f.current&&(f.current.pause(),f.current.currentTime=0),i(!1)},b=()=>{if(!(d!=null&&d.isPending)){if(s){p();return}if(l){h();return}d.mutate()}},m="text-muted-foreground size-4";return S.jsxs("div",{children:[l?S.jsxs("audio",{crossOrigin:"anonymous",playsInline:!0,ref:f,onEnded:()=>{i(!1)},autoPlay:!0,children:[S.jsx("source",{src:URL.createObjectURL(l),type:"audio/mpeg"}),S.jsx("track",{kind:"captions",src:"",label:"English captions"}),"Your browser does not support the audio element."]}):null,S.jsxs(ls,{children:[S.jsx(us,{asChild:!0,children:S.jsx(Ze,{size:"icon",variant:"ghost",type:"button",onClick:()=>b(),disabled:d==null?void 0:d.isPending,children:d!=null&&d.isPending?S.jsx(AE,{className:m}):s?S.jsx(wM,{className:m}):S.jsx(UM,{className:m})})}),S.jsx(br,{side:"bottom",children:S.jsx("p",{children:s?"Stop":"Read aloud"})})]})]})}function Ez(t={}){const{offset:e=20,smooth:n=!1}=t,s=E.useRef(null),i=E.useRef(0),l=E.useRef(!1),[c,f]=E.useState({isAtBottom:!0,autoScrollEnabled:!0}),d=E.useCallback(m=>{const{scrollTop:v,scrollHeight:g,clientHeight:x}=m;return Math.abs(g-v-x)<=e},[e]),h=E.useCallback(m=>{if(!s.current)return;const v=s.current.scrollHeight-s.current.clientHeight;m?s.current.scrollTop=v:s.current.scrollTo({top:v,behavior:n?"smooth":"auto"}),f({isAtBottom:!0,autoScrollEnabled:!0}),l.current=!1},[n]),p=E.useCallback(()=>{if(!s.current)return;const m=d(s.current);f(v=>({isAtBottom:m,autoScrollEnabled:m?!0:v.autoScrollEnabled}))},[d]);E.useEffect(()=>{const m=s.current;if(m)return m.addEventListener("scroll",p,{passive:!0}),()=>m.removeEventListener("scroll",p)},[p]),E.useEffect(()=>{const m=s.current;if(!m)return;const v=m.scrollHeight;v!==i.current&&(c.autoScrollEnabled&&requestAnimationFrame(()=>{h(i.current===0)}),i.current=v)},[c.autoScrollEnabled,h]),E.useEffect(()=>{const m=s.current;if(!m)return;const v=new ResizeObserver(()=>{c.autoScrollEnabled&&h(!0)});return v.observe(m),()=>v.disconnect()},[c.autoScrollEnabled,h]);const b=E.useCallback(()=>{(s.current?d(s.current):!1)||(l.current=!0,f(v=>({...v,autoScrollEnabled:!1})))},[d]);return{scrollRef:s,isAtBottom:c.isAtBottom,autoScrollEnabled:c.autoScrollEnabled,scrollToBottom:()=>h(!1),disableAutoScroll:b}}const Cz="client_chat";function Tz({message:t,agentId:e,isLastMessage:n}){var s;return S.jsxs("div",{className:"flex flex-col",children:[S.jsxs(WA,{isLoading:t.isLoading,...t.name===as?{variant:"sent"}:{},children:[t.name===as?t.text:n&&t.name!==as?S.jsx(bz,{children:t.text}):t.text,S.jsx("div",{children:(s=t.attachments)==null?void 0:s.map(i=>S.jsxs("div",{className:"flex flex-col gap-1 mt-2",children:[S.jsx("img",{alt:"attachment",src:i.url,width:"100%",height:"100%",className:"w-64 rounded-md"}),S.jsxs("div",{className:"flex items-center justify-between gap-4",children:[S.jsx("span",{}),S.jsx("span",{})]})]},`${i.url}-${i.title}`))})]}),S.jsxs("div",{className:"flex items-center gap-4 justify-between w-full mt-1",children:[t.text&&!t.isLoading?S.jsxs("div",{className:"flex items-center gap-1",children:[S.jsx(Sz,{text:t.text}),S.jsx(_z,{agentId:e,text:t.text})]}):null,S.jsxs("div",{className:fe([t.isLoading?"mt-2":"","flex items-center justify-between gap-4 select-none"]),children:[t.thought?S.jsx(Ed,{variant:"outline",children:t.thought}):null,t.plan?S.jsx(Ed,{variant:"outline",children:t.plan}):null,t.createdAt?S.jsx(mB,{timestamp:U3(t.createdAt).format("LT")}):null]})]})]})}function Rz({agentId:t}){var U,G,I,L;const[e,n]=E.useState(null),[s,i]=E.useState(""),[l,c]=E.useState(!1),[f,d]=E.useState("actions"),h=E.useRef(null),p=E.useRef(null),b=E.useRef(null),m=er(),v=Za.getWorldId(),g=(G=(U=v8(t))==null?void 0:U.data)==null?void 0:G.data,x=H3(),w=t,{data:C=[]}=x8(t,w),T=ay.getInstance();E.useEffect(()=>{T.connect(t,w),T.connect(x,w);const N=H=>{m.setQueryData(["messages",t,w,v],(V=[])=>[...V,{...H,name:H.senderName}])};return T.on("messageBroadcast",N),()=>{T.disconnectAll(),T.off("messageBroadcast",N)}},[w]);const A=N=>N!==x?"received":"sent",{scrollRef:R,isAtBottom:k,scrollToBottom:j,disableAutoScroll:D}=Ez({smooth:!0});E.useEffect(()=>{j()},[C.length]),E.useEffect(()=>{j()},[]);const F=N=>{if(N.key==="Enter"&&!N.shiftKey){if(N.preventDefault(),N.nativeEvent.isComposing)return;M(N)}},M=N=>{var H;N.preventDefault(),s&&(T.handleBroadcastMessage(x,as,s,w,Cz),n(null),i(""),(H=b.current)==null||H.reset())};E.useEffect(()=>{h.current&&h.current.focus()},[]);const P=N=>{var V;const H=(V=N.target.files)==null?void 0:V[0];H!=null&&H.type.startsWith("image/")&&n(H)},q=()=>{c(!l)};return S.jsxs("div",{className:"flex flex-col w-full h-screen p-4",children:[S.jsxs("div",{className:"flex items-center justify-between mb-4 p-3 bg-card rounded-lg border",children:[S.jsxs("div",{className:"flex items-center gap-3",children:[S.jsx(Zv,{className:"size-10 border rounded-full",children:S.jsx(Xv,{src:(I=g==null?void 0:g.settings)!=null&&I.avatar?(L=g==null?void 0:g.settings)==null?void 0:L.avatar:"/elizaos-icon.png"})}),S.jsxs("div",{className:"flex flex-col",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("h2",{className:"font-semibold text-lg",children:(g==null?void 0:g.name)||"Agent"}),(g==null?void 0:g.status)===Nn.ACTIVE?S.jsxs(ls,{children:[S.jsx(us,{asChild:!0,children:S.jsx("div",{className:"size-2.5 rounded-full bg-green-500 ring-2 ring-green-500/20 animate-pulse"})}),S.jsx(br,{side:"right",children:S.jsx("p",{children:"Agent is active"})})]}):S.jsxs(ls,{children:[S.jsx(us,{asChild:!0,children:S.jsx("div",{className:"size-2.5 rounded-full bg-gray-300 ring-2 ring-gray-300/20"})}),S.jsx(br,{side:"right",children:S.jsx("p",{children:"Agent is inactive"})})]})]}),(g==null?void 0:g.bio)&&S.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:Array.isArray(g.bio)?g.bio[0]:g.bio})]})]}),S.jsx(Ze,{variant:"outline",size:"sm",onClick:q,className:fe("gap-1.5",l&&"bg-secondary"),children:S.jsx(OM,{className:"size-4"})})]}),S.jsxs("div",{className:"flex flex-row w-full overflow-y-auto grow gap-4",children:[S.jsxs("div",{className:fe("flex flex-col transition-all duration-300",l?"w-3/5":"w-full"),children:[S.jsx(ZA,{scrollRef:R,isAtBottom:k,scrollToBottom:j,disableAutoScroll:D,children:C.map((N,H)=>{var Q,z;const V=N.name===as;return S.jsx("div",{className:`flex flex-column gap-1 p-1 ${V?"justify-end":""}`,children:S.jsxs(QA,{variant:A(V?x:t),className:`flex flex-row items-center gap-2 ${V?"flex-row-reverse":""}`,children:[S.jsxs(Zv,{className:"size-8 border rounded-full select-none",children:[S.jsx(Xv,{src:V?"/user-icon.png":(Q=g==null?void 0:g.settings)!=null&&Q.avatar?(z=g==null?void 0:g.settings)==null?void 0:z.avatar:"/elizaos-icon.png"}),V&&S.jsx(YA,{children:"U"})]}),S.jsx(Tz,{message:N,agentId:t,isLastMessage:H===C.length-1})]})},`${N.id}-${N.createdAt}`)})}),S.jsx("div",{className:"px-4 pb-4 mt-auto",children:S.jsxs("form",{ref:b,onSubmit:M,className:"relative rounded-md border bg-card",children:[e?S.jsx("div",{className:"p-3 flex",children:S.jsxs("div",{className:"relative rounded-md border p-2",children:[S.jsx(Ze,{onClick:()=>n(null),className:"absolute -right-2 -top-2 size-[22px] ring-2 ring-background",variant:"outline",size:"icon",children:S.jsx(ui,{})}),S.jsx("img",{alt:"Selected file",src:URL.createObjectURL(e),height:"100%",width:"100%",className:"aspect-square object-contain w-16"})]})}):null,S.jsx(KA,{ref:h,onKeyDown:F,value:s,onChange:({target:N})=>i(N.value),placeholder:"Type your message here...",className:"min-h-12 resize-none rounded-md bg-card border-0 p-3 shadow-none focus-visible:ring-0"}),S.jsxs("div",{className:"flex items-center p-3 pt-0",children:[S.jsxs(ls,{children:[S.jsx(us,{asChild:!0,children:S.jsxs("div",{children:[S.jsxs(Ze,{variant:"ghost",size:"icon",onClick:()=>{p.current&&p.current.click()},children:[S.jsx(LM,{className:"size-4"}),S.jsx("span",{className:"sr-only",children:"Attach file"})]}),S.jsx("input",{type:"file",ref:p,onChange:P,accept:"image/*",className:"hidden"})]})}),S.jsx(br,{side:"left",children:S.jsx("p",{children:"Attach file"})})]}),S.jsx(wz,{agentId:t,onChange:N=>i(N)}),S.jsx(Ze,{type:"submit",size:"sm",className:"ml-auto gap-1.5 h-[30px]",children:S.jsx(OE,{className:"size-3.5"})})]})]})})]}),l&&S.jsx("div",{className:"w-2/5 border rounded-lg overflow-hidden pb-4 bg-background flex flex-col h-full",children:S.jsxs(wT,{defaultValue:"actions",value:f,onValueChange:N=>d(N),className:"flex flex-col h-full",children:[S.jsx("div",{className:"border-b px-4 py-2",children:S.jsxs(By,{className:"grid grid-cols-2",children:[S.jsxs(hu,{value:"actions",className:"flex items-center gap-1.5",children:[S.jsx(TE,{className:"h-4 w-4"}),S.jsx("span",{children:"Agent Actions"})]}),S.jsxs(hu,{value:"logs",className:"flex items-center gap-1.5",children:[S.jsx(NE,{className:"h-4 w-4"}),S.jsx("span",{children:"Logs"})]})]})}),S.jsx(pu,{value:"actions",className:"overflow-y-scroll",children:S.jsx(xz,{agentId:t,roomId:w})}),S.jsx(pu,{value:"logs",children:S.jsx(dA,{agentName:g==null?void 0:g.name,level:"all",hideTitle:!0})})]})})]})]})}function Az(){const{agentId:t}=HC();return t?S.jsx(Rz,{agentId:t}):S.jsx("div",{children:"No data."})}function Oz(){return S.jsx(NT,{})}function Nz({title:t,content:e,buttons:n}){return S.jsxs(Fu,{className:"h-full",children:[S.jsx(JC,{className:"pb-2 pt-3",children:S.jsx(eT,{className:"text-base truncate max-w-48",children:t})}),S.jsx(Xd,{className:"p-3",children:S.jsx("div",{className:"rounded-md bg-muted w-full mb-3 overflow-hidden",style:{aspectRatio:"1 / 1"},children:S.jsx("div",{className:"flex items-center justify-center h-full",children:S.jsx("div",{className:"text-4xl font-bold uppercase h-full flex items-center justify-center w-full",children:e})})})}),S.jsx(tT,{className:"p-3 pb-4",children:S.jsx("div",{className:"flex items-center gap-2 w-full justify-center",children:n.map(({label:s,icon:i,action:l,className:c,variant:f,size:d,disabled:h},p)=>S.jsxs(Ze,{variant:f,className:c,onClick:l,size:d,disabled:h,children:[i,s&&S.jsx("span",{children:s})]},p))})})]})}function dO(){Bo();const t=er(),{toast:e}=tr(),n=y8(),s=b8(),[i,l]=E.useState([]),[c,f]=E.useState([]);return{startAgent:async m=>{if(!m.id){e({title:"Error",description:"Agent ID is missing",variant:"destructive"});return}const v=m.id;if(!i.includes(v))try{l(g=>[...g,v]),await n.mutateAsync(v),t.invalidateQueries({queryKey:["active-agents"]})}catch(g){console.error("Failed to start agent:",g),e({title:"Error Starting Agent",description:g instanceof Error?g.message:"Failed to start agent",variant:"destructive"})}finally{l(g=>g.filter(x=>x!==v))}},stopAgent:async m=>{if(!m.id){e({title:"Error",description:"Agent ID is missing",variant:"destructive"});return}const v=m.id;if(!c.includes(v))try{f(g=>[...g,v]),await s.mutateAsync(v),t.invalidateQueries({queryKey:["active-agents"]}),e({title:"Agent Stopped",description:`${m.name} has been stopped`})}catch(g){console.error("Failed to stop agent:",g),e({title:"Error Stopping Agent",description:g instanceof Error?g.message:"Failed to stop agent",variant:"destructive"})}finally{f(g=>g.filter(x=>x!==v))}},isAgentStarting:m=>m?i.includes(m):!1,isAgentStopping:m=>m?c.includes(m):!1,startingAgents:i,stoppingAgents:c}}function kz({isOpen:t,onClose:e,agent:n}){var C;if(!t)return null;const{startAgent:s,stopAgent:i,isAgentStarting:l,isAgentStopping:c}=dO(),f=Bo(),d=n.status==="active",h=l(n.id),p=c(n.id),b=h||p,m=E.useRef(null),[v,g]=E.useState(!1);let x="Start",w=S.jsx(DM,{});return h?(x="Starting...",w=S.jsx(Ew,{className:"animate-spin"})):p?(x="Stopping...",w=S.jsx(Ew,{className:"animate-spin"})):d&&(w=S.jsx(IM,{fill:"#EF4444",size:16})),E.useEffect(()=>{const T=A=>{m.current&&!m.current.contains(A.target)&&g(!1)};return document.addEventListener("mousedown",T),()=>{document.removeEventListener("mousedown",T)}},[]),S.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-80 flex items-center justify-center z-50",onClick:e,children:S.jsxs(Fu,{className:"flex flex-col items-center justify-between h-[70vh] w-[70vh]",onClick:T=>T.stopPropagation(),children:[S.jsx("div",{className:"p-3 h-[30%] w-full flex items-end",children:S.jsxs("div",{className:"flex w-full h-full justify-between items-end",children:[S.jsxs("div",{className:"flex flex-col gap-2",children:[S.jsxs("div",{className:"w-20 h-20 flex justify-center items-center relative",children:[n&&S.jsx("div",{className:"text-4xl bg-muted rounded-full h-full w-full flex justify-center items-center overflow-hidden",children:(C=n.settings)!=null&&C.avatar?S.jsx("img",{src:n.settings.avatar,alt:"Agent Avatar",className:"w-full h-full object-contain"}):dd(n.name)}),S.jsx("div",{className:`absolute bottom-1 right-1 w-4 h-4 rounded-full border-2 border-white ${d?"bg-green-500":"bg-muted-foreground"}`})]}),S.jsx("div",{className:"flex justify-center items-center mr-4 font-bold",children:n&&S.jsx("div",{className:"text-xl truncate max-w-48",children:n.name})})]}),S.jsx("div",{className:"flex flex-col items-end justify-end h-full",children:S.jsxs("div",{className:"flex gap-1",children:[S.jsxs(Ze,{variant:"secondary",className:"mr-4",onClick:()=>{g(!1),f(`/settings/${n.id}`)},children:[S.jsx("div",{children:S.jsx(py,{className:"w-4 h-4"})}),S.jsx("div",{children:"Settings"})]}),S.jsxs(Ze,{variant:"secondary",className:"mr-4",onClick:()=>{d&&f(`/chat/${n.id}`)},size:"default",disabled:!d,children:[S.jsx(NM,{className:"w-10 h-10 rounded-full",style:{height:14,width:14}}),"Message"]}),S.jsxs(Ze,{variant:"secondary",className:`mr-4 ${d?"text-red-500":""}`,onClick:()=>{b||(d?i(n):s(n))},size:"default",disabled:b,children:[w,x]})]})})]})}),S.jsx(Xd,{className:"p-3 h-[70%] w-full",children:S.jsx("div",{className:"rounded-md bg-muted h-full w-full mb-3",children:S.jsx("div",{className:"flex h-full",children:S.jsx("div",{className:"p-6 overflow-scroll flex flex-col gap-2",children:S.jsxs("div",{children:[S.jsx("p",{className:"font-light",children:"About Me"}),n&&S.jsx("p",{className:"font-light text-sm text-gray-500",children:n==null?void 0:n.system})]})})})})})]})})}function Mz(){const{data:{data:t}={},isLoading:e,isError:n,error:s}=qy(),i=Bo(),l=(t==null?void 0:t.agents)||[],[c,f]=E.useState(!1),[d,h]=E.useState(null),{startAgent:p,isAgentStarting:b,isAgentStopping:m}=dO(),v=x=>{h(x),f(!0)},g=()=>{h(null),f(!1)};return S.jsxs(S.Fragment,{children:[S.jsxs("div",{className:"flex flex-col gap-4 h-full p-4",children:[S.jsx("div",{className:"flex items-center justify-between",children:S.jsx(hR,{title:"Agents"})}),e&&S.jsx("div",{className:"text-center py-8",children:"Loading agents..."}),n&&S.jsxs("div",{className:"text-center py-8 text-destructive",children:["Error loading agents:"," ",s instanceof Error?s.message:"Unknown error"]}),l.length===0&&!e&&S.jsx("div",{className:"text-center py-8 flex flex-col items-center gap-4",children:S.jsx("p",{className:"text-muted-foreground",children:"No agents currently running. Start a character to begin."})}),!e&&!n&&S.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4 p-3",children:[l==null?void 0:l.sort((x,w)=>Number(w==null?void 0:w.enabled)-Number(x==null?void 0:x.enabled)).map(x=>{var w;return S.jsx(Nz,{title:S.jsxs("div",{className:"flex gap-2 items-center",children:[S.jsx("div",{className:"",children:x.name}),(x==null?void 0:x.status)===Nn.ACTIVE?S.jsxs(yd,{children:[S.jsx(bd,{asChild:!0,children:S.jsx("div",{className:"size-2.5 rounded-full bg-green-500 ring-2 ring-green-500/20 animate-pulse mt-[2px]"})}),S.jsx(xd,{side:"right",children:S.jsx("p",{children:"Agent is active"})})]}):S.jsxs(yd,{children:[S.jsx(bd,{asChild:!0,children:S.jsx("div",{className:"size-2.5 rounded-full bg-gray-300 ring-2 ring-gray-300/20 mt-[2px]"})}),S.jsx(xd,{side:"right",children:S.jsx("p",{children:"Agent is inactive"})})]})]}),content:S.jsxs("div",{className:"relative cursor-pointer h-full w-full flex items-center justify-center group",onClick:()=>v(x),children:[S.jsx("div",{className:x.status===Nn.ACTIVE?"brightness-[100%] hover:brightness-[107%]":"grayscale brightness-[75%] opacity-50 hover:brightness-[85%]",children:(w=x.settings)!=null&&w.avatar?S.jsx("img",{src:x.settings.avatar,alt:"Agent Avatar",className:"w-full h-full object-contain"}):dd(x.name)}),x.status!==Nn.ACTIVE&&S.jsx("span",{className:"absolute bottom-4 left-1/2 transform -translate-x-1/2 bg-black text-white text-xs px-2 py-1 rounded-md opacity-60",children:"Offline"})]}),buttons:[x.status===Nn.ACTIVE?{label:"Message",action:()=>i(`/chat/${x.id}`),className:"w-[80%]",variant:"default"}:{label:b(x.id)?"Starting...":m(x.id)?"Stopping...":"Start",action:()=>p(x),className:"w-[80%]",variant:"default",disabled:b(x.id)||m(x.id)},{icon:S.jsx(AM,{style:{height:16,width:16}}),className:"w-10 h-10 rounded-full",action:()=>{v(x)},variant:"outline"},{icon:S.jsx(py,{style:{height:16,width:16}}),className:"w-10 h-10 rounded-full",action:()=>i(`/settings/${x.id}`),variant:"outline"}]},x.id)}),S.jsx(Fu,{className:"flex flex-col items-center justify-center h-full cursor-pointer hover:bg-accent/50 transition-colors",onClick:()=>i("/create"),children:S.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 p-8",children:[S.jsx(jM,{size:40,className:"text-muted-foreground"}),S.jsx("span",{className:"text-muted-foreground whitespace-nowrap",children:"Create New Agent"})]})})]})]}),S.jsx(kz,{isOpen:c,onClose:g,agent:l.find(x=>x.id===(d==null?void 0:d.id))||d,agents:l})]})}function Lz({agent:t,agentId:e}){const{toast:n}=tr(),s=Bo(),i=er(),[l,c]=E.useState(t),f=async h=>{try{if(!e)throw new Error("Agent ID is missing");const p={...h,plugins:l.plugins};await kt.updateAgent(e,p),i.invalidateQueries({queryKey:["agent",e]}),i.invalidateQueries({queryKey:["agents"]}),s("/"),n({title:"Success",description:"Agent updated and restarted successfully"})}catch(p){throw n({title:"Error",description:p instanceof Error?p.message:"Failed to update agent",variant:"destructive"}),p}},d=async h=>{try{await kt.deleteAgent(h.id),i.invalidateQueries({queryKey:["agents"]}),s("/")}catch(p){console.error("Error deleting agent:",p)}};return S.jsx(ST,{characterValue:l,setCharacterValue:c,title:"Character Settings",description:"Configure your AI character's behavior and capabilities",onSubmit:f,onReset:()=>c(t),onDelete:()=>d(t),isAgent:!0,customComponents:[{name:"Plugins",component:S.jsx(AT,{characterValue:l,setCharacterValue:c})},{name:"Secret",component:S.jsx(OT,{characterValue:l,setCharacterValue:c})},{name:"Avatar",component:S.jsx(_T,{characterValue:l,setCharacterValue:c})}]})}function Dz(){var s;const{agentId:t}=HC(),e=da({queryKey:["agent",t],queryFn:()=>kt.getAgent(t??""),staleTime:Qn.FREQUENT,refetchInterval:5e3,enabled:!!t});if(!t)return S.jsx("div",{children:"No data."});const n=(s=e==null?void 0:e.data)==null?void 0:s.data;return n?S.jsx(Lz,{agent:n,agentId:t}):null}const hO=new J5({defaultOptions:{queries:{staleTime:Qn.STANDARD,refetchInterval:!1,retry:3,retryDelay:t=>Math.min(1e3*2**t,3e4),refetchOnWindowFocus:!0,refetchOnReconnect:!0},mutations:{retry:3,retryDelay:t=>Math.min(1e3*2**t,3e4)}}}),pO=async()=>{try{await hO.prefetchQuery({queryKey:["agents"],queryFn:()=>kt.getAgents(),staleTime:Qn.FREQUENT})}catch(t){console.error("Error prefetching initial data:",t)}};pO();function jz(){return lB(),E.useEffect(()=>{pO()},[]),S.jsx(sD,{client:hO,children:S.jsx("div",{className:"dark antialiased",style:{colorScheme:"dark"},children:S.jsx(Aj,{children:S.jsxs(uC,{delayDuration:0,children:[S.jsxs(fC,{children:[S.jsx(F7,{}),S.jsx(hC,{children:S.jsxs(aj,{children:[S.jsx(za,{path:"/",element:S.jsx(Mz,{})}),S.jsx(za,{path:"chat/:agentId",element:S.jsx(Az,{})}),S.jsx(za,{path:"settings/:agentId",element:S.jsx(Dz,{})}),S.jsx(za,{path:"agents/new",element:S.jsx(Oz,{})}),S.jsx(za,{path:"/create",element:S.jsx(NT,{})}),S.jsx(za,{path:"/logs",element:S.jsx(dA,{})})]})})]}),S.jsx(oB,{})]})})})})}const mO=document.getElementById("root");if(!mO)throw new Error("Root element not found");X4.createRoot(mO).render(S.jsx(E.StrictMode,{children:S.jsx(jz,{})}));export{ZP as a,U4 as c,Rr as g,so as r};
|