@alexberardi/jarvis-admin 0.1.76 → 0.1.77
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/package.json
CHANGED
|
@@ -15,4 +15,4 @@ Please change the parent <Route path="${k}"> to <Route path="${k==="/"?"*":`${k}
|
|
|
15
15
|
`):" "+Cx(m[0]):"as no adapter specified";throw new we("There is no suitable adapter to dispatch the request "+v,"ERR_NOT_SUPPORT")}return d}const Xv={getAdapter:dj,adapters:Dd};function Fu(a){if(a.cancelToken&&a.cancelToken.throwIfRequested(),a.signal&&a.signal.aborted)throw new El(null,a)}function Tx(a){return Fu(a),a.headers=Zt.from(a.headers),a.data=Vu.call(a,a.transformRequest),["post","put","patch"].indexOf(a.method)!==-1&&a.headers.setContentType("application/x-www-form-urlencoded",!1),Xv.getAdapter(a.adapter||wl.adapter,a)(a).then(function(i){return Fu(a),i.data=Vu.call(a,a.transformResponse,i),i.headers=Zt.from(i.headers),i},function(i){return Gv(i)||(Fu(a),i&&i.response&&(i.response.data=Vu.call(a,a.transformResponse,i.response),i.response.headers=Zt.from(i.response.headers))),Promise.reject(i)})}const Kv="1.13.4",pi={};["object","boolean","number","function","string","symbol"].forEach((a,s)=>{pi[a]=function(i){return typeof i===a||"a"+(s<1?"n ":" ")+a}});const _x={};pi.transitional=function(s,o,i){function d(f,m){return"[Axios v"+Kv+"] Transitional option '"+f+"'"+m+(i?". "+i:"")}return(f,m,v)=>{if(s===!1)throw new we(d(m," has been removed"+(o?" in "+o:"")),we.ERR_DEPRECATED);return o&&!_x[m]&&(_x[m]=!0,console.warn(d(m," has been deprecated since v"+o+" and will be removed in the near future"))),s?s(f,m,v):!0}};pi.spelling=function(s){return(o,i)=>(console.warn(`${i} is likely a misspelling of ${s}`),!0)};function fj(a,s,o){if(typeof a!="object")throw new we("options must be an object",we.ERR_BAD_OPTION_VALUE);const i=Object.keys(a);let d=i.length;for(;d-- >0;){const f=i[d],m=s[f];if(m){const v=a[f],g=v===void 0||m(v,f,a);if(g!==!0)throw new we("option "+f+" must be "+g,we.ERR_BAD_OPTION_VALUE);continue}if(o!==!0)throw new we("Unknown option "+f,we.ERR_BAD_OPTION)}}const ei={assertOptions:fj,validators:pi},Oa=ei.validators;let ir=class{constructor(s){this.defaults=s||{},this.interceptors={request:new xx,response:new xx}}async request(s,o){try{return await this._request(s,o)}catch(i){if(i instanceof Error){let d={};Error.captureStackTrace?Error.captureStackTrace(d):d=new Error;const f=d.stack?d.stack.replace(/^.+\n/,""):"";try{i.stack?f&&!String(i.stack).endsWith(f.replace(/^.+\n.+\n/,""))&&(i.stack+=`
|
|
16
16
|
`+f):i.stack=f}catch{}}throw i}}_request(s,o){typeof s=="string"?(o=o||{},o.url=s):o=s||{},o=dr(this.defaults,o);const{transitional:i,paramsSerializer:d,headers:f}=o;i!==void 0&&ei.assertOptions(i,{silentJSONParsing:Oa.transitional(Oa.boolean),forcedJSONParsing:Oa.transitional(Oa.boolean),clarifyTimeoutError:Oa.transitional(Oa.boolean)},!1),d!=null&&(V.isFunction(d)?o.paramsSerializer={serialize:d}:ei.assertOptions(d,{encode:Oa.function,serialize:Oa.function},!0)),o.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?o.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:o.allowAbsoluteUrls=!0),ei.assertOptions(o,{baseUrl:Oa.spelling("baseURL"),withXsrfToken:Oa.spelling("withXSRFToken")},!0),o.method=(o.method||this.defaults.method||"get").toLowerCase();let m=f&&V.merge(f.common,f[o.method]);f&&V.forEach(["delete","get","head","post","put","patch","common"],w=>{delete f[w]}),o.headers=Zt.concat(m,f);const v=[];let g=!0;this.interceptors.request.forEach(function(E){typeof E.runWhen=="function"&&E.runWhen(o)===!1||(g=g&&E.synchronous,v.unshift(E.fulfilled,E.rejected))});const h=[];this.interceptors.response.forEach(function(E){h.push(E.fulfilled,E.rejected)});let y,x=0,S;if(!g){const w=[Tx.bind(this),void 0];for(w.unshift(...v),w.push(...h),S=w.length,y=Promise.resolve(o);x<S;)y=y.then(w[x++],w[x++]);return y}S=v.length;let R=o;for(;x<S;){const w=v[x++],E=v[x++];try{R=w(R)}catch(_){E.call(this,_);break}}try{y=Tx.call(this,R)}catch(w){return Promise.reject(w)}for(x=0,S=h.length;x<S;)y=y.then(h[x++],h[x++]);return y}getUri(s){s=dr(this.defaults,s);const o=Vv(s.baseURL,s.url,s.allowAbsoluteUrls);return Bv(o,s.params,s.paramsSerializer)}};V.forEach(["delete","get","head","options"],function(s){ir.prototype[s]=function(o,i){return this.request(dr(i||{},{method:s,url:o,data:(i||{}).data}))}});V.forEach(["post","put","patch"],function(s){function o(i){return function(f,m,v){return this.request(dr(v||{},{method:s,headers:i?{"Content-Type":"multipart/form-data"}:{},url:f,data:m}))}}ir.prototype[s]=o(),ir.prototype[s+"Form"]=o(!0)});let mj=class $v{constructor(s){if(typeof s!="function")throw new TypeError("executor must be a function.");let o;this.promise=new Promise(function(f){o=f});const i=this;this.promise.then(d=>{if(!i._listeners)return;let f=i._listeners.length;for(;f-- >0;)i._listeners[f](d);i._listeners=null}),this.promise.then=d=>{let f;const m=new Promise(v=>{i.subscribe(v),f=v}).then(d);return m.cancel=function(){i.unsubscribe(f)},m},s(function(f,m,v){i.reason||(i.reason=new El(f,m,v),o(i.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(s){if(this.reason){s(this.reason);return}this._listeners?this._listeners.push(s):this._listeners=[s]}unsubscribe(s){if(!this._listeners)return;const o=this._listeners.indexOf(s);o!==-1&&this._listeners.splice(o,1)}toAbortSignal(){const s=new AbortController,o=i=>{s.abort(i)};return this.subscribe(o),s.signal.unsubscribe=()=>this.unsubscribe(o),s.signal}static source(){let s;return{token:new $v(function(d){s=d}),cancel:s}}};function hj(a){return function(o){return a.apply(null,o)}}function pj(a){return V.isObject(a)&&a.isAxiosError===!0}const md={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(md).forEach(([a,s])=>{md[s]=a});function Zv(a){const s=new ir(a),o=Tv(ir.prototype.request,s);return V.extend(o,ir.prototype,s,{allOwnKeys:!0}),V.extend(o,s,null,{allOwnKeys:!0}),o.create=function(d){return Zv(dr(a,d))},o}const nt=Zv(wl);nt.Axios=ir;nt.CanceledError=El;nt.CancelToken=mj;nt.isCancel=Gv;nt.VERSION=Kv;nt.toFormData=hi;nt.AxiosError=we;nt.Cancel=nt.CanceledError;nt.all=function(s){return Promise.all(s)};nt.spread=hj;nt.isAxiosError=pj;nt.mergeConfig=dr;nt.AxiosHeaders=Zt;nt.formToJSON=a=>Hv(V.isHTMLForm(a)?new FormData(a):a);nt.getAdapter=Xv.getAdapter;nt.HttpStatusCode=md;nt.default=nt;const{Axios:d3,AxiosError:f3,CanceledError:m3,isCancel:h3,CancelToken:p3,VERSION:x3,all:v3,Cancel:g3,isAxiosError:y3,spread:b3,toFormData:N3,AxiosHeaders:j3,HttpStatusCode:S3,formToJSON:w3,getAdapter:E3,mergeConfig:C3}=nt,be=nt.create({baseURL:""});function rs(a){a?be.defaults.headers.common.Authorization=`Bearer ${a}`:delete be.defaults.headers.common.Authorization}let hd=null;function xj(a){hd=a}let Jv=null;function vj(a){Jv=a}be.interceptors.request.use(a=>{if(!a.headers.Authorization){const s=localStorage.getItem("jarvis-admin:access_token")??localStorage.getItem("access_token");s&&(a.headers.Authorization=`Bearer ${s}`)}return a});be.interceptors.response.use(a=>a,async a=>{const s=a.config;if(s.url?.startsWith("/api/auth/"))return Promise.reject(a);if(a.response?.status===401&&!s._retry&&hd){s._retry=!0;const o=await hd();if(o)return s.headers.Authorization=`Bearer ${o}`,be(s);Jv?.()}return Promise.reject(a)});async function gj(){const{data:a}=await be.get("/api/auth/setup-status");return a}async function Pv(a,s,o){const{data:i}=await be.post("/api/auth/setup",{email:a,password:s,username:o});return i}async function yj(a,s){const{data:o}=await be.post("/api/auth/login",{email:a,password:s});return o}async function bj(a){const{data:s}=await be.post("/api/auth/refresh",{refresh_token:a});return s}const Iv=N.createContext(void 0),ml="jarvis-admin:access_token",ts="jarvis-admin:refresh_token",Yo="jarvis-admin:user",Nj=600*1e3;function jj({children:a}){const[s,o]=N.useState(()=>{const g=localStorage.getItem(ml),h=localStorage.getItem(ts),y=localStorage.getItem(Yo);if(g&&h&&y)try{const x=JSON.parse(y);return rs(g),{user:x,accessToken:g,refreshToken:h,isAuthenticated:!0,isLoading:!1,error:null}}catch{}return{user:null,accessToken:null,refreshToken:null,isAuthenticated:!1,isLoading:!1,error:null}}),i=N.useCallback(()=>{localStorage.removeItem(ml),localStorage.removeItem(ts),localStorage.removeItem(Yo),rs(null),o({user:null,accessToken:null,refreshToken:null,isAuthenticated:!1,isLoading:!1,error:null})},[]),d=N.useCallback(async()=>{const g=localStorage.getItem(ts);if(!g)return null;try{const h=await bj(g),y=h.access_token,x=h.refresh_token??g;return localStorage.setItem(ml,y),localStorage.setItem(ts,x),rs(y),o(S=>({...S,accessToken:y,refreshToken:x})),y}catch{return i(),null}},[i]);N.useEffect(()=>{xj(d),vj(i)},[d,i]),N.useEffect(()=>{if(!s.isAuthenticated)return;const g=setInterval(()=>{d()},Nj);return()=>clearInterval(g)},[s.isAuthenticated,d]);const f=N.useCallback(async(g,h)=>{o(y=>({...y,error:null,isLoading:!0}));try{const y=await yj(g,h);if(!y.user.is_superuser){o(x=>({...x,isLoading:!1,error:"Admin access required. This account is not a superuser."}));return}localStorage.setItem(ml,y.access_token),localStorage.setItem(ts,y.refresh_token),localStorage.setItem(Yo,JSON.stringify(y.user)),rs(y.access_token),o({user:y.user,accessToken:y.access_token,refreshToken:y.refresh_token,isAuthenticated:!0,isLoading:!1,error:null})}catch(y){const x=y?.response?.data?.detail??"Login failed";o(S=>({...S,isLoading:!1,error:x}))}},[]),m=N.useCallback(async(g,h,y)=>{o(x=>({...x,error:null,isLoading:!0}));try{const x=await Pv(g,h,y);localStorage.setItem(ml,x.access_token),localStorage.setItem(ts,x.refresh_token),localStorage.setItem(Yo,JSON.stringify(x.user)),rs(x.access_token),o({user:x.user,accessToken:x.access_token,refreshToken:x.refresh_token,isAuthenticated:!0,isLoading:!1,error:null})}catch(x){const S=x?.response?.data?.detail??"Setup failed";o(R=>({...R,isLoading:!1,error:S}))}},[]),v=N.useMemo(()=>({state:s,login:f,setup:m,logout:i}),[s,f,m,i]);return l.jsx(Iv.Provider,{value:v,children:a})}function Ud(){const a=N.useContext(Iv);if(!a)throw new Error("useAuth must be used within AuthProvider");return a}const Wv=(...a)=>a.filter((s,o,i)=>!!s&&s.trim()!==""&&i.indexOf(s)===o).join(" ").trim();const Sj=a=>a.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const wj=a=>a.replace(/^([A-Z])|[\s-_]+(\w)/g,(s,o,i)=>i?i.toUpperCase():o.toLowerCase());const Rx=a=>{const s=wj(a);return s.charAt(0).toUpperCase()+s.slice(1)};var Ej={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Cj=a=>{for(const s in a)if(s.startsWith("aria-")||s==="role"||s==="title")return!0;return!1};const Tj=N.forwardRef(({color:a="currentColor",size:s=24,strokeWidth:o=2,absoluteStrokeWidth:i,className:d="",children:f,iconNode:m,...v},g)=>N.createElement("svg",{ref:g,...Ej,width:s,height:s,stroke:a,strokeWidth:i?Number(o)*24/Number(s):o,className:Wv("lucide",d),...!f&&!Cj(v)&&{"aria-hidden":"true"},...v},[...m.map(([h,y])=>N.createElement(h,y)),...Array.isArray(f)?f:[f]]));const ye=(a,s)=>{const o=N.forwardRef(({className:i,...d},f)=>N.createElement(Tj,{ref:f,iconNode:s,className:Wv(`lucide-${Sj(Rx(a))}`,`lucide-${a}`,i),...d}));return o.displayName=Rx(a),o};const _j=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Rj=ye("activity",_j);const kj=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],Mj=ye("box",kj);const Aj=[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]],Oj=ye("boxes",Aj);const zj=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],pd=ye("brain",zj);const Dj=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],xi=ye("check",Dj);const Uj=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Ld=ye("chevron-down",Uj);const Lj=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],eg=ye("chevron-right",Lj);const Bj=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Bd=ye("circle-alert",Bj);const qj=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]],tg=ye("circle-arrow-up",qj);const Hj=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Gj=ye("circle-check-big",Hj);const Qj=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ht=ye("circle-check",Qj);const Vj=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],xl=ye("circle-x",Vj);const Fj=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],os=ye("circle",Fj);const Yj=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Xj=ye("clock",Yj);const Kj=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],qd=ye("copy",Kj);const $j=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],On=ye("cpu",$j);const Zj=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],Jj=ye("database",Zj);const Pj=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],en=ye("download",Pj);const Ij=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Wj=ye("external-link",Ij);const eS=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],ag=ye("file-text",eS);const tS=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]],xd=ye("git-merge",tS);const aS=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],nS=ye("globe",aS);const rS=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],Hd=ye("hard-drive",rS);const sS=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],lS=ye("info",sS);const oS=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],iS=ye("key-round",oS);const cS=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],uS=ye("key",cS);const dS=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],fS=ye("layout-dashboard",dS);const mS=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ct=ye("loader-circle",mS);const hS=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]],pS=ye("lock-open",hS);const xS=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],vi=ye("lock",xS);const vS=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],gS=ye("log-out",vS);const yS=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]],kx=ye("mic",yS);const bS=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],NS=ye("monitor",bS);const jS=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],SS=ye("moon",jS);const wS=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],ES=ye("pencil",wS);const CS=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],ng=ye("play",CS);const TS=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],ti=ye("plus",TS);const _S=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],it=ye("refresh-cw",_S);const RS=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],gi=ye("rotate-ccw",RS);const kS=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Gd=ye("rotate-cw",kS);const MS=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],AS=ye("search",MS);const OS=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],Qd=ye("server",OS);const zS=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],rg=ye("settings",zS);const DS=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],US=ye("shield-check",DS);const LS=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],BS=ye("sparkles",LS);const qS=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],HS=ye("square",qS);const GS=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],QS=ye("sun",GS);const VS=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],yi=ye("trash-2",VS);const FS=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ra=ye("triangle-alert",FS);const YS=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]],XS=ye("user-x",YS);const KS=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],$S=ye("users",KS);const ZS=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Vd=ye("x",ZS);const JS=[["path",{d:"M10.513 4.856 13.12 2.17a.5.5 0 0 1 .86.46l-1.377 4.317",key:"193nxd"}],["path",{d:"M15.656 10H20a1 1 0 0 1 .78 1.63l-1.72 1.773",key:"27a7lr"}],["path",{d:"M16.273 16.273 10.88 21.83a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14H4a1 1 0 0 1-.78-1.63l4.507-4.643",key:"1e0qe9"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],PS=ye("zap-off",JS);const IS=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],oi=ye("zap",IS);function sg(a){var s,o,i="";if(typeof a=="string"||typeof a=="number")i+=a;else if(typeof a=="object")if(Array.isArray(a)){var d=a.length;for(s=0;s<d;s++)a[s]&&(o=sg(a[s]))&&(i&&(i+=" "),i+=o)}else for(o in a)a[o]&&(i&&(i+=" "),i+=o);return i}function WS(){for(var a,s,o=0,i="",d=arguments.length;o<d;o++)(a=arguments[o])&&(s=sg(a))&&(i&&(i+=" "),i+=s);return i}const ew=(a,s)=>{const o=new Array(a.length+s.length);for(let i=0;i<a.length;i++)o[i]=a[i];for(let i=0;i<s.length;i++)o[a.length+i]=s[i];return o},tw=(a,s)=>({classGroupId:a,validator:s}),lg=(a=new Map,s=null,o)=>({nextPart:a,validators:s,classGroupId:o}),ii="-",Mx=[],aw="arbitrary..",nw=a=>{const s=sw(a),{conflictingClassGroups:o,conflictingClassGroupModifiers:i}=a;return{getClassGroupId:m=>{if(m.startsWith("[")&&m.endsWith("]"))return rw(m);const v=m.split(ii),g=v[0]===""&&v.length>1?1:0;return og(v,g,s)},getConflictingClassGroupIds:(m,v)=>{if(v){const g=i[m],h=o[m];return g?h?ew(h,g):g:h||Mx}return o[m]||Mx}}},og=(a,s,o)=>{if(a.length-s===0)return o.classGroupId;const d=a[s],f=o.nextPart.get(d);if(f){const h=og(a,s+1,f);if(h)return h}const m=o.validators;if(m===null)return;const v=s===0?a.join(ii):a.slice(s).join(ii),g=m.length;for(let h=0;h<g;h++){const y=m[h];if(y.validator(v))return y.classGroupId}},rw=a=>a.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const s=a.slice(1,-1),o=s.indexOf(":"),i=s.slice(0,o);return i?aw+i:void 0})(),sw=a=>{const{theme:s,classGroups:o}=a;return lw(o,s)},lw=(a,s)=>{const o=lg();for(const i in a){const d=a[i];Fd(d,o,i,s)}return o},Fd=(a,s,o,i)=>{const d=a.length;for(let f=0;f<d;f++){const m=a[f];ow(m,s,o,i)}},ow=(a,s,o,i)=>{if(typeof a=="string"){iw(a,s,o);return}if(typeof a=="function"){cw(a,s,o,i);return}uw(a,s,o,i)},iw=(a,s,o)=>{const i=a===""?s:ig(s,a);i.classGroupId=o},cw=(a,s,o,i)=>{if(dw(a)){Fd(a(i),s,o,i);return}s.validators===null&&(s.validators=[]),s.validators.push(tw(o,a))},uw=(a,s,o,i)=>{const d=Object.entries(a),f=d.length;for(let m=0;m<f;m++){const[v,g]=d[m];Fd(g,ig(s,v),o,i)}},ig=(a,s)=>{let o=a;const i=s.split(ii),d=i.length;for(let f=0;f<d;f++){const m=i[f];let v=o.nextPart.get(m);v||(v=lg(),o.nextPart.set(m,v)),o=v}return o},dw=a=>"isThemeGetter"in a&&a.isThemeGetter===!0,fw=a=>{if(a<1)return{get:()=>{},set:()=>{}};let s=0,o=Object.create(null),i=Object.create(null);const d=(f,m)=>{o[f]=m,s++,s>a&&(s=0,i=o,o=Object.create(null))};return{get(f){let m=o[f];if(m!==void 0)return m;if((m=i[f])!==void 0)return d(f,m),m},set(f,m){f in o?o[f]=m:d(f,m)}}},vd="!",Ax=":",mw=[],Ox=(a,s,o,i,d)=>({modifiers:a,hasImportantModifier:s,baseClassName:o,maybePostfixModifierPosition:i,isExternal:d}),hw=a=>{const{prefix:s,experimentalParseClassName:o}=a;let i=d=>{const f=[];let m=0,v=0,g=0,h;const y=d.length;for(let E=0;E<y;E++){const _=d[E];if(m===0&&v===0){if(_===Ax){f.push(d.slice(g,E)),g=E+1;continue}if(_==="/"){h=E;continue}}_==="["?m++:_==="]"?m--:_==="("?v++:_===")"&&v--}const x=f.length===0?d:d.slice(g);let S=x,R=!1;x.endsWith(vd)?(S=x.slice(0,-1),R=!0):x.startsWith(vd)&&(S=x.slice(1),R=!0);const w=h&&h>g?h-g:void 0;return Ox(f,R,S,w)};if(s){const d=s+Ax,f=i;i=m=>m.startsWith(d)?f(m.slice(d.length)):Ox(mw,!1,m,void 0,!0)}if(o){const d=i;i=f=>o({className:f,parseClassName:d})}return i},pw=a=>{const s=new Map;return a.orderSensitiveModifiers.forEach((o,i)=>{s.set(o,1e6+i)}),o=>{const i=[];let d=[];for(let f=0;f<o.length;f++){const m=o[f],v=m[0]==="[",g=s.has(m);v||g?(d.length>0&&(d.sort(),i.push(...d),d=[]),i.push(m)):d.push(m)}return d.length>0&&(d.sort(),i.push(...d)),i}},xw=a=>({cache:fw(a.cacheSize),parseClassName:hw(a),sortModifiers:pw(a),...nw(a)}),vw=/\s+/,gw=(a,s)=>{const{parseClassName:o,getClassGroupId:i,getConflictingClassGroupIds:d,sortModifiers:f}=s,m=[],v=a.trim().split(vw);let g="";for(let h=v.length-1;h>=0;h-=1){const y=v[h],{isExternal:x,modifiers:S,hasImportantModifier:R,baseClassName:w,maybePostfixModifierPosition:E}=o(y);if(x){g=y+(g.length>0?" "+g:g);continue}let _=!!E,O=i(_?w.substring(0,E):w);if(!O){if(!_){g=y+(g.length>0?" "+g:g);continue}if(O=i(w),!O){g=y+(g.length>0?" "+g:g);continue}_=!1}const k=S.length===0?"":S.length===1?S[0]:f(S).join(":"),Y=R?k+vd:k,I=Y+O;if(m.indexOf(I)>-1)continue;m.push(I);const ne=d(O,_);for(let ee=0;ee<ne.length;++ee){const H=ne[ee];m.push(Y+H)}g=y+(g.length>0?" "+g:g)}return g},yw=(...a)=>{let s=0,o,i,d="";for(;s<a.length;)(o=a[s++])&&(i=cg(o))&&(d&&(d+=" "),d+=i);return d},cg=a=>{if(typeof a=="string")return a;let s,o="";for(let i=0;i<a.length;i++)a[i]&&(s=cg(a[i]))&&(o&&(o+=" "),o+=s);return o},bw=(a,...s)=>{let o,i,d,f;const m=g=>{const h=s.reduce((y,x)=>x(y),a());return o=xw(h),i=o.cache.get,d=o.cache.set,f=v,v(g)},v=g=>{const h=i(g);if(h)return h;const y=gw(g,o);return d(g,y),y};return f=m,(...g)=>f(yw(...g))},Nw=[],dt=a=>{const s=o=>o[a]||Nw;return s.isThemeGetter=!0,s},ug=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,dg=/^\((?:(\w[\w-]*):)?(.+)\)$/i,jw=/^\d+\/\d+$/,Sw=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,ww=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Ew=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Cw=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Tw=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,as=a=>jw.test(a),Ae=a=>!!a&&!Number.isNaN(Number(a)),Mn=a=>!!a&&Number.isInteger(Number(a)),Yu=a=>a.endsWith("%")&&Ae(a.slice(0,-1)),Wa=a=>Sw.test(a),_w=()=>!0,Rw=a=>ww.test(a)&&!Ew.test(a),fg=()=>!1,kw=a=>Cw.test(a),Mw=a=>Tw.test(a),Aw=a=>!de(a)&&!fe(a),Ow=a=>ms(a,pg,fg),de=a=>ug.test(a),sr=a=>ms(a,xg,Rw),Xu=a=>ms(a,Bw,Ae),zx=a=>ms(a,mg,fg),zw=a=>ms(a,hg,Mw),Xo=a=>ms(a,vg,kw),fe=a=>dg.test(a),hl=a=>hs(a,xg),Dw=a=>hs(a,qw),Dx=a=>hs(a,mg),Uw=a=>hs(a,pg),Lw=a=>hs(a,hg),Ko=a=>hs(a,vg,!0),ms=(a,s,o)=>{const i=ug.exec(a);return i?i[1]?s(i[1]):o(i[2]):!1},hs=(a,s,o=!1)=>{const i=dg.exec(a);return i?i[1]?s(i[1]):o:!1},mg=a=>a==="position"||a==="percentage",hg=a=>a==="image"||a==="url",pg=a=>a==="length"||a==="size"||a==="bg-size",xg=a=>a==="length",Bw=a=>a==="number",qw=a=>a==="family-name",vg=a=>a==="shadow",Hw=()=>{const a=dt("color"),s=dt("font"),o=dt("text"),i=dt("font-weight"),d=dt("tracking"),f=dt("leading"),m=dt("breakpoint"),v=dt("container"),g=dt("spacing"),h=dt("radius"),y=dt("shadow"),x=dt("inset-shadow"),S=dt("text-shadow"),R=dt("drop-shadow"),w=dt("blur"),E=dt("perspective"),_=dt("aspect"),O=dt("ease"),k=dt("animate"),Y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],I=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],ne=()=>[...I(),fe,de],ee=()=>["auto","hidden","clip","visible","scroll"],H=()=>["auto","contain","none"],K=()=>[fe,de,g],ie=()=>[as,"full","auto",...K()],re=()=>[Mn,"none","subgrid",fe,de],oe=()=>["auto",{span:["full",Mn,fe,de]},Mn,fe,de],he=()=>[Mn,"auto",fe,de],Ee=()=>["auto","min","max","fr",fe,de],Te=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],ae=()=>["start","end","center","stretch","center-safe","end-safe"],C=()=>["auto",...K()],F=()=>[as,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...K()],X=()=>[a,fe,de],ve=()=>[...I(),Dx,zx,{position:[fe,de]}],W=()=>["no-repeat",{repeat:["","x","y","space","round"]}],j=()=>["auto","cover","contain",Uw,Ow,{size:[fe,de]}],D=()=>[Yu,hl,sr],G=()=>["","none","full",h,fe,de],Z=()=>["",Ae,hl,sr],se=()=>["solid","dashed","dotted","double"],me=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ue=()=>[Ae,Yu,Dx,zx],je=()=>["","none",w,fe,de],U=()=>["none",Ae,fe,de],z=()=>["none",Ae,fe,de],Se=()=>[Ae,fe,de],xe=()=>[as,"full",...K()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Wa],breakpoint:[Wa],color:[_w],container:[Wa],"drop-shadow":[Wa],ease:["in","out","in-out"],font:[Aw],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Wa],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Wa],shadow:[Wa],spacing:["px",Ae],text:[Wa],"text-shadow":[Wa],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",as,de,fe,_]}],container:["container"],columns:[{columns:[Ae,de,fe,v]}],"break-after":[{"break-after":Y()}],"break-before":[{"break-before":Y()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:ne()}],overflow:[{overflow:ee()}],"overflow-x":[{"overflow-x":ee()}],"overflow-y":[{"overflow-y":ee()}],overscroll:[{overscroll:H()}],"overscroll-x":[{"overscroll-x":H()}],"overscroll-y":[{"overscroll-y":H()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:ie()}],"inset-x":[{"inset-x":ie()}],"inset-y":[{"inset-y":ie()}],start:[{start:ie()}],end:[{end:ie()}],top:[{top:ie()}],right:[{right:ie()}],bottom:[{bottom:ie()}],left:[{left:ie()}],visibility:["visible","invisible","collapse"],z:[{z:[Mn,"auto",fe,de]}],basis:[{basis:[as,"full","auto",v,...K()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ae,as,"auto","initial","none",de]}],grow:[{grow:["",Ae,fe,de]}],shrink:[{shrink:["",Ae,fe,de]}],order:[{order:[Mn,"first","last","none",fe,de]}],"grid-cols":[{"grid-cols":re()}],"col-start-end":[{col:oe()}],"col-start":[{"col-start":he()}],"col-end":[{"col-end":he()}],"grid-rows":[{"grid-rows":re()}],"row-start-end":[{row:oe()}],"row-start":[{"row-start":he()}],"row-end":[{"row-end":he()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Ee()}],"auto-rows":[{"auto-rows":Ee()}],gap:[{gap:K()}],"gap-x":[{"gap-x":K()}],"gap-y":[{"gap-y":K()}],"justify-content":[{justify:[...Te(),"normal"]}],"justify-items":[{"justify-items":[...ae(),"normal"]}],"justify-self":[{"justify-self":["auto",...ae()]}],"align-content":[{content:["normal",...Te()]}],"align-items":[{items:[...ae(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...ae(),{baseline:["","last"]}]}],"place-content":[{"place-content":Te()}],"place-items":[{"place-items":[...ae(),"baseline"]}],"place-self":[{"place-self":["auto",...ae()]}],p:[{p:K()}],px:[{px:K()}],py:[{py:K()}],ps:[{ps:K()}],pe:[{pe:K()}],pt:[{pt:K()}],pr:[{pr:K()}],pb:[{pb:K()}],pl:[{pl:K()}],m:[{m:C()}],mx:[{mx:C()}],my:[{my:C()}],ms:[{ms:C()}],me:[{me:C()}],mt:[{mt:C()}],mr:[{mr:C()}],mb:[{mb:C()}],ml:[{ml:C()}],"space-x":[{"space-x":K()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":K()}],"space-y-reverse":["space-y-reverse"],size:[{size:F()}],w:[{w:[v,"screen",...F()]}],"min-w":[{"min-w":[v,"screen","none",...F()]}],"max-w":[{"max-w":[v,"screen","none","prose",{screen:[m]},...F()]}],h:[{h:["screen","lh",...F()]}],"min-h":[{"min-h":["screen","lh","none",...F()]}],"max-h":[{"max-h":["screen","lh",...F()]}],"font-size":[{text:["base",o,hl,sr]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[i,fe,Xu]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Yu,de]}],"font-family":[{font:[Dw,de,s]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[d,fe,de]}],"line-clamp":[{"line-clamp":[Ae,"none",fe,Xu]}],leading:[{leading:[f,...K()]}],"list-image":[{"list-image":["none",fe,de]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",fe,de]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:X()}],"text-color":[{text:X()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...se(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ae,"from-font","auto",fe,sr]}],"text-decoration-color":[{decoration:X()}],"underline-offset":[{"underline-offset":[Ae,"auto",fe,de]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:K()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",fe,de]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",fe,de]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ve()}],"bg-repeat":[{bg:W()}],"bg-size":[{bg:j()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Mn,fe,de],radial:["",fe,de],conic:[Mn,fe,de]},Lw,zw]}],"bg-color":[{bg:X()}],"gradient-from-pos":[{from:D()}],"gradient-via-pos":[{via:D()}],"gradient-to-pos":[{to:D()}],"gradient-from":[{from:X()}],"gradient-via":[{via:X()}],"gradient-to":[{to:X()}],rounded:[{rounded:G()}],"rounded-s":[{"rounded-s":G()}],"rounded-e":[{"rounded-e":G()}],"rounded-t":[{"rounded-t":G()}],"rounded-r":[{"rounded-r":G()}],"rounded-b":[{"rounded-b":G()}],"rounded-l":[{"rounded-l":G()}],"rounded-ss":[{"rounded-ss":G()}],"rounded-se":[{"rounded-se":G()}],"rounded-ee":[{"rounded-ee":G()}],"rounded-es":[{"rounded-es":G()}],"rounded-tl":[{"rounded-tl":G()}],"rounded-tr":[{"rounded-tr":G()}],"rounded-br":[{"rounded-br":G()}],"rounded-bl":[{"rounded-bl":G()}],"border-w":[{border:Z()}],"border-w-x":[{"border-x":Z()}],"border-w-y":[{"border-y":Z()}],"border-w-s":[{"border-s":Z()}],"border-w-e":[{"border-e":Z()}],"border-w-t":[{"border-t":Z()}],"border-w-r":[{"border-r":Z()}],"border-w-b":[{"border-b":Z()}],"border-w-l":[{"border-l":Z()}],"divide-x":[{"divide-x":Z()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":Z()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...se(),"hidden","none"]}],"divide-style":[{divide:[...se(),"hidden","none"]}],"border-color":[{border:X()}],"border-color-x":[{"border-x":X()}],"border-color-y":[{"border-y":X()}],"border-color-s":[{"border-s":X()}],"border-color-e":[{"border-e":X()}],"border-color-t":[{"border-t":X()}],"border-color-r":[{"border-r":X()}],"border-color-b":[{"border-b":X()}],"border-color-l":[{"border-l":X()}],"divide-color":[{divide:X()}],"outline-style":[{outline:[...se(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ae,fe,de]}],"outline-w":[{outline:["",Ae,hl,sr]}],"outline-color":[{outline:X()}],shadow:[{shadow:["","none",y,Ko,Xo]}],"shadow-color":[{shadow:X()}],"inset-shadow":[{"inset-shadow":["none",x,Ko,Xo]}],"inset-shadow-color":[{"inset-shadow":X()}],"ring-w":[{ring:Z()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:X()}],"ring-offset-w":[{"ring-offset":[Ae,sr]}],"ring-offset-color":[{"ring-offset":X()}],"inset-ring-w":[{"inset-ring":Z()}],"inset-ring-color":[{"inset-ring":X()}],"text-shadow":[{"text-shadow":["none",S,Ko,Xo]}],"text-shadow-color":[{"text-shadow":X()}],opacity:[{opacity:[Ae,fe,de]}],"mix-blend":[{"mix-blend":[...me(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":me()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ae]}],"mask-image-linear-from-pos":[{"mask-linear-from":ue()}],"mask-image-linear-to-pos":[{"mask-linear-to":ue()}],"mask-image-linear-from-color":[{"mask-linear-from":X()}],"mask-image-linear-to-color":[{"mask-linear-to":X()}],"mask-image-t-from-pos":[{"mask-t-from":ue()}],"mask-image-t-to-pos":[{"mask-t-to":ue()}],"mask-image-t-from-color":[{"mask-t-from":X()}],"mask-image-t-to-color":[{"mask-t-to":X()}],"mask-image-r-from-pos":[{"mask-r-from":ue()}],"mask-image-r-to-pos":[{"mask-r-to":ue()}],"mask-image-r-from-color":[{"mask-r-from":X()}],"mask-image-r-to-color":[{"mask-r-to":X()}],"mask-image-b-from-pos":[{"mask-b-from":ue()}],"mask-image-b-to-pos":[{"mask-b-to":ue()}],"mask-image-b-from-color":[{"mask-b-from":X()}],"mask-image-b-to-color":[{"mask-b-to":X()}],"mask-image-l-from-pos":[{"mask-l-from":ue()}],"mask-image-l-to-pos":[{"mask-l-to":ue()}],"mask-image-l-from-color":[{"mask-l-from":X()}],"mask-image-l-to-color":[{"mask-l-to":X()}],"mask-image-x-from-pos":[{"mask-x-from":ue()}],"mask-image-x-to-pos":[{"mask-x-to":ue()}],"mask-image-x-from-color":[{"mask-x-from":X()}],"mask-image-x-to-color":[{"mask-x-to":X()}],"mask-image-y-from-pos":[{"mask-y-from":ue()}],"mask-image-y-to-pos":[{"mask-y-to":ue()}],"mask-image-y-from-color":[{"mask-y-from":X()}],"mask-image-y-to-color":[{"mask-y-to":X()}],"mask-image-radial":[{"mask-radial":[fe,de]}],"mask-image-radial-from-pos":[{"mask-radial-from":ue()}],"mask-image-radial-to-pos":[{"mask-radial-to":ue()}],"mask-image-radial-from-color":[{"mask-radial-from":X()}],"mask-image-radial-to-color":[{"mask-radial-to":X()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":I()}],"mask-image-conic-pos":[{"mask-conic":[Ae]}],"mask-image-conic-from-pos":[{"mask-conic-from":ue()}],"mask-image-conic-to-pos":[{"mask-conic-to":ue()}],"mask-image-conic-from-color":[{"mask-conic-from":X()}],"mask-image-conic-to-color":[{"mask-conic-to":X()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ve()}],"mask-repeat":[{mask:W()}],"mask-size":[{mask:j()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",fe,de]}],filter:[{filter:["","none",fe,de]}],blur:[{blur:je()}],brightness:[{brightness:[Ae,fe,de]}],contrast:[{contrast:[Ae,fe,de]}],"drop-shadow":[{"drop-shadow":["","none",R,Ko,Xo]}],"drop-shadow-color":[{"drop-shadow":X()}],grayscale:[{grayscale:["",Ae,fe,de]}],"hue-rotate":[{"hue-rotate":[Ae,fe,de]}],invert:[{invert:["",Ae,fe,de]}],saturate:[{saturate:[Ae,fe,de]}],sepia:[{sepia:["",Ae,fe,de]}],"backdrop-filter":[{"backdrop-filter":["","none",fe,de]}],"backdrop-blur":[{"backdrop-blur":je()}],"backdrop-brightness":[{"backdrop-brightness":[Ae,fe,de]}],"backdrop-contrast":[{"backdrop-contrast":[Ae,fe,de]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ae,fe,de]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ae,fe,de]}],"backdrop-invert":[{"backdrop-invert":["",Ae,fe,de]}],"backdrop-opacity":[{"backdrop-opacity":[Ae,fe,de]}],"backdrop-saturate":[{"backdrop-saturate":[Ae,fe,de]}],"backdrop-sepia":[{"backdrop-sepia":["",Ae,fe,de]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":K()}],"border-spacing-x":[{"border-spacing-x":K()}],"border-spacing-y":[{"border-spacing-y":K()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",fe,de]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ae,"initial",fe,de]}],ease:[{ease:["linear","initial",O,fe,de]}],delay:[{delay:[Ae,fe,de]}],animate:[{animate:["none",k,fe,de]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[E,fe,de]}],"perspective-origin":[{"perspective-origin":ne()}],rotate:[{rotate:U()}],"rotate-x":[{"rotate-x":U()}],"rotate-y":[{"rotate-y":U()}],"rotate-z":[{"rotate-z":U()}],scale:[{scale:z()}],"scale-x":[{"scale-x":z()}],"scale-y":[{"scale-y":z()}],"scale-z":[{"scale-z":z()}],"scale-3d":["scale-3d"],skew:[{skew:Se()}],"skew-x":[{"skew-x":Se()}],"skew-y":[{"skew-y":Se()}],transform:[{transform:[fe,de,"","none","gpu","cpu"]}],"transform-origin":[{origin:ne()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:xe()}],"translate-x":[{"translate-x":xe()}],"translate-y":[{"translate-y":xe()}],"translate-z":[{"translate-z":xe()}],"translate-none":["translate-none"],accent:[{accent:X()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:X()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",fe,de]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":K()}],"scroll-mx":[{"scroll-mx":K()}],"scroll-my":[{"scroll-my":K()}],"scroll-ms":[{"scroll-ms":K()}],"scroll-me":[{"scroll-me":K()}],"scroll-mt":[{"scroll-mt":K()}],"scroll-mr":[{"scroll-mr":K()}],"scroll-mb":[{"scroll-mb":K()}],"scroll-ml":[{"scroll-ml":K()}],"scroll-p":[{"scroll-p":K()}],"scroll-px":[{"scroll-px":K()}],"scroll-py":[{"scroll-py":K()}],"scroll-ps":[{"scroll-ps":K()}],"scroll-pe":[{"scroll-pe":K()}],"scroll-pt":[{"scroll-pt":K()}],"scroll-pr":[{"scroll-pr":K()}],"scroll-pb":[{"scroll-pb":K()}],"scroll-pl":[{"scroll-pl":K()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",fe,de]}],fill:[{fill:["none",...X()]}],"stroke-w":[{stroke:[Ae,hl,sr,Xu]}],stroke:[{stroke:["none",...X()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Gw=bw(Hw);function te(...a){return Gw(WS(a))}async function Qw(){const{data:a}=await be.get("/api/system/info");return a}function Vw(){return yt({queryKey:["system-info"],queryFn:Qw,staleTime:6e4})}function Fw(a){const s=Math.floor(a/86400),o=Math.floor(a%86400/3600);if(s>0)return`${s}d ${o}h`;const i=Math.floor(a%3600/60);return o>0?`${o}h ${i}m`:`${i}m`}function Yw(){const{data:a}=Vw();return a?l.jsxs("div",{className:"border-t border-[var(--color-border)] px-3 py-2 text-[10px] text-[var(--color-text-muted)]",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(On,{size:10}),l.jsxs("span",{children:[a.cpuCount," cores"]}),l.jsx("span",{className:"mx-0.5",children:"|"}),l.jsx(Hd,{size:10}),l.jsxs("span",{children:[Math.round(a.totalMemoryMb/1024),"GB"]})]}),l.jsxs("div",{className:"mt-0.5",children:[a.hostname," · up ",Fw(a.uptime)," · v",a.version]})]}):null}const Xw=[{label:"Dashboard",icon:fS,path:"/dashboard"},{label:"Settings",icon:rg,path:"/settings"},{label:"Services",icon:Qd,path:"/services"},{label:"Models",icon:Mj,path:"/models"},{label:"Quick Sets",icon:oi,path:"/quick-sets"},{label:"Traces",icon:Rj,path:"/traces"},{label:"Nodes",icon:On,path:"/nodes"},{label:"Users",icon:$S,path:"/users"},{label:"Native",icon:Oj,path:"/native-services"}];function Kw(){return l.jsxs("aside",{className:"flex w-56 flex-col border-r border-[var(--color-border)] bg-[var(--color-surface)]",children:[l.jsx("div",{className:"flex h-14 items-center border-b border-[var(--color-border)] px-4",children:l.jsx("span",{className:"text-lg font-bold text-[var(--color-primary)]",children:"Jarvis"})}),l.jsx("nav",{className:"flex-1 space-y-1 p-2",children:Xw.map(a=>l.jsxs(mv,{to:a.path,className:({isActive:s})=>te("flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition-colors",s?"bg-[var(--color-primary)]/10 text-[var(--color-primary)]":"text-[var(--color-text-muted)] hover:bg-[var(--color-surface-alt)] hover:text-[var(--color-text)]"),children:[l.jsx(a.icon,{size:18}),a.label]},a.path))}),l.jsx(Yw,{})]})}function $w(){const{state:a,logout:s}=Ud(),{theme:o,toggleTheme:i}=H2();return l.jsxs("header",{className:"flex h-14 items-center justify-between border-b border-[var(--color-border)] bg-[var(--color-surface)] px-6",children:[l.jsx("h2",{className:"text-sm font-medium text-[var(--color-text-muted)]",children:"Admin Dashboard"}),l.jsxs("div",{className:"flex items-center gap-3",children:[a.user&&l.jsx("span",{className:"text-sm text-[var(--color-text-muted)]",children:a.user.email}),l.jsx("button",{onClick:i,className:"rounded-lg p-2 text-[var(--color-text-muted)] hover:bg-[var(--color-surface-alt)]",title:`Switch to ${o==="dark"?"light":"dark"} mode`,children:o==="dark"?l.jsx(QS,{size:18}):l.jsx(SS,{size:18})}),l.jsx("button",{onClick:s,className:"rounded-lg p-2 text-[var(--color-text-muted)] hover:bg-[var(--color-surface-alt)] hover:text-red-500",title:"Logout",children:l.jsx(gS,{size:18})})]})]})}function Zw(){const{state:a}=Ud();return a.isLoading?l.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[var(--color-background)]",children:l.jsx("p",{className:"text-[var(--color-text-muted)]",children:"Loading..."})}):a.isAuthenticated?l.jsxs("div",{className:"flex h-screen bg-[var(--color-background)]",children:[l.jsx(Kw,{}),l.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[l.jsx($w,{}),l.jsx("main",{className:"flex-1 overflow-y-auto p-6",children:l.jsx(X0,{})})]})]}):l.jsx(ni,{to:"/login",replace:!0})}function Jw(){const{state:a,login:s,setup:o}=Ud(),i=wa(),[d,f]=N.useState("loading"),[m,v]=N.useState(""),[g,h]=N.useState(""),[y,x]=N.useState(""),[S,R]=N.useState(""),[w,E]=N.useState(null);if(N.useEffect(()=>{let I=!1;async function ne(){try{const{data:ee}=await be.get("/api/setup/status");if(!I&&!ee.configured){i("/setup",{replace:!0});return}}catch{if(!I){i("/setup",{replace:!0});return}}try{const ee=await gj();I||f(ee.needs_setup?"setup":"login")}catch{I||f("login")}}return ne(),()=>{I=!0}},[i]),a.isAuthenticated)return l.jsx(ni,{to:"/settings",replace:!0});const _=I=>{I.preventDefault(),s(m,y)},O=I=>{if(I.preventDefault(),E(null),y!==S){E("Passwords do not match");return}if(y.length<8){E("Password must be at least 8 characters");return}o(m,y,g||void 0)},k=te("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]"),Y=w??a.error;return d==="loading"?l.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[var(--color-background)]",children:l.jsx("div",{className:"w-full max-w-sm rounded-xl border border-[var(--color-border)] bg-[var(--color-surface)] p-8 shadow-lg",children:l.jsx("div",{className:"flex justify-center",children:l.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-[var(--color-border)] border-t-[var(--color-primary)]"})})})}):l.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[var(--color-background)]",children:l.jsx("div",{className:"w-full max-w-sm rounded-xl border border-[var(--color-border)] bg-[var(--color-surface)] p-8 shadow-lg",children:d==="setup"?l.jsxs(l.Fragment,{children:[l.jsx("h1",{className:"mb-1 text-center text-2xl font-bold text-[var(--color-text)]",children:"Welcome to Jarvis"}),l.jsx("p",{className:"mb-6 text-center text-sm text-[var(--color-text-muted)]",children:"Set up your first administrator account to get started."}),l.jsxs("form",{onSubmit:O,className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{htmlFor:"email",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Email"}),l.jsx("input",{id:"email",type:"email",required:!0,autoComplete:"email",value:m,onChange:I=>v(I.target.value),className:k,placeholder:"admin@example.com"})]}),l.jsxs("div",{children:[l.jsx("label",{htmlFor:"username",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Username"}),l.jsx("input",{id:"username",type:"text",required:!0,autoComplete:"username",value:g,onChange:I=>h(I.target.value),className:k,placeholder:"admin"})]}),l.jsxs("div",{children:[l.jsx("label",{htmlFor:"password",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Password"}),l.jsx("input",{id:"password",type:"password",required:!0,minLength:8,autoComplete:"new-password",value:y,onChange:I=>x(I.target.value),className:k})]}),l.jsxs("div",{children:[l.jsx("label",{htmlFor:"confirm-password",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Confirm Password"}),l.jsx("input",{id:"confirm-password",type:"password",required:!0,minLength:8,autoComplete:"new-password",value:S,onChange:I=>R(I.target.value),className:k})]}),Y&&l.jsx("p",{className:"rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-500",children:Y}),l.jsx("button",{type:"submit",disabled:a.isLoading,className:te("w-full rounded-lg bg-[var(--color-primary)] px-4 py-2 font-medium text-white","hover:opacity-90 disabled:opacity-50","transition-opacity"),children:a.isLoading?"Creating account...":"Create Admin Account"})]})]}):l.jsxs(l.Fragment,{children:[l.jsx("h1",{className:"mb-6 text-center text-2xl font-bold text-[var(--color-text)]",children:"Jarvis Admin"}),l.jsxs("form",{onSubmit:_,className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{htmlFor:"email",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Email"}),l.jsx("input",{id:"email",type:"email",required:!0,autoComplete:"email",value:m,onChange:I=>v(I.target.value),className:k,placeholder:"admin@example.com"})]}),l.jsxs("div",{children:[l.jsx("label",{htmlFor:"password",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Password"}),l.jsx("input",{id:"password",type:"password",required:!0,autoComplete:"current-password",value:y,onChange:I=>x(I.target.value),className:k})]}),Y&&l.jsx("p",{className:"rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-500",children:Y}),l.jsx("button",{type:"submit",disabled:a.isLoading,className:te("w-full rounded-lg bg-[var(--color-primary)] px-4 py-2 font-medium text-white","hover:opacity-90 disabled:opacity-50","transition-opacity"),children:a.isLoading?"Signing in...":"Sign in"})]})]})})})}async function Pw(){const{data:a}=await be.get("/api/settings/");return a}async function Iw(a,s,o){const{data:i}=await be.put(`/api/settings/${encodeURIComponent(a)}/${s}`,{value:o});return i}function Ww(){return yt({queryKey:["settings"],queryFn:Pw,staleTime:3e4})}function gg(){const a=pt();return bt({mutationFn:({serviceName:s,key:o,value:i})=>Iw(s,o,i),onSuccess:()=>{a.invalidateQueries({queryKey:["settings"]})}})}function eE({setting:a,onSave:s,onCancel:o,isSaving:i}){const[d,f]=N.useState(()=>a.value_type==="json"?JSON.stringify(a.value,null,2):a.value_type==="bool"?"":String(a.value??"")),[m,v]=N.useState(()=>!!a.value),[g,h]=N.useState(null),y=!!a.options?.length,x=y&&!a.options.includes(d),[S,R]=N.useState(x),w=_=>{_.preventDefault();let O;switch(a.value_type){case"bool":O=m;break;case"int":if(O=parseInt(d,10),isNaN(O)){h("Must be a whole number");return}h(null);break;case"float":if(O=parseFloat(d),isNaN(O)){h("Must be a number");return}h(null);break;case"json":try{O=JSON.parse(d),h(null)}catch{h("Invalid JSON");return}break;default:O=d}s(O)},E=te("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-1.5","text-sm text-[var(--color-text)] outline-none focus:ring-2 focus:ring-[var(--color-primary)]");return l.jsxs("form",{onSubmit:w,className:"flex items-center gap-2",children:[y?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("select",{value:S?"__other__":d,onChange:_=>{_.target.value==="__other__"?(R(!0),f("")):(R(!1),f(_.target.value))},className:te(E,"max-w-xs"),children:[a.options.map(_=>l.jsx("option",{value:String(_),children:String(_)},String(_))),l.jsx("option",{value:"__other__",children:"Other..."})]}),S&&l.jsx("input",{type:"text",value:d,onChange:_=>f(_.target.value),placeholder:"Custom value",className:te(E,"max-w-xs"),autoFocus:!0})]}):a.value_type==="bool"?l.jsx("button",{type:"button",onClick:()=>v(_=>!_),className:te("relative h-6 w-11 rounded-full transition-colors",m?"bg-[var(--color-primary)]":"bg-[var(--color-border)]"),children:l.jsx("span",{className:te("absolute left-0.5 top-0.5 h-5 w-5 rounded-full bg-white transition-transform",m&&"translate-x-5")})}):a.value_type==="json"?l.jsxs("div",{className:"flex-1",children:[l.jsx("textarea",{value:d,onChange:_=>{f(_.target.value),h(null)},rows:4,className:te(E,"font-mono text-xs")}),g&&l.jsx("p",{className:"mt-1 text-xs text-red-500",children:g})]}):l.jsxs("div",{children:[l.jsx("input",{type:a.value_type==="int"||a.value_type==="float"?"number":a.is_secret?"password":"text",step:a.value_type==="float"?"any":void 0,value:d,onChange:_=>{f(_.target.value),h(null)},className:te(E,"max-w-xs")}),g&&l.jsx("p",{className:"mt-1 text-xs text-red-500",children:g})]}),l.jsx("button",{type:"submit",disabled:i,className:"rounded-lg bg-[var(--color-primary)] px-3 py-1.5 text-xs font-medium text-white hover:opacity-90 disabled:opacity-50",children:i?"Saving...":"Save"}),l.jsx("button",{type:"button",onClick:o,className:"rounded-lg border border-[var(--color-border)] px-3 py-1.5 text-xs text-[var(--color-text-muted)] hover:bg-[var(--color-surface-alt)]",children:"Cancel"})]})}function tE(a){return a.is_secret?"********":a.value===null||a.value===void 0?"(not set)":a.value_type==="json"?JSON.stringify(a.value):String(a.value)}const aE={string:"bg-blue-500/10 text-blue-500",int:"bg-emerald-500/10 text-emerald-500",float:"bg-emerald-500/10 text-emerald-500",bool:"bg-amber-500/10 text-amber-500",json:"bg-purple-500/10 text-purple-500"};function nE({setting:a,serviceName:s,onRestartService:o}){const[i,d]=N.useState(!1),f=gg(),m=v=>{f.mutate({serviceName:s,key:a.key,value:v},{onSuccess:g=>{d(!1),g.requires_reload?Me.warning(`Setting updated. ${s} requires a restart to apply.`,o?{action:{label:"Restart",onClick:o}}:void 0):Me.success("Setting updated")},onError:g=>{Me.error(`Failed to update: ${g.message}`)}})};return l.jsxs("div",{className:"flex items-start justify-between gap-4 rounded-lg px-3 py-2 hover:bg-[var(--color-surface-alt)]",children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("code",{className:"text-sm font-medium text-[var(--color-text)]",children:a.key}),l.jsx("span",{className:te("rounded px-1.5 py-0.5 text-[10px] font-medium",aE[a.value_type]??"bg-gray-500/10 text-gray-500"),children:a.value_type}),a.from_db&&l.jsx("span",{title:"Stored in database",children:l.jsx(Jj,{size:12,className:"text-[var(--color-tertiary)]"})}),a.requires_reload&&l.jsx("span",{title:"Requires service restart",children:l.jsx(ra,{size:12,className:"text-amber-500"})})]}),a.description&&l.jsx("p",{className:"mt-0.5 text-xs text-[var(--color-text-muted)]",children:a.description}),i?l.jsx("div",{className:"mt-2",children:l.jsx(eE,{setting:a,onSave:m,onCancel:()=>d(!1),isSaving:f.isPending})}):l.jsx("p",{className:"mt-1 font-mono text-xs text-[var(--color-text-muted)]",children:tE(a)})]}),!i&&l.jsx("button",{onClick:()=>d(!0),className:"shrink-0 rounded-lg p-1.5 text-[var(--color-text-muted)] hover:bg-[var(--color-surface-alt)] hover:text-[var(--color-primary)]",title:"Edit",children:l.jsx(ES,{size:14})})]})}function rE({category:a,settings:s,serviceName:o,onRestartService:i}){const[d,f]=N.useState(!0);return l.jsxs("div",{children:[l.jsxs("button",{onClick:()=>f(m=>!m),className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs font-semibold uppercase tracking-wider text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:[d?l.jsx(Ld,{size:14}):l.jsx(eg,{size:14}),a,l.jsxs("span",{className:"font-normal",children:["(",s.length,")"]})]}),d&&l.jsx("div",{className:"space-y-0.5",children:s.map(m=>l.jsx(nE,{setting:m,serviceName:o,onRestartService:i},m.key))})]})}async function sE(){const{data:a}=await be.get("/api/containers");return a}async function lE(a){const{data:s}=await be.post(`/api/containers/${a}/restart`);return s}function yg(){return yt({queryKey:["containers"],queryFn:sE,staleTime:1e4,refetchInterval:1e4})}function bg(){const a=pt();return bt({mutationFn:s=>lE(s),onSuccess:()=>{a.invalidateQueries({queryKey:["containers"]})}})}function oE({result:a,defaultExpanded:s=!1}){const[o,i]=N.useState(s),{data:d}=yg(),f=bg(),m=N.useCallback(()=>{const g=d?.containers.find(h=>h.name.includes(a.service_name)||h.name.includes(a.service_name.replace("jarvis-","")));g?f.mutate(g.id,{onSuccess:()=>Me.success(`${a.service_name} is restarting...`),onError:h=>Me.error(`Restart failed: ${h.message}`)}):Me.error(`Could not find container for ${a.service_name}`)},[d,a.service_name,f]),v=N.useMemo(()=>{const g=new Map;for(const h of a.settings){const y=g.get(h.category)??[];g.set(h.category,[...y,h])}return g},[a]);return l.jsxs("div",{className:"overflow-hidden rounded-xl border border-[var(--color-border)] bg-[var(--color-surface)]",children:[l.jsxs("button",{onClick:()=>i(g=>!g),className:"flex w-full items-center gap-3 px-4 py-3 text-left hover:bg-[var(--color-surface-alt)]",children:[o?l.jsx(Ld,{size:18,className:"text-[var(--color-text-muted)]"}):l.jsx(eg,{size:18,className:"text-[var(--color-text-muted)]"}),l.jsx("span",{className:"font-medium text-[var(--color-text)]",children:a.service_name}),a.success?l.jsx(ht,{size:16,className:"text-[var(--color-secondary)]"}):l.jsx(xl,{size:16,className:"text-red-500"}),l.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:a.success?`${a.settings.length} settings`:a.error??"Error"}),a.latency_ms!=null&&l.jsxs("span",{className:te("ml-auto text-xs",a.latency_ms>500?"text-amber-500":"text-[var(--color-text-muted)]"),children:[Math.round(a.latency_ms),"ms"]})]}),o&&a.success&&l.jsx("div",{className:"space-y-2 border-t border-[var(--color-border)] px-2 py-3",children:[...v.entries()].map(([g,h])=>l.jsx(rE,{category:g,settings:h,serviceName:a.service_name,onRestartService:m},g))}),o&&!a.success&&l.jsx("div",{className:"border-t border-[var(--color-border)] px-4 py-3",children:l.jsx("p",{className:"text-sm text-red-500",children:a.error??"Failed to fetch settings"})})]})}function iE(){const{data:a,isLoading:s,isError:o,error:i,refetch:d,isFetching:f}=Ww(),[m,v]=N.useState(""),g=N.useMemo(()=>{if(!a)return[];if(!m.trim())return a.services;const h=m.toLowerCase();return a.services.map(y=>({...y,settings:y.settings.filter(x=>x.key.toLowerCase().includes(h)||x.category.toLowerCase().includes(h)||(x.description?.toLowerCase().includes(h)??!1))})).filter(y=>y.settings.length>0||y.service_name.toLowerCase().includes(h))},[a,m]);return s?l.jsx("div",{className:"flex items-center justify-center py-20",children:l.jsx(it,{className:"animate-spin text-[var(--color-primary)]",size:24})}):o?l.jsxs("div",{className:"py-20 text-center",children:[l.jsx("p",{className:"mb-2 text-red-500",children:"Failed to load settings"}),l.jsx("p",{className:"mb-4 text-sm text-[var(--color-text-muted)]",children:i?.message??"Unknown error"}),l.jsx("button",{onClick:()=>d(),className:"rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm text-white hover:opacity-90",children:"Retry"})]}):l.jsxs("div",{className:"mx-auto max-w-4xl space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h1",{className:"text-xl font-bold text-[var(--color-text)]",children:"Settings"}),l.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--color-text-muted)]",children:[a&&l.jsxs("span",{children:[a.successful_services,"/",a.total_services," services"]}),l.jsx("button",{onClick:()=>d(),disabled:f,className:te("rounded-lg p-1.5 hover:bg-[var(--color-surface-alt)]",f&&"animate-spin"),title:"Refresh",children:l.jsx(it,{size:14})})]})]}),l.jsxs("div",{className:"relative",children:[l.jsx(AS,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--color-text-muted)]"}),l.jsx("input",{type:"text",value:m,onChange:h=>v(h.target.value),placeholder:"Search settings...",className:te("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] py-2 pl-9 pr-3","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]")})]}),l.jsxs("div",{className:"space-y-3",children:[g.map((h,y)=>l.jsx(oE,{result:h,defaultExpanded:y===0},h.service_name)),g.length===0&&l.jsx("p",{className:"py-8 text-center text-sm text-[var(--color-text-muted)]",children:m?"No settings match your search":"No services found"})]})]})}async function cE(){const{data:a}=await be.get("/api/services/registry");return a}async function uE(a){const{data:s}=await be.post("/api/services/register",a);return s}async function dE(a){const{data:s}=await be.post("/api/services/rotate-key",a);return s}async function fE(a){const{data:s}=await be.post("/api/services/probe",a);return s}async function mE(a){const{data:s}=await be.post("/api/services/register",{services:[{name:a.name,host:a.host,port:a.port,scheme:a.scheme,health_path:a.health_path,description:a.description}]});return s}async function hE(a){await be.delete(`/api/services/${encodeURIComponent(a)}`)}async function pE(){const{data:a}=await be.get("/api/services/suggestions");return a}function xE(){return yt({queryKey:["service-registry"],queryFn:cE,staleTime:3e4})}function vE(){const a=pt();return bt({mutationFn:uE,onSuccess:()=>{a.invalidateQueries({queryKey:["service-registry"]})}})}function gE(){const a=pt();return bt({mutationFn:dE,onSuccess:()=>{a.invalidateQueries({queryKey:["service-registry"]})}})}function yE(){const a=pt();return bt({mutationFn:mE,onSuccess:()=>{a.invalidateQueries({queryKey:["service-registry"]})}})}function bE(){const a=pt();return bt({mutationFn:hE,onSuccess:()=>{a.invalidateQueries({queryKey:["service-registry"]})}})}function NE(){return yt({queryKey:["service-suggestions"],queryFn:pE,staleTime:6e4})}function Ux({ok:a,label:s}){return l.jsxs("span",{className:te("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium",a?"bg-green-500/10 text-green-600 dark:text-green-400":"bg-[var(--color-surface-alt)] text-[var(--color-text-muted)]"),children:[a?l.jsx(xi,{size:12}):l.jsx(Vd,{size:12}),s]})}function jE({status:a,error:s,latency:o}){return a==="idle"?null:a==="probing"?l.jsx("span",{className:"flex items-center gap-1 text-xs text-[var(--color-text-muted)]",children:l.jsx(Ct,{size:12,className:"animate-spin"})}):a==="healthy"?l.jsxs("span",{className:"flex items-center gap-1 text-xs text-green-600 dark:text-green-400",children:[l.jsx(os,{size:8,fill:"currentColor"}),o!=null&&`${o}ms`]}):l.jsxs("span",{className:"flex items-center gap-1 text-xs text-red-500",title:s,children:[l.jsx(os,{size:8,fill:"currentColor"}),s||"Unreachable"]})}function SE({entry:a,checked:s,host:o,port:i,scheme:d,onToggle:f,onHostChange:m,onPortChange:v,onSchemeChange:g,onHostBlur:h,onPortBlur:y,onRotateKey:x,onDelete:S,disabled:R,rotating:w,deleting:E,healthStatus:_,healthError:O,healthLatency:k}){return l.jsxs("div",{className:te("flex flex-wrap items-center gap-3 rounded-lg border border-[var(--color-border)] p-3","bg-[var(--color-surface)] transition-colors",s&&"border-[var(--color-primary)]/30 bg-[var(--color-primary)]/5"),children:[l.jsx("input",{type:"checkbox",checked:s,onChange:f,disabled:R,className:"h-4 w-4 rounded border-[var(--color-border)] accent-[var(--color-primary)]"}),l.jsxs("div",{className:"min-w-[180px] flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-[var(--color-text)]",children:[a.name,a.custom&&l.jsx("span",{className:"rounded-full bg-blue-500/10 px-1.5 py-0.5 text-[10px] font-medium text-blue-600 dark:text-blue-400",children:"custom"})]}),l.jsx("div",{className:"text-xs text-[var(--color-text-muted)]",children:a.description})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Ux,{ok:a.config_registered,label:"Config"}),l.jsx(Ux,{ok:a.auth_registered,label:"Auth"}),a.custom&&S&&l.jsxs("button",{onClick:S,disabled:R||E,className:te("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium","bg-red-500/10 text-red-600 dark:text-red-400","hover:bg-red-500/20","disabled:opacity-50"),title:"Remove custom service",children:[l.jsx(yi,{size:12,className:E?"animate-spin":""}),"Remove"]}),a.auth_registered&&l.jsxs("button",{onClick:x,disabled:R||w,className:te("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium","bg-[var(--color-surface-alt)] text-[var(--color-text-muted)]","hover:bg-[var(--color-primary)]/10 hover:text-[var(--color-primary)]","disabled:opacity-50"),title:"Rotate app key",children:[l.jsx(Gd,{size:12,className:w?"animate-spin":""}),"Rotate Key"]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("select",{value:d,onChange:Y=>g(Y.target.value),disabled:R,className:te("rounded border px-1.5 py-1 text-xs font-mono",d==="https"?"border-green-500/40 bg-green-500/10 text-green-600 dark:text-green-400":d==="mqtt"||d==="mqtts"?"border-purple-500/40 bg-purple-500/10 text-purple-600 dark:text-purple-400":d==="ws"||d==="wss"?"border-blue-500/40 bg-blue-500/10 text-blue-600 dark:text-blue-400":"border-[var(--color-border)] bg-[var(--color-background)] text-[var(--color-text-muted)]","disabled:opacity-50"),title:"Scheme",children:[l.jsx("option",{value:"http",children:"http"}),l.jsx("option",{value:"https",children:"https"}),l.jsx("option",{value:"mqtt",children:"mqtt"}),l.jsx("option",{value:"mqtts",children:"mqtts"}),l.jsx("option",{value:"ws",children:"ws"}),l.jsx("option",{value:"wss",children:"wss"})]}),l.jsx("input",{type:"text",value:o,onChange:Y=>m(Y.target.value),onBlur:h,disabled:R,placeholder:"host",className:te("w-36 rounded border border-[var(--color-border)] bg-[var(--color-background)] px-2 py-1","text-xs text-[var(--color-text)] outline-none focus:ring-1 focus:ring-[var(--color-primary)]","disabled:opacity-50")}),l.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:":"}),l.jsx("input",{type:"number",value:i,onChange:Y=>v(Number(Y.target.value)),onBlur:y,disabled:R,className:te("w-20 rounded border border-[var(--color-border)] bg-[var(--color-background)] px-2 py-1","text-xs text-[var(--color-text)] outline-none focus:ring-1 focus:ring-[var(--color-primary)]","disabled:opacity-50")}),l.jsx(jE,{status:_,error:O,latency:k})]})]})}const Lx={name:"",host:"localhost",port:"",scheme:"http",health_path:"/health",description:""};function wE(){const{data:a,isLoading:s,isError:o,error:i,refetch:d,isFetching:f}=xE(),m=vE(),v=gE(),g=yE(),h=bE(),{data:y}=NE(),[x,S]=N.useState({}),[R,w]=N.useState(null),[E,_]=N.useState(null),[O,k]=N.useState(null),[Y,I]=N.useState(null),[ne,ee]=N.useState(null),[H,K]=N.useState({}),[ie,re]=N.useState(!1),[oe,he]=N.useState(Lx),[Ee,Te]=N.useState(!1),ae=N.useRef(null),C=N.useMemo(()=>new Set(a?.services.map(U=>U.name)??[]),[a]),F=N.useMemo(()=>{const z=(y?.suggestions??[]).filter(xe=>!C.has(xe.id));if(!oe.name.trim())return z;const Se=oe.name.toLowerCase();return z.filter(xe=>xe.id.toLowerCase().includes(Se)||xe.name.toLowerCase().includes(Se)||xe.description.toLowerCase().includes(Se))},[y,C,oe.name]),X=N.useCallback(U=>{he({name:U.id,description:U.description,host:"localhost",port:String(U.port),scheme:"http",health_path:U.healthCheck}),Te(!1)},[]);N.useEffect(()=>{const U=z=>{ae.current&&!ae.current.contains(z.target)&&Te(!1)};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[]);const ve=N.useCallback(U=>{if(x[U])return x[U];const z=a?.services.find(Se=>Se.name===U);return z?{checked:z.config_registered,host:z.current_host??"localhost",port:z.current_port??z.default_port,scheme:z.current_scheme??"http"}:{checked:!1,host:"localhost",port:0,scheme:"http"}},[x,a]),W=N.useCallback((U,z)=>{S(Se=>{const xe=Se[U]??{checked:!1,host:"localhost",port:0};return{...Se,[U]:{...xe,...z}}})},[]),j=N.useCallback(async(U,z,Se,xe,Ut="http")=>{if(!(!z||!Se)){K(ct=>({...ct,[U]:{status:"probing"}}));try{const ct=await fE({host:z,port:Se,health_path:xe,scheme:Ut});K(Dn=>({...Dn,[U]:{status:ct.healthy?"healthy":"unhealthy",error:ct.error??void 0,latency:ct.latency_ms??void 0}}))}catch{K(ct=>({...ct,[U]:{status:"unhealthy",error:"Request failed"}}))}}},[]),D=N.useCallback(()=>{if(!a)return;const U=a.services.filter(z=>ve(z.name).checked).map(z=>{const Se=ve(z.name);return{name:z.name,host:Se.host,port:Se.port,scheme:Se.scheme}});if(U.length===0){Me.error("No services selected");return}w(null),_(null),m.mutate({services:U},{onSuccess:z=>{w(z.results);const Se=z.results.filter(Ut=>Ut.config_ok&&Ut.auth_ok).length,xe=z.results.length;Se===xe?Me.success(`All ${xe} services registered`):Me.warning(`${Se}/${xe} services registered successfully`)},onError:z=>{Me.error(`Registration failed: ${z.message}`)}})},[a,ve,m]),G=N.useCallback(U=>{k(U),_(null),v.mutate({service_name:U},{onSuccess:z=>{_(z),k(null),Me.success(`Key rotated for ${U}`)},onError:z=>{k(null),Me.error(`Key rotation failed: ${z.message}`)}})},[v]),Z=N.useCallback(U=>{I(U),h.mutate(U,{onSuccess:()=>{I(null),Me.success(`Removed ${U}`)},onError:z=>{I(null),Me.error(`Failed to remove: ${z.message}`)}})},[h]),se=N.useCallback(()=>{const U=parseInt(oe.port,10);if(!oe.name.trim()){Me.error("Service name is required");return}if(!U||U<1||U>65535){Me.error("Port must be between 1 and 65535");return}g.mutate({name:oe.name.trim(),host:oe.host.trim()||"localhost",port:U,scheme:oe.scheme,health_path:oe.health_path.trim()||"/health",description:oe.description.trim()},{onSuccess:z=>{const Se=z.results[0];Se?.config_ok?(Me.success(`Added ${oe.name.trim()}`),he(Lx),re(!1)):Me.error(`Failed to add: ${Se?.error??"Unknown error"}`)},onError:z=>{Me.error(`Failed to add service: ${z.message}`)}})},[oe,g]),me=N.useCallback(U=>{navigator.clipboard.writeText(U).then(()=>{ee(U),setTimeout(()=>ee(null),2e3)})},[]),ue=a?.services.filter(U=>ve(U.name).checked).length??0,je=R?.some(U=>U.env_written)||E?.env_written===!0;return s?l.jsx("div",{className:"flex items-center justify-center py-20",children:l.jsx(it,{className:"animate-spin text-[var(--color-primary)]",size:24})}):o?l.jsxs("div",{className:"py-20 text-center",children:[l.jsx("p",{className:"mb-2 text-red-500",children:"Failed to load service registry"}),l.jsx("p",{className:"mb-4 text-sm text-[var(--color-text-muted)]",children:i?.message??"Unknown error"}),l.jsx("button",{onClick:()=>d(),className:"rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm text-white hover:opacity-90",children:"Retry"})]}):l.jsxs("div",{className:"mx-auto max-w-4xl space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("h1",{className:"text-xl font-bold text-[var(--color-text)]",children:"Services"}),l.jsx("span",{className:"rounded-full bg-[var(--color-surface-alt)] px-2.5 py-0.5 text-xs font-medium text-[var(--color-text-muted)]",children:a?.services.length??0})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("button",{onClick:()=>re(U=>!U),className:te("flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium",ie?"bg-[var(--color-surface-alt)] text-[var(--color-text)]":"bg-[var(--color-primary)] text-white hover:opacity-90"),children:[ie?l.jsx(Vd,{size:14}):l.jsx(ti,{size:14}),ie?"Cancel":"Add Service"]}),l.jsx("button",{onClick:()=>d(),disabled:f,className:te("rounded-lg p-1.5 text-[var(--color-text-muted)] hover:bg-[var(--color-surface-alt)]",f&&"animate-spin"),title:"Refresh",children:l.jsx(it,{size:14})})]})]}),ie&&l.jsxs("div",{className:"rounded-lg border border-[var(--color-primary)]/30 bg-[var(--color-primary)]/5 p-4",children:[l.jsx("h2",{className:"mb-3 text-sm font-semibold text-[var(--color-text)]",children:"Add Service"}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{ref:ae,className:"relative",children:[l.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Service"}),l.jsxs("div",{className:"relative",children:[l.jsx("input",{type:"text",value:oe.name,onChange:U=>{he(z=>({...z,name:U.target.value})),Te(!0)},onFocus:()=>Te(!0),placeholder:"Select or type a service name...",className:te("w-full rounded border border-[var(--color-border)] bg-[var(--color-background)] px-2.5 py-1.5 pr-8","text-sm text-[var(--color-text)] outline-none focus:ring-1 focus:ring-[var(--color-primary)]")}),l.jsx("button",{type:"button",onClick:()=>Te(U=>!U),className:"absolute right-1.5 top-1/2 -translate-y-1/2 rounded p-0.5 text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:l.jsx(Ld,{size:14})})]}),Ee&&F.length>0&&l.jsx("div",{className:"absolute z-10 mt-1 max-h-48 w-full overflow-y-auto rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] shadow-lg",children:F.map(U=>l.jsxs("button",{type:"button",onClick:()=>X(U),className:"flex w-full flex-col px-3 py-2 text-left hover:bg-[var(--color-surface-alt)]",children:[l.jsxs("span",{className:"text-sm font-medium text-[var(--color-text)]",children:[U.name,l.jsxs("span",{className:"ml-2 font-normal text-[var(--color-text-muted)]",children:[":",U.port]})]}),l.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:U.description})]},U.id))})]}),l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Description"}),l.jsx("input",{type:"text",value:oe.description,onChange:U=>he(z=>({...z,description:U.target.value})),placeholder:"e.g. Camera streaming via WebRTC",className:te("w-full rounded border border-[var(--color-border)] bg-[var(--color-background)] px-2.5 py-1.5","text-sm text-[var(--color-text)] outline-none focus:ring-1 focus:ring-[var(--color-primary)]")})]}),l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Host"}),l.jsx("input",{type:"text",value:oe.host,onChange:U=>he(z=>({...z,host:U.target.value})),placeholder:"localhost",className:te("w-full rounded border border-[var(--color-border)] bg-[var(--color-background)] px-2.5 py-1.5","text-sm text-[var(--color-text)] outline-none focus:ring-1 focus:ring-[var(--color-primary)]")})]}),l.jsxs("div",{className:"flex gap-3",children:[l.jsxs("div",{className:"flex-1",children:[l.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Port"}),l.jsx("input",{type:"number",value:oe.port,onChange:U=>he(z=>({...z,port:U.target.value})),placeholder:"e.g. 1984",className:te("w-full rounded border border-[var(--color-border)] bg-[var(--color-background)] px-2.5 py-1.5","text-sm text-[var(--color-text)] outline-none focus:ring-1 focus:ring-[var(--color-primary)]")})]}),l.jsxs("div",{className:"w-20",children:[l.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Scheme"}),l.jsxs("select",{value:oe.scheme,onChange:U=>he(z=>({...z,scheme:U.target.value})),className:te("w-full rounded border border-[var(--color-border)] bg-[var(--color-background)] px-2 py-1.5","text-sm text-[var(--color-text)] outline-none focus:ring-1 focus:ring-[var(--color-primary)]"),children:[l.jsx("option",{value:"http",children:"http"}),l.jsx("option",{value:"https",children:"https"}),l.jsx("option",{value:"mqtt",children:"mqtt"}),l.jsx("option",{value:"mqtts",children:"mqtts"}),l.jsx("option",{value:"ws",children:"ws"}),l.jsx("option",{value:"wss",children:"wss"})]})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Health Path"}),l.jsx("input",{type:"text",value:oe.health_path,onChange:U=>he(z=>({...z,health_path:U.target.value})),placeholder:"/health",className:te("w-full rounded border border-[var(--color-border)] bg-[var(--color-background)] px-2.5 py-1.5","text-sm text-[var(--color-text)] outline-none focus:ring-1 focus:ring-[var(--color-primary)]")})]})]}),l.jsx("div",{className:"mt-3 flex justify-end",children:l.jsx("button",{onClick:se,disabled:g.isPending||!oe.name.trim()||!oe.port,className:te("rounded-lg bg-[var(--color-primary)] px-4 py-1.5 text-sm font-medium text-white","hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50"),children:g.isPending?"Adding...":"Add Service"})})]}),l.jsx("div",{className:"space-y-2",children:a?.services.map(U=>{const z=ve(U.name),Se=H[U.name]??{status:"idle"};return l.jsx(SE,{entry:U,checked:z.checked,host:z.host,port:z.port,scheme:z.scheme,onToggle:()=>{const xe=!z.checked;W(U.name,{...z,checked:xe}),xe?j(U.name,z.host,z.port,U.health_path,z.scheme):K(Ut=>({...Ut,[U.name]:{status:"idle"}}))},onHostChange:xe=>W(U.name,{...z,host:xe}),onPortChange:xe=>W(U.name,{...z,port:xe}),onSchemeChange:xe=>W(U.name,{...z,scheme:xe}),onHostBlur:()=>{z.checked&&j(U.name,z.host,z.port,U.health_path,z.scheme)},onPortBlur:()=>{z.checked&&j(U.name,z.host,z.port,U.health_path,z.scheme)},onRotateKey:()=>G(U.name),onDelete:()=>Z(U.name),disabled:m.isPending,rotating:O===U.name,deleting:Y===U.name,healthStatus:Se.status,healthError:Se.error,healthLatency:Se.latency},U.name)})}),l.jsx("button",{onClick:D,disabled:m.isPending||ue===0,className:te("rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm font-medium text-white","hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50"),children:m.isPending?"Registering...":`Register Selected (${ue})`}),E&&l.jsx(EE,{serviceName:E.service_name,appKey:E.app_key,envWritten:E.env_written,copiedKey:ne,onCopy:me,label:"Rotated Key"}),R&&l.jsxs("div",{className:"space-y-2 rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsx("h2",{className:"text-sm font-semibold text-[var(--color-text)]",children:"Registration Results"}),R.map(U=>l.jsxs("div",{className:te("flex flex-wrap items-center gap-3 rounded-lg border p-3 text-sm",U.config_ok&&U.auth_ok?"border-green-500/20 bg-green-500/5":"border-yellow-500/20 bg-yellow-500/5"),children:[l.jsx("span",{className:"min-w-[180px] font-medium text-[var(--color-text)]",children:U.name}),l.jsxs("span",{className:te("text-xs",U.config_ok?"text-green-600 dark:text-green-400":"text-red-500"),children:["Config: ",U.config_ok?"OK":"Failed"]}),l.jsxs("span",{className:te("text-xs",U.auth_ok?"text-green-600 dark:text-green-400":"text-red-500"),children:["Auth: ",U.auth_ok?U.auth_created?"Created":"Exists":"Failed"]}),U.env_written!==null&&l.jsxs("span",{className:te("text-xs",U.env_written?"text-green-600 dark:text-green-400":"text-red-500"),children:[".env: ",U.env_written?"Written":"Failed"]}),U.error&&l.jsxs("span",{className:"flex items-center gap-1 text-xs text-yellow-600 dark:text-yellow-400",children:[l.jsx(ra,{size:12}),U.error]}),U.auth_created&&U.app_key&&l.jsxs("div",{className:"mt-1 w-full",children:[l.jsxs("div",{className:"mb-1 flex items-center gap-1 text-xs font-medium text-yellow-600 dark:text-yellow-400",children:[l.jsx(ra,{size:12}),"App key (shown once only):"]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("code",{className:"flex-1 overflow-x-auto rounded bg-[var(--color-background)] px-2 py-1 font-mono text-xs text-[var(--color-text)]",children:U.app_key}),l.jsx("button",{onClick:()=>me(U.app_key),className:"rounded p-1 hover:bg-[var(--color-surface-alt)]",title:"Copy to clipboard",children:ne===U.app_key?l.jsx(xi,{size:14,className:"text-green-500"}):l.jsx(qd,{size:14,className:"text-[var(--color-text-muted)]"})})]})]})]},U.name))]}),je&&l.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-blue-500/20 bg-blue-500/5 p-3",children:[l.jsx(lS,{size:16,className:"mt-0.5 shrink-0 text-blue-500"}),l.jsx("p",{className:"text-sm text-[var(--color-text)]",children:"Services whose .env files were updated need to be restarted to pick up the new credentials. Restart each affected service's container or process."})]})]})}function EE({serviceName:a,appKey:s,envWritten:o,copiedKey:i,onCopy:d,label:f}){return l.jsxs("div",{className:"space-y-2 rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsxs("h2",{className:"text-sm font-semibold text-[var(--color-text)]",children:[f,": ",a]}),l.jsxs("div",{className:"rounded-lg border border-green-500/20 bg-green-500/5 p-3",children:[o!==null&&l.jsxs("span",{className:te("mb-2 inline-block text-xs",o?"text-green-600 dark:text-green-400":"text-red-500"),children:[".env: ",o?"Written":"Failed"]}),l.jsxs("div",{children:[l.jsxs("div",{className:"mb-1 flex items-center gap-1 text-xs font-medium text-yellow-600 dark:text-yellow-400",children:[l.jsx(ra,{size:12}),"New app key (shown once only):"]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("code",{className:"flex-1 overflow-x-auto rounded bg-[var(--color-background)] px-2 py-1 font-mono text-xs text-[var(--color-text)]",children:s}),l.jsx("button",{onClick:()=>d(s),className:"rounded p-1 hover:bg-[var(--color-surface-alt)]",title:"Copy to clipboard",children:i===s?l.jsx(xi,{size:14,className:"text-green-500"}):l.jsx(qd,{size:14,className:"text-[var(--color-text-muted)]"})})]})]})]})]})}async function CE(){const{data:a}=await be.get("/api/llm-setup/status");return a}async function TE(a){const{data:s}=await be.post("/api/llm-setup/configure",{settings:a});return s}async function _E(a,s,o){const{data:i}=await be.post("/api/llm-setup/download",{repo:a,filename:s,token:o});return i}function RE(){return yt({queryKey:["llm-status"],queryFn:CE,staleTime:3e4,retry:1})}function Ng(){const a=pt();return bt({mutationFn:s=>TE(s),onSuccess:()=>{a.invalidateQueries({queryKey:["llm-status"]}),a.invalidateQueries({queryKey:["containers"]})}})}function kE(){return bt({mutationFn:({repo:a,filename:s,token:o})=>_E(a,s,o)})}async function Yd(){const{data:a}=await be.get("/api/install/status");return a}async function ME(a){const s=a?.length?{services:a.join(",")}:{},{data:o}=await be.get("/api/install/preflight",{params:s});return o}async function AE(){const{data:a}=await be.get("/api/install/hardware");return a}async function Bx(a){const{data:s}=await be.post("/api/install/generate",a);return s}async function jg(){const{data:a}=await be.get("/api/install/registry");return a}async function OE(){const{data:a}=await be.get("/api/install/defaults");return a}const zE={running:"bg-emerald-500",exited:"bg-red-500",restarting:"bg-amber-500",paused:"bg-amber-500",created:"bg-gray-400",dead:"bg-red-700"};function DE(a){return a.match(/^Up (.+)$/)?.[1]??null}function qx({container:a,onRestart:s,isRestarting:o}){const i=DE(a.status),d=a.ports.find(f=>f.public)?.public;return l.jsxs("div",{className:"overflow-hidden rounded-xl border border-[var(--color-border)] bg-[var(--color-surface)]",children:[l.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[l.jsx("div",{className:te("h-2.5 w-2.5 rounded-full",zE[a.state]??"bg-gray-400")}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"truncate text-sm font-medium text-[var(--color-text)]",children:a.displayName??a.name}),a.description&&l.jsx("p",{className:"truncate text-xs text-[var(--color-text-muted)]",children:a.description})]}),l.jsx("span",{className:te("rounded-full px-2 py-0.5 text-xs font-medium",a.state==="running"?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"bg-red-500/10 text-red-600 dark:text-red-400"),children:a.state})]}),l.jsx("div",{className:"border-t border-[var(--color-border)] px-4 py-2",children:l.jsxs("div",{className:"flex items-center justify-between text-xs text-[var(--color-text-muted)]",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[i&&l.jsxs("span",{children:["Up ",i]}),d&&l.jsxs("span",{children:[":",d]})]}),l.jsxs("div",{className:"flex items-center gap-1",children:[d&&l.jsx("a",{href:`http://localhost:${d}/health`,target:"_blank",rel:"noopener noreferrer",className:"rounded p-1 hover:bg-[var(--color-surface-alt)]",title:"Open health endpoint",children:l.jsx(Wj,{size:13})}),l.jsx("button",{onClick:()=>s(a.id),disabled:o,className:te("rounded p-1 hover:bg-[var(--color-surface-alt)]",o&&"animate-spin"),title:"Restart",children:l.jsx(Gd,{size:13})})]})]})})]})}async function UE(){const{data:a}=await be.get("/api/update/check");return a}function Sg(){return yt({queryKey:["update-check"],queryFn:UE,staleTime:300*1e3,retry:1,refetchOnWindowFocus:!1})}const Hx="jarvis-update-dismissed-version";function Gx(){const a=wa(),{data:s}=Sg(),[o,i]=N.useState(()=>s?.latestVersion?localStorage.getItem(Hx)===s.latestVersion:!1);return!s?.updateAvailable||o?null:l.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-green-500/30 bg-green-500/5 p-4",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(tg,{size:20,className:"text-green-500"}),l.jsxs("div",{children:[l.jsxs("p",{className:"text-sm font-medium text-[var(--color-text)]",children:["Jarvis v",s.latestVersion," available"]}),l.jsxs("p",{className:"text-xs text-[var(--color-text-muted)]",children:["You have v",s.currentVersion]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[s.releaseUrl&&l.jsx("a",{href:s.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:"Release notes"}),l.jsx("button",{onClick:()=>{localStorage.setItem(Hx,s.latestVersion),i(!0)},className:"text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:"Dismiss"}),l.jsx("button",{onClick:()=>a("/update"),className:"rounded-lg bg-green-600 px-3 py-1.5 text-xs text-white hover:opacity-90",children:"Update"})]})]})}const Ku="jarvis-admin:llm-setup-dismissed";function LE(){const a=wa(),[s,o]=N.useState(!1),{data:i,isLoading:d,isError:f,error:m,refetch:v,isFetching:g}=yg(),h=bg(),y=RE(),[x,S]=N.useState(()=>!!localStorage.getItem(Ku));N.useEffect(()=>{Yd().then(k=>{k.deployMode==="compose-export"&&o(!0)}).catch(()=>{})},[]);const R=!!y.data&&!y.data.configured&&!x,w=k=>{h.mutate(k,{onSuccess:()=>Me.success("Container restart initiated"),onError:Y=>Me.error(`Restart failed: ${Y.message}`)})};if(s)return l.jsxs("div",{className:"mx-auto max-w-4xl space-y-4",children:[l.jsx("h1",{className:"text-xl font-bold text-[var(--color-text)]",children:"Dashboard"}),l.jsx(Gx,{}),R&&l.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-[var(--color-primary)]/30 bg-[var(--color-primary)]/5 p-4",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(pd,{size:20,className:"text-[var(--color-primary)]"}),l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:"LLM not configured"}),l.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:"Set up a language model to enable voice command processing"})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:()=>{localStorage.setItem(Ku,"true"),S(!0)},className:"text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:"Dismiss"}),l.jsx("button",{onClick:()=>a("/llm-setup"),className:"rounded-lg bg-[var(--color-primary)] px-3 py-1.5 text-xs text-white hover:opacity-90",children:"Set up LLM"})]})]}),l.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(xd,{size:20,className:"text-[var(--color-text-muted)]"}),l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:"Sync compose to latest registry"}),l.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:"Regenerate docker-compose.yml, apply changes, and re-register services with config-service"})]})]}),l.jsx("button",{onClick:()=>a("/reconcile"),className:"rounded-lg border border-[var(--color-border)] px-3 py-1.5 text-xs text-[var(--color-text)] hover:bg-[var(--color-surface-alt)]",children:"Sync now"})]}),l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-8 text-center",children:[l.jsx(Qd,{size:32,className:"mx-auto mb-3 text-[var(--color-text-muted)]"}),l.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:"Running in Docker Compose mode"}),l.jsx("p",{className:"mt-1 text-xs text-[var(--color-text-muted)]",children:"Container management is handled by your Docker environment (TrueNAS, Portainer, etc.). Use your platform's tools to view container status, logs, and restarts."})]})]});if(d)return l.jsx("div",{className:"flex items-center justify-center py-20",children:l.jsx(it,{className:"animate-spin text-[var(--color-primary)]",size:24})});if(f)return l.jsxs("div",{className:"py-20 text-center",children:[l.jsx("p",{className:"mb-2 text-red-500",children:"Failed to load containers"}),l.jsx("p",{className:"mb-4 text-sm text-[var(--color-text-muted)]",children:m?.message??"Unknown error"}),l.jsx("button",{onClick:()=>v(),className:"rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm text-white hover:opacity-90",children:"Retry"})]});const E=i?.containers??[],_=E.filter(k=>k.state==="running"),O=E.filter(k=>k.state!=="running");return l.jsxs("div",{className:"mx-auto max-w-4xl space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h1",{className:"text-xl font-bold text-[var(--color-text)]",children:"Dashboard"}),l.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--color-text-muted)]",children:[l.jsxs("span",{children:[_.length,"/",E.length," running"]}),l.jsx("button",{onClick:()=>v(),disabled:g,className:te("rounded-lg p-1.5 hover:bg-[var(--color-surface-alt)]",g&&"animate-spin"),title:"Refresh",children:l.jsx(it,{size:14})})]})]}),l.jsx(Gx,{}),R&&l.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-[var(--color-primary)]/30 bg-[var(--color-primary)]/5 p-4",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(pd,{size:20,className:"text-[var(--color-primary)]"}),l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:"LLM not configured"}),l.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:"Set up a language model to enable voice command processing"})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:()=>{localStorage.setItem(Ku,"true"),S(!0)},className:"text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:"Dismiss"}),l.jsx("button",{onClick:()=>a("/llm-setup"),className:"rounded-lg bg-[var(--color-primary)] px-3 py-1.5 text-xs text-white hover:opacity-90",children:"Set up LLM"})]})]}),l.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(xd,{size:20,className:"text-[var(--color-text-muted)]"}),l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:"Sync compose to latest registry"}),l.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:"Regenerate docker-compose.yml and apply changes — adds new background workers and services without recreating unchanged containers"})]})]}),l.jsx("button",{onClick:()=>a("/reconcile"),className:"rounded-lg border border-[var(--color-border)] px-3 py-1.5 text-xs text-[var(--color-text)] hover:bg-[var(--color-surface-alt)]",children:"Sync now"})]}),E.length===0&&l.jsx("div",{className:"py-12 text-center",children:l.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:i?.error?i.error:"No Jarvis containers found. Is Docker running?"})}),_.length>0&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("h2",{className:"text-xs font-semibold uppercase tracking-wider text-[var(--color-text-muted)]",children:"Running"}),l.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:_.map(k=>l.jsx(qx,{container:k,onRestart:w,isRestarting:h.isPending&&h.variables===k.id},k.id))})]}),O.length>0&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("h2",{className:"text-xs font-semibold uppercase tracking-wider text-[var(--color-text-muted)]",children:"Stopped"}),l.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:O.map(k=>l.jsx(qx,{container:k,onRestart:w,isRestarting:h.isPending&&h.variables===k.id},k.id))})]})]})}async function BE(){const{data:a}=await be.get("/api/nodes");return a}async function qE(a){const{data:s}=await be.get(`/api/nodes/${a}/nodes`);return s}async function HE(a){const{data:s}=await be.post(`/api/nodes/${a}/train-adapter`);return s}function GE(){return yt({queryKey:["households"],queryFn:BE,staleTime:3e4})}function QE(a){return yt({queryKey:["household-nodes",a],queryFn:()=>qE(a),enabled:!!a,staleTime:3e4})}function VE(){const a=pt();return bt({mutationFn:HE,onSuccess:()=>{a.invalidateQueries({queryKey:["household-nodes"]})}})}function FE({node:a,onTrain:s,isTraining:o}){return l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsxs("div",{className:"flex items-start justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(On,{size:16,className:"text-[var(--color-text-muted)]"}),l.jsx("span",{className:"font-medium text-[var(--color-text)]",children:a.name})]}),l.jsxs("span",{className:te("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium",a.is_active?"bg-green-500/10 text-green-500":"bg-red-500/10 text-red-500"),children:[a.is_active?l.jsx(oi,{size:10}):l.jsx(PS,{size:10}),a.is_active?"Active":"Inactive"]})]}),l.jsxs("div",{className:"mt-3 space-y-1 text-xs text-[var(--color-text-muted)]",children:[l.jsxs("p",{children:[l.jsx("span",{className:"font-medium",children:"ID:"})," ",a.node_id]}),a.services.length>0&&l.jsxs("p",{children:[l.jsx("span",{className:"font-medium",children:"Services:"})," ",a.services.join(", ")]})]}),l.jsx("div",{className:"mt-4",children:l.jsx("button",{onClick:()=>s(a.node_id),disabled:o||!a.is_active,className:te("rounded-lg px-3 py-1.5 text-xs font-medium transition-colors",o||!a.is_active?"cursor-not-allowed bg-[var(--color-surface-alt)] text-[var(--color-text-muted)]":"bg-[var(--color-primary)] text-white hover:opacity-90"),children:o?l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx(it,{size:12,className:"animate-spin"}),"Training..."]}):"Train Adapter"})})]})}function YE({householdId:a,householdName:s}){const{data:o,isLoading:i,isError:d}=QE(a),f=VE(),m=v=>{f.mutate(v,{onSuccess:g=>Me.success(`Training triggered for ${v} (request: ${g.request_id.slice(0,8)}...)`),onError:g=>Me.error(`Training failed: ${g.message}`)})};return l.jsxs("div",{className:"space-y-2",children:[l.jsx("h2",{className:"text-xs font-semibold uppercase tracking-wider text-[var(--color-text-muted)]",children:s}),i&&l.jsx("div",{className:"flex items-center justify-center py-8",children:l.jsx(it,{className:"animate-spin text-[var(--color-primary)]",size:18})}),d&&l.jsx("p",{className:"py-4 text-center text-sm text-red-500",children:"Failed to load nodes"}),o&&o.length===0&&l.jsx("p",{className:"py-4 text-center text-sm text-[var(--color-text-muted)]",children:"No nodes registered in this household"}),o&&o.length>0&&l.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:o.map(v=>l.jsx(FE,{node:v,onTrain:m,isTraining:f.isPending&&f.variables===v.node_id},v.node_id))})]})}function XE(){const{data:a,isLoading:s,isError:o,error:i,refetch:d,isFetching:f}=GE();return s?l.jsx("div",{className:"flex items-center justify-center py-20",children:l.jsx(it,{className:"animate-spin text-[var(--color-primary)]",size:24})}):o?l.jsxs("div",{className:"py-20 text-center",children:[l.jsx("p",{className:"mb-2 text-red-500",children:"Failed to load households"}),l.jsx("p",{className:"mb-4 text-sm text-[var(--color-text-muted)]",children:i?.message??"Unknown error"}),l.jsx("button",{onClick:()=>d(),className:"rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm text-white hover:opacity-90",children:"Retry"})]}):l.jsxs("div",{className:"mx-auto max-w-4xl space-y-6",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h1",{className:"text-xl font-bold text-[var(--color-text)]",children:"Nodes"}),l.jsx("button",{onClick:()=>d(),disabled:f,className:te("rounded-lg p-1.5 hover:bg-[var(--color-surface-alt)]",f&&"animate-spin"),title:"Refresh",children:l.jsx(it,{size:14,className:"text-[var(--color-text-muted)]"})})]}),(!a||a.length===0)&&l.jsx("div",{className:"py-12 text-center",children:l.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:"No households found. Register a household in jarvis-auth first."})}),a?.map(m=>l.jsx(YE,{householdId:m.id,householdName:m.name},m.id))]})}async function KE(){const{data:a}=await be.get("/api/admin/households");return a}async function $E(){const{data:a}=await be.get("/api/admin/nodes");return a}async function ZE(){const{data:a}=await be.get("/api/admin/users");return a}async function JE(a,s={}){const{data:o}=await be.post(`/api/admin/users/${a}/temp-password`,s);return o}function PE(){return yt({queryKey:["admin-users"],queryFn:ZE,staleTime:3e4})}function IE(){const a=pt();return bt({mutationFn:({userId:s,options:o})=>JE(s,o),onSuccess:()=>{a.invalidateQueries({queryKey:["admin-users"]})}})}function $u({tone:a,children:s}){const o={green:"bg-green-500/10 text-green-500",red:"bg-red-500/10 text-red-500",amber:"bg-amber-500/10 text-amber-500",blue:"bg-blue-500/10 text-blue-500"};return l.jsx("span",{className:te("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium",o[a]),children:s})}function WE({result:a,email:s,onDismiss:o}){const i=async()=>{try{await navigator.clipboard.writeText(a.temp_password),Me.success("Temporary password copied")}catch{Me.error("Copy failed — select it manually")}};return l.jsxs("div",{className:"rounded-lg border border-amber-500/40 bg-amber-500/5 p-4",children:[l.jsxs("p",{className:"text-sm font-medium text-[var(--color-text)]",children:["Temporary password for ",s]}),l.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[l.jsx("code",{className:"rounded bg-[var(--color-surface-alt)] px-3 py-1.5 font-mono text-base tracking-wide text-[var(--color-text)]",children:a.temp_password}),l.jsx("button",{onClick:i,className:"rounded-lg p-1.5 hover:bg-[var(--color-surface-alt)]",title:"Copy to clipboard",children:l.jsx(qd,{size:14,className:"text-[var(--color-text-muted)]"})})]}),l.jsxs("p",{className:"mt-2 text-xs text-[var(--color-text-muted)]",children:["Shown once — it is not stored anywhere. Valid until"," ",new Date(a.expires_at).toLocaleString(),". All of the user's sessions were signed out; on their next login they'll be asked to set a new password."]}),l.jsx("button",{onClick:o,className:"mt-3 rounded-lg bg-[var(--color-primary)] px-3 py-1.5 text-xs font-medium text-white hover:opacity-90",children:"Done"})]})}function e4({user:a,onCancel:s,onConfirm:o,isPending:i}){const[d,f]=N.useState(""),m=d.length>0&&d.length<8;return l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:[l.jsxs("p",{className:"text-sm text-[var(--color-text)]",children:["Reset the password for ",l.jsx("span",{className:"font-medium",children:a.email}),"? This signs the user out everywhere and replaces their password with a temporary one they must change at next login."]}),l.jsxs("div",{className:"mt-3",children:[l.jsx("input",{type:"text",value:d,onChange:v=>f(v.target.value),placeholder:"Custom temp password (optional — leave blank to generate)",className:"w-full max-w-md rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] px-3 py-1.5 text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]"}),m&&l.jsx("p",{className:"mt-1 text-xs text-red-500",children:"Must be at least 8 characters"})]}),l.jsxs("div",{className:"mt-3 flex gap-2",children:[l.jsx("button",{onClick:()=>o(d||null),disabled:i||m,className:te("rounded-lg px-3 py-1.5 text-xs font-medium transition-colors",i||m?"cursor-not-allowed bg-[var(--color-surface)] text-[var(--color-text-muted)]":"bg-red-500 text-white hover:opacity-90"),children:i?l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx(it,{size:12,className:"animate-spin"}),"Resetting..."]}):"Reset password"}),l.jsx("button",{onClick:s,disabled:i,className:"rounded-lg px-3 py-1.5 text-xs font-medium text-[var(--color-text-muted)] hover:bg-[var(--color-surface)]",children:"Cancel"})]})]})}function t4({user:a}){const[s,o]=N.useState("idle"),[i,d]=N.useState(null),f=IE(),m=v=>{f.mutate({userId:a.id,options:v?{temp_password:v}:{}},{onSuccess:g=>{o("idle"),d(g)},onError:g=>Me.error(`Reset failed: ${g.message}`)})};return l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"font-medium text-[var(--color-text)]",children:a.email}),a.is_superuser&&l.jsxs($u,{tone:"blue",children:[l.jsx(US,{size:10}),"Superuser"]}),!a.is_active&&l.jsxs($u,{tone:"red",children:[l.jsx(XS,{size:10}),"Deactivated"]}),a.must_change_password&&l.jsxs($u,{tone:"amber",children:[l.jsx(Xj,{size:10}),"Temp password"]})]}),l.jsxs("div",{className:"mt-1 space-y-0.5 text-xs text-[var(--color-text-muted)]",children:[l.jsxs("p",{children:[l.jsx("span",{className:"font-medium",children:"Username:"})," ",a.username]}),a.households.length>0&&l.jsxs("p",{children:[l.jsx("span",{className:"font-medium",children:"Households:"})," ",a.households.map(v=>`${v.household_name} (${v.role})`).join(", ")]}),l.jsxs("p",{children:[l.jsx("span",{className:"font-medium",children:"Created:"})," ",new Date(a.created_at).toLocaleDateString()]})]})]}),s==="idle"&&!i&&l.jsxs("button",{onClick:()=>o("confirm"),disabled:!a.is_active,title:a.is_active?void 0:"Reactivate the account first",className:te("flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors",a.is_active?"bg-[var(--color-surface-alt)] text-[var(--color-text)] hover:bg-[var(--color-primary)]/10 hover:text-[var(--color-primary)]":"cursor-not-allowed bg-[var(--color-surface-alt)] text-[var(--color-text-muted)]"),children:[l.jsx(iS,{size:12}),"Reset password"]})]}),s==="confirm"&&l.jsx("div",{className:"mt-3",children:l.jsx(e4,{user:a,onCancel:()=>o("idle"),onConfirm:m,isPending:f.isPending})}),i&&l.jsx("div",{className:"mt-3",children:l.jsx(WE,{result:i,email:a.email,onDismiss:()=>d(null)})})]})}function a4(){const{data:a,isLoading:s,isError:o,error:i,refetch:d,isFetching:f}=PE();return s?l.jsx("div",{className:"flex items-center justify-center py-20",children:l.jsx(it,{className:"animate-spin text-[var(--color-primary)]",size:24})}):o?l.jsxs("div",{className:"py-20 text-center",children:[l.jsx("p",{className:"mb-2 text-red-500",children:"Failed to load users"}),l.jsx("p",{className:"mb-4 text-sm text-[var(--color-text-muted)]",children:i?.message??"Unknown error"}),l.jsx("button",{onClick:()=>d(),className:"rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm text-white hover:opacity-90",children:"Retry"})]}):l.jsxs("div",{className:"mx-auto max-w-4xl space-y-6",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h1",{className:"text-xl font-bold text-[var(--color-text)]",children:"Users"}),l.jsx("button",{onClick:()=>d(),disabled:f,className:te("rounded-lg p-1.5 hover:bg-[var(--color-surface-alt)]",f&&"animate-spin"),title:"Refresh",children:l.jsx(it,{size:14,className:"text-[var(--color-text-muted)]"})})]}),a&&a.length===0&&l.jsx("div",{className:"py-12 text-center",children:l.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:"No users found."})}),l.jsx("div",{className:"space-y-3",children:a?.map(m=>l.jsx(t4,{user:m},m.id))})]})}async function n4(){const{data:a}=await be.get("/api/native-services");return a}async function r4(a){const{data:s}=await be.post(`/api/native-services/${a}/restart`);return s}async function s4(a){const{data:s}=await be.post(`/api/native-services/${a}/stop`);return s}async function l4(a){const{data:s}=await be.post(`/api/native-services/${a}/uninstall`);return s}async function o4(a,s="stderr",o=200){const{data:i}=await be.get(`/api/native-services/${a}/logs`,{params:{stream:s,lines:o}});return i}const bi=["native-services"];function i4(){return yt({queryKey:bi,queryFn:n4,staleTime:5e3,refetchInterval:5e3})}function wg(){const a=pt();return bt({mutationFn:s=>r4(s),onSuccess:()=>a.invalidateQueries({queryKey:bi})})}function c4(){const a=pt();return bt({mutationFn:s=>s4(s),onSuccess:()=>a.invalidateQueries({queryKey:bi})})}function u4(){const a=pt();return bt({mutationFn:s=>l4(s),onSuccess:()=>a.invalidateQueries({queryKey:bi})})}function d4(a,s,o){return yt({queryKey:["native-services-logs",a,s],queryFn:()=>o4(a,s,200),enabled:o,staleTime:3e3,refetchInterval:o?3e3:!1})}function f4(){const{data:a,isLoading:s,isError:o,error:i,refetch:d,isFetching:f}=i4();return s?l.jsx("div",{className:"p-6",children:l.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:"Loading native services…"})}):o?l.jsx("div",{className:"p-6",children:l.jsx(h4,{message:i instanceof Error?i.message:String(i)})}):a?a.supported?l.jsxs("div",{className:"p-6",children:[l.jsxs("header",{className:"mb-4 flex items-start justify-between",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold text-[var(--color-text)]",children:"Native Services"}),l.jsxs("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:["macOS LaunchAgents — these services run outside Docker so they can use the Apple GPU (MLX / Metal / MPS). Status reflects ",l.jsx("code",{children:"launchctl print"}),"."]})]}),l.jsxs("button",{type:"button",onClick:()=>d(),disabled:f,className:te("flex items-center gap-2 rounded-lg border border-[var(--color-border)] px-3 py-1.5 text-sm","hover:bg-[var(--color-surface-alt)] transition-colors",f&&"opacity-50"),children:[l.jsx(it,{size:14,className:f?"animate-spin":""}),"Refresh"]})]}),a.services.length===0?l.jsx("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:l.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:"No native-capable services are registered. Re-run the install wizard to add them."})}):l.jsx("div",{className:"space-y-3",children:a.services.map(m=>l.jsx(m4,{service:m},m.id))})]}):l.jsxs("div",{className:"p-6",children:[l.jsxs("header",{className:"mb-4",children:[l.jsx("h1",{className:"text-2xl font-bold text-[var(--color-text)]",children:"Native Services"}),l.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Manage Jarvis services running as macOS LaunchAgents."})]}),l.jsx("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:l.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:"Native services are only available on macOS. On Linux all services run in Docker."})})]}):null}function m4({service:a}){const s=wg(),o=c4(),i=u4(),[d,f]=N.useState(!1),[m,v]=N.useState("stderr"),g=d4(a.id,m,d),{status:h}=a;async function y(w,E){try{await w,Me.success(E)}catch(_){Me.error(_ instanceof Error?_.message:String(_))}}async function x(){confirm(`Uninstall ${a.id}? The LaunchAgent will be removed; source files at ${h.sourceDir??"~/.jarvis/native"} stay on disk.`)&&await y(i.mutateAsync(a.id),`${a.id} uninstalled`)}const S=h.installed?h.running?`Running (pid ${h.pid??"?"})`:"Installed, stopped":"Not installed",R=h.installed?h.running?"bg-green-500":"bg-amber-500":"bg-[var(--color-text-muted)]/30";return l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] overflow-hidden",children:[l.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-3",children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("span",{className:te("h-2.5 w-2.5 shrink-0 rounded-full",R)}),l.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:a.name}),l.jsxs("span",{className:"text-xs text-[var(--color-text-muted)]",children:[":",h.port??a.port]}),l.jsx("code",{className:"text-xs text-[var(--color-text-muted)]",children:h.label})]}),l.jsxs("p",{className:"ml-5 mt-0.5 text-xs text-[var(--color-text-muted)]",children:[S,h.sourceDir&&l.jsxs("span",{className:"ml-2 opacity-60",children:["· ",h.sourceDir]})]})]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[h.installed&&l.jsxs(l.Fragment,{children:[h.running?l.jsx(pl,{icon:HS,label:"Stop",onClick:()=>y(o.mutateAsync(a.id),`${a.id} stopped`),disabled:o.isPending}):l.jsx(pl,{icon:ng,label:"Start",onClick:()=>y(s.mutateAsync(a.id),`${a.id} started`),disabled:s.isPending}),h.running&&l.jsx(pl,{icon:Gd,label:"Restart",onClick:()=>y(s.mutateAsync(a.id),`${a.id} restarted`),disabled:s.isPending}),l.jsx(pl,{icon:ag,label:d?"Hide logs":"Logs",onClick:()=>f(w=>!w)}),l.jsx(pl,{icon:yi,label:"Uninstall",onClick:x,disabled:i.isPending,danger:!0})]}),!h.installed&&l.jsxs("span",{className:"flex items-center gap-1 text-xs text-[var(--color-text-muted)]",children:[l.jsx(On,{size:12})," Re-run install wizard to enable"]})]})]}),d&&h.installed&&l.jsxs("div",{className:"border-t border-[var(--color-border)] bg-[var(--color-background)] p-3",children:[l.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[l.jsx(Qx,{active:m==="stderr",onClick:()=>v("stderr"),children:"stderr"}),l.jsx(Qx,{active:m==="stdout",onClick:()=>v("stdout"),children:"stdout"}),l.jsx("code",{className:"ml-2 text-xs text-[var(--color-text-muted)] opacity-60",children:g.data?.file})]}),l.jsx("pre",{className:"max-h-80 overflow-auto whitespace-pre-wrap rounded bg-[var(--color-surface-alt)] p-2 text-xs font-mono text-[var(--color-text)]",children:g.isLoading?"Loading…":g.isError?`Failed to load logs: ${g.error instanceof Error?g.error.message:String(g.error)}`:g.data?.content||"(empty)"})]})]})}function pl({icon:a,label:s,onClick:o,disabled:i,danger:d}){return l.jsxs("button",{type:"button",onClick:o,disabled:i,className:te("flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","transition-colors disabled:cursor-not-allowed disabled:opacity-50",d?"border-red-500/30 text-red-500 hover:bg-red-500/10":"border-[var(--color-border)] text-[var(--color-text-muted)] hover:bg-[var(--color-surface-alt)] hover:text-[var(--color-text)]"),children:[l.jsx(a,{size:12}),s]})}function Qx({active:a,onClick:s,children:o}){return l.jsx("button",{type:"button",onClick:s,className:te("rounded px-2 py-0.5 text-xs",a?"bg-[var(--color-primary)] text-white":"border border-[var(--color-border)] text-[var(--color-text-muted)] hover:text-[var(--color-text)]"),children:o})}function h4({message:a}){return l.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-500",children:[l.jsx(Bd,{size:14}),a]})}async function p4(){const{data:a}=await be.get("/api/models/installed");return a.models}async function x4(a){const{data:s}=await be.post("/api/models/download",a);return s}async function v4(a){await be.delete(`/api/models/${encodeURIComponent(a)}`)}function Eg(){return yt({queryKey:["models","installed"],queryFn:p4,staleTime:1e4})}function Cg(){const a=pt();return bt({mutationFn:s=>x4(s),onSuccess:()=>{a.invalidateQueries({queryKey:["models","installed"]})}})}function g4(){const a=pt();return bt({mutationFn:s=>v4(s),onSuccess:()=>{a.invalidateQueries({queryKey:["models","installed"]})}})}const ss=[{id:"qwen3-4b",displayName:"Qwen 3 4B",hfRepoVllm:"Qwen/Qwen3-4B-AWQ",hfRepoGguf:"Qwen/Qwen3-4B-GGUF",ggufFilename:"Qwen3-4B-Q4_K_M.gguf",chatFormat:"qwen3",contextWindow:40960,sizeVllm:"2.5GB",sizeGguf:"2.5GB",vramMb:4096,gated:!1,quantization:"awq",promptProvider:"Qwen25MediumUntrained"},{id:"qwen3-8b",displayName:"Qwen 3 8B",hfRepoVllm:"Qwen/Qwen3-8B-AWQ",hfRepoGguf:"Qwen/Qwen3-8B-GGUF",ggufFilename:"Qwen3-8B-Q4_K_M.gguf",chatFormat:"qwen3",contextWindow:40960,sizeVllm:"5.7GB",sizeGguf:"5GB",vramMb:7168,gated:!1,quantization:"awq",promptProvider:"Qwen25MediumUntrained"},{id:"qwen3-14b",displayName:"Qwen 3 14B",hfRepoVllm:"Qwen/Qwen3-14B-AWQ",hfRepoGguf:"Qwen/Qwen3-14B-GGUF",ggufFilename:"Qwen3-14B-Q4_K_M.gguf",chatFormat:"qwen3",contextWindow:40960,sizeVllm:"9.4GB",sizeGguf:"9GB",vramMb:12288,gated:!1,quantization:"awq",promptProvider:"Qwen3LargeUntrained"},{id:"qwen25-7b",displayName:"Qwen 2.5 7B Instruct",hfRepoVllm:"Qwen/Qwen2.5-7B-Instruct-AWQ",hfRepoGguf:"Qwen/Qwen2.5-7B-Instruct-GGUF",ggufFilename:"qwen2.5-7b-instruct-q4_k_m.gguf",chatFormat:"chatml",contextWindow:32768,sizeVllm:"4.7GB",sizeGguf:"4.7GB",vramMb:6144,gated:!1,quantization:"awq",promptProvider:"Qwen25MediumUntrained"},{id:"llama-3.1-8b",displayName:"Llama 3.1 8B Instruct",hfRepoVllm:"hugging-quants/Meta-Llama-3.1-8B-Instruct-AWQ-INT4",hfRepoGguf:"lmstudio-community/Meta-Llama-3.1-8B-Instruct-GGUF",ggufFilename:"Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf",chatFormat:"llama-3",contextWindow:131072,sizeVllm:"5.4GB",sizeGguf:"5GB",vramMb:7168,gated:!1,quantization:"awq",promptProvider:"Llama31MediumUntrained"},{id:"hermes-3-8b",displayName:"Hermes 3 Llama 3.1 8B",hfRepoVllm:"solidrust/Hermes-3-Llama-3.1-8B-AWQ",hfRepoGguf:"NousResearch/Hermes-3-Llama-3.1-8B-GGUF",ggufFilename:"Hermes-3-Llama-3.1-8B.Q4_K_M.gguf",chatFormat:"chatml",contextWindow:131072,sizeVllm:"5.4GB",sizeGguf:"4.9GB",vramMb:7168,gated:!1,quantization:"awq",promptProvider:"HermesMediumUntrained"}];function y4(){const[a,s]=N.useState(""),[o,i]=N.useState(""),[d,f]=N.useState(""),[m,v]=N.useState(null),{data:g,isLoading:h}=Eg(),y=Cg(),x=g4();function S(E,_){const O=`${E}/${_??""}`;v(O),y.mutate({repo:E,filename:_||void 0,token:a||void 0},{onSuccess:k=>{Me.success(k.message),v(null)},onError:k=>{Me.error(k instanceof Error?k.message:"Download failed"),v(null)}})}function R(E){confirm(`Delete ${E}?`)&&x.mutate(E,{onSuccess:()=>Me.success(`Deleted ${E}`),onError:()=>Me.error("Failed to delete")})}function w(){o&&S(o,d)}return l.jsxs("div",{className:"mx-auto max-w-4xl space-y-8 p-6",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold text-[var(--color-text)]",children:"Models"}),l.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:"Manage LLM models on the inference server"})]}),l.jsxs("section",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[l.jsx(uS,{size:16,className:"text-[var(--color-text-muted)]"}),l.jsx("h2",{className:"text-sm font-semibold text-[var(--color-text)]",children:"HuggingFace Token"}),l.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:"(optional, for gated models)"})]}),l.jsx("input",{type:"password",value:a,onChange:E=>s(E.target.value),placeholder:"hf_...",className:"w-full rounded-md border border-[var(--color-border)] bg-[var(--color-background)] px-3 py-2 text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]"})]}),l.jsxs("section",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[l.jsx(Hd,{size:16,className:"text-[var(--color-text-muted)]"}),l.jsx("h2",{className:"text-sm font-semibold text-[var(--color-text)]",children:"Installed Models"})]}),h?l.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:"Loading..."}):g?.length?l.jsx("div",{className:"space-y-2",children:g.map(E=>l.jsxs("div",{className:"flex items-center justify-between rounded-md border border-[var(--color-border)] px-3 py-2",children:[l.jsxs("div",{children:[l.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:E.name}),l.jsx("span",{className:"ml-2 text-xs text-[var(--color-text-muted)]",children:E.sizeFormatted})]}),l.jsx("button",{onClick:()=>R(E.name),disabled:x.isPending,className:"rounded p-1 text-[var(--color-text-muted)] hover:bg-red-500/10 hover:text-red-500",children:l.jsx(yi,{size:14})})]},E.name))}):l.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:"No models installed yet"})]}),l.jsxs("section",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[l.jsx(BS,{size:16,className:"text-[var(--color-text-muted)]"}),l.jsx("h2",{className:"text-sm font-semibold text-[var(--color-text)]",children:"Suggested Models"})]}),l.jsx("div",{className:"space-y-3",children:ss.map(E=>{const _=g?.some(O=>O.name===E.ggufFilename||O.name.includes(E.ggufFilename));return l.jsxs("div",{className:"flex items-center justify-between rounded-md border border-[var(--color-border)] px-4 py-3",children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:E.displayName}),l.jsxs("span",{className:"rounded bg-[var(--color-surface-alt)] px-1.5 py-0.5 text-xs text-[var(--color-text-muted)]",children:["~",E.sizeGguf]}),_&&l.jsx("span",{className:"rounded bg-green-500/10 px-1.5 py-0.5 text-xs text-green-500",children:"installed"})]}),l.jsxs("p",{className:"text-xs text-[var(--color-text-muted)]",children:[E.hfRepoGguf," / ",E.ggufFilename]}),l.jsxs("p",{className:"text-xs text-[var(--color-text-muted)]",children:["Prompt provider: ",l.jsx("code",{className:"text-[var(--color-primary)]",children:E.promptProvider})]})]}),l.jsxs("button",{onClick:()=>S(E.hfRepoGguf,E.ggufFilename),disabled:m!==null,className:te("ml-4 flex items-center gap-1 rounded-md px-3 py-1.5 text-sm font-medium transition-colors",_?"border border-[var(--color-border)] text-[var(--color-text-muted)] hover:bg-[var(--color-surface-alt)]":"bg-[var(--color-primary)] text-white hover:opacity-90"),children:[l.jsx(en,{size:14}),m===`${E.hfRepoGguf}/${E.ggufFilename}`?"Downloading...":_?"Re-download":"Download"]})]},E.id)})})]}),l.jsxs("section",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[l.jsx(en,{size:16,className:"text-[var(--color-text-muted)]"}),l.jsx("h2",{className:"text-sm font-semibold text-[var(--color-text)]",children:"Download from HuggingFace"})]}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Repository (e.g. Qwen/Qwen3-14B-GGUF)"}),l.jsx("input",{value:o,onChange:E=>i(E.target.value),placeholder:"owner/repo-name",className:"w-full rounded-md border border-[var(--color-border)] bg-[var(--color-background)] px-3 py-2 text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Filename (optional — downloads specific file instead of full repo)"}),l.jsx("input",{value:d,onChange:E=>f(E.target.value),placeholder:"model-name.gguf",className:"w-full rounded-md border border-[var(--color-border)] bg-[var(--color-background)] px-3 py-2 text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]"})]}),l.jsxs("button",{onClick:w,disabled:!o||m!==null,className:"flex items-center gap-2 rounded-md bg-[var(--color-primary)] px-4 py-2 text-sm font-medium text-white transition-colors hover:opacity-90 disabled:opacity-50",children:[l.jsx(en,{size:14}),m===`${o}/${d}`?"Downloading...":"Download"]})]})]})]})}async function b4(){const{data:a}=await be.get("/api/quick-sets");return a}async function N4(a){const{data:s}=await be.post("/api/quick-sets/apply",a);return s}async function j4(a){const{data:s}=await be.post("/api/quick-sets/custom",a);return s}async function S4(a){const{data:s}=await be.delete(`/api/quick-sets/custom/${a}`);return s}function w4(){return yt({queryKey:["quick-sets"],queryFn:b4,staleTime:6e4})}function E4(){const a=pt();return bt({mutationFn:s=>N4(s),onSuccess:()=>{a.invalidateQueries({queryKey:["quick-sets"]}),a.invalidateQueries({queryKey:["settings"]}),a.invalidateQueries({queryKey:["llm-status"]}),a.invalidateQueries({queryKey:["containers"]})}})}function C4(){const a=pt();return bt({mutationFn:s=>j4(s),onSuccess:()=>{a.invalidateQueries({queryKey:["quick-sets"]})}})}function T4(){const a=pt();return bt({mutationFn:s=>S4(s),onSuccess:()=>{a.invalidateQueries({queryKey:["quick-sets"]})}})}const Vx=["GGUF","MLX","VLLM","TRANSFORMERS","REST"];function _4(){const{data:a,isLoading:s,error:o}=w4(),i=E4(),d=C4(),f=T4(),{data:m}=Eg(),v=N.useMemo(()=>(m??[]).map(z=>`.models/${z.name}`),[m]),[g,h]=N.useState(null),[y,x]=N.useState(""),[S,R]=N.useState(!1),[w,E]=N.useState(""),[_,O]=N.useState(""),[k,Y]=N.useState(""),[I,ne]=N.useState(""),[ee,H]=N.useState(new Set(["live"])),[K,ie]=N.useState(!1),[re,oe]=N.useState(""),[he,Ee]=N.useState(""),[Te,ae]=N.useState(""),[C,F]=N.useState(""),[X,ve]=N.useState("GGUF"),[W,j]=N.useState(8192),D=a?.presets,G=N.useMemo(()=>{if(!D)return new Map;const z=new Map;for(const Se of D){const xe=Se.family||"Custom",Ut=z.get(xe)??[];Ut.push(Se),z.set(xe,Ut)}return z},[D]);function Z(z){if(g===z.id){h(null);return}h(z.id),x(a?.currentValues.modelName??""),R(!1),O(z.defaultBackend),Y(z.chatFormat),ne(z.promptProvider);const Se=a?.currentValues.contextWindow;E(Se&&Se>0?Se:z.defaultContextWindow)}function se(z){H(Se=>{const xe=new Set(Se);return xe.has(z)?xe.size>1&&xe.delete(z):xe.add(z),xe})}function me(){!g||!y.trim()||i.mutate({presetId:g,modelName:y.trim(),contextWindow:w?Number(w):void 0,backend:_,chatFormat:k,promptProvider:I,targets:Array.from(ee)},{onSuccess:z=>{z.success?Me.success(z.message):Me.warning(z.message),h(null)},onError:z=>{Me.error(z.message||"Failed to apply preset")}})}function ue(){!re.trim()||!Te.trim()||!C.trim()||d.mutate({name:re.trim(),family:he.trim()||"Custom",chatFormat:Te.trim(),promptProvider:C.trim(),defaultBackend:X,defaultContextWindow:W?Number(W):8192},{onSuccess:()=>{Me.success(`Created preset "${re.trim()}"`),ie(!1),oe(""),Ee(""),ae(""),F(""),ve("GGUF"),j(8192)},onError:z=>{Me.error(z.message||"Failed to create preset")}})}function je(z){f.mutate(z.id,{onSuccess:()=>{Me.success(`Deleted "${z.name}"`),g===z.id&&h(null)},onError:()=>Me.error("Failed to delete preset")})}const U=a?.presets.find(z=>z.id===g);return l.jsxs("div",{className:"mx-auto max-w-4xl space-y-8 p-6",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold text-[var(--color-text)]",children:"Quick Sets"}),l.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:"Select a model preset to auto-configure chat format, prompt provider, and backend"})]}),a?.currentValues.modelName&&l.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-3",children:[l.jsx(On,{size:16,className:"text-[var(--color-primary)]"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:"Current model"}),l.jsx("p",{className:"truncate text-sm font-medium text-[var(--color-text)]",children:a.currentValues.modelName})]}),a.currentValues.contextWindow>0&&l.jsxs("span",{className:"rounded bg-[var(--color-surface-alt)] px-2 py-0.5 text-xs text-[var(--color-text-muted)]",children:[a.currentValues.contextWindow.toLocaleString()," ctx"]})]}),s&&l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx(it,{size:20,className:"animate-spin text-[var(--color-text-muted)]"})}),o&&l.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-red-500/30 bg-red-500/5 px-4 py-3",children:[l.jsx(ra,{size:16,className:"text-red-500"}),l.jsx("span",{className:"text-sm text-red-500",children:"Failed to load presets"})]}),!s&&Array.from(G.entries()).map(([z,Se])=>l.jsxs("section",{children:[l.jsx("h2",{className:"mb-3 text-sm font-semibold text-[var(--color-text-muted)]",children:z}),l.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:Se.map(xe=>l.jsxs("div",{className:te("relative rounded-lg border px-4 py-3 transition-colors",g===xe.id?"border-[var(--color-primary)] bg-[var(--color-primary)]/5":"border-[var(--color-border)] bg-[var(--color-surface)] hover:bg-[var(--color-surface-alt)]"),children:[l.jsxs("button",{onClick:()=>Z(xe),className:"w-full text-left",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:xe.name}),g===xe.id&&l.jsx(xi,{size:16,className:"text-[var(--color-primary)]"})]}),xe.description&&l.jsx("p",{className:"mt-1 text-xs text-[var(--color-text-muted)]",children:xe.description}),l.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[l.jsx("span",{className:"rounded bg-[var(--color-surface-alt)] px-1.5 py-0.5 text-xs text-[var(--color-text-muted)]",children:xe.chatFormat}),l.jsx("span",{className:"rounded bg-[var(--color-surface-alt)] px-1.5 py-0.5 text-xs text-[var(--color-text-muted)]",children:xe.defaultBackend})]})]}),xe.isCustom&&l.jsx("button",{onClick:()=>je(xe),disabled:f.isPending,className:"absolute right-2 top-2 rounded p-1 text-[var(--color-text-muted)] hover:bg-red-500/10 hover:text-red-500",title:"Delete custom preset",children:l.jsx(yi,{size:14})})]},xe.id))})]},z)),!s&&!K&&l.jsxs("button",{onClick:()=>ie(!0),className:"flex items-center gap-2 rounded-lg border border-dashed border-[var(--color-border)] px-4 py-3 text-sm text-[var(--color-text-muted)] transition-colors hover:border-[var(--color-primary)] hover:text-[var(--color-primary)]",children:[l.jsx(ti,{size:16}),"Create custom preset"]}),K&&l.jsxs("section",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(ti,{size:16,className:"text-[var(--color-primary)]"}),l.jsx("h2",{className:"text-sm font-semibold text-[var(--color-text)]",children:"New Custom Preset"})]}),l.jsx("button",{onClick:()=>ie(!1),className:"rounded p-1 text-[var(--color-text-muted)] hover:bg-[var(--color-surface-alt)]",children:l.jsx(Vd,{size:16})})]}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Name *"}),l.jsx("input",{type:"text",value:re,onChange:z=>oe(z.target.value),placeholder:"My Custom Model",className:"w-full rounded-md border border-[var(--color-border)] bg-[var(--color-background)] px-3 py-2 text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Family"}),l.jsx("input",{type:"text",value:he,onChange:z=>Ee(z.target.value),placeholder:"Custom",className:"w-full rounded-md border border-[var(--color-border)] bg-[var(--color-background)] px-3 py-2 text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]"})]})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Chat format *"}),l.jsx("input",{type:"text",value:Te,onChange:z=>ae(z.target.value),placeholder:"chatml",className:"w-full rounded-md border border-[var(--color-border)] bg-[var(--color-background)] px-3 py-2 text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Prompt provider *"}),l.jsx("input",{type:"text",value:C,onChange:z=>F(z.target.value),placeholder:"Qwen25MediumUntrained",className:"w-full rounded-md border border-[var(--color-border)] bg-[var(--color-background)] px-3 py-2 text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]"})]})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Default backend"}),l.jsx("select",{value:X,onChange:z=>ve(z.target.value),className:"w-full rounded-md border border-[var(--color-border)] bg-[var(--color-background)] px-3 py-2 text-sm text-[var(--color-text)]",children:Vx.map(z=>l.jsx("option",{value:z,children:z},z))})]}),l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Default context window"}),l.jsx("input",{type:"number",value:W,onChange:z=>j(z.target.value?parseInt(z.target.value,10):""),placeholder:"8192",min:1,className:"w-full rounded-md border border-[var(--color-border)] bg-[var(--color-background)] px-3 py-2 text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]"})]})]}),l.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[l.jsxs("button",{onClick:ue,disabled:!re.trim()||!Te.trim()||!C.trim()||d.isPending,className:"flex items-center gap-2 rounded-md bg-[var(--color-primary)] px-4 py-2 text-sm font-medium text-white transition-colors hover:opacity-90 disabled:opacity-50",children:[d.isPending?l.jsx(it,{size:14,className:"animate-spin"}):l.jsx(ti,{size:14}),d.isPending?"Creating...":"Create Preset"]}),l.jsx("button",{onClick:()=>ie(!1),className:"rounded-md px-3 py-2 text-sm text-[var(--color-text-muted)] hover:bg-[var(--color-surface-alt)]",children:"Cancel"})]})]})]}),U&&l.jsxs("section",{className:"rounded-lg border border-[var(--color-primary)]/30 bg-[var(--color-surface)] p-4",children:[l.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[l.jsx(oi,{size:16,className:"text-[var(--color-primary)]"}),l.jsxs("h2",{className:"text-sm font-semibold text-[var(--color-text)]",children:["Apply: ",U.name]})]}),l.jsxs("div",{className:"mb-4",children:[l.jsx("span",{className:"mb-2 block text-xs font-medium text-[var(--color-text-muted)]",children:"Apply to"}),l.jsx("div",{className:"flex items-center gap-4",children:["live","background"].map(z=>l.jsxs("label",{className:"flex items-center gap-2 text-sm text-[var(--color-text)]",children:[l.jsx("input",{type:"checkbox",checked:ee.has(z),onChange:()=>se(z),className:"rounded border-[var(--color-border)] accent-[var(--color-primary)]"}),l.jsx("span",{className:"capitalize",children:z})]},z))})]}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Model file path"}),v.length>0&&l.jsxs("select",{value:S||y!==""&&!v.includes(y)?"__other__":y,onChange:z=>{z.target.value==="__other__"?R(!0):(R(!1),x(z.target.value))},className:"w-full rounded-md border border-[var(--color-border)] bg-[var(--color-background)] px-3 py-2 text-sm text-[var(--color-text)]",children:[l.jsx("option",{value:"",disabled:!0,children:"Select a model…"}),v.map(z=>l.jsx("option",{value:z,children:z.replace(/^\.models\//,"")},z)),l.jsx("option",{value:"__other__",children:"Other (custom path / HF ID)…"})]}),(v.length===0||S||y!==""&&!v.includes(y))&&l.jsx("input",{type:"text",value:y,onChange:z=>x(z.target.value),placeholder:".models/model-name.gguf",className:"w-full rounded-md border border-[var(--color-border)] bg-[var(--color-background)] px-3 py-2 text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]"})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Chat format"}),l.jsx("input",{type:"text",value:k,onChange:z=>Y(z.target.value),placeholder:"chatml",className:"w-full rounded-md border border-[var(--color-border)] bg-[var(--color-background)] px-3 py-2 text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Prompt provider"}),l.jsx("input",{type:"text",value:I,onChange:z=>ne(z.target.value),placeholder:"Qwen25MediumUntrained",className:"w-full rounded-md border border-[var(--color-border)] bg-[var(--color-background)] px-3 py-2 text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]"})]})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Context window (tokens)"}),l.jsx("input",{type:"number",value:w,onChange:z=>E(z.target.value?parseInt(z.target.value,10):""),placeholder:String(U.defaultContextWindow),min:1,className:"w-full rounded-md border border-[var(--color-border)] bg-[var(--color-background)] px-3 py-2 text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Backend"}),l.jsx("select",{value:_,onChange:z=>O(z.target.value),className:"w-full rounded-md border border-[var(--color-border)] bg-[var(--color-background)] px-3 py-2 text-sm text-[var(--color-text)]",children:Vx.map(z=>l.jsx("option",{value:z,children:z},z))})]})]})]}),l.jsxs("div",{className:"mt-4 flex items-center gap-3",children:[l.jsxs("button",{onClick:me,disabled:!y.trim()||i.isPending,className:"flex items-center gap-2 rounded-md bg-[var(--color-primary)] px-4 py-2 text-sm font-medium text-white transition-colors hover:opacity-90 disabled:opacity-50",children:[i.isPending?l.jsx(it,{size:14,className:"animate-spin"}):l.jsx(oi,{size:14}),i.isPending?"Applying...":"Apply Settings"]}),l.jsx("button",{onClick:()=>h(null),className:"rounded-md px-3 py-2 text-sm text-[var(--color-text-muted)] hover:bg-[var(--color-surface-alt)]",children:"Cancel"})]})]})]})}const Zu={preflight:"Checking prerequisites",download:"Downloading update",binary:"Updating binary",restarting:"Restarting admin server",compose:"Updating configuration",pull:"Pulling images",restart:"Restarting services",verify:"Verifying health",done:"Complete"};function R4(){const a=wa(),{data:s,isLoading:o}=Sg(),[i,d]=N.useState("idle"),[f,m]=N.useState([]),[v,g]=N.useState(null),h=N.useRef(null),y=N.useCallback(R=>{m(w=>[...w,R])},[]);N.useEffect(()=>{h.current&&(h.current.scrollTop=h.current.scrollHeight)},[f]);async function x(){d("preflight"),m([]),g(null);try{const R=localStorage.getItem("jarvis-admin:access_token")??localStorage.getItem("access_token"),w=await fetch("/api/update/apply",{method:"POST",headers:{Authorization:`Bearer ${R}`}});if(!w.ok||!w.body){const k=await w.text();throw new Error(k||`HTTP ${w.status}`)}const E=w.body.getReader(),_=new TextDecoder;let O="";for(;;){const{done:k,value:Y}=await E.read();if(k)break;O+=_.decode(Y,{stream:!0});const I=O.split(`
|
|
17
17
|
`);O=I.pop()??"";for(const ne of I)if(ne.startsWith("data: "))try{const ee=JSON.parse(ne.slice(6));if(ee.phase&&d(ee.phase),ee.message&&y({text:ee.message,phase:ee.phase}),ee.stream&&ee.text&&y({text:ee.text.trim()}),ee.restart){d("restarting"),y({text:"Admin server restarting with new version..."}),await k4(s?.latestVersion??""),d("done"),y({text:"Upgrade complete!"});return}if(ee.done&&ee.code!==0)throw new Error(ee.error??"Upgrade failed");ee.done&&ee.code===0&&d("done")}catch(ee){if(ee instanceof SyntaxError)continue;throw ee}}}catch(R){const w=R instanceof Error?R.message:String(R);g(w),d("error"),y({text:`Error: ${w}`})}}if(o)return l.jsx("div",{className:"flex min-h-[50vh] items-center justify-center",children:l.jsx(Ct,{size:24,className:"animate-spin text-[var(--color-primary)]"})});const S=Object.keys(Zu).filter(R=>{const w=Object.keys(Zu),E=w.indexOf(i);return w.indexOf(R)<E});return l.jsxs("div",{className:"mx-auto max-w-3xl space-y-6 p-6",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold text-[var(--color-text)]",children:"Update Jarvis"}),s?.updateAvailable?l.jsxs("p",{className:"text-sm text-[var(--color-text-muted)]",children:["v",s.currentVersion," → v",s.latestVersion]}):l.jsxs("p",{className:"text-sm text-[var(--color-text-muted)]",children:["You're running the latest version (v",s?.currentVersion??"?",")"]})]}),i!=="idle"&&l.jsx("div",{className:"space-y-2 rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:Object.entries(Zu).map(([R,w])=>{const E=R===i,_=S.includes(R),O=R===i&&i==="error";return l.jsxs("div",{className:"flex items-center gap-2",children:[_?l.jsx(ht,{size:16,className:"text-green-500"}):O?l.jsx(ra,{size:16,className:"text-red-500"}):E?l.jsx(Ct,{size:16,className:"animate-spin text-[var(--color-primary)]"}):l.jsx("div",{className:"h-4 w-4 rounded-full border border-[var(--color-border)]"}),l.jsx("span",{className:te("text-sm",E?"font-medium text-[var(--color-text)]":"text-[var(--color-text-muted)]",_&&"text-green-500"),children:w})]},R)})}),f.length>0&&l.jsx("div",{ref:h,className:"max-h-64 overflow-y-auto rounded-lg border border-[var(--color-border)] bg-[#0d1117] p-3 font-mono text-xs text-gray-300",children:f.map((R,w)=>l.jsx("div",{children:R.text},w))}),v&&l.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-red-500/10 px-3 py-2",children:[l.jsx(ra,{size:14,className:"text-red-500"}),l.jsx("span",{className:"text-sm text-red-500",children:v})]}),l.jsxs("div",{className:"flex gap-3",children:[i==="idle"&&s?.updateAvailable&&l.jsxs("button",{onClick:x,className:"flex items-center gap-2 rounded-lg bg-green-600 px-4 py-2 text-sm font-medium text-white hover:opacity-90",children:[l.jsx(tg,{size:16}),"Update to v",s.latestVersion]}),i==="done"&&l.jsxs("button",{onClick:()=>a("/dashboard"),className:"flex items-center gap-2 rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm font-medium text-white hover:opacity-90",children:[l.jsx(ht,{size:16}),"Go to Dashboard"]}),i==="error"&&l.jsxs("button",{onClick:x,className:"flex items-center gap-2 rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm font-medium text-white hover:opacity-90",children:[l.jsx(it,{size:16}),"Retry"]})]})]})}async function k4(a,s=6e4){const o=Date.now()+s;for(;Date.now()<o;){await new Promise(i=>setTimeout(i,2e3));try{const i=await fetch("/health");if(i.ok){const d=await i.json();if(d.version&&d.version!=="0.0.0-dev")return}}catch{}}throw new Error("Admin server did not restart within 60 seconds")}const Ju={regenerate:"Regenerating compose from registry",pull:"Pulling images for new release track",apply:"Applying changes (docker compose up)",done:"Complete"};function M4(){const a=wa(),s=localStorage.getItem("jarvis-admin:access_token")??localStorage.getItem("access_token"),[o,i]=N.useState("loading_options"),[d,f]=N.useState([]),[m,v]=N.useState(null),g=N.useRef(null),[h,y]=N.useState([]),[x,S]=N.useState(!1),[R,w]=N.useState("https://relay.jarvisautomation.io"),[E,_]=N.useState("/whisper-models/ggml-base.en.bin"),[O,k]=N.useState("cpu"),[Y,I]=N.useState("cpu"),[ne,ee]=N.useState(!1),[H,K]=N.useState("stable"),[ie,re]=N.useState(null),[oe,he]=N.useState(!1),Ee=N.useCallback(W=>{f(j=>[...j,W])},[]);N.useEffect(()=>{g.current&&(g.current.scrollTop=g.current.scrollHeight)},[d]),N.useEffect(()=>{async function W(){try{const j=await fetch("/api/install/reconcile/options",{headers:{Authorization:`Bearer ${s}`}});if(!j.ok)throw new Error(`HTTP ${j.status}`);const D=await j.json();y(D.services),S(D.relayEnabled),w(D.relayUrl||"https://relay.jarvisautomation.io"),_(D.whisperModelPath||"/whisper-models/ggml-base.en.bin"),k(D.whisperBackend??"cpu"),I(D.ttsBackend??"cpu"),ee(D.pinImages??!1),K(D.releaseTrack??"stable"),i("options")}catch(j){v(j instanceof Error?j.message:"Failed to load options"),i("error")}}W()},[s]);function Te(W){y(j=>j.map(D=>D.id===W?{...D,enabled:!D.enabled}:D))}async function ae(){i("regenerate"),f([]),v(null);const W=h.filter(j=>j.enabled).map(j=>j.id);try{const j=await fetch("/api/install/reconcile",{method:"POST",headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json"},body:JSON.stringify({enabledModules:W,relayEnabled:x,relayUrl:R,whisperModelPath:E,whisperBackend:O,ttsBackend:Y,pinImages:ne,releaseTrack:H})});if(!j.ok||!j.body){const se=await j.text();throw new Error(se||`HTTP ${j.status}`)}const D=j.body.getReader(),G=new TextDecoder;let Z="";for(;;){const{done:se,value:me}=await D.read();if(se)break;Z+=G.decode(me,{stream:!0});const ue=Z.split(`
|
|
18
|
-
`);Z=ue.pop()??"";for(const je of ue)if(je.startsWith("data: "))try{const U=JSON.parse(je.slice(6));if(U.phase&&i(U.phase),U.message&&Ee({text:U.message,phase:U.phase}),U.stream&&U.text&&Ee({text:U.text.trim()}),U.done&&U.code!==0)throw new Error(U.message??"Reconcile failed")}catch(U){if(U instanceof SyntaxError)continue;throw U}}}catch(j){const D=j instanceof Error?j.message:String(j);v(D),i("error"),Ee({text:`Error: ${D}`})}}function C(){return{enabledModules:h.filter(W=>W.enabled).map(W=>W.id),relayEnabled:x,relayUrl:R,whisperModelPath:E,whisperBackend:O,ttsBackend:Y,pinImages:ne,releaseTrack:H}}async function F(W){he(!0),v(null),re(null);try{const{latest:j,...D}=W??{},Z=await fetch(`/api/install/regenerate-download${j?"?latest=true":""}`,{method:"POST",headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json"},body:JSON.stringify({...C(),...D})});if(!Z.ok){const me=await Z.text();throw new Error(me||`HTTP ${Z.status}`)}const se=await Z.json();re({compose:se.compose,env:se.env,initDb:se.initDb})}catch(j){v(j instanceof Error?j.message:String(j))}finally{he(!1)}}function X(W,j){const D=new Blob([j],{type:"text/plain;charset=utf-8"}),G=URL.createObjectURL(D),Z=document.createElement("a");Z.href=G,Z.download=W,document.body.appendChild(Z),Z.click(),Z.remove(),URL.revokeObjectURL(G)}const ve=Object.keys(Ju).filter(W=>{const j=Object.keys(Ju),D=j.indexOf(o);return j.indexOf(W)<D||o==="done"&&W==="done"});return l.jsxs("div",{className:"mx-auto max-w-3xl space-y-6 p-6",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold text-[var(--color-text)]",children:"Sync Compose"}),l.jsxs("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:["Regenerate ",l.jsx("code",{className:"rounded bg-[var(--color-surface)] px-1.5 py-0.5 text-xs",children:"docker-compose.yml"})," from the latest service registry, preserving your secrets. ",l.jsx("strong",{className:"text-[var(--color-text)]",children:"Sync now"})," applies it to the running stack;",l.jsx("strong",{className:"text-[var(--color-text)]",children:" Download"})," hands you the files to review and apply by hand (",l.jsx("code",{className:"rounded bg-[var(--color-surface)] px-1 text-xs",children:"docker compose up -d"}),")."," ",l.jsx("strong",{className:"text-[var(--color-text)]",children:"Update stack to latest"})," downloads the same, pinned to the newest published images."]})]}),o==="loading_options"&&l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx(Ct,{size:32,className:"animate-spin text-[var(--color-primary)]"})}),o==="options"&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsx("h2",{className:"mb-3 text-sm font-semibold text-[var(--color-text)]",children:"Services"}),l.jsx("div",{className:"space-y-2",children:h.map(W=>l.jsxs("button",{onClick:()=>Te(W.id),className:"flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left hover:bg-[var(--color-bg-secondary)] transition-colors",children:[W.enabled?l.jsx(ht,{size:18,className:"shrink-0 text-[var(--color-primary)]"}):l.jsx(os,{size:18,className:"shrink-0 text-[var(--color-text-muted)]"}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-sm font-medium text-[var(--color-text)]",children:W.name}),l.jsx("div",{className:"text-xs text-[var(--color-text-muted)]",children:W.description})]})]},W.id))})]}),l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsx("h2",{className:"mb-3 text-sm font-semibold text-[var(--color-text)]",children:"Release Track"}),l.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[l.jsxs("div",{children:[l.jsx("div",{className:"text-sm font-medium text-[var(--color-text)]",children:H==="dev"?"Dev":"Stable"}),l.jsx("div",{className:"text-xs text-[var(--color-text-muted)]",children:H==="dev"?"Using latest main branch builds (may be unstable)":"Using tagged releases"})]}),l.jsx("button",{type:"button",role:"switch","aria-checked":H==="dev",onClick:()=>K(H==="dev"?"stable":"dev"),className:`relative h-6 w-11 shrink-0 rounded-full transition-colors ${H==="dev"?"bg-amber-500":"bg-[var(--color-surface-alt)]"}`,children:l.jsx("span",{className:`absolute left-0.5 top-0.5 h-5 w-5 rounded-full bg-white transition-transform ${H==="dev"?"translate-x-5":"translate-x-0"}`})})]}),H==="dev"&&l.jsx("div",{className:"mx-3 mt-1 rounded-lg border border-amber-300 bg-amber-500/10 px-3 py-2 text-xs text-amber-400",children:"Switching tracks will pull all images and force-recreate containers."})]}),l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsx("h2",{className:"mb-3 text-sm font-semibold text-[var(--color-text)]",children:"Integrations"}),l.jsxs("button",{onClick:()=>S(!x),className:"flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left hover:bg-[var(--color-bg-secondary)] transition-colors",children:[x?l.jsx(ht,{size:18,className:"shrink-0 text-[var(--color-primary)]"}):l.jsx(os,{size:18,className:"shrink-0 text-[var(--color-text-muted)]"}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-sm font-medium text-[var(--color-text)]",children:"Jarvis Relay"}),l.jsx("div",{className:"text-xs text-[var(--color-text-muted)]",children:"Routes OAuth callbacks through a cloud relay for external providers (Google, Spotify, etc.)"})]})]}),x&&l.jsxs("div",{className:"mt-2 px-3",children:[l.jsx("label",{className:"text-xs font-medium text-[var(--color-text-muted)]",children:"Relay URL"}),l.jsx("input",{type:"url",value:R,onChange:W=>w(W.target.value),placeholder:"https://relay.jarvisautomation.io",className:"mt-1 w-full rounded-md border border-[var(--color-border)] bg-[var(--color-bg)] px-3 py-1.5 text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]"})]})]}),h.some(W=>W.id==="jarvis-whisper-api"&&W.enabled)&&l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsx("h2",{className:"mb-3 text-sm font-semibold text-[var(--color-text)]",children:"Whisper"}),l.jsxs("div",{className:"px-3",children:[l.jsx("label",{className:"text-xs font-medium text-[var(--color-text-muted)]",children:"Model path"}),l.jsx("input",{type:"text",value:E,onChange:W=>_(W.target.value),placeholder:"/whisper-models/ggml-base.en.bin",className:"mt-1 w-full rounded-md border border-[var(--color-border)] bg-[var(--color-bg)] px-3 py-1.5 text-sm font-mono text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]"}),l.jsxs("p",{className:"mt-1 text-xs text-[var(--color-text-muted)]",children:["Path inside the container. Place model files in ",l.jsx("code",{className:"rounded bg-[var(--color-bg)] px-1",children:"./whisper-models/"})," next to your compose file."]}),l.jsx("label",{className:"mt-3 block text-xs font-medium text-[var(--color-text-muted)]",children:"GPU backend"}),l.jsxs("select",{value:O,onChange:W=>k(W.target.value),className:"mt-1 w-full rounded-md border border-[var(--color-border)] bg-[var(--color-bg)] px-3 py-1.5 text-sm text-[var(--color-text)]",children:[l.jsx("option",{value:"cpu",children:"CPU (default)"}),l.jsx("option",{value:"cuda",children:"NVIDIA (CUDA)"}),l.jsx("option",{value:"vulkan",children:"AMD / generic (Vulkan)"}),l.jsx("option",{value:"rocm",children:"AMD (ROCm)"})]}),l.jsx("p",{className:"mt-1 text-xs text-[var(--color-text-muted)]",children:"Where speech-to-text runs. CPU leaves the GPU for the LLM; pick a GPU backend to run Whisper on the GPU."})]})]}),h.some(W=>W.id==="jarvis-tts"&&W.enabled)&&l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsx("h2",{className:"mb-3 text-sm font-semibold text-[var(--color-text)]",children:"Text-to-speech"}),l.jsxs("div",{className:"px-3",children:[l.jsx("label",{className:"text-xs font-medium text-[var(--color-text-muted)]",children:"Inference device"}),l.jsxs("select",{value:Y,onChange:W=>I(W.target.value),className:"mt-1 w-full rounded-md border border-[var(--color-border)] bg-[var(--color-bg)] px-3 py-1.5 text-sm text-[var(--color-text)]",children:[l.jsx("option",{value:"cpu",children:"CPU (default)"}),l.jsx("option",{value:"cuda",children:"NVIDIA (CUDA)"})]}),l.jsxs("p",{className:"mt-1 text-xs text-[var(--color-text-muted)]",children:["Where Kokoro synthesis runs. CPU is fine for most installs; CUDA gives the fastest first-audio. On multi-GPU hosts set ",l.jsx("code",{className:"rounded bg-[var(--color-bg)] px-1",children:"TTS_GPU_DEVICE"})," in .env to pick which GPU (default 0)."]})]})]}),l.jsx("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:l.jsxs("label",{className:"flex items-start gap-3 text-sm",children:[l.jsx("input",{type:"checkbox",checked:ne,onChange:W=>ee(W.target.checked),className:"mt-0.5","data-testid":"pin-images-checkbox"}),l.jsxs("span",{children:[l.jsx("span",{className:"font-medium text-[var(--color-text)]",children:"Pin images by digest"}),l.jsxs("span",{className:"mt-1 block text-xs text-[var(--color-text-muted)]",children:["Advanced supply-chain hardening: locks every image to an exact build. Leave OFF for normal use — with pinning on, ",l.jsx("code",{className:"rounded bg-[var(--color-bg)] px-1",children:"docker compose pull"})," will never update anything and services only change via this page."]})]})]})})]}),ie&&o==="options"&&l.jsxs("div",{className:"rounded-lg border border-[var(--color-primary)]/40 bg-[var(--color-surface)] p-4",children:[l.jsxs("h2",{className:"mb-1 flex items-center gap-2 text-sm font-semibold text-[var(--color-text)]",children:[l.jsx(ht,{size:16,className:"text-green-500"}),"Updated files ready"]}),l.jsxs("p",{className:"mb-3 text-xs text-[var(--color-text-muted)]",children:["Your existing secrets and settings are carried over. Download, replace the files next to your compose, then run ",l.jsx("code",{className:"rounded bg-[var(--color-bg)] px-1",children:"docker compose up -d"}),". Nothing on the server was changed."]}),l.jsxs("div",{className:"flex flex-wrap gap-2",children:[l.jsxs("button",{onClick:()=>X("docker-compose.yml",ie.compose),className:"flex items-center gap-2 rounded-lg bg-[var(--color-primary)] px-3 py-2 text-sm font-medium text-white hover:opacity-90",children:[l.jsx(en,{size:15}),"docker-compose.yml"]}),l.jsxs("button",{onClick:()=>X(".env",ie.env),className:"flex items-center gap-2 rounded-lg border border-[var(--color-border)] px-3 py-2 text-sm font-medium text-[var(--color-text)] hover:bg-[var(--color-surface-alt)]",children:[l.jsx(en,{size:15}),".env"]}),l.jsxs("button",{onClick:()=>X("init-db.sh",ie.initDb),className:"flex items-center gap-2 rounded-lg border border-[var(--color-border)] px-3 py-2 text-sm font-medium text-[var(--color-text)] hover:bg-[var(--color-surface-alt)]",children:[l.jsx(en,{size:15}),"init-db.sh"]})]}),l.jsxs("p",{className:"mt-3 text-xs text-[var(--color-text-muted)]",children:["The ",l.jsx("code",{className:"rounded bg-[var(--color-bg)] px-1",children:".env"})," merges new keys into your existing values, and ",l.jsx("code",{className:"rounded bg-[var(--color-bg)] px-1",children:"init-db.sh"})," covers any new databases — replace all three to be safe. Diff them against your current files first if you want to eyeball the changes."]})]}),o!=="loading_options"&&o!=="options"&&l.jsx("div",{className:"space-y-2 rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:Object.entries(Ju).map(([W,j])=>{const D=W===o,G=ve.includes(W),Z=W===o&&o==="error";return l.jsxs("div",{className:"flex items-center gap-2",children:[G?l.jsx(ht,{size:16,className:"text-green-500"}):Z?l.jsx(ra,{size:16,className:"text-red-500"}):D?l.jsx(Ct,{size:16,className:"animate-spin text-[var(--color-primary)]"}):l.jsx("div",{className:"h-4 w-4 rounded-full border border-[var(--color-border)]"}),l.jsx("span",{className:te("text-sm",D?"font-medium text-[var(--color-text)]":"text-[var(--color-text-muted)]",G&&"text-green-500"),children:j})]},W)})}),d.length>0&&l.jsx("div",{ref:g,className:"max-h-64 overflow-y-auto rounded-lg border border-[var(--color-border)] bg-[#0d1117] p-3 font-mono text-xs text-gray-300",children:d.map((W,j)=>l.jsx("div",{children:W.text},j))}),m&&l.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-red-500/10 px-3 py-2",children:[l.jsx(ra,{size:14,className:"text-red-500"}),l.jsx("span",{className:"text-sm text-red-500",children:m})]}),l.jsxs("div",{className:"flex gap-3",children:[o==="options"&&l.jsxs("button",{onClick:ae,className:"flex items-center gap-2 rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm font-medium text-white hover:opacity-90",children:[l.jsx(xd,{size:16}),"Sync now"]}),o==="options"&&l.jsxs("button",{onClick:()=>F(),disabled:oe,title:"Regenerate the compose and download it to apply by hand — doesn't touch the running stack",className:"flex items-center gap-2 rounded-lg border border-[var(--color-border)] px-4 py-2 text-sm font-medium text-[var(--color-text)] hover:bg-[var(--color-surface-alt)] disabled:cursor-not-allowed disabled:opacity-50",children:[oe?l.jsx(Ct,{size:16,className:"animate-spin"}):l.jsx(en,{size:16}),"Download updated compose"]}),o==="options"&&l.jsxs("button",{onClick:()=>F({latest:!0}),disabled:oe,title:"Download a compose pinned to the LATEST published images (digests refreshed from the registry). Apply it yourself on the host — docker compose pull && docker compose up -d — which also updates jarvis-admin.",className:"flex items-center gap-2 rounded-lg border border-[var(--color-border)] px-4 py-2 text-sm font-medium text-[var(--color-text)] hover:bg-[var(--color-surface-alt)] disabled:cursor-not-allowed disabled:opacity-50",children:[oe?l.jsx(Ct,{size:16,className:"animate-spin"}):l.jsx(it,{size:16}),"Update stack to latest"]}),o==="options"&&l.jsxs("button",{onClick:()=>F({mqttAllowAnon:!1}),disabled:oe,title:"Download a compose with the MQTT broker locked (allow_anonymous=false). Do this only after every node has authenticated, or un-migrated nodes will drop off.",className:"flex items-center gap-2 rounded-lg border border-[var(--color-border)] px-4 py-2 text-sm font-medium text-[var(--color-text)] hover:bg-[var(--color-surface-alt)] disabled:cursor-not-allowed disabled:opacity-50",children:[oe?l.jsx(Ct,{size:16,className:"animate-spin"}):l.jsx(vi,{size:16}),"Download + lock broker"]}),o==="options"&&l.jsxs("button",{onClick:()=>F({mqttAllowAnon:!0}),disabled:oe,title:"Download a compose that re-opens the MQTT broker to anonymous clients (allow_anonymous=true) — the transition/rollback state.",className:"flex items-center gap-2 rounded-lg border border-[var(--color-border)] px-4 py-2 text-sm font-medium text-[var(--color-text)] hover:bg-[var(--color-surface-alt)] disabled:cursor-not-allowed disabled:opacity-50",children:[oe?l.jsx(Ct,{size:16,className:"animate-spin"}):l.jsx(pS,{size:16}),"Download + unlock broker"]}),(o==="options"||o==="regenerate"||o==="apply"||o==="done")&&l.jsxs("button",{onClick:()=>a("/dashboard"),disabled:o==="regenerate"||o==="apply",className:"flex items-center gap-2 rounded-lg border border-[var(--color-border)] px-4 py-2 text-sm font-medium text-[var(--color-text)] hover:bg-[var(--color-surface-alt)] disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent",children:[l.jsx(ht,{size:16}),"Back to dashboard"]}),o==="error"&&l.jsxs("button",{onClick:ae,className:"flex items-center gap-2 rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm font-medium text-white hover:opacity-90",children:[l.jsx(it,{size:16}),"Retry"]})]})]})}async function A4(a={}){const{data:s}=await be.get("/api/traces",{params:a});return s}async function O4(a){const{data:s}=await be.get(`/api/traces/${a}`);return s}function Fx(a){return a<1e3?`${Math.round(a)}ms`:`${(a/1e3).toFixed(1)}s`}function Yx(a){return new Date(a).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function z4(a){const s=new Map;for(const o of a){const i=s.get(o.conversation_id);if(!i){s.set(o.conversation_id,{conversation_id:o.conversation_id,traces:[o],newest_at:o.created_at,user_command:o.user_command,assistant_message:o.assistant_message,source:o.source,node_id:o.node_id,household_id:o.household_id,total_duration_ms:o.total_duration_ms,status:o.status});continue}i.traces.push(o),i.total_duration_ms+=o.total_duration_ms,o.created_at>i.newest_at&&(i.newest_at=o.created_at),!i.user_command&&o.user_command&&(i.user_command=o.user_command),!i.assistant_message&&o.assistant_message&&(i.assistant_message=o.assistant_message),o.status!=="ok"&&(i.status=o.status)}return Array.from(s.values()).sort((o,i)=>o.newest_at<i.newest_at?1:-1)}function D4(a){return a==="mobile"?"📱":"🔊"}function U4(){const a=wa(),[s,o]=N.useState(""),[i,d]=N.useState(""),[f,m]=N.useState(""),[v,g]=N.useState(""),[h,y]=N.useState(new Set),x=yt({queryKey:["admin","households"],queryFn:KE,staleTime:6e4}),S=yt({queryKey:["admin","nodes"],queryFn:$E,staleTime:6e4}),{data:R,isLoading:w,error:E}=yt({queryKey:["traces",s,i,f,v],queryFn:()=>A4({limit:100,...s?{status:s}:{},...i?{source:i}:{},...f?{household_id:f}:{},...v?{node_id:v}:{}}),refetchInterval:1e4}),_=N.useMemo(()=>{const H=S.data??[];return f?H.filter(K=>K.household_id===f):H},[S.data,f]),O=N.useMemo(()=>{const H=new Map;for(const K of S.data??[])H.set(K.node_id,K.name);return H},[S.data]),k=N.useMemo(()=>{const H=new Map;for(const K of x.data??[])H.set(K.id,K.name);return H},[x.data]),Y=N.useMemo(()=>R?z4(R.traces):[],[R]);function I(H){y(K=>{const ie=new Set(K);return ie.has(H)?ie.delete(H):ie.add(H),ie})}function ne(H){if(m(H),H&&v){const K=(S.data??[]).find(ie=>ie.node_id===v);K&&K.household_id!==H&&g("")}}const ee="rounded border border-[var(--color-border)] bg-[var(--color-surface)] px-2 py-1 text-sm text-[var(--color-text)]";return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[l.jsx("h1",{className:"text-2xl font-bold text-[var(--color-text)]",children:"Request Traces"}),l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[l.jsxs("select",{className:ee,value:f,onChange:H=>ne(H.target.value),disabled:x.isLoading,children:[l.jsx("option",{value:"",children:"All households"}),(x.data??[]).map(H=>l.jsx("option",{value:H.id,children:H.name},H.id))]}),l.jsxs("select",{className:ee,value:v,onChange:H=>g(H.target.value),disabled:S.isLoading,children:[l.jsx("option",{value:"",children:"All nodes"}),_.map(H=>l.jsx("option",{value:H.node_id,children:H.name},H.node_id))]}),l.jsxs("select",{className:ee,value:s,onChange:H=>o(H.target.value),children:[l.jsx("option",{value:"",children:"All statuses"}),l.jsx("option",{value:"ok",children:"OK"}),l.jsx("option",{value:"error",children:"Error"})]}),l.jsxs("select",{className:ee,value:i,onChange:H=>d(H.target.value),children:[l.jsx("option",{value:"",children:"All sources"}),l.jsx("option",{value:"node",children:"Node"}),l.jsx("option",{value:"mobile",children:"Mobile"})]})]})]}),w&&l.jsx("div",{className:"flex justify-center py-12",children:l.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-[var(--color-primary)] border-t-transparent"})}),E&&l.jsx("div",{className:"rounded-lg border border-red-300 bg-red-50 p-4 text-red-700 dark:border-red-700 dark:bg-red-900/20 dark:text-red-400",children:"Failed to load traces"}),R&&l.jsxs(l.Fragment,{children:[l.jsxs("p",{className:"text-sm text-[var(--color-text-muted)]",children:[R.total," traces in ",Y.length," conversation",Y.length===1?"":"s"]}),l.jsx("div",{className:"overflow-x-auto rounded-lg border border-[var(--color-border)]",children:l.jsxs("table",{className:"w-full text-sm",children:[l.jsx("thead",{children:l.jsxs("tr",{className:"border-b border-[var(--color-border)] bg-[var(--color-surface-alt)]",children:[l.jsx("th",{className:"w-8 px-2 py-2"}),l.jsx("th",{className:"px-3 py-2 text-left font-medium text-[var(--color-text-muted)]",children:"Time"}),l.jsx("th",{className:"px-3 py-2 text-left font-medium text-[var(--color-text-muted)]",children:"Source"}),l.jsx("th",{className:"px-3 py-2 text-left font-medium text-[var(--color-text-muted)]",children:"Node"}),l.jsx("th",{className:"px-3 py-2 text-left font-medium text-[var(--color-text-muted)]",children:"User said"}),l.jsx("th",{className:"px-3 py-2 text-left font-medium text-[var(--color-text-muted)]",children:"Jarvis said"}),l.jsx("th",{className:"px-3 py-2 text-right font-medium text-[var(--color-text-muted)]",children:"Duration"}),l.jsx("th",{className:"px-3 py-2 text-center font-medium text-[var(--color-text-muted)]",children:"Status"}),l.jsx("th",{className:"px-3 py-2 text-right font-medium text-[var(--color-text-muted)]",children:"Traces"})]})}),l.jsxs("tbody",{children:[Y.map(H=>{const K=h.has(H.conversation_id),ie=H.traces.length,re=H.node_id?O.get(H.node_id)??H.node_id.slice(0,8):"-";return l.jsxs(N.Fragment,{children:[l.jsxs("tr",{className:"border-b border-[var(--color-border)] cursor-pointer transition-colors hover:bg-[var(--color-surface-alt)]",onClick:()=>I(H.conversation_id),children:[l.jsx("td",{className:"px-2 py-2 text-center text-[var(--color-text-muted)]",children:ie>1?K?"▼":"▶":""}),l.jsx("td",{className:"px-3 py-2 text-[var(--color-text)] whitespace-nowrap",children:Yx(H.newest_at)}),l.jsx("td",{className:"px-3 py-2 text-[var(--color-text-muted)]",children:l.jsxs("span",{className:"inline-flex items-center gap-1",children:[D4(H.source),H.source]})}),l.jsxs("td",{className:"px-3 py-2 text-[var(--color-text-muted)] whitespace-nowrap",children:[re,H.household_id&&l.jsxs("span",{className:"ml-1 text-xs opacity-60",children:["· ",k.get(H.household_id)??""]})]}),l.jsx("td",{className:"px-3 py-2 text-[var(--color-text)] max-w-xs truncate",children:H.user_command??"-"}),l.jsx("td",{className:"px-3 py-2 text-[var(--color-text-muted)] max-w-xs truncate",children:H.assistant_message??"-"}),l.jsx("td",{className:"px-3 py-2 text-right text-[var(--color-text)] tabular-nums",children:Fx(H.total_duration_ms)}),l.jsx("td",{className:"px-3 py-2 text-center",children:l.jsx("span",{className:`inline-block h-2 w-2 rounded-full ${H.status==="ok"?"bg-green-500":"bg-red-500"}`})}),l.jsx("td",{className:"px-3 py-2 text-right text-[var(--color-text-muted)] tabular-nums",children:ie})]}),K&&H.traces.slice().sort((oe,he)=>oe.created_at<he.created_at?-1:1).map(oe=>l.jsxs("tr",{className:"border-b border-[var(--color-border)] cursor-pointer bg-[var(--color-surface-alt)]/40 transition-colors hover:bg-[var(--color-surface-alt)]",onClick:()=>a(`/traces/${oe.id}`),children:[l.jsx("td",{className:"px-2 py-2"}),l.jsxs("td",{className:"px-3 py-2 text-[var(--color-text-muted)] whitespace-nowrap",children:[l.jsx("span",{className:"inline-block w-3"}),Yx(oe.created_at)]}),l.jsx("td",{className:"px-3 py-2 text-[var(--color-text-muted)] text-xs",children:oe.request_type}),l.jsx("td",{className:"px-3 py-2 text-[var(--color-text-muted)] whitespace-nowrap text-xs",children:oe.node_id?O.get(oe.node_id)??oe.node_id.slice(0,8):"-"}),l.jsx("td",{className:"px-3 py-2 text-[var(--color-text)] max-w-xs truncate",children:oe.user_command??"-"}),l.jsx("td",{className:"px-3 py-2 text-[var(--color-text-muted)] max-w-xs truncate",children:oe.assistant_message??"-"}),l.jsx("td",{className:"px-3 py-2 text-right text-[var(--color-text)] tabular-nums",children:Fx(oe.total_duration_ms)}),l.jsx("td",{className:"px-3 py-2 text-center",children:l.jsx("span",{className:`inline-block h-2 w-2 rounded-full ${oe.status==="ok"?"bg-green-500":"bg-red-500"}`})}),l.jsx("td",{className:"px-3 py-2 text-right text-[var(--color-text-muted)] tabular-nums",children:oe.span_count})]},oe.id))]},H.conversation_id)}),Y.length===0&&l.jsx("tr",{children:l.jsx("td",{colSpan:9,className:"px-3 py-8 text-center text-[var(--color-text-muted)]",children:"No traces yet"})})]})]})})]})]})}function ns(a){return a<1e3?`${Math.round(a)}ms`:`${(a/1e3).toFixed(1)}s`}const Xx={cc:"#9e9e9e",llm_proxy:"#42a5f5",node:"#66bb6a",tts:"#ffa726",whisper:"#ab47bc"},Kx={cc:"Command Center",llm_proxy:"LLM Proxy",node:"Node",tts:"TTS",whisper:"Whisper"};function L4(a){const s=a.filter(d=>d.duration_ms>0),o=s.filter(d=>!s.some(f=>f!==d&&d.start_ms<=f.start_ms&&d.end_ms>=f.end_ms&&f.duration_ms>0));o.sort((d,f)=>d.start_ms-f.start_ms);const i=[];for(const d of o){const f=i[i.length-1];f&&f.service===d.service?(f.duration_ms=Math.round((f.duration_ms+d.duration_ms)*10)/10,f.steps.push(d.name),d.status==="error"&&(f.status="error")):i.push({service:d.service,duration_ms:d.duration_ms,status:d.status,steps:[d.name]})}return i}function B4(){const{id:a}=A0(),s=wa(),[o,i]=N.useState(!1),[d,f]=N.useState(null),{data:m,isLoading:v,error:g}=yt({queryKey:["trace",a],queryFn:()=>O4(a),enabled:!!a}),h=N.useMemo(()=>m?L4(m.spans):[],[m]);return v?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-[var(--color-primary)] border-t-transparent"})}):g||!m?l.jsxs("div",{className:"space-y-4",children:[l.jsx("button",{className:"text-sm text-[var(--color-primary)] hover:underline",onClick:()=>s("/traces"),children:"Back to traces"}),l.jsx("div",{className:"rounded-lg border border-red-300 bg-red-50 p-4 text-red-700 dark:border-red-700 dark:bg-red-900/20 dark:text-red-400",children:"Trace not found"})]}):l.jsxs("div",{className:"space-y-6",children:[l.jsx("button",{className:"text-sm text-[var(--color-primary)] hover:underline",onClick:()=>s("/traces"),children:"Back to traces"}),l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-lg font-bold text-[var(--color-text)]",children:m.user_command??"Request Trace"}),l.jsxs("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:[m.source==="mobile"?"📱 Mobile":"🔊 Node",m.node_id&&` (${m.node_id})`," · ",m.request_type," · ",m.created_at?new Date(m.created_at).toLocaleString():""]})]}),l.jsxs("div",{className:"text-right",children:[l.jsx("div",{className:"text-2xl font-bold tabular-nums text-[var(--color-text)]",children:ns(m.total_duration_ms)}),l.jsxs("div",{className:"flex items-center justify-end gap-1 mt-1",children:[l.jsx("span",{className:`inline-block h-2 w-2 rounded-full ${m.status==="ok"?"bg-green-500":"bg-red-500"}`}),l.jsx("span",{className:"text-sm text-[var(--color-text-muted)]",children:m.status})]})]})]}),m.error_message&&l.jsx("div",{className:"mt-3 rounded border border-red-300 bg-red-50 p-2 text-sm text-red-700 dark:border-red-700 dark:bg-red-900/20 dark:text-red-400",children:m.error_message}),l.jsx("p",{className:"mt-2 text-xs text-[var(--color-text-muted)] font-mono",children:m.conversation_id})]}),l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsx("h2",{className:"mb-3 text-sm font-medium text-[var(--color-text-muted)]",children:"Service Flow"}),l.jsx("p",{className:"mb-4 text-xs text-[var(--color-text-muted)] opacity-60",children:h.map(y=>Kx[y.service]??y.service).join(" → ")}),l.jsx("div",{className:"space-y-2",children:h.map((y,x)=>{const S=Math.min(y.duration_ms/m.total_duration_ms*100,100),R=y.status==="error"?"#ef4444":Xx[y.service]??"#9e9e9e",w=Kx[y.service]??y.service;return l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:R}}),l.jsx("span",{className:"w-32 text-sm text-[var(--color-text)] shrink-0",children:w}),l.jsxs("div",{className:"flex-1 h-6 rounded bg-[var(--color-surface-alt)] relative",children:[l.jsx("div",{className:"absolute top-0 left-0 h-full rounded",style:{width:`${Math.max(S,1)}%`,backgroundColor:R,opacity:.7}}),l.jsx("span",{className:"absolute inset-0 flex items-center px-2 text-xs text-[var(--color-text)] opacity-70",children:y.steps.join(", ")})]}),l.jsx("span",{className:"w-16 text-sm text-[var(--color-text)] text-right tabular-nums shrink-0",children:ns(y.duration_ms)})]},`${y.service}-${x}`)})})]}),l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsxs("button",{className:"text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text)]",onClick:()=>{i(y=>!y),f(null)},children:[o?"Hide":"Show"," raw spans (",m.spans.length,")"]}),o&&l.jsx("div",{className:"mt-3 space-y-1",children:m.spans.map((y,x)=>{const S=Math.min(y.duration_ms/m.total_duration_ms*100,100),R=y.start_ms/m.total_duration_ms*100,w=y.status==="error"?"#ef4444":Xx[y.service]??"#9e9e9e",E=d===y;return l.jsxs("div",{className:`flex items-center gap-2 cursor-pointer rounded px-1 py-0.5 ${E?"bg-[var(--color-surface-alt)]":""}`,onClick:()=>f(E?null:y),children:[l.jsx("span",{className:"w-36 truncate text-xs text-[var(--color-text-muted)] text-right shrink-0",children:y.name}),l.jsx("div",{className:"flex-1 relative h-4 rounded bg-[var(--color-surface-alt)]",children:l.jsx("div",{className:"absolute top-0 h-full rounded",style:{left:`${R}%`,width:`${Math.max(S,.5)}%`,backgroundColor:w,minWidth:"2px"}})}),l.jsx("span",{className:"w-14 text-xs text-[var(--color-text-muted)] text-right shrink-0 tabular-nums",children:ns(y.duration_ms)}),l.jsx("span",{className:"w-16 text-xs text-[var(--color-text-muted)] opacity-60 shrink-0",children:y.service})]},`${y.name}-${x}`)})}),d&&o&&l.jsx("div",{className:"mt-3 border-t border-[var(--color-border)] pt-3",children:l.jsxs("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-sm max-w-md",children:[l.jsx("dt",{className:"text-[var(--color-text-muted)]",children:"Service"}),l.jsx("dd",{className:"text-[var(--color-text)]",children:d.service}),l.jsx("dt",{className:"text-[var(--color-text-muted)]",children:"Duration"}),l.jsx("dd",{className:"text-[var(--color-text)] tabular-nums",children:ns(d.duration_ms)}),l.jsx("dt",{className:"text-[var(--color-text-muted)]",children:"Start"}),l.jsx("dd",{className:"text-[var(--color-text)] tabular-nums",children:ns(d.start_ms)}),l.jsx("dt",{className:"text-[var(--color-text-muted)]",children:"End"}),l.jsx("dd",{className:"text-[var(--color-text)] tabular-nums",children:ns(d.end_ms)}),l.jsx("dt",{className:"text-[var(--color-text-muted)]",children:"Status"}),l.jsx("dd",{className:d.status==="ok"?"text-green-600":"text-red-600",children:d.status}),Object.entries(d.metadata||{}).map(([y,x])=>l.jsxs("div",{className:"contents",children:[l.jsx("dt",{className:"text-[var(--color-text-muted)]",children:y}),l.jsx("dd",{className:"text-[var(--color-text)] tabular-nums",children:String(x)})]},y))]})})]})]})}function q4(){return l.jsxs("div",{className:"flex min-h-[60vh] flex-col items-center justify-center",children:[l.jsx("h1",{className:"mb-2 text-4xl font-bold text-[var(--color-text)]",children:"404"}),l.jsx("p",{className:"mb-4 text-[var(--color-text-muted)]",children:"Page not found"}),l.jsx(Cd,{to:"/settings",className:"text-[var(--color-primary)] underline hover:opacity-80",children:"Go to Settings"})]})}const H4=7,G4={currentStep:0,totalSteps:H4,enabledModules:[],portOverrides:{},infraPortOverrides:{},secrets:{},dbUser:"jarvis",whisperModel:"base.en",whisperModelPath:"/whisper-models/ggml-base.en.bin",llmInterface:"Qwen25MediumUntrained",deploymentMode:"local",deploymentTarget:"standard",remoteLlmUrl:"",remoteWhisperUrl:"",platform:"linux",hardware:null,relayEnabled:!1,installRunning:!1,installComplete:!1,nativeServices:[]};function Q4(a,s,o){return Math.max(s,Math.min(o,a))}function V4(a,s){switch(s.type){case"SET_STEP":return{...a,currentStep:Q4(s.step,0,a.totalSteps-1)};case"NEXT_STEP":return{...a,currentStep:Math.min(a.currentStep+1,a.totalSteps-1)};case"PREV_STEP":return{...a,currentStep:Math.max(a.currentStep-1,0)};case"SET_ENABLED_MODULES":return{...a,enabledModules:s.modules};case"TOGGLE_MODULE":{if(s.enabled){const o=a.enabledModules.includes(s.serviceId)?a.enabledModules:[...a.enabledModules,s.serviceId];return{...a,enabledModules:o}}return{...a,enabledModules:a.enabledModules.filter(o=>o!==s.serviceId)}}case"SET_PORT_OVERRIDE":return{...a,portOverrides:{...a.portOverrides,[s.serviceId]:s.port}};case"SET_INFRA_PORT_OVERRIDE":return{...a,infraPortOverrides:{...a.infraPortOverrides,[s.infraId]:s.port}};case"SET_SECRET":return{...a,secrets:{...a.secrets,[s.name]:s.value}};case"SET_SECRETS":return{...a,secrets:s.secrets};case"SET_DB_USER":return{...a,dbUser:s.user};case"SET_WHISPER_MODEL":return{...a,whisperModel:s.model};case"SET_WHISPER_BACKEND":return{...a,whisperBackend:s.backend};case"SET_LLM_INTERFACE":return{...a,llmInterface:s.interfaceId};case"SET_DEPLOYMENT_MODE":return{...a,deploymentMode:s.mode};case"SET_DEPLOYMENT_TARGET":return{...a,deploymentTarget:s.target};case"SET_REMOTE_LLM_URL":return{...a,remoteLlmUrl:s.url};case"SET_REMOTE_WHISPER_URL":return{...a,remoteWhisperUrl:s.url};case"SET_PLATFORM":return{...a,platform:s.platform};case"SET_HARDWARE":return{...a,hardware:s.hardware,platform:s.hardware.platform};case"SET_RELAY_ENABLED":return{...a,relayEnabled:s.enabled};case"SET_INSTALL_RUNNING":return{...a,installRunning:s.running};case"SET_INSTALL_COMPLETE":return{...a,installRunning:!1,installComplete:!0};case"SET_NATIVE_SERVICES":return{...a,nativeServices:s.services};case"TOGGLE_NATIVE_SERVICE":{if(s.enabled){const o=a.nativeServices.includes(s.serviceId)?a.nativeServices:[...a.nativeServices,s.serviceId];return{...a,nativeServices:o}}return{...a,nativeServices:a.nativeServices.filter(o=>o!==s.serviceId)}}default:return a}}const Tg=N.createContext(null);function F4({children:a}){const[s,o]=N.useReducer(V4,G4);return l.jsx(Tg.Provider,{value:{state:s,dispatch:o},children:a})}function fr(){const a=N.useContext(Tg);if(!a)throw new Error("useWizard must be used within a WizardProvider");return a}function Y4(){const{state:a,dispatch:s}=fr(),[o,i]=N.useState(null),[d,f]=N.useState(!0),[m,v]=N.useState(!1);function g(){f(!0),v(!1),Yd().then(y=>{i(y);const x=y.reason==="docker_not_found";v(x),s(x?{type:"SET_INSTALL_RUNNING",running:!0}:{type:"SET_INSTALL_RUNNING",running:!1})}).catch(()=>{i({configured:!1,reason:"error"}),v(!0),s({type:"SET_INSTALL_RUNNING",running:!0})}).finally(()=>f(!1))}N.useEffect(()=>{g()},[]);const h=o&&o.reason!=="docker_not_found";return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Welcome to Jarvis"}),l.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Let's get your personal voice assistant up and running. This wizard will guide you through selecting services, configuring hardware, and starting everything up."})]}),l.jsx("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:l.jsxs("div",{className:"flex items-center gap-3",children:[d?l.jsx(Ct,{size:20,className:"animate-spin text-[var(--color-primary)]"}):h?l.jsx(ht,{size:20,className:"text-green-500"}):l.jsx(Bd,{size:20,className:"text-red-500"}),l.jsxs("div",{className:"flex-1",children:[l.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:d?"Checking Docker...":h?"Docker is running":"Docker not found"}),!d&&!h&&l.jsxs("div",{className:"mt-1 space-y-1",children:[l.jsx("p",{className:"text-xs text-red-400",children:"Docker is required to run Jarvis services."}),l.jsxs("p",{className:"text-xs text-[var(--color-text-muted)]",children:["Install"," ",l.jsx("a",{href:"https://www.docker.com/products/docker-desktop/",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--color-primary)] underline hover:no-underline",children:"Docker Desktop"})," ","for your platform, start it, then click Retry."]})]})]}),m&&!d&&l.jsxs("button",{type:"button",onClick:g,className:"flex items-center gap-1 rounded-md border border-[var(--color-border)] px-2 py-1 text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:[l.jsx(gi,{size:12}),"Retry"]})]})}),l.jsxs("div",{children:[l.jsx("label",{className:"mb-2 block text-sm font-medium text-[var(--color-text)]",children:"Deployment Mode"}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("button",{type:"button",onClick:()=>s({type:"SET_DEPLOYMENT_MODE",mode:"local"}),className:te("flex flex-col items-center gap-2 rounded-lg border p-4 transition-colors",a.deploymentMode==="local"?"border-[var(--color-primary)] bg-[var(--color-primary)]/10":"border-[var(--color-border)] hover:border-[var(--color-primary)]/50"),children:[l.jsx(NS,{size:24,className:"text-[var(--color-primary)]"}),l.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:"Local"}),l.jsx("span",{className:"text-xs text-center text-[var(--color-text-muted)]",children:"Everything on this machine"})]}),l.jsxs("button",{type:"button",onClick:()=>s({type:"SET_DEPLOYMENT_MODE",mode:"remote-llm"}),className:te("flex flex-col items-center gap-2 rounded-lg border p-4 transition-colors",a.deploymentMode==="remote-llm"?"border-[var(--color-primary)] bg-[var(--color-primary)]/10":"border-[var(--color-border)] hover:border-[var(--color-primary)]/50"),children:[l.jsx(Qd,{size:24,className:"text-[var(--color-primary)]"}),l.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:"Remote LLM"}),l.jsx("span",{className:"text-xs text-center text-[var(--color-text-muted)]",children:"LLM on separate GPU machine"})]})]})]})]})}const $o=[{label:"None / CPU only",gpu:null,gpuType:"none",vramMb:null,backends:["gguf"],defaultBackend:"gguf"},{label:"NVIDIA RTX 4090 (24 GB)",gpu:"NVIDIA RTX 4090",gpuType:"nvidia",vramMb:24576,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"NVIDIA RTX 4080 (16 GB)",gpu:"NVIDIA RTX 4080",gpuType:"nvidia",vramMb:16384,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"NVIDIA RTX 4070 Ti (12 GB)",gpu:"NVIDIA RTX 4070 Ti",gpuType:"nvidia",vramMb:12288,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"NVIDIA RTX 3090 (24 GB)",gpu:"NVIDIA RTX 3090",gpuType:"nvidia",vramMb:24576,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"NVIDIA RTX 3080 (10 GB)",gpu:"NVIDIA RTX 3080",gpuType:"nvidia",vramMb:10240,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"NVIDIA RTX 3070 (8 GB)",gpu:"NVIDIA RTX 3070",gpuType:"nvidia",vramMb:8192,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"NVIDIA A100 (80 GB)",gpu:"NVIDIA A100",gpuType:"nvidia",vramMb:81920,backends:["gguf","vllm"],defaultBackend:"vllm"},{label:"NVIDIA A100 (40 GB)",gpu:"NVIDIA A100",gpuType:"nvidia",vramMb:40960,backends:["gguf","vllm"],defaultBackend:"vllm"},{label:"NVIDIA Tesla T4 (16 GB)",gpu:"NVIDIA Tesla T4",gpuType:"nvidia",vramMb:16384,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"AMD RX 9070 XT — Vulkan (16 GB)",gpu:"AMD RX 9070 XT",gpuType:"amd",vramMb:16384,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 9070 — Vulkan (12 GB)",gpu:"AMD RX 9070",gpuType:"amd",vramMb:12288,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7900 XTX — Vulkan (24 GB)",gpu:"AMD RX 7900 XTX",gpuType:"amd",vramMb:24576,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7900 XT — Vulkan (20 GB)",gpu:"AMD RX 7900 XT",gpuType:"amd",vramMb:20480,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7800 XT — Vulkan (16 GB)",gpu:"AMD RX 7800 XT",gpuType:"amd",vramMb:16384,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7600 — Vulkan (8 GB)",gpu:"AMD RX 7600",gpuType:"amd",vramMb:8192,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 9070 XT — ROCm (16 GB)",gpu:"AMD RX 9070 XT",gpuType:"amd-rocm",vramMb:16384,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 9070 — ROCm (12 GB)",gpu:"AMD RX 9070",gpuType:"amd-rocm",vramMb:12288,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7900 XTX — ROCm (24 GB)",gpu:"AMD RX 7900 XTX",gpuType:"amd-rocm",vramMb:24576,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7900 XT — ROCm (20 GB)",gpu:"AMD RX 7900 XT",gpuType:"amd-rocm",vramMb:20480,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7800 XT — ROCm (16 GB)",gpu:"AMD RX 7800 XT",gpuType:"amd-rocm",vramMb:16384,backends:["gguf"],defaultBackend:"gguf"},{label:"Apple M4 Max (128 GB unified)",gpu:"Apple M4 Max",gpuType:"apple",vramMb:131072,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M4 Max (64 GB unified)",gpu:"Apple M4 Max",gpuType:"apple",vramMb:65536,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M4 Pro (48 GB unified)",gpu:"Apple M4 Pro",gpuType:"apple",vramMb:49152,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M4 Pro (24 GB unified)",gpu:"Apple M4 Pro",gpuType:"apple",vramMb:24576,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M2 Max (32 GB unified)",gpu:"Apple M2 Max",gpuType:"apple",vramMb:32768,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M2 Pro (16 GB unified)",gpu:"Apple M2 Pro",gpuType:"apple",vramMb:16384,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M1 (16 GB unified)",gpu:"Apple M1",gpuType:"apple",vramMb:16384,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M1 (8 GB unified)",gpu:"Apple M1",gpuType:"apple",vramMb:8192,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Other (enter VRAM manually)",gpu:"Other",gpuType:"none",vramMb:null,backends:["gguf"],defaultBackend:"gguf"}];function X4(){const{state:a,dispatch:s}=fr(),[o,i]=N.useState(!a.hardware),[d,f]=N.useState(!1),[m,v]=N.useState(0),[g,h]=N.useState("");N.useEffect(()=>{a.hardware||AE().then(S=>{s({type:"SET_HARDWARE",hardware:S}),S.recommendedBackend==="remote"&&a.deploymentMode==="local"&&s({type:"SET_DEPLOYMENT_MODE",mode:"remote-llm"})}).catch(()=>{}).finally(()=>i(!1))},[]);function y(S,R){const w=$o[S];if(!a.hardware)return;const E=w.gpu==="Other"?(parseInt(R??g,10)||0)*1024:w.vramMb,_={...a.hardware,gpuName:w.gpu,gpuVramMb:E||null,gpuType:w.gpuType,recommendedBackends:[...w.backends],recommendedBackend:w.defaultBackend};s({type:"SET_HARDWARE",hardware:_})}const x=a.hardware;return o?l.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[l.jsx(Ct,{size:32,className:"animate-spin text-[var(--color-primary)]"}),l.jsx("p",{className:"mt-3 text-sm text-[var(--color-text-muted)]",children:"Detecting hardware..."})]}):l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Hardware Detection"}),l.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"We detected the following hardware. This determines which LLM backend to use."})]}),x&&l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:[l.jsxs("div",{className:"flex items-center gap-2 text-[var(--color-text-muted)]",children:[l.jsx(On,{size:16}),l.jsx("span",{className:"text-xs font-medium uppercase",children:"Platform"})]}),l.jsxs("p",{className:"mt-1 text-sm font-medium text-[var(--color-text)]",children:[x.platform==="darwin"?"macOS":"Linux"," (",x.arch,")"]})]}),l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:[l.jsxs("div",{className:"flex items-center gap-2 text-[var(--color-text-muted)]",children:[l.jsx(Hd,{size:16}),l.jsx("span",{className:"text-xs font-medium uppercase",children:"Memory"})]}),l.jsxs("p",{className:"mt-1 text-sm font-medium text-[var(--color-text)]",children:[x.totalMemoryGb," GB RAM"]})]}),l.jsxs("div",{className:"col-span-2 rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2 text-[var(--color-text-muted)]",children:[l.jsx(On,{size:16}),l.jsx("span",{className:"text-xs font-medium uppercase",children:"GPU"})]}),l.jsx("p",{className:"mt-1 text-sm font-medium text-[var(--color-text)]",children:x.gpuName??"No GPU detected"}),x.gpuVramMb!=null&&x.gpuVramMb>0&&l.jsxs("p",{className:"text-xs text-[var(--color-text-muted)]",children:[Math.round(x.gpuVramMb/1024)," GB VRAM"]})]}),l.jsx("button",{type:"button",onClick:()=>f(!d),className:"text-xs font-medium text-[var(--color-primary)] hover:underline",children:d?"Cancel":"Override"})]}),d&&l.jsxs("div",{className:"mt-3 space-y-3 border-t border-[var(--color-border)] pt-3",children:[l.jsxs("div",{children:[l.jsx("label",{htmlFor:"gpu-select",className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Select GPU"}),l.jsx("select",{id:"gpu-select",value:m,onChange:S=>{const R=parseInt(S.target.value,10);v(R),$o[R].gpu!=="Other"&&(y(R),f(!1))},className:te("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]"),children:$o.map((S,R)=>l.jsx("option",{value:R,children:S.label},`${S.label}-${R}`))})]}),$o[m].gpu==="Other"&&l.jsxs("div",{className:"flex items-end gap-2",children:[l.jsxs("div",{className:"flex-1",children:[l.jsx("label",{htmlFor:"custom-vram",className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"VRAM (GB)"}),l.jsx("input",{id:"custom-vram",type:"number",min:1,max:512,value:g,onChange:S=>h(S.target.value),placeholder:"e.g. 24",className:te("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]")})]}),l.jsx("button",{type:"button",disabled:!g||parseInt(g,10)<=0,onClick:()=>{y(m,g),f(!1)},className:te("rounded-lg px-4 py-2 text-sm font-medium","bg-[var(--color-primary)] text-white","disabled:cursor-not-allowed disabled:opacity-50"),children:"Apply"})]})]})]}),l.jsxs("div",{className:"col-span-2 rounded-lg border border-[var(--color-primary)]/30 bg-[var(--color-primary)]/5 p-4",children:[l.jsxs("p",{className:"text-sm font-medium text-[var(--color-text)]",children:["Recommended: ",l.jsx("span",{className:"text-[var(--color-primary)]",children:x.recommendedBackend.toUpperCase()})]}),x.recommendedBackends.length>1&&l.jsxs("p",{className:"mt-0.5 text-xs text-[var(--color-text-muted)]",children:["Available backends: ",x.recommendedBackends.join(", ")]})]})]}),a.deploymentMode==="remote-llm"&&l.jsxs("div",{className:"space-y-3",children:[l.jsx("h3",{className:"text-sm font-medium text-[var(--color-text)]",children:"Remote Service URLs"}),l.jsxs("div",{children:[l.jsx("label",{htmlFor:"remote-llm",className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"LLM Proxy URL"}),l.jsx("input",{id:"remote-llm",type:"url",value:a.remoteLlmUrl,onChange:S=>s({type:"SET_REMOTE_LLM_URL",url:S.target.value}),placeholder:"http://192.168.1.100:7704",className:te("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]")})]}),l.jsxs("div",{children:[l.jsx("label",{htmlFor:"remote-whisper",className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Whisper URL (optional)"}),l.jsx("input",{id:"remote-whisper",type:"url",value:a.remoteWhisperUrl,onChange:S=>s({type:"SET_REMOTE_WHISPER_URL",url:S.target.value}),placeholder:"http://192.168.1.100:7706",className:te("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]")})]})]})]})}function K4(){const{state:a,dispatch:s}=fr(),[o,i]=N.useState(null),[d,f]=N.useState(!0);if(N.useEffect(()=>{Promise.all([jg(),OE()]).then(([h,y])=>{if(i(h),a.enabledModules.length===0&&s({type:"SET_ENABLED_MODULES",modules:y.enabledModules}),a.platform==="darwin"&&a.nativeServices.length===0){const x=h.services.filter(S=>S.nativeCapable).map(S=>S.id);x.length>0&&s({type:"SET_NATIVE_SERVICES",services:x})}}).catch(()=>{}).finally(()=>f(!1))},[]),d||!o)return l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx(Ct,{size:32,className:"animate-spin text-[var(--color-primary)]"})});const{core:m,recommended:v,optional:g}=$4(o.services);return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Select Services"}),l.jsxs("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:["Core services are always included. Toggle recommended and optional services.",a.platform==="darwin"&&l.jsxs(l.Fragment,{children:[" Services marked ",l.jsx("em",{children:"Native"})," can run as macOS LaunchAgents to use the Apple GPU."]})]})]}),l.jsx(Pu,{title:"Core",subtitle:"Always included",services:m,enabled:m.map(h=>h.id),nativeServices:a.nativeServices,platform:a.platform,locked:!0}),l.jsx(Pu,{title:"Recommended",subtitle:"Enabled by default",services:v,enabled:a.enabledModules,nativeServices:a.nativeServices,platform:a.platform,onToggle:(h,y)=>s({type:"TOGGLE_MODULE",serviceId:h,enabled:y}),onToggleNative:(h,y)=>s({type:"TOGGLE_NATIVE_SERVICE",serviceId:h,enabled:y})}),g.length>0&&l.jsx(Pu,{title:"Optional",subtitle:"Off by default",services:g,enabled:a.enabledModules,nativeServices:a.nativeServices,platform:a.platform,onToggle:(h,y)=>s({type:"TOGGLE_MODULE",serviceId:h,enabled:y}),onToggleNative:(h,y)=>s({type:"TOGGLE_NATIVE_SERVICE",serviceId:h,enabled:y})}),l.jsxs("div",{children:[l.jsxs("div",{className:"mb-2 flex items-baseline gap-2",children:[l.jsx("h3",{className:"text-sm font-medium text-[var(--color-text)]",children:"Integrations"}),l.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:"Cloud services"})]}),l.jsxs("button",{type:"button",onClick:()=>s({type:"SET_RELAY_ENABLED",enabled:!a.relayEnabled}),className:te("flex w-full items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",a.relayEnabled?"border-[var(--color-primary)]/30 bg-[var(--color-primary)]/5":"border-[var(--color-border)] hover:border-[var(--color-primary)]/30"),children:[a.relayEnabled?l.jsx(ht,{size:16,className:"shrink-0 text-[var(--color-primary)]"}):l.jsx(os,{size:16,className:"shrink-0 text-[var(--color-text-muted)]"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:"Jarvis Relay"}),l.jsx(nS,{size:12,className:"text-[var(--color-text-muted)]"})]}),l.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:"Routes OAuth callbacks through a cloud relay for external providers (Google, Spotify, etc.)"})]})]})]})]})}function $4(a){return{core:a.filter(s=>s.category==="core"),recommended:a.filter(s=>s.category==="recommended"),optional:a.filter(s=>s.category==="optional")}}function Pu({title:a,subtitle:s,services:o,enabled:i,nativeServices:d,locked:f,onToggle:m,onToggleNative:v,platform:g}){return l.jsxs("div",{children:[l.jsxs("div",{className:"mb-2 flex items-baseline gap-2",children:[l.jsx("h3",{className:"text-sm font-medium text-[var(--color-text)]",children:a}),l.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:s})]}),l.jsx("div",{className:"space-y-1",children:o.map(h=>{const y=i.includes(h.id),x=h.nativeCapable&&g==="darwin"&&y,S=d.includes(h.id);return l.jsxs("div",{className:te("rounded-lg border transition-colors",y?"border-[var(--color-primary)]/30 bg-[var(--color-primary)]/5":"border-[var(--color-border)]",!f&&!y&&"hover:border-[var(--color-primary)]/30"),children:[l.jsxs("button",{type:"button",disabled:f,onClick:()=>m?.(h.id,!y),className:te("flex w-full items-center gap-3 px-3 py-2.5 text-left",f&&"cursor-default"),children:[f?l.jsx(vi,{size:16,className:"shrink-0 text-[var(--color-text-muted)]"}):y?l.jsx(ht,{size:16,className:"shrink-0 text-[var(--color-primary)]"}):l.jsx(os,{size:16,className:"shrink-0 text-[var(--color-text-muted)]"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:h.name}),l.jsxs("span",{className:"text-xs text-[var(--color-text-muted)]",children:[":",h.port]}),h.nativeCapable&&g==="darwin"&&l.jsx("span",{className:"rounded bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-medium text-amber-500",children:"Native"})]}),l.jsx("p",{className:"truncate text-xs text-[var(--color-text-muted)]",children:h.description})]})]}),x&&l.jsxs("button",{type:"button",onClick:()=>v?.(h.id,!S),className:te("flex w-full items-center gap-2 border-t border-[var(--color-border)]/50 px-3 py-2 text-left text-xs","hover:bg-[var(--color-surface-alt)] transition-colors"),children:[l.jsx(On,{size:12,className:S?"text-amber-500":"text-[var(--color-text-muted)]"}),l.jsx("span",{className:S?"text-[var(--color-text)]":"text-[var(--color-text-muted)]",children:"Run natively via LaunchAgent"}),l.jsx("span",{className:"ml-auto text-[var(--color-text-muted)]",children:S?"On (uses Apple GPU)":"Off (runs in Docker)"})]})]},h.id)})})]})}function Z4(){const{state:a}=fr(),[s,o]=N.useState(null);if(N.useEffect(()=>{jg().then(o).catch(()=>{})},[]),!s)return l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx(Ct,{size:32,className:"animate-spin text-[var(--color-primary)]"})});const i=s.services.filter(x=>x.category==="core"),d=s.services.filter(x=>x.category!=="core"&&a.enabledModules.includes(x.id)),f=[...i,...d],m=new Map;for(const x of f){const S=a.portOverrides[x.id]??x.port,R=m.get(S)??[];m.set(S,[...R,x.name])}const v=[...m.entries()].filter(([,x])=>x.length>1),g=f.filter(x=>x.database).length,h=f.filter(x=>a.nativeServices.includes(x.id)),y=f.filter(x=>!a.nativeServices.includes(x.id));return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Review Configuration"}),l.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Review your selections before installing."})]}),l.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[l.jsx(Iu,{label:"Docker Services",value:y.length}),l.jsx(Iu,{label:"Native Services",value:h.length}),l.jsx(Iu,{label:"Databases",value:g})]}),l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:[l.jsx("p",{className:"text-xs font-medium uppercase text-[var(--color-text-muted)]",children:"Deployment Mode"}),l.jsx("p",{className:"mt-1 text-sm font-medium text-[var(--color-text)]",children:a.deploymentMode==="local"?"Local (all services on this machine)":"Remote LLM"}),a.deploymentMode==="remote-llm"&&a.remoteLlmUrl&&l.jsxs("p",{className:"mt-0.5 text-xs text-[var(--color-text-muted)]",children:["LLM: ",a.remoteLlmUrl]})]}),l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] overflow-hidden",children:[l.jsx("div",{className:"border-b border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2",children:l.jsxs("span",{className:"text-xs font-medium text-[var(--color-text-muted)]",children:["Services (",f.length,")"]})}),l.jsx("div",{className:"divide-y divide-[var(--color-border)]",children:f.map(x=>l.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(ht,{size:14,className:"text-green-500"}),l.jsx("span",{className:"text-sm text-[var(--color-text)]",children:x.name})]}),l.jsxs("span",{className:"text-xs text-[var(--color-text-muted)]",children:[":",a.portOverrides[x.id]??x.port]})]},x.id))})]}),a.relayEnabled&&l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:[l.jsx("p",{className:"text-xs font-medium uppercase text-[var(--color-text-muted)]",children:"Jarvis Relay"}),l.jsx("p",{className:"mt-1 text-sm font-medium text-[var(--color-text)]",children:"Enabled"}),l.jsx("p",{className:"mt-0.5 text-xs text-[var(--color-text-muted)]",children:"https://relay.jarvisautomation.io"})]}),v.length>0&&l.jsxs("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-4",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(ra,{size:16,className:"text-amber-500"}),l.jsx("span",{className:"text-sm font-medium text-amber-500",children:"Port Conflicts"})]}),v.map(([x,S])=>l.jsxs("p",{className:"mt-1 text-xs text-[var(--color-text-muted)]",children:["Port ",x,": ",S.join(", ")]},x))]})]})}function Iu({label:a,value:s}){return l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-3 text-center",children:[l.jsx("p",{className:"text-2xl font-bold text-[var(--color-primary)]",children:s}),l.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:a})]})}function Wu(){const[a,s]=N.useState({lines:[],running:!1,done:!1,exitCode:null,error:null,redirect:null}),o=N.useRef(null),i=N.useCallback((f,m)=>(o.current?.close(),s({lines:[],running:!0,done:!1,exitCode:null,error:null,redirect:null}),new Promise((v,g)=>{const h=new EventSource(f);o.current=h,h.onmessage=y=>{try{const x=JSON.parse(y.data);if(m&&m(x),"done"in x){if(s(S=>({...S,running:!1,done:!0,exitCode:x.code,redirect:x.redirect??null})),h.close(),x.code===0)v(x.code);else{const S=x.error?String(x.error):`Process exited with code ${x.code}`;g(new Error(S))}return}if("stream"in x&&"text"in x){const S={stream:x.stream,text:x.text,timestamp:Date.now()};s(R=>({...R,lines:[...R.lines,S]}))}}catch{}},h.onerror=()=>{const y=o.current===null;s(x=>({...x,running:!1,error:x.done?null:"Connection lost"})),h.close(),y||g(new Error("Connection lost"))}})),[]),d=N.useCallback(()=>{o.current?.close(),o.current=null,s(f=>({...f,running:!1}))},[]);return{...a,run:i,stop:d}}function ed({lines:a,running:s,title:o,className:i}){const d=N.useRef(null),f=N.useRef(!0);N.useEffect(()=>{const v=d.current;!v||!f.current||(v.scrollTop=v.scrollHeight)},[a]);function m(){const v=d.current;if(!v)return;const g=v.scrollHeight-v.scrollTop-v.clientHeight;f.current=g<50}return l.jsxs("div",{className:te("flex flex-col rounded-lg border border-[var(--color-border)] overflow-hidden",i),children:[o&&l.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--color-border)] bg-[var(--color-surface)] px-3 py-2",children:[l.jsx("span",{className:"text-xs font-medium text-[var(--color-text-muted)]",children:o}),s&&l.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-green-500"})]}),l.jsxs("div",{ref:d,onScroll:m,className:"h-64 overflow-y-auto bg-[#0d1117] p-3 font-mono text-xs leading-5",children:[a.length===0&&!s&&l.jsx("span",{className:"text-gray-500",children:"Waiting for output..."}),a.map((v,g)=>l.jsx("div",{className:te("whitespace-pre-wrap break-all",v.stream==="stderr"?"text-yellow-400":"text-gray-300"),children:v.text},g)),s&&l.jsx("span",{className:"inline-block h-4 w-1.5 animate-pulse bg-gray-400"})]})]})}function J4(){const{state:a,dispatch:s}=fr(),o=Wu(),i=Wu(),d=Wu(),[f,m]=N.useState("idle"),[v,g]=N.useState(null),[h,y]=N.useState(null),[x,S]=N.useState({}),[R,w]=N.useState({}),[E,_]=N.useState(null),[O,k]=N.useState(null),[Y,I]=N.useState(null),[ne,ee]=N.useState({});N.useEffect(()=>{const ae=i.redirect;if(f!=="done"||!ae)return;k(5);const C=setInterval(()=>{k(F=>F===null||F<=1?(clearInterval(C),window.location.href=ae,0):F-1)},1e3);return()=>clearInterval(C)},[f,i.redirect]);const H=N.useCallback(async()=>{m("preflight"),y(null),g(null);try{const ae=await ME(a.enabledModules);return y(ae),ae.canProceed?!0:(g("Pre-flight checks failed. Fix the issues above and retry."),m("error"),_("preflight"),!1)}catch(ae){return g(`Pre-flight check failed: ${ae instanceof Error?ae.message:String(ae)}`),m("error"),_("preflight"),!1}},[a.enabledModules]);async function K(){if(a.nativeServices.length!==0){m("native");for(const ae of a.nativeServices){I(ae);try{await d.run(`/api/native-services/${ae}/install`),ee(C=>({...C,[ae]:{ok:!0}}))}catch(C){const F=C instanceof Error?C.message:String(C);ee(X=>({...X,[ae]:{ok:!1,error:F}}))}}I(null)}}async function ie(){g(null),S({}),_(null),ee({}),s({type:"SET_INSTALL_RUNNING",running:!0});try{if(!await H()){s({type:"SET_INSTALL_RUNNING",running:!1});return}m("generating"),await Bx(a),m("pulling"),await o.run("/api/install/pull"),m("starting"),await i.run("/api/install/start",C=>{if(C.phase==="health"&&typeof C.service=="string"&&S(F=>({...F,[C.service]:{healthy:C.healthy,error:C.error}})),C.serviceHealth&&typeof C.serviceHealth=="object"){const F=C.serviceHealth;S(X=>({...X,...F}))}}),await K(),m("done"),s({type:"SET_INSTALL_COMPLETE"})}catch(ae){g(ae instanceof Error?ae.message:String(ae)),m("error"),_(f),s({type:"SET_INSTALL_RUNNING",running:!1})}}async function re(){if(E==="preflight"){if(g(null),s({type:"SET_INSTALL_RUNNING",running:!0}),!await H()){s({type:"SET_INSTALL_RUNNING",running:!1});return}try{m("generating"),await Bx(a),m("pulling"),await o.run("/api/install/pull"),m("starting"),await i.run("/api/install/start",C=>{if(C.phase==="health"&&typeof C.service=="string"&&S(F=>({...F,[C.service]:{healthy:C.healthy,error:C.error}})),C.serviceHealth&&typeof C.serviceHealth=="object"){const F=C.serviceHealth;S(X=>({...X,...F}))}}),await K(),m("done"),s({type:"SET_INSTALL_COMPLETE"})}catch(C){g(C instanceof Error?C.message:String(C)),m("error"),s({type:"SET_INSTALL_RUNNING",running:!1})}}else ie()}async function oe(ae){try{const C=await fetch(`/api/containers/${ae}/logs`);if(C.ok){const F=await C.text();w(X=>({...X,[ae]:F}))}else w(F=>({...F,[ae]:`Failed to fetch logs: HTTP ${C.status}`}))}catch(C){w(F=>({...F,[ae]:`Failed to fetch logs: ${C instanceof Error?C.message:String(C)}`}))}}const he=[{key:"preflight",label:"Pre-flight checks"},{key:"generating",label:"Generate configuration"},{key:"pulling",label:"Pull Docker images"},{key:"starting",label:"Start services"},...a.nativeServices.length>0?[{key:"native",label:`Install ${a.nativeServices.length} native service${a.nativeServices.length===1?"":"s"}`}]:[]],Te=he.map(ae=>ae.key).indexOf(f);return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Install"}),l.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:f==="idle"?"Ready to install. This will pull Docker images and start all services.":f==="done"?i.redirect?`Installation complete! Redirecting to your admin dashboard in ${O??"..."}s...`:"Installation complete! All services are running.":f==="error"?"Installation encountered an error.":"Installing..."})]}),h&&l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] overflow-hidden",children:[l.jsx("div",{className:"border-b border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2",children:l.jsx("span",{className:"text-xs font-medium text-[var(--color-text-muted)]",children:"Pre-flight Checks"})}),l.jsx("div",{className:"divide-y divide-[var(--color-border)]",children:h.checks.map(ae=>l.jsx("div",{className:"flex items-center justify-between px-3 py-2",children:l.jsxs("div",{className:"flex items-center gap-2",children:[ae.status==="pass"?l.jsx(ht,{size:14,className:"text-green-500"}):ae.status==="warn"?l.jsx(ra,{size:14,className:"text-amber-500"}):l.jsx(xl,{size:14,className:"text-red-500"}),l.jsxs("div",{children:[l.jsx("span",{className:"text-sm text-[var(--color-text)]",children:ae.name}),l.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:ae.message}),ae.details&&ae.status!=="pass"&&l.jsx("p",{className:"text-xs text-[var(--color-text-muted)] opacity-60",children:ae.details})]})]})},ae.name))})]}),l.jsx("div",{className:"space-y-2",children:he.map((ae,C)=>{const F=ae.key===f,X=Te>C||f==="done",ve=f==="error"&&ae.key===E;return l.jsxs("div",{className:"flex items-center gap-3",children:[X?l.jsx(ht,{size:18,className:"text-green-500"}):ve?l.jsx(xl,{size:18,className:"text-red-500"}):F?l.jsx(Ct,{size:18,className:"animate-spin text-[var(--color-primary)]"}):l.jsx("div",{className:"h-[18px] w-[18px] rounded-full border-2 border-[var(--color-border)]"}),l.jsx("span",{className:te("text-sm",X?"text-green-500":F?"font-medium text-[var(--color-text)]":"text-[var(--color-text-muted)]"),children:ae.label})]},ae.key)})}),(f==="starting"||f==="done"||f==="error")&&Object.keys(x).length>0&&l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] overflow-hidden",children:[l.jsx("div",{className:"border-b border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2",children:l.jsx("span",{className:"text-xs font-medium text-[var(--color-text-muted)]",children:"Service Status"})}),l.jsx("div",{className:"divide-y divide-[var(--color-border)]",children:Object.entries(x).map(([ae,C])=>l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[l.jsx("span",{className:"text-sm text-[var(--color-text)]",children:ae}),l.jsxs("div",{className:"flex items-center gap-2",children:[!C.healthy&&l.jsxs("button",{type:"button",onClick:()=>oe(ae),className:"flex items-center gap-1 text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:[l.jsx(ag,{size:12}),"Logs"]}),C.healthy?l.jsx(ht,{size:14,className:"text-green-500"}):l.jsx(xl,{size:14,className:"text-red-500"})]})]}),C.error&&l.jsx("p",{className:"px-3 pb-2 text-xs text-red-400",children:C.error}),R[ae]&&l.jsx("div",{className:"mx-3 mb-2 max-h-32 overflow-auto rounded bg-[var(--color-background)] p-2 text-xs font-mono text-[var(--color-text-muted)]",children:l.jsx("pre",{className:"whitespace-pre-wrap",children:R[ae]})})]},ae))})]}),(o.lines.length>0||o.running)&&l.jsx(ed,{lines:o.lines,running:o.running,title:"docker compose pull"}),(i.lines.length>0||i.running)&&l.jsx(ed,{lines:i.lines,running:i.running,title:"docker compose up -d"}),(f==="native"||Object.keys(ne).length>0)&&l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] overflow-hidden",children:[l.jsx("div",{className:"border-b border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2",children:l.jsx("span",{className:"text-xs font-medium text-[var(--color-text-muted)]",children:"Native Services (LaunchAgents)"})}),l.jsx("div",{className:"divide-y divide-[var(--color-border)]",children:a.nativeServices.map(ae=>{const C=ne[ae],F=Y===ae&&f==="native";return l.jsxs("div",{className:"px-3 py-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-[var(--color-text)]",children:ae}),C?.ok?l.jsx(ht,{size:14,className:"text-green-500"}):C?l.jsx(xl,{size:14,className:"text-red-500"}):F?l.jsx(Ct,{size:14,className:"animate-spin text-[var(--color-primary)]"}):l.jsx("div",{className:"h-3 w-3 rounded-full border border-[var(--color-border)]"})]}),C?.error&&l.jsx("p",{className:"mt-1 text-xs text-red-400",children:C.error})]},ae)})})]}),(d.lines.length>0||d.running)&&l.jsx(ed,{lines:d.lines,running:d.running,title:Y?`deploy-launchd.sh (${Y})`:"deploy-launchd.sh"}),v&&l.jsx("div",{className:"rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-500",children:v}),(f==="idle"||f==="error")&&l.jsxs("button",{type:"button",onClick:f==="error"?re:ie,className:te("flex w-full items-center justify-center gap-2 rounded-lg bg-[var(--color-primary)] px-4 py-3 font-medium text-white","hover:opacity-90 transition-opacity"),children:[f==="error"?l.jsx(gi,{size:18}):l.jsx(ng,{size:18}),f==="error"?"Retry Installation":"Start Installation"]})]})}const $x="jarvis-whisper-api",P4="jarvis-llm-proxy-api";function I4(){const{state:a,dispatch:s}=fr(),o=Ng(),i=Cg(),d=gg(),f=wg(),m=a.platform==="darwin",[v,g]=N.useState("select"),[h,y]=N.useState(null),[x,S]=N.useState("GGUF"),[R,w]=N.useState(""),[E,_]=N.useState(!0),[O,k]=N.useState(null);if(a.deploymentMode==="remote-llm")return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Models"}),l.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Your LLM is configured to use a remote server."})]}),l.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-green-500/30 bg-green-500/5 p-4",children:[l.jsx(ht,{size:20,className:"text-green-500"}),l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:"Remote LLM configured"}),l.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:a.remoteLlmUrl})]})]})]});const Y=async()=>{await d.mutateAsync({serviceName:$x,key:"whisper.allow_model_autodownload",value:!0}),m&&await f.mutateAsync($x)},I=re=>{y(re),k(null),re.gated&&!R.trim()?g("token"):ee(re,R.trim())},ne=()=>{if(!R.trim()){k("HuggingFace token is required for gated models");return}h&&ee(h,R)},ee=async(re,oe)=>{if(k(null),E){g("whisper");try{await Y()}catch(Te){k(`Whisper model setup failed: ${Te.message}`),g("select");return}}g("downloading");const he=x==="GGUF"?re.hfRepoGguf:re.hfRepoVllm,Ee=x==="GGUF"?re.ggufFilename:void 0;try{await i.mutateAsync({repo:he,filename:Ee,token:oe||void 0}),await H(re)}catch(Te){k(`Download failed: ${Te.message}`),g("select")}},H=async re=>{g("configuring");const he={"model.main.name":x==="GGUF"?`.models/${re.ggufFilename}`:`.models/${re.hfRepoVllm.split("/").pop()}`,"model.main.backend":x,"model.main.chat_format":re.chatFormat,"model.main.context_window":re.contextWindow,"llm.interface":re.promptProvider};x==="GGUF"&&(he["inference.gguf.n_gpu_layers"]=-1),x==="VLLM"&&re.quantization&&(he["inference.vllm.quantization"]=re.quantization);try{await o.mutateAsync(he),m&&await f.mutateAsync(P4),s({type:"SET_LLM_INTERFACE",interfaceId:re.promptProvider}),g("done")}catch(Ee){k(`Configuration failed: ${Ee.message}`),g("select")}},K=a.hardware?.gpuVramMb,ie=K?ss.filter(re=>re.vramMb<=K):ss;return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Models"}),l.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:v==="done"?"Models configured. Services are restarting to load them.":"Choose a language model, and optionally fetch the speech-to-text model."})]}),O&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-red-500/30 bg-red-500/10 p-3 text-sm text-red-500",children:[l.jsx(ra,{size:16,className:"mt-0.5 shrink-0"}),O]}),h&&l.jsxs("button",{type:"button",onClick:()=>ee(h,R),className:te("flex w-full items-center justify-center gap-2 rounded-lg border border-[var(--color-border)] px-4 py-2 text-sm","hover:bg-[var(--color-surface-alt)] transition-colors"),children:[l.jsx(gi,{size:14}),"Retry"]})]}),v==="select"&&l.jsxs(l.Fragment,{children:[!m&&l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:"Backend"}),l.jsx("div",{className:"flex gap-2",children:["GGUF","VLLM"].map(re=>l.jsx("button",{type:"button",onClick:()=>S(re),className:te("rounded-md px-3 py-1 text-xs font-medium transition-colors",x===re?"bg-[var(--color-primary)] text-white":"bg-[var(--color-surface-alt)] text-[var(--color-text-muted)] hover:text-[var(--color-text)]"),children:re==="VLLM"?"vLLM":re},re))})]}),l.jsxs("label",{className:te("flex cursor-pointer items-start gap-3 rounded-lg border p-3 transition-colors",E?"border-[var(--color-primary)] bg-[var(--color-primary)]/5":"border-[var(--color-border)]"),children:[l.jsx("input",{type:"checkbox",checked:E,onChange:re=>_(re.target.checked),className:"mt-0.5"}),l.jsxs("span",{className:"flex items-center gap-2 text-sm text-[var(--color-text)]",children:[l.jsx(kx,{size:15,className:"shrink-0 text-[var(--color-primary)]"}),l.jsxs("span",{children:["Auto-download the speech-to-text model",l.jsxs("span",{className:"block text-xs text-[var(--color-text-muted)]",children:["Whisper ",l.jsx("code",{children:"base.en"})," (~150 MB, no token needed). Required for voice."]})]})]})]}),l.jsxs("div",{children:[l.jsx("label",{htmlFor:"hf-token",className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"HuggingFace Token (optional — speeds up downloads, required for gated models)"}),l.jsx("input",{id:"hf-token",type:"password",value:R,onChange:re=>w(re.target.value),placeholder:"hf_...",className:te("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]")})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:"Language model"}),ie.map(re=>l.jsxs("button",{type:"button",onClick:()=>I(re),className:te("flex w-full items-center justify-between rounded-lg border border-[var(--color-border)] p-3 text-left transition-colors","hover:border-[var(--color-primary)] hover:bg-[var(--color-surface-alt)]"),children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:re.displayName}),re.gated&&l.jsxs("span",{className:"flex items-center gap-0.5 rounded bg-yellow-500/15 px-1.5 py-0.5 text-[10px] font-medium text-yellow-600 dark:text-yellow-400",children:[l.jsx(vi,{size:10}),"Gated"]})]}),l.jsxs("p",{className:"mt-0.5 text-xs text-[var(--color-text-muted)]",children:[re.promptProvider," · ",re.contextWindow.toLocaleString()," ctx"]})]}),l.jsxs("span",{className:"text-xs text-[var(--color-text-muted)]",children:["~",x==="GGUF"?re.sizeGguf:re.sizeVllm]})]},re.id)),ie.length===0&&l.jsxs("p",{className:"py-4 text-center text-sm text-[var(--color-text-muted)]",children:["No models fit your available memory (",K?Math.round(K/1024)+" GB":"unknown",")."]}),K&&ie.length<ss.length&&l.jsxs("p",{className:"text-xs text-[var(--color-text-muted)]",children:["Showing ",ie.length," of ",ss.length," models that fit your ",Math.round(K/1024)," GB."]})]})]}),v==="token"&&h&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("p",{className:"text-sm text-[var(--color-text-muted)]",children:[l.jsx("strong",{children:h.displayName})," is a gated model. Accept the license on HuggingFace and paste your access token below."]}),l.jsx("input",{type:"password",value:R,onChange:re=>w(re.target.value),placeholder:"hf_...",className:te("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]")}),l.jsxs("div",{className:"flex justify-between",children:[l.jsx("button",{type:"button",onClick:()=>{g("select"),k(null)},className:"text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:"Back"}),l.jsx("button",{type:"button",onClick:ne,className:"rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm text-white hover:opacity-90",children:"Download"})]})]}),v==="whisper"&&l.jsxs("div",{className:"flex flex-col items-center py-8",children:[l.jsx(kx,{className:"mb-4 animate-pulse text-[var(--color-primary)]",size:32}),l.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:"Enabling speech-to-text model download..."}),l.jsx("p",{className:"mt-1 text-xs text-[var(--color-text-muted)]",children:"Whisper will fetch ggml-base.en on restart"})]}),v==="downloading"&&l.jsxs("div",{className:"flex flex-col items-center py-8",children:[l.jsx(en,{className:"mb-4 animate-bounce text-[var(--color-primary)]",size:32}),l.jsxs("p",{className:"text-sm font-medium text-[var(--color-text)]",children:["Downloading ",h?.displayName,"..."]}),l.jsxs("p",{className:"mt-1 text-xs text-[var(--color-text-muted)]",children:["~",x==="GGUF"?h?.sizeGguf:h?.sizeVllm," · This may take several minutes"]})]}),v==="configuring"&&l.jsxs("div",{className:"flex flex-col items-center py-8",children:[l.jsx(Ct,{className:"mb-4 animate-spin text-[var(--color-primary)]",size:32}),l.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:"Configuring model and prompt provider..."})]}),v==="done"&&h&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-green-500/30 bg-green-500/5 p-4",children:[l.jsx(ht,{size:20,className:"text-green-500"}),l.jsxs("div",{children:[l.jsxs("p",{className:"text-sm font-medium text-[var(--color-text)]",children:[h.displayName," configured"]}),l.jsxs("p",{className:"text-xs text-[var(--color-text-muted)]",children:["Backend: ",x," · Prompt provider: ",h.promptProvider,E&&" · Whisper auto-download enabled"]})]})]}),l.jsxs("p",{className:"text-xs text-[var(--color-text-muted)]",children:["The LLM proxy is restarting with the new model",E&&", and whisper is fetching its model",". This may take a few minutes to finish loading. Command Center will use the"," ",l.jsx("strong",{children:h.promptProvider})," prompt provider."]})]})]})}function W4(){const[a,s]=N.useState(""),[o,i]=N.useState(""),[d,f]=N.useState(""),[m,v]=N.useState(""),[g,h]=N.useState(!1),[y,x]=N.useState(!1),[S,R]=N.useState(null),w=o===d,E=a&&o&&d&&m&&w&&!g;async function _(){if(E){h(!0),R(null);try{const k=await Pv(a,o,m);rs(k.access_token),localStorage.setItem("access_token",k.access_token),localStorage.setItem("refresh_token",k.refresh_token),x(!0)}catch(k){const Y=k?.response?.data?.error??(k instanceof Error?k.message:"Failed to create account");R(Y)}finally{h(!1)}}}if(y)return l.jsxs("div",{className:"space-y-6",children:[l.jsx("div",{children:l.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Account Created"})}),l.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-green-500/30 bg-green-500/5 p-4",children:[l.jsx(ht,{size:20,className:"text-green-500"}),l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:"Superuser account created"}),l.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:a})]})]}),l.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:`You're logged in. Click "Next" to configure your LLM model.`})]});const O=te("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]");return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Create Account"}),l.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Create your superuser account. This will be the admin for your Jarvis instance."})]}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{htmlFor:"display-name",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Display Name"}),l.jsx("input",{id:"display-name",type:"text",value:m,onChange:k=>v(k.target.value),className:O,placeholder:"Alex"})]}),l.jsxs("div",{children:[l.jsx("label",{htmlFor:"email",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Email"}),l.jsx("input",{id:"email",type:"email",value:a,onChange:k=>s(k.target.value),className:O,placeholder:"admin@example.com"})]}),l.jsxs("div",{children:[l.jsx("label",{htmlFor:"password",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Password"}),l.jsx("input",{id:"password",type:"password",value:o,onChange:k=>i(k.target.value),className:O,placeholder:"Choose a strong password"})]}),l.jsxs("div",{children:[l.jsx("label",{htmlFor:"confirm-password",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Confirm Password"}),l.jsx("input",{id:"confirm-password",type:"password",value:d,onChange:k=>f(k.target.value),className:te(O,d&&!w&&"ring-2 ring-red-500"),placeholder:"Confirm password"}),d&&!w&&l.jsx("p",{className:"mt-1 text-xs text-red-500",children:"Passwords don't match"})]})]}),S&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-red-500/10 px-3 py-2",children:[l.jsx(Bd,{size:14,className:"text-red-500 shrink-0"}),l.jsx("span",{className:"text-sm text-red-500",children:S})]}),l.jsxs("button",{type:"button",onClick:_,disabled:!E,className:te("flex w-full items-center justify-center gap-2 rounded-lg border border-[var(--color-border)] px-4 py-2 text-sm","hover:bg-[var(--color-surface-alt)] transition-colors","disabled:opacity-50"),children:[l.jsx(gi,{size:14}),"Retry"]})]}),!S&&l.jsx("button",{type:"button",onClick:_,disabled:!E,className:te("w-full rounded-lg bg-[var(--color-primary)] px-4 py-2 font-medium text-white","hover:opacity-90 disabled:opacity-50 transition-opacity"),children:g?"Creating...":"Create Superuser Account"})]})}const Zo=[{label:"Welcome",component:Y4},{label:"Hardware",component:X4},{label:"Services",component:K4},{label:"Review",component:Z4},{label:"Install",component:J4},{label:"Account",component:W4},{label:"Models",component:I4}],e3=5;function t3({skipToAccount:a}){const{state:s,dispatch:o}=fr();N.useEffect(()=>{a&&o({type:"SET_STEP",step:e3})},[a,o]);const i=wa(),d=Zo[s.currentStep].component,f=s.currentStep===0,m=s.currentStep===Zo.length-1,h=s.currentStep===4&&!s.installComplete,y=s.installRunning||h;function x(){m?i("/login"):o({type:"NEXT_STEP"})}function S(){o({type:"PREV_STEP"})}return l.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[var(--color-background)] p-4",children:l.jsxs("div",{className:"w-full max-w-2xl",children:[l.jsx("div",{className:"mb-6 flex items-center justify-center gap-1",children:Zo.map((R,w)=>l.jsxs("button",{type:"button",onClick:()=>!y&&o({type:"SET_STEP",step:w}),disabled:y,className:te("flex items-center gap-1",y&&"cursor-not-allowed"),children:[l.jsx("div",{className:te("flex h-7 w-7 items-center justify-center rounded-full text-xs font-medium transition-colors",w===s.currentStep?"bg-[var(--color-primary)] text-white":w<s.currentStep?"bg-[var(--color-primary)]/20 text-[var(--color-primary)]":"bg-[var(--color-surface-alt)] text-[var(--color-text-muted)]"),children:w+1}),l.jsx("span",{className:te("hidden text-xs sm:inline",w===s.currentStep?"font-medium text-[var(--color-text)]":"text-[var(--color-text-muted)]"),children:R.label}),w<Zo.length-1&&l.jsx("div",{className:te("mx-1 h-px w-4 sm:w-6",w<s.currentStep?"bg-[var(--color-primary)]/30":"bg-[var(--color-border)]")})]},R.label))}),l.jsx("div",{className:"rounded-xl border border-[var(--color-border)] bg-[var(--color-surface)] p-6 shadow-lg",children:l.jsx(d,{})}),l.jsxs("div",{className:"mt-4 flex justify-between",children:[l.jsx("button",{type:"button",onClick:S,disabled:f||y,className:te("rounded-lg border border-[var(--color-border)] px-4 py-2 text-sm","hover:bg-[var(--color-surface-alt)] transition-colors","disabled:invisible"),children:"Back"}),l.jsx("button",{type:"button",onClick:x,disabled:y,className:te("rounded-lg bg-[var(--color-primary)] px-6 py-2 text-sm font-medium text-white","hover:opacity-90 transition-opacity","disabled:opacity-50 disabled:cursor-not-allowed"),children:m?"Finish":"Next"})]})]})})}function a3({skipToAccount:a}){return l.jsx(F4,{children:l.jsx(t3,{skipToAccount:a})})}function n3(){const a=wa(),s=Ng(),o=kE(),[i,d]=N.useState("select"),[f,m]=N.useState(null),[v,g]=N.useState("GGUF"),[h,y]=N.useState(""),[x,S]=N.useState(null),R=k=>{m(k),k.gated?d("token"):E(k,"")},w=()=>{if(!h.trim()){S("HuggingFace token is required for gated models");return}S(null),f&&E(f,h)},E=async(k,Y)=>{d("download"),S(null);const I=v==="GGUF"?k.hfRepoGguf:k.hfRepoVllm,ne=v==="GGUF"?k.ggufFilename:void 0;try{await o.mutateAsync({repo:I,filename:ne,token:Y||void 0}),_(k)}catch(ee){S(`Download failed: ${ee.message}`),d("select")}},_=async k=>{d("configure"),S(null);const I={"model.main.name":v==="GGUF"?`.models/${k.ggufFilename}`:`.models/${k.hfRepoVllm.split("/").pop()}`,"model.main.backend":v,"model.main.chat_format":k.chatFormat,"model.main.context_window":k.contextWindow};v==="GGUF"&&(I["inference.gguf.n_gpu_layers"]=-1),v==="VLLM"&&k.quantization&&(I["inference.vllm.quantization"]=k.quantization);try{await s.mutateAsync(I),d("done"),Me.success("LLM configured successfully")}catch(ne){S(`Configuration failed: ${ne.message}`),d("select")}},O=()=>{a("/dashboard")};return l.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[var(--color-bg)] p-4",children:l.jsxs("div",{className:"w-full max-w-2xl rounded-xl border border-[var(--color-border)] bg-[var(--color-surface)] p-8 shadow-lg",children:[l.jsxs("div",{className:"mb-8 text-center",children:[l.jsx(pd,{className:"mx-auto mb-3 text-[var(--color-primary)]",size:40}),l.jsx("h1",{className:"text-2xl font-bold text-[var(--color-text)]",children:"LLM Setup"}),l.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Configure a local language model for Jarvis"})]}),l.jsx("div",{className:"mb-8 flex items-center justify-center gap-2",children:["select","download","configure","done"].map((k,Y)=>{const I=i==="token"?"select":i,ne=["select","download","configure","done"];return l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:te("h-2 w-2 rounded-full",I===k?"bg-[var(--color-primary)]":ne.indexOf(I)>Y?"bg-green-500":"bg-[var(--color-border)]")}),Y<3&&l.jsx("div",{className:"h-px w-8 bg-[var(--color-border)]"})]},k)})}),x&&l.jsxs("div",{className:"mb-6 flex items-start gap-2 rounded-lg border border-red-500/30 bg-red-500/10 p-3 text-sm text-red-500",children:[l.jsx(ra,{size:16,className:"mt-0.5 shrink-0"}),x]}),i==="select"&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[l.jsx("h2",{className:"text-sm font-semibold text-[var(--color-text)]",children:"Select a model"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:()=>g("GGUF"),className:te("rounded-md px-3 py-1 text-xs font-medium transition-colors",v==="GGUF"?"bg-[var(--color-primary)] text-white":"bg-[var(--color-surface-alt)] text-[var(--color-text-muted)] hover:text-[var(--color-text)]"),children:"GGUF"}),l.jsx("button",{onClick:()=>g("VLLM"),className:te("rounded-md px-3 py-1 text-xs font-medium transition-colors",v==="VLLM"?"bg-[var(--color-primary)] text-white":"bg-[var(--color-surface-alt)] text-[var(--color-text-muted)] hover:text-[var(--color-text)]"),children:"vLLM"})]})]}),l.jsx("div",{className:"grid gap-3",children:ss.map(k=>l.jsxs("button",{onClick:()=>R(k),className:te("flex items-center justify-between rounded-lg border border-[var(--color-border)] p-4 text-left transition-colors","hover:border-[var(--color-primary)] hover:bg-[var(--color-surface-alt)]"),children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"font-medium text-[var(--color-text)]",children:k.displayName}),k.gated&&l.jsxs("span",{className:"flex items-center gap-1 rounded bg-yellow-500/15 px-1.5 py-0.5 text-[10px] font-medium text-yellow-600 dark:text-yellow-400",children:[l.jsx(vi,{size:10}),"Gated"]})]}),l.jsxs("p",{className:"mt-0.5 text-xs text-[var(--color-text-muted)]",children:[k.quantization?`${k.quantization.toUpperCase()} 4-bit`:k.chatFormat," · ",k.contextWindow.toLocaleString()," ctx"]})]}),l.jsxs("span",{className:"text-sm text-[var(--color-text-muted)]",children:["~",v==="GGUF"?k.sizeGguf:k.sizeVllm]})]},k.id))}),l.jsx("div",{className:"flex justify-end pt-2",children:l.jsx("button",{onClick:O,className:"text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:"Skip for now"})})]}),i==="token"&&f&&l.jsxs("div",{className:"space-y-4",children:[l.jsx("h2",{className:"text-sm font-semibold text-[var(--color-text)]",children:"HuggingFace Access Required"}),l.jsxs("p",{className:"text-sm text-[var(--color-text-muted)]",children:[l.jsx("strong",{children:f.displayName})," is a gated model. You need to:"]}),l.jsxs("ol",{className:"list-inside list-decimal space-y-1 text-sm text-[var(--color-text-muted)]",children:[l.jsx("li",{children:"Visit the model page on huggingface.co and accept the license agreement"}),l.jsx("li",{children:"Create an access token at huggingface.co/settings/tokens"}),l.jsx("li",{children:"Paste your token below"})]}),l.jsx("input",{type:"password",value:h,onChange:k=>y(k.target.value),placeholder:"hf_...",className:te("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-bg)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]")}),l.jsxs("div",{className:"flex justify-between",children:[l.jsx("button",{onClick:()=>{d("select"),S(null)},className:"text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:"Back"}),l.jsx("button",{onClick:w,className:"rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm text-white hover:opacity-90",children:"Continue"})]})]}),i==="download"&&l.jsxs("div",{className:"flex flex-col items-center py-8",children:[l.jsx(en,{className:"mb-4 animate-bounce text-[var(--color-primary)]",size:32}),l.jsx("h2",{className:"text-lg font-semibold text-[var(--color-text)]",children:"Downloading model..."}),l.jsxs("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:[f?.displayName," ","(~",v==="GGUF"?f?.sizeGguf:f?.sizeVllm,")"]}),l.jsx("p",{className:"mt-4 text-xs text-[var(--color-text-muted)]",children:"This may take several minutes depending on your connection"})]}),i==="configure"&&l.jsxs("div",{className:"flex flex-col items-center py-8",children:[l.jsx(rg,{className:"mb-4 animate-spin text-[var(--color-primary)]",size:32}),l.jsx("h2",{className:"text-lg font-semibold text-[var(--color-text)]",children:"Configuring..."}),l.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Writing settings and restarting LLM proxy"})]}),i==="done"&&l.jsxs("div",{className:"flex flex-col items-center py-8",children:[l.jsx(Gj,{className:"mb-4 text-green-500",size:40}),l.jsx("h2",{className:"text-lg font-semibold text-[var(--color-text)]",children:"LLM Ready"}),l.jsxs("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:[f?.displayName," configured on ",v]}),l.jsx("p",{className:"mt-1 text-xs text-[var(--color-text-muted)]",children:"The model service is restarting. It may take a minute to load the model."}),l.jsx("button",{onClick:()=>a("/dashboard"),className:"mt-6 rounded-lg bg-[var(--color-primary)] px-6 py-2 text-sm text-white hover:opacity-90",children:"Go to Dashboard"})]}),(o.isPending||s.isPending)&&i!=="download"&&i!=="configure"&&l.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",children:l.jsx(Ct,{className:"animate-spin text-white",size:32})})]})})}const r3=new I1;function s3(){const[a,s]=N.useState(!0),[o,i]=N.useState(!1),[d,f]=N.useState(!1);return N.useEffect(()=>{Yd().then(m=>{m.state==="deployed-needs-account"?(f(!0),i(!0)):i(!m.configured)}).catch(()=>{i(!1)}).finally(()=>s(!1))},[]),a?l.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[var(--color-background)]",children:l.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-[var(--color-primary)] border-t-transparent"})}):l.jsxs($0,{children:[l.jsx(ft,{path:"/setup",element:l.jsx(a3,{skipToAccount:d})}),l.jsx(ft,{path:"/login",element:l.jsx(Jw,{})}),l.jsx(ft,{path:"/llm-setup",element:l.jsx(n3,{})}),l.jsxs(ft,{element:l.jsx(Zw,{}),children:[l.jsx(ft,{path:"/dashboard",element:l.jsx(LE,{})}),l.jsx(ft,{path:"/settings",element:l.jsx(iE,{})}),l.jsx(ft,{path:"/services",element:l.jsx(wE,{})}),l.jsx(ft,{path:"/models",element:l.jsx(y4,{})}),l.jsx(ft,{path:"/quick-sets",element:l.jsx(_4,{})}),l.jsx(ft,{path:"/traces",element:l.jsx(U4,{})}),l.jsx(ft,{path:"/traces/:id",element:l.jsx(B4,{})}),l.jsx(ft,{path:"/update",element:l.jsx(R4,{})}),l.jsx(ft,{path:"/reconcile",element:l.jsx(M4,{})}),l.jsx(ft,{path:"/nodes",element:l.jsx(XE,{})}),l.jsx(ft,{path:"/users",element:l.jsx(a4,{})}),l.jsx(ft,{path:"/native-services",element:l.jsx(f4,{})}),l.jsx(ft,{path:"/",element:o?l.jsx(ni,{to:"/setup",replace:!0}):l.jsx(ni,{to:"/dashboard",replace:!0})}),l.jsx(ft,{path:"*",element:l.jsx(q4,{})})]})]})}function l3(){return l.jsx(q2,{children:l.jsx(W1,{client:r3,children:l.jsxs(jj,{children:[l.jsx(g1,{children:l.jsx(s3,{})}),l.jsx(L2,{position:"bottom-right",richColors:!0})]})})})}Kb.createRoot(document.getElementById("root")).render(l.jsx(N.StrictMode,{children:l.jsx(l3,{})}));
|
|
18
|
+
`);Z=ue.pop()??"";for(const je of ue)if(je.startsWith("data: "))try{const U=JSON.parse(je.slice(6));if(U.phase&&i(U.phase),U.message&&Ee({text:U.message,phase:U.phase}),U.stream&&U.text&&Ee({text:U.text.trim()}),U.done&&U.code!==0)throw new Error(U.message??"Reconcile failed")}catch(U){if(U instanceof SyntaxError)continue;throw U}}}catch(j){const D=j instanceof Error?j.message:String(j);v(D),i("error"),Ee({text:`Error: ${D}`})}}function C(){return{enabledModules:h.filter(W=>W.enabled).map(W=>W.id),relayEnabled:x,relayUrl:R,whisperModelPath:E,whisperBackend:O,ttsBackend:Y,pinImages:ne,releaseTrack:H}}async function F(W){he(!0),v(null),re(null);try{const{latest:j,...D}=W??{},Z=await fetch(`/api/install/regenerate-download${j?"?latest=true":""}`,{method:"POST",headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json"},body:JSON.stringify({...C(),...D})});if(!Z.ok){const me=await Z.text();throw new Error(me||`HTTP ${Z.status}`)}const se=await Z.json();re({compose:se.compose,env:se.env,initDb:se.initDb})}catch(j){v(j instanceof Error?j.message:String(j))}finally{he(!1)}}function X(W,j){const D=new Blob([j],{type:"text/plain;charset=utf-8"}),G=URL.createObjectURL(D),Z=document.createElement("a");Z.href=G,Z.download=W,document.body.appendChild(Z),Z.click(),Z.remove(),URL.revokeObjectURL(G)}const ve=Object.keys(Ju).filter(W=>{const j=Object.keys(Ju),D=j.indexOf(o);return j.indexOf(W)<D||o==="done"&&W==="done"});return l.jsxs("div",{className:"mx-auto max-w-3xl space-y-6 p-6",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold text-[var(--color-text)]",children:"Sync Compose"}),l.jsxs("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:["Regenerate ",l.jsx("code",{className:"rounded bg-[var(--color-surface)] px-1.5 py-0.5 text-xs",children:"docker-compose.yml"})," from the latest service registry, preserving your secrets. ",l.jsx("strong",{className:"text-[var(--color-text)]",children:"Sync now"})," applies it to the running stack;",l.jsx("strong",{className:"text-[var(--color-text)]",children:" Download"})," hands you the files to review and apply by hand (",l.jsx("code",{className:"rounded bg-[var(--color-surface)] px-1 text-xs",children:"docker compose up -d"}),")."," ",l.jsx("strong",{className:"text-[var(--color-text)]",children:"Update stack to latest"})," downloads the same, pinned to the newest published images."]})]}),o==="loading_options"&&l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx(Ct,{size:32,className:"animate-spin text-[var(--color-primary)]"})}),o==="options"&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsx("h2",{className:"mb-3 text-sm font-semibold text-[var(--color-text)]",children:"Services"}),l.jsx("div",{className:"space-y-2",children:h.map(W=>l.jsxs("button",{onClick:()=>Te(W.id),className:"flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left hover:bg-[var(--color-bg-secondary)] transition-colors",children:[W.enabled?l.jsx(ht,{size:18,className:"shrink-0 text-[var(--color-primary)]"}):l.jsx(os,{size:18,className:"shrink-0 text-[var(--color-text-muted)]"}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-sm font-medium text-[var(--color-text)]",children:W.name}),l.jsx("div",{className:"text-xs text-[var(--color-text-muted)]",children:W.description})]})]},W.id))})]}),l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsx("h2",{className:"mb-3 text-sm font-semibold text-[var(--color-text)]",children:"Release Track"}),l.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[l.jsxs("div",{children:[l.jsx("div",{className:"text-sm font-medium text-[var(--color-text)]",children:H==="dev"?"Dev":"Stable"}),l.jsx("div",{className:"text-xs text-[var(--color-text-muted)]",children:H==="dev"?"Using latest main branch builds (may be unstable)":"Using tagged releases"})]}),l.jsx("button",{type:"button",role:"switch","aria-checked":H==="dev",onClick:()=>K(H==="dev"?"stable":"dev"),className:`relative h-6 w-11 shrink-0 rounded-full transition-colors ${H==="dev"?"bg-amber-500":"bg-[var(--color-surface-alt)]"}`,children:l.jsx("span",{className:`absolute left-0.5 top-0.5 h-5 w-5 rounded-full bg-white transition-transform ${H==="dev"?"translate-x-5":"translate-x-0"}`})})]}),H==="dev"&&l.jsx("div",{className:"mx-3 mt-1 rounded-lg border border-amber-300 bg-amber-500/10 px-3 py-2 text-xs text-amber-400",children:"Switching tracks will pull all images and force-recreate containers."})]}),l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsx("h2",{className:"mb-3 text-sm font-semibold text-[var(--color-text)]",children:"Integrations"}),l.jsxs("button",{onClick:()=>S(!x),className:"flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left hover:bg-[var(--color-bg-secondary)] transition-colors",children:[x?l.jsx(ht,{size:18,className:"shrink-0 text-[var(--color-primary)]"}):l.jsx(os,{size:18,className:"shrink-0 text-[var(--color-text-muted)]"}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-sm font-medium text-[var(--color-text)]",children:"Jarvis Relay"}),l.jsx("div",{className:"text-xs text-[var(--color-text-muted)]",children:"Routes OAuth callbacks through a cloud relay for external providers (Google, Spotify, etc.)"})]})]}),x&&l.jsxs("div",{className:"mt-2 px-3",children:[l.jsx("label",{className:"text-xs font-medium text-[var(--color-text-muted)]",children:"Relay URL"}),l.jsx("input",{type:"url",value:R,onChange:W=>w(W.target.value),placeholder:"https://relay.jarvisautomation.io",className:"mt-1 w-full rounded-md border border-[var(--color-border)] bg-[var(--color-bg)] px-3 py-1.5 text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]"})]})]}),h.some(W=>W.id==="jarvis-whisper-api"&&W.enabled)&&l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsx("h2",{className:"mb-3 text-sm font-semibold text-[var(--color-text)]",children:"Whisper"}),l.jsxs("div",{className:"px-3",children:[l.jsx("label",{className:"text-xs font-medium text-[var(--color-text-muted)]",children:"Model path"}),l.jsx("input",{type:"text",value:E,onChange:W=>_(W.target.value),placeholder:"/whisper-models/ggml-base.en.bin",className:"mt-1 w-full rounded-md border border-[var(--color-border)] bg-[var(--color-bg)] px-3 py-1.5 text-sm font-mono text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]"}),l.jsxs("p",{className:"mt-1 text-xs text-[var(--color-text-muted)]",children:["Path inside the container. Place model files in ",l.jsx("code",{className:"rounded bg-[var(--color-bg)] px-1",children:"./whisper-models/"})," next to your compose file."]}),l.jsx("label",{className:"mt-3 block text-xs font-medium text-[var(--color-text-muted)]",children:"GPU backend"}),l.jsxs("select",{value:O,onChange:W=>k(W.target.value),className:"mt-1 w-full rounded-md border border-[var(--color-border)] bg-[var(--color-bg)] px-3 py-1.5 text-sm text-[var(--color-text)]",children:[l.jsx("option",{value:"cpu",children:"CPU (default)"}),l.jsx("option",{value:"cuda",children:"NVIDIA (CUDA)"}),l.jsx("option",{value:"vulkan",children:"AMD / generic (Vulkan)"}),l.jsx("option",{value:"rocm",children:"AMD (ROCm)"})]}),l.jsx("p",{className:"mt-1 text-xs text-[var(--color-text-muted)]",children:"Where speech-to-text runs. CPU leaves the GPU for the LLM; pick a GPU backend to run Whisper on the GPU."})]})]}),h.some(W=>W.id==="jarvis-tts"&&W.enabled)&&l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsx("h2",{className:"mb-3 text-sm font-semibold text-[var(--color-text)]",children:"Text-to-speech"}),l.jsxs("div",{className:"px-3",children:[l.jsx("label",{className:"text-xs font-medium text-[var(--color-text-muted)]",children:"Inference device"}),l.jsxs("select",{value:Y,onChange:W=>I(W.target.value),className:"mt-1 w-full rounded-md border border-[var(--color-border)] bg-[var(--color-bg)] px-3 py-1.5 text-sm text-[var(--color-text)]",children:[l.jsx("option",{value:"cpu",children:"CPU (default)"}),l.jsx("option",{value:"cuda",children:"NVIDIA (CUDA)"})]}),l.jsxs("p",{className:"mt-1 text-xs text-[var(--color-text-muted)]",children:["Where Kokoro synthesis runs. CPU is fine for most installs; CUDA gives the fastest first-audio. On multi-GPU hosts set ",l.jsx("code",{className:"rounded bg-[var(--color-bg)] px-1",children:"TTS_GPU_DEVICE"})," in .env to pick which GPU (default 0)."]})]})]}),l.jsx("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:l.jsxs("label",{className:"flex items-start gap-3 text-sm",children:[l.jsx("input",{type:"checkbox",checked:ne,onChange:W=>ee(W.target.checked),className:"mt-0.5","data-testid":"pin-images-checkbox"}),l.jsxs("span",{children:[l.jsx("span",{className:"font-medium text-[var(--color-text)]",children:"Pin images by digest"}),l.jsxs("span",{className:"mt-1 block text-xs text-[var(--color-text-muted)]",children:["Advanced supply-chain hardening: locks every image to an exact build. Leave OFF for normal use — with pinning on, ",l.jsx("code",{className:"rounded bg-[var(--color-bg)] px-1",children:"docker compose pull"})," will never update anything and services only change via this page."]})]})]})})]}),ie&&o==="options"&&l.jsxs("div",{className:"rounded-lg border border-[var(--color-primary)]/40 bg-[var(--color-surface)] p-4",children:[l.jsxs("h2",{className:"mb-1 flex items-center gap-2 text-sm font-semibold text-[var(--color-text)]",children:[l.jsx(ht,{size:16,className:"text-green-500"}),"Updated files ready"]}),l.jsxs("p",{className:"mb-3 text-xs text-[var(--color-text-muted)]",children:["Your existing secrets and settings are carried over. Download, replace the files next to your compose, then run ",l.jsx("code",{className:"rounded bg-[var(--color-bg)] px-1",children:"docker compose up -d"}),". Nothing on the server was changed."]}),l.jsxs("div",{className:"flex flex-wrap gap-2",children:[l.jsxs("button",{onClick:()=>X("docker-compose.yml",ie.compose),className:"flex items-center gap-2 rounded-lg bg-[var(--color-primary)] px-3 py-2 text-sm font-medium text-white hover:opacity-90",children:[l.jsx(en,{size:15}),"docker-compose.yml"]}),l.jsxs("button",{onClick:()=>X(".env",ie.env),className:"flex items-center gap-2 rounded-lg border border-[var(--color-border)] px-3 py-2 text-sm font-medium text-[var(--color-text)] hover:bg-[var(--color-surface-alt)]",children:[l.jsx(en,{size:15}),".env"]}),l.jsxs("button",{onClick:()=>X("init-db.sh",ie.initDb),className:"flex items-center gap-2 rounded-lg border border-[var(--color-border)] px-3 py-2 text-sm font-medium text-[var(--color-text)] hover:bg-[var(--color-surface-alt)]",children:[l.jsx(en,{size:15}),"init-db.sh"]})]}),l.jsxs("p",{className:"mt-3 text-xs text-[var(--color-text-muted)]",children:["The ",l.jsx("code",{className:"rounded bg-[var(--color-bg)] px-1",children:".env"})," merges new keys into your existing values, and ",l.jsx("code",{className:"rounded bg-[var(--color-bg)] px-1",children:"init-db.sh"})," covers any new databases — replace all three to be safe. Diff them against your current files first if you want to eyeball the changes."]})]}),o!=="loading_options"&&o!=="options"&&l.jsx("div",{className:"space-y-2 rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:Object.entries(Ju).map(([W,j])=>{const D=W===o,G=ve.includes(W),Z=W===o&&o==="error";return l.jsxs("div",{className:"flex items-center gap-2",children:[G?l.jsx(ht,{size:16,className:"text-green-500"}):Z?l.jsx(ra,{size:16,className:"text-red-500"}):D?l.jsx(Ct,{size:16,className:"animate-spin text-[var(--color-primary)]"}):l.jsx("div",{className:"h-4 w-4 rounded-full border border-[var(--color-border)]"}),l.jsx("span",{className:te("text-sm",D?"font-medium text-[var(--color-text)]":"text-[var(--color-text-muted)]",G&&"text-green-500"),children:j})]},W)})}),d.length>0&&l.jsx("div",{ref:g,className:"max-h-64 overflow-y-auto rounded-lg border border-[var(--color-border)] bg-[#0d1117] p-3 font-mono text-xs text-gray-300",children:d.map((W,j)=>l.jsx("div",{children:W.text},j))}),m&&l.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-red-500/10 px-3 py-2",children:[l.jsx(ra,{size:14,className:"text-red-500"}),l.jsx("span",{className:"text-sm text-red-500",children:m})]}),l.jsxs("div",{className:"flex gap-3",children:[o==="options"&&l.jsxs("button",{onClick:ae,className:"flex items-center gap-2 rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm font-medium text-white hover:opacity-90",children:[l.jsx(xd,{size:16}),"Sync now"]}),o==="options"&&l.jsxs("button",{onClick:()=>F(),disabled:oe,title:"Regenerate the compose and download it to apply by hand — doesn't touch the running stack",className:"flex items-center gap-2 rounded-lg border border-[var(--color-border)] px-4 py-2 text-sm font-medium text-[var(--color-text)] hover:bg-[var(--color-surface-alt)] disabled:cursor-not-allowed disabled:opacity-50",children:[oe?l.jsx(Ct,{size:16,className:"animate-spin"}):l.jsx(en,{size:16}),"Download updated compose"]}),o==="options"&&l.jsxs("button",{onClick:()=>F({latest:!0}),disabled:oe,title:"Download a compose pinned to the LATEST published images (digests refreshed from the registry). Apply it yourself on the host — docker compose pull && docker compose up -d — which also updates jarvis-admin.",className:"flex items-center gap-2 rounded-lg border border-[var(--color-border)] px-4 py-2 text-sm font-medium text-[var(--color-text)] hover:bg-[var(--color-surface-alt)] disabled:cursor-not-allowed disabled:opacity-50",children:[oe?l.jsx(Ct,{size:16,className:"animate-spin"}):l.jsx(it,{size:16}),"Update stack to latest"]}),o==="options"&&l.jsxs("button",{onClick:()=>F({mqttAllowAnon:!1}),disabled:oe,title:"Download a compose with the MQTT broker locked (allow_anonymous=false). Do this only after every node has authenticated, or un-migrated nodes will drop off.",className:"flex items-center gap-2 rounded-lg border border-[var(--color-border)] px-4 py-2 text-sm font-medium text-[var(--color-text)] hover:bg-[var(--color-surface-alt)] disabled:cursor-not-allowed disabled:opacity-50",children:[oe?l.jsx(Ct,{size:16,className:"animate-spin"}):l.jsx(vi,{size:16}),"Download + lock broker"]}),o==="options"&&l.jsxs("button",{onClick:()=>F({mqttAllowAnon:!0}),disabled:oe,title:"Download a compose that re-opens the MQTT broker to anonymous clients (allow_anonymous=true) — the transition/rollback state.",className:"flex items-center gap-2 rounded-lg border border-[var(--color-border)] px-4 py-2 text-sm font-medium text-[var(--color-text)] hover:bg-[var(--color-surface-alt)] disabled:cursor-not-allowed disabled:opacity-50",children:[oe?l.jsx(Ct,{size:16,className:"animate-spin"}):l.jsx(pS,{size:16}),"Download + unlock broker"]}),(o==="options"||o==="regenerate"||o==="apply"||o==="done")&&l.jsxs("button",{onClick:()=>a("/dashboard"),disabled:o==="regenerate"||o==="apply",className:"flex items-center gap-2 rounded-lg border border-[var(--color-border)] px-4 py-2 text-sm font-medium text-[var(--color-text)] hover:bg-[var(--color-surface-alt)] disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent",children:[l.jsx(ht,{size:16}),"Back to dashboard"]}),o==="error"&&l.jsxs("button",{onClick:ae,className:"flex items-center gap-2 rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm font-medium text-white hover:opacity-90",children:[l.jsx(it,{size:16}),"Retry"]})]})]})}async function A4(a={}){const{data:s}=await be.get("/api/traces",{params:a});return s}async function O4(a){const{data:s}=await be.get(`/api/traces/${a}`);return s}function Fx(a){return a<1e3?`${Math.round(a)}ms`:`${(a/1e3).toFixed(1)}s`}function Yx(a){return new Date(a).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function z4(a){const s=new Map;for(const o of a){const i=s.get(o.conversation_id);if(!i){s.set(o.conversation_id,{conversation_id:o.conversation_id,traces:[o],newest_at:o.created_at,user_command:o.user_command,assistant_message:o.assistant_message,source:o.source,node_id:o.node_id,household_id:o.household_id,total_duration_ms:o.total_duration_ms,status:o.status});continue}i.traces.push(o),i.total_duration_ms+=o.total_duration_ms,o.created_at>i.newest_at&&(i.newest_at=o.created_at),!i.user_command&&o.user_command&&(i.user_command=o.user_command),!i.assistant_message&&o.assistant_message&&(i.assistant_message=o.assistant_message),o.status!=="ok"&&(i.status=o.status)}return Array.from(s.values()).sort((o,i)=>o.newest_at<i.newest_at?1:-1)}function D4(a){return a==="mobile"?"📱":"🔊"}function U4(){const a=wa(),[s,o]=N.useState(""),[i,d]=N.useState(""),[f,m]=N.useState(""),[v,g]=N.useState(""),[h,y]=N.useState(new Set),x=yt({queryKey:["admin","households"],queryFn:KE,staleTime:6e4}),S=yt({queryKey:["admin","nodes"],queryFn:$E,staleTime:6e4}),{data:R,isLoading:w,error:E}=yt({queryKey:["traces",s,i,f,v],queryFn:()=>A4({limit:100,...s?{status:s}:{},...i?{source:i}:{},...f?{household_id:f}:{},...v?{node_id:v}:{}}),refetchInterval:1e4}),_=N.useMemo(()=>{const H=S.data??[];return f?H.filter(K=>K.household_id===f):H},[S.data,f]),O=N.useMemo(()=>{const H=new Map;for(const K of S.data??[])H.set(K.node_id,K.name);return H},[S.data]),k=N.useMemo(()=>{const H=new Map;for(const K of x.data??[])H.set(K.id,K.name);return H},[x.data]),Y=N.useMemo(()=>R?z4(R.traces):[],[R]);function I(H){y(K=>{const ie=new Set(K);return ie.has(H)?ie.delete(H):ie.add(H),ie})}function ne(H){if(m(H),H&&v){const K=(S.data??[]).find(ie=>ie.node_id===v);K&&K.household_id!==H&&g("")}}const ee="rounded border border-[var(--color-border)] bg-[var(--color-surface)] px-2 py-1 text-sm text-[var(--color-text)]";return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[l.jsx("h1",{className:"text-2xl font-bold text-[var(--color-text)]",children:"Request Traces"}),l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[l.jsxs("select",{className:ee,value:f,onChange:H=>ne(H.target.value),disabled:x.isLoading,children:[l.jsx("option",{value:"",children:"All households"}),(x.data??[]).map(H=>l.jsx("option",{value:H.id,children:H.name},H.id))]}),l.jsxs("select",{className:ee,value:v,onChange:H=>g(H.target.value),disabled:S.isLoading,children:[l.jsx("option",{value:"",children:"All nodes"}),_.map(H=>l.jsx("option",{value:H.node_id,children:H.name},H.node_id))]}),l.jsxs("select",{className:ee,value:s,onChange:H=>o(H.target.value),children:[l.jsx("option",{value:"",children:"All statuses"}),l.jsx("option",{value:"ok",children:"OK"}),l.jsx("option",{value:"error",children:"Error"})]}),l.jsxs("select",{className:ee,value:i,onChange:H=>d(H.target.value),children:[l.jsx("option",{value:"",children:"All sources"}),l.jsx("option",{value:"node",children:"Node"}),l.jsx("option",{value:"mobile",children:"Mobile"})]})]})]}),w&&l.jsx("div",{className:"flex justify-center py-12",children:l.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-[var(--color-primary)] border-t-transparent"})}),E&&l.jsx("div",{className:"rounded-lg border border-red-300 bg-red-50 p-4 text-red-700 dark:border-red-700 dark:bg-red-900/20 dark:text-red-400",children:"Failed to load traces"}),R&&l.jsxs(l.Fragment,{children:[l.jsxs("p",{className:"text-sm text-[var(--color-text-muted)]",children:[R.total," traces in ",Y.length," conversation",Y.length===1?"":"s"]}),l.jsx("div",{className:"overflow-x-auto rounded-lg border border-[var(--color-border)]",children:l.jsxs("table",{className:"w-full text-sm",children:[l.jsx("thead",{children:l.jsxs("tr",{className:"border-b border-[var(--color-border)] bg-[var(--color-surface-alt)]",children:[l.jsx("th",{className:"w-8 px-2 py-2"}),l.jsx("th",{className:"px-3 py-2 text-left font-medium text-[var(--color-text-muted)]",children:"Time"}),l.jsx("th",{className:"px-3 py-2 text-left font-medium text-[var(--color-text-muted)]",children:"Source"}),l.jsx("th",{className:"px-3 py-2 text-left font-medium text-[var(--color-text-muted)]",children:"Node"}),l.jsx("th",{className:"px-3 py-2 text-left font-medium text-[var(--color-text-muted)]",children:"User said"}),l.jsx("th",{className:"px-3 py-2 text-left font-medium text-[var(--color-text-muted)]",children:"Jarvis said"}),l.jsx("th",{className:"px-3 py-2 text-right font-medium text-[var(--color-text-muted)]",children:"Duration"}),l.jsx("th",{className:"px-3 py-2 text-center font-medium text-[var(--color-text-muted)]",children:"Status"}),l.jsx("th",{className:"px-3 py-2 text-right font-medium text-[var(--color-text-muted)]",children:"Traces"})]})}),l.jsxs("tbody",{children:[Y.map(H=>{const K=h.has(H.conversation_id),ie=H.traces.length,re=H.node_id?O.get(H.node_id)??H.node_id.slice(0,8):"-";return l.jsxs(N.Fragment,{children:[l.jsxs("tr",{className:"border-b border-[var(--color-border)] cursor-pointer transition-colors hover:bg-[var(--color-surface-alt)]",onClick:()=>I(H.conversation_id),children:[l.jsx("td",{className:"px-2 py-2 text-center text-[var(--color-text-muted)]",children:ie>1?K?"▼":"▶":""}),l.jsx("td",{className:"px-3 py-2 text-[var(--color-text)] whitespace-nowrap",children:Yx(H.newest_at)}),l.jsx("td",{className:"px-3 py-2 text-[var(--color-text-muted)]",children:l.jsxs("span",{className:"inline-flex items-center gap-1",children:[D4(H.source),H.source]})}),l.jsxs("td",{className:"px-3 py-2 text-[var(--color-text-muted)] whitespace-nowrap",children:[re,H.household_id&&l.jsxs("span",{className:"ml-1 text-xs opacity-60",children:["· ",k.get(H.household_id)??""]})]}),l.jsx("td",{className:"px-3 py-2 text-[var(--color-text)] max-w-xs truncate",children:H.user_command??"-"}),l.jsx("td",{className:"px-3 py-2 text-[var(--color-text-muted)] max-w-xs truncate",children:H.assistant_message??"-"}),l.jsx("td",{className:"px-3 py-2 text-right text-[var(--color-text)] tabular-nums",children:Fx(H.total_duration_ms)}),l.jsx("td",{className:"px-3 py-2 text-center",children:l.jsx("span",{className:`inline-block h-2 w-2 rounded-full ${H.status==="ok"?"bg-green-500":"bg-red-500"}`})}),l.jsx("td",{className:"px-3 py-2 text-right text-[var(--color-text-muted)] tabular-nums",children:ie})]}),K&&H.traces.slice().sort((oe,he)=>oe.created_at<he.created_at?-1:1).map(oe=>l.jsxs("tr",{className:"border-b border-[var(--color-border)] cursor-pointer bg-[var(--color-surface-alt)]/40 transition-colors hover:bg-[var(--color-surface-alt)]",onClick:()=>a(`/traces/${oe.id}`),children:[l.jsx("td",{className:"px-2 py-2"}),l.jsxs("td",{className:"px-3 py-2 text-[var(--color-text-muted)] whitespace-nowrap",children:[l.jsx("span",{className:"inline-block w-3"}),Yx(oe.created_at)]}),l.jsx("td",{className:"px-3 py-2 text-[var(--color-text-muted)] text-xs",children:oe.request_type}),l.jsx("td",{className:"px-3 py-2 text-[var(--color-text-muted)] whitespace-nowrap text-xs",children:oe.node_id?O.get(oe.node_id)??oe.node_id.slice(0,8):"-"}),l.jsx("td",{className:"px-3 py-2 text-[var(--color-text)] max-w-xs truncate",children:oe.user_command??"-"}),l.jsx("td",{className:"px-3 py-2 text-[var(--color-text-muted)] max-w-xs truncate",children:oe.assistant_message??"-"}),l.jsx("td",{className:"px-3 py-2 text-right text-[var(--color-text)] tabular-nums",children:Fx(oe.total_duration_ms)}),l.jsx("td",{className:"px-3 py-2 text-center",children:l.jsx("span",{className:`inline-block h-2 w-2 rounded-full ${oe.status==="ok"?"bg-green-500":"bg-red-500"}`})}),l.jsx("td",{className:"px-3 py-2 text-right text-[var(--color-text-muted)] tabular-nums",children:oe.span_count})]},oe.id))]},H.conversation_id)}),Y.length===0&&l.jsx("tr",{children:l.jsx("td",{colSpan:9,className:"px-3 py-8 text-center text-[var(--color-text-muted)]",children:"No traces yet"})})]})]})})]})]})}function ns(a){return a<1e3?`${Math.round(a)}ms`:`${(a/1e3).toFixed(1)}s`}const Xx={cc:"#9e9e9e",llm_proxy:"#42a5f5",node:"#66bb6a",tts:"#ffa726",whisper:"#ab47bc"},Kx={cc:"Command Center",llm_proxy:"LLM Proxy",node:"Node",tts:"TTS",whisper:"Whisper"};function L4(a){const s=a.filter(d=>d.duration_ms>0),o=s.filter(d=>!s.some(f=>f!==d&&d.start_ms<=f.start_ms&&d.end_ms>=f.end_ms&&f.duration_ms>0));o.sort((d,f)=>d.start_ms-f.start_ms);const i=[];for(const d of o){const f=i[i.length-1];f&&f.service===d.service?(f.duration_ms=Math.round((f.duration_ms+d.duration_ms)*10)/10,f.steps.push(d.name),d.status==="error"&&(f.status="error")):i.push({service:d.service,duration_ms:d.duration_ms,status:d.status,steps:[d.name]})}return i}function B4(){const{id:a}=A0(),s=wa(),[o,i]=N.useState(!1),[d,f]=N.useState(null),{data:m,isLoading:v,error:g}=yt({queryKey:["trace",a],queryFn:()=>O4(a),enabled:!!a}),h=N.useMemo(()=>m?L4(m.spans):[],[m]);return v?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-[var(--color-primary)] border-t-transparent"})}):g||!m?l.jsxs("div",{className:"space-y-4",children:[l.jsx("button",{className:"text-sm text-[var(--color-primary)] hover:underline",onClick:()=>s("/traces"),children:"Back to traces"}),l.jsx("div",{className:"rounded-lg border border-red-300 bg-red-50 p-4 text-red-700 dark:border-red-700 dark:bg-red-900/20 dark:text-red-400",children:"Trace not found"})]}):l.jsxs("div",{className:"space-y-6",children:[l.jsx("button",{className:"text-sm text-[var(--color-primary)] hover:underline",onClick:()=>s("/traces"),children:"Back to traces"}),l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-lg font-bold text-[var(--color-text)]",children:m.user_command??"Request Trace"}),l.jsxs("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:[m.source==="mobile"?"📱 Mobile":"🔊 Node",m.node_id&&` (${m.node_id})`," · ",m.request_type," · ",m.created_at?new Date(m.created_at).toLocaleString():""]})]}),l.jsxs("div",{className:"text-right",children:[l.jsx("div",{className:"text-2xl font-bold tabular-nums text-[var(--color-text)]",children:ns(m.total_duration_ms)}),l.jsxs("div",{className:"flex items-center justify-end gap-1 mt-1",children:[l.jsx("span",{className:`inline-block h-2 w-2 rounded-full ${m.status==="ok"?"bg-green-500":"bg-red-500"}`}),l.jsx("span",{className:"text-sm text-[var(--color-text-muted)]",children:m.status})]})]})]}),m.error_message&&l.jsx("div",{className:"mt-3 rounded border border-red-300 bg-red-50 p-2 text-sm text-red-700 dark:border-red-700 dark:bg-red-900/20 dark:text-red-400",children:m.error_message}),l.jsx("p",{className:"mt-2 text-xs text-[var(--color-text-muted)] font-mono",children:m.conversation_id})]}),l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsx("h2",{className:"mb-3 text-sm font-medium text-[var(--color-text-muted)]",children:"Service Flow"}),l.jsx("p",{className:"mb-4 text-xs text-[var(--color-text-muted)] opacity-60",children:h.map(y=>Kx[y.service]??y.service).join(" → ")}),l.jsx("div",{className:"space-y-2",children:h.map((y,x)=>{const S=Math.min(y.duration_ms/m.total_duration_ms*100,100),R=y.status==="error"?"#ef4444":Xx[y.service]??"#9e9e9e",w=Kx[y.service]??y.service;return l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:R}}),l.jsx("span",{className:"w-32 text-sm text-[var(--color-text)] shrink-0",children:w}),l.jsxs("div",{className:"flex-1 h-6 rounded bg-[var(--color-surface-alt)] relative",children:[l.jsx("div",{className:"absolute top-0 left-0 h-full rounded",style:{width:`${Math.max(S,1)}%`,backgroundColor:R,opacity:.7}}),l.jsx("span",{className:"absolute inset-0 flex items-center px-2 text-xs text-[var(--color-text)] opacity-70",children:y.steps.join(", ")})]}),l.jsx("span",{className:"w-16 text-sm text-[var(--color-text)] text-right tabular-nums shrink-0",children:ns(y.duration_ms)})]},`${y.service}-${x}`)})})]}),l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[l.jsxs("button",{className:"text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text)]",onClick:()=>{i(y=>!y),f(null)},children:[o?"Hide":"Show"," raw spans (",m.spans.length,")"]}),o&&l.jsx("div",{className:"mt-3 space-y-1",children:m.spans.map((y,x)=>{const S=Math.min(y.duration_ms/m.total_duration_ms*100,100),R=y.start_ms/m.total_duration_ms*100,w=y.status==="error"?"#ef4444":Xx[y.service]??"#9e9e9e",E=d===y;return l.jsxs("div",{className:`flex items-center gap-2 cursor-pointer rounded px-1 py-0.5 ${E?"bg-[var(--color-surface-alt)]":""}`,onClick:()=>f(E?null:y),children:[l.jsx("span",{className:"w-36 truncate text-xs text-[var(--color-text-muted)] text-right shrink-0",children:y.name}),l.jsx("div",{className:"flex-1 relative h-4 rounded bg-[var(--color-surface-alt)]",children:l.jsx("div",{className:"absolute top-0 h-full rounded",style:{left:`${R}%`,width:`${Math.max(S,.5)}%`,backgroundColor:w,minWidth:"2px"}})}),l.jsx("span",{className:"w-14 text-xs text-[var(--color-text-muted)] text-right shrink-0 tabular-nums",children:ns(y.duration_ms)}),l.jsx("span",{className:"w-16 text-xs text-[var(--color-text-muted)] opacity-60 shrink-0",children:y.service})]},`${y.name}-${x}`)})}),d&&o&&l.jsx("div",{className:"mt-3 border-t border-[var(--color-border)] pt-3",children:l.jsxs("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-sm max-w-md",children:[l.jsx("dt",{className:"text-[var(--color-text-muted)]",children:"Service"}),l.jsx("dd",{className:"text-[var(--color-text)]",children:d.service}),l.jsx("dt",{className:"text-[var(--color-text-muted)]",children:"Duration"}),l.jsx("dd",{className:"text-[var(--color-text)] tabular-nums",children:ns(d.duration_ms)}),l.jsx("dt",{className:"text-[var(--color-text-muted)]",children:"Start"}),l.jsx("dd",{className:"text-[var(--color-text)] tabular-nums",children:ns(d.start_ms)}),l.jsx("dt",{className:"text-[var(--color-text-muted)]",children:"End"}),l.jsx("dd",{className:"text-[var(--color-text)] tabular-nums",children:ns(d.end_ms)}),l.jsx("dt",{className:"text-[var(--color-text-muted)]",children:"Status"}),l.jsx("dd",{className:d.status==="ok"?"text-green-600":"text-red-600",children:d.status}),Object.entries(d.metadata||{}).map(([y,x])=>l.jsxs("div",{className:"contents",children:[l.jsx("dt",{className:"text-[var(--color-text-muted)]",children:y}),l.jsx("dd",{className:"text-[var(--color-text)] tabular-nums",children:String(x)})]},y))]})})]})]})}function q4(){return l.jsxs("div",{className:"flex min-h-[60vh] flex-col items-center justify-center",children:[l.jsx("h1",{className:"mb-2 text-4xl font-bold text-[var(--color-text)]",children:"404"}),l.jsx("p",{className:"mb-4 text-[var(--color-text-muted)]",children:"Page not found"}),l.jsx(Cd,{to:"/settings",className:"text-[var(--color-primary)] underline hover:opacity-80",children:"Go to Settings"})]})}const H4=7,G4={currentStep:0,totalSteps:H4,enabledModules:[],portOverrides:{},infraPortOverrides:{},secrets:{},dbUser:"jarvis",whisperModel:"base.en",whisperModelPath:"/whisper-models/ggml-base.en.bin",llmInterface:"Qwen25MediumUntrained",deploymentMode:"local",deploymentTarget:"standard",remoteLlmUrl:"",remoteWhisperUrl:"",platform:"linux",hardware:null,relayEnabled:!1,installRunning:!1,installComplete:!1,nativeServices:[]};function Q4(a,s,o){return Math.max(s,Math.min(o,a))}function V4(a,s){switch(s.type){case"SET_STEP":return{...a,currentStep:Q4(s.step,0,a.totalSteps-1)};case"NEXT_STEP":return{...a,currentStep:Math.min(a.currentStep+1,a.totalSteps-1)};case"PREV_STEP":return{...a,currentStep:Math.max(a.currentStep-1,0)};case"SET_ENABLED_MODULES":return{...a,enabledModules:s.modules};case"TOGGLE_MODULE":{if(s.enabled){const o=a.enabledModules.includes(s.serviceId)?a.enabledModules:[...a.enabledModules,s.serviceId];return{...a,enabledModules:o}}return{...a,enabledModules:a.enabledModules.filter(o=>o!==s.serviceId)}}case"SET_PORT_OVERRIDE":return{...a,portOverrides:{...a.portOverrides,[s.serviceId]:s.port}};case"SET_INFRA_PORT_OVERRIDE":return{...a,infraPortOverrides:{...a.infraPortOverrides,[s.infraId]:s.port}};case"SET_SECRET":return{...a,secrets:{...a.secrets,[s.name]:s.value}};case"SET_SECRETS":return{...a,secrets:s.secrets};case"SET_DB_USER":return{...a,dbUser:s.user};case"SET_WHISPER_MODEL":return{...a,whisperModel:s.model};case"SET_WHISPER_BACKEND":return{...a,whisperBackend:s.backend};case"SET_LLM_INTERFACE":return{...a,llmInterface:s.interfaceId};case"SET_DEPLOYMENT_MODE":return{...a,deploymentMode:s.mode};case"SET_DEPLOYMENT_TARGET":return{...a,deploymentTarget:s.target};case"SET_REMOTE_LLM_URL":return{...a,remoteLlmUrl:s.url};case"SET_REMOTE_WHISPER_URL":return{...a,remoteWhisperUrl:s.url};case"SET_PLATFORM":return{...a,platform:s.platform};case"SET_HARDWARE":return{...a,hardware:s.hardware,platform:s.hardware.platform};case"SET_RELAY_ENABLED":return{...a,relayEnabled:s.enabled};case"SET_INSTALL_RUNNING":return{...a,installRunning:s.running};case"SET_INSTALL_COMPLETE":return{...a,installRunning:!1,installComplete:!0};case"SET_NATIVE_SERVICES":return{...a,nativeServices:s.services};case"TOGGLE_NATIVE_SERVICE":{if(s.enabled){const o=a.nativeServices.includes(s.serviceId)?a.nativeServices:[...a.nativeServices,s.serviceId];return{...a,nativeServices:o}}return{...a,nativeServices:a.nativeServices.filter(o=>o!==s.serviceId)}}default:return a}}const Tg=N.createContext(null);function F4({children:a}){const[s,o]=N.useReducer(V4,G4);return l.jsx(Tg.Provider,{value:{state:s,dispatch:o},children:a})}function fr(){const a=N.useContext(Tg);if(!a)throw new Error("useWizard must be used within a WizardProvider");return a}function Y4(){const{state:a,dispatch:s}=fr(),[o,i]=N.useState(null),[d,f]=N.useState(!0),[m,v]=N.useState(!1);function g(){f(!0),v(!1),Yd().then(y=>{i(y);const x=y.reason==="docker_not_found";v(x),s(x?{type:"SET_INSTALL_RUNNING",running:!0}:{type:"SET_INSTALL_RUNNING",running:!1})}).catch(()=>{i({configured:!1,reason:"error"}),v(!0),s({type:"SET_INSTALL_RUNNING",running:!0})}).finally(()=>f(!1))}N.useEffect(()=>{g()},[]);const h=o&&o.reason!=="docker_not_found";return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Welcome to Jarvis"}),l.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Let's get your personal voice assistant up and running. This wizard will guide you through selecting services, configuring hardware, and starting everything up."})]}),l.jsx("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:l.jsxs("div",{className:"flex items-center gap-3",children:[d?l.jsx(Ct,{size:20,className:"animate-spin text-[var(--color-primary)]"}):h?l.jsx(ht,{size:20,className:"text-green-500"}):l.jsx(Bd,{size:20,className:"text-red-500"}),l.jsxs("div",{className:"flex-1",children:[l.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:d?"Checking Docker...":h?"Docker is running":"Docker not found"}),!d&&!h&&l.jsxs("div",{className:"mt-1 space-y-1",children:[l.jsx("p",{className:"text-xs text-red-400",children:"Docker is required to run Jarvis services."}),l.jsxs("p",{className:"text-xs text-[var(--color-text-muted)]",children:["Install"," ",l.jsx("a",{href:"https://www.docker.com/products/docker-desktop/",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--color-primary)] underline hover:no-underline",children:"Docker Desktop"})," ","for your platform, start it, then click Retry."]})]})]}),m&&!d&&l.jsxs("button",{type:"button",onClick:g,className:"flex items-center gap-1 rounded-md border border-[var(--color-border)] px-2 py-1 text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:[l.jsx(gi,{size:12}),"Retry"]})]})}),l.jsxs("div",{children:[l.jsx("label",{className:"mb-2 block text-sm font-medium text-[var(--color-text)]",children:"Deployment Mode"}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("button",{type:"button",onClick:()=>s({type:"SET_DEPLOYMENT_MODE",mode:"local"}),className:te("flex flex-col items-center gap-2 rounded-lg border p-4 transition-colors",a.deploymentMode==="local"?"border-[var(--color-primary)] bg-[var(--color-primary)]/10":"border-[var(--color-border)] hover:border-[var(--color-primary)]/50"),children:[l.jsx(NS,{size:24,className:"text-[var(--color-primary)]"}),l.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:"Local"}),l.jsx("span",{className:"text-xs text-center text-[var(--color-text-muted)]",children:"Everything on this machine"})]}),l.jsxs("button",{type:"button",onClick:()=>s({type:"SET_DEPLOYMENT_MODE",mode:"remote-llm"}),className:te("flex flex-col items-center gap-2 rounded-lg border p-4 transition-colors",a.deploymentMode==="remote-llm"?"border-[var(--color-primary)] bg-[var(--color-primary)]/10":"border-[var(--color-border)] hover:border-[var(--color-primary)]/50"),children:[l.jsx(Qd,{size:24,className:"text-[var(--color-primary)]"}),l.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:"Remote LLM"}),l.jsx("span",{className:"text-xs text-center text-[var(--color-text-muted)]",children:"LLM on separate GPU machine"})]})]})]})]})}const $o=[{label:"None / CPU only",gpu:null,gpuType:"none",vramMb:null,backends:["gguf"],defaultBackend:"gguf"},{label:"NVIDIA RTX 4090 (24 GB)",gpu:"NVIDIA RTX 4090",gpuType:"nvidia",vramMb:24576,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"NVIDIA RTX 4080 (16 GB)",gpu:"NVIDIA RTX 4080",gpuType:"nvidia",vramMb:16384,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"NVIDIA RTX 4070 Ti (12 GB)",gpu:"NVIDIA RTX 4070 Ti",gpuType:"nvidia",vramMb:12288,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"NVIDIA RTX 3090 (24 GB)",gpu:"NVIDIA RTX 3090",gpuType:"nvidia",vramMb:24576,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"NVIDIA RTX 3080 (10 GB)",gpu:"NVIDIA RTX 3080",gpuType:"nvidia",vramMb:10240,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"NVIDIA RTX 3070 (8 GB)",gpu:"NVIDIA RTX 3070",gpuType:"nvidia",vramMb:8192,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"NVIDIA A100 (80 GB)",gpu:"NVIDIA A100",gpuType:"nvidia",vramMb:81920,backends:["gguf","vllm"],defaultBackend:"vllm"},{label:"NVIDIA A100 (40 GB)",gpu:"NVIDIA A100",gpuType:"nvidia",vramMb:40960,backends:["gguf","vllm"],defaultBackend:"vllm"},{label:"NVIDIA Tesla T4 (16 GB)",gpu:"NVIDIA Tesla T4",gpuType:"nvidia",vramMb:16384,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"AMD RX 9070 XT — Vulkan (16 GB)",gpu:"AMD RX 9070 XT",gpuType:"amd",vramMb:16384,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 9070 — Vulkan (12 GB)",gpu:"AMD RX 9070",gpuType:"amd",vramMb:12288,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7900 XTX — Vulkan (24 GB)",gpu:"AMD RX 7900 XTX",gpuType:"amd",vramMb:24576,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7900 XT — Vulkan (20 GB)",gpu:"AMD RX 7900 XT",gpuType:"amd",vramMb:20480,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7800 XT — Vulkan (16 GB)",gpu:"AMD RX 7800 XT",gpuType:"amd",vramMb:16384,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7600 — Vulkan (8 GB)",gpu:"AMD RX 7600",gpuType:"amd",vramMb:8192,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 9070 XT — ROCm (16 GB)",gpu:"AMD RX 9070 XT",gpuType:"amd-rocm",vramMb:16384,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 9070 — ROCm (12 GB)",gpu:"AMD RX 9070",gpuType:"amd-rocm",vramMb:12288,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7900 XTX — ROCm (24 GB)",gpu:"AMD RX 7900 XTX",gpuType:"amd-rocm",vramMb:24576,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7900 XT — ROCm (20 GB)",gpu:"AMD RX 7900 XT",gpuType:"amd-rocm",vramMb:20480,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7800 XT — ROCm (16 GB)",gpu:"AMD RX 7800 XT",gpuType:"amd-rocm",vramMb:16384,backends:["gguf"],defaultBackend:"gguf"},{label:"Apple M4 Max (128 GB unified)",gpu:"Apple M4 Max",gpuType:"apple",vramMb:131072,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M4 Max (64 GB unified)",gpu:"Apple M4 Max",gpuType:"apple",vramMb:65536,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M4 Pro (48 GB unified)",gpu:"Apple M4 Pro",gpuType:"apple",vramMb:49152,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M4 Pro (24 GB unified)",gpu:"Apple M4 Pro",gpuType:"apple",vramMb:24576,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M2 Max (32 GB unified)",gpu:"Apple M2 Max",gpuType:"apple",vramMb:32768,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M2 Pro (16 GB unified)",gpu:"Apple M2 Pro",gpuType:"apple",vramMb:16384,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M1 (16 GB unified)",gpu:"Apple M1",gpuType:"apple",vramMb:16384,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M1 (8 GB unified)",gpu:"Apple M1",gpuType:"apple",vramMb:8192,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Other (enter VRAM manually)",gpu:"Other",gpuType:"none",vramMb:null,backends:["gguf"],defaultBackend:"gguf"}];function X4(){const{state:a,dispatch:s}=fr(),[o,i]=N.useState(!a.hardware),[d,f]=N.useState(!1),[m,v]=N.useState(0),[g,h]=N.useState("");N.useEffect(()=>{a.hardware||AE().then(S=>{s({type:"SET_HARDWARE",hardware:S}),S.recommendedBackend==="remote"&&a.deploymentMode==="local"&&s({type:"SET_DEPLOYMENT_MODE",mode:"remote-llm"})}).catch(()=>{}).finally(()=>i(!1))},[]);function y(S,R){const w=$o[S];if(!a.hardware)return;const E=w.gpu==="Other"?(parseInt(R??g,10)||0)*1024:w.vramMb,_={...a.hardware,gpuName:w.gpu,gpuVramMb:E||null,gpuType:w.gpuType,recommendedBackends:[...w.backends],recommendedBackend:w.defaultBackend};s({type:"SET_HARDWARE",hardware:_})}const x=a.hardware;return o?l.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[l.jsx(Ct,{size:32,className:"animate-spin text-[var(--color-primary)]"}),l.jsx("p",{className:"mt-3 text-sm text-[var(--color-text-muted)]",children:"Detecting hardware..."})]}):l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Hardware Detection"}),l.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"We detected the following hardware. This determines which LLM backend to use."})]}),x&&l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:[l.jsxs("div",{className:"flex items-center gap-2 text-[var(--color-text-muted)]",children:[l.jsx(On,{size:16}),l.jsx("span",{className:"text-xs font-medium uppercase",children:"Platform"})]}),l.jsxs("p",{className:"mt-1 text-sm font-medium text-[var(--color-text)]",children:[x.platform==="darwin"?"macOS":"Linux"," (",x.arch,")"]})]}),l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:[l.jsxs("div",{className:"flex items-center gap-2 text-[var(--color-text-muted)]",children:[l.jsx(Hd,{size:16}),l.jsx("span",{className:"text-xs font-medium uppercase",children:"Memory"})]}),l.jsxs("p",{className:"mt-1 text-sm font-medium text-[var(--color-text)]",children:[x.totalMemoryGb," GB RAM"]})]}),l.jsxs("div",{className:"col-span-2 rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2 text-[var(--color-text-muted)]",children:[l.jsx(On,{size:16}),l.jsx("span",{className:"text-xs font-medium uppercase",children:"GPU"})]}),l.jsx("p",{className:"mt-1 text-sm font-medium text-[var(--color-text)]",children:x.gpuName??"No GPU detected"}),x.gpuVramMb!=null&&x.gpuVramMb>0&&l.jsxs("p",{className:"text-xs text-[var(--color-text-muted)]",children:[Math.round(x.gpuVramMb/1024)," GB VRAM"]})]}),l.jsx("button",{type:"button",onClick:()=>f(!d),className:"text-xs font-medium text-[var(--color-primary)] hover:underline",children:d?"Cancel":"Override"})]}),d&&l.jsxs("div",{className:"mt-3 space-y-3 border-t border-[var(--color-border)] pt-3",children:[l.jsxs("div",{children:[l.jsx("label",{htmlFor:"gpu-select",className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Select GPU"}),l.jsx("select",{id:"gpu-select",value:m,onChange:S=>{const R=parseInt(S.target.value,10);v(R),$o[R].gpu!=="Other"&&(y(R),f(!1))},className:te("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]"),children:$o.map((S,R)=>l.jsx("option",{value:R,children:S.label},`${S.label}-${R}`))})]}),$o[m].gpu==="Other"&&l.jsxs("div",{className:"flex items-end gap-2",children:[l.jsxs("div",{className:"flex-1",children:[l.jsx("label",{htmlFor:"custom-vram",className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"VRAM (GB)"}),l.jsx("input",{id:"custom-vram",type:"number",min:1,max:512,value:g,onChange:S=>h(S.target.value),placeholder:"e.g. 24",className:te("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]")})]}),l.jsx("button",{type:"button",disabled:!g||parseInt(g,10)<=0,onClick:()=>{y(m,g),f(!1)},className:te("rounded-lg px-4 py-2 text-sm font-medium","bg-[var(--color-primary)] text-white","disabled:cursor-not-allowed disabled:opacity-50"),children:"Apply"})]})]})]}),l.jsxs("div",{className:"col-span-2 rounded-lg border border-[var(--color-primary)]/30 bg-[var(--color-primary)]/5 p-4",children:[l.jsxs("p",{className:"text-sm font-medium text-[var(--color-text)]",children:["Recommended: ",l.jsx("span",{className:"text-[var(--color-primary)]",children:x.recommendedBackend.toUpperCase()})]}),x.recommendedBackends.length>1&&l.jsxs("p",{className:"mt-0.5 text-xs text-[var(--color-text-muted)]",children:["Available backends: ",x.recommendedBackends.join(", ")]})]})]}),a.deploymentMode==="remote-llm"&&l.jsxs("div",{className:"space-y-3",children:[l.jsx("h3",{className:"text-sm font-medium text-[var(--color-text)]",children:"Remote Service URLs"}),l.jsxs("div",{children:[l.jsx("label",{htmlFor:"remote-llm",className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"LLM Proxy URL"}),l.jsx("input",{id:"remote-llm",type:"url",value:a.remoteLlmUrl,onChange:S=>s({type:"SET_REMOTE_LLM_URL",url:S.target.value}),placeholder:"http://192.168.1.100:7704",className:te("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]")})]}),l.jsxs("div",{children:[l.jsx("label",{htmlFor:"remote-whisper",className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Whisper URL (optional)"}),l.jsx("input",{id:"remote-whisper",type:"url",value:a.remoteWhisperUrl,onChange:S=>s({type:"SET_REMOTE_WHISPER_URL",url:S.target.value}),placeholder:"http://192.168.1.100:7706",className:te("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]")})]})]})]})}function K4(){const{state:a,dispatch:s}=fr(),[o,i]=N.useState(null),[d,f]=N.useState(!0);if(N.useEffect(()=>{Promise.all([jg(),OE()]).then(([h,y])=>{if(i(h),a.enabledModules.length===0&&s({type:"SET_ENABLED_MODULES",modules:y.enabledModules}),a.platform==="darwin"&&a.nativeServices.length===0){const x=h.services.filter(S=>S.nativeCapable).map(S=>S.id);x.length>0&&s({type:"SET_NATIVE_SERVICES",services:x})}}).catch(()=>{}).finally(()=>f(!1))},[]),d||!o)return l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx(Ct,{size:32,className:"animate-spin text-[var(--color-primary)]"})});const{core:m,recommended:v,optional:g}=$4(o.services);return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Select Services"}),l.jsxs("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:["Core services are always included. Toggle recommended and optional services.",a.platform==="darwin"&&l.jsxs(l.Fragment,{children:[" Services marked ",l.jsx("em",{children:"Native"})," can run as macOS LaunchAgents to use the Apple GPU."]})]})]}),l.jsx(Pu,{title:"Core",subtitle:"Always included",services:m,enabled:m.map(h=>h.id),nativeServices:a.nativeServices,platform:a.platform,locked:!0}),l.jsx(Pu,{title:"Recommended",subtitle:"Enabled by default",services:v,enabled:a.enabledModules,nativeServices:a.nativeServices,platform:a.platform,onToggle:(h,y)=>s({type:"TOGGLE_MODULE",serviceId:h,enabled:y}),onToggleNative:(h,y)=>s({type:"TOGGLE_NATIVE_SERVICE",serviceId:h,enabled:y})}),g.length>0&&l.jsx(Pu,{title:"Optional",subtitle:"Off by default",services:g,enabled:a.enabledModules,nativeServices:a.nativeServices,platform:a.platform,onToggle:(h,y)=>s({type:"TOGGLE_MODULE",serviceId:h,enabled:y}),onToggleNative:(h,y)=>s({type:"TOGGLE_NATIVE_SERVICE",serviceId:h,enabled:y})}),l.jsxs("div",{children:[l.jsxs("div",{className:"mb-2 flex items-baseline gap-2",children:[l.jsx("h3",{className:"text-sm font-medium text-[var(--color-text)]",children:"Integrations"}),l.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:"Cloud services"})]}),l.jsxs("button",{type:"button",onClick:()=>s({type:"SET_RELAY_ENABLED",enabled:!a.relayEnabled}),className:te("flex w-full items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",a.relayEnabled?"border-[var(--color-primary)]/30 bg-[var(--color-primary)]/5":"border-[var(--color-border)] hover:border-[var(--color-primary)]/30"),children:[a.relayEnabled?l.jsx(ht,{size:16,className:"shrink-0 text-[var(--color-primary)]"}):l.jsx(os,{size:16,className:"shrink-0 text-[var(--color-text-muted)]"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:"Jarvis Relay"}),l.jsx(nS,{size:12,className:"text-[var(--color-text-muted)]"})]}),l.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:"Routes OAuth callbacks through a cloud relay for external providers (Google, Spotify, etc.)"})]})]})]})]})}function $4(a){return{core:a.filter(s=>s.category==="core"),recommended:a.filter(s=>s.category==="recommended"),optional:a.filter(s=>s.category==="optional")}}function Pu({title:a,subtitle:s,services:o,enabled:i,nativeServices:d,locked:f,onToggle:m,onToggleNative:v,platform:g}){return l.jsxs("div",{children:[l.jsxs("div",{className:"mb-2 flex items-baseline gap-2",children:[l.jsx("h3",{className:"text-sm font-medium text-[var(--color-text)]",children:a}),l.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:s})]}),l.jsx("div",{className:"space-y-1",children:o.map(h=>{const y=i.includes(h.id),x=h.nativeCapable&&g==="darwin"&&y,S=d.includes(h.id);return l.jsxs("div",{className:te("rounded-lg border transition-colors",y?"border-[var(--color-primary)]/30 bg-[var(--color-primary)]/5":"border-[var(--color-border)]",!f&&!y&&"hover:border-[var(--color-primary)]/30"),children:[l.jsxs("button",{type:"button",disabled:f,onClick:()=>m?.(h.id,!y),className:te("flex w-full items-center gap-3 px-3 py-2.5 text-left",f&&"cursor-default"),children:[f?l.jsx(vi,{size:16,className:"shrink-0 text-[var(--color-text-muted)]"}):y?l.jsx(ht,{size:16,className:"shrink-0 text-[var(--color-primary)]"}):l.jsx(os,{size:16,className:"shrink-0 text-[var(--color-text-muted)]"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:h.name}),l.jsxs("span",{className:"text-xs text-[var(--color-text-muted)]",children:[":",h.port]}),h.nativeCapable&&g==="darwin"&&l.jsx("span",{className:"rounded bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-medium text-amber-500",children:"Native"})]}),l.jsx("p",{className:"truncate text-xs text-[var(--color-text-muted)]",children:h.description})]})]}),x&&l.jsxs("button",{type:"button",onClick:()=>v?.(h.id,!S),className:te("flex w-full items-center gap-2 border-t border-[var(--color-border)]/50 px-3 py-2 text-left text-xs","hover:bg-[var(--color-surface-alt)] transition-colors"),children:[l.jsx(On,{size:12,className:S?"text-amber-500":"text-[var(--color-text-muted)]"}),l.jsx("span",{className:S?"text-[var(--color-text)]":"text-[var(--color-text-muted)]",children:"Run natively via LaunchAgent"}),l.jsx("span",{className:"ml-auto text-[var(--color-text-muted)]",children:S?"On (uses Apple GPU)":"Off (runs in Docker)"})]})]},h.id)})})]})}function Z4(){const{state:a}=fr(),[s,o]=N.useState(null);if(N.useEffect(()=>{jg().then(o).catch(()=>{})},[]),!s)return l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx(Ct,{size:32,className:"animate-spin text-[var(--color-primary)]"})});const i=s.services.filter(x=>x.category==="core"),d=s.services.filter(x=>x.category!=="core"&&a.enabledModules.includes(x.id)),f=[...i,...d],m=new Map;for(const x of f){const S=a.portOverrides[x.id]??x.port,R=m.get(S)??[];m.set(S,[...R,x.name])}const v=[...m.entries()].filter(([,x])=>x.length>1),g=f.filter(x=>x.database).length,h=f.filter(x=>a.nativeServices.includes(x.id)),y=f.filter(x=>!a.nativeServices.includes(x.id));return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Review Configuration"}),l.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Review your selections before installing."})]}),l.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[l.jsx(Iu,{label:"Docker Services",value:y.length}),l.jsx(Iu,{label:"Native Services",value:h.length}),l.jsx(Iu,{label:"Databases",value:g})]}),l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:[l.jsx("p",{className:"text-xs font-medium uppercase text-[var(--color-text-muted)]",children:"Deployment Mode"}),l.jsx("p",{className:"mt-1 text-sm font-medium text-[var(--color-text)]",children:a.deploymentMode==="local"?"Local (all services on this machine)":"Remote LLM"}),a.deploymentMode==="remote-llm"&&a.remoteLlmUrl&&l.jsxs("p",{className:"mt-0.5 text-xs text-[var(--color-text-muted)]",children:["LLM: ",a.remoteLlmUrl]})]}),l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] overflow-hidden",children:[l.jsx("div",{className:"border-b border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2",children:l.jsxs("span",{className:"text-xs font-medium text-[var(--color-text-muted)]",children:["Services (",f.length,")"]})}),l.jsx("div",{className:"divide-y divide-[var(--color-border)]",children:f.map(x=>l.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(ht,{size:14,className:"text-green-500"}),l.jsx("span",{className:"text-sm text-[var(--color-text)]",children:x.name})]}),l.jsxs("span",{className:"text-xs text-[var(--color-text-muted)]",children:[":",a.portOverrides[x.id]??x.port]})]},x.id))})]}),a.relayEnabled&&l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:[l.jsx("p",{className:"text-xs font-medium uppercase text-[var(--color-text-muted)]",children:"Jarvis Relay"}),l.jsx("p",{className:"mt-1 text-sm font-medium text-[var(--color-text)]",children:"Enabled"}),l.jsx("p",{className:"mt-0.5 text-xs text-[var(--color-text-muted)]",children:"https://relay.jarvisautomation.io"})]}),v.length>0&&l.jsxs("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-4",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(ra,{size:16,className:"text-amber-500"}),l.jsx("span",{className:"text-sm font-medium text-amber-500",children:"Port Conflicts"})]}),v.map(([x,S])=>l.jsxs("p",{className:"mt-1 text-xs text-[var(--color-text-muted)]",children:["Port ",x,": ",S.join(", ")]},x))]})]})}function Iu({label:a,value:s}){return l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-3 text-center",children:[l.jsx("p",{className:"text-2xl font-bold text-[var(--color-primary)]",children:s}),l.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:a})]})}function Wu(){const[a,s]=N.useState({lines:[],running:!1,done:!1,exitCode:null,error:null,redirect:null}),o=N.useRef(null),i=N.useCallback((f,m)=>(o.current?.close(),s({lines:[],running:!0,done:!1,exitCode:null,error:null,redirect:null}),new Promise((v,g)=>{const h=new EventSource(f);o.current=h,h.onmessage=y=>{try{const x=JSON.parse(y.data);if(m&&m(x),"done"in x){if(s(S=>({...S,running:!1,done:!0,exitCode:x.code,redirect:x.redirect??null})),h.close(),x.code===0)v(x.code);else{const S=x.error?String(x.error):`Process exited with code ${x.code}`;g(new Error(S))}return}if("stream"in x&&"text"in x){const S={stream:x.stream,text:x.text,timestamp:Date.now()};s(R=>({...R,lines:[...R.lines,S]}))}}catch{}},h.onerror=()=>{const y=o.current===null;s(x=>({...x,running:!1,error:x.done?null:"Connection lost"})),h.close(),y||g(new Error("Connection lost"))}})),[]),d=N.useCallback(()=>{o.current?.close(),o.current=null,s(f=>({...f,running:!1}))},[]);return{...a,run:i,stop:d}}function ed({lines:a,running:s,title:o,className:i}){const d=N.useRef(null),f=N.useRef(!0);N.useEffect(()=>{const v=d.current;!v||!f.current||(v.scrollTop=v.scrollHeight)},[a]);function m(){const v=d.current;if(!v)return;const g=v.scrollHeight-v.scrollTop-v.clientHeight;f.current=g<50}return l.jsxs("div",{className:te("flex flex-col rounded-lg border border-[var(--color-border)] overflow-hidden",i),children:[o&&l.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--color-border)] bg-[var(--color-surface)] px-3 py-2",children:[l.jsx("span",{className:"text-xs font-medium text-[var(--color-text-muted)]",children:o}),s&&l.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-green-500"})]}),l.jsxs("div",{ref:d,onScroll:m,className:"h-64 overflow-y-auto bg-[#0d1117] p-3 font-mono text-xs leading-5",children:[a.length===0&&!s&&l.jsx("span",{className:"text-gray-500",children:"Waiting for output..."}),a.map((v,g)=>l.jsx("div",{className:te("whitespace-pre-wrap break-all",v.stream==="stderr"?"text-yellow-400":"text-gray-300"),children:v.text},g)),s&&l.jsx("span",{className:"inline-block h-4 w-1.5 animate-pulse bg-gray-400"})]})]})}function J4(){const{state:a,dispatch:s}=fr(),o=Wu(),i=Wu(),d=Wu(),[f,m]=N.useState("idle"),[v,g]=N.useState(null),[h,y]=N.useState(null),[x,S]=N.useState({}),[R,w]=N.useState({}),[E,_]=N.useState(null),[O,k]=N.useState(null),[Y,I]=N.useState(null),[ne,ee]=N.useState({});N.useEffect(()=>{const ae=i.redirect;if(f!=="done"||!ae||a.platform==="darwin")return;k(5);const C=setInterval(()=>{k(F=>F===null||F<=1?(clearInterval(C),window.location.href=ae,0):F-1)},1e3);return()=>clearInterval(C)},[f,i.redirect]);const H=N.useCallback(async()=>{m("preflight"),y(null),g(null);try{const ae=await ME(a.enabledModules);return y(ae),ae.canProceed?!0:(g("Pre-flight checks failed. Fix the issues above and retry."),m("error"),_("preflight"),!1)}catch(ae){return g(`Pre-flight check failed: ${ae instanceof Error?ae.message:String(ae)}`),m("error"),_("preflight"),!1}},[a.enabledModules]);async function K(){if(a.nativeServices.length!==0){m("native");for(const ae of a.nativeServices){I(ae);try{await d.run(`/api/native-services/${ae}/install`),ee(C=>({...C,[ae]:{ok:!0}}))}catch(C){const F=C instanceof Error?C.message:String(C);ee(X=>({...X,[ae]:{ok:!1,error:F}}))}}I(null)}}async function ie(){g(null),S({}),_(null),ee({}),s({type:"SET_INSTALL_RUNNING",running:!0});try{if(!await H()){s({type:"SET_INSTALL_RUNNING",running:!1});return}m("generating"),await Bx(a),m("pulling"),await o.run("/api/install/pull"),m("starting"),await i.run("/api/install/start",C=>{if(C.phase==="health"&&typeof C.service=="string"&&S(F=>({...F,[C.service]:{healthy:C.healthy,error:C.error}})),C.serviceHealth&&typeof C.serviceHealth=="object"){const F=C.serviceHealth;S(X=>({...X,...F}))}}),await K(),m("done"),s({type:"SET_INSTALL_COMPLETE"})}catch(ae){g(ae instanceof Error?ae.message:String(ae)),m("error"),_(f),s({type:"SET_INSTALL_RUNNING",running:!1})}}async function re(){if(E==="preflight"){if(g(null),s({type:"SET_INSTALL_RUNNING",running:!0}),!await H()){s({type:"SET_INSTALL_RUNNING",running:!1});return}try{m("generating"),await Bx(a),m("pulling"),await o.run("/api/install/pull"),m("starting"),await i.run("/api/install/start",C=>{if(C.phase==="health"&&typeof C.service=="string"&&S(F=>({...F,[C.service]:{healthy:C.healthy,error:C.error}})),C.serviceHealth&&typeof C.serviceHealth=="object"){const F=C.serviceHealth;S(X=>({...X,...F}))}}),await K(),m("done"),s({type:"SET_INSTALL_COMPLETE"})}catch(C){g(C instanceof Error?C.message:String(C)),m("error"),s({type:"SET_INSTALL_RUNNING",running:!1})}}else ie()}async function oe(ae){try{const C=await fetch(`/api/containers/${ae}/logs`);if(C.ok){const F=await C.text();w(X=>({...X,[ae]:F}))}else w(F=>({...F,[ae]:`Failed to fetch logs: HTTP ${C.status}`}))}catch(C){w(F=>({...F,[ae]:`Failed to fetch logs: ${C instanceof Error?C.message:String(C)}`}))}}const he=[{key:"preflight",label:"Pre-flight checks"},{key:"generating",label:"Generate configuration"},{key:"pulling",label:"Pull Docker images"},{key:"starting",label:"Start services"},...a.nativeServices.length>0?[{key:"native",label:`Install ${a.nativeServices.length} native service${a.nativeServices.length===1?"":"s"}`}]:[]],Te=he.map(ae=>ae.key).indexOf(f);return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Install"}),l.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:f==="idle"?"Ready to install. This will pull Docker images and start all services.":f==="done"?i.redirect&&a.platform!=="darwin"?`Installation complete! Redirecting to your admin dashboard in ${O??"..."}s...`:"Installation complete! Click Next to create your account and choose your models.":f==="error"?"Installation encountered an error.":"Installing..."})]}),h&&l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] overflow-hidden",children:[l.jsx("div",{className:"border-b border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2",children:l.jsx("span",{className:"text-xs font-medium text-[var(--color-text-muted)]",children:"Pre-flight Checks"})}),l.jsx("div",{className:"divide-y divide-[var(--color-border)]",children:h.checks.map(ae=>l.jsx("div",{className:"flex items-center justify-between px-3 py-2",children:l.jsxs("div",{className:"flex items-center gap-2",children:[ae.status==="pass"?l.jsx(ht,{size:14,className:"text-green-500"}):ae.status==="warn"?l.jsx(ra,{size:14,className:"text-amber-500"}):l.jsx(xl,{size:14,className:"text-red-500"}),l.jsxs("div",{children:[l.jsx("span",{className:"text-sm text-[var(--color-text)]",children:ae.name}),l.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:ae.message}),ae.details&&ae.status!=="pass"&&l.jsx("p",{className:"text-xs text-[var(--color-text-muted)] opacity-60",children:ae.details})]})]})},ae.name))})]}),l.jsx("div",{className:"space-y-2",children:he.map((ae,C)=>{const F=ae.key===f,X=Te>C||f==="done",ve=f==="error"&&ae.key===E;return l.jsxs("div",{className:"flex items-center gap-3",children:[X?l.jsx(ht,{size:18,className:"text-green-500"}):ve?l.jsx(xl,{size:18,className:"text-red-500"}):F?l.jsx(Ct,{size:18,className:"animate-spin text-[var(--color-primary)]"}):l.jsx("div",{className:"h-[18px] w-[18px] rounded-full border-2 border-[var(--color-border)]"}),l.jsx("span",{className:te("text-sm",X?"text-green-500":F?"font-medium text-[var(--color-text)]":"text-[var(--color-text-muted)]"),children:ae.label})]},ae.key)})}),(f==="starting"||f==="done"||f==="error")&&Object.keys(x).length>0&&l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] overflow-hidden",children:[l.jsx("div",{className:"border-b border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2",children:l.jsx("span",{className:"text-xs font-medium text-[var(--color-text-muted)]",children:"Service Status"})}),l.jsx("div",{className:"divide-y divide-[var(--color-border)]",children:Object.entries(x).map(([ae,C])=>l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[l.jsx("span",{className:"text-sm text-[var(--color-text)]",children:ae}),l.jsxs("div",{className:"flex items-center gap-2",children:[!C.healthy&&l.jsxs("button",{type:"button",onClick:()=>oe(ae),className:"flex items-center gap-1 text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:[l.jsx(ag,{size:12}),"Logs"]}),C.healthy?l.jsx(ht,{size:14,className:"text-green-500"}):l.jsx(xl,{size:14,className:"text-red-500"})]})]}),C.error&&l.jsx("p",{className:"px-3 pb-2 text-xs text-red-400",children:C.error}),R[ae]&&l.jsx("div",{className:"mx-3 mb-2 max-h-32 overflow-auto rounded bg-[var(--color-background)] p-2 text-xs font-mono text-[var(--color-text-muted)]",children:l.jsx("pre",{className:"whitespace-pre-wrap",children:R[ae]})})]},ae))})]}),(o.lines.length>0||o.running)&&l.jsx(ed,{lines:o.lines,running:o.running,title:"docker compose pull"}),(i.lines.length>0||i.running)&&l.jsx(ed,{lines:i.lines,running:i.running,title:"docker compose up -d"}),(f==="native"||Object.keys(ne).length>0)&&l.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] overflow-hidden",children:[l.jsx("div",{className:"border-b border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2",children:l.jsx("span",{className:"text-xs font-medium text-[var(--color-text-muted)]",children:"Native Services (LaunchAgents)"})}),l.jsx("div",{className:"divide-y divide-[var(--color-border)]",children:a.nativeServices.map(ae=>{const C=ne[ae],F=Y===ae&&f==="native";return l.jsxs("div",{className:"px-3 py-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-[var(--color-text)]",children:ae}),C?.ok?l.jsx(ht,{size:14,className:"text-green-500"}):C?l.jsx(xl,{size:14,className:"text-red-500"}):F?l.jsx(Ct,{size:14,className:"animate-spin text-[var(--color-primary)]"}):l.jsx("div",{className:"h-3 w-3 rounded-full border border-[var(--color-border)]"})]}),C?.error&&l.jsx("p",{className:"mt-1 text-xs text-red-400",children:C.error})]},ae)})})]}),(d.lines.length>0||d.running)&&l.jsx(ed,{lines:d.lines,running:d.running,title:Y?`deploy-launchd.sh (${Y})`:"deploy-launchd.sh"}),v&&l.jsx("div",{className:"rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-500",children:v}),(f==="idle"||f==="error")&&l.jsxs("button",{type:"button",onClick:f==="error"?re:ie,className:te("flex w-full items-center justify-center gap-2 rounded-lg bg-[var(--color-primary)] px-4 py-3 font-medium text-white","hover:opacity-90 transition-opacity"),children:[f==="error"?l.jsx(gi,{size:18}):l.jsx(ng,{size:18}),f==="error"?"Retry Installation":"Start Installation"]})]})}const $x="jarvis-whisper-api",P4="jarvis-llm-proxy-api";function I4(){const{state:a,dispatch:s}=fr(),o=Ng(),i=Cg(),d=gg(),f=wg(),m=a.platform==="darwin",[v,g]=N.useState("select"),[h,y]=N.useState(null),[x,S]=N.useState("GGUF"),[R,w]=N.useState(""),[E,_]=N.useState(!0),[O,k]=N.useState(null);if(a.deploymentMode==="remote-llm")return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Models"}),l.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Your LLM is configured to use a remote server."})]}),l.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-green-500/30 bg-green-500/5 p-4",children:[l.jsx(ht,{size:20,className:"text-green-500"}),l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:"Remote LLM configured"}),l.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:a.remoteLlmUrl})]})]})]});const Y=async()=>{await d.mutateAsync({serviceName:$x,key:"whisper.allow_model_autodownload",value:!0}),m&&await f.mutateAsync($x)},I=re=>{y(re),k(null),re.gated&&!R.trim()?g("token"):ee(re,R.trim())},ne=()=>{if(!R.trim()){k("HuggingFace token is required for gated models");return}h&&ee(h,R)},ee=async(re,oe)=>{if(k(null),E){g("whisper");try{await Y()}catch(Te){k(`Whisper model setup failed: ${Te.message}`),g("select");return}}g("downloading");const he=x==="GGUF"?re.hfRepoGguf:re.hfRepoVllm,Ee=x==="GGUF"?re.ggufFilename:void 0;try{await i.mutateAsync({repo:he,filename:Ee,token:oe||void 0}),await H(re)}catch(Te){k(`Download failed: ${Te.message}`),g("select")}},H=async re=>{g("configuring");const he={"model.main.name":x==="GGUF"?`.models/${re.ggufFilename}`:`.models/${re.hfRepoVllm.split("/").pop()}`,"model.main.backend":x,"model.main.chat_format":re.chatFormat,"model.main.context_window":re.contextWindow,"llm.interface":re.promptProvider};x==="GGUF"&&(he["inference.gguf.n_gpu_layers"]=-1),x==="VLLM"&&re.quantization&&(he["inference.vllm.quantization"]=re.quantization);try{await o.mutateAsync(he),m&&await f.mutateAsync(P4),s({type:"SET_LLM_INTERFACE",interfaceId:re.promptProvider}),g("done")}catch(Ee){k(`Configuration failed: ${Ee.message}`),g("select")}},K=a.hardware?.gpuVramMb,ie=K?ss.filter(re=>re.vramMb<=K):ss;return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Models"}),l.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:v==="done"?"Models configured. Services are restarting to load them.":"Choose a language model, and optionally fetch the speech-to-text model."})]}),O&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-red-500/30 bg-red-500/10 p-3 text-sm text-red-500",children:[l.jsx(ra,{size:16,className:"mt-0.5 shrink-0"}),O]}),h&&l.jsxs("button",{type:"button",onClick:()=>ee(h,R),className:te("flex w-full items-center justify-center gap-2 rounded-lg border border-[var(--color-border)] px-4 py-2 text-sm","hover:bg-[var(--color-surface-alt)] transition-colors"),children:[l.jsx(gi,{size:14}),"Retry"]})]}),v==="select"&&l.jsxs(l.Fragment,{children:[!m&&l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:"Backend"}),l.jsx("div",{className:"flex gap-2",children:["GGUF","VLLM"].map(re=>l.jsx("button",{type:"button",onClick:()=>S(re),className:te("rounded-md px-3 py-1 text-xs font-medium transition-colors",x===re?"bg-[var(--color-primary)] text-white":"bg-[var(--color-surface-alt)] text-[var(--color-text-muted)] hover:text-[var(--color-text)]"),children:re==="VLLM"?"vLLM":re},re))})]}),l.jsxs("label",{className:te("flex cursor-pointer items-start gap-3 rounded-lg border p-3 transition-colors",E?"border-[var(--color-primary)] bg-[var(--color-primary)]/5":"border-[var(--color-border)]"),children:[l.jsx("input",{type:"checkbox",checked:E,onChange:re=>_(re.target.checked),className:"mt-0.5"}),l.jsxs("span",{className:"flex items-center gap-2 text-sm text-[var(--color-text)]",children:[l.jsx(kx,{size:15,className:"shrink-0 text-[var(--color-primary)]"}),l.jsxs("span",{children:["Auto-download the speech-to-text model",l.jsxs("span",{className:"block text-xs text-[var(--color-text-muted)]",children:["Whisper ",l.jsx("code",{children:"base.en"})," (~150 MB, no token needed). Required for voice."]})]})]})]}),l.jsxs("div",{children:[l.jsx("label",{htmlFor:"hf-token",className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"HuggingFace Token (optional — speeds up downloads, required for gated models)"}),l.jsx("input",{id:"hf-token",type:"password",value:R,onChange:re=>w(re.target.value),placeholder:"hf_...",className:te("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]")})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:"Language model"}),ie.map(re=>l.jsxs("button",{type:"button",onClick:()=>I(re),className:te("flex w-full items-center justify-between rounded-lg border border-[var(--color-border)] p-3 text-left transition-colors","hover:border-[var(--color-primary)] hover:bg-[var(--color-surface-alt)]"),children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:re.displayName}),re.gated&&l.jsxs("span",{className:"flex items-center gap-0.5 rounded bg-yellow-500/15 px-1.5 py-0.5 text-[10px] font-medium text-yellow-600 dark:text-yellow-400",children:[l.jsx(vi,{size:10}),"Gated"]})]}),l.jsxs("p",{className:"mt-0.5 text-xs text-[var(--color-text-muted)]",children:[re.promptProvider," · ",re.contextWindow.toLocaleString()," ctx"]})]}),l.jsxs("span",{className:"text-xs text-[var(--color-text-muted)]",children:["~",x==="GGUF"?re.sizeGguf:re.sizeVllm]})]},re.id)),ie.length===0&&l.jsxs("p",{className:"py-4 text-center text-sm text-[var(--color-text-muted)]",children:["No models fit your available memory (",K?Math.round(K/1024)+" GB":"unknown",")."]}),K&&ie.length<ss.length&&l.jsxs("p",{className:"text-xs text-[var(--color-text-muted)]",children:["Showing ",ie.length," of ",ss.length," models that fit your ",Math.round(K/1024)," GB."]})]})]}),v==="token"&&h&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("p",{className:"text-sm text-[var(--color-text-muted)]",children:[l.jsx("strong",{children:h.displayName})," is a gated model. Accept the license on HuggingFace and paste your access token below."]}),l.jsx("input",{type:"password",value:R,onChange:re=>w(re.target.value),placeholder:"hf_...",className:te("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]")}),l.jsxs("div",{className:"flex justify-between",children:[l.jsx("button",{type:"button",onClick:()=>{g("select"),k(null)},className:"text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:"Back"}),l.jsx("button",{type:"button",onClick:ne,className:"rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm text-white hover:opacity-90",children:"Download"})]})]}),v==="whisper"&&l.jsxs("div",{className:"flex flex-col items-center py-8",children:[l.jsx(kx,{className:"mb-4 animate-pulse text-[var(--color-primary)]",size:32}),l.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:"Enabling speech-to-text model download..."}),l.jsx("p",{className:"mt-1 text-xs text-[var(--color-text-muted)]",children:"Whisper will fetch ggml-base.en on restart"})]}),v==="downloading"&&l.jsxs("div",{className:"flex flex-col items-center py-8",children:[l.jsx(en,{className:"mb-4 animate-bounce text-[var(--color-primary)]",size:32}),l.jsxs("p",{className:"text-sm font-medium text-[var(--color-text)]",children:["Downloading ",h?.displayName,"..."]}),l.jsxs("p",{className:"mt-1 text-xs text-[var(--color-text-muted)]",children:["~",x==="GGUF"?h?.sizeGguf:h?.sizeVllm," · This may take several minutes"]})]}),v==="configuring"&&l.jsxs("div",{className:"flex flex-col items-center py-8",children:[l.jsx(Ct,{className:"mb-4 animate-spin text-[var(--color-primary)]",size:32}),l.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:"Configuring model and prompt provider..."})]}),v==="done"&&h&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-green-500/30 bg-green-500/5 p-4",children:[l.jsx(ht,{size:20,className:"text-green-500"}),l.jsxs("div",{children:[l.jsxs("p",{className:"text-sm font-medium text-[var(--color-text)]",children:[h.displayName," configured"]}),l.jsxs("p",{className:"text-xs text-[var(--color-text-muted)]",children:["Backend: ",x," · Prompt provider: ",h.promptProvider,E&&" · Whisper auto-download enabled"]})]})]}),l.jsxs("p",{className:"text-xs text-[var(--color-text-muted)]",children:["The LLM proxy is restarting with the new model",E&&", and whisper is fetching its model",". This may take a few minutes to finish loading. Command Center will use the"," ",l.jsx("strong",{children:h.promptProvider})," prompt provider."]})]})]})}function W4(){const[a,s]=N.useState(""),[o,i]=N.useState(""),[d,f]=N.useState(""),[m,v]=N.useState(""),[g,h]=N.useState(!1),[y,x]=N.useState(!1),[S,R]=N.useState(null),w=o===d,E=a&&o&&d&&m&&w&&!g;async function _(){if(E){h(!0),R(null);try{const k=await Pv(a,o,m);rs(k.access_token),localStorage.setItem("access_token",k.access_token),localStorage.setItem("refresh_token",k.refresh_token),x(!0)}catch(k){const Y=k?.response?.data?.error??(k instanceof Error?k.message:"Failed to create account");R(Y)}finally{h(!1)}}}if(y)return l.jsxs("div",{className:"space-y-6",children:[l.jsx("div",{children:l.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Account Created"})}),l.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-green-500/30 bg-green-500/5 p-4",children:[l.jsx(ht,{size:20,className:"text-green-500"}),l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:"Superuser account created"}),l.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:a})]})]}),l.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:`You're logged in. Click "Next" to configure your LLM model.`})]});const O=te("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]");return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Create Account"}),l.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Create your superuser account. This will be the admin for your Jarvis instance."})]}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{htmlFor:"display-name",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Display Name"}),l.jsx("input",{id:"display-name",type:"text",value:m,onChange:k=>v(k.target.value),className:O,placeholder:"Alex"})]}),l.jsxs("div",{children:[l.jsx("label",{htmlFor:"email",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Email"}),l.jsx("input",{id:"email",type:"email",value:a,onChange:k=>s(k.target.value),className:O,placeholder:"admin@example.com"})]}),l.jsxs("div",{children:[l.jsx("label",{htmlFor:"password",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Password"}),l.jsx("input",{id:"password",type:"password",value:o,onChange:k=>i(k.target.value),className:O,placeholder:"Choose a strong password"})]}),l.jsxs("div",{children:[l.jsx("label",{htmlFor:"confirm-password",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Confirm Password"}),l.jsx("input",{id:"confirm-password",type:"password",value:d,onChange:k=>f(k.target.value),className:te(O,d&&!w&&"ring-2 ring-red-500"),placeholder:"Confirm password"}),d&&!w&&l.jsx("p",{className:"mt-1 text-xs text-red-500",children:"Passwords don't match"})]})]}),S&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-red-500/10 px-3 py-2",children:[l.jsx(Bd,{size:14,className:"text-red-500 shrink-0"}),l.jsx("span",{className:"text-sm text-red-500",children:S})]}),l.jsxs("button",{type:"button",onClick:_,disabled:!E,className:te("flex w-full items-center justify-center gap-2 rounded-lg border border-[var(--color-border)] px-4 py-2 text-sm","hover:bg-[var(--color-surface-alt)] transition-colors","disabled:opacity-50"),children:[l.jsx(gi,{size:14}),"Retry"]})]}),!S&&l.jsx("button",{type:"button",onClick:_,disabled:!E,className:te("w-full rounded-lg bg-[var(--color-primary)] px-4 py-2 font-medium text-white","hover:opacity-90 disabled:opacity-50 transition-opacity"),children:g?"Creating...":"Create Superuser Account"})]})}const Zo=[{label:"Welcome",component:Y4},{label:"Hardware",component:X4},{label:"Services",component:K4},{label:"Review",component:Z4},{label:"Install",component:J4},{label:"Account",component:W4},{label:"Models",component:I4}],e3=5;function t3({skipToAccount:a}){const{state:s,dispatch:o}=fr();N.useEffect(()=>{a&&o({type:"SET_STEP",step:e3})},[a,o]);const i=wa(),d=Zo[s.currentStep].component,f=s.currentStep===0,m=s.currentStep===Zo.length-1,h=s.currentStep===4&&!s.installComplete,y=s.installRunning||h;function x(){m?i("/login"):o({type:"NEXT_STEP"})}function S(){o({type:"PREV_STEP"})}return l.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[var(--color-background)] p-4",children:l.jsxs("div",{className:"w-full max-w-2xl",children:[l.jsx("div",{className:"mb-6 flex items-center justify-center gap-1",children:Zo.map((R,w)=>l.jsxs("button",{type:"button",onClick:()=>!y&&o({type:"SET_STEP",step:w}),disabled:y,className:te("flex items-center gap-1",y&&"cursor-not-allowed"),children:[l.jsx("div",{className:te("flex h-7 w-7 items-center justify-center rounded-full text-xs font-medium transition-colors",w===s.currentStep?"bg-[var(--color-primary)] text-white":w<s.currentStep?"bg-[var(--color-primary)]/20 text-[var(--color-primary)]":"bg-[var(--color-surface-alt)] text-[var(--color-text-muted)]"),children:w+1}),l.jsx("span",{className:te("hidden text-xs sm:inline",w===s.currentStep?"font-medium text-[var(--color-text)]":"text-[var(--color-text-muted)]"),children:R.label}),w<Zo.length-1&&l.jsx("div",{className:te("mx-1 h-px w-4 sm:w-6",w<s.currentStep?"bg-[var(--color-primary)]/30":"bg-[var(--color-border)]")})]},R.label))}),l.jsx("div",{className:"rounded-xl border border-[var(--color-border)] bg-[var(--color-surface)] p-6 shadow-lg",children:l.jsx(d,{})}),l.jsxs("div",{className:"mt-4 flex justify-between",children:[l.jsx("button",{type:"button",onClick:S,disabled:f||y,className:te("rounded-lg border border-[var(--color-border)] px-4 py-2 text-sm","hover:bg-[var(--color-surface-alt)] transition-colors","disabled:invisible"),children:"Back"}),l.jsx("button",{type:"button",onClick:x,disabled:y,className:te("rounded-lg bg-[var(--color-primary)] px-6 py-2 text-sm font-medium text-white","hover:opacity-90 transition-opacity","disabled:opacity-50 disabled:cursor-not-allowed"),children:m?"Finish":"Next"})]})]})})}function a3({skipToAccount:a}){return l.jsx(F4,{children:l.jsx(t3,{skipToAccount:a})})}function n3(){const a=wa(),s=Ng(),o=kE(),[i,d]=N.useState("select"),[f,m]=N.useState(null),[v,g]=N.useState("GGUF"),[h,y]=N.useState(""),[x,S]=N.useState(null),R=k=>{m(k),k.gated?d("token"):E(k,"")},w=()=>{if(!h.trim()){S("HuggingFace token is required for gated models");return}S(null),f&&E(f,h)},E=async(k,Y)=>{d("download"),S(null);const I=v==="GGUF"?k.hfRepoGguf:k.hfRepoVllm,ne=v==="GGUF"?k.ggufFilename:void 0;try{await o.mutateAsync({repo:I,filename:ne,token:Y||void 0}),_(k)}catch(ee){S(`Download failed: ${ee.message}`),d("select")}},_=async k=>{d("configure"),S(null);const I={"model.main.name":v==="GGUF"?`.models/${k.ggufFilename}`:`.models/${k.hfRepoVllm.split("/").pop()}`,"model.main.backend":v,"model.main.chat_format":k.chatFormat,"model.main.context_window":k.contextWindow};v==="GGUF"&&(I["inference.gguf.n_gpu_layers"]=-1),v==="VLLM"&&k.quantization&&(I["inference.vllm.quantization"]=k.quantization);try{await s.mutateAsync(I),d("done"),Me.success("LLM configured successfully")}catch(ne){S(`Configuration failed: ${ne.message}`),d("select")}},O=()=>{a("/dashboard")};return l.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[var(--color-bg)] p-4",children:l.jsxs("div",{className:"w-full max-w-2xl rounded-xl border border-[var(--color-border)] bg-[var(--color-surface)] p-8 shadow-lg",children:[l.jsxs("div",{className:"mb-8 text-center",children:[l.jsx(pd,{className:"mx-auto mb-3 text-[var(--color-primary)]",size:40}),l.jsx("h1",{className:"text-2xl font-bold text-[var(--color-text)]",children:"LLM Setup"}),l.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Configure a local language model for Jarvis"})]}),l.jsx("div",{className:"mb-8 flex items-center justify-center gap-2",children:["select","download","configure","done"].map((k,Y)=>{const I=i==="token"?"select":i,ne=["select","download","configure","done"];return l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:te("h-2 w-2 rounded-full",I===k?"bg-[var(--color-primary)]":ne.indexOf(I)>Y?"bg-green-500":"bg-[var(--color-border)]")}),Y<3&&l.jsx("div",{className:"h-px w-8 bg-[var(--color-border)]"})]},k)})}),x&&l.jsxs("div",{className:"mb-6 flex items-start gap-2 rounded-lg border border-red-500/30 bg-red-500/10 p-3 text-sm text-red-500",children:[l.jsx(ra,{size:16,className:"mt-0.5 shrink-0"}),x]}),i==="select"&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[l.jsx("h2",{className:"text-sm font-semibold text-[var(--color-text)]",children:"Select a model"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:()=>g("GGUF"),className:te("rounded-md px-3 py-1 text-xs font-medium transition-colors",v==="GGUF"?"bg-[var(--color-primary)] text-white":"bg-[var(--color-surface-alt)] text-[var(--color-text-muted)] hover:text-[var(--color-text)]"),children:"GGUF"}),l.jsx("button",{onClick:()=>g("VLLM"),className:te("rounded-md px-3 py-1 text-xs font-medium transition-colors",v==="VLLM"?"bg-[var(--color-primary)] text-white":"bg-[var(--color-surface-alt)] text-[var(--color-text-muted)] hover:text-[var(--color-text)]"),children:"vLLM"})]})]}),l.jsx("div",{className:"grid gap-3",children:ss.map(k=>l.jsxs("button",{onClick:()=>R(k),className:te("flex items-center justify-between rounded-lg border border-[var(--color-border)] p-4 text-left transition-colors","hover:border-[var(--color-primary)] hover:bg-[var(--color-surface-alt)]"),children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"font-medium text-[var(--color-text)]",children:k.displayName}),k.gated&&l.jsxs("span",{className:"flex items-center gap-1 rounded bg-yellow-500/15 px-1.5 py-0.5 text-[10px] font-medium text-yellow-600 dark:text-yellow-400",children:[l.jsx(vi,{size:10}),"Gated"]})]}),l.jsxs("p",{className:"mt-0.5 text-xs text-[var(--color-text-muted)]",children:[k.quantization?`${k.quantization.toUpperCase()} 4-bit`:k.chatFormat," · ",k.contextWindow.toLocaleString()," ctx"]})]}),l.jsxs("span",{className:"text-sm text-[var(--color-text-muted)]",children:["~",v==="GGUF"?k.sizeGguf:k.sizeVllm]})]},k.id))}),l.jsx("div",{className:"flex justify-end pt-2",children:l.jsx("button",{onClick:O,className:"text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:"Skip for now"})})]}),i==="token"&&f&&l.jsxs("div",{className:"space-y-4",children:[l.jsx("h2",{className:"text-sm font-semibold text-[var(--color-text)]",children:"HuggingFace Access Required"}),l.jsxs("p",{className:"text-sm text-[var(--color-text-muted)]",children:[l.jsx("strong",{children:f.displayName})," is a gated model. You need to:"]}),l.jsxs("ol",{className:"list-inside list-decimal space-y-1 text-sm text-[var(--color-text-muted)]",children:[l.jsx("li",{children:"Visit the model page on huggingface.co and accept the license agreement"}),l.jsx("li",{children:"Create an access token at huggingface.co/settings/tokens"}),l.jsx("li",{children:"Paste your token below"})]}),l.jsx("input",{type:"password",value:h,onChange:k=>y(k.target.value),placeholder:"hf_...",className:te("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-bg)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]")}),l.jsxs("div",{className:"flex justify-between",children:[l.jsx("button",{onClick:()=>{d("select"),S(null)},className:"text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:"Back"}),l.jsx("button",{onClick:w,className:"rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm text-white hover:opacity-90",children:"Continue"})]})]}),i==="download"&&l.jsxs("div",{className:"flex flex-col items-center py-8",children:[l.jsx(en,{className:"mb-4 animate-bounce text-[var(--color-primary)]",size:32}),l.jsx("h2",{className:"text-lg font-semibold text-[var(--color-text)]",children:"Downloading model..."}),l.jsxs("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:[f?.displayName," ","(~",v==="GGUF"?f?.sizeGguf:f?.sizeVllm,")"]}),l.jsx("p",{className:"mt-4 text-xs text-[var(--color-text-muted)]",children:"This may take several minutes depending on your connection"})]}),i==="configure"&&l.jsxs("div",{className:"flex flex-col items-center py-8",children:[l.jsx(rg,{className:"mb-4 animate-spin text-[var(--color-primary)]",size:32}),l.jsx("h2",{className:"text-lg font-semibold text-[var(--color-text)]",children:"Configuring..."}),l.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Writing settings and restarting LLM proxy"})]}),i==="done"&&l.jsxs("div",{className:"flex flex-col items-center py-8",children:[l.jsx(Gj,{className:"mb-4 text-green-500",size:40}),l.jsx("h2",{className:"text-lg font-semibold text-[var(--color-text)]",children:"LLM Ready"}),l.jsxs("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:[f?.displayName," configured on ",v]}),l.jsx("p",{className:"mt-1 text-xs text-[var(--color-text-muted)]",children:"The model service is restarting. It may take a minute to load the model."}),l.jsx("button",{onClick:()=>a("/dashboard"),className:"mt-6 rounded-lg bg-[var(--color-primary)] px-6 py-2 text-sm text-white hover:opacity-90",children:"Go to Dashboard"})]}),(o.isPending||s.isPending)&&i!=="download"&&i!=="configure"&&l.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",children:l.jsx(Ct,{className:"animate-spin text-white",size:32})})]})})}const r3=new I1;function s3(){const[a,s]=N.useState(!0),[o,i]=N.useState(!1),[d,f]=N.useState(!1);return N.useEffect(()=>{Yd().then(m=>{m.state==="deployed-needs-account"?(f(!0),i(!0)):i(!m.configured)}).catch(()=>{i(!1)}).finally(()=>s(!1))},[]),a?l.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[var(--color-background)]",children:l.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-[var(--color-primary)] border-t-transparent"})}):l.jsxs($0,{children:[l.jsx(ft,{path:"/setup",element:l.jsx(a3,{skipToAccount:d})}),l.jsx(ft,{path:"/login",element:l.jsx(Jw,{})}),l.jsx(ft,{path:"/llm-setup",element:l.jsx(n3,{})}),l.jsxs(ft,{element:l.jsx(Zw,{}),children:[l.jsx(ft,{path:"/dashboard",element:l.jsx(LE,{})}),l.jsx(ft,{path:"/settings",element:l.jsx(iE,{})}),l.jsx(ft,{path:"/services",element:l.jsx(wE,{})}),l.jsx(ft,{path:"/models",element:l.jsx(y4,{})}),l.jsx(ft,{path:"/quick-sets",element:l.jsx(_4,{})}),l.jsx(ft,{path:"/traces",element:l.jsx(U4,{})}),l.jsx(ft,{path:"/traces/:id",element:l.jsx(B4,{})}),l.jsx(ft,{path:"/update",element:l.jsx(R4,{})}),l.jsx(ft,{path:"/reconcile",element:l.jsx(M4,{})}),l.jsx(ft,{path:"/nodes",element:l.jsx(XE,{})}),l.jsx(ft,{path:"/users",element:l.jsx(a4,{})}),l.jsx(ft,{path:"/native-services",element:l.jsx(f4,{})}),l.jsx(ft,{path:"/",element:o?l.jsx(ni,{to:"/setup",replace:!0}):l.jsx(ni,{to:"/dashboard",replace:!0})}),l.jsx(ft,{path:"*",element:l.jsx(q4,{})})]})]})}function l3(){return l.jsx(q2,{children:l.jsx(W1,{client:r3,children:l.jsxs(jj,{children:[l.jsx(g1,{children:l.jsx(s3,{})}),l.jsx(L2,{position:"bottom-right",richColors:!0})]})})})}Kb.createRoot(document.getElementById("root")).render(l.jsx(N.StrictMode,{children:l.jsx(l3,{})}));
|
package/public/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<link rel="icon" type="image/png" href="/favicon.png" />
|
|
7
7
|
<title>Jarvis Admin</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-D7KODgJA.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-CAv1RM9y.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|