@amd-gaia/agent-ui 0.27.0-rc.6 → 0.27.0-rc.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AdvancedSettings-CqwfEYlx.js → AdvancedSettings-Biw1bDji.js} +1 -1
- package/dist/assets/{AutomationsSettings-gXZ4bqbG.js → AutomationsSettings-BhcaMHRu.js} +1 -1
- package/dist/assets/{ConnectorsPane-M3EutXKJ.js → ConnectorsPane-Dfw_U1zK.js} +1 -1
- package/dist/assets/{DocumentLibrary-Dw4NolAa.js → DocumentLibrary-CoHBPrsI.js} +1 -1
- package/dist/assets/{FileBrowser-CLds5WqB.js → FileBrowser-DYrnvgKL.js} +1 -1
- package/dist/assets/{MemoryDashboard-6GyDYAJB.js → MemoryDashboard-BsbzPxKH.js} +1 -1
- package/dist/assets/{MessagingSettings-DaU8766C.js → MessagingSettings-DVdUqQ1T.js} +1 -1
- package/dist/assets/{MobileAccessModal-D-OYiykI.js → MobileAccessModal-DATZSrW1.js} +1 -1
- package/dist/assets/{ScheduleManager-aO0-jiBD.js → ScheduleManager-wj9BdhrA.js} +1 -1
- package/dist/assets/{index-D2fEYdu1.js → index-BzYC8KPL.js} +13 -13
- package/dist/assets/index-CwFbWuGn.css +1 -0
- package/dist/assets/useFocusTrap-CKHW166E.js +6 -0
- package/dist/index.html +3 -3
- package/dist/sw.js +1 -1
- package/package.json +1 -1
- package/dist/assets/index-DoATqxKC.css +0 -1
- package/dist/assets/useFocusTrap-DeTUlRT3.js +0 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ConnectorsPane-
|
|
2
|
-
import{n as e,r as t,t as n}from"./rolldown-runtime-XKyaHtl9.js";import{$ as r,$n as i,$r as a,A as o,An as s,Ar as c,At as l,B as u,Br as d,C as f,Ct as p,D as m,Dn as h,Dt as g,E as _,En as v,Et as y,F as b,Fn as x,Fr as S,Ft as C,G as w,Gn as T,Gr as E,Gt as D,Hn as O,Hr as ee,Ht as te,I as ne,In as re,Ir as k,It as ie,J as ae,Jn as A,Jr as oe,Jt as se,K as ce,Kn as le,Kr as ue,Kt as de,L as fe,Ln as pe,Lr as me,Lt as j,M as he,Mn as M,Mt as ge,N as _e,Nn as ve,O as ye,On as be,Ot as xe,P as Se,Pn as Ce,Pr as we,Pt as Te,Q as Ee,Qn as De,Qr as Oe,Qt as ke,R as Ae,Rn as je,Rr as Me,Rt as Ne,S as Pe,Sn as Fe,St as Ie,T as Le,Tn as Re,Tt as ze,U as Be,Un as Ve,Ur as He,Ut as Ue,V as We,Vn as Ge,Vr as Ke,Vt as qe,W as Je,Wn as Ye,Wr as Xe,Wt as Ze,X as Qe,Xn as $e,Xr as et,Xt as tt,Y as nt,Yn as rt,Yr as it,Yt as at,Z as ot,Zn as st,Zr as ct,Zt as lt,_ as ut,_n as dt,_r as ft,_t as pt,a as mt,ai as ht,an as gt,ar as _t,at as vt,b as N,bn as yt,bt,c as P,ci as F,cn as xt,cr as St,ct as Ct,d as wt,di as Tt,dn as Et,dr as Dt,dt as Ot,ei as kt,en as At,er as jt,et as Mt,f as Nt,fi as Pt,fn as Ft,fr as It,g as Lt,gi as Rt,h as zt,hi as I,hn as Bt,hr as Vt,ht as Ht,i as Ut,ii as Wt,in as Gt,ir as Kt,it as qt,j as Jt,jn as Yt,jt as Xt,k as Zt,kn as Qt,kt as $t,l as L,li as en,ln as tn,lr as nn,lt as rn,m as an,mi as on,mn as sn,mr as cn,mt as ln,n as un,ni as dn,nn as fn,nr as pn,o as mn,oi as hn,on as gn,or as _n,ot as vn,p as yn,pi as bn,pn as xn,pr as Sn,pt as Cn,q as wn,qn as Tn,qr as En,qt as Dn,r as On,ri as kn,rn as An,rr as jn,rt as Mn,s as R,si as Nn,sn as Pn,sr as Fn,st as In,t as Ln,ti as Rn,tn as zn,tr as Bn,tt as Vn,u as z,ui as Hn,un as Un,ur as Wn,ut as Gn,v as Kn,vn as qn,vt as Jn,w as Yn,wn as Xn,wt as Zn,x as Qn,xn as $n,xt as er,y as tr,yn as nr,yt as rr,z as ir,zn as ar,zr as or,zt as sr}from"./useFocusTrap-DeTUlRT3.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var cr=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&ne(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ne(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var ee=new MessageChannel,te=ee.port2;ee.port1.onmessage=D,O=function(){te.postMessage(null)}}else O=function(){_(D,0)};function ne(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,ne(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),lr=n(((e,t)=>{t.exports=cr()})),ur=n((e=>{var t=Rt();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.browser=function(e){return{$$typeof:o,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=u(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=u(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.1`})),dr=n(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=ur()})),fr=n((e=>{var t=lr(),n=Rt(),r=dr();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}function f(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&f(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function p(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function m(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function h(e){var t=[null,null],n=p(e);return n===null||g(t,e,n.child,{foundSelf:!1}),t}function g(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&g(e,t,n.child,r))return!0;n=n.sibling}return!1}function _(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var v=null,y=null;function b(e,t,n){return e===n||e===t&&(v=e,!0)}function x(e,t,n){return e===n?(y=e,!1):e===t&&(y!==null&&(v=e),!0)}function S(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function C(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var w=Object.assign,T=Symbol.for(`react.element`),E=Symbol.for(`react.transitional.element`),D=Symbol.for(`react.portal`),O=Symbol.for(`react.fragment`),ee=Symbol.for(`react.strict_mode`),te=Symbol.for(`react.profiler`),ne=Symbol.for(`react.consumer`),re=Symbol.for(`react.context`),k=Symbol.for(`react.forward_ref`),ie=Symbol.for(`react.suspense`),ae=Symbol.for(`react.suspense_list`),A=Symbol.for(`react.memo`),oe=Symbol.for(`react.lazy`),se=Symbol.for(`react.activity`),ce=Symbol.for(`react.legacy_hidden`),le=Symbol.for(`react.memo_cache_sentinel`),ue=Symbol.for(`react.view_transition`),de=Symbol.for(`react.recoverable`),fe=Symbol.iterator;function pe(e){return typeof e!=`object`||!e?null:(e=fe&&e[fe]||e[`@@iterator`],typeof e==`function`?e:null)}var me=Symbol.for(`react.client.reference`);function j(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===me?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case O:return`Fragment`;case te:return`Profiler`;case ee:return`StrictMode`;case ie:return`Suspense`;case ae:return`SuspenseList`;case se:return`Activity`;case ue:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case D:return`Portal`;case re:return e.displayName||`Context`;case ne:return(e._context.displayName||`Context`)+`.Consumer`;case k:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case A:return t=e.displayName||null,t===null?j(e.type)||`Memo`:t;case oe:t=e._payload,e=e._init;try{return j(e(t))}catch{}}return null}var he=Array.isArray,M=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ge=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_e={pending:!1,data:null,method:null,action:null},ve=[],ye=-1;function be(e){return{current:e}}function xe(e){0>ye||(e.current=ve[ye],ve[ye]=null,ye--)}function Se(e,t){ye++,ve[ye]=e.current,e.current=t}var Ce=be(null),we=be(null),Te=be(null),Ee=be(null);function De(e,t){switch(Se(Te,t),Se(we,e),Se(Ce,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?xp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=xp(t),e=Sp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}xe(Ce),Se(Ce,e)}function Oe(){xe(Ce),xe(we),xe(Te)}function ke(e){var t=e.memoizedState;t!==null&&(vh._currentValue=t.memoizedState,Se(Ee,e)),t=Ce.current;var n=Sp(t,e.type);t!==n&&(Se(we,e),Se(Ce,n))}function Ae(e){we.current===e&&(xe(Ce),xe(we)),Ee.current===e&&(xe(Ee),vh._currentValue=_e)}var je,Me;function Ne(e){if(je===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);je=t&&t[1]||``,Me=-1<e.stack.indexOf(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ConnectorsPane-Dfw_U1zK.js","./rolldown-runtime-XKyaHtl9.js","./useFocusTrap-CKHW166E.js","./ConnectorsPane-BGI8nBUb.css","./MessagingSettings-DVdUqQ1T.js","./AutomationsSettings-BhcaMHRu.js","./AdvancedSettings-Biw1bDji.js","./MemoryDashboard-BsbzPxKH.js","./MemoryDashboard-RpfLag-v.css","./ScheduleManager-wj9BdhrA.js","./ScheduleManager-BZzEH2-W.css","./DocumentLibrary-CoHBPrsI.js","./DocumentLibrary-fEMoY7lH.css","./FileBrowser-DYrnvgKL.js","./FileBrowser-1goNp4CP.css","./MobileAccessModal-DATZSrW1.js","./MobileAccessModal-BrZMaERi.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{n as e,r as t,t as n}from"./rolldown-runtime-XKyaHtl9.js";import{$ as r,$n as i,$r as a,A as o,An as s,Ar as c,At as l,B as u,Br as d,C as f,Ct as p,D as m,Dn as h,Dt as g,E as _,En as v,Et as y,F as b,Fn as x,Fr as S,Ft as C,G as w,Gn as T,Gr as E,Gt as D,Hn as O,Hr as ee,Ht as te,I as ne,In as re,Ir as k,It as ie,J as ae,Jn as A,Jr as oe,Jt as se,K as ce,Kn as le,Kr as ue,Kt as de,L as fe,Ln as pe,Lr as me,Lt as j,M as he,Mn as M,Mt as ge,N as _e,Nn as ve,O as ye,On as be,Ot as xe,P as Se,Pn as Ce,Pr as we,Pt as Te,Q as Ee,Qn as De,Qr as Oe,Qt as ke,R as Ae,Rn as je,Rr as Me,Rt as Ne,S as Pe,Sn as Fe,St as Ie,T as Le,Tn as Re,Tt as ze,U as Be,Un as Ve,Ur as He,Ut as Ue,V as We,Vn as Ge,Vr as Ke,Vt as qe,W as Je,Wn as Ye,Wr as Xe,Wt as Ze,X as Qe,Xn as $e,Xr as et,Xt as tt,Y as nt,Yn as rt,Yr as it,Yt as at,Z as ot,Zn as st,Zr as ct,Zt as lt,_ as ut,_n as dt,_r as ft,_t as pt,a as mt,ai as ht,an as gt,ar as _t,at as vt,b as N,bn as yt,bt,c as P,ci as F,cn as xt,cr as St,ct as Ct,d as wt,di as Tt,dn as Et,dr as Dt,dt as Ot,ei as kt,en as At,er as jt,et as Mt,f as Nt,fi as Pt,fn as Ft,fr as It,g as Lt,gi as Rt,h as zt,hi as I,hn as Bt,hr as Vt,ht as Ht,i as Ut,ii as Wt,in as Gt,ir as Kt,it as qt,j as Jt,jn as Yt,jt as Xt,k as Zt,kn as Qt,kt as $t,l as L,li as en,ln as tn,lr as nn,lt as rn,m as an,mi as on,mn as sn,mr as cn,mt as ln,n as un,ni as dn,nn as fn,nr as pn,o as mn,oi as hn,on as gn,or as _n,ot as vn,p as yn,pi as bn,pn as xn,pr as Sn,pt as Cn,q as wn,qn as Tn,qr as En,qt as Dn,r as On,ri as kn,rn as An,rr as jn,rt as Mn,s as R,si as Nn,sn as Pn,sr as Fn,st as In,t as Ln,ti as Rn,tn as zn,tr as Bn,tt as Vn,u as z,ui as Hn,un as Un,ur as Wn,ut as Gn,v as Kn,vn as qn,vt as Jn,w as Yn,wn as Xn,wt as Zn,x as Qn,xn as $n,xt as er,y as tr,yn as nr,yt as rr,z as ir,zn as ar,zr as or,zt as sr}from"./useFocusTrap-CKHW166E.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var cr=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&ne(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ne(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var ee=new MessageChannel,te=ee.port2;ee.port1.onmessage=D,O=function(){te.postMessage(null)}}else O=function(){_(D,0)};function ne(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,ne(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),lr=n(((e,t)=>{t.exports=cr()})),ur=n((e=>{var t=Rt();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.browser=function(e){return{$$typeof:o,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=u(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=u(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.1`})),dr=n(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=ur()})),fr=n((e=>{var t=lr(),n=Rt(),r=dr();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}function f(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&f(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function p(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function m(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function h(e){var t=[null,null],n=p(e);return n===null||g(t,e,n.child,{foundSelf:!1}),t}function g(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&g(e,t,n.child,r))return!0;n=n.sibling}return!1}function _(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var v=null,y=null;function b(e,t,n){return e===n||e===t&&(v=e,!0)}function x(e,t,n){return e===n?(y=e,!1):e===t&&(y!==null&&(v=e),!0)}function S(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function C(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var w=Object.assign,T=Symbol.for(`react.element`),E=Symbol.for(`react.transitional.element`),D=Symbol.for(`react.portal`),O=Symbol.for(`react.fragment`),ee=Symbol.for(`react.strict_mode`),te=Symbol.for(`react.profiler`),ne=Symbol.for(`react.consumer`),re=Symbol.for(`react.context`),k=Symbol.for(`react.forward_ref`),ie=Symbol.for(`react.suspense`),ae=Symbol.for(`react.suspense_list`),A=Symbol.for(`react.memo`),oe=Symbol.for(`react.lazy`),se=Symbol.for(`react.activity`),ce=Symbol.for(`react.legacy_hidden`),le=Symbol.for(`react.memo_cache_sentinel`),ue=Symbol.for(`react.view_transition`),de=Symbol.for(`react.recoverable`),fe=Symbol.iterator;function pe(e){return typeof e!=`object`||!e?null:(e=fe&&e[fe]||e[`@@iterator`],typeof e==`function`?e:null)}var me=Symbol.for(`react.client.reference`);function j(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===me?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case O:return`Fragment`;case te:return`Profiler`;case ee:return`StrictMode`;case ie:return`Suspense`;case ae:return`SuspenseList`;case se:return`Activity`;case ue:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case D:return`Portal`;case re:return e.displayName||`Context`;case ne:return(e._context.displayName||`Context`)+`.Consumer`;case k:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case A:return t=e.displayName||null,t===null?j(e.type)||`Memo`:t;case oe:t=e._payload,e=e._init;try{return j(e(t))}catch{}}return null}var he=Array.isArray,M=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ge=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_e={pending:!1,data:null,method:null,action:null},ve=[],ye=-1;function be(e){return{current:e}}function xe(e){0>ye||(e.current=ve[ye],ve[ye]=null,ye--)}function Se(e,t){ye++,ve[ye]=e.current,e.current=t}var Ce=be(null),we=be(null),Te=be(null),Ee=be(null);function De(e,t){switch(Se(Te,t),Se(we,e),Se(Ce,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?xp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=xp(t),e=Sp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}xe(Ce),Se(Ce,e)}function Oe(){xe(Ce),xe(we),xe(Te)}function ke(e){var t=e.memoizedState;t!==null&&(vh._currentValue=t.memoizedState,Se(Ee,e)),t=Ce.current;var n=Sp(t,e.type);t!==n&&(Se(we,e),Se(Ce,n))}function Ae(e){we.current===e&&(xe(Ce),xe(we)),Ee.current===e&&(xe(Ee),vh._currentValue=_e)}var je,Me;function Ne(e){if(je===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);je=t&&t[1]||``,Me=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+je+e+Me}var Pe=!1;function Fe(e,t){if(!e||Pe)return``;Pe=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
5
5
|
`),l=s.split(`
|
|
@@ -185,7 +185,7 @@ Error generating stack: `+e.message+`
|
|
|
185
185
|
`)}function OF(e,t){return e?new Date(e).toLocaleString(On(t),{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`,second:`2-digit`,hour12:!0}):``}function kF(e,t,n=new Date){if(!e)return``;let r=new Date(e),i=On(t),a=r.toLocaleTimeString(i,{hour:`numeric`,minute:`2-digit`}),o=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime(),s=Math.round((o(n)-o(r))/864e5);return s===0?a:s===1?t(`msg.yesterdayAt`,{time:a}):r.toLocaleString(i,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,...r.getFullYear()===n.getFullYear()?{}:{year:`numeric`}})}var AF=`Cancelled.`,jF=[[`This answer was interrupted when GAIA closed. Send again to retry.`,`msg.cutOff.interrupted`],[`This answer was interrupted before it finished. Send again to retry.`,`msg.cutOff.cancelled`],[`This answer ended before GAIA could save a reply. Send again to retry.`,`msg.cutOff.noReply`],[`This run was stopped because its schedule was deleted.`,`msg.cutOff.scheduleDeleted`],[`This run was stopped because its schedule was paused.`,`msg.cutOff.schedulePaused`]],MF=/(?:^|\n\n)Before it stopped, it had started these tools: (.+)\.$/;function NF(e){let t=e.trim(),n=jF.find(([e])=>t.endsWith(e));if(!n)return null;t=t.slice(0,-n[0].length).trimEnd();let r=MF.exec(t);return r&&(t=t.slice(0,r.index).trimEnd()),{body:t,notice:n[1],tools:r?r[1]:null}}function PF(e,t,n=!1){return t?`stopped`:NF(e)?`interrupted`:n?`failed`:void 0}var FF=320;function IF({original:e,draft:t,onDraft:n,onSend:r,onCancel:i,confirming:a=!1}){let o=R(),{text:s,links:c}=(0,B.useMemo)(()=>Av(e),[e]),[l,u]=(0,B.useState)(()=>t==null?s:Av(t).text),d=(0,B.useRef)(null),f=l.trim()!==``&&l!==s,p=()=>r(jv(l,c));return(0,B.useLayoutEffect)(()=>{let e=d.current;e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},[]),(0,B.useLayoutEffect)(()=>{let e=d.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,FF)}px`)},[l]),z(`div`,{className:`msg-edit`,children:[L(`textarea`,{ref:d,className:`msg-edit-input`,value:l,onChange:e=>{u(e.target.value),n?.(e.target.value)},onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),i()):e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),f&&!a&&p())},"aria-label":o(`msg.editLabel`),readOnly:a,rows:1,dir:`auto`,...Nt}),c.length>0&&L(`ul`,{className:`msg-edit-attachments`,"aria-label":o(`composer.attached`),children:c.map((e,t)=>z(`li`,{className:`msg-edit-attachment`,children:[L(sa,{size:14,"aria-hidden":`true`}),L(`span`,{className:`msg-edit-attachment-name`,title:e.name,dir:`auto`,children:e.name})]},t))}),!a&&z(`div`,{className:`msg-edit-actions`,children:[L(`button`,{type:`button`,className:`btn-secondary msg-edit-btn`,onClick:i,children:o(`msg.editCancel`)}),L(`button`,{type:`button`,className:`btn-primary msg-edit-btn`,onClick:p,disabled:!f,children:o(`msg.editSend`)})]})]})}var LF=/^\[schedule-run\] Run #(\d+) \u00b7 (.+)$/;function RF({message:e,isStreaming:t,agentSteps:n,agentStepsActive:r,cards:i,onDelete:a,onResend:o,extraActions:s,onTryAgain:c,onContinue:l,onRegenerate:u,onEditStart:d,editing:f=!1,editDraft:p=null,onEditDraft:m,onEdit:h,onEditCancel:g,laterCount:_=0,latest:v=!1,latencyMs:y,liveStatus:b,toolStatus:x,awaitingUser:S}){let C=R();Vc();let w=(0,B.useMemo)(()=>{if(e.role!==`assistant`||!n)return{steps:n,echoed:!1,endedBy:null};let r=bP(n,e.content);return t?{steps:r,echoed:!1,endedBy:null}:mF(r,e.content)},[n,e.content,e.role,t]),T=e.role===`assistant`&&(w.echoed||e.failed===!0||fF(e.content)),E=qc(),D=hc(e=>e.show),O=N(e=>e.openSettings),ee=N(e=>e.jumpToSetting),te=(0,B.useMemo)(()=>T&&!t?MP(e.content):null,[T,t,e.content]),ne=e.role===`assistant`?e.stopState??(e.content.trim()===AF?`stopped`:void 0):void 0,re=(0,B.useMemo)(()=>e.role===`assistant`&&!t?NF(e.content):null,[e.content,e.role,t]),k=re?null:w.endedBy,ie=(0,B.useMemo)(()=>e.role===`user`?IP(e.content):null,[e.content,e.role]),ae=(0,B.useMemo)(()=>ie?ud(ie.text):EF(re?re.body:k?e.content.trimEnd().slice(0,-k.length):e.content,!!t),[e.content,ie,t,re,k]),A=!!ae.trim()&&!(ne&&ae.trim()===AF),oe=e.turnSummary?.files,se=(0,B.useMemo)(()=>oe?.map(e=>e.path)??[],[oe]),ce=`${e.session_id}:${e.id}`,[le,ue]=(0,B.useState)(!1),[de,fe]=(0,B.useState)(!1),pe=e.role===`user`&&zD(e.content),me=(0,B.useMemo)(()=>pe?VD(e.content):null,[pe,e.content]),[j,he]=(0,B.useState)(!1),M=(0,B.useId)(),ge=(0,B.useRef)(null),_e=(0,B.useRef)(!1),ve=(0,B.useCallback)(()=>{j&&(_e.current=!0),he(!j)},[j]);(0,B.useEffect)(()=>{!j&&_e.current&&(_e.current=!1,ge.current?.scrollIntoView?.({block:`nearest`}))},[j]);let ye=(0,B.useRef)(null),be=(0,B.useRef)(null);(0,B.useEffect)(()=>()=>{ye.current&&clearTimeout(ye.current),be.current&&clearTimeout(be.current)},[]);let xe=(0,B.useCallback)(()=>{let t=e.role===`assistant`?eN(ae):e.content;if(navigator.clipboard?.writeText)navigator.clipboard.writeText(t).catch(()=>{});else{let e=document.createElement(`textarea`);e.value=t,e.style.position=`fixed`,e.style.opacity=`0`,document.body.appendChild(e),e.select(),document.execCommand(`copy`),document.body.removeChild(e)}ue(!0),ye.current&&clearTimeout(ye.current),ye.current=setTimeout(()=>ue(!1),2e3)},[ae,e.content,e.role]),Se=(0,B.useCallback)(()=>{de?(fe(!1),be.current&&clearTimeout(be.current),a?.(e.id)):(fe(!0),be.current&&clearTimeout(be.current),be.current=setTimeout(()=>fe(!1),3e3))},[de,e.id,a]),[Ce,we]=(0,B.useState)(null),Te=(0,B.useCallback)(e=>{_>0?we(()=>e):e()},[_]),Ee=(0,B.useCallback)(()=>{Te(()=>o?.(e))},[e,o,Te]),De=e.created_at?C(e.role===`user`?`msg.sent`:`msg.replied`,{time:OF(e.created_at,C)}):void 0,Oe=e.role===`system`?LF.exec(e.content):null;return Oe?L(`div`,{className:`msg-run-divider`,role:`separator`,children:C(`msg.scheduledRun`,{n:Oe[1],time:Oe[2]})}):L(`div`,{className:`msg msg-${e.role} ${T?`msg-error`:``}${v?` msg-latest`:``}`,title:De,children:z(`div`,{className:`msg-inner`,children:[z(`div`,{className:`msg-header`,children:[L(`div`,{className:`msg-header-left`}),!t&&!f&&z(`div`,{className:`msg-actions`,children:[e.role===`user`&&d&&h&&L(`button`,{type:`button`,className:`msg-action-btn`,onClick:()=>d(e),title:C(`msg.edit`),"aria-label":C(`msg.edit`),children:L(Io,{size:12})}),e.role===`user`&&o&&L(`button`,{className:`msg-action-btn`,onClick:Ee,title:C(`msg.resend`),"aria-label":C(`msg.resend`),children:L(Qo,{size:12})}),e.role===`assistant`&&u&&L(`button`,{type:`button`,className:`msg-action-btn`,onClick:u,title:C(`msg.tryAgain`),"aria-label":C(`msg.tryAgain`),children:L(is,{size:12})}),s,e.role===`assistant`&&!T&&A&&L(VN,{messageId:ce,content:ae}),A&&L(`button`,{className:`msg-copy ${le?`copied`:``}`,onClick:xe,title:C(le?`msg.copied`:`msg.copy`),"aria-label":C(le?`msg.copiedAria`:`msg.copy`),children:L(le?Yr:Ti,{size:12})}),a&&L(`button`,{className:`msg-action-btn msg-delete ${de?`confirm`:``}`,onClick:Se,title:C(de?`msg.confirmDelete`:`msg.delete`),"aria-label":C(de?`msg.confirmDeleteAria`:`msg.delete`),children:L(Hs,{size:12})})]})]}),z(`div`,{className:`msg-body`,children:[e.role===`assistant`&&(w.steps&&w.steps.length>0||t)&&L(PO,{steps:w.steps??[],isActive:r??!1,running:!!t,awaitingUser:S,toolStatus:t?x:null,answer:t?void 0:ae,liveLine:t&&L(iF,{active:!!r||!ae,label:b,awaitingUser:S})}),T&&z(`div`,{className:`error-banner`,children:[L(Ws,{size:14}),L(`span`,{children:C(te&&te.kind!==`unknown`?`failedTurn.${te.kind}.title`:`msg.error`)})]}),(e.cards??i)?.map((e,t)=>L(ZM,{render:e.render,data:e.data},t)),e.page_elements&&e.page_elements.length>0&&L(hP,{elements:e.page_elements}),f&&h?L(IF,{original:e.content,draft:p,onDraft:m,onSend:t=>Te(()=>h(e,t)),onCancel:()=>{we(null),g?.()},confirming:Ce!==null&&!t}):pe?z(P.Fragment,{children:[!j&&me?z(`div`,{ref:ge,id:M,className:`msg-excerpt md-content`,children:[L(`div`,{className:`msg-excerpt-lines`,dir:`auto`,children:me.head}),L(`div`,{className:`msg-excerpt-gap`,children:C.plural(`msg.moreLines`,me.hidden)}),L(`div`,{className:`msg-excerpt-lines`,dir:`auto`,children:me.tail})]}):L(`div`,{ref:ge,id:M,className:`msg-collapsible${j?``:` is-collapsed`}`,children:L(cI,{content:ae})}),L(UD,{expanded:j,onToggle:ve,controls:M,collapsedLabel:C.hint(C(`msg.showAll`),HD(C,e.content)),expandedLabel:C(`msg.showLess`),className:`msg-expand-toggle`})]}):te?.raw?z(P.Fragment,{children:[L(`p`,{className:`msg-failed-lead`,children:C(`failedTurn.${te.kind}.body`)}),z(`details`,{className:`msg-failed-details`,children:[L(`summary`,{children:C(`failedTurn.details`)}),L(cI,{content:NP(ae)})]})]}):!(ne&&ae.trim()===AF)&&L(cI,{content:ae,showCursor:t&&!!ae&&!r,isStreaming:t,writtenFiles:se}),!f&&ie&&L(RP,{images:ie.images}),Ce&&!t&&z(`div`,{className:`msg-drop-confirm`,role:`alertdialog`,"aria-labelledby":`${M}-drop`,children:[L(`span`,{id:`${M}-drop`,children:C.plural(`msg.dropLater`,_)}),z(`div`,{className:`msg-edit-actions`,children:[L(`button`,{type:`button`,className:`btn-secondary msg-edit-btn`,onClick:()=>we(null),autoFocus:!0,children:C(`msg.editCancel`)}),L(`button`,{type:`button`,className:`btn-primary msg-edit-btn`,onClick:()=>{we(null),Ce()},children:C(`msg.dropLaterGo`)})]})]}),ne&&z(`div`,{className:`msg-stopped${ne===`unconfirmed`||e.stopError?` is-unconfirmed`:``}`,role:`note`,children:[L(Is,{size:9,fill:`currentColor`,"aria-hidden":`true`}),L(`span`,{children:ne===`unconfirmed`?C(`msg.stoppedUnconfirmed`):e.stopError?C(`msg.stoppedError`,{error:e.stopError}):C(`msg.stopped`)})]}),re&&L(`p`,{className:`msg-cut-off`,role:`note`,children:C.compose(e=>re.tools?`${e(`msg.cutOff.toolsRan`,{tools:re.tools})} ${e(re.notice)}`:e(re.notice))}),k&&L(`p`,{className:`msg-cut-off`,role:`note`,dir:`auto`,children:k}),l&&ne&&!t&&ae.trim()&&ae.trim()!==AF&&z(`button`,{type:`button`,className:`msg-try-again`,onClick:l,children:[L(Ho,{size:12,"aria-hidden":`true`}),C(`msg.continue`)]}),c&&!t&&z(`button`,{type:`button`,className:`msg-try-again`,onClick:c,children:[L(is,{size:12,"aria-hidden":`true`}),C(`msg.tryAgain`)]}),te?.sections.map(e=>z(`button`,{type:`button`,className:`msg-try-again`,onClick:()=>{let t=te?.targets[e];t?ee({section:e,target:t}):O(e)},children:[L(ms,{size:12,"aria-hidden":`true`}),C.compose(t=>t(`failedTurn.openSettings`,{tab:t(`settings.section.${e}`)}))]},e)),(T||k)&&!t&&uF(k??e.content)?z(`button`,{type:`button`,className:`msg-try-again`,onClick:()=>D(`agent`),children:[L(cs,{size:12,"aria-hidden":`true`}),C(`logs.agentLog`)]}):(T||e.role===`assistant`&&cF(e.content))&&!t&&E?.remote===!1&&z(`button`,{type:`button`,className:`msg-try-again`,onClick:()=>D(`model_server`),children:[L(cs,{size:12,"aria-hidden":`true`}),C(`logs.serverLog`)]}),e.role===`assistant`&&!t&&(iP(e.content)||iP(e.failureText??``))&&L(oP,{classes:dF,note:C(`msg.reportNote`)}),e.role===`assistant`&&!t&&Pk(ae)&&L(Vk,{content:ae}),e.role===`assistant`&&!t&&(e.stats||y!=null||e.created_at)&&z(`div`,{className:`msg-stats`,"aria-label":C(`msg.about`),children:[e.created_at&&L(`span`,{className:`msg-stats-ts`,title:OF(e.created_at,C),children:kF(e.created_at,C)}),e.stats?.retried&&e.stats.model&&L(`span`,{title:`This answer was kept from Retry with… (${e.stats.model})`,children:Uc(e.stats.model)}),!e.stats?.retried&&e.stats?.route?.model&&L(`span`,{className:`msg-stats-route`,title:C(`msg.route`,{reason:e.stats.route.reason??``}),children:Uc(e.stats.route.model)}),L(kA,{latencyMs:y,stats:e.stats,ended:PF(e.content,ne,T||!!k)})]}),e.role===`assistant`&&!t&&e.stats?.route?.degraded&&e.stats.route.notice&&L(`div`,{className:`msg-route-notice`,role:`status`,children:e.stats.route.notice}),e.role===`assistant`&&!t&&e.id>0&&e.session_id&&L(EN,{sessionId:e.session_id,messageId:e.id}),e.role===`assistant`&&L(HN,{messageId:ce}),e.role===`assistant`&&L(UN,{messageId:ce})]})]})})}var zF=(0,B.createContext)(!1);function BF({lang:e,code:t}){let n=R(),[r,i]=(0,B.useState)(!1),[a,o]=(0,B.useState)(!1),s=(0,B.useContext)(zF),c=(0,B.useId)(),l=RD(t),u=l>(s?20:25),d=u&&!a,f=(0,B.useRef)(null);(0,B.useEffect)(()=>()=>{f.current&&clearTimeout(f.current)},[]);let p=(0,B.useCallback)(()=>{if(navigator.clipboard?.writeText)navigator.clipboard.writeText(t).catch(()=>{});else{let e=document.createElement(`textarea`);e.value=t,e.style.position=`fixed`,e.style.opacity=`0`,document.body.appendChild(e),e.select(),document.execCommand(`copy`),document.body.removeChild(e)}i(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>i(!1),2e3)},[t]);return z(`div`,{className:`code-block${d?` is-collapsed`:``}`,dir:`ltr`,children:[z(`div`,{className:`code-header`,children:[L(`span`,{className:`code-lang`,children:e||`code`}),z(`button`,{className:`code-copy ${r?`copied`:``}`,onClick:p,title:n(r?`msg.copied`:`code.copy`),"aria-label":n(r?`msg.copiedAria`:`code.copyAria`),children:[L(r?Yr:Ti,{size:13}),L(`span`,{children:n(r?`code.copied`:`code.copy`)})]})]}),L(`pre`,{id:c,children:L(`code`,{children:t})}),u&&L(UD,{expanded:a,onToggle:()=>o(e=>!e),controls:c,collapsedLabel:n(`code.expand`,{size:LD(n,l)}),expandedLabel:n(`code.collapse`),className:`code-expand-toggle`})]})}var VF=/(?<=["\u201c])[A-Z]:[\\/][^*?"<>|\r\n\u201c\u201d]+(?=["\u201d])|\b[A-Z]:[\\/](?=[^\s*?"<>|,;)}\]\\/])(?:[^\s*?"<>|,;)}\]\\/]+(?:(?: +(?:[^\s*?"<>|,;:)}\]\\/]+|\([^\s*?"<>|,;:)}\]\\/]+\)))+\\|[\\/]))*(?:(?:[^\s*?"<>|,;:.)}\]\\/]+ +){1,2}[^\s*?"<>|,;)}\]\\/]+\.[A-Za-z0-9]{1,5}\b|[^\s*?"<>|,;)}\]\\/]+)?/gi,HF=/[.:!']+$/,UF=RegExp(`^(?:${VF.source})$`,`i`),WF=(0,B.createContext)([]);function GF(e,t){if(typeof t!=`string`||e.length===0)return null;let n=t.trim();if(!n)return null;if(e.includes(n))return n;if(/[\\/]/.test(n))return null;let r=n.toLowerCase(),i=e.filter(e=>(e.split(/[\\/]/).pop()??``).toLowerCase()===r);return i.length===1?i[0]:null}function KF(e){if(typeof e!=`string`)return null;let t=e.trim();return UF.test(t)?t:null}function qF({path:e,label:t}){let n=t=>{t.preventDefault(),Ft(e).catch(e=>{F.ui.error(`Failed to open path`,e)})};return z(`span`,{className:`file-path-link`,dir:`ltr`,onClick:n,title:`Open in file explorer: ${V(e)}`,role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n(e))},children:[L(da,{size:12,className:`file-path-icon`}),V(t??e)]})}function JF(e){return[...e.matchAll(new RegExp(VF.source,`gi`))].map(t=>{let n=t.index+t[0].length,r=`"“`.includes(e[t.index-1]??`
|
|
186
186
|
`)&&`"”`.includes(e[n]??`
|
|
187
187
|
`);return{start:t.index,path:r?t[0]:t[0].replace(HF,``)}})}function YF(e){let t=[],n=0;for(let{start:r,path:i}of JF(e))r>n&&t.push(e.slice(n,r)),t.push(L(qF,{path:i},r)),n=r+i.length;return t.length===0?e:(n<e.length&&t.push(e.slice(n)),L(P.Fragment,{children:t}))}var XF=(0,B.createContext)(JP([]));function ZF({doc:e,page:t,t:n}){return z(`a`,{className:`citation-link`,href:Ie(e.id,t),target:`_blank`,rel:`noopener noreferrer`,dir:`ltr`,title:t?n(`citation.openPage`,{page:t}):n(`citation.open`,{name:V(e.label)}),"data-doc-id":e.id,"data-page":t,children:[L(sa,{size:12,className:`citation-icon`,"aria-hidden":`true`}),V(e.label)]})}function QF({doc:e,page:t,label:n,t:r}){return L(`a`,{className:`citation-page`,href:Ie(e.id,t),target:`_blank`,rel:`noopener noreferrer`,title:r(`citation.openPage`,{page:t}),"data-doc-id":e.id,"data-page":t,children:n})}function $F(e,t){let n=XP(e,t)[0];return rF(n?t.slice(0,n.start):t)}function eI(e,t,n,r){let i=JF(e),a=XP(t,e).filter(e=>!i.some(t=>t.start<e.start&&e.start<t.start+t.path.length)),o=[],s=(t,r,i)=>{for(let a of r){let r=i+a.start,s=i+a.end;o.push({start:r,end:s,node:L(QF,{doc:t,page:a.page,label:e.slice(r,s),t:n},`p${r}`)})}};if(r&&s(r,rF(e.slice(0,a[0]?.start??e.length)),0),a.forEach((t,r)=>{let i=rF(e.slice(t.end,a[r+1]?.start??e.length));o.push({start:t.start,end:t.end,node:L(ZF,{doc:t.doc,page:i[0]?.page,t:n},`c${t.start}`)}),s(t.doc,i,t.end)}),o.length===0)return YF(e);o.sort((e,t)=>e.start-t.start);let c=[],l=0;for(let t of o)t.start>l&&c.push(L(B.Fragment,{children:YF(e.slice(l,t.start))},`t${l}`)),c.push(t.node),l=t.end;return l<e.length&&c.push(L(B.Fragment,{children:YF(e.slice(l))},`t${l}`)),L(P.Fragment,{children:c})}function tI(e,t){return typeof t==`string`?YP(e,t):null}function nI({children:e}){let t=(0,B.useContext)(XF),n=R(),r=B.Children.toArray(e),i=null,a=r.map((e,a)=>{if(typeof e==`string`){let r=eI(e,t,n,i);return i=null,L(B.Fragment,{children:r},`s${a}`)}if(i=null,B.isValidElement(e)&&e.type===iI){let o=tI(t,e.props.children);if(o){let e=r[a+1],s=typeof e==`string`?$F(t,e):[];return i=o,L(ZF,{doc:o,page:s[0]?.page,t:n},`k${a}`)}}return e});return L(P.Fragment,{children:a})}function rI({tex:e,display:t}){let n=(0,B.useMemo)(()=>RE.renderToString(e,{displayMode:t,throwOnError:!1,errorColor:`var(--danger)`}),[e,t]),r=(0,B.useRef)(null),[i,a]=(0,B.useState)(!1);return(0,B.useLayoutEffect)(()=>{let e=r.current;if(t||!e)return;let n=()=>{let t=e.firstElementChild,n=e.parentElement;for(;n&&n.clientWidth===0;)n=n.parentElement;t&&n&&a(t.getBoundingClientRect().width>n.clientWidth)};n();let i=e.closest(`.md-content`);if(!i||typeof ResizeObserver>`u`)return;let o=new ResizeObserver(n);return o.observe(i),()=>o.disconnect()},[n,t]),L(t?`div`:`span`,{ref:r,className:t?`md-math md-math-display`:i?`md-math md-math-wide`:`md-math`,dir:`ltr`,dangerouslySetInnerHTML:{__html:n}})}function iI({className:e,children:t,node:n,...r}){let i=(0,B.useContext)(XF),a=(0,B.useContext)(WF),o=R();if(e?.includes(`math-inline`))return L(rI,{tex:String(t),display:!1});let s=tI(i,t);if(s)return L(ZF,{doc:s,t:o});let c=KF(t);if(c)return L(qF,{path:c});let l=GF(a,t);return l?L(qF,{path:l,label:String(t).trim()}):L(`code`,{className:`inline-code`,dir:`ltr`,...r,children:t})}var aI={code:iI,pre({children:e}){let t=B.Children.toArray(e)[0];if(B.isValidElement(t)&&(t.type===`code`||t.props?.className!==void 0||typeof t.props?.children==`string`)){let e=t.props,n=e?.className||``,r=/language-([\w-]+)/.exec(n),i=String(e?.children||``).replace(/\n$/,``);if(n.includes(`math-display`))return L(rI,{tex:i,display:!0});let a=r?.[1]||``;return L(BF,{lang:a,code:i})}return L(`pre`,{dir:`ltr`,children:e})},table({children:e}){return L(`div`,{className:`md-table-wrap`,children:L(`table`,{className:`md-table`,dir:`auto`,children:e})})},a({href:e,children:t}){return L(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`md-link`,children:t})},p({children:e}){return L(`p`,{className:`md-p`,dir:`auto`,children:L(nI,{children:e})})},h1({children:e}){return L(`h2`,{className:`md-h2`,dir:`auto`,children:L(nI,{children:e})})},h2({children:e}){return L(`h3`,{className:`md-h3`,dir:`auto`,children:L(nI,{children:e})})},h3({children:e}){return L(`h4`,{className:`md-h4`,dir:`auto`,children:L(nI,{children:e})})},h4({children:e}){return L(`h5`,{className:`md-h4`,dir:`auto`,children:L(nI,{children:e})})},ul({children:e}){return L(`ul`,{className:`md-ul`,dir:`auto`,children:e})},ol({children:e,start:t}){return L(`ol`,{className:`md-ol`,start:t,dir:`auto`,children:e})},li({children:e,className:t}){return L(`li`,{className:t?`md-li ${t}`:`md-li`,dir:`auto`,children:L(nI,{children:e})})},blockquote({children:e}){return L(`blockquote`,{className:`md-blockquote`,dir:`auto`,children:L(nI,{children:e})})},hr(){return L(`hr`,{className:`md-hr`})},td({children:e,className:t,style:n}){return L(`td`,{className:t,style:n,children:L(nI,{children:e})})},th({children:e,className:t,style:n}){return L(`th`,{className:t,style:n,children:L(nI,{children:e})})}},oI=[],sI=[Wx,{singleDollarTextMath:!1}];function cI({content:e,showCursor:t,isStreaming:n=!1,writtenFiles:r=oI}){let i=N(e=>e.documents),a=(0,B.useMemo)(()=>JP(i),[i]),o=(0,B.useMemo)(()=>QE(e),[e]);return!e&&!t?null:!e&&t?L(`span`,{className:`cursor`}):L(zF.Provider,{value:n,children:L(XF.Provider,{value:a,children:L(WF.Provider,{value:r,children:z(`div`,{className:`md-content`,children:[L(yv,{remarkPlugins:[Mx,sI,iD,UE,GE],disallowedElements:[...wv],urlTransform:Mv,components:aI,children:o}),t&&L(`span`,{className:`cursor`})]})})})})}var lI=()=>[...N.getState().messages].reverse().find(e=>e.role===`assistant`)?.id;function uI({busy:e}){let t=R(),[n,r]=(0,B.useState)({n:0,text:``}),i=(0,B.useRef)(lI());return(0,B.useEffect)(()=>{e&&(i.current=lI())},[e]),Nd(e,()=>{let e=N.getState().messages,n=e[e.length-1];if(n?.role!==`assistant`||n.id===i.current||n.stopState===`stopped`&&!n.stopError)return;let a=n.failed===!0||fF(n.content);r(e=>({n:e.n+1,text:t(a?`live.replyFailed`:`live.replyReady`)}))}),L(`div`,{className:`turn-announcer`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:L(`span`,{children:n.text},n.n)})}function dI(e){return e.type===`status`&&e.status===`working`&&!e.phase&&(e.message??``).startsWith(`Model is processing`)}function fI(e){return e.phase===`loading_tools`?Ut()(`chat.loadingTools`):e.phase===`model_queue`&&e.queue?pI(e.queue):(e.message||``).trim()}function pI(e){let t=Ut(),n=String(Math.floor(e.waited_s??0));if(e.event===`granted`)return t(`chat.modelQueue.granted`,{seconds:n});let r=e.queue_length??1;return r>1&&e.position!=null?t(`chat.modelQueue.waitingInLine`,{position:String(e.position),length:String(r),seconds:n}):!e.holder&&e.scope!==`process`?t(`chat.modelQueue.priority`,{seconds:n}):t(`chat.modelQueue.waiting`,{seconds:n})}function mI(e,t){let n=++t.current,r=Date.now();switch(e.type){case`thinking`:return{id:n,type:`thinking`,label:`Thinking`,detail:e.content,active:!0,timestamp:r};case`commentary`:return{id:n,type:`commentary`,label:`Commentary`,detail:e.content,active:!1,timestamp:r};case`tool_start`:return{id:n,type:`tool`,label:`Using tool`,tool:e.tool,detail:e.detail,narration:e.narration,active:!0,timestamp:r,mcpServer:e.mcp_server,mcpServerLabel:e.mcp_server_label,mcpTool:e.mcp_tool};case`skill_use`:return{id:n,type:`tool`,label:`Using tool`,tool:`use_skill`,detail:e.skill,narration:`Using skill: ${e.skill}`,active:!1,success:!0,timestamp:r};case`plan`:return{id:n,type:`plan`,label:`Created plan`,planSteps:e.steps,planNarrations:e.step_narrations,currentStep:e.current_step,active:!1,success:!0,timestamp:r};case`step`:return{id:n,type:`status`,label:`Step ${e.step}${e.total?` of ${e.total}`:``}`,active:!0,timestamp:r};case`status`:return e.message?.startsWith(`Agent: `)?null:{id:n,type:`status`,label:e.message||e.status||`Working`,active:e.status===`working`,...e.status===`warning`?{success:!1}:{},timestamp:r};case`agent_error`:return{id:n,type:`error`,label:`Error`,detail:e.content,success:!1,active:!1,timestamp:r};case`policy_alert`:{let t=e.tool||`unknown tool`,i=e.reason||e.message||e.content||`Tool execution was blocked by governance policy.`;return{id:n,type:`policy_alert`,label:`Policy blocked ${t}`,detail:i,tool:t,decision:e.decision||`BLOCK`,reason:i,ruleIds:e.rule_ids??[],policyVersion:e.policy_version,receiptId:e.receipt_id,success:!1,active:!1,timestamp:r}}default:return null}}var hI=`speech_model_downloaded`,gI=new Set([`tool`,`waiting`]);function _I(e){return e.livePhase&&!gI.has(e.livePhase)?e.liveStatus:null}function vI(e,t){let n=N.getState(),r=e.status,i=fI(e);if(e.phase===`recording_found`&&e.section!=null){n.addRecordingSection({section:e.section,sections:e.sections??e.section,start:e.start??``,end:e.end??``,summary:e.summary??``,items:e.items??[]});return}if(e.phase===`recording`&&e.stage!=null){n.setRecordingStage(e.stage,{state:e.state??0,percent:e.percent,etaSeconds:e.eta_seconds});return}if(e.phase===hI&&i){let e={label:i,active:!1,success:!0,kept:!0},r=n.agentSteps[n.agentSteps.length-1];r&&r.type===`status`&&r.active?n.updateLastAgentStep({...e,detail:void 0}):n.addStepBeforeRunningCall({id:++t.current,type:`status`,timestamp:Date.now(),...e}),n.setLiveStatus(null);return}if(e.phase&&i&&n.setLiveStatus(i,e.phase),e.phase===`waiting`||dI(e)||i.toLowerCase().startsWith(`executing `)||r!==`working`&&r!==`warning`&&r!==`info`)return;let a=n.agentSteps[n.agentSteps.length-1];if(a&&a.type===`status`&&a.active&&r!==`warning`){n.updateLastAgentStep({label:i||`Working`,detail:i});return}if(a&&a.type===`thinking`&&a.active){n.updateLastAgentStep({label:i||`Thinking`});return}let o=mI({...e,message:i},t);o&&n.addAgentStep(o)}var yI=/\s*\{\s*"?(?:tool|thought|goal)"?\s*:\s*"[^"]*"[^}]*(?:"?tool_args"?\s*:\s*\{[^}]*\})?\s*\}/g;function bI(e){let t=e.trim();if(!t.startsWith(`{`)||!t.includes(`"thought"`)&&!t.includes(`"answer"`)&&!t.includes(`"goal"`))return e;try{let e=JSON.parse(t);if(e.answer!==void 0)return String(e.answer)}catch{}let n=t.indexOf(`"answer"`);if(n===-1)return``;let r=t.indexOf(`:`,n+8);if(r===-1)return``;let i=r+1;for(;i<t.length&&/\s/.test(t[i]);)i++;if(i>=t.length||t[i]!==`"`)return``;let a=t.slice(i+1);return a.endsWith(`"}`)?a=a.slice(0,-2):a.endsWith(`"`)&&(a=a.slice(0,-1)),a.replace(/\\"/g,`"`).replace(/\\n/g,`
|
|
188
|
-
`).replace(/\\\\/g,`\\`)}function xI(e,t){if(e.type!==`agent_error`||e.recoverable!==!0)return!1;let n=t[t.length-1];return!n||n.type!==`tool`?!1:n.success===!1||!!n.active&&n.success==null}function SI(e){let t=(e||[]).filter(e=>typeof e.render==`string`&&e.render.length>0).reduce((e,t)=>w(e,{render:t.render,data:t.data}),[]);return t.length>0?t:void 0}function CI(e){return(e||[]).map(e=>{let t=e.agentSteps||e.agent_steps||void 0;return{...e,agentSteps:t,cards:e.cards||SI(t),stats:e.stats||e.inference_stats||void 0,turnSummary:e.turnSummary||e.turn_summary||void 0,libraryNotices:e.libraryNotices||e.library_notices||void 0,stopState:e.stopState??(e.stopped?`stopped`:void 0)}})}function wI(e,t,n){let r=e.find(e=>e.id===n.id&&e.role===`user`);if(r)return r;let i=t.findIndex(e=>e.id===n.id);if(i<0)throw Error(`Message ${n.id} is no longer in this chat.`);let a=new Set(e.map(e=>e.id)),o=i-1;for(;o>=0&&!a.has(t[o].id);)o--;let s=o<0?0:e.findIndex(e=>e.id===t[o].id)+1,c=e.slice(s).filter(e=>e.role===`user`),l=0;for(let e of t.slice(o+1,i))e.role===`user`&&c[l]?.content===e.content&&l++;return c[l]?.content===n.content?c[l]:null}function TI(e,t){return!!e&&e.role===`assistant`&&!!t.failureText&&e.content.trim()===t.failureText.trim()}function EI(e,t,n){let r=e.slice(e.findIndex(e=>e.id===t.id)+1);return r.length===0||r.length===1&&(r[0].id===n.id||TI(r[0],n))}function DI(e,t,n){let r=new Set(t.map(e=>e.id)),i=new Set(e.map(e=>e.id)),a=e.filter(e=>!r.has(e.id));for(let e of t){if(i.has(e.id)||n.has(e.id))continue;let t=a.findIndex(t=>t.role===e.role&&t.content.trim()===e.content.trim());if(t<0)continue;let[r]=a.splice(t,1);n.set(e.id,n.get(r.id)??r.id)}}function OI(e,t){let n=e[e.length-1],r=t[t.length-1];if(!n?.failed||!TI(r,n))return t;let i=e=>[...e].reverse().find(e=>e.role===`user`)?.content;return i(e)===i(t)?[...t.slice(0,-1),{...r,failed:!0,failureText:n.failureText}]:t}function kI(e){return`policy-receipt-${encodeURIComponent(e)}`}function AI(e){let t=e.content.trim();return!t||e.stopState||e.failed||e.failure||fF(t)||PN(t,1e3).length===0?!1:!mF(e.agentSteps??[],t).echoed}function jI(){(0,B.useEffect)(()=>{let e=!0,t=async()=>{try{let t=await DN();e&&t&&BN.getState().setSettings(t)}catch(e){F.ui.error(`Could not load the read-aloud settings; replies will not be read automatically`,e)}};return t(),window.addEventListener(`focus`,t),()=>{e=!1,window.removeEventListener(`focus`,t)}},[])}var MI=[`download`,`decode`,`transcribe`,`voices`,`prepare`,`analyze`],NI=0,PI=5;function FI(e,t){return e==null?``:e<60?t(`recording.leftUnderMinute`):t(`recording.leftMinutes`,{minutes:Math.ceil(e/60)})}function II(e){return MI.map((e,t)=>t).filter(t=>t!==NI&&t!==PI||t in e)}function LI({state:e}){return e===1?L(Yr,{size:14,"aria-hidden":`true`}):e===2?L(mo,{size:14,"aria-hidden":`true`}):L(`span`,{className:`recording-progress-dot`,"aria-hidden":`true`})}function RI({index:e,stage:t}){let n=R(),r=n(`recording.stage.${MI[e]}`),i=t?.state===0,a=t?.percent,o=i?FI(t?.etaSeconds,n):``,s=t?.state===2?n(`recording.skipped`):o;return z(`li`,{className:`recording-progress-row${i?` is-running`:``}${t?``:` is-waiting`}${t?.state===1?` is-done`:``}`,children:[L(`span`,{className:`recording-progress-mark`,children:L(LI,{state:t?.state})}),L(`span`,{className:`recording-progress-label`,children:r}),i&&a!=null&&z(`bdi`,{className:`recording-progress-percent`,dir:`ltr`,children:[a,`%`]}),s&&L(`span`,{className:`recording-progress-left`,children:s}),i&&L(`div`,{className:`recording-progress-track${a==null?` is-indeterminate`:``}`,role:`progressbar`,"aria-label":r,"aria-valuemin":a==null?void 0:0,"aria-valuemax":a==null?void 0:100,"aria-valuenow":a??void 0,children:L(`div`,{className:`recording-progress-fill`,style:a==null?void 0:{inlineSize:`${a}%`}})})]})}var zI=120;function BI(e){let t=[];return Object.values(e).sort((e,t)=>e.section-t.section).map(e=>{let n=e.items.filter(e=>{let n=e.title.trim().toLowerCase(),r=t.some(t=>t.title===n&&Math.abs(t.seconds-e.seconds)<zI);return r||t.push({title:n,seconds:e.seconds}),!r});return{...e,items:n}})}function VI({sections:e}){let t=R(),n=BI(e),r=n[0]?.sections??0;return z(`section`,{className:`recording-found`,"aria-label":t(`recording.found.title`),children:[z(`h4`,{className:`recording-found-title`,children:[t(`recording.found.title`),L(`span`,{className:`recording-found-count`,children:t(`recording.found.count`,{done:n.length,total:r})})]}),n.map(e=>z(`div`,{className:`recording-found-section`,children:[z(`p`,{className:`recording-found-span`,children:[z(`bdi`,{dir:`ltr`,className:`recording-found-time`,children:[e.start,`–`,e.end]}),e.summary&&L(`span`,{dir:`auto`,children:e.summary})]}),e.items.length>0&&L(`ul`,{className:`recording-found-items`,children:e.items.map(e=>z(`li`,{children:[L(`bdi`,{dir:`ltr`,className:`recording-found-time`,children:e.start}),L(`span`,{dir:`auto`,children:e.title})]},`${e.seconds}-${e.title}`))})]},e.section))]})}function HI(){let e=R(),t=N(e=>e.recordingStages),n=N(e=>e.recordingSections);return t?z(`section`,{className:`recording-progress`,"aria-label":e(`recording.title`),children:[L(`ol`,{className:`recording-progress-list`,children:II(t).map(e=>L(RI,{index:e,stage:t[e]},e))}),n&&L(VI,{sections:n})]}):null}function UI(e,t){let n=e.tool||``,r=e.tool_label||n,{addNotification:i,notifications:a}=zl.getState(),o=e.confirm_id?a.find(t=>t.id===e.confirm_id):void 0;if(o){!o.response&&o.dismissed&&zl.setState(e=>({notifications:e.notifications.map(e=>e.id===o.id?{...e,dismissed:!1}:e)}));return}let s=n===Tl,c=s&&Il(a,t,e.args);i({id:e.confirm_id??`perm-${Date.now()}`,type:`permission_request`,agentId:t,sessionId:t,agentName:`GAIA`,title:s?Ol(e.args,c):n===`trust_project_folder`?`Trust this folder's instructions and skills?`:`Allow ${r}?`,message:s?Dl(e.args,c):n===`trust_project_folder`?`GAIA would put this folder's CLAUDE.md, AGENTS.md and skills in the model's prompt, now and every time you work in it.`:`GAIA needs your OK before ${r}.`,timestamp:Date.now(),read:!1,dismissed:!1,priority:`high`,tool:n,toolArgs:e.args,confirmId:e.confirm_id,alwaysScope:typeof e.always_scope==`string`?e.always_scope:void 0,alwaysLabel:typeof e.always_label==`string`&&e.always_label?e.always_label:void 0,toolLabel:e.tool_label||void 0,risk:typeof e.risk==`string`?e.risk:void 0,summary:typeof e.summary==`string`&&e.summary?e.summary:void 0,pathFollowUp:c||void 0,timeoutSeconds:e.timeout_seconds,expiresAt:typeof e.expires_at==`number`?e.expires_at*1e3:void 0})}function WI(e,t,n){let r=e.tool||`unknown tool`,i=e.reason||e.message||e.content||`Tool execution was blocked by governance policy.`;return{id:e.receipt_id??n,type:`policy_alert`,agentId:t,agentName:`GAIA`,title:`Blocked: ${r} is restricted by policy.`,message:i,timestamp:Date.now(),read:!1,dismissed:!1,priority:`critical`,tool:r,decision:e.decision||`BLOCK`,reason:i,ruleIds:e.rule_ids??[],policyVersion:e.policy_version,receiptId:e.receipt_id}}function GI(e){let t=e.data&&typeof e.data==`object`?e.data:{};return(e.status??t.status)===`denied`?e.timed_out===!0||t.timed_out===!0?`timedOut`:(e.denied_by??t.denied_by)===`policy`?`refused`:(e.declined_by??t.declined_by)===`agent`?`autoDeclined`:`declined`:null}function KI(e){let t={result:e.summary||e.title||`Done`,active:!1,success:e.success!==!1,latencyMs:e.latency_ms},n=GI(e);n&&(t[n]=!0),e.command_output&&(t.commandOutput={command:e.command_output.command,stdout:e.command_output.stdout,stderr:e.command_output.stderr,returnCode:e.command_output.return_code,expectedExit:e.command_output.expected_exit,cwd:e.command_output.cwd,durationSeconds:e.command_output.duration_seconds,truncated:e.command_output.truncated}),e.mcp_output?.text&&(t.mcpOutput=e.mcp_output),e.result_data?.chunks&&e.result_data.chunks.length>0&&(t.retrievalChunks=e.result_data.chunks.map(e=>({id:e.id,source:e.source,sourcePath:e.sourcePath,page:e.page,score:e.score,preview:e.preview,content:e.content}))),e.result_data?.type===`file_list`&&e.result_data.files?.length>0&&(t.fileList={files:e.result_data.files,total:e.result_data.total??e.result_data.files.length});let r=e.data&&typeof e.data==`object`?e.data.needs_model:void 0;return(e.needs_model??r)===`vision`&&(t.needsModel=`vision`),t}var qI=5e3,JI=2e3,YI=3e4,XI=6e4;function ZI(e){return e?.init_state===`initializing`?!e.init_tasks||e.init_tasks.some(e=>e.status===`pending`||e.status===`running`):!1}function QI(e){return e.lemonade_running?`up`:e.lemonade_error?`unresponsive`:`down`}function $I(e){return e.kind===`slow`||e.kind===`error`||e.kind===`ok`&&QI(e.status)===`unresponsive`}function eL(e){let t=e.kind===`ok`?e.status.download_progress?.state:void 0;return t===`downloading`||t===`starting`}function tL(e){let t=null,n=0,r=!1,i=null,a=null,o=!1,s=!1,c=()=>{o||!s||a||(a=setTimeout(()=>{a=null,f()},p()))},l=0,u=null,d=async()=>{let e={controller:new AbortController,cancelled:!1};u=e;let{controller:t}=e,n=setTimeout(()=>t.abort(),XI);try{return{kind:`ok`,status:await se(t.signal)}}catch(n){if(e.cancelled)return null;if(t.signal.aborted)return{kind:`slow`};let r=n?.httpStatus;return r===504?{kind:`slow`}:n?.name===`ApiError`&&typeof r==`number`&&r!==502?{kind:`error`,httpStatus:r,message:n.message}:{kind:`unreachable`,error:n}}finally{clearTimeout(n),u===e&&(u=null)}},f=()=>{if(t)return t;let i=d().then(t=>{if(t!==null){n=$I(t)?n+1:0,r=eL(t),t.kind===`ok`?s=ZI(t.status):t.kind===`unreachable`&&(s=!1),c();try{e(t)}catch(e){F.system.error(`Could not apply the system status; the next poll will try again`,e)}}}).finally(()=>{t===i&&(t=null)});return t=i,i},p=()=>Math.min((r?JI:qI)*2**n,YI),m=e=>{f().finally(()=>{e===l&&(i=setTimeout(()=>m(e),p()))})};return{check:f,start:()=>{let e=++l;return o=!0,a&&clearTimeout(a),a=null,m(e),()=>{e===l&&(l++,o=!1,c(),i&&clearTimeout(i),i=null,u&&(u.cancelled=!0,u.controller.abort(),u=null,t=null))}}}}var nL=1e3,rL=15e3,iL=null,aL=null,oL=nL,sL=0,cL=null;function lL(){if(iL)return iL;let e=Date.now();return iL=Kt().then(t=>N.getState().setActiveRuns(t,e)).catch(e=>{F.api.warn(`Could not read which chats are running`,e),rN(e)&&N.getState().loseActiveRuns()}).finally(()=>{iL=null}),iL}function uL(){let e=N.getState();return e.isStreaming||e.runningSessionIds.length>0}function dL(){return uL()?(oL=nL,nL):(oL=Math.min(oL*2,rL),oL)}function fL(e){lL().then(()=>{e===sL&&(aL=setTimeout(()=>fL(e),dL()))})}function pL(){cL&&(aL&&clearTimeout(aL),aL=null,oL=nL,fL(++sL))}function mL(){cL?.();let e=N.subscribe((e,t)=>{e.isStreaming&&!t.isStreaming&&pL()}),t=()=>pL();window.addEventListener(`focus`,t);let n=()=>{sL++,aL&&clearTimeout(aL),aL=null,e(),window.removeEventListener(`focus`,t),cL===n&&(cL=null)};return cL=n,oL=nL,fL(++sL),n}var hL=3e3,gL=new Set,_L=new Map,vL=new Set,yL=null;function bL(e,t=Date.now()){_L.set(e,t)}function xL(e){let t=N.getState();return t.activeRunsAt>0&&t.activeRunsAt>=(_L.get(e)??0)&&!t.runningSessionIds.includes(e)&&!t.queuedSessionIds.includes(e)}function SL(e){return vL.add(e),()=>{vL.delete(e),yL?.()}}function CL(e){return e instanceof Error?YN(e)??(e.message||`Unknown error`):String(e)}function wL(e){let t=e?.httpStatus;return typeof t==`number`?t:void 0}function TL(e){let t=wL(e);return t===409||t===429}function EL(e){F.chat.warn(`Chat ${e} no longer exists; dropping its queued messages`),N.getState().updateQueue(e,()=>[])}function DL(e){N.getState().setQueueHold(e,!0),setTimeout(()=>N.getState().setQueueHold(e,!1),hL)}function OL(e,t,n){return wL(n)===409&&(F.chat.info(`Chat ${e} was busy; queueing the message to try again`),N.getState().updateQueue(e,e=>Qn(e,t,`queued`)),DL(e),!0)}async function kL(e,t,n){let r=N.getState;if(gL.has(e)||r().queueHolds[e])return;let i=r().messageQueues[e]??[];if(i.some(e=>e.state===`sending`))return;let a=Yn(i);if(a||Le(i)){gL.add(e);try{if(a){let t;try{t=await Fn(e)}catch(t){if(wL(t)===409){F.chat.info(`Chat ${e} is answering again; its queue waits for that turn to end`);return}if(wL(t)===404){EL(e);return}F.chat.error(`Could not learn what chat ${e}'s last reply did with the messages added to it`,t),r().updateQueue(e,e=>Pe(e,`GAIA could not say whether it read this message: ${CL(t)}`));return}r().updateQueue(e,e=>ye(e,t))}let i=Le(r().messageQueues[e]??[]);if(!i||!n())return;r().updateQueue(e,e=>m(e,i.id,`queued`,`starting`));let o;try{o=await t(e,i.text)}catch(e){o={kind:`failed`,error:CL(e)}}if(o.kind===`accepted`){bL(e),r().updateQueue(e,e=>Zt(e,i.id)),pL();return}if(o.kind===`busy`){F.chat.info(`Queued message found chat ${e} busy; holding it`),r().updateQueue(e,e=>_(e,i.id)),DL(e);return}if(o.kind===`gone`){EL(e);return}F.chat.error(`Queued message for chat ${e} was not sent: ${o.error}`),r().updateQueue(e,e=>_(e,i.id,o.error))}finally{gL.delete(e)}}}function AL(e){return e.type!==`status`||e.phase!==`waiting`}var jL=(e,t)=>new Promise(n=>{let r=!1,i=null,a=!1,o=e=>{r||(r=!0,e.kind===`accepted`&&(i?i.abort():a=!0),n(e))},s=()=>o({kind:`accepted`});F.chat.info(`Sending queued message for chat ${e} in the background`),i=v(e,t,{onChunk:s,onAgentEvent:e=>{AL(e)&&s()},onDone:s,onError:e=>{KN(e)?s():TL(e)?o({kind:`busy`}):wL(e)===404?o({kind:`gone`}):o({kind:`failed`,error:CL(e)})}}),a&&i.abort()});function ML(e=jL){let t=()=>{let t=N.getState();if(!ZI(t.systemStatus))for(let n of Object.keys(t.messageQueues))!vL.has(n)&&xL(n)&&kL(n,e,()=>!vL.has(n))},n=N.subscribe((e,n)=>{(e.messageQueues!==n.messageQueues||e.queueHolds!==n.queueHolds||e.activeRunsAt!==n.activeRunsAt||e.runningSessionIds!==n.runningSessionIds||e.systemStatus!==n.systemStatus)&&t()});return yL=t,t(),()=>{n(),yL===t&&(yL=null)}}var NL=new Set([`.3g2`,`.3gp`,`.asf`,`.avi`,`.divx`,`.f4v`,`.flv`,`.m2ts`,`.m2v`,`.m4v`,`.mkv`,`.mov`,`.mp4`,`.mpeg`,`.mpg`,`.mts`,`.mxf`,`.ogv`,`.rm`,`.rmvb`,`.vob`,`.webm`,`.wmv`]),PL=new Set([`.aac`,`.ac3`,`.aif`,`.aiff`,`.amr`,`.ape`,`.au`,`.caf`,`.dts`,`.eac3`,`.flac`,`.m4a`,`.m4b`,`.mka`,`.mp2`,`.mp3`,`.oga`,`.ogg`,`.opus`,`.spx`,`.wav`,`.wma`,`.wv`]);function FL(e){let t=e.lastIndexOf(`.`);return t<0?``:e.slice(t).toLowerCase()}function IL(e){return NL.has(FL(e))}function LL(e){let t=FL(e);return NL.has(t)||PL.has(t)}function RL(e,t){return e===`model_server_down`?t(`docs.serverDown`):e===`model_server_busy`?t(`docs.serverBusy`):null}function zL(e){return e===`model_server_down`}function BL(e){return e===`model_server_busy`}function VL(e,t,n){return e===`model_server_down`?n(`docs.notAddedServer`,{name:t}):e===`model_server_busy`?n(`docs.notAddedServerBusy`,{name:t}):null}var HL=`https://github.com/amd/gaia/issues/new`,UL=[{label:`Image`,extensions:new Set([`.ico`,`.heic`,`.heif`]),message:`This image format cannot be indexed.`,alternatives:[`Convert it to PNG or JPEG — GAIA reads the text in those images`],featureTitle:`Support HEIC and ICO image indexing`},{label:`Video`,extensions:NL,message:`Video files can't go in the document library.`,alternatives:[`Attach the video to a chat, and GAIA will transcribe it`],featureTitle:`Support video files in the document library`},{label:`Audio`,extensions:PL,message:`Audio files can't go in the document library.`,alternatives:[`Attach the recording to a chat, and GAIA will transcribe it`],featureTitle:`Support audio files in the document library`},{label:`Archive`,extensions:new Set([`.zip`,`.rar`,`.7z`,`.tar`,`.gz`,`.bz2`,`.xz`,`.tgz`]),message:`Archive files must be extracted before indexing.`,alternatives:[`Extract the archive contents to a folder`,`Then index the folder or individual files from the Document Library`],featureTitle:`Support automatic archive extraction for indexing`},{label:`Executable`,extensions:new Set([`.exe`,`.msi`,`.dll`,`.so`,`.app`,`.dmg`,`.bin`,`.com`]),message:`Executable and binary files cannot be indexed.`,alternatives:[`Index source code files (.py, .js, .ts, .java, etc.) instead`,`Index documentation or README files from the project`],featureTitle:`Support binary file analysis`},{label:`Database`,extensions:new Set([`.sqlite`,`.db`,`.mdb`,`.accdb`,`.dbf`]),message:`Database files are not supported for direct indexing.`,alternatives:[`Export data to CSV or JSON format, then index those files`,`Use SQL queries to extract relevant data to a text file`],featureTitle:`Support database file indexing`},{label:`Microsoft Office`,extensions:new Set([`.doc`,`.ppt`,`.xls`]),message:`Legacy Office formats (.doc, legacy PowerPoint .ppt, legacy Excel .xls) are not supported — GAIA reads only the modern XML-based formats. Modern Word (.docx), PowerPoint (.pptx), and Excel (.xlsx) are supported.`,alternatives:[`Re-save as .docx — GAIA indexes modern Word documents directly`,`Save modern PowerPoint as .pptx — GAIA indexes .pptx directly`,`Re-save legacy .xls workbooks as .xlsx — GAIA supports modern Excel files`],featureTitle:`Support legacy Microsoft Office (doc, ppt, xls) indexing`}];function WL(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;for(let e of UL)if(e.extensions.has(t))return e;return null}var GL=new Set(`.pdf,.pptx,.docx,.epub,.png,.jpg,.jpeg,.webp,.bmp,.gif,.tif,.tiff,.txt,.md,.mdx,.markdown,.rst,.csv,.json,.xlsx,.html,.htm,.xml,.svg,.yaml,.yml,.py,.js,.ts,.java,.c,.cpp,.h,.rs,.go,.rb,.sh,.bat,.ps1,.log,.cfg,.ini,.toml`.split(`,`));function KL(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;return GL.has(t)}function qL(){let e=navigator.userAgent;return`**Environment:**\n- GAIA Version: 0.27.0rc6\n- Platform: ${navigator.platform||`unknown`}\n- User Agent: ${e}\n- Interface: Agent UI (Web)`}function JL(e,t){let n=[`## Feature Description`,``,t||`I would like GAIA to support: **${e}**`,``,`## Use Case`,``,`_Describe how you would use this feature:_`,``,`## Current Workaround`,``,`_Is there a workaround you are currently using?_`,``,`---`,qL(),``,`_Submitted from GAIA Agent UI_`].join(`
|
|
188
|
+
`).replace(/\\\\/g,`\\`)}function xI(e,t){if(e.type!==`agent_error`||e.recoverable!==!0)return!1;let n=t[t.length-1];return!n||n.type!==`tool`?!1:n.success===!1||!!n.active&&n.success==null}function SI(e){let t=(e||[]).filter(e=>typeof e.render==`string`&&e.render.length>0).reduce((e,t)=>w(e,{render:t.render,data:t.data}),[]);return t.length>0?t:void 0}function CI(e){return(e||[]).map(e=>{let t=e.agentSteps||e.agent_steps||void 0;return{...e,agentSteps:t,cards:e.cards||SI(t),stats:e.stats||e.inference_stats||void 0,turnSummary:e.turnSummary||e.turn_summary||void 0,libraryNotices:e.libraryNotices||e.library_notices||void 0,stopState:e.stopState??(e.stopped?`stopped`:void 0)}})}function wI(e,t,n){let r=e.find(e=>e.id===n.id&&e.role===`user`);if(r)return r;let i=t.findIndex(e=>e.id===n.id);if(i<0)throw Error(`Message ${n.id} is no longer in this chat.`);let a=new Set(e.map(e=>e.id)),o=i-1;for(;o>=0&&!a.has(t[o].id);)o--;let s=o<0?0:e.findIndex(e=>e.id===t[o].id)+1,c=e.slice(s).filter(e=>e.role===`user`),l=0;for(let e of t.slice(o+1,i))e.role===`user`&&c[l]?.content===e.content&&l++;return c[l]?.content===n.content?c[l]:null}function TI(e,t){return!!e&&e.role===`assistant`&&!!t.failureText&&e.content.trim()===t.failureText.trim()}function EI(e,t,n){let r=e.slice(e.findIndex(e=>e.id===t.id)+1);return r.length===0||r.length===1&&(r[0].id===n.id||TI(r[0],n))}function DI(e,t,n){let r=new Set(t.map(e=>e.id)),i=new Set(e.map(e=>e.id)),a=e.filter(e=>!r.has(e.id));for(let e of t){if(i.has(e.id)||n.has(e.id))continue;let t=a.findIndex(t=>t.role===e.role&&t.content.trim()===e.content.trim());if(t<0)continue;let[r]=a.splice(t,1);n.set(e.id,n.get(r.id)??r.id)}}function OI(e,t){let n=e[e.length-1],r=t[t.length-1];if(!n?.failed||!TI(r,n))return t;let i=e=>[...e].reverse().find(e=>e.role===`user`)?.content;return i(e)===i(t)?[...t.slice(0,-1),{...r,failed:!0,failureText:n.failureText}]:t}function kI(e){return`policy-receipt-${encodeURIComponent(e)}`}function AI(e){let t=e.content.trim();return!t||e.stopState||e.failed||e.failure||fF(t)||PN(t,1e3).length===0?!1:!mF(e.agentSteps??[],t).echoed}function jI(){(0,B.useEffect)(()=>{let e=!0,t=async()=>{try{let t=await DN();e&&t&&BN.getState().setSettings(t)}catch(e){F.ui.error(`Could not load the read-aloud settings; replies will not be read automatically`,e)}};return t(),window.addEventListener(`focus`,t),()=>{e=!1,window.removeEventListener(`focus`,t)}},[])}var MI=[`download`,`decode`,`transcribe`,`voices`,`prepare`,`analyze`],NI=0,PI=5;function FI(e,t){return e==null?``:e<60?t(`recording.leftUnderMinute`):t(`recording.leftMinutes`,{minutes:Math.ceil(e/60)})}function II(e){return MI.map((e,t)=>t).filter(t=>t!==NI&&t!==PI||t in e)}function LI({state:e}){return e===1?L(Yr,{size:14,"aria-hidden":`true`}):e===2?L(mo,{size:14,"aria-hidden":`true`}):L(`span`,{className:`recording-progress-dot`,"aria-hidden":`true`})}function RI({index:e,stage:t}){let n=R(),r=n(`recording.stage.${MI[e]}`),i=t?.state===0,a=t?.percent,o=i?FI(t?.etaSeconds,n):``,s=t?.state===2?n(`recording.skipped`):o;return z(`li`,{className:`recording-progress-row${i?` is-running`:``}${t?``:` is-waiting`}${t?.state===1?` is-done`:``}`,children:[L(`span`,{className:`recording-progress-mark`,children:L(LI,{state:t?.state})}),L(`span`,{className:`recording-progress-label`,children:r}),i&&a!=null&&z(`bdi`,{className:`recording-progress-percent`,dir:`ltr`,children:[a,`%`]}),s&&L(`span`,{className:`recording-progress-left`,children:s}),i&&L(`div`,{className:`recording-progress-track${a==null?` is-indeterminate`:``}`,role:`progressbar`,"aria-label":r,"aria-valuemin":a==null?void 0:0,"aria-valuemax":a==null?void 0:100,"aria-valuenow":a??void 0,children:L(`div`,{className:`recording-progress-fill`,style:a==null?void 0:{inlineSize:`${a}%`}})})]})}var zI=120;function BI(e){let t=[];return Object.values(e).sort((e,t)=>e.section-t.section).map(e=>{let n=e.items.filter(e=>{let n=e.title.trim().toLowerCase(),r=t.some(t=>t.title===n&&Math.abs(t.seconds-e.seconds)<zI);return r||t.push({title:n,seconds:e.seconds}),!r});return{...e,items:n}})}function VI({sections:e}){let t=R(),n=BI(e),r=n[0]?.sections??0;return z(`section`,{className:`recording-found`,"aria-label":t(`recording.found.title`),children:[z(`h4`,{className:`recording-found-title`,children:[t(`recording.found.title`),L(`span`,{className:`recording-found-count`,children:t(`recording.found.count`,{done:n.length,total:r})})]}),n.map(e=>z(`div`,{className:`recording-found-section`,children:[z(`p`,{className:`recording-found-span`,children:[z(`bdi`,{dir:`ltr`,className:`recording-found-time`,children:[e.start,`–`,e.end]}),e.summary&&L(`span`,{dir:`auto`,children:e.summary})]}),e.items.length>0&&L(`ul`,{className:`recording-found-items`,children:e.items.map(e=>z(`li`,{children:[L(`bdi`,{dir:`ltr`,className:`recording-found-time`,children:e.start}),L(`span`,{dir:`auto`,children:e.title})]},`${e.seconds}-${e.title}`))})]},e.section))]})}function HI(){let e=R(),t=N(e=>e.recordingStages),n=N(e=>e.recordingSections);return t?z(`section`,{className:`recording-progress`,"aria-label":e(`recording.title`),children:[L(`ol`,{className:`recording-progress-list`,children:II(t).map(e=>L(RI,{index:e,stage:t[e]},e))}),n&&L(VI,{sections:n})]}):null}function UI(e,t){let n=e.tool||``,r=e.tool_label||n,{addNotification:i,notifications:a}=zl.getState(),o=e.confirm_id?a.find(t=>t.id===e.confirm_id):void 0;if(o){!o.response&&o.dismissed&&zl.setState(e=>({notifications:e.notifications.map(e=>e.id===o.id?{...e,dismissed:!1}:e)}));return}let s=n===Tl,c=s&&Il(a,t,e.args);i({id:e.confirm_id??`perm-${Date.now()}`,type:`permission_request`,agentId:t,sessionId:t,agentName:`GAIA`,title:s?Ol(e.args,c):n===`trust_project_folder`?`Trust this folder's instructions and skills?`:`Allow ${r}?`,message:s?Dl(e.args,c):n===`trust_project_folder`?`GAIA would put this folder's CLAUDE.md, AGENTS.md and skills in the model's prompt, now and every time you work in it.`:`GAIA needs your OK before ${r}.`,timestamp:Date.now(),read:!1,dismissed:!1,priority:`high`,tool:n,toolArgs:e.args,confirmId:e.confirm_id,alwaysScope:typeof e.always_scope==`string`?e.always_scope:void 0,alwaysLabel:typeof e.always_label==`string`&&e.always_label?e.always_label:void 0,toolLabel:e.tool_label||void 0,risk:typeof e.risk==`string`?e.risk:void 0,summary:typeof e.summary==`string`&&e.summary?e.summary:void 0,pathFollowUp:c||void 0,timeoutSeconds:e.timeout_seconds,expiresAt:typeof e.expires_at==`number`?e.expires_at*1e3:void 0})}function WI(e,t,n){let r=e.tool||`unknown tool`,i=e.reason||e.message||e.content||`Tool execution was blocked by governance policy.`;return{id:e.receipt_id??n,type:`policy_alert`,agentId:t,agentName:`GAIA`,title:`Blocked: ${r} is restricted by policy.`,message:i,timestamp:Date.now(),read:!1,dismissed:!1,priority:`critical`,tool:r,decision:e.decision||`BLOCK`,reason:i,ruleIds:e.rule_ids??[],policyVersion:e.policy_version,receiptId:e.receipt_id}}function GI(e){let t=e.data&&typeof e.data==`object`?e.data:{};return(e.status??t.status)===`denied`?e.timed_out===!0||t.timed_out===!0?`timedOut`:(e.denied_by??t.denied_by)===`policy`?`refused`:(e.declined_by??t.declined_by)===`agent`?`autoDeclined`:`declined`:null}function KI(e){let t={result:e.summary||e.title||`Done`,active:!1,success:e.success!==!1,latencyMs:e.latency_ms},n=GI(e);n&&(t[n]=!0),e.command_output&&(t.commandOutput={command:e.command_output.command,stdout:e.command_output.stdout,stderr:e.command_output.stderr,returnCode:e.command_output.return_code,expectedExit:e.command_output.expected_exit,cwd:e.command_output.cwd,durationSeconds:e.command_output.duration_seconds,truncated:e.command_output.truncated}),e.mcp_output?.text&&(t.mcpOutput=e.mcp_output),e.result_data?.chunks&&e.result_data.chunks.length>0&&(t.retrievalChunks=e.result_data.chunks.map(e=>({id:e.id,source:e.source,sourcePath:e.sourcePath,page:e.page,score:e.score,preview:e.preview,content:e.content}))),e.result_data?.type===`file_list`&&e.result_data.files?.length>0&&(t.fileList={files:e.result_data.files,total:e.result_data.total??e.result_data.files.length});let r=e.data&&typeof e.data==`object`?e.data.needs_model:void 0;return(e.needs_model??r)===`vision`&&(t.needsModel=`vision`),t}var qI=5e3,JI=2e3,YI=3e4,XI=6e4;function ZI(e){return e?.init_state===`initializing`?!e.init_tasks||e.init_tasks.some(e=>e.status===`pending`||e.status===`running`):!1}function QI(e){return e.lemonade_running?`up`:e.lemonade_error?`unresponsive`:`down`}function $I(e){return e.kind===`slow`||e.kind===`error`||e.kind===`ok`&&QI(e.status)===`unresponsive`}function eL(e){let t=e.kind===`ok`?e.status.download_progress?.state:void 0;return t===`downloading`||t===`starting`}function tL(e){let t=null,n=0,r=!1,i=null,a=null,o=!1,s=!1,c=()=>{o||!s||a||(a=setTimeout(()=>{a=null,f()},p()))},l=0,u=null,d=async()=>{let e={controller:new AbortController,cancelled:!1};u=e;let{controller:t}=e,n=setTimeout(()=>t.abort(),XI);try{return{kind:`ok`,status:await se(t.signal)}}catch(n){if(e.cancelled)return null;if(t.signal.aborted)return{kind:`slow`};let r=n?.httpStatus;return r===504?{kind:`slow`}:n?.name===`ApiError`&&typeof r==`number`&&r!==502?{kind:`error`,httpStatus:r,message:n.message}:{kind:`unreachable`,error:n}}finally{clearTimeout(n),u===e&&(u=null)}},f=()=>{if(t)return t;let i=d().then(t=>{if(t!==null){n=$I(t)?n+1:0,r=eL(t),t.kind===`ok`?s=ZI(t.status):t.kind===`unreachable`&&(s=!1),c();try{e(t)}catch(e){F.system.error(`Could not apply the system status; the next poll will try again`,e)}}}).finally(()=>{t===i&&(t=null)});return t=i,i},p=()=>Math.min((r?JI:qI)*2**n,YI),m=e=>{f().finally(()=>{e===l&&(i=setTimeout(()=>m(e),p()))})};return{check:f,start:()=>{let e=++l;return o=!0,a&&clearTimeout(a),a=null,m(e),()=>{e===l&&(l++,o=!1,c(),i&&clearTimeout(i),i=null,u&&(u.cancelled=!0,u.controller.abort(),u=null,t=null))}}}}var nL=1e3,rL=15e3,iL=null,aL=null,oL=nL,sL=0,cL=null;function lL(){if(iL)return iL;let e=Date.now();return iL=Kt().then(t=>N.getState().setActiveRuns(t,e)).catch(e=>{F.api.warn(`Could not read which chats are running`,e),rN(e)&&N.getState().loseActiveRuns()}).finally(()=>{iL=null}),iL}function uL(){let e=N.getState();return e.isStreaming||e.runningSessionIds.length>0}function dL(){return uL()?(oL=nL,nL):(oL=Math.min(oL*2,rL),oL)}function fL(e){lL().then(()=>{e===sL&&(aL=setTimeout(()=>fL(e),dL()))})}function pL(){cL&&(aL&&clearTimeout(aL),aL=null,oL=nL,fL(++sL))}function mL(){cL?.();let e=N.subscribe((e,t)=>{e.isStreaming&&!t.isStreaming&&pL()}),t=()=>pL();window.addEventListener(`focus`,t);let n=()=>{sL++,aL&&clearTimeout(aL),aL=null,e(),window.removeEventListener(`focus`,t),cL===n&&(cL=null)};return cL=n,oL=nL,fL(++sL),n}var hL=3e3,gL=new Set,_L=new Map,vL=new Set,yL=null;function bL(e,t=Date.now()){_L.set(e,t)}function xL(e){let t=N.getState();return t.activeRunsAt>0&&t.activeRunsAt>=(_L.get(e)??0)&&!t.runningSessionIds.includes(e)&&!t.queuedSessionIds.includes(e)}function SL(e){return vL.add(e),()=>{vL.delete(e),yL?.()}}function CL(e){return e instanceof Error?YN(e)??(e.message||`Unknown error`):String(e)}function wL(e){let t=e?.httpStatus;return typeof t==`number`?t:void 0}function TL(e){let t=wL(e);return t===409||t===429}function EL(e){F.chat.warn(`Chat ${e} no longer exists; dropping its queued messages`),N.getState().updateQueue(e,()=>[])}function DL(e){N.getState().setQueueHold(e,!0),setTimeout(()=>N.getState().setQueueHold(e,!1),hL)}function OL(e,t,n){return wL(n)===409&&(F.chat.info(`Chat ${e} was busy; queueing the message to try again`),N.getState().updateQueue(e,e=>Qn(e,t,`queued`)),DL(e),!0)}async function kL(e,t,n){let r=N.getState;if(gL.has(e)||r().queueHolds[e])return;let i=r().messageQueues[e]??[];if(i.some(e=>e.state===`sending`))return;let a=Yn(i);if(a||Le(i)){gL.add(e);try{if(a){let t;try{t=await Fn(e)}catch(t){if(wL(t)===409){F.chat.info(`Chat ${e} is answering again; its queue waits for that turn to end`);return}if(wL(t)===404){EL(e);return}F.chat.error(`Could not learn what chat ${e}'s last reply did with the messages added to it`,t),r().updateQueue(e,e=>Pe(e,`GAIA could not say whether it read this message: ${CL(t)}`));return}r().updateQueue(e,e=>ye(e,t))}let i=Le(r().messageQueues[e]??[]);if(!i||!n())return;r().updateQueue(e,e=>m(e,i.id,`queued`,`starting`));let o;try{o=await t(e,i.text)}catch(e){o={kind:`failed`,error:CL(e)}}if(o.kind===`accepted`){bL(e),r().updateQueue(e,e=>Zt(e,i.id)),pL();return}if(o.kind===`busy`){F.chat.info(`Queued message found chat ${e} busy; holding it`),r().updateQueue(e,e=>_(e,i.id)),DL(e);return}if(o.kind===`gone`){EL(e);return}F.chat.error(`Queued message for chat ${e} was not sent: ${o.error}`),r().updateQueue(e,e=>_(e,i.id,o.error))}finally{gL.delete(e)}}}function AL(e){return e.type!==`status`||e.phase!==`waiting`}var jL=(e,t)=>new Promise(n=>{let r=!1,i=null,a=!1,o=e=>{r||(r=!0,e.kind===`accepted`&&(i?i.abort():a=!0),n(e))},s=()=>o({kind:`accepted`});F.chat.info(`Sending queued message for chat ${e} in the background`),i=v(e,t,{onChunk:s,onAgentEvent:e=>{AL(e)&&s()},onDone:s,onError:e=>{KN(e)?s():TL(e)?o({kind:`busy`}):wL(e)===404?o({kind:`gone`}):o({kind:`failed`,error:CL(e)})}}),a&&i.abort()});function ML(e=jL){let t=()=>{let t=N.getState();if(!ZI(t.systemStatus))for(let n of Object.keys(t.messageQueues))!vL.has(n)&&xL(n)&&kL(n,e,()=>!vL.has(n))},n=N.subscribe((e,n)=>{(e.messageQueues!==n.messageQueues||e.queueHolds!==n.queueHolds||e.activeRunsAt!==n.activeRunsAt||e.runningSessionIds!==n.runningSessionIds||e.systemStatus!==n.systemStatus)&&t()});return yL=t,t(),()=>{n(),yL===t&&(yL=null)}}var NL=new Set([`.3g2`,`.3gp`,`.asf`,`.avi`,`.divx`,`.f4v`,`.flv`,`.m2ts`,`.m2v`,`.m4v`,`.mkv`,`.mov`,`.mp4`,`.mpeg`,`.mpg`,`.mts`,`.mxf`,`.ogv`,`.rm`,`.rmvb`,`.vob`,`.webm`,`.wmv`]),PL=new Set([`.aac`,`.ac3`,`.aif`,`.aiff`,`.amr`,`.ape`,`.au`,`.caf`,`.dts`,`.eac3`,`.flac`,`.m4a`,`.m4b`,`.mka`,`.mp2`,`.mp3`,`.oga`,`.ogg`,`.opus`,`.spx`,`.wav`,`.wma`,`.wv`]);function FL(e){let t=e.lastIndexOf(`.`);return t<0?``:e.slice(t).toLowerCase()}function IL(e){return NL.has(FL(e))}function LL(e){let t=FL(e);return NL.has(t)||PL.has(t)}function RL(e,t){return e===`model_server_down`?t(`docs.serverDown`):e===`model_server_busy`?t(`docs.serverBusy`):null}function zL(e){return e===`model_server_down`}function BL(e){return e===`model_server_busy`}function VL(e,t,n){return e===`model_server_down`?n(`docs.notAddedServer`,{name:t}):e===`model_server_busy`?n(`docs.notAddedServerBusy`,{name:t}):null}var HL=`https://github.com/amd/gaia/issues/new`,UL=[{label:`Image`,extensions:new Set([`.ico`,`.heic`,`.heif`]),message:`This image format cannot be indexed.`,alternatives:[`Convert it to PNG or JPEG — GAIA reads the text in those images`],featureTitle:`Support HEIC and ICO image indexing`},{label:`Video`,extensions:NL,message:`Video files can't go in the document library.`,alternatives:[`Attach the video to a chat, and GAIA will transcribe it`],featureTitle:`Support video files in the document library`},{label:`Audio`,extensions:PL,message:`Audio files can't go in the document library.`,alternatives:[`Attach the recording to a chat, and GAIA will transcribe it`],featureTitle:`Support audio files in the document library`},{label:`Archive`,extensions:new Set([`.zip`,`.rar`,`.7z`,`.tar`,`.gz`,`.bz2`,`.xz`,`.tgz`]),message:`Archive files must be extracted before indexing.`,alternatives:[`Extract the archive contents to a folder`,`Then index the folder or individual files from the Document Library`],featureTitle:`Support automatic archive extraction for indexing`},{label:`Executable`,extensions:new Set([`.exe`,`.msi`,`.dll`,`.so`,`.app`,`.dmg`,`.bin`,`.com`]),message:`Executable and binary files cannot be indexed.`,alternatives:[`Index source code files (.py, .js, .ts, .java, etc.) instead`,`Index documentation or README files from the project`],featureTitle:`Support binary file analysis`},{label:`Database`,extensions:new Set([`.sqlite`,`.db`,`.mdb`,`.accdb`,`.dbf`]),message:`Database files are not supported for direct indexing.`,alternatives:[`Export data to CSV or JSON format, then index those files`,`Use SQL queries to extract relevant data to a text file`],featureTitle:`Support database file indexing`},{label:`Microsoft Office`,extensions:new Set([`.doc`,`.ppt`,`.xls`]),message:`Legacy Office formats (.doc, legacy PowerPoint .ppt, legacy Excel .xls) are not supported — GAIA reads only the modern XML-based formats. Modern Word (.docx), PowerPoint (.pptx), and Excel (.xlsx) are supported.`,alternatives:[`Re-save as .docx — GAIA indexes modern Word documents directly`,`Save modern PowerPoint as .pptx — GAIA indexes .pptx directly`,`Re-save legacy .xls workbooks as .xlsx — GAIA supports modern Excel files`],featureTitle:`Support legacy Microsoft Office (doc, ppt, xls) indexing`}];function WL(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;for(let e of UL)if(e.extensions.has(t))return e;return null}var GL=new Set(`.pdf,.pptx,.docx,.epub,.png,.jpg,.jpeg,.webp,.bmp,.gif,.tif,.tiff,.txt,.md,.mdx,.markdown,.rst,.csv,.json,.xlsx,.html,.htm,.xml,.svg,.yaml,.yml,.py,.js,.ts,.java,.c,.cpp,.h,.rs,.go,.rb,.sh,.bat,.ps1,.log,.cfg,.ini,.toml`.split(`,`));function KL(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;return GL.has(t)}function qL(){let e=navigator.userAgent;return`**Environment:**\n- GAIA Version: 0.27.0rc7\n- Platform: ${navigator.platform||`unknown`}\n- User Agent: ${e}\n- Interface: Agent UI (Web)`}function JL(e,t){let n=[`## Feature Description`,``,t||`I would like GAIA to support: **${e}**`,``,`## Use Case`,``,`_Describe how you would use this feature:_`,``,`## Current Workaround`,``,`_Is there a workaround you are currently using?_`,``,`---`,qL(),``,`_Submitted from GAIA Agent UI_`].join(`
|
|
189
189
|
`);return`${HL}?${new URLSearchParams({title:`[Feature] ${e}`,body:n,labels:`enhancement,agent-ui`}).toString()}`}function YL(e,t){let n=[`## Bug Description`,``,t||e,``,`## Steps to Reproduce`,``,`1. Open GAIA Agent UI`,`2. _Describe what you did:_`,`3. `,``,`## Expected Behavior`,``,`_What did you expect to happen?_`,``,`## Actual Behavior`,``,`_What happened instead?_`,``,`---`,qL(),``,`_Submitted from GAIA Agent UI_`].join(`
|
|
190
190
|
`);return`${HL}?${new URLSearchParams({title:`[Bug] ${e}`,body:n,labels:`bug,agent-ui`}).toString()}`}var XL={corrupted:`The file looks damaged. Re-download or re-export it, then add the new copy.`,encrypted:`The PDF needs a password to open. Save a copy without the password, then add that.`,empty:`The PDF has no readable text, which usually means it is a scan. Run OCR on it, then add it again.`,empty_file:`This file is empty. Add content to it, then add it again.`,unsupported_workbook:`This is an old .xls workbook or has a password. Open it in Excel, save a copy as .xlsx without a password, then add that.`};function ZL(e,t){if(!e.startsWith(t))return e;let n=e.slice(t.length).trim();return n.charAt(0).toUpperCase()+n.slice(1)}function QL({filename:e,error:t,status:n,kind:r,onDismiss:i,timeout:a=15e3}){let o=R(),s=(0,B.useRef)(null);(0,B.useEffect)(()=>(a>0&&(s.current=setTimeout(i,a)),()=>{s.current&&clearTimeout(s.current)}),[i,a]);let c=e.includes(`.`)?`.`+e.split(`.`).pop()?.toLowerCase():``,l=c?WL(c):null,u=t.toLowerCase().includes(`unsupported file type`)||t.toLowerCase().includes(`not supported for indexing`)||t.toLowerCase().includes(`file type not allowed`)||l!==null,d=t.toLowerCase().includes(`fetch`)||t.toLowerCase().includes(`network`)||t.toLowerCase().includes(`connect`),f,p,m,h=di,g=r?XL[r]:void 0;return g?(f=`"${e}" can't be read`,p=g,m=null,h=Ws):RL(r,o)?(f=VL(r,e,o)??o(`docs.notAddedServer`,{name:e}),p=RL(r,o)??t,m=null,h=Ws):r===`too_large`?(f=o(`docs.tooLarge`,{name:e}),p=t,m=null,h=Ws):n===404?(f=o(`docs.notFound`,{name:e}),p=o(`docs.notFoundDetail`),m=null,h=Ws):n===403?(f=`GAIA can't read files in that location`,p=`${t} Or drop the file here instead (up to 20 MB) and GAIA keeps its own copy.`,m=null,h=Ws):u&&l?(f=`${l.label} files not supported`,p=l.message,m=JL(l.featureTitle),h=Ws):u&&!c?(f=`"${e}" has no file extension`,p=ZL(t,`File type not allowed:`),m=null,h=Ws):u?(f=`File type not supported: ${c}`,p=`This file format cannot be indexed. Supported: PDF, DOCX, PPTX, XLSX, EPUB, images (PNG, JPG, WEBP, ...), TXT, MD, CSV, JSON, HTML, XML, YAML, and 30+ code file formats.`,m=JL(`Support ${c} file indexing`),h=Ws):d?(f=`Connection error`,p=`Could not reach the GAIA server. Make sure the backend is running.`,m=YL(`Upload connection error for ${e}`),h=di):(f=`Failed to index "${e}"`,p=t||`An unexpected error occurred during indexing.`,m=YL(`Indexing error: ${t.slice(0,80)}`),h=zr),z(`div`,{className:`upload-error-toast`,role:`alert`,children:[L(h,{size:16}),z(`div`,{className:`upload-error-content`,children:[L(`div`,{className:`upload-error-title`,children:f}),z(`div`,{className:`upload-error-detail`,children:[p,m&&` `,m===null?null:u?L(`a`,{href:m,target:`_blank`,rel:`noopener noreferrer`,children:`Request this feature →`}):L(`a`,{href:m,target:`_blank`,rel:`noopener noreferrer`,children:`Report this issue →`})]})]}),L(`button`,{className:`upload-error-dismiss`,onClick:i,"aria-label":`Dismiss`,children:L(nc,{size:14})})]})}function $L(e,t,n=[],r=[],i={}){let a=eR(t,r,i);if(n.length>0)return n.some(a);let o=Fk(e);return o===`google`?a(`google`):o===`microsoft`?a(`microsoft`):a(`google`)||a(`microsoft`)}function eR(e,t,n){return r=>mk(e.find(e=>e.id===r),t.find(e=>e.id===r),n[r])}function tR(e,t,n=[],r=[],i={}){let a=eR(t,r,i),o=n.find(a);if(o){let e=t.find(e=>e.id===o&&!(`error`in e));return e&&!(`error`in e)?e.display_name:o}let s=Fk(e);return s===`google`?`Google`:s===`microsoft`?`Microsoft`:a(`google`)?`Google`:a(`microsoft`)?`Microsoft`:`Google`}function nR({content:e,providers:t=[],accounts:n,onRetry:r}){let i=R(),[a,o]=(0,B.useState)([]),[s,l]=(0,B.useState)(null),[u,d]=(0,B.useState)(!1),f=(0,B.useCallback)(()=>{c().then(e=>{let t=e.connectors||[];o(t),l(e=>e??t)}).catch(e=>F.ui.warn(`ConnectorRetryBanner: connector fetch failed`,e))},[]),p=s!==null&&$L(e,a,t,s,n);if((0,B.useEffect)(()=>{f();let e=()=>f();return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[f]),VA(!p,f),!p||u)return null;let m=tR(e,a,t,s??[],n);return z(`div`,{className:`connector-retry-banner`,role:`status`,children:[L(li,{size:14,className:`connector-retry-banner__icon`}),L(`span`,{className:`connector-retry-banner__text`,children:i(`retryBanner.connected`,{name:m})}),z(`button`,{type:`button`,className:`connector-retry-banner__btn`,onClick:()=>{d(!0),r()},children:[L(Qo,{size:12}),L(`span`,{children:i(`retryBanner.askAgain`)})]}),L(`button`,{type:`button`,className:`connector-retry-banner__dismiss`,onClick:()=>d(!0),"aria-label":i(`retryBanner.dismiss`),children:`×`})]})}function rR(e,t=32){let n=Array.from(e);if(n.length<=t)return e;let r=Array.from(/\.[^.\s]{1,8}$/.exec(e)?.[0]??``).length,i=Math.min(Math.max(Math.ceil(t*.45),r+4),t-2);return`${n.slice(0,t-i-1).join(``)}…${n.slice(-i).join(``)}`}function iR(e){if(e<=0)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.min(Math.floor(Math.log(e)/Math.log(t)),n.length-1);return parseFloat((e/t**r).toFixed(1))+` `+n[r]}function aR(e){return e.replace(/-/g,``).slice(0,7)}function oR(e,t){let n=t.replace(/^#/,``).toLowerCase();if(!n||n.length<4)return null;let r=e.find(e=>e.id.replace(/-/g,``).toLowerCase().startsWith(n));return r?r.id:null}function sR(e,t){return e.key===`ArrowUp`&&!e.shiftKey&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.nativeEvent?.isComposing&&t===``}function cR(e){for(let t=e.length-1;t>=0;t--)if(e[t].role===`user`)return e[t]}function lR(e,t){for(let n=t+1;n<e.length;n++)if(e[n].role===`user`)return e.length-n;return 0}var uR=/^\/[a-z0-9-]*$/i;function dR(e){let t=uR.test(e),[n,r]=(0,B.useState)([]),[i,a]=(0,B.useState)(`loading`),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(0),[u,d]=(0,B.useState)(null);(0,B.useEffect)(()=>{if(!t)return;let e=!0;return a(e=>e===`ready`?e:`loading`),Pn().then(t=>{bn(t.skills.map(e=>e.name)),e&&(r(t.skills),a(`ready`),s(null))},t=>{e&&(a(`error`),s(t instanceof Error?t.message:String(t)))}),()=>{e=!1}},[t]),(0,B.useEffect)(()=>{l(0)},[e]);let f=e.toLowerCase(),p=t?n.filter(e=>`/${e.name}`.startsWith(f)):[],m=t&&u!==e&&(i!==`ready`||p.length>0),h=(0,B.useCallback)(e=>l(e),[]),g=(0,B.useCallback)(()=>d(e),[e]);return{open:m,status:i,error:o,matches:p,selected:Math.min(c,Math.max(p.length-1,0)),select:h,dismiss:g}}var fR=`composer-skill-menu`;function pR(e){return`${fR}-${e}`}function mR(e){let t=e.replace(/\s+/g,` `).trim(),n=t.indexOf(`. `);return n>=0?t.slice(0,n+1):t}var hR=320,gR=6,_R=8;function vR(e,t,n){let r=Math.max(0,e.top-gR-_R),i=Math.max(0,t-e.bottom-gR-_R),a=r<Math.min(hR,n)&&i>r;return{below:a,maxHeight:Math.floor(Math.min(hR,a?i:r))}}function yR({menu:e,onPick:t}){let n=R(),r=(0,B.useRef)(null),[i,a]=(0,B.useState)(null),o=e.open&&e.status===`ready`?e.matches.length:-1;if((0,B.useLayoutEffect)(()=>{let e=r.current,t=e?.parentElement;if(!e||!t){a(null);return}let n=()=>{let n=vR(t.getBoundingClientRect(),window.innerHeight,e.scrollHeight);a(e=>e&&e.below===n.below&&e.maxHeight===n.maxHeight?e:n)};n(),window.addEventListener(`resize`,n);let i=typeof ResizeObserver>`u`?null:new ResizeObserver(n);return i?.observe(t),()=>{window.removeEventListener(`resize`,n),i?.disconnect()}},[e.open,e.status,o]),(0,B.useEffect)(()=>{o>0&&document.getElementById(pR(e.selected))?.scrollIntoView?.({block:`nearest`})},[e.selected,o]),!e.open)return null;let s=`skill-menu${i?.below?` is-below`:``}`,c=i?{maxHeight:i.maxHeight}:void 0;return e.status===`ready`?z(`div`,{ref:r,className:s,style:c,children:[L(`p`,{className:`skill-menu-title`,children:n(`composer.skillsTitle`)}),L(`ul`,{id:fR,role:`listbox`,"aria-label":n(`composer.skillsTitle`),children:e.matches.map((n,r)=>z(`li`,{id:pR(r),role:`option`,"aria-selected":r===e.selected,className:`skill-menu-row${r===e.selected?` is-selected`:``}`,onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>e.select(r),onClick:()=>t(n.name),children:[z(`span`,{className:`skill-menu-name`,dir:`ltr`,children:[`/`,n.name]}),L(`span`,{className:`skill-menu-desc`,dir:`auto`,children:mR(n.description)})]},n.name))})]}):L(`div`,{ref:r,className:s,style:c,role:e.status===`error`?`alert`:`status`,children:L(`p`,{className:`skill-menu-note`,children:e.status===`error`?n(`composer.skillsFailed`,{error:e.error??``}):n(`composer.skillsLoading`)})})}function bR(e){return e.isMedia?IL(e.name)?aa:$i:sa}var xR=240,SR=1e5;function CR({value:e,onChange:t,onSubmit:n,onStop:r,streaming:i=!1,stopping:a=!1,queueWhileStreaming:o=!1,answering:s=!1,disabledReason:c,attachments:l,placeholder:u,autoFocus:d,inputRef:f,leftControls:p,rightControls:m,onEditLast:h}){let g=R(),_=(0,B.useRef)(null),v=f??_,y=(0,B.useRef)(null),b=!!c,x=e.trim().length>0||l.hasUploaded,S=l.compose(e.trim()).length,C=S>SR,w=mP(i),T=l.attachments.filter(e=>e.error).map(e=>e.name).join(`, `),E=!b&&(!i||o)&&!l.uploading&&x&&!C&&!T&&!w,D=c||u||g(`composer.placeholder`),O=dR(b?``:e),ee=(0,B.useCallback)(e=>{t(`/${e} `),v.current?.focus()},[t,v]);(0,B.useLayoutEffect)(()=>{let e=v.current;if(!e)return;let t=()=>{e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,xR)}px`};if(t(),typeof ResizeObserver>`u`)return;let n=e.clientWidth,r=new ResizeObserver(()=>{e.clientWidth!==n&&(n=e.clientWidth,t())});return r.observe(e),()=>r.disconnect()},[e,D,v]);let te=(0,B.useCallback)(t=>{if(O.open&&!t.nativeEvent.isComposing){let{matches:n,selected:r}=O;if(t.key===`Escape`){t.preventDefault(),O.dismiss();return}if(n.length>0&&(t.key===`ArrowDown`||t.key===`ArrowUp`)){t.preventDefault();let e=t.key===`ArrowDown`?1:-1;O.select((r+e+n.length)%n.length);return}let i=n[r]?.name,a=i!==void 0&&e.toLowerCase()===`/${i}`;if(i&&(t.key===`Tab`||t.key===`Enter`&&!t.shiftKey&&!a)){t.preventDefault(),ee(i);return}}h&&sR(t,e)?(t.preventDefault(),h()):t.key===`Enter`&&!t.shiftKey&&!t.nativeEvent.isComposing&&(t.preventDefault(),E&&n())},[E,n,h,e,O,ee]),ne=(0,B.useCallback)(e=>{e.dataTransfer?.files?.length&&(e.preventDefault(),e.stopPropagation(),l.addFiles(Array.from(e.dataTransfer.files)))},[l]);return z(`div`,{className:`composer${b?` composer-disabled`:``}`,onDrop:ne,onDragOver:e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault()},children:[L(pP,{}),l.attachments.length>0&&L(`ul`,{className:`composer-attachments`,"aria-label":g(`composer.attached`),children:l.attachments.map(e=>{let t=bR(e);return z(`li`,{title:e.isImage&&e.url?e.name:void 0,className:`composer-attachment${e.error?` has-error`:``}${e.isMedia?` is-media`:``}${e.isImage&&e.url?` is-image`:``}`,children:[e.isImage&&e.url?L(`img`,{src:e.url,alt:``,className:`composer-attachment-thumb`}):L(t,{size:14,"aria-hidden":`true`}),L(`span`,{className:`composer-attachment-name`,title:e.name,dir:`ltr`,children:rR(e.name)}),e.uploading&&L(`span`,{className:`composer-attachment-state`,children:e.progress===void 0?g(`composer.uploading`):g(`composer.uploadingPercent`,{percent:e.progress})}),e.uploaded&&e.isMedia&&L(`span`,{className:`composer-attachment-state`,children:g(`composer.mediaReady`)}),e.error&&L(`span`,{className:`composer-attachment-state`,role:`alert`,title:e.error,children:e.error}),L(`button`,{type:`button`,className:`composer-icon-btn`,onClick:()=>l.remove(e.id),"aria-label":g(`composer.remove`,{name:e.name}),children:L(nc,{size:12})})]},e.id)})}),L(yR,{menu:O,onPick:ee}),L(`textarea`,{ref:v,className:`composer-input`,value:e,onChange:e=>t(e.target.value),onKeyDown:te,onPaste:e=>{l.handlePaste(e)},placeholder:D,rows:1,disabled:b,autoFocus:d,"aria-label":g(`composer.message`),"aria-autocomplete":`list`,"aria-expanded":O.open&&O.matches.length>0,"aria-controls":O.open&&O.matches.length>0?fR:void 0,"aria-activedescendant":O.open&&O.matches.length>0?pR(O.selected):void 0,dir:`auto`}),C&&z(`p`,{className:`composer-limit-error`,role:`alert`,children:[g(`composer.tooLong`,{sent:S.toLocaleString(),max:1e5.toLocaleString()}),` `,g(`composer.tooLongHint`)]}),T&&x&&L(`p`,{className:`composer-limit-error`,role:`alert`,children:g(`composer.removeRefused`,{names:T})}),z(`div`,{className:`composer-row`,children:[z(`div`,{className:`composer-row-left`,children:[L(`button`,{type:`button`,className:`composer-icon-btn`,onClick:()=>y.current?.click(),disabled:b,"aria-label":g(`composer.attach`),title:g(`composer.attach`),children:L(Ko,{size:16})}),L(`input`,{ref:y,type:`file`,multiple:!0,hidden:!0,onChange:e=>{e.target.files&&l.addFiles(Array.from(e.target.files)),e.target.value=``}}),p]}),z(`div`,{className:`composer-row-right`,children:[m,i&&o&&x&&L(`button`,{type:`button`,className:`composer-send`,onClick:n,disabled:!E,"aria-label":g(s?`composer.sendAnswer`:`composer.queue`),title:s?g(`composer.sendAnswerTitle`):w??g(`composer.queueTitle`),children:L(Dr,{size:16})}),i?L(`button`,{type:`button`,className:`composer-send is-stop`,onClick:r,disabled:a,"aria-label":g(`composer.stop`),title:a?g(`composer.stopping`):g.hint(g(`composer.stop`),`Esc`),children:L(Is,{size:12,fill:`currentColor`})}):L(`button`,{type:`button`,className:`composer-send`,onClick:n,disabled:!E,"aria-label":g(`composer.send`),title:w??g.hint(g(`composer.send`),`Enter`),children:L(Dr,{size:16})})]})]})]})}var wR=8,TR=8;function ER({label:e,warning:t,children:n,id:r,pinned:i=!1,onUnpin:a,tabIndex:o}){let s=(0,B.useId)(),c=r??s,l=(0,B.useRef)(null),u=(0,B.useRef)(null),[d,f]=(0,B.useState)(!1),p=d||i,[m,h]=(0,B.useState)(null);return(0,B.useLayoutEffect)(()=>{if(!p){h(null);return}let e=l.current?.getBoundingClientRect(),t=u.current?.getBoundingClientRect(),n=l.current?.closest(`[role="dialog"]`)?.getBoundingClientRect()??e;if(!e||!t||!n)return;let r=window.innerWidth,i=window.innerHeight,a,o;n.right+wR+t.width<=r-TR?(a=n.right+wR,o=e.top+e.height/2-t.height/2):n.left-wR-t.width>=TR?(a=n.left-wR-t.width,o=e.top+e.height/2-t.height/2):(a=Math.min(Math.max(TR,e.right-t.width),r-TR-t.width),o=e.top-wR-t.height>=TR?e.top-wR-t.height:e.bottom+wR),o=Math.min(Math.max(TR,o),i-TR-t.height),h({left:a,top:o})},[p]),(0,B.useEffect)(()=>{if(!p)return;let e=()=>{f(!1),a?.()};return window.addEventListener(`scroll`,e,!0),()=>window.removeEventListener(`scroll`,e,!0)},[p,a]),z(P.Fragment,{children:[L(`button`,{ref:l,type:`button`,className:`info-bubble-icon${t?` is-warning`:``}`,"aria-label":e,tabIndex:o,"aria-describedby":p?c:void 0,onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),onFocus:()=>f(!0),onBlur:()=>f(!1),onClick:e=>{e.stopPropagation(),f(e=>!e)},onKeyDown:e=>{e.key===`Escape`&&p&&(e.stopPropagation(),f(!1))},children:L(Na,{size:13,"aria-hidden":`true`})}),p&&(0,mM.createPortal)(L(`div`,{ref:u,id:c,role:`tooltip`,className:`info-bubble`,style:m?{left:m.left,top:m.top}:{left:0,top:0,visibility:`hidden`},children:n}),document.body)]})}function DR(e){return e<.1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function OR(e,t=mt){return e?t(`settings.price.perMillion`,{input:DR(e.input_per_million),output:DR(e.output_per_million)}):t(`settings.price.unknown`)}function kR(e){return`$${e.toFixed(2)}`}function AR(e,t,n,r=!1){return!fe(t)||mt(t)!==n?n:r?e.bare(t):e(t)}function jR(e,t){return AR(e,`providers.${t.id}.name`,t.name,!0)}function MR(e,t){return AR(e,`providers.${t.id}.notice`,t.privacy_notice)}var NR=2e3,PR=`waiting_for_os_permission`,FR=`store_locked`,IR=5;function LR(e,t){let n=e.rank?`#${e.rank} ${e.note??``}`.trim():null;return t?[n,OR(e.price)].filter(e=>!!e):[el(e.placement),e.size_gb?`${e.size_gb} GB`:null,e.tokens_per_second?`${Math.round(e.tokens_per_second)} tok/s on this PC`:null,n,e.custom?`added by you`:null].filter(e=>!!e)}function RR(e,t){return!Hc(t,e.id)&&(rl(e)||nl(e)===`not_downloaded`)}function zR(e,t,n){let r=e=>e.provider.id===t?0:1;return[...e].sort((e,t)=>r(e)-r(t)).map(e=>e.provider.remote?e:{...e,models:[...e.models].sort((e,t)=>Number(RR(e,n))-Number(RR(t,n)))})}function BR({m:e,onDownload:t,busy:n}){let r=R();if(rl(e)){let t=Math.round(e.download_progress?.percent??0);return z(`span`,{className:`model-state is-downloading`,title:`Downloading, ${t}%`,children:[L(Za,{size:12,className:`spin`,"aria-hidden":`true`}),` `,t,`%`]})}let i=nl(e);return i===`not_downloaded`?L(`button`,{type:`button`,className:`model-state-btn`,onClick:e=>{e.stopPropagation(),t()},disabled:n,"aria-label":r(`modelMenu.downloadModel`,{name:e.display_name??e.id}),title:e.size_gb?`${$c.not_downloaded} (${e.size_gb} GB)`:$c.not_downloaded,tabIndex:-1,children:L(Ni,{size:13,"aria-hidden":`true`})}):i===`loaded`?L(`span`,{className:`model-state is-loaded`,role:`img`,"aria-label":$c.loaded,title:$c.loaded}):L(`span`,{className:`model-state is-ready`,title:$c.downloaded,children:r(`modelMenu.ready`)})}function VR(){let e=R(),t=zc(e=>e.active),n=zc(e=>e.select),r=zc(e=>e.queued),i=r??t?.model,a=zc(e=>e.queue),o=zc(e=>e.queueError),s=zc(e=>e.rememberNames);zc(e=>e.names);let c=qc(),l=N(e=>Jc(t,e.sessions,e.currentSessionId)),u=N(e=>e.isStreaming),d=N(e=>e.openSettings),f=(0,B.useRef)(null),[m,h]=(0,B.useState)(!1),[g,_]=(0,B.useState)(null),[v,y]=(0,B.useState)(!1),[b,x]=(0,B.useState)(0),[S,C]=(0,B.useState)(null),[w,T]=(0,B.useState)(null),[E,D]=(0,B.useState)(null),[O,ee]=(0,B.useState)(null),[te,ne]=(0,B.useState)(null),[re,k]=(0,B.useState)(null),[ie,ae]=(0,B.useState)(0),[A,oe]=(0,B.useState)(null),se=(0,B.useRef)(0),ce=(0,B.useRef)(null),le=(0,B.useId)(),ue=(0,B.useRef)(null),de=(0,B.useRef)(null),[fe,pe]=(0,B.useState)(null),[me,j]=(0,B.useState)(null),he=(0,B.useCallback)(()=>j(null),[]),M=(0,B.useCallback)(()=>h(!1),[]),ge=(0,B.useRef)(!1),_e=(0,B.useRef)(null),ve=(0,B.useCallback)(async(t=!1)=>{t||(ge.current=!1,C(null),_(null));try{let{providers:n,lemonade_error:r}=await gt();if(r)throw Error(r);let i=n.filter(e=>!e.remote||e.models_discovered||e.id===`fireworks`||e.registered),a=await Promise.all(i.map(async t=>{if(t.blocked)return{provider:t,models:[],error:e(`settings.privacy.localOnlyBlocked`)};if(t.remote&&!t.models_discovered)return{provider:t,models:[]};try{let n=await Gt(t.id);return{provider:t,models:n.models,error:n.blocked?e(`settings.privacy.localOnlyBlocked`):void 0}}catch(e){return{provider:t,models:[],error:aN(e)}}}));s(a.flatMap(e=>e.models)),x(a.flatMap(e=>e.models).filter(e=>e.available===!1).length),t||(ge.current=!0),_(a.map(e=>({...e,models:e.models.filter(e=>e.available!==!1)})))}catch(e){C(aN(e))}},[s,e]),ye=(0,B.useCallback)(async()=>{try{await Fe()}catch(e){C(aN(e));return}await ve(!0)},[ve]);(0,B.useEffect)(()=>{m&&(T(null),D(null),y(!1),pe(null),j(null),ve())},[m,ve]),(0,B.useEffect)(()=>{if(!m||!g||!ge.current)return;let e=ue.current?.querySelector(`[role="option"][tabindex="0"]`);e&&(ge.current=!1,e.focus(),e.scrollIntoView?.({block:`nearest`}))},[m,g]),(0,B.useEffect)(()=>{let e=_e.current;if(!m||!g||!e||!v)return;let t=g.find(t=>t.provider.id===e)?.models.find(e=>e.rank===null&&!Hc(i,e.id));if(!t)return;let n=Array.from(ue.current?.querySelectorAll(`[role="option"]`)??[]).find(e=>e.dataset.row===t.id);n&&(_e.current=null,pe(t.id),n.focus(),n.scrollIntoView?.({block:`nearest`}))},[m,g,v,i]),(0,B.useEffect)(()=>{(w||E)&&de.current?.scrollIntoView?.({block:`nearest`})},[w,E]);let be=e=>{if(e.altKey||e.ctrlKey||e.metaKey)return;let t=Array.from(ue.current?.querySelectorAll(`[role="option"]:not(:disabled)`)??[]);if(!t.length)return;let n=t.indexOf(document.activeElement),r;switch(e.key){case`ArrowDown`:r=n<0?0:Math.min(n+1,t.length-1);break;case`ArrowUp`:r=n<0?t.length-1:Math.max(n-1,0);break;case`Home`:r=0;break;case`End`:r=t.length-1;break;case`ArrowRight`:case`i`:{let r=n<0?void 0:t[n].dataset.row;if(!r)return;e.preventDefault(),j(t=>e.key===`i`&&t===r?null:r);return}case`ArrowLeft`:e.preventDefault(),j(null);return;default:return}e.preventDefault(),t[r].focus(),t[r].scrollIntoView?.({block:`nearest`})},xe=!!g?.some(e=>e.models.some(rl)),Se=!!g?.some(e=>e.provider.key_state===PR);(0,B.useEffect)(()=>{if(!(m||re)||!(xe||re||Se))return;let e=setInterval(()=>{ve(!0)},NR);return()=>clearInterval(e)},[m,xe,re,Se,ve]);let Ce=(0,B.useCallback)(async e=>{ne(e),ae(e=>e+1),C(null);try{await p(e),await ve(!0)}catch(t){k(t=>t?.model===e?null:t),C(aN(t))}finally{ne(null),ae(e=>e-1)}},[ve]),we=(0,B.useCallback)((e,t,n)=>{D(null),n&&(se.current=0,oe(null),k({model:e,provider:t})),Ce(e)},[Ce]),Te=(0,B.useCallback)(async(e,r)=>{if(r.remote&&!t?.remote&&w?.model!==e)return T({model:e,provider:r}),null;if(T(null),u)return a(e===t?.model?null:e),h(!1),null;ee(e),C(null);try{return await n(e),oe(null),h(!1),null}catch(e){let t=aN(e);return C(t),t}finally{ee(null)}},[t?.model,t?.remote,w,a,n,u]);(0,B.useEffect)(()=>{if(!re||!g||ie>0)return;let{model:e,provider:t}=re,n=()=>(ce.current!==g&&(ce.current=g,se.current+=1),se.current>=IR),r=g.flatMap(e=>e.models).find(t=>t.id===e);if(!r){if(!n())return;k(null),oe(`${Uc(e)} is no longer in the model list, so it wasn't switched to.`);return}if(rl(r)){se.current=0;return}let i=r.download_progress;if(i?.state===`error`)k(null),oe(`Downloading ${Uc(e)} failed: ${i.message??`no reason given`}`);else if(i?.state!==`complete`&&nl(r)===`not_downloaded`){if(!n())return;k(null),oe(`The download of ${Uc(e)} never started. Try the download button again.`)}else k(null),Te(e,t).then(t=>{t&&oe(`${Uc(e)} downloaded, but switching to it failed: ${t}`)})},[g,re,ie,Te]);let Ee=(e,t)=>e.id===`fireworks`&&!v&&t.some(e=>e.rank!==null),De=(e,t)=>Ee(e,t)?t.filter(e=>e.rank!==null||Hc(i,e.id)):t,Oe=(e,t)=>Ee(e,t)&&t.some(e=>e.rank===null&&!Hc(i,e.id)),ke=g?.flatMap(({provider:e,models:t})=>[...e.remote&&!e.models_discovered?[`key:${e.id}`]:[],...De(e,t).filter(e=>O===null&&!rl(e)).map(e=>e.id),...Oe(e,t)?[`showall:${e.id}`]:[]])??[],Ae=fe&&ke.includes(fe)?fe:i&&ke.includes(i)?i:ke[0],je=e=>({role:`option`,tabIndex:e===Ae?0:-1,"data-row":e,onFocus:()=>pe(e),onBlur:()=>j(null)}),Me=c?.remote?xi:c?ki:pi,Ne=l?Uc(l):`Model`,Pe=`${Ne}${c?` · ${c.label}`:``}`,Ie=Object.fromEntries((g??[]).map(e=>[e.provider.id,Zc(e.models)])),Le=g&&zR(g,t?.provider,i),Re=t?.downloaded===!1&&l===t.model,ze=A||o||(r?`${Uc(r)} is used from your next message.`:t?.config_error?t.config_error:Re?`${Ne} isn't downloaded yet. Open the list to download it.`:c?c.description?.replace(/`/g,``)??(c.remote?e(`modelStatus.runsRemote`,{name:c.label}):e(`modelStatus.runsHere`)):Kc);return z(`div`,{className:`composer-chip-wrap`,children:[z(`button`,{ref:f,type:`button`,className:`composer-chip${Re||o||A?` is-warning`:``}`,onClick:()=>h(e=>!e),"aria-haspopup":`dialog`,"aria-expanded":m,title:ze,children:[L(Me,{size:13,"aria-hidden":`true`}),L(`span`,{className:`composer-chip-label`,dir:`auto`,children:Pe}),r&&z(`span`,{className:`composer-chip-next`,children:[`→ `,Uc(r),` next`]}),Re&&L(Ni,{size:12,"aria-label":`Not downloaded`}),A&&L(di,{size:12,"aria-label":`Model switch failed`}),L($r,{size:12,"aria-hidden":`true`})]}),z(pc,{open:m,onClose:M,anchor:f,label:e(`modelMenu.label`),align:`end`,className:`model-menu`,children:[u&&L(`div`,{className:`popover-message`,role:`status`,children:l?e(`modelMenu.keepsModel`,{model:Uc(l)}):e(`modelMenu.keepsItsModel`)}),A&&L(`div`,{className:`popover-message is-error`,role:`alert`,children:A}),o&&L(`div`,{className:`popover-message is-error`,role:`alert`,children:o}),S&&L(`div`,{className:`popover-message is-error`,role:`alert`,children:S}),!g&&!S&&z(`div`,{className:`popover-message`,children:[L(Za,{size:13,className:`spin`}),` `,e(`modelMenu.loading`)]}),g&&L(`div`,{ref:ue,role:`listbox`,"aria-label":e(`modelMenu.models`),onKeyDown:be,children:Le.map(({provider:n,models:a,error:o})=>z(`div`,{role:`group`,"aria-labelledby":`${le}-${n.id}`,children:[L(`div`,{className:`popover-heading`,id:`${le}-${n.id}`,children:jR(e,n)}),o&&L(`div`,{className:`popover-message is-error`,children:o}),n.key_state===PR?z(`div`,{className:`popover-message`,role:`status`,children:[L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,n.key_message]}):n.key_state===FR?z(`button`,{type:`button`,className:`popover-item`,...je(`unlock:${n.id}`),"aria-selected":!1,onClick:()=>void ye(),children:[L(`span`,{className:`popover-item-check`,children:L(Fa,{size:13,"aria-hidden":`true`})}),z(`span`,{className:`popover-item-body`,children:[L(`span`,{className:`popover-item-title`,children:e(`settings.key.unlockAgain`)}),L(`span`,{className:`popover-item-note`,children:e(`settings.key.storeLocked`)})]})]}):n.remote&&!n.models_discovered&&z(`button`,{type:`button`,className:`popover-item`,...je(`key:${n.id}`),"aria-selected":!1,onClick:()=>{h(!1),d(`model`,n.id)},children:[L(`span`,{className:`popover-item-check`,children:L(Fa,{size:13,"aria-hidden":`true`})}),z(`span`,{className:`popover-item-body`,children:[L(`span`,{className:`popover-item-title`,children:e(`modelMenu.addKey`)}),L(`span`,{className:`popover-item-note`,children:e(`modelMenu.connectInSettings`,{provider:n.name})})]})]}),!o&&a.length===0&&n.models_discovered!==!1&&L(`div`,{className:`popover-message`,children:e(`modelMenu.noModels`)}),De(n,a).map((a,o,s)=>{let c=!n.remote&&RR(a,i)&&o===s.findIndex(e=>RR(e,i)),l=Hc(r??t?.model,a.id),u=!n.remote&&nl(a)===`not_downloaded`,d=Ie[n.id][a.id],f=LR(a,n.remote),p=`${le}-info-${n.id}-${a.id}`;return z(B.Fragment,{children:[c&&L(`div`,{className:`popover-subheading`,children:e(`modelMenu.availableToDownload`)}),z(`div`,{className:`popover-row`,children:[z(`button`,{type:`button`,className:`popover-item`,onClick:()=>{u?(T(null),D({model:a.id,provider:n,pick:!0})):(k(null),D(null),Te(a.id,n))},disabled:O!==null||rl(a),...je(a.id),"aria-selected":l,"aria-describedby":me===a.id?p:void 0,children:[L(`span`,{className:`popover-item-check`,"aria-hidden":`true`,children:O===a.id?L(Za,{size:13,className:`spin`}):l?L(Yr,{size:13}):null}),z(`span`,{className:`popover-item-body is-inline`,children:[L(`span`,{className:`popover-item-title is-model`,children:d}),!n.remote&&a.size_gb?L(`span`,{className:`popover-item-meta`,children:z(`bdi`,{dir:`ltr`,children:[a.size_gb,` GB`]})}):null]})]}),z(ER,{label:`About ${d}`,warning:!!a.placement?.warning,id:p,pinned:me===a.id,onUnpin:he,tabIndex:-1,children:[L(`div`,{className:`info-bubble-title`,children:d}),f.length>0&&L(`ul`,{className:`info-bubble-lines`,children:f.map(e=>L(`li`,{children:e},e))}),a.placement?.warning&&L(`ul`,{className:`info-bubble-lines`,children:L(`li`,{className:`is-warning`,children:a.placement.warning})}),L(`div`,{className:`info-bubble-id`,children:a.id})]}),L(`span`,{className:`popover-row-state`,children:!n.remote&&L(BR,{m:a,busy:te!==null,onDownload:()=>{T(null),D({model:a.id,provider:n,pick:!1})}})})]}),E?.model===a.id&&E.provider.id===n.id&&z(`div`,{ref:de,className:`popover-message model-download-confirm`,role:`alert`,children:[z(`span`,{children:[L(sl,{text:a.size_gb?e(`modelMenu.downloadConfirm`,{name:il(d),size:il(`${a.size_gb} GB`)}):e(`modelMenu.downloadConfirmNoSize`,{name:il(d)})}),E.pick&&` ${e(`modelMenu.switchWhenDone`)}`]}),z(`span`,{className:`model-download-confirm-actions`,children:[L(`button`,{type:`button`,className:`btn-primary`,onClick:()=>we(a.id,n,E.pick),children:e(`modelMenu.download`)}),L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>D(null),children:e(`modelMenu.cancel`)})]})]}),w?.model===a.id&&w.provider.id===n.id&&z(`div`,{ref:de,className:`popover-message`,role:`alert`,children:[MR(e,w.provider),` `,L(`button`,{type:`button`,className:`link-btn`,onClick:()=>Te(w.model,w.provider),children:e(`modelMenu.useModel`,{name:Uc(w.model)})})]})]},a.id)}),Oe(n,a)&&z(`button`,{type:`button`,className:`popover-item`,...je(`showall:${n.id}`),"aria-selected":!1,onClick:()=>{_e.current=n.id,y(!0)},children:[L(`span`,{className:`popover-item-check`}),L(`span`,{className:`popover-item-body`,children:L(`span`,{className:`popover-item-title`,children:e(`settings.model.showAll`)})})]})]},n.id))}),b>0&&z(`button`,{type:`button`,className:`popover-item`,onClick:()=>{h(!1),d(`model`)},children:[L(`span`,{className:`popover-item-check`}),L(`span`,{className:`popover-item-body`,children:L(`span`,{className:`popover-item-note`,children:e.plural(`modelMenu.unavailable`,b)})})]}),L(`div`,{className:`popover-divider`}),z(`button`,{type:`button`,className:`popover-item`,onClick:()=>{h(!1),d(`model`)},children:[L(`span`,{className:`popover-item-check`,children:L(qa,{size:13,"aria-hidden":`true`})}),z(`span`,{className:`popover-item-body`,children:[L(`span`,{className:`popover-item-title`,children:e(`modelMenu.addFromLink`)}),L(`span`,{className:`popover-item-note`,children:e(`modelMenu.addFromLinkNote`)})]})]}),z(`button`,{type:`button`,className:`popover-item`,onClick:()=>{h(!1),d(`model`)},children:[L(`span`,{className:`popover-item-check`}),L(`span`,{className:`popover-item-body`,children:L(`span`,{className:`popover-item-title`,children:e(`modelMenu.providers`)})})]})]})]})}function HR(e,t,n){if(e==null||!t(e))throw Error(`the server sent no ${n}`);return e}var UR=e=>e.startsWith(`.`);function WR({onPick:e,onClose:t}){let n=R(),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(``),[s,c]=(0,B.useState)(null),[l,u]=(0,B.useState)(!1),[d,f]=(0,B.useState)(!1);ut(!0,t);let p=(0,B.useRef)(null);un(p,!0);let m=(0,B.useCallback)(e=>{u(!0),c(null),Promise.resolve().then(()=>Ot(e)).then(e=>{let t=HR(e,e=>Array.isArray(e.entries),`folder listing`);i(t),o(t.current_path)}).catch(e=>c(e instanceof Vn?e.detail||e.message:String(e))).finally(()=>u(!1))},[]);(0,B.useEffect)(()=>m(),[m]);let h=r?.entries.filter(e=>e.type===`folder`)??[],g=d?h:h.filter(e=>!UR(e.name));return L(`div`,{className:`modal-overlay`,onClick:t,children:z(`div`,{ref:p,className:`modal-panel sp-picker`,role:`dialog`,"aria-modal":`true`,"aria-label":n(`pick.label`),onClick:e=>e.stopPropagation(),children:[z(`div`,{className:`modal-header`,children:[L(`h3`,{children:n(`pick.title`)}),L(`button`,{type:`button`,className:`btn-icon`,onClick:t,"aria-label":n(`sp.closeShort`),children:L(nc,{size:18})})]}),z(`div`,{className:`modal-body sp-picker-body`,children:[L(`p`,{className:`sp-meta`,children:n(`pick.note`)}),z(`form`,{className:`sp-picker-path`,onSubmit:e=>{e.preventDefault(),a.trim()&&m(a.trim())},children:[L(`input`,{value:a,onChange:e=>o(e.target.value),"aria-label":n(`pick.path`),spellCheck:!1,dir:`ltr`}),L(`button`,{type:`submit`,className:`sp-action`,children:n(`pick.go`)})]}),r&&z(`div`,{className:`sp-picker-quick`,children:[r.quick_links.map(e=>L(`button`,{type:`button`,className:`sp-action`,onClick:()=>m(e.path),children:e.name},e.path)),z(`label`,{className:`sp-picker-hidden`,children:[L(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked)}),n(`pick.showHidden`)]})]}),z(`ul`,{className:`sp-picker-list`,"aria-busy":l,children:[r?.parent_path&&L(`li`,{children:z(`button`,{type:`button`,onClick:()=>m(r.parent_path??void 0),children:[L(Dr,{size:13,"aria-hidden":`true`}),` `,n(`pick.up`)]})}),g.map(e=>L(`li`,{children:z(`button`,{type:`button`,onClick:()=>m(e.path),children:[L(_a,{size:13,"aria-hidden":`true`}),` `,e.name]})},e.path)),r&&g.length===0&&L(`li`,{className:`sp-meta`,children:n(h.length>0?`pick.onlyHidden`:`pick.none`)}),l&&z(`li`,{className:`sp-meta`,children:[L(Za,{size:12,className:`spin`,"aria-hidden":`true`}),` `,n(`pick.loading`)]})]}),s&&L(`p`,{className:`sp-error`,role:`alert`,children:s}),r?.folder_refusal&&L(`p`,{className:`sp-meta`,role:`status`,children:r.folder_refusal})]}),z(`div`,{className:`sp-picker-actions`,children:[L(`button`,{type:`button`,className:`btn-secondary`,onClick:t,children:n(`sp.cancel`)}),L(`button`,{type:`button`,className:`btn-primary`,disabled:!r||!!r.folder_refusal,onClick:()=>r&&e(r.current_path),children:n(`pick.use`)})]})]})})}var GR=e=>e instanceof Vn?e.detail||e.message:e instanceof Error?e.message:String(e);function KR(e){let t=R(),[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(null);return{open:n=>{a(null);let i=window.gaiaAPI?.dialog;i?i.pickFolder(n).then(async n=>{if(!n)return;let r;try{({refusal:r}=await Ye(n))}catch(e){a(t(`pick.checkFailed`,{error:GR(e)}));return}r?a(r):e(n)},e=>a(t(`pick.openFailed`,{error:GR(e)}))):r(!0)},picker:n?L(WR,{onPick:t=>{r(!1),e(t)},onClose:()=>r(!1)}):null,error:i}}var qR=new Map;function JR(e){let t=qR.get(e);return t||(t={env:null,error:null,inFlight:null,version:0,listeners:new Set},qR.set(e,t)),t}function YR(e,t,n){let r=JR(e);r.env=t??r.env,r.error=n,r.listeners.forEach(e=>e())}function XR(e){let t=JR(e);if(t.inFlight)return t.inFlight;let n=t.version;return t.inFlight=Promise.resolve().then(()=>A(e)).then(r=>{let i=HR(r,e=>Array.isArray(e.folders),`chat's environment`);t.version===n&&YR(e,i,null)}).catch(t=>YR(e,null,t instanceof Error?t.message:String(t))).finally(()=>{t.inFlight=null}),t.inFlight}function ZR(e){let[,t]=(0,B.useState)(0);(0,B.useEffect)(()=>{let n=JR(e),r=()=>t(e=>e+1);return n.listeners.add(r),!n.env&&!n.inFlight&&XR(e),()=>{n.listeners.delete(r)}},[e]);let n=(0,B.useCallback)(()=>XR(e),[e]),r=(0,B.useCallback)(async t=>{let n=await t();return JR(e).version+=1,YR(e,n,null),n},[e]),i=JR(e);return{env:i.env,error:i.error,refresh:n,change:r}}var QR=e=>e.split(/[\\/]/).filter(Boolean).pop()??e;function $R({folder:e,disabled:t}){let n=R(),r=N(e=>e.draftFolder),i=N(e=>e.setDraftFolder),{open:a,picker:o,error:s}=KR(i),c=e.gaia_folder?n(`folderChip.worksInOwn`,{path:e.path}):n(`folderChip.worksIn`,{path:e.path}),l=!e.gaia_folder&&z(`span`,{className:`new-chat-folder`,title:c,children:[L(_a,{size:13,"aria-hidden":`true`}),L(`span`,{className:`new-chat-folder-name`,dir:`auto`,children:e.name})]});return e.choosable?z(P.Fragment,{children:[l,r?z(`span`,{className:`new-chat-folder is-on`,title:n(`folderChip.picked`,{path:r}),children:[L(_a,{size:13,"aria-hidden":`true`}),L(`span`,{className:`new-chat-folder-name`,dir:`auto`,children:QR(r)}),L(`button`,{type:`button`,className:`new-chat-folder-clear`,onClick:()=>i(null),disabled:t,"aria-label":n(`folderChip.remove`,{name:QR(r)}),title:n(`folderChip.remove`,{name:QR(r)}),children:L(nc,{size:12,"aria-hidden":`true`})})]}):z(`button`,{type:`button`,className:`new-chat-folder is-button`,onClick:()=>a(e.path),disabled:t,"aria-haspopup":`dialog`,title:`${c} ${n(`folderChip.addHint`)}`,children:[L(Ko,{size:13,"aria-hidden":`true`}),L(`span`,{className:`new-chat-folder-name`,children:n(`folderChip.add`)})]}),s&&L(`span`,{className:`new-chat-folder-error`,role:`alert`,children:s}),o]}):l||z(`span`,{className:`new-chat-folder`,title:`${c} ${n(`folderChip.ownFixedHint`)}`,children:[L(_a,{size:13,"aria-hidden":`true`}),L(`span`,{className:`new-chat-folder-name`,children:n(`folderChip.gaiaFolder`)})]})}function ez({sessionId:e,onOpen:t}){let{env:n}=ZR(e),r=n?.folders.find(e=>e.source===`working_folder`);if(!r)return null;let i=QR(r.path);return z(`button`,{type:`button`,className:`composer-chip folder-chip`,title:`GAIA works in ${r.path}`,"aria-label":`Working folder ${i}, show the chat's folders`,onClick:t,children:[L(_a,{size:13,"aria-hidden":`true`}),L(`span`,{className:`composer-chip-label`,dir:`auto`,children:i})]})}var tz=`gaia:permission-mode`;function nz(e,t){window.dispatchEvent(new CustomEvent(tz,{detail:{sessionId:e,mode:t}}))}function rz(e,t){let n=(0,B.useRef)(t);n.current=t,(0,B.useEffect)(()=>{if(!e)return;let t=t=>{let r=t.detail;r?.sessionId===e&&n.current(r.mode)};return window.addEventListener(tz,t),()=>window.removeEventListener(tz,t)},[e])}var iz=[{mode:`ask`,label:`perm.ask`,note:`perm.askNote`},{mode:`full_access`,label:`perm.full`,note:`perm.fullNote`}];function az({sessionId:e,disabled:t}){let n=R(),r=N(e=>e.draftPermissionMode),i=N(e=>e.setDraftPermissionMode),[a,o]=(0,B.useState)(e?`ask`:r),[s,c]=(0,B.useState)(!1),[l,u]=(0,B.useState)(!1),[d,f]=(0,B.useState)(null),p=(0,B.useRef)(null),m=zl(t=>e!==null&&Ul(e)(t)!==null);(0,B.useEffect)(()=>{if(!e){o(r);return}let t=!1;return St(e).then(e=>{t||o(e.mode)}).catch(e=>{t||f(aN(e))}),()=>{t=!0}},[e,r]),rz(e,o);let h=(0,B.useCallback)(async t=>{if(t===`full_access`&&!l)u(!0);else{f(null);try{if(e){let n=(await Vt(e,t)).mode;o(n),nz(e,n),n===`full_access`&&m||c(!1)}else i(t),o(t),c(!1)}catch(t){f(aN(t)),e&&St(e).then(e=>o(e.mode)).catch(e=>f(t=>`${t??``} Couldn't re-read the saved mode: ${aN(e)}`.trim()))}finally{u(!1)}}},[l,m,e,i]),g=a===`full_access`,_=g?bs:vs;return z(`div`,{className:`composer-chip-wrap`,children:[z(`button`,{ref:p,type:`button`,className:`composer-chip${g?` is-warning`:``}`,onClick:()=>{u(!1),c(e=>!e)},disabled:t,"aria-haspopup":`dialog`,"aria-expanded":s,"aria-label":n(`perm.chipAria`,{mode:We(g?`perm.fullLower`:`perm.askLower`)}),children:[L(_,{size:13,"aria-hidden":`true`}),L(`span`,{className:`composer-chip-label`,dir:`auto`,children:n(g?`perm.full`:`env.ask`)}),L($r,{size:12,"aria-hidden":`true`})]}),z(pc,{open:s,onClose:()=>c(!1),anchor:p,label:n(`env.permission`),children:[iz.map(e=>z(`button`,{type:`button`,className:`popover-item`,onClick:()=>h(e.mode),"aria-pressed":a===e.mode,children:[L(`span`,{className:`popover-item-check`,"aria-hidden":`true`,children:a===e.mode&&L(Yr,{size:13})}),z(`span`,{className:`popover-item-body`,children:[L(`span`,{className:`popover-item-title`,children:n(e.label)}),L(`span`,{className:`popover-item-note`,children:n(e.note)})]})]},e.mode)),l&&z(`div`,{className:`popover-message`,role:`alert`,children:[n(`env.fullAccessWarn`),` `,L(`button`,{type:`button`,className:`link-btn`,onClick:()=>h(`full_access`),children:n(`env.turnOn`)})]}),g&&m&&!l&&L(`div`,{className:`popover-message`,role:`status`,children:n(`perm.fullPendingNote`)}),d&&L(`div`,{className:`popover-message is-error`,role:`alert`,children:d})]})]})}function oz(e){return N(t=>tr(t,e))}function sz(e,t){return on(e,tr(N.getState(),t))}function cz({sessionId:e,disabled:t,compact:n=!1}){let r=R(),i=oz(e),a=N(e=>e.setResearch),o=t=>a(e,t);return(0,B.useEffect)(()=>{if(!i)return;let e=!0;return Pn().then(t=>{e&&bn(t.skills.map(e=>e.name))},e=>F.chat.warn(`Research mode could not read the installed skills; /<skill> commands will be researched`,e)),()=>{e=!1}},[i]),z(`button`,{type:`button`,className:`composer-chip composer-chip-research${i?` is-on`:``}`,onClick:()=>o(!i),disabled:t,"aria-pressed":i,"aria-label":r(`composer.research`),title:r(i?`composer.researchOnTitle`:`composer.researchOffTitle`),children:[L(Rs,{size:13,"aria-hidden":`true`}),!n&&L(`span`,{className:`composer-chip-label`,dir:`auto`,children:r(`composer.research`)})]})}function lz({text:e}){return L(`div`,{className:`history-notice`,role:`note`,children:e})}function uz({notices:e}){return L(`div`,{className:`library-notices`,role:`note`,children:e.map((e,t)=>L(`div`,{dir:`auto`,children:e},`${t}-${e}`))})}var dz={sending:`Adding to the running reply…`,delivered:`Added to the running reply. GAIA reads it at its next step.`,queued:`Queued. Sends when this reply ends.`};function fz(e,t){return e?dz.queued:t?`GAIA is still busy in this chat. Trying again in a few seconds.`:`Sending next.`}function pz({items:e,onRemove:t,onSteer:n,onRetry:r,replying:i=!0,busyRetry:a=!1}){let o=e.filter(e=>e.state!==`starting`);return o.length===0?null:L(`ul`,{className:`queued-messages`,"aria-label":`Messages waiting to send`,"aria-live":`polite`,children:o.map(e=>z(`li`,{className:`queued-message is-${e.state}`,children:[e.state===`failed`?L(di,{size:12,"aria-hidden":`true`}):e.state===`queued`?L(yi,{size:12,"aria-hidden":`true`}):L(Di,{size:12,"aria-hidden":`true`}),L(`span`,{className:`queued-message-text`,title:e.text,children:e.text}),L(`span`,{className:`queued-message-state`,title:e.error,children:e.state===`failed`?`Not sent. ${e.error??``}`.trim():e.state===`queued`?i&&e.note||fz(i,a):dz[e.state]}),e.state===`failed`&&z(`button`,{type:`button`,className:`queued-message-steer`,onClick:()=>r(e.id),"aria-label":`Send again: ${e.text}`,children:[L(is,{size:11,"aria-hidden":`true`}),` Send again`]}),e.state===`queued`&&n&&L(`button`,{type:`button`,className:`queued-message-steer`,onClick:()=>n(e.id),title:`GAIA reads it at its next step, without starting over. It may not answer it separately.`,children:`Add to this reply`}),(e.state===`queued`||e.state===`failed`)&&L(`button`,{type:`button`,className:`queued-message-remove`,onClick:()=>t(e.id),"aria-label":`Remove queued message: ${e.text}`,title:`Remove`,children:L(nc,{size:12})})]},e.id))})}var mz=e=>e.toLocaleString(`en-US`);function hz({n:e}){let t=R();if(e==null)return L(`span`,{className:`cp-unknown`,children:t(`ctx.unknown`)});let n=e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(+(e<1e4))}K`:`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`;return L(`span`,{title:t(`ctx.tokens`,{n:mz(e)}),dir:`ltr`,children:n})}function gz({s:e}){let t=R();if(e==null)return L(`span`,{className:`cp-unknown`,children:t(`ctx.unknown`)});let n=e<.1?e===0?`0 s`:`<0.1 s`:e<10?`${e.toFixed(1)} s`:`${Math.round(e)} s`;return L(`span`,{title:`${(e*1e3).toFixed(0)} ms`,dir:`ltr`,children:n})}function _z({r:e}){let t=R();return e==null?L(`span`,{className:`cp-unknown`,children:t(`ctx.unknown`)}):L(`span`,{title:t(`ctx.rateTitle`,{n:e}),children:t(`ctx.rate`,{n:Math.round(e).toLocaleString(`en-US`)})})}var vz=(e,t)=>t>0?Math.round(e/t*100):0,yz=(e,t)=>{let n=vz(e,t);return n===0&&e>0?`<1`:String(n)},bz=(e,t)=>t&&e!=null?Math.floor(e/t*100):null,xz=256;function Sz(e,t=mt){if(e.provider===`unknown`)return t(`ctx.unknown`);if(e.provider===`cloud`)return t(`ctx.cloud`);if(e.provider!==`local`)return t(`ctx.cloudVia`,{provider:Qc(e.provider)});if(!e.device)return e.loaded===!1?t(`ctx.notLoadedNow`):t(`ctx.unknown`);let n=e.device.toUpperCase(),r=e.backend===`npu`?`FLM`:e.backend;return r&&r!==e.device?`${n} · ${r.charAt(0).toUpperCase()}${r.slice(1)}`:n}function Cz({label:e,children:t,hint:n}){return z(`div`,{className:`cp-row`,title:n,children:[L(`dt`,{children:e}),L(`dd`,{children:t})]})}function wz({t:e}){let t=R();if(e.model_seconds==null||e.gaia_seconds==null)return z(Cz,{label:t(`ctx.took`),children:[L(gz,{s:e.wall_seconds}),` · `,t.bare(`ctx.split`),` `,L(`span`,{className:`cp-unknown`,children:t(`ctx.unknown`)})]});let n=[{key:`model`,label:t(`ctx.inModel`),s:e.model_seconds},{key:`tools`,label:t(`ctx.runningTools`),s:e.tool_seconds},{key:`waiting`,label:t(`ctx.waitingOnYou`),s:e.waiting_seconds},{key:`gaia`,label:t(`ctx.gaiaItself`),s:e.own_seconds??0}];return z(P.Fragment,{children:[L(Cz,{label:t(`ctx.took`),hint:t(`ctx.tookHint`),children:L(gz,{s:e.wall_seconds})}),L(`div`,{className:`cp-stack`,"aria-hidden":`true`,children:n.map(t=>L(`span`,{className:`cp-time-${t.key}`,style:{width:`${vz(t.s,e.wall_seconds)}%`}},t.key))}),z(`dl`,{className:`cp-rows cp-indent`,children:[L(Cz,{label:t(`ctx.inModel`),children:L(gz,{s:e.model_seconds})}),L(Cz,{label:t(`ctx.inGaia`),hint:t(`ctx.inGaiaHint`),children:L(gz,{s:e.gaia_seconds})}),n.slice(1).filter(e=>e.s>0).map(e=>z(Cz,{label:`· ${e.label}`,children:[L(`span`,{className:`swatch cp-time-${e.key}`,"aria-hidden":`true`}),` `,L(gz,{s:e.s})]},e.key))]})]})}function Tz({why:e}){let t=R();return L(`span`,{className:`cp-unknown`,title:e,children:t(`ctx.unknown`)})}var Ez={server:`ctx.src.server`,client:`ctx.src.client`};function Dz(e,t){return e?t(Ez[e]):void 0}function Oz({turn:e}){let t=R(),n=bz(e.tokens_cached,e.tokens_in),r=e.unknown??{},i=e.tools.map(e=>`${e.name??t(`ctx.toolOutside`)}: ${e.seconds??`?`} s`).join(`
|
|
191
191
|
`);return z(P.Fragment,{children:[L(wz,{t:e.time}),z(`dl`,{className:`cp-rows`,children:[L(Cz,{label:t(`ctx.firstWord`),hint:Dz(e.first_token_source,t),children:e.first_token_seconds==null?L(Tz,{why:r.first_token_seconds}):z(P.Fragment,{children:[t.bare(`ctx.in`),` `,L(gz,{s:e.first_token_seconds})]})}),L(Cz,{label:t(`ctx.readingPrompt`),hint:t(`ctx.readingHint`),children:e.tokens_new!=null&&e.tokens_new<xz?L(`span`,{title:t(`ctx.tooFewTitle`),children:t(`ctx.onlyNew`,{n:e.tokens_new})}):e.prefill_tokens_per_second==null?L(Tz,{why:r.prefill_tokens_per_second}):z(P.Fragment,{children:[L(_z,{r:e.prefill_tokens_per_second}),e.prefill_source===`client`&&L(`span`,{className:`cp-chip`,title:t(`ctx.approxTitle`),children:t(`ctx.approx`)})]})}),L(Cz,{label:t(`ctx.writing`),hint:Dz(e.generation_source,t)??t(`ctx.writingHint`),children:e.generation_tokens_per_second==null?L(Tz,{why:r.generation_tokens_per_second}):L(_z,{r:e.generation_tokens_per_second})}),L(Cz,{label:t(`ctx.tokensInOut`),hint:r.tokens,children:z(`span`,{dir:`ltr`,children:[L(hz,{n:e.tokens_in}),` → `,L(hz,{n:e.tokens_out})]})}),L(Cz,{label:t(`ctx.cache`),hint:t(`ctx.cacheHint`),children:e.tokens_cached==null?L(Tz,{why:r.tokens_cached}):z(P.Fragment,{children:[L(hz,{n:e.tokens_cached}),n!=null&&` (${n}%)`]})}),L(Cz,{label:t(`ctx.modelCalls`),children:e.model_calls}),L(Cz,{label:t(`ctx.toolCalls`),hint:i||void 0,children:e.tool_calls===0&&!e.tool_seconds_total?t(`ctx.none`):z(P.Fragment,{children:[e.tool_calls,` · `,L(gz,{s:e.tool_seconds_total??0})]})}),L(Cz,{label:t(`ctx.loads`),children:e.loads.length===0?t(`ctx.none`):z(`span`,{title:e.loads.map(e=>`${e.model}${e.replaced?.length?` replaced ${e.replaced.join(`, `)}`:``}: ${e.seconds} s`).join(`
|
|
@@ -206,17 +206,17 @@ Error generating stack: `+e.message+`
|
|
|
206
206
|
|
|
207
207
|
`)),e instanceof ik?_(!0):h(aN(e))}finally{ne.current=!1,y(!1)}}}},[D,e]),ie=(0,B.useCallback)(()=>k(D.compose(on(d.trim(),tr(N.getState(),null))),d.trim()),[D,k,d]);(0,B.useEffect)(()=>{n&&w.current?.focus()},[n]),(0,B.useEffect)(()=>{let e=w.current;t&&e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},[t]);let ae=v,A=(0,B.useRef)(null);(0,B.useLayoutEffect)(()=>{let e=T.current;if(!e)return;typeof e.getAnimations==`function`&&e.getAnimations().forEach(e=>e.cancel());let t=e.getBoundingClientRect().top,n=A.current;if(A.current={top:t,docked:ae},!n||n.docked===ae||CB()||typeof e.animate!=`function`)return;let r=getComputedStyle(document.documentElement).getPropertyValue(`--ease`).trim();if(!r)throw Error(`Motion token --ease is not set; check styles/index.css.`);e.animate([{transform:`translateY(${n.top-t}px)`},{transform:`none`}],{duration:SB(`--duration-spring`),easing:r})});let oe=(0,B.useRef)(``),se=(0,B.useCallback)(e=>{let t=oe.current,n=(t&&d.endsWith(t)?d.slice(0,-t.length):d).trimEnd();oe.current=e,p(n?`${n}\n\n${e}`:e),w.current?.focus()},[d,p]),ce=c?.state===`starting`||c?.state===`downloading`,le=v?`sending`:ce?`download`:s||O!==null?`loading`:`idle`,ue=b?.working_folder;return z(`main`,{className:`new-chat${ae?` is-docked`:``}`,"aria-label":a(`newChat.label`),children:[L(mG,{activity:le,progress:(c?.percent??0)/100,pulse:d.length,docked:ae,contentRef:T,composerRef:E}),L(`div`,{className:`new-chat-actions`,children:L(SH,{})}),z(`div`,{className:`new-chat-inner`,ref:T,children:[L(`h1`,{className:`new-chat-greeting`,"aria-hidden":ae,children:cK(new Date,a)}),l&&!u&&L(mK,{error:l}),L(`div`,{ref:E,children:L(CR,{value:d,onChange:p,onSubmit:ie,attachments:D,disabledReason:s?a(`composer.starting`):null,autoFocus:!0,inputRef:w,placeholder:o?a(`composer.researchPlaceholder`):void 0,leftControls:z(P.Fragment,{children:[L(az,{sessionId:null}),L(eK,{disabled:v}),L(cz,{sessionId:null,disabled:v,compact:!0})]}),rightControls:L(VR,{})})}),L(`div`,{className:`new-chat-meta`,children:ue&&L($R,{folder:ue,disabled:s||v})}),L(pK,{}),O!==null&&!s&&L(`p`,{className:`new-chat-warmup`,role:`status`,children:uK(O,a)}),m&&L(`p`,{className:`new-chat-error`,role:`alert`,children:m}),g&&r&&L(`p`,{className:`new-chat-error`,role:`alert`,children:a(`agentNotice.sendRefused`)}),L(nK,{onPick:se,disabled:s||v}),S&&L(dK,{detail:S,onRetry:()=>te()})]})]})}var gK=1e3,_K=15,vK=5,yK=new Map;function bK(){let e=R(),t=xc(e=>e.need),n=xc(e=>e.settle),r=(0,B.useRef)(null),i=(0,B.useRef)(null),a=(0,B.useRef)(0),o=(0,B.useRef)(0),s=(0,B.useRef)(null);s.current=t;let[c,l]=(0,B.useState)(null),[u,d]=(0,B.useState)(!1),[f,p]=(0,B.useState)(null),[m,h]=(0,B.useState)(!1),g=(0,B.useCallback)(()=>{i.current&&clearInterval(i.current),i.current=null},[]);(0,B.useEffect)(()=>(l(null),d(!1),p(null),h(!1),g),[t,g]);let _=(0,B.useCallback)(()=>{g(),u&&t?.model&&S(t.model.id).catch(e=>console.warn(`[ModelNeededDialog] could not cancel the download`,e)),n(!1)},[u,t,n,g]);ut(!!t,_),un(r,!!t);let v=(0,B.useCallback)(async r=>{if(!t?.model)return;let c=t,u=t.model.id,f=(yK.get(u)??0)+1;yK.set(u,f),p(null),d(!0),a.current=0,o.current=0;try{await Ke(u,{acknowledgeLowDisk:r})}catch(e){if(s.current!==c)return;d(!1),p(e instanceof Error?e.message:String(e)),e instanceof Vn&&e.body?.code===`low_disk`&&h(!0);return}s.current===c?(g(),i.current=setInterval(()=>{oe().then(t=>{if(s.current!==c){g();return}o.current=0;let r=t.models?.find(e=>e.id===u);if(r)r.bytes_total>0&&l(Math.floor(r.bytes_done*100/r.bytes_total)),r.state===`ready`||r.state===`verifying`?(g(),n(!0)):(r.state===`failed`||r.state===`cancelled`)&&(g(),d(!1),p(r.error??e(`modelNeeded.failed`)));else{if(++a.current<_K)return;g(),d(!1),p(e(`modelNeeded.failed`))}}).catch(e=>{s.current===c?++o.current<vK||(g(),d(!1),p(e instanceof Error?e.message:String(e))):g()})},gK)):yK.get(u)===f&&S(u).catch(e=>console.warn(`[ModelNeededDialog] could not cancel the download`,e))},[t,n,g,e]);if(t?.off)return(0,mM.createPortal)(L(`div`,{className:`model-needed-overlay`,children:z(`div`,{ref:r,className:`model-needed`,role:`dialog`,"aria-modal":`true`,"aria-label":e(`modelNeeded.off.${t.off}.title`),children:[L(`h2`,{className:`model-needed-title`,children:e(`modelNeeded.off.${t.off}.title`)}),L(`p`,{className:`model-needed-from`,children:e(`modelNeeded.off.${t.off}.body`)}),z(`div`,{className:`model-needed-actions`,children:[L(`button`,{type:`button`,className:`btn-secondary`,onClick:_,children:e(`modelNeeded.notNow`)}),L(`button`,{type:`button`,className:`btn-primary`,onClick:()=>n(!0),children:e(`modelNeeded.off.send`)})]})]})}),document.body);if(!t?.model)return null;let{model:y,job:b,disk_free_gb:x}=t,C=y.size_gb!=null&&x!=null&&y.size_gb>x,w=C||m;return(0,mM.createPortal)(L(`div`,{className:`model-needed-overlay`,children:z(`div`,{ref:r,className:`model-needed`,role:`dialog`,"aria-modal":`true`,"aria-label":e(`modelNeeded.dialog`),children:[L(`h2`,{className:`model-needed-title`,children:e(`modelNeeded.title.${b}`)}),z(`p`,{className:`model-needed-line`,children:[L(`bdi`,{children:y.name}),y.size_gb!=null&&z(P.Fragment,{children:[`, `,L(`bdi`,{dir:`ltr`,children:Sk(y.size_gb)})]}),x!=null&&z(P.Fragment,{children:[` · `,e(`modelNeeded.free`),` `,L(`bdi`,{dir:`ltr`,children:Sk(x)})]})]}),y.source&&z(`p`,{className:`model-needed-from`,children:[e(`setup.contents.from`),` `,L(`bdi`,{dir:`ltr`,children:y.source})]}),L(`p`,{className:`model-needed-from`,children:e(`modelNeeded.waits`)}),u&&(c==null?z(`p`,{role:`status`,children:[L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,e(`modelNeeded.starting`)]}):L(`progress`,{className:`setup-progress`,max:100,value:c,"aria-label":e(`modelNeeded.dialog`)})),C&&!u&&L(`p`,{className:`setup-error`,role:`alert`,children:e(`modelNeeded.lowDisk`,{need:Sk(y.size_gb??0),free:Sk(x??0),freeUp:Sk((y.size_gb??0)-(x??0))})}),f&&L(`p`,{className:`setup-error`,role:`alert`,children:f}),z(`div`,{className:`model-needed-actions`,children:[L(`button`,{type:`button`,className:`btn-secondary`,onClick:_,children:e(`modelNeeded.notNow`)}),L(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void v(w),disabled:u,children:e(w?`setup.confirm.downloadAnyway`:f?`setup.tryAgain`:`modelNeeded.download`)})]})]})}),document.body)}function xK(e,t,n){let r=(0,B.useRef)(n);(0,B.useEffect)(()=>{r.current=n});let i=(0,B.useRef)(!1),a=(0,B.useRef)(null);if(t&&!i.current){let e=document.activeElement;a.current=e instanceof HTMLElement?e:null}(0,B.useEffect)(()=>{if(!t)return;i.current=!0;let n=a.current,o=e.current;if(o&&!o.contains(document.activeElement)){let e=r.current?.()??Ln(o)[0];e?e.focus():(o.hasAttribute(`tabindex`)||o.setAttribute(`tabindex`,`-1`),o.focus())}return()=>{i.current=!1;let e=document.activeElement;(!e||e===document.body||o?.contains(e))&&n?.isConnected&&n.focus()}},[e,t])}var SK=2e3,CK=``,wK=``,TK={model_server:`logs.source.modelServer`,gaia:`logs.source.gaia`,service:`logs.source.service`,agent:`logs.source.agent`,desktop:`logs.source.desktop`,other:`logs.source.other`},EK={model_server:`logs.hint.modelServer`,gaia:`logs.hint.gaia`,service:`logs.hint.service`,agent:`logs.hint.agent`,desktop:`logs.hint.desktop`,other:`logs.hint.other`},DK={no_file:`logs.reason.noFile`,unreadable:`logs.reason.unreadable`,not_running:`logs.reason.notRunning`,remote:`logs.reason.remote`,no_stream:`logs.reason.noStream`,stream_failed:`logs.reason.streamFailed`},OK=e=>e.severity===`warning`||e.severity===`error`;function kK(e){return e instanceof Error?e.message:String(e)}function AK(e){let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}${t(e.getMonth()+1)}${t(e.getDate())}-${t(e.getHours())}${t(e.getMinutes())}${t(e.getSeconds())}`}function jK({source:e,file:t}){let n=R(),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)([]),[s,c]=(0,B.useState)(null),[l,u]=(0,B.useState)(!0),[d,f]=(0,B.useState)(!0),[p,m]=(0,B.useState)(!1),[h,g]=(0,B.useState)(null),_=(0,B.useRef)(null),v=(0,B.useRef)(!1),y=(0,B.useRef)(null),b=(0,B.useRef)(!0),x=(0,B.useRef)(null),S=(0,B.useCallback)(async n=>{if(!v.current){v.current=!0,n&&u(!0);try{let r=await Ne(e,{file:t,after:n?null:_.current});r.cursor&&(_.current=r.cursor);let a=r.lines??[],s=n||!!r.reset;o(e=>(s?a:[...e,...a]).slice(-5e3)),i(e=>s||!e?r:{...r,server_answering:r.server_answering??e.server_answering,dropped:e.dropped}),c(null)}catch(e){c(kK(e))}finally{v.current=!1,u(!1)}}},[e,t]);(0,B.useEffect)(()=>{_.current=null,b.current=!0,i(null),o([]),g(null),S(!0)},[S]),(0,B.useEffect)(()=>{if(!d)return;let e=setInterval(()=>{S(!1)},SK);return()=>clearInterval(e)},[d,S]);let C=p?a.filter(OK):a,w=C.map(e=>e.text).join(`
|
|
208
208
|
`),T=(0,B.useCallback)(()=>{let e=y.current;e&&b.current&&(e.scrollTop=e.scrollHeight,x.current=e.scrollTop)},[]);(0,B.useEffect)(T,[w,T]);let E=C.length>0;(0,B.useEffect)(()=>{let e=y.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(T);return t.observe(e),e.firstElementChild&&t.observe(e.firstElementChild),()=>t.disconnect()},[E,T]);let D=(0,B.useCallback)(async()=>{try{await navigator.clipboard.writeText(w),g({ok:!0,text:n(`logs.copied`)})}catch(e){g({ok:!1,text:n(`logs.copyFailed`,{error:kK(e)})})}},[n,w]),O=(0,B.useCallback)(()=>{let t=URL.createObjectURL(new Blob([`${w}\n`],{type:`text/plain;charset=utf-8`})),n=document.createElement(`a`);n.href=t,n.download=`gaia-${e.replace(`_`,`-`)}-log-${AK(new Date)}.txt`,n.click(),setTimeout(()=>URL.revokeObjectURL(t),6e4),g(null)},[e,w]),ee=e===`model_server`,te=r&&!r.available&&r.reason?!ee&&r.reason===`no_file`?`logs.reason.notWritten`:DK[r.reason]:void 0;return z(`div`,{className:`log-viewer-view`,children:[L(`p`,{className:`log-viewer-hint`,children:n(EK[e])}),r?.source===`file`&&r.log_path&&z(`p`,{className:`log-viewer-source`,children:[n(`logs.fromFile`),` `,L(`bdi`,{dir:`ltr`,children:r.log_path})]}),r?.source===`stream`&&z(`p`,{className:`log-viewer-source`,children:[n(`logs.fromStream`),` `,L(`bdi`,{dir:`ltr`,children:r.base_url})]}),ee&&r?.source===`file`&&r.server_answering===!1&&L(`p`,{className:`log-viewer-warning`,role:`alert`,children:n(`logs.notAnswering`)}),te&&z(`div`,{className:`log-viewer-warning`,role:`alert`,children:[L(`p`,{children:n(te)}),r?.detail&&L(`p`,{className:`log-viewer-detail`,children:L(`bdi`,{dir:`ltr`,children:r.detail})})]}),r?.available&&r.detail&&L(`p`,{className:`log-viewer-hint`,role:`note`,children:L(`bdi`,{dir:`ltr`,children:r.detail})}),s&&L(`p`,{className:`log-viewer-warning`,role:`alert`,children:n(`logs.readFailed`,{error:s})}),z(`div`,{className:`log-viewer-toolbar`,children:[z(`label`,{className:`log-viewer-check`,children:[L(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked)}),n(`logs.follow`)]}),z(`label`,{className:`log-viewer-check`,children:[L(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked)}),n(`logs.problemsOnly`)]}),z(`div`,{className:`log-viewer-actions`,children:[z(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void S(!0),disabled:l,children:[l?L(Za,{size:13,className:`spin`,"aria-hidden":`true`}):L(is,{size:13,"aria-hidden":`true`}),n(`logs.refresh`)]}),z(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void D(),disabled:!w,children:[h?.ok?L(Yr,{size:13,"aria-hidden":`true`}):L(Ti,{size:13,"aria-hidden":`true`}),n(`logs.copy`)]}),z(`button`,{type:`button`,className:`btn-secondary`,onClick:O,disabled:!w,children:[L(Zi,{size:13,"aria-hidden":`true`}),n(`logs.save`)]})]})]}),l&&!r?z(`p`,{className:`log-viewer-empty`,role:`status`,children:[L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,n(`logs.loading`)]}):r?.available&&C.length===0?L(`p`,{className:`log-viewer-empty`,role:`status`,children:p&&a.length>0?n(`logs.noProblems`):n(`logs.empty`)}):C.length>0&&L(`pre`,{ref:y,className:`log-viewer-lines`,dir:`ltr`,tabIndex:0,"aria-label":n(TK[e]),onScroll:e=>{let t=e.currentTarget;t.scrollTop!==x.current&&(x.current=null,b.current=t.scrollHeight-t.scrollTop-t.clientHeight<8)},children:L(`span`,{className:`log-viewer-body`,children:C.map((e,t)=>z(`span`,{className:e.severity?`is-${e.severity}`:void 0,children:[e.text,`
|
|
209
|
-
`]},t))})}),(r?.dropped??0)>0&&L(`p`,{className:`log-viewer-hint`,children:n(`logs.older`)}),h&&L(`p`,{className:h.ok?`settings-ok`:`log-viewer-warning`,role:h.ok?`status`:`alert`,children:h.text})]})}function MK(){let e=R(),[t,n]=(0,B.useState)(!1),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(null),s=(0,B.useCallback)(async()=>{n(!0),o(null),i(null);try{let e=await or(),t=await ee(e.name),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=e.name,r.click(),setTimeout(()=>URL.revokeObjectURL(n),6e4),i(e)}catch(t){o(e(`logs.saveAllFailed`,{error:kK(t)}))}finally{n(!1)}},[e]);return z(`div`,{className:`log-viewer-save-all`,children:[z(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void s(),disabled:t,children:[t?L(Za,{size:13,className:`spin`,"aria-hidden":`true`}):L(_r,{size:13,"aria-hidden":`true`}),e(`logs.saveAll`)]}),L(`span`,{className:`log-viewer-hint`,children:e(`setup.logs.reportNote`)}),r&&z(`p`,{className:`log-viewer-hint`,role:`status`,children:[e(`logs.savedAll`,{size:Ek(r.size_bytes)}),` `,L(`bdi`,{dir:`ltr`,children:r.path})]}),a&&L(`p`,{className:`log-viewer-warning`,role:`alert`,children:a})]})}function NK(){let e=R(),t=hc(e=>e.open),n=hc(e=>e.source),r=hc(e=>e.show),i=hc(e=>e.hide),a=(0,B.useRef)(null),o=(0,B.useRef)(null),[s,c]=(0,B.useState)({}),[l,u]=(0,B.useState)(null);if(ut(t,i),un(a,t),xK(a,t,()=>o.current),(0,B.useEffect)(()=>{t&&sr().then(e=>c(Object.fromEntries(e.sources.map(e=>[e.id,e.files??[]])))).catch(e=>console.warn(`[LogsDialog] could not list log files`,e))},[t]),(0,B.useEffect)(()=>{u(null)},[n]),!t)return null;let d=s[n]??[];return(0,mM.createPortal)(L(`div`,{className:`log-viewer-overlay`,onMouseDown:e=>{e.target===e.currentTarget&&i()},children:z(`div`,{ref:a,className:`log-viewer`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`log-viewer-title`,children:[z(`div`,{className:`log-viewer-head`,children:[L(`h2`,{id:`log-viewer-title`,className:`log-viewer-title`,children:e(`logs.title`)}),L(`button`,{ref:o,type:`button`,className:`log-viewer-close`,onClick:i,"aria-label":e(`logs.close`),title:e(`logs.close`),children:L(nc,{size:16,"aria-hidden":`true`})})]}),L(`div`,{className:`log-viewer-tabs`,role:`tablist`,"aria-label":e(`logs.title`),children:mc.map(t=>L(`button`,{type:`button`,role:`tab`,"aria-selected":t===n,className:t===n?`is-active`:``,onClick:()=>r(t),children:t===`gaia`?L(`bdi`,{children:e(TK[t])}):e(TK[t])},t))}),d.length>1&&z(`label`,{className:`log-viewer-file`,children:[e(`logs.file`),L(`select`,{dir:`ltr`,value:l??d[0].name,onChange:e=>u(e.target.value),children:d.map(e=>z(`option`,{value:e.name,children:[e.name,e.size_bytes==null?``:` (${CK}${iR(e.size_bytes)}${wK})`]},e.name))})]}),L(`div`,{role:`tabpanel`,className:`log-viewer-panel`,children:L(jK,{source:n,file:l},`${n}:${l??``}`)}),L(`p`,{className:`log-viewer-hint`,children:e(`logs.privacy`)}),L(MK,{})]})}),document.body)}var PK=[{label:`shortcuts.newChat`,keys:`Mod+Shift+O`},{label:`shortcuts.search`,keys:`Mod+K`},{label:`shortcuts.sidebar`,keys:`Mod+B`},{label:`shortcuts.settings`,keys:`Mod+,`},{label:`shortcuts.sheet`,keys:`Mod+/`},{label:`shortcuts.browserPane`,keys:`Mod+Shift+B`,desktopOnly:!0},{label:`shortcuts.send`,keys:`Enter`},{label:`shortcuts.newLine`,keys:`Shift+Enter`},{label:`shortcuts.editLast`,keys:`↑`},{label:`shortcuts.stop`,keys:`Esc`}];function FK(){let e=!!MV();return PK.filter(t=>e||!t.desktopOnly)}function IK({onClose:e}){let t=R(),n=(0,B.useRef)(null);return ut(!0,e),un(n,!0),xK(n,!0),L(`div`,{ref:n,className:`modal-overlay`,onClick:e,role:`dialog`,"aria-modal":`true`,"aria-label":t(`shortcuts.title`),children:z(`div`,{className:`modal-panel shortcuts-dialog`,onClick:e=>e.stopPropagation(),children:[z(`div`,{className:`modal-header`,children:[L(`h3`,{children:t(`shortcuts.title`)}),L(`button`,{type:`button`,className:`btn-icon`,onClick:e,"aria-label":t(`shortcuts.close`),children:L(nc,{size:18,"aria-hidden":`true`})})]}),L(`dl`,{className:`modal-body shortcuts-list`,children:FK().map(({label:e,keys:n})=>z(`div`,{className:`shortcuts-row`,children:[L(`dt`,{children:t(e)}),L(`dd`,{children:L(`kbd`,{dir:`ltr`,children:_u(n)})})]},e))})]})})}function LK(e){let t=e?.reason;return t===`needs_key`||t===`bad_key`}function RK({provider:e,limit:t,picked:n=null,onPick:r,pickDisabled:i=!1,onDefault:a}){let o=R(),[s,c]=(0,B.useState)(null),[l,u]=(0,B.useState)(null),d=(0,B.useRef)(a);if(d.current=a,(0,B.useEffect)(()=>{let t=!0;return c(null),u(null),d.current?.(null),Xt(e).then(e=>{t&&(c(e),d.current?.(e.models[0]?.model??null))}).catch(e=>{t&&u(e instanceof Error?e.message:String(e))}),()=>{t=!1}},[e]),l)return L(`p`,{className:`settings-error`,role:`alert`,children:o(`settings.price.loadFailed`,{reason:l})});if(!s)return z(`p`,{className:`settings-hint`,children:[L(Za,{size:13,className:`spin`}),` `,o(`settings.price.loading`)]});if(s.models.length===0)return z(`p`,{className:`settings-hint cloud-prices-note`,children:[o(`settings.price.unknownSentence`),` `,L(`bdi`,{children:s.note})]});let f=t?s.models.slice(0,t):s.models,p=n?s.models.find(e=>e.model===n&&!f.includes(e)):void 0,m=p?[...f,p]:f,h=n??m[0]?.model,g=r!==void 0;return z(`div`,{className:`cloud-prices`,"aria-label":o(`settings.model.prices`),children:[g&&L(`p`,{className:`cloud-prices-legend`,id:`cloud-prices-legend`,children:o(`settings.price.pickLegend`)}),L(`ul`,{className:`cloud-prices-list${g?` is-pickable`:``}`,role:g?`radiogroup`:void 0,"aria-labelledby":g?`cloud-prices-legend`:void 0,children:m.map((t,n)=>{let a=z(`span`,{className:`cloud-prices-name`,children:[L(`bdi`,{children:t.name}),n===0&&g&&z(`span`,{className:`cloud-prices-default`,children:[` · `,o(`settings.price.default`)]}),t.note&&z(`span`,{className:`cloud-prices-note`,children:[` · `,L(`bdi`,{children:t.note})]})]});return z(`li`,{className:g&&h===t.model?`is-chosen`:void 0,children:[g?z(`label`,{className:`cloud-prices-pick`,children:[L(`input`,{type:`radio`,name:`cloud-model-${e}`,value:t.model,checked:h===t.model,disabled:i,onChange:()=>r(t.model)}),a]}):a,L(`span`,{className:`cloud-prices-price`,children:OR(t.price,o)})]},t.model)})}),z(`span`,{className:`settings-hint`,children:[L(`bdi`,{children:s.source}),`. `,o(`settings.price.payProvider`)]})]})}function zK(){return Du(xB)}function BK(e,t=150){let n=zK(),[r,i]=(0,B.useState)(e),a=(0,B.useRef)(e);return(0,B.useEffect)(()=>{if(n||typeof requestAnimationFrame!=`function`){a.current=e,i(e);return}let r=a.current,o=performance.now(),s=0,c=n=>{let l=Math.min(1,(n-o)/t),u=1-(1-l)**3,d=r+(e-r)*u;a.current=d,i(d),l<1&&(s=requestAnimationFrame(c))};return s=requestAnimationFrame(c),()=>cancelAnimationFrame(s)},[e,t,n]),r}function VK(e,t){let[n,r]=(0,B.useState)(e);return(0,B.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}function HK(){let[e,t]=(0,B.useState)(()=>typeof document>`u`||document.visibilityState!==`hidden`);return(0,B.useEffect)(()=>{let e=()=>t(document.visibilityState!==`hidden`);return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),e}var UK=180;function WK({open:e,children:t}){let[n,r]=(0,B.useState)(e),[i,a]=(0,B.useState)(e),o=(0,B.useRef)(t);return e&&(o.current=t),(0,B.useEffect)(()=>{if(e){r(!0);let e=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(e)}a(!1);let t=setTimeout(()=>r(!1),UK);return()=>clearTimeout(t)},[e]),n?L(`div`,{className:`reveal${i?` is-open`:``}`,"aria-hidden":!e||void 0,children:L(`div`,{className:`reveal-inner`,children:e?t:o.current})}):null}var GK=e=>e?.catalog??[],KK=e=>e.roles.includes(`vision`),qK=e=>e.roles.includes(`embedding`),JK=e=>e.recipe===`flm`,YK=e=>e.fits===!1&&(e.fit_code===`npu`||e.fit_code===`backend`),XK=e=>e.support===null,ZK=e=>e?.feature_tier!==`compact`;function QK(e,t){let n=e.find(e=>e.id===t.defaultChat);return n&&JK(n)||t.vision===`none`?null:t.vision?t.vision:n?.reads_images?n.id:e.find(e=>KK(e)&&e.gaia_model)?.id??null}function $K(e,t){let n=QK(t,e),r=new Set(e.ticked),i=new Set(e.unticked);for(let a of t)KK(a)&&a.id!==e.defaultChat&&(a.id===n?(r.add(a.id),i.delete(a.id)):a.downloaded||(r.delete(a.id),i.add(a.id)));return{...e,ticked:r,unticked:i}}function eq(e,t,n){let r=new Set(e.ticked),i=t.find(t=>t.id===e.defaultChat);i&&!i.downloaded&&r.delete(i.id);let a=t.find(e=>e.id===n);if(a?.downloaded||r.add(n),!ZK(a))for(let e of t)e.roles.includes(`image_creation`)&&r.delete(e.id);return $K({...e,ticked:r,defaultChat:n,chatChosen:!0,vision:null},t)}function tq(e,t,n){return $K({...e,vision:n},t)}function nq(e,t){if(t.vision===`none`)return null;let n=QK(e,t),r=e.find(e=>e.id===t.defaultChat);return r&&JK(r)||n===(r?.reads_images?r.id:e.find(e=>KK(e)&&e.gaia_model)?.id)?null:n}function rq(e){return e.filter(e=>e.gaia_model&&(e.planned||e.recommended||e.downloaded||e.partial))}function iq(e){let t=new Set(rq(e).map(e=>e.id));return e.filter(e=>e.gaia_model&&!t.has(e.id))}function aq(e){return e.filter(e=>!e.gaia_model&&e.downloaded)}function oq(e){let t=GK(e),n=new Set(t.filter(e=>e.selected||e.gaia_model&&e.downloaded&&!e.skipped).map(e=>e.id)),r=!t.find(t=>t.id===e.chat_model.id)?.reads_images&&t.some(e=>KK(e)&&e.gaia_model&&e.skipped);return $K({ticked:n,defaultChat:e.chat_model.id,unticked:new Set,chatChosen:e.chat_model.user_set,vision:e.vision_model??(r?`none`:null)},t)}function sq(e,t){return e.filter(e=>e.chat_choice&&(t.has(e.id)||e.downloaded))}function cq(e,t,n,r){let i=new Set(e.ticked),a=new Set(e.unticked);r?(i.add(n),a.delete(n)):(i.delete(n),a.add(n));let o=sq(t,i),s=e.defaultChat;if(!s||!o.some(e=>e.id===s)){let e=t.find(e=>e.id===n);s=r&&e?.chat_choice?n:(o.find(e=>e.recommended)??o[0])?.id??null}return{...e,ticked:i,defaultChat:s,unticked:a}}function lq(e,t,n){let r=t.find(e=>e.id===n)?.downloaded;return{...e,defaultChat:n,chatChosen:!0,ticked:r?e.ticked:new Set([...e.ticked,n])}}function uq(e){let t=GK(e),n=new Set(t.filter(e=>e.recommended||e.gaia_model&&e.downloaded).map(e=>e.id)),r=sq(t,n);return $K({ticked:n,defaultChat:e.recommended_model&&r.some(t=>t.id===e.recommended_model)?e.recommended_model:(r.find(e=>e.recommended)??r[0])?.id??null,unticked:new Set,chatChosen:!1,vision:null},t)}function dq(e,t){return e.filter(e=>t.ticked.has(e.id)&&!e.downloaded).sort((e,t)=>(t.size_gb??0)-(e.size_gb??0))}function fq(e,t){let n=dq(GK(e),t).map(e=>e.size_gb),r=n.every(e=>e!=null)?vq(n.reduce((e,t)=>e+t,0)):null,i=e.disk?.free_gb??null;return{downloadGb:r,freeGb:i,afterGb:r!=null&&i!=null?vq(i-r):null}}function pq(e,t){let{downloadGb:n,freeGb:r}=fq(e,t);return n==null||r==null||n<=r?null:{needGb:n,freeGb:r,freeUpGb:vq(n-r),drop:dq(GK(e),t).find(e=>e.size_gb!=null&&n-e.size_gb<=r)??null}}function mq(e,t){return e.filter(e=>e.fits===!1&&(t.ticked.has(e.id)||e.id===t.defaultChat))}function hq(e,t){let n=[];for(let r of GK(e)){if(!r.planned){r.skipped&&t.ticked.has(r.id)&&n.push({id:r.id,skipped:!1});continue}if(r.id===e.chat_model.id){r.skipped&&n.push({id:r.id,skipped:!1});continue}let i=t.ticked.has(r.id);!i&&!r.skipped&&n.push({id:r.id,skipped:!0}),i&&r.skipped&&n.push({id:r.id,skipped:!1})}return n}function gq(e,t){return GK(e).filter(e=>t.ticked.has(e.id)&&!e.planned&&!e.downloaded).map(e=>e.id)}function _q(e,t){let n=(e.models??[]).filter(e=>e.state!==`skipped`);if(!t?.catalog||n.length===0)return e.overall;let r=0,i=0;for(let e of n){let n=t.catalog.find(t=>t.id===e.id),a=n?.downloaded?0:n?.size_gb==null?e.bytes_total:Math.min(e.bytes_total||1/0,n.size_gb*1e9),o=Math.max(0,e.bytes_total-a);i+=a,r+=e.state===`ready`||e.state===`verifying`?a:Math.min(a,Math.max(0,e.bytes_done-o))}return{bytes_done:r,bytes_total:i,speed_bps:e.overall?.speed_bps??0,eta_s:null,percent:i>0?Math.floor(r*100/i):100,failed:n.filter(e=>e.state===`failed`).length}}function vq(e){return Math.round(e*10)/10}var yq=6;function bq(e,t){let n=[];return e.chat_choice&&!qK(e)&&n.push(t(`setup.models.purpose.chat`)),KK(e)&&n.push(t(`setup.models.purpose.vision`)),qK(e)&&n.push(t(`setup.models.purpose.documents`)),e.roles.includes(`speech`)&&n.push(t(`setup.models.purpose.speech`)),e.roles.includes(`voice`)&&n.push(t(`setup.models.purpose.voice`)),e.roles.includes(`image_creation`)&&n.push(t(`setup.models.purpose.imageCreation`)),n}function xq(e,t){return qK(e)?t(`setup.models.line.documents`):KK(e)?t(`setup.models.line.vision`):e.roles.includes(`speech`)?t(`setup.models.line.speech`):e.roles.includes(`voice`)?t(`setup.models.line.voice`):e.roles.includes(`image_creation`)?t(`setup.models.line.imageCreation`):t(`setup.models.line.chat`)}function Sq(e,t){return e.downloaded?t(`setup.models.status.onPc`):e.size_gb==null?t(`setup.models.status.sizeUnknown`):e.partial?t(`setup.models.status.partial`,{size:Sk(e.size_gb)}):t(`setup.models.status.download`,{size:Sk(e.size_gb)})}function Cq(e,t){return e.fits!==!0||e.need_gb==null||e.capacity_gb==null?null:t(`setup.models.fit.ok`,{need:Tk(e.need_gb),have:Tk(e.capacity_gb)})}function wq(e,t){return e.fit_code===`npu`?t(`setup.models.warn.npu`):e.fit_code===`backend`?t(`setup.models.warn.backend`):e.need_gb!=null&&e.capacity_gb!=null?t(`setup.models.warn.tooBig`,{need:Tk(e.need_gb),have:Tk(e.capacity_gb)}):t(`setup.models.warn.tooBigNoNumbers`)}function Tq(e,t,n,r){return!KK(e)&&!qK(e)||KK(e)&&!e.downloaded&&r?null:n===`settings`?e.downloaded?t(`settings.models.warn.kept`,{name:e.name}):t(KK(e)?`settings.models.warn.vision`:`settings.models.warn.documents`,{name:e.name}):t(KK(e)?`setup.models.warn.vision`:`setup.models.warn.documents`,{name:e.name})}function Eq({entry:e,ticked:t,onToggle:n,disabled:r,progress:i,actions:a,place:o,imagesCovered:s}){let c=R(),l=(0,B.useId)(),u=e.fits===!1,d=t?null:Tq(e,c,o,s),f=i?.state===`downloading`&&i.bytes_total>0,p=u?wq(e,c):d,m=[`${l}-status`,`${l}-note`,p?`${l}-warn`:null].filter(Boolean).join(` `);return z(`li`,{className:`mc-row${t?` is-ticked`:``}${p?` has-warning`:``}`,children:[z(`div`,{className:`mc-row-top`,children:[z(`label`,{className:`mc-row-main`,children:[L(`input`,{type:`checkbox`,className:`mc-input`,checked:t,disabled:r,onChange:e=>n(e.target.checked),"aria-describedby":m}),L(`span`,{className:`mc-box`,"aria-hidden":`true`,children:L(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,children:L(`path`,{className:`mc-tick`,d:`M3.5 8.5l3 3 6-7`})})}),z(`span`,{className:`mc-text`,children:[z(`span`,{className:`mc-name-line`,children:[L(`bdi`,{className:`mc-name`,title:e.id,children:e.name}),z(`span`,{className:`mc-chips`,children:[bq(e,c).map(e=>L(`span`,{className:`mc-chip`,children:e},e)),JK(e)&&L(`span`,{className:`mc-chip is-npu`,children:c(`setup.models.npu`)})]})]}),z(`span`,{className:`mc-status`,id:`${l}-status`,children:[f?c(`setup.models.status.downloading`,{done:Ek(i.bytes_done),total:Ek(i.bytes_total)}):Sq(e,c),e.recommended&&L(`span`,{className:`mc-pill`,children:c(`setup.models.recommended`)}),e.fits===null&&z(`span`,{className:`mc-chip is-unknown`,children:[L(pi,{size:11,"aria-hidden":`true`}),` `,c(`setup.models.fitUnknown`)]})]}),L(`span`,{className:`mc-note`,id:`${l}-note`,children:c.compose(t=>[xq(e,t),Cq(e,t),e.fits===null?t(`setup.models.fit.unknown`):null].filter(Boolean).join(` `))})]})]}),a&&L(`span`,{className:`mc-actions`,children:a})]}),f&&L(`progress`,{className:`mc-mini-progress`,max:i.bytes_total,value:i.bytes_done,"aria-label":c(`setup.progress.rowLabel`,{name:e.name,state:c(`setup.state.downloading`)})}),L(WK,{open:!!p,children:z(`p`,{className:`mc-warn${u?` is-big`:``}`,role:`note`,id:`${l}-warn`,children:[L(Ws,{size:13,"aria-hidden":`true`}),L(`span`,{children:p})]})})]})}function Dq({plan:e,selection:t}){let n=R(),{downloadGb:r,freeGb:i,afterGb:a}=fq(e,t),o=pq(e,t),s=BK(r??0),c=BK(a??0),l=Oq(e.disk?.path??null),u=r!=null&&i?Math.min(1,r/i):0,d=VK(r==null?n(`setup.summary.spokenUnknown`):a==null?n(`setup.summary.spokenNoDisk`,{download:Sk(r)}):n(`setup.summary.spoken`,{download:Sk(r),after:Sk(Math.max(0,a))}),600);return z(`div`,{className:`mc-summary${o?` is-warn`:``}`,role:`group`,"aria-label":n(`setup.summary.label`),children:[z(`div`,{className:`mc-summary-stats`,children:[z(`span`,{className:`mc-stat`,children:[L(`span`,{className:`mc-stat-label`,children:n(`setup.summary.download`)}),L(`bdi`,{className:`mc-stat-value`,children:r==null?n(`setup.summary.sizeUnknown`):Sk(kq(s))})]}),z(`span`,{className:`mc-stat`,children:[z(`span`,{className:`mc-stat-label`,children:[L(ka,{size:12,"aria-hidden":`true`}),` `,l?z(P.Fragment,{children:[n(`setup.summary.freeOn`),` `,L(`bdi`,{dir:`ltr`,className:`mc-stat-path`,children:l})]}):n(`setup.summary.free`)]}),L(`bdi`,{className:`mc-stat-value`,children:i==null?n(`setup.summary.freeUnknown`):Sk(i)})]}),a!=null&&!o&&z(`span`,{className:`mc-stat`,children:[L(`span`,{className:`mc-stat-label`,children:n(`setup.summary.after`)}),L(`bdi`,{className:`mc-stat-value`,children:Sk(Math.max(0,kq(c)))})]})]}),i!=null&&L(`div`,{className:`mc-disk`,"aria-hidden":`true`,children:L(`span`,{className:`mc-disk-fill`,style:{inlineSize:`${(u*100).toFixed(1)}%`}})}),L(WK,{open:!!o,children:o&&z(`p`,{className:`mc-disk-warn`,role:`note`,children:[L(Ws,{size:13,"aria-hidden":`true`}),L(`span`,{children:o.drop?n(`setup.summary.shortDrop`,{need:Sk(o.needGb),free:Sk(o.freeGb),drive:l??n(`setup.summary.theDrive`),freeUp:Sk(o.freeUpGb),name:o.drop.name,saves:Sk(o.drop.size_gb??0)}):n(`setup.summary.short`,{need:Sk(o.needGb),free:Sk(o.freeGb),drive:l??n(`setup.summary.theDrive`),freeUp:Sk(o.freeUpGb)})})]})}),L(`span`,{className:`visually-hidden`,"aria-live":`polite`,children:d})]})}function Oq(e){if(!e)return null;let t=/^([A-Za-z]:)[\\/]/.exec(e);return t?t[1]:e}function kq(e){return Math.round(e*10)/10}function Aq({plan:e,selection:t,onToggle:n,onDefaultChat:r,labelledBy:i,cloud:a,disabled:o,progress:s,rowActions:c,place:l=`setup`}){let u=R(),d=GK(e),[f,p]=(0,B.useState)(``),m=(0,B.useId)(),h=a?d.filter(qK):rq(d),g=a?[]:iq(d),_=a?[]:aq(d),v=(0,B.useMemo)(()=>{let e=f.trim().toLowerCase();return e?_.filter(t=>t.id.toLowerCase().includes(e)||t.name.toLowerCase().includes(e)):_},[_,f]),y=sq(d,t.ticked),b=e=>L(Eq,{entry:e,ticked:t.ticked.has(e.id),onToggle:t=>n(e.id,t),disabled:o,progress:s?.[e.id],actions:c?.(e),place:l,imagesCovered:d.some(n=>n.id!==e.id&&KK(n)&&(t.ticked.has(n.id)||n.downloaded===!0))},e.id);return z(`div`,{className:`mc`,children:[L(`ul`,{className:`mc-list`,role:`group`,"aria-labelledby":i,children:h.map(b)}),a?L(`p`,{className:`setup-hint`,children:u(`setup.models.cloudNote`)}):L(`p`,{className:`mc-foot`,children:u(`setup.models.neverDeletes`)}),g.length>0&&z(`details`,{className:`mc-more`,children:[L(`summary`,{children:u(`setup.models.more`,{n:String(g.length)})}),L(`ul`,{className:`mc-list`,role:`group`,"aria-label":u(`setup.models.moreLabel`),children:g.map(b)})]}),_.length>0&&z(`details`,{className:`mc-more`,children:[L(`summary`,{children:u(`setup.models.installed`,{n:String(_.length)})}),_.length>yq&&L(`input`,{className:`settings-input mc-search`,type:`search`,value:f,onChange:e=>p(e.target.value),placeholder:u(`setup.models.search`),"aria-label":u(`setup.models.search`)}),L(`ul`,{className:`mc-list`,role:`radiogroup`,"aria-label":u(`setup.models.installedLabel`),children:v.map(e=>L(`li`,{className:`mc-row is-installed${t.defaultChat===e.id?` is-ticked`:``}`,children:z(`label`,{className:`mc-row-main`,children:[L(`input`,{type:`radio`,name:`${m}-installed`,className:`mc-radio`,checked:t.defaultChat===e.id,disabled:o,onChange:()=>r(e.id)}),z(`span`,{className:`mc-text`,children:[z(`span`,{className:`mc-name-line`,children:[L(`bdi`,{className:`mc-name`,title:e.id,children:e.name}),z(`span`,{className:`mc-chips`,children:[L(`span`,{className:`mc-chip`,children:u(`setup.models.purpose.chat`)}),JK(e)&&L(`span`,{className:`mc-chip is-npu`,children:u(`setup.models.npu`)})]})]}),z(`span`,{className:`mc-status`,children:[u(`setup.models.status.onPc`),` · `,u(`setup.models.useAsDefault`)]})]})]})},e.id))})]}),!a&&z(`div`,{className:`mc-default`,children:[L(`label`,{htmlFor:m,className:`mc-default-label`,children:u(`setup.models.defaultChat`)}),z(`select`,{id:m,className:`settings-input mc-select`,value:t.defaultChat??``,disabled:o||y.length===0,onChange:e=>r(e.target.value),children:[y.length===0&&L(`option`,{value:``,children:u.bare(`setup.models.noChat`)}),y.map(e=>z(`option`,{value:e.id,children:[e.name,JK(e)?` (${u(`setup.models.npu`)})`:``]},e.id))]})]})]})}function jq(){let e=R();return z(`div`,{className:`mc`,"aria-busy":`true`,children:[z(`p`,{className:`setup-hint`,role:`status`,children:[L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,e(`setup.models.loading`)]}),L(`ul`,{className:`mc-list`,"aria-hidden":`true`,children:[0,1,2].map(e=>L(`li`,{className:`mc-row is-skeleton`,children:L(`span`,{className:`mc-skeleton`})},e))})]})}function Mq({entry:e}){let t=R();return e.support===`verified`?L(`span`,{className:`mc-chip is-verified`,children:t(`setup.label.verified`)}):e.support===`untested`?L(`span`,{className:`mc-chip is-untested`,children:t(`setup.label.untested`)}):null}function Nq({name:e,entry:t,checked:n,recommended:r,disabled:i,onPick:a,children:o}){let s=R();return L(`li`,{className:`mc-row${n?` is-ticked`:``}`,children:z(`label`,{className:`mc-row-main`,children:[L(`input`,{type:`radio`,className:`mc-radio`,name:e,checked:n,disabled:i||YK(t),onChange:a}),z(`span`,{className:`mc-text`,children:[z(`span`,{className:`mc-name-line`,children:[L(`span`,{className:`mc-name`,title:t.id,children:L(`bdi`,{children:t.name})}),z(`span`,{className:`mc-chips`,children:[r&&L(`span`,{className:`mc-pill`,children:s(`setup.models.recommended`)}),L(Mq,{entry:t}),JK(t)&&L(`bdi`,{className:`mc-chip is-npu`,children:s(`setup.models.npu`)})]})]}),L(`span`,{className:`mc-status`,children:Sq(t,s)}),t.fits===!1&&z(`span`,{className:`mc-warn is-big`,role:`note`,children:[L(Ws,{size:13,"aria-hidden":`true`}),` `,wq(t,s)]}),o]})]})})}function Pq({label:e,note:t,size:n,checked:r,disabled:i,warning:a,chips:o,onChange:s}){return L(`li`,{className:`mc-row${r?` is-ticked`:``}${i?` is-off`:``}`,children:z(`label`,{className:`mc-row-main`,children:[L(`input`,{type:`checkbox`,className:`mc-input`,checked:r,disabled:i,onChange:e=>s(e.target.checked)}),L(`span`,{className:`mc-box`,"aria-hidden":`true`,children:L(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,children:L(`path`,{className:`mc-tick`,d:`M3.5 8.5l3 3 6-7`})})}),z(`span`,{className:`mc-text`,children:[z(`span`,{className:`mc-name-line`,children:[L(`span`,{className:`mc-name`,children:L(`bdi`,{children:e})}),L(`span`,{className:`mc-chips`,children:o})]}),L(`span`,{className:`mc-status`,children:L(`bdi`,{dir:`ltr`,children:n})}),L(`span`,{className:`mc-note`,children:t}),a&&z(`span`,{className:`mc-warn`,role:`note`,children:[L(Ws,{size:13,"aria-hidden":`true`}),` `,a]})]})]})})}function Fq({plan:e,selection:t,onSelection:n,disabled:r}){let i=R(),a=(0,B.useId)(),o=GK(e),[s,c]=(0,B.useState)(!1),l=o.find(e=>e.id===t.defaultChat),u=!!l&&JK(l),d=o.filter(e=>e.chat_choice&&!qK(e)&&(e.gaia_model||e.downloaded)&&JK(e)===u),f=d.filter(e=>e.support===`verified`),p=d.filter(e=>e.support!==`verified`),m=QK(o,t),h=!!l?.reads_images,g=o.filter(e=>KK(e)&&e.id!==l?.id),_=o.find(qK),v=e=>o.find(t=>XK(t)&&t.roles.includes(e)),y=e=>e.downloaded?i(`setup.models.status.onPc`):e.size_gb==null?i(`setup.contents.sizeOnDownload`):Sk(e.size_gb),b=(e,r)=>n(cq(t,o,e,r)),x=e=>n(eq(t,o,e)),S=e=>n(tq(t,o,e)),C=v(`speech`),w=v(`voice`),T=v(`image_creation`),E=ZK(l),D=l?.support===`untested`;return z(`div`,{className:`mc`,children:[z(`section`,{className:`mc-job`,"aria-labelledby":`${a}-chat`,children:[L(`h3`,{className:`mc-job-title`,id:`${a}-chat`,children:i(`setup.job.chat`)}),L(`p`,{className:`setup-hint`,children:i(`setup.job.verifiedNote`)}),L(`ul`,{className:`mc-list`,role:`radiogroup`,"aria-labelledby":`${a}-chat`,children:f.map(n=>L(Nq,{name:`${a}-chat-model`,entry:n,checked:n.id===t.defaultChat,recommended:n.id===e.recommended_model,disabled:r,onPick:()=>x(n.id)},n.id))}),p.length>0&&z(P.Fragment,{children:[L(`p`,{className:`setup-hint`,children:i(`setup.job.untestedNote`)}),L(`ul`,{className:`mc-list`,role:`radiogroup`,"aria-labelledby":`${a}-chat`,children:p.map(e=>L(Nq,{name:`${a}-chat-model`,entry:e,checked:e.id===t.defaultChat,recommended:!1,disabled:r,onPick:()=>x(e.id)},e.id))})]}),D&&z(`p`,{className:`mc-warn`,role:`note`,children:[L(Ws,{size:13,"aria-hidden":`true`}),` `,i(`setup.job.untestedPicked`)]})]}),z(`section`,{className:`mc-job`,"aria-labelledby":`${a}-vision`,children:[L(`h3`,{className:`mc-job-title`,id:`${a}-vision`,children:i(`setup.job.vision`)}),u?L(`p`,{className:`setup-hint`,role:`note`,children:i(`setup.job.visionOffNpu`,{name:l?.name??``})}):h?z(`div`,{className:`setup-card`,children:[z(`p`,{className:`mc-job-line`,children:[L(`bdi`,{children:i(`setup.job.visionBuiltIn`,{name:l?.name??``})}),L(`span`,{className:`setup-ok`,children:i(`setup.job.nothingMore`)})]}),L(`button`,{type:`button`,className:`link-btn`,"aria-expanded":s,onClick:()=>c(e=>!e),children:i(s?`setup.job.hideVision`:`setup.job.otherVision`)})]}):L(`p`,{className:`setup-hint`,children:i(`setup.job.visionNeeded`,{name:l?.name??``})}),!u&&(!h||s)&&z(`ul`,{className:`mc-list`,role:`radiogroup`,"aria-labelledby":`${a}-vision`,children:[g.map(e=>L(Nq,{name:`${a}-vision-model`,entry:e,checked:m===e.id,recommended:!h&&e.gaia_model&&e.support===`verified`,disabled:r,onPick:()=>S(e.id)},e.id)),L(`li`,{className:`mc-row${m===null?` is-ticked`:``}`,children:z(`label`,{className:`mc-row-main`,children:[L(`input`,{type:`radio`,className:`mc-radio`,name:`${a}-vision-model`,checked:h?m===l?.id:m===null,disabled:r,onChange:()=>S(h?null:`none`)}),z(`span`,{className:`mc-text`,children:[L(`span`,{className:`mc-name`,children:i(h?`setup.job.useChatForVision`:`setup.job.skipVision`)}),m===null&&!h&&z(`span`,{className:`mc-warn`,role:`note`,children:[L(Ws,{size:13,"aria-hidden":`true`}),` `,i(`setup.job.skipVisionNote`)]})]})]})})]})]}),_&&z(`section`,{className:`mc-job`,"aria-labelledby":`${a}-docs`,children:[L(`h3`,{className:`mc-job-title`,id:`${a}-docs`,children:i(`setup.job.documents`)}),L(`ul`,{className:`mc-list`,children:L(Pq,{label:_.name,note:i(`setup.models.line.documents`),size:y(_),checked:t.ticked.has(_.id),disabled:r,warning:t.ticked.has(_.id)?null:i(`setup.job.documentsOff`),chips:z(P.Fragment,{children:[L(`span`,{className:`mc-pill`,children:i(`setup.models.recommended`)}),L(Mq,{entry:_})]}),onChange:e=>b(_.id,e)})})]}),z(`section`,{className:`mc-job`,"aria-labelledby":`${a}-extras`,children:[L(`h3`,{className:`mc-job-title`,id:`${a}-extras`,children:i(`setup.job.extras`)}),L(`p`,{className:`setup-hint`,children:i(`setup.job.extrasNote`)}),z(`ul`,{className:`mc-list`,children:[C&&L(Pq,{label:i(`setup.job.speech`),note:i(`setup.job.speechNote`),size:y(C),checked:t.ticked.has(C.id),disabled:r,onChange:e=>b(C.id,e)}),w&&L(Pq,{label:i(`setup.job.voice`),note:i(`setup.job.voiceNote`),size:y(w),checked:t.ticked.has(w.id),disabled:r,onChange:e=>b(w.id,e)}),T&&L(Pq,{label:i(`setup.job.images`),note:i(`setup.job.imagesNote`),size:y(T),checked:t.ticked.has(T.id),disabled:r||!E,warning:E?null:i(`setup.job.imagesBlocked`,{name:l?.name??``}),onChange:e=>b(T.id,e)})]})]}),L(Iq,{plan:e,selection:t})]})}function Iq({plan:e,selection:t}){let n=R(),r=GK(e),i=e=>r.find(t=>t.id===e)?.name??e??n(`setup.get.off`),a=e=>r.find(n=>XK(n)&&n.roles.includes(e)&&t.ticked.has(n.id)),o=r.find(e=>qK(e)&&t.ticked.has(e.id)),s=r.find(e=>e.id===t.defaultChat),c=QK(r,t),l=[a(`speech`)&&n(`setup.job.speech`),a(`voice`)&&n(`setup.job.voice`)].filter(Boolean).join(`, `);return z(`section`,{className:`setup-card`,"aria-label":n(`setup.get.title`),children:[L(`h3`,{className:`mc-job-title`,children:n(`setup.get.title`)}),z(`dl`,{className:`setup-summary-list`,children:[z(`div`,{children:[L(`dt`,{children:n(`setup.job.chat`)}),L(`dd`,{children:L(`bdi`,{children:i(t.defaultChat)})})]}),z(`div`,{children:[L(`dt`,{children:n(`setup.job.vision`)}),L(`dd`,{children:L(`bdi`,{children:s&&JK(s)?n(`setup.get.offNpu`):c?i(c):n(`setup.get.off`)})})]}),z(`div`,{children:[L(`dt`,{children:n(`setup.job.documents`)}),L(`dd`,{children:L(`bdi`,{children:o?o.name:n(`setup.get.off`)})})]}),z(`div`,{children:[L(`dt`,{children:n(`setup.get.voice`)}),L(`dd`,{children:l||n(`setup.get.off`)})]}),z(`div`,{children:[L(`dt`,{children:n(`setup.job.images`)}),L(`dd`,{children:ZK(s)?a(`image_creation`)?n(`setup.get.on`):n(`setup.get.off`):n(`setup.get.notAvailable`)})]})]})]})}var Lq=(0,B.createContext)(void 0),Rq=Lq.Provider;function zq({children:e}){let t=(0,B.useContext)(Lq);return t===void 0?L(`div`,{className:`setup-row setup-nav`,children:e}):t===null?null:(0,mM.createPortal)(L(`div`,{className:`setup-footer-row`,children:e}),t)}function Bq({title:e,children:t,confirmLabel:n,cancelLabel:r,onConfirm:i,onCancel:a,danger:o,busy:s}){let c=(0,B.useRef)(null),l=(0,B.useRef)(null),u=(0,B.useId)(),d=(0,B.useId)();return un(c,!0),(0,B.useEffect)(()=>{let e=document.activeElement;return l.current?.focus(),()=>e?.focus?.()},[]),ut(!0,a,!s),(0,mM.createPortal)(L(`div`,{className:`confirm-overlay`,children:z(`div`,{ref:c,className:`confirm-sheet`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":u,"aria-describedby":t?d:void 0,children:[L(`h2`,{id:u,className:`confirm-title`,children:e}),t&&L(`div`,{id:d,className:`confirm-body`,children:t}),z(`div`,{className:`confirm-actions`,children:[L(`button`,{ref:l,type:`button`,className:`btn-secondary`,onClick:a,disabled:s,children:r}),L(`button`,{type:`button`,className:o?`btn-danger`:`btn-primary`,onClick:i,disabled:s,children:n})]})]})}),document.body)}function Vq(e){return e===`windows`?`Windows`:e===`linux`?`Linux`:e}function Hq(e){let t=/^Run:\s*(.+)$/.exec(e)??/^(sudo .+)$/.exec(e);return t?t[1].trim():null}function Uq(e,t){return e.setting&&Math.abs(e.setting.current_gb-t)<.05&&e.gpu_gb!=null?e.gpu_gb:e.presets?.find(e=>Math.abs(e.setting_gb-t)<.05)?.gpu_gb??null}function Wq(e,t,n=!1){return t==null?e(n?`gpu.appliedAny`:`gpu.pending.restartAny`):e(n?`gpu.applied`:`gpu.pending.restart`,{gb:Sk(t)})}function Gq(e){e.focus({preventScroll:!0});for(let t=e.parentElement;t;t=t.parentElement){let n=getComputedStyle(t).overflowY;if(n!==`auto`&&n!==`scroll`)continue;let r=e.getBoundingClientRect().top-t.getBoundingClientRect().top;(r<0||r>t.clientHeight-40)&&(t.scrollTop+=r-16);return}}function Kq(e){return e instanceof Error?e.message:String(e)}function qq({status:e,targetGpuGb:t}){let n=R(),r=e=>Math.round(e*10),i=r(e.total_gb??0),a=r(e.gpu_gb??0),o=t!=null&&r(t)>a?r(t):null,s=o==null?0:o-a,c=Math.max(0,i-a-s),l=e=>Sk(e/10),u=e=>i>0?Math.min(100,e/i*100):0,d=e.pending?.state===`took_effect`;return z(`div`,{className:`gpu-split`,children:[z(`div`,{className:`gpu-bar${d?` is-new`:``}`,role:`img`,"aria-label":o==null?n(`gpu.split.aria`,{cpu:l(c),gpu:l(a)}):n(`gpu.split.ariaTarget`,{cpu:l(c),gpu:l(o),now:l(a)}),children:[L(`span`,{className:`gpu-seg is-gpu`,style:{inlineSize:`${u(a)}%`}}),L(`span`,{className:`gpu-seg is-target`,style:{inlineSize:`${u(s)}%`}}),L(`span`,{className:`gpu-seg is-cpu`}),o!=null&&L(`span`,{className:`gpu-marker`,style:{insetInlineStart:`${u(o)}%`}})]}),z(`div`,{className:`gpu-legend`,"aria-hidden":`true`,children:[L(`span`,{className:`gpu-key is-gpu`,children:L(`bdi`,{children:n(`gpu.split.gpu`,{gb:l(a)})})}),o!=null&&L(`span`,{className:`gpu-key is-target`,children:L(`bdi`,{children:n(`gpu.split.added`,{gb:l(s)})})}),L(`span`,{className:`gpu-key is-cpu`,children:L(`bdi`,{children:n(`gpu.split.cpu`,{gb:l(c)})})})]})]})}function Jq({presets:e,value:t,onChange:n,recommended:r,max:i,keepGb:a,disabled:o}){let s=R();return z(jB,{className:`gpu-presets`,"aria-label":s(`gpu.presets.label`),children:[a!=null&&L(`button`,{type:`button`,role:`radio`,"aria-checked":t===null,className:`gpu-preset${t===null?` is-active`:``}`,disabled:o,onClick:()=>n(null),children:L(`bdi`,{children:s(`gpu.presets.keep`,{gb:Sk(a)})})}),e.map(e=>z(`button`,{type:`button`,role:`radio`,"aria-checked":e.setting_gb===t,className:`gpu-preset${e.setting_gb===t?` is-active`:``}`,disabled:o,onClick:()=>n(e.setting_gb),children:[L(`bdi`,{children:s(`gpu.presets.gpu`,{gb:Sk(e.gpu_gb)})}),e.setting_gb===r&&z(P.Fragment,{children:[` `,L(`span`,{className:`gpu-tag is-recommended`,children:s(`gpu.presets.recommended`)})]}),e.setting_gb===i&&z(P.Fragment,{children:[` `,L(`span`,{className:`gpu-tag is-max`,children:s(`gpu.presets.max`)})]})]},e.setting_gb))]})}function Yq({status:e,onStatus:t,mode:n,names:r,onSkip:i,onContinue:o,onBack:s,headingId:c,cloud:l=!1}){let u=R(),f=zc(e=>!!e.active?.remote)||l,p=(0,B.useCallback)(()=>{let e=c?document.getElementById(c):null;e&&Gq(e)},[c]);(0,B.useEffect)(()=>{n===`setup`&&p()},[n,p]);let m=(0,B.useId)(),h=e.presets??[],g=f?null:e.recommended_setting_gb??null,[_,v]=(0,B.useState)(g??(e.gpu_gb==null?h[0]?.setting_gb??null:null)),[y,b]=(0,B.useState)(!1),[x,S]=(0,B.useState)(null),[C,w]=(0,B.useState)(void 0),[T,E]=(0,B.useState)(null),[D,O]=(0,B.useState)(null),[ee,te]=(0,B.useState)(null),[ne,re]=(0,B.useState)(null),k=h.find(e=>e.setting_gb===_)??null,ie=h.length>0&&h[h.length-1].setting_gb===e.setting?.max_gb?h[h.length-1].setting_gb:null,ae=k&&e.total_gb!=null?Math.max(0,e.total_gb-k.gpu_gb):null,A=g==null&&!f?(e.models??[]).find(e=>e.default&&e.fits_now):void 0,oe=(k?.unlocks??[]).slice(0,2).map(e=>r[e]??e),se=e.pending??null,ce=e.method===`apply`,le=e.guided_value!==null,ue=(0,B.useCallback)(async()=>{b(!0),S(null),O(`steps`),te(null);try{let e=await Xe(_??void 0);w(e.guided_value),S(e.guided_value===null?[]:e.guided_steps??[])}catch(e){w(void 0),S([]),te({kind:`error`,message:Kq(e)})}finally{O(null)}},[_]),de=async()=>{if(_!=null){E(null),O(`apply`),te(null);try{t(await we(_)),te({kind:`applied`})}catch(e){let t=e instanceof Vn&&e.httpStatus===403;te(t?{kind:`denied`}:{kind:`error`,message:Kq(e)}),t&&p()}finally{O(null)}}},fe=async()=>{E(null),O(`revert`),te(null);try{t(await a()),te({kind:`applied`})}catch(e){te(e instanceof Vn&&e.httpStatus===403?{kind:`denied`}:{kind:`error`,message:Kq(e)})}finally{O(null)}},pe=async()=>{if(_!=null){O(`done`),te(null);try{t(await ct(_)),b(!1)}catch(e){te({kind:`error`,message:Kq(e)})}finally{O(null)}}},me=async()=>{O(`keep`),te(null);try{t(await d())}catch(e){te({kind:`error`,message:Kq(e)})}finally{O(null)}},j=async e=>{try{await navigator.clipboard.writeText(e),re(e)}catch(e){te({kind:`error`,message:u(`gpu.copyFailed`,{reason:Kq(e)})})}},he=se?.state===`restart_required`;return z(`div`,{className:`gpu`,children:[L(`p`,{className:`setup-hint`,children:u(`gpu.body`,{total:Sk(e.total_gb??0),gpu:Sk(e.gpu_gb??0)})}),L(qq,{status:e,targetGpuGb:!he&&!y?k?.gpu_gb??null:null}),se?.state===`took_effect`&&z(`div`,{className:`gpu-notice is-ok`,role:`status`,children:[L(Yr,{size:14,"aria-hidden":`true`}),L(`span`,{children:u(`gpu.pending.tookEffect`,{gb:Sk(e.gpu_gb??0)})}),L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void me(),disabled:D!==null,children:u(`gpu.ok`)})]}),he&&z(`div`,{className:`gpu-notice`,role:`status`,children:[L(Na,{size:14,"aria-hidden":`true`}),L(`span`,{children:u.compose(t=>[Wq(t,Uq(e,se.setting_gb),ee?.kind===`applied`),t(`gpu.pending.restartHow`),n===`setup`?t(`gpu.pending.downloadsFirst`):null].filter(Boolean).join(` `))}),se.source===`guided`&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void me(),disabled:D!==null,children:u(`gpu.keep`,{gb:Sk(e.gpu_gb??0)})})]}),se?.state===`not_applied`&&z(`div`,{className:`gpu-notice is-warn`,role:`status`,children:[L(Ws,{size:14,"aria-hidden":`true`}),L(`span`,{children:u(`gpu.pending.notApplied`,{gb:Sk(e.gpu_gb??0)})}),L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void me(),disabled:D!==null,children:u(`gpu.keep`,{gb:Sk(e.gpu_gb??0)})})]}),!he&&!y&&h.length>0&&z(P.Fragment,{children:[A&&z(`p`,{className:`gpu-unlock is-keep`,children:[L(Yr,{size:13,"aria-hidden":`true`}),` `,u(`gpu.keepRecommended`,{model:r[A.id]??A.id})]}),L(Jq,{presets:h,value:_,onChange:v,recommended:g,max:ie,keepGb:e.gpu_gb??null,disabled:D!==null}),k&&L(`p`,{className:`gpu-unlock`,children:oe.length>0?u(oe.length>1?`gpu.unlock.two`:`gpu.unlock.one`,{gb:Sk(k.gpu_gb),a:oe[0],b:oe[1]??``}):u(`gpu.unlock.none`,{gb:Sk(k.gpu_gb)})}),k&&k.setting_gb===ie&&ae!=null&&z(`p`,{className:`gpu-unlock is-warn`,role:`note`,children:[L(Ws,{size:13,"aria-hidden":`true`}),` `,u(`gpu.maxWarn`,{cpu:Sk(ae),os:Vq(e.os)})]}),L(`p`,{className:`setup-hint`,children:u.compose(t=>`${t(`gpu.reserve`,{gb:Sk(e.reserve_gb??16),os:Vq(e.os)})} ${t(`gpu.needs`)}`)}),!ce&&e.method_reason&&L(`p`,{className:`setup-hint`,children:L(`bdi`,{dir:`ltr`,children:e.method_reason})})]}),!he&&!y&&h.length===0&&L(`p`,{className:`setup-hint`,children:u(`gpu.noPresets`)}),y&&z(`div`,{className:`gpu-guided`,children:[k&&L(`p`,{className:`setup-hint`,id:m,children:u(`gpu.guided.lede`,{gb:Sk(k.gpu_gb)})}),x===null?z(`p`,{className:`setup-hint`,role:`status`,children:[L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,u(`gpu.guided.loading`)]}):C===null?L(`p`,{className:`setup-hint`,children:u(`gpu.noPresets`)}):L(`ol`,{className:`gpu-steps`,"aria-labelledby":m,children:x.map(e=>{let t=Hq(e);return z(`li`,{children:[L(`span`,{children:e}),t&&z(`button`,{type:`button`,className:`btn-secondary gpu-copy`,onClick:()=>void j(t),"aria-label":u(`gpu.copyAria`,{what:t}),children:[L(ne===t?Yr:Ti,{size:12,"aria-hidden":`true`}),u(ne===t?`gpu.copied`:`gpu.copy`)]})]},e)})}),z(zq,{children:[L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>b(!1),disabled:D!==null,children:u(`gpu.guided.back`)}),!ce&&C!==null&&z(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void pe(),disabled:D!==null||_==null,children:[D===`done`&&L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,u(`gpu.guided.done`)]})]})]}),D===`apply`||D===`revert`?z(`p`,{className:`setup-hint`,role:`status`,children:[L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,u(`gpu.waiting`)]}):null,ee?.kind===`denied`&&z(`div`,{className:`gpu-notice is-warn`,role:`alert`,children:[L(Ws,{size:14,"aria-hidden":`true`}),L(`span`,{children:u(`gpu.denied`)})]}),ee?.kind===`error`&&L(`p`,{className:`setup-error`,role:`alert`,children:ee.message}),!y&&(()=>{let t=!he&&ce&&h.length>0&&L(`button`,{type:`button`,className:`btn-primary`,onClick:()=>E(`apply`),disabled:D!==null||_==null,children:ee?.kind===`denied`||se?.state===`not_applied`?u(`gpu.tryAgain`):u(`gpu.apply`)}),r=!he&&h.length>0&&le&&L(`button`,{type:`button`,className:ce?`btn-secondary`:`btn-primary`,onClick:()=>void ue(),disabled:D!==null||_==null,children:u(`gpu.showMe`)});return n===`setup`?z(zq,{children:[s&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:s,children:u(`setup.back`)}),he?o&&L(`button`,{type:`button`,className:`btn-primary`,onClick:o,autoFocus:!0,children:u(`setup.continue`)}):_==null&&h.length>0?(i??o)&&L(`button`,{type:`button`,className:`btn-primary`,onClick:i??o,disabled:D!==null,children:u(`gpu.keepAsIs`)}):z(P.Fragment,{children:[i&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:i,disabled:D!==null,children:u(`gpu.skip`)}),ce?z(P.Fragment,{children:[r,t]}):r]})]}):z(`div`,{className:`setup-row gpu-actions`,children:[t,r,e.revert?.available&&z(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>E(`revert`),disabled:D!==null,children:[L(ns,{size:13,"aria-hidden":`true`}),` `,u(`gpu.undo`)]})]})})(),T===`apply`&&_!=null&&z(Bq,{title:k?u(`gpu.consent.title`,{gb:Sk(k.gpu_gb)}):u(`gpu.consent.titleAny`),confirmLabel:u(`setup.continue`),cancelLabel:u(`setup.cancel`),onConfirm:()=>void de(),onCancel:()=>E(null),children:[L(`p`,{children:k?u(`gpu.consent.body`,{name:e.setting?.name??``,gb:Sk(k.gpu_gb)}):u(`gpu.consent.bodyAny`,{name:e.setting?.name??``})}),L(`p`,{className:`confirm-note`,children:u(`gpu.consent.saved`,{gb:Sk(e.gpu_gb??0)})})]}),T===`revert`&&L(Bq,{title:u(`gpu.revert.title`),confirmLabel:u(`setup.continue`),cancelLabel:u(`setup.cancel`),onConfirm:()=>void fe(),onCancel:()=>E(null),children:L(`p`,{children:u(`gpu.revert.body`)})})]})}function Xq({plan:e,planError:t,onRetryPlan:n,onUseRecommended:r,selection:i,onSelection:a,cloud:o,keepTrying:s,onKeepTrying:c,onBack:l,onContinue:u,busy:d,error:f}){let p=R(),m=(0,B.useRef)(null),[h,g]=(0,B.useState)(!1),_=!!e&&!!i&&!!e.catalog,v=(0,B.useRef)(null);if(_&&v.current===null&&(v.current=!o&&dq(GK(e),i).length===0&&!!i.defaultChat&&GK(e).some(e=>e.downloaded)),(0,B.useEffect)(()=>{_&&m.current?.querySelector(`input:not([disabled])`)?.focus()},[_,h]),t&&!_)return z(`div`,{className:`setup-models-error`,children:[L(`p`,{className:`setup-error`,role:`alert`,children:p(`setup.models.listFailed`,{reason:t})}),z(`div`,{className:`setup-row`,children:[L(`button`,{type:`button`,className:`btn-primary`,onClick:n,children:p(`setup.tryAgain`)}),L(`button`,{type:`button`,className:`btn-secondary`,onClick:r,children:p(`setup.models.useRecommended`)})]}),L(`p`,{className:`setup-hint`,children:p(`setup.models.useRecommendedNote`)})]});if(!_)return L(jq,{});let y=GK(e),b=dq(y,i),x=!o&&!i.defaultChat,S=pq(e,i),C=o?[]:y.filter(e=>e.fits===!1&&i.ticked.has(e.id)),w=!h&&!!v.current&&b.length===0,T=p(S?`setup.continueAnyway`:`setup.continue`);return w?z(`div`,{className:`setup-present`,role:`status`,children:[z(`p`,{children:[L(Yr,{size:14,"aria-hidden":`true`}),` `,p(`setup.models.allPresent`)]}),L(`button`,{type:`button`,className:`link-btn`,onClick:()=>g(!0),children:p(`setup.models.change`)}),z(zq,{children:[L(`button`,{type:`button`,className:`btn-secondary`,onClick:l,disabled:d,children:p(`setup.back`)}),z(`button`,{type:`button`,className:`btn-primary`,onClick:()=>u(!1),disabled:d,children:[d&&L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,p(`setup.finish`)]})]}),f&&L(`p`,{className:`setup-error`,role:`alert`,children:f})]}):z(`div`,{className:`setup-models`,ref:m,children:[L(`p`,{className:`setup-hint`,children:p(`setup.job.lede`)}),L(Fq,{plan:e,selection:i,onSelection:a,disabled:d}),!o&&L(`button`,{type:`button`,className:`link-btn setup-reset`,onClick:()=>a(uq(e)),disabled:d,children:p(`setup.models.resetRecommended`)}),z(`div`,{className:`setup-models-footer`,children:[L(Dq,{plan:e,selection:i}),z(`label`,{className:`setup-keep-trying`,children:[L(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked),disabled:d}),L(`span`,{children:p(`setup.keepTrying`)})]}),L(WK,{open:x,children:L(`p`,{className:`setup-error`,id:`setup-no-chat`,children:p(`setup.models.noChatReason`)})}),C.length>0&&L(`span`,{className:`visually-hidden`,children:C.map(e=>wq(e,p)).join(` `)}),f&&L(`p`,{className:`setup-error`,role:`alert`,children:f}),z(zq,{children:[L(`button`,{type:`button`,className:`btn-secondary`,onClick:l,disabled:d,children:p(`setup.back`)}),z(`button`,{type:`button`,className:`btn-primary`,onClick:()=>u(!!S),disabled:d||x,"aria-describedby":x?`setup-no-chat`:void 0,children:[d&&L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,T]})]})]})]})}function Zq({plan:e,chatModel:t,gpu:n}){let r=R();if(!e?.catalog)return null;let i=e.catalog,a=e=>e?i.find(t=>t.id===e)?.name??e:null,o=QK(i,{ticked:new Set,unticked:new Set,chatChosen:!1,defaultChat:t,vision:e.vision_model??null}),s=i.find(e=>e.id===o)??i.find(e=>KK(e)&&e.gaia_model),c=i.find(e=>qK(e)&&e.downloaded),l=i.filter(e=>e.gaia_model&&e.planned&&e.skipped),u=n?.pending,d=i.find(e=>e.id===t);return z(`dl`,{className:`setup-summary-list`,children:[t&&z(`div`,{children:[L(`dt`,{children:r(`setup.ready.chat`)}),z(`dd`,{children:[L(`bdi`,{children:a(t)}),d?.recipe===`flm`?` (${r(`setup.models.npu`)})`:``]})]}),z(`div`,{children:[L(`dt`,{children:r(`setup.ready.vision`)}),L(`dd`,{children:s?.downloaded?L(`bdi`,{children:s.name}):r(`setup.ready.visionOff`,{name:s?.name??`Gemma-4-E4B-it`})})]}),c&&z(`div`,{children:[L(`dt`,{children:r(`setup.ready.documents`)}),L(`dd`,{children:L(`bdi`,{children:c.name})})]}),l.length>0&&z(`div`,{children:[L(`dt`,{children:r(`setup.ready.notInstalled`)}),L(`dd`,{children:l.map(e=>e.name).join(`, `)})]}),u?.state===`restart_required`&&z(`div`,{className:`is-warn`,children:[L(`dt`,{children:r(`setup.ready.gpu`)}),z(`dd`,{children:[L(Ws,{size:13,"aria-hidden":`true`}),` `,Wq(r,n?Uq(n,u.setting_gb):null)]})]}),u?.state===`took_effect`&&z(`div`,{children:[L(`dt`,{children:r(`setup.ready.gpu`)}),L(`dd`,{children:n?.gpu_gb==null?r(`setup.ready.gpuChanged`):r(`setup.ready.gpuNow`,{gb:Sk(n.gpu_gb)})})]})]})}function Qq(e){if(e.skill===`document-brief`){let t=/^(\d+) /.exec(e.note)?.[1];return t?{n:Number(t)}:void 0}if(e.skill===`coding`){let t=/^In (.+)$/.exec(e.note)?.[1];return t?{folder:t}:void 0}}function $q(e,t,n,r){let i=`${n}.one`,a=`${n}.other`,o=fe(i)&&fe(a)&&typeof r?.n==`number`?r.n===1?i:a:n;return!fe(o)||Be[o].includes(`{`)&&!r?t:mt(o,r)===t?e(o,r):t}function eJ(e,t){return{title:$q(t,e.title,`card.${e.skill}.title`),note:$q(t,e.note,`card.${e.skill}.note`,Qq(e))}}function tJ({text:e}){let t=b(e);return t.length===1?L(P.Fragment,{children:e}):L(P.Fragment,{children:t.map((e,t)=>L(`span`,{className:`start-card-part`,children:e},t))})}function nJ({cards:e,onPick:t,disabled:n}){let r=R();return e.length===0?null:L(`ul`,{className:`start-cards`,"aria-label":r(`newChat.cardsLabel`),children:e.map(e=>{let{title:i,note:a}=eJ(e,r);return L(`li`,{children:z(`button`,{type:`button`,className:`start-card`,onClick:()=>t(e),disabled:n,title:e.needs_input?`${e.prompt}…`:e.prompt,children:[z(`span`,{className:`start-card-title`,children:[i,L(Tr,{size:13,"aria-hidden":`true`})]}),L(`span`,{className:`start-card-note`,children:L(tJ,{text:a})})]})},e.skill)})})}function rJ(){let[e,t]=(0,B.useState)(null),[n,r]=(0,B.useState)([]),i=(0,B.useCallback)(()=>{Promise.resolve(gt()).then(e=>{t(e?.providers?.find(e=>e.id===`amd`)?.network??null),r(e?.providers??[])}).catch(e=>{console.warn(`[useGatewayNetwork] could not check the AMD gateway`,e),t(null)})},[]);return(0,B.useEffect)(i,[i]),{network:e,providers:n,recheck:i}}function iJ(e,t,n){return t===`active`?n(`setup.contents.working`):t===`done`?n(`setup.contents.ready`):t===`failed`?n(`setup.contents.failed`):e.installed?n(`setup.contents.alreadyHere`):n(`setup.contents.waiting`)}function aJ(e,t){return e==null?t(`setup.contents.sizeOnDownload`):Sk(e)}function oJ({state:e}){return e===`done`?L(Yr,{size:13,"aria-hidden":`true`}):e===`active`?L(Za,{size:13,className:`spin`,"aria-hidden":`true`}):L(e===`failed`?nc:_i,{size:13,"aria-hidden":`true`})}function sJ({id:e,error:t,transient:n,onRetry:r,disabled:i}){let a=R(),o=a(`setup.component.${e}`);return z(`div`,{className:`setup-content-failure`,role:`alert`,children:[L(`p`,{children:a(n?`setup.contents.failedNetwork`:`setup.contents.failedOther`,{name:o})}),t&&z(`details`,{className:`dl-details`,children:[L(`summary`,{children:a(`setup.progress.details`)}),L(`pre`,{dir:`ltr`,children:t})]}),r&&L(`button`,{type:`button`,className:`btn-primary`,onClick:r,disabled:i,"aria-label":a(`setup.contents.retryNamed`,{name:o}),children:a(`setup.progress.retry`)})]})}function cJ({plan:e,run:t,models:n=[],onRetry:r,retryDisabled:i}){let a=R();return z(`ul`,{className:`setup-contents`,children:[(e.components??[]).map(e=>{let n=t?.components?.[e.id],o=t!=null&&t.state!==`running`&&t.state!==`verifying`,s=n===`active`&&o?void 0:n;return z(`li`,{className:`setup-content is-${s??(e.installed?`done`:`waiting`)}`,children:[L(`span`,{className:`setup-content-icon`,children:L(oJ,{state:s??(e.installed?`done`:void 0)})}),z(`span`,{className:`setup-content-main`,children:[L(`span`,{className:`setup-content-name`,children:a(`setup.component.${e.id}`)}),L(`span`,{className:`setup-content-note`,children:a(`setup.component.${e.id}Note`)}),e.bundled?L(`span`,{className:`setup-content-from`,children:a(`setup.contents.bundled`)}):z(`span`,{className:`setup-content-from`,children:[a(`setup.contents.from`),` `,L(`bdi`,{dir:`ltr`,children:e.source})]})]}),z(`span`,{className:`setup-content-side`,children:[L(`bdi`,{dir:`ltr`,children:aJ(e.size_gb,a)}),L(`span`,{children:iJ(e,s,a)})]}),s===`failed`&&o&&!t?.problem&&L(sJ,{id:e.id,error:t?.error,transient:t?.component_kinds?.[e.id]===`transient`,onRetry:r,disabled:i})]},e.id)}),n.map(e=>z(`li`,{className:`setup-content is-waiting`,children:[L(`span`,{className:`setup-content-icon`,children:L(oJ,{state:void 0})}),z(`span`,{className:`setup-content-main`,children:[L(`span`,{className:`setup-content-name`,children:L(`bdi`,{children:e.name})}),L(`span`,{className:`setup-content-note`,children:e.roles.map(e=>a(`setup.purpose.${e}`)).join(` · `)}),e.source&&z(`span`,{className:`setup-content-from`,children:[a(`setup.contents.from`),` `,L(`bdi`,{dir:`ltr`,children:e.source})]})]}),L(`span`,{className:`setup-content-side`,children:L(`bdi`,{dir:`ltr`,children:aJ(e.size_gb,a)})})]},e.id))]})}function lJ({lines:e,className:t,id:n}){let r=(0,B.useRef)(null),i=(0,B.useRef)(!0),a=e.join(`
|
|
210
|
-
`);return(0,B.useEffect)(()=>{let e=r.current;e&&i.current&&(e.scrollTop=e.scrollHeight)},[a]),L(`pre`,{ref:r,id:n,className:t,dir:`ltr`,tabIndex:0,onScroll:e=>{let t=e.currentTarget;i.current=t.scrollHeight-t.scrollTop-t.clientHeight<8},children:a})}var
|
|
211
|
-
`):e.error})]}),u?L(`p`,{className:`dl-detail`,children:p(`setup.progress.retryLater`)}):z(`div`,{className:`setup-row`,children:[a&&z(`button`,{type:`button`,className:`btn-primary`,disabled:l,onClick:()=>a(e.id,e.error_kind),"aria-describedby":m,children:[L(is,{size:13,"aria-hidden":`true`}),` `,p(`setup.progress.retry`)]}),s&&L(`button`,{type:`button`,className:`btn-secondary`,disabled:l,onClick:()=>s(e.id),children:p(`setup.progress.skipModel`)})]})]}),e.state===`cancelled`&&o&&L(`div`,{className:`setup-row`,children:L(`button`,{type:`button`,className:`btn-secondary`,disabled:l,onClick:()=>o(e.id),children:p(`setup.progress.resume`)})}),S>=60&&c&&L(`div`,{className:`setup-row`,children:z(`button`,{type:`button`,className:`btn-secondary`,disabled:l,onClick:c,children:[L(is,{size:13,"aria-hidden":`true`}),` `,p(`setup.progress.retry`)]})})]})}function bJ({status:e,names:t,freeGb:n=null,onCancel:r,onRetry:i,onResume:a,onResumeAll:o,onSkip:s,onRestart:c,busy:l=!1,retryLater:u=!1,labelledBy:d}){let f=R(),p=HK(),m=(0,B.useMemo)(()=>pJ(e.models??[]),[e.models]),h=(0,B.useRef)(new Map),g=(0,B.useRef)(new Map),_=(0,B.useRef)(new Mk),v=(0,B.useRef)(!1),[y,b]=(0,B.useState)(()=>Date.now()),[x,S]=(0,B.useState)(!1),[C,w]=(0,B.useState)(null),T=i&&((e,t)=>{let n=m.find(t=>t.id===e);t===`verify`&&n?w(n):i(e,t)}),[E,D]=(0,B.useState)(``),[O,ee]=(0,B.useState)(``),te=(0,B.useRef)(null),ne=e.state===`verifying`||e.state!==`running`&&m.some(e=>e.state===`verifying`),re=(0,B.useRef)(new Map);(0,B.useEffect)(()=>{if(!p||!(m.some(e=>e.retrying_until)||ne))return;let e=setInterval(()=>b(Date.now()),1e3);return()=>clearInterval(e)},[m,p,ne]);let k=e.overall,{estimates:ie,overallEstimate:ae}=(0,B.useMemo)(()=>{let e=Date.now(),t={};for(let n of m){if(n.state!==`downloading`){h.current.delete(n.id);continue}let r=h.current.get(n.id),i=n.downloaded_before_gb??null;r&&g.current.get(n.id)===i||(r=new Mk,h.current.set(n.id,r),g.current.set(n.id,i)),t[n.id]=r.update(n.bytes_done,n.bytes_total,e)}let n=m.some(e=>e.state===`downloading`);n&&!v.current&&(_.current=new Mk),v.current=n;let r=m.filter(e=>e.state===`downloading`||e.state===`queued`).reduce((e,t)=>e+Math.max(0,t.bytes_total-t.bytes_done),0);return{estimates:t,overallEstimate:n&&k?_.current.update(k.bytes_done,k.bytes_done+r,e):void 0}},[m,k]);(0,B.useEffect)(()=>{let e=new Map(m.map(e=>[e.id,e.state])),n=Math.floor((k?.percent??0)/25),r=te.current;if(te.current={states:e,quarter:n},!r)return;let i=[];for(let e of m){if(r.states.get(e.id)===e.state)continue;let n=t[e.id]??e.id;e.state===`failed`?ee(f(`setup.progress.announceFailed`,{name:n})):i.push(f(`setup.progress.announceState`,{name:n,state:f(gJ[e.state])}))}n>r.quarter&&n>0&&n<4&&i.push(f(`setup.progress.announceOverall`,{n:String(n*25)})),i.length&&D(i.join(`. `))},[m,k?.percent,t,f]);let A=e=>{if(!ne)return re.current.delete(e),0;let t=Date.now(),n=re.current.get(e)??t;return re.current.set(e,n),Math.floor((t-n)/1e3)},oe=_J(e),se=m.filter(e=>e.state===`cancelled`),ce=k?.failed??m.filter(e=>e.state===`failed`).length,le=k?.percent??0,ue=()=>{(k?.bytes_done??0)>uJ?S(!0):r?.()},de=f.compose(e=>[e(`setup.progress.overallPct`,{n:String(le)}),k&&k.bytes_total>0?e(`setup.progress.of`,{done:Ek(k.bytes_done),total:Ek(k.bytes_total)}):null,oe&&ae?.speed?Ok(f.locale,Dk(ae.speed)):null,oe?ae?.eta==null?e(`setup.progress.estimating`):e(`setup.progress.left`,{eta:kk(ae.eta,e)}):null,ce>0?e(`setup.progress.failedCount`,{n:String(ce)}):null].filter(Boolean).join(` · `));return z(`section`,{className:`dl${p?``:` is-paused`}`,"aria-labelledby":d,children:[z(`div`,{className:`dl-overall`,children:[L(`p`,{className:`dl-overall-line`,children:L(`bdi`,{children:de})}),L(`div`,{className:`dl-track is-overall${m.some(e=>e.state===`downloading`)?` is-live`:``}`,role:`progressbar`,"aria-label":f(`setup.progress.overallLabel`),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":le,"aria-valuetext":f(`setup.progress.percent`,{n:String(le)}),children:L(`span`,{className:`dl-fill`,style:{inlineSize:`${le}%`}})})]}),L(`ul`,{className:`dl-list`,children:m.map(e=>L(yJ,{model:e,name:t[e.id]??e.id,estimate:ie[e.id],now:y,freeGb:n,onRetry:T,onResume:oe?void 0:a,onSkip:s,onRestart:c,busy:l,retryLater:u,checking:ne,checkingFor:A(e.id)},e.id))}),oe&&L(`p`,{className:`setup-hint dl-controls`,children:f(`setup.progress.keepsGoing`)}),(oe&&r||!oe&&se.length>0&&o)&&z(zq,{children:[oe&&r&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:ue,disabled:l,children:f(`setup.progress.cancel`)}),!oe&&se.length>0&&o&&L(`button`,{type:`button`,className:`btn-primary`,onClick:o,disabled:l,children:f(`setup.progress.resumeAll`)})]}),L(`span`,{className:`visually-hidden`,"aria-live":`polite`,children:E}),L(`span`,{className:`visually-hidden`,role:`alert`,children:O}),x&&L(Bq,{title:f(`setup.progress.cancelTitle`),confirmLabel:f(`setup.progress.cancelConfirm`),cancelLabel:f(`setup.progress.cancelKeep`),onConfirm:()=>{S(!1),r?.()},onCancel:()=>S(!1),children:L(`p`,{children:f(`setup.progress.cancelBody`)})}),C&&L(Bq,{title:f(`setup.redownload.title`,{name:t[C.id]??C.id}),confirmLabel:f(`setup.redownload.confirm`),cancelLabel:f(`setup.redownload.keep`),onConfirm:()=>{let e=C;w(null),i?.(e.id,`verify`)},onCancel:()=>w(null),children:L(`p`,{children:f(`setup.redownload.body`,{name:t[C.id]??C.id,size:Ek(C.bytes_total)})})})]})}function xJ({run:e,plan:t,idle:n,bar:r=!0}){let i=R(),a=t?.components??[],o=a.find(t=>e.components?.[t.id]===`active`),s=a.filter(t=>e.components?.[t.id]===`done`||e.components?.[t.id]==null&&t.installed).length,c=e.percent==null?null:Math.max(0,Math.min(100,Math.round(e.percent))),l=o?i(`setup.download.now`,{name:i(`setup.component.${o.id}`)}):n;return z(`div`,{className:`setup-activity`,children:[z(`p`,{className:`setup-hint`,children:[L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,L(`span`,{role:`status`,children:l}),c!=null&&z(P.Fragment,{children:[` · `,z(`bdi`,{dir:`ltr`,children:[c,`%`]})]}),a.length>0&&z(P.Fragment,{children:[` · `,i(`setup.download.partsReady`,{done:String(s),total:String(a.length)})]})]}),r&&c!=null&&L(`progress`,{className:`setup-progress`,max:100,value:c,"aria-label":l})]})}var SJ=[`check`,`download`,`test`],CJ={root:`setup-report`,button:`btn-secondary setup-report-button`,hint:`setup-hint`,error:`setup-error`},wJ=/\d+(\.\d+)?\s*%/;function TJ(e){let t=[],n=null;for(let r of e){let e=r.search(wJ),i=e>=0?r.slice(0,e):null;i!==null&&i===n?t[t.length-1]=r:t.push(r),n=i}return t}function EJ({run:e,before:t={},failed:n=!1}){let r=R(),[i,a]=(0,B.useState)(n),[o,s]=(0,B.useState)(()=>new Set);(0,B.useEffect)(()=>{n&&a(!0)},[n]);let c=e=>s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),l=n=>TJ([...t[n]??[],...e?.logs?.[n]??[]]),u=SJ.filter(e=>l(e).length>0);return z(`section`,{className:`setup-logs`,"aria-label":r(`setup.logs.title`),children:[z(`button`,{type:`button`,className:`setup-log-toggle setup-help-toggle`,onClick:()=>a(e=>!e),"aria-expanded":i,"aria-controls":`setup-help`,children:[L(ri,{size:13,className:i?`is-open`:``,"aria-hidden":`true`}),` `,r(`setup.logs.help`)]}),i&&z(`div`,{id:`setup-help`,className:`setup-help`,children:[u.map(e=>{let t=l(e),n=o.has(e);return z(`div`,{className:`setup-log`,children:[z(`button`,{type:`button`,className:`setup-log-toggle`,onClick:()=>c(e),"aria-expanded":n,children:[L(ri,{size:13,className:n?`is-open`:``,"aria-hidden":`true`}),` `,r(`setup.logs.${e}`)]}),n&&L(lJ,{lines:t,className:`setup-log-pre`})]},e)}),L(oP,{classes:CJ,note:r(`setup.logs.reportNote`)})]})]})}function DJ(){let e=R(),t=N(e=>e.locale),n=N(e=>e.setLocale);return z(`label`,{className:`setup-language`,children:[L(La,{size:14,"aria-hidden":`true`}),L(`span`,{className:`visually-hidden`,children:e(`settings.language`)}),L(`select`,{value:t,onChange:e=>n(e.target.value),children:_e.map(({meta:e})=>L(`option`,{value:e.code,lang:e.code,dir:e.dir,children:ir(e)},e.code))})]})}var OJ=1e3,kJ=e=>e instanceof Error?e.message:String(e);function AJ(e){let[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)(!1),a=(0,B.useRef)(e);a.current=e;let o=(0,B.useRef)(!1),s=(0,B.useRef)(!1),c=(0,B.useCallback)(async()=>{o.current=!1,s.current=!0,i(!1),n({state:`downloading`,bytes_done:0,bytes_total:null,error:null});try{n(await Yt())}catch(e){n({state:`failed`,bytes_done:0,bytes_total:null,error:kJ(e)})}},[]),l=(0,B.useCallback)(e=>{e.state===`downloading`&&(o.current=!1,s.current=!1,i(!1),n(e))},[]),u=t?.state;return(0,B.useEffect)(()=>{if(u!==`downloading`)return;let e=!0,t=setTimeout(()=>{g().then(t=>{e&&(t.state===`idle`?(i(!0),n(e=>({...e??t,state:`failed`,error:null}))):n(t))}).catch(t=>{e&&n(e=>({...e??{bytes_done:0,bytes_total:null},state:`failed`,error:kJ(t)}))})},OJ);return()=>{e=!1,clearTimeout(t)}},[t,u]),(0,B.useEffect)(()=>{u!==`done`||o.current||(o.current=!0,a.current(s.current))},[u]),{job:t,start:c,follow:l,interrupted:r}}function jJ(e,t){return e.state===`done`?t(`setup.state.ready`):e.state===`failed`?t(`setup.state.failed`):t(`setup.state.downloading`)}function MJ({job:e,name:t,onRetry:n,failedNote:r,interrupted:i=!1}){let a=R(),o=(0,B.useId)(),s=e.bytes_total??0,c=e.state===`done`?100:s>0?Math.min(100,e.bytes_done/s*100):0,l=jJ(e,a),u=s>0?`${Ek(e.bytes_done)} / ${Ek(s)}`:Ek(e.bytes_done);return L(`ul`,{className:`dl-list agent-download`,children:z(`li`,{className:`dl-row is-${e.state===`done`?`ready`:e.state}${e.state===`downloading`?` is-live`:``}`,children:[z(`div`,{className:`dl-row-head`,children:[L(`span`,{className:`dl-icon`,"aria-hidden":`true`,children:e.state===`done`?L(Yr,{size:14}):e.state===`failed`?L(di,{size:14}):L(`span`,{className:`dl-dot`})}),L(`span`,{className:`dl-name`,children:L(`bdi`,{dir:`ltr`,children:t})}),L(`span`,{className:`dl-state`,children:l}),e.state===`downloading`&&z(`bdi`,{className:`dl-pct`,children:[Math.floor(c),`%`]})]}),L(`div`,{className:`dl-track`,role:`progressbar`,"aria-label":a(`setup.progress.rowLabel`,{name:t,state:l}),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.floor(c),"aria-valuetext":s>0?a(`setup.progress.of`,{done:Ek(e.bytes_done),total:Ek(s)}):l,children:L(`span`,{className:`dl-fill`,style:{inlineSize:`${c}%`}})}),e.state===`downloading`&&L(`p`,{className:`dl-detail`,children:L(`bdi`,{children:Ok(a.locale,u)})}),e.state===`failed`&&z(`div`,{className:`dl-fail`,role:`alert`,children:[L(`p`,{className:`dl-error`,id:o,children:a(`setup.agent.downloadFailed`,{name:t})}),i&&L(`p`,{className:`dl-detail`,children:a(`setup.agent.downloadInterrupted`)}),r&&L(`p`,{className:`dl-detail`,children:r}),e.error&&z(`details`,{className:`dl-details`,children:[L(`summary`,{children:a(`setup.progress.details`)}),L(`pre`,{dir:`ltr`,children:e.error})]}),L(`div`,{className:`setup-row`,children:z(`button`,{type:`button`,className:`btn-primary`,onClick:n,"aria-describedby":o,children:[L(is,{size:13,"aria-hidden":`true`}),` `,a(`setup.progress.retry`)]})})]})]})})}var NJ=[{id:`gaiapy`,label:`setup.agent.gaiapy`,more:`setup.agent.gaiapyMore`,tag:`setup.offer.recommended`},{id:`gaiacpp`,label:`setup.agent.gaiacpp`,more:`setup.agent.gaiacppMore`,tag:`setup.agent.beta`}],PJ={no_release:`setup.agent.why.noRelease`,unreachable:`setup.agent.why.unreachable`,unverifiable:`setup.agent.why.unverifiable`},FJ=e=>e instanceof Error?e.message:String(e);function IJ({inSettings:e=!1,disabled:t=!1,pending:n=null,onPending:r}){let i=R(),a=(0,B.useId)(),o=`${a}-title`,s=`${a}-more`,c=`${a}-off`,[l,u]=(0,B.useState)(null),[d,f]=(0,B.useState)(null),[p,m]=(0,B.useState)(null),[h,g]=(0,B.useState)(!1),[_,v]=(0,B.useState)(!1),y=(0,B.useRef)(!0),b=(0,B.useCallback)(async(e,t)=>{g(!0),m(null),u(t=>t&&{...t,current:e});try{let t=await pe({flagship_agent:e});y.current&&u(e=>e&&{...e,current:t.flagship_agent})}catch(e){if(!y.current)return;m(FJ(e));let n=e instanceof Vn&&(e.httpStatus===422||e.httpStatus===409)?null:await $t().catch(()=>null);y.current&&u(e=>n??(e&&{...e,current:t}))}finally{y.current&&g(!1)}},[]),x=(0,B.useRef)(`gaiapy`);x.current=l?.current??`gaiapy`;let{job:S,start:C,follow:w,interrupted:T}=AJ(e=>{let t=x.current;$t().then(e=>{y.current&&u(e)},e=>console.warn(`[AgentChoice] could not re-read the agents after the download`,e)).then(()=>{y.current&&e&&b(`gaiacpp`,t)})});(0,B.useEffect)(()=>(y.current=!0,$t().then(t=>{y.current&&(u(t),e&&w(t.download))}).catch(e=>{y.current&&f(FJ(e))}),()=>{y.current=!1}),[e,w]);let E=e=>l?.programs.find(t=>t.id===e),D=e=>e.id===`gaiapy`||e.installed,O=e=>!!e&&!D(e)&&!e.can_download,ee=t=>!!t&&e&&!D(t)&&t.can_download,te=S?.state===`downloading`,ne=n??l?.current,re=n=>{let i=E(n);l&&i&&!t&&!O(i)&&(e?h||te||ee(i)||n!==l.current&&b(n,l.current):r?.(n===l.current?null:{id:n,download:!D(i),current:l.current}))},k=E(`gaiacpp`),ie=k?.unavailable_code?i(PJ[k.unavailable_code]):k?.unavailable_reason,ae=!k||D(k)?null:k.can_download?i(e?`setup.agent.downloadsOnButton`:`setup.agent.downloadsLater`):ie?i(`setup.agent.cantDownload`,{reason:ie}):i(`setup.agent.notInstalledMore`);return z(`section`,{className:`agent-choice${e?` settings-card`:``}`,"aria-labelledby":o,"aria-busy":h||te||!l&&!d,children:[z(`h3`,{className:`agent-choice-title ${e?`settings-label`:`mc-job-title`}`,id:o,children:[i(`setup.agent.title`),h&&L(Za,{size:13,className:`spin`,"aria-hidden":`true`})]}),d&&L(`p`,{className:`agent-choice-error`,role:`alert`,children:i(`setup.agent.loadFailed`,{error:d})}),l&&z(P.Fragment,{children:[L(jB,{className:`setup-choices`,"aria-labelledby":o,children:NJ.map(n=>{let r=E(n.id),a=O(r),o=ee(r),s=z(`button`,{type:`button`,role:`radio`,"aria-checked":ne===n.id,"aria-disabled":a||o||t||void 0,"aria-describedby":a||o?c:void 0,className:`setup-choice agent-choice-row${ne===n.id?` is-active`:``}${a?` is-disabled`:``}${o?` is-pending`:``}`,onClick:()=>re(n.id),children:[z(`span`,{className:`agent-choice-what`,children:[L(`bdi`,{dir:`ltr`,className:`agent-choice-name`,children:n.id}),L(`span`,{className:`agent-choice-label`,children:i(n.label)}),r?.size_bytes!=null&&L(`bdi`,{dir:`ltr`,className:`agent-choice-size`,children:Ek(r.size_bytes)})]}),L(`span`,{className:`setup-choice-tag`,children:i(n.tag)}),a&&L(`span`,{className:`setup-choice-tag agent-choice-off`,children:i(`setup.agent.notInstalled`)}),r&&!D(r)&&!a&&!e&&L(`span`,{className:`setup-choice-tag agent-choice-off is-quiet`,children:i(`settings.model.notDownloaded`)})]},n.id);return a?z(`div`,{className:`agent-choice-blocked`,children:[s,L(`p`,{id:c,className:`agent-choice-why`,dir:`auto`,children:ae})]},n.id):!o||te||S?.state===`failed`?s:z(`div`,{className:`agent-choice-item`,children:[s,z(`button`,{type:`button`,className:`btn-secondary agent-choice-download`,onClick:()=>void C(),disabled:h||t,"aria-label":i(`setup.agent.downloadNamed`,{name:n.id}),children:[L(Ni,{size:13,"aria-hidden":`true`}),` `,i(`setup.agent.download`)]})]},n.id)})}),S&&(S.state===`downloading`||S.state===`failed`)&&L(MJ,{job:S,name:`gaiacpp`,onRetry:()=>void C(),failedNote:i(`setup.agent.stays`,{name:l.current}),interrupted:T}),z(`button`,{type:`button`,className:`agent-choice-more`,"aria-expanded":_,"aria-controls":s,onClick:()=>v(e=>!e),children:[L($r,{size:13,className:`agent-choice-chevron${_?` is-open`:``}`,"aria-hidden":`true`}),` `,i(`setup.agent.compare`)]}),z(`div`,{id:s,className:`agent-choice-detail`,hidden:!_,children:[NJ.map(e=>z(`p`,{children:[i(e.more,{name:e.id}),e.id===`gaiacpp`&&ae&&!O(k)&&z(P.Fragment,{children:[` `,L(`span`,{id:c,children:ae})]})]},e.id)),L(`p`,{children:i(e?`settings.agent.nextMessage`:`setup.agent.hint`)})]})]}),p&&L(`p`,{className:`agent-choice-error`,role:`alert`,children:i(`setup.agent.saveFailed`,{error:p})})]})}var LJ={driver:[`setup.npu.problem.driver`,`setup.npu.fix.driver`],device:[`setup.npu.problem.device`,`setup.npu.fix.device`],firmware:[`setup.npu.problem.firmware`,`setup.npu.fix.firmware`],access:[`setup.npu.problem.access`,`setup.npu.fix.access`],memlock:[`setup.npu.problem.memlock`,`setup.npu.fix.memlock`],runtime:[`setup.npu.problem.runtime`,`setup.npu.fix.runtime`]},RJ={cancelled:`setup.npu.fixError.cancelled`,timeout:`setup.npu.fixError.timeout`,not_authorized:`setup.npu.fixError.notAuthorized`,no_pkexec:`setup.npu.fixError.noPkexec`};function zJ({problem:e}){let t=R(),n=LJ[e.code];if(!n)return z(`li`,{children:[L(`strong`,{children:e.title}),` `,e.fix]});let r=e.params,i=n[1];e.code===`access`&&r.group&&(i=`setup.npu.fix.accessGroup`);let a=n[0];return e.code===`memlock`&&r.fix===`restart`&&(a=`setup.npu.problem.memlockStill`,i=`setup.npu.fix.memlockRestart`),e.code===`memlock`&&r.fix===`stuck`&&(a=`setup.npu.problem.memlockStuck`,i=`setup.npu.fix.memlockStuck`),z(`li`,{children:[L(`strong`,{children:t(a,{device:r.device??``,limit:r.limit??``,version:r.version??``,detail:r.detail??``})}),` `,t(i,{group:r.group??``})]})}function BJ({problems:e,disabled:t,onRecheck:n,id:r=`setup-npu-problems`}){let i=R(),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(null),l=e.some(e=>e.code===`memlock`&&e.params.fix===`apply`),u=async(e,t)=>{o(!0),c(null);try{await e(),n?.()}catch(e){let n=e instanceof Vn?e.body?.code:void 0,r=n&&n in RJ?RJ[n]:t;c(i(r))}finally{o(!1)}};return z(`div`,{className:`setup-npu-problems`,id:r,role:`note`,children:[L(`p`,{children:i(`setup.npu.notReady`)}),L(`ul`,{children:e.map(e=>L(zJ,{problem:e},e.code))}),L(`p`,{className:`setup-hint`,children:i(`setup.npu.meanwhile`)}),s&&L(`p`,{className:`setup-npu-error`,role:`alert`,children:s}),z(`div`,{className:`setup-npu-actions`,children:[l&&L(`button`,{type:`button`,className:`btn-primary`,disabled:t||a,onClick:()=>void u(He,`setup.npu.fixError.failed`),children:i(`setup.npu.fixMemlock`)}),n&&L(`button`,{type:`button`,className:`btn-secondary`,disabled:t||a,onClick:()=>void u(et,`setup.npu.recheckFailed`),children:i(`setup.npu.recheck`)})]})]})}async function VJ(){let e=await Ue();e.reachable&&(e.available_backends??[]).some(e=>e.name===`vulkan`)&&(e.preferred_backend??e.default_backend)!==`vulkan`&&await Qt(`vulkan`)}function HJ({plan:e,selection:t,onSelection:n,disabled:r=!1,onRecheck:i}){let a=R(),o=GK(e),s=e.npu?.present&&!e.npu.ready?e.npu.problems:[],c=s.length?void 0:o.find(e=>JK(e)&&e.gaia_model&&e.chat_choice&&e.fits!==!1)??o.find(e=>JK(e)&&e.chat_choice&&e.downloaded&&!YK(e)),l=!s.length&&!c&&o.some(e=>JK(e)&&e.fit_code===`npu`),u=!!o.find(e=>e.id===t.defaultChat&&JK(e)),d=uq(e).defaultChat,f=d&&!o.find(e=>e.id===d&&JK(e))?d:o.find(e=>e.chat_choice&&e.gaia_model&&e.support===`verified`&&!JK(e))?.id,p=e=>{e===`npu`&&c&&!u&&n(eq(t,o,c.id)),e===`gpu`&&u&&f&&n(eq(t,o,f))},m=[{id:`gpu`,label:a(`setup.backend.gpu`)},...c?[{id:`npu`,label:a(`setup.backend.npu`)}]:[],...s.length?[{id:`npu`,label:a(`setup.backend.npu`),unavailable:!0}]:[]],h=u?`npu`:`gpu`;return z(`section`,{className:`setup-backend`,"aria-labelledby":`setup-backend-title`,children:[L(`h3`,{className:`mc-job-title`,id:`setup-backend-title`,children:a(`setup.backend.title`)}),L(jB,{className:`segmented`,"aria-labelledby":`setup-backend-title`,children:m.map(e=>L(`button`,{type:`button`,role:`radio`,"aria-checked":h===e.id,"aria-describedby":e.unavailable?`setup-npu-problems`:void 0,className:h===e.id?`is-active`:``,disabled:r||e.unavailable,onClick:()=>p(e.id),children:L(`bdi`,{children:e.label})},e.id))}),s.length>0?L(BJ,{problems:s,disabled:r,onRecheck:i}):L(`p`,{className:`setup-hint`,children:a(c?`setup.backend.hint`:l?`setup.backend.hintNpuUnusable`:`setup.backend.hintNoNpu`)})]})}var UJ=({children:e})=>L(`bdi`,{dir:`ltr`,children:e});function WJ({label:e,children:t}){return z(`div`,{className:`found-row`,children:[L(`dt`,{children:e}),L(`dd`,{children:t})]})}function GJ(e){return e.family?`${e.name} (${e.family})`:e.name}var KJ=[[`llamacpp`,`llama.cpp`],[`flm`,`FastFlowLM`],[`whispercpp`,`whisper.cpp`],[`kokoro`,`Kokoro`],[`sd-cpp`,`stable-diffusion.cpp`]],qJ=new Set([`llamacpp`,`flm`]);function JJ(e){let t=[];for(let[n,r]of KJ){let i=(e.backends??[]).find(e=>e.recipe===n&&e.default);i&&i.state!==`unsupported`&&t.push({name:r,b:i})}return t}function YJ(e,t){return e?e.kind===`release_candidate`&&e.rc?`${e.version.replace(/rc\d+$/,``)} RC ${e.rc}`:e.kind===`source`&&e.commit?`${e.version} (${e.commit})`:e.version:t??null}var XJ={release:`release`,release_candidate:`release candidate`,local:`local build`,source:`from source`};function ZJ(e,t){let n=e.system,r=e=>(n?.devices??[]).filter(t=>t.available&&e(t.kind)),i=r(e=>e.endsWith(`gpu`)),a=r(e=>e.endsWith(`npu`)),o=JJ(e);return{sys:n,cpu:r(e=>e===`cpu`)[0],gpus:i,graphics:i.length?i.map(GJ).join(`; `):t?.gpu_name??null,npus:a,runsOn:i[0]?.name??t?.gpu_name??null,npu:a[0]??null,runtimes:o,gaia:YJ(n?.gaia_build,n?.gaia_version),build:n?.gaia_build?.kind??null,software:[YJ(n?.gaia_build,n?.gaia_version)?`GAIA ${YJ(n?.gaia_build,n?.gaia_version)}`:null,n?.lemonade_version?`Lemonade ${n.lemonade_version}`:null,...o.filter(({b:e})=>qJ.has(e.recipe)&&$J(e)).map(({name:e,b:t})=>`${e} ${t.version??t.backend}`)].filter(e=>!!e),totalMemory:wk(n?.physical_memory,t?.ram_gb),freeGb:e.disk?.free_gb??t?.disk_free_gb??null,modelsPath:e.disk?.path??null,gaiaHome:n?.gaia_home??null}}var QJ={installed:`installed`,update_required:`installed, updates on first use`},$J=e=>e.state===`installed`||e.state===`update_required`,eY={chat:`setup.job.chat`,vision:`setup.job.vision`,embedding:`setup.job.documents`,speech:`setup.job.speech`,voice:`setup.job.voice`,image_creation:`setup.job.images`};function tY(e,t){let n=ZJ(e,t),r=e.lemonade.mode===`external`?`the user's own`:`GAIA's own`;return[`GAIA: ${n.gaia??`unknown`}${n.build?`, ${XJ[n.build]}`:``} (agent ${n.sys?.agent_version??`not installed yet`})`,`Model server: ${r} Lemonade ${n.sys?.lemonade_version??`(version not reported)`}${e.lemonade.url?` at ${e.lemonade.url}`:``}`,...n.runtimes.map(({name:e,b:t})=>`${e}: ${t.backend}${t.version?` ${t.version}`:``} (${QJ[t.state??``]??`not installed`})`),`OS: ${n.sys?.os??t?.os??`unknown`}`,`Processor: ${n.cpu?.name??n.sys?.processor??`unknown`}${n.cpu?.cores?` (${n.cpu.cores} cores, ${n.cpu.threads??n.cpu.cores} threads)`:``}`,`Graphics: ${n.graphics??`none found`}`,`NPU: ${n.npus.map(GJ).join(`; `)||`none found`}`,`Memory: ${n.totalMemory??`unknown`}${e.capacity_gb==null?``:`, ${Sk(e.capacity_gb)} for models${e.memory_source?` (${e.memory_source})`:``}`}`,`Models folder: ${n.modelsPath??`unknown`}${n.freeGb==null?``:` (${Sk(n.freeGb)} free)`}`,`GAIA data and logs: ${n.gaiaHome??`unknown`}`].join(`
|
|
212
|
-
`)}function nY({plan:e,hardware:t,onChangeMemory:n}){let r=R(),i=ZJ(e,t),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(null),[l,u]=(0,B.useState)(null),d=async e=>{u(null);try{await Ft(e,!1)}catch(e){u(r(`setup.found.openFailed`,{error:e instanceof Error?e.message:String(e)}))}},f=L(`span`,{className:`found-muted`,children:r(`setup.found.unknown`)}),p=[...t?.blockers??[],...(t?.warnings??[]).filter(e=>t?.lemonade_running||!/\bNPU\b/.test(e))],m=(0,B.useRef)(null);(0,B.useEffect)(()=>()=>{m.current&&clearTimeout(m.current)},[]);let h=e=>{c(e),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>c(null),2e3)};return z(`section`,{className:`setup-card found`,"aria-label":r(`setup.found.title`),children:[z(`div`,{className:`found-head`,children:[L(`h3`,{className:`mc-job-title`,children:r(`setup.found.title`)}),L(`button`,{type:`button`,className:`found-copy`,onClick:()=>{navigator.clipboard.writeText(tY(e,t)).then(()=>h(`done`),e=>{console.warn(`[DetectedSummary] could not copy the details`,e),h(`failed`)})},"aria-label":r(`setup.found.copy`),title:r(`setup.found.copy`),children:L(s===`done`?Yr:Ti,{size:14,"aria-hidden":`true`})}),s&&L(`span`,{className:`found-copied`,role:`status`,children:r(s===`done`?`setup.found.copied`:`setup.found.copyFailed`)})]}),z(`dl`,{className:`found-glance`,children:[z(WJ,{label:r(`setup.found.runsOn`),children:[i.runsOn?L(UJ,{children:i.runsOn}):f,i.npu&&L(`span`,{className:`found-chip`,children:L(UJ,{children:`NPU`})})]}),z(WJ,{label:r(`setup.found.memory`),children:[e.capacity_gb!=null&&i.totalMemory?r(`setup.found.memoryOf`,{size:Sk(e.capacity_gb),total:i.totalMemory}):e.capacity_gb==null?i.totalMemory?L(UJ,{children:i.totalMemory}):f:L(UJ,{children:Sk(e.capacity_gb)}),n&&L(`button`,{type:`button`,className:`link-btn found-link`,onClick:n,children:r(`setup.found.changeMemory`)})]}),L(WJ,{label:r(`setup.found.space`),children:i.freeGb==null?f:L(UJ,{children:Sk(i.freeGb)})}),z(WJ,{label:r(`setup.found.software`),children:[i.software.length?L(UJ,{children:i.software.join(` · `)}):f,i.build&&i.build!==`release`&&L(`span`,{className:`found-chip`,children:r(`setup.found.build.${i.build}`)})]})]}),z(`div`,{className:`found-paths`,children:[[[`setup.found.modelsFolder`,i.modelsPath],[`setup.found.gaiaFolder`,i.gaiaHome]].map(([e,t])=>t&&z(`button`,{type:`button`,className:`link-btn found-open`,onClick:()=>void d(t),title:t,children:[L(da,{size:13,"aria-hidden":`true`}),` `,r(e)]},e)),l&&L(`p`,{className:`setup-error`,role:`alert`,children:l})]}),p.length>0&&z(`details`,{className:`dl-details found-warnings`,children:[z(`summary`,{children:[L(di,{size:13,"aria-hidden":`true`}),` `,r(`setup.found.noticed`)]}),L(`ul`,{children:p.map(e=>L(`li`,{children:L(UJ,{children:e})},e))})]}),z(`button`,{type:`button`,className:`setup-log-toggle found-more`,onClick:()=>o(e=>!e),"aria-expanded":a,children:[L(ri,{size:13,className:a?`is-open`:``,"aria-hidden":`true`}),` `,r(`setup.found.details`)]}),a&&z(`div`,{className:`found-details`,children:[L(`h4`,{className:`found-group`,children:r(`setup.found.software`)}),z(`dl`,{className:`found-list`,children:[z(WJ,{label:L(UJ,{children:`GAIA`}),children:[i.gaia?L(UJ,{children:i.gaia}):f,i.build&&i.build!==`release`&&L(`span`,{className:`found-chip`,children:r(`setup.found.build.${i.build}`)})]}),L(WJ,{label:r(`setup.found.agent`),children:i.sys?.agent_version?L(UJ,{children:i.sys.agent_version}):L(`span`,{className:`found-muted`,children:r(`setup.found.agentLater`)})}),z(WJ,{label:r(`setup.found.server`),children:[e.lemonade.mode===`external`?r(`setup.found.serverYours`):r(`setup.found.serverOwn`),i.sys?.lemonade_version&&z(P.Fragment,{children:[` `,L(UJ,{children:i.sys.lemonade_version})]}),e.lemonade.url&&L(`span`,{className:`found-sub`,children:L(UJ,{children:e.lemonade.url})})]})]}),L(`h4`,{className:`found-group`,children:r(`setup.found.runtime`)}),i.runtimes.length?L(`div`,{className:`found-table-wrap`,children:z(`table`,{className:`found-table`,children:[L(`thead`,{className:`visually-hidden`,children:z(`tr`,{children:[L(`th`,{scope:`col`,children:r(`setup.found.col.runtime`)}),L(`th`,{scope:`col`,children:r(`setup.found.col.device`)}),L(`th`,{scope:`col`,children:r(`setup.found.col.version`)}),L(`th`,{scope:`col`,children:r(`setup.found.col.state`)})]})}),L(`tbody`,{children:i.runtimes.map(({name:e,b:t})=>z(`tr`,{children:[L(`th`,{scope:`row`,children:L(UJ,{children:e})}),L(`td`,{children:L(UJ,{children:t.backend})}),L(`td`,{children:L(UJ,{children:t.version??``})}),L(`td`,{className:$J(t)?`is-installed`:void 0,children:r($J(t)?`setup.pc.backend.installed`:`setup.pc.backend.available`)})]},t.recipe))})]})}):L(`p`,{className:`found-muted`,children:r(`setup.found.unknown`)}),L(`h4`,{className:`found-group`,children:r(`setup.found.models`)}),(e.catalog??[]).length?L(`div`,{className:`found-table-wrap`,children:z(`table`,{className:`found-table`,children:[L(`thead`,{className:`visually-hidden`,children:z(`tr`,{children:[L(`th`,{scope:`col`,children:r(`setup.found.col.model`)}),L(`th`,{scope:`col`,children:r(`setup.found.col.job`)}),L(`th`,{scope:`col`,children:r(`setup.found.col.tested`)}),L(`th`,{scope:`col`,children:r(`setup.found.col.size`)}),L(`th`,{scope:`col`,children:r(`setup.found.col.state`)})]})}),L(`tbody`,{children:(e.catalog??[]).map(e=>z(`tr`,{children:[L(`th`,{scope:`row`,title:e.id,children:L(`bdi`,{children:e.name})}),L(`td`,{children:e.roles.map(e=>r(eY[e])).join(` · `)}),z(`td`,{children:[e.support===`verified`&&L(`span`,{className:`mc-chip is-verified`,children:r(`setup.label.verified`)}),e.support===`untested`&&L(`span`,{className:`mc-chip is-untested`,children:r(`setup.label.untested`)})]}),L(`td`,{children:L(UJ,{children:e.full_size_gb??e.size_gb?Sk(e.full_size_gb??e.size_gb):``})}),L(`td`,{className:e.downloaded?`is-installed`:void 0,children:r(e.downloaded?`setup.models.status.onPc`:`setup.found.notDownloaded`)})]},e.id))})]})}):L(`p`,{className:`found-muted`,children:r(`setup.found.unknown`)}),L(`h4`,{className:`found-group`,children:r(`setup.found.hardware`)}),z(`dl`,{className:`found-list`,children:[L(WJ,{label:r(`setup.found.os`),children:i.sys?.os??t?.os?L(UJ,{children:i.sys?.os??t?.os}):f}),z(WJ,{label:r(`setup.found.cpu`),children:[i.cpu||i.sys?.processor?L(UJ,{children:i.cpu?.name??i.sys?.processor}):f,i.cpu?.cores?L(`span`,{className:`found-sub`,children:r(`setup.found.cores`,{cores:String(i.cpu.cores),threads:String(i.cpu.threads??i.cpu.cores)})}):null]}),L(WJ,{label:r(`setup.found.gpu`),children:i.graphics?L(UJ,{children:i.graphics}):L(`span`,{className:`found-muted`,children:r(`setup.found.none`)})}),L(WJ,{label:r(`setup.found.npu`),children:i.npus.length?L(UJ,{children:i.npus.map(GJ).join(`; `)}):L(`span`,{className:`found-muted`,children:r(`setup.found.none`)})})]})]})]})}function rY(){return window.gaiaUpdater}var iY={status:`idle`,version:null,progress:0,releaseNotes:null,error:null,currentVersion:null,pinnedVersion:null,autoUpdate:!1,includePrereleases:!1};function aY(){let[e,t]=(0,B.useState)({...iY}),n=(0,B.useRef)(!1),r=(0,B.useRef)(0),i=(0,B.useCallback)(async()=>{let e=rY();if(!e)return;let i=r.current;try{let r=await e.getStatus();n.current&&r&&t(r)}catch(e){F.system.error(`Reading the update status failed`,e),n.current&&r.current===i&&t(e=>({...e,readFailed:!0}))}},[]);return(0,B.useEffect)(()=>{let e=rY();if(!e)return;n.current=!0;let a=e.onStatusChange(e=>{e&&(r.current+=1,n.current&&t(e))});return i(),()=>{n.current=!1,a()}},[i]),{...e,reload:i}}var oY=`gaia-update-error:`;function sY(e,t){let n=`update.err.${e}`;return fe(n)?We(n,t??{}):null}function cY(e){let t=e instanceof Error?e.message:String(e),n=t.indexOf(oY);if(n<0)return t.replace(/^Error invoking remote method '[^']+': (?:Error: )?/,``);let r;try{r=JSON.parse(t.slice(n+18))}catch{return t.slice(0,n)+t.slice(n+18)}let i=sY(r.code,r.params)??r.message??r.code,a=r.note&&sY(r.note.code,r.note.params);return a?We(`update.err.withNote`,{error:i,note:a}):i}function lY(e,t){let n=cY(e);return typeof n==`object`?t(n.ref,n.params):String(n)}function uY({className:e}){let t=R(),n=aY(),[r,i]=(0,B.useState)(!1),[a,o]=(0,B.useState)(null),s=n.lastWorking;if(!rY()||!s)return null;let c=(r||n.version===s.version)&&n.status===`downloading`,l=r&&n.status===`downloaded`,u=!r&&n.status===`downloaded`&&n.version===s.version,d=new Date(s.at).toLocaleDateString(On(t),{year:`numeric`,month:`short`,day:`numeric`}),f=t(`setup.goBack.title`);return z(`section`,{className:e?`setup-card ${e}`:`setup-card`,"aria-label":f,children:[L(`h3`,{className:`mc-job-title`,children:f}),L(`p`,{children:t(`setup.goBack.lead`,{version:s.version,date:d})}),L(`p`,{className:`setup-hint`,children:t(`setup.goBack.fixes`,{version:s.version})}),c||l?z(`p`,{className:`setup-hint`,role:`status`,children:[L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,c?t(`setup.goBack.downloading`,{version:s.version,pct:Math.max(0,Math.min(100,Math.round(n.progress)))}):t(`setup.goBack.restarting`,{version:s.version})]}):u?z(P.Fragment,{children:[L(`p`,{className:`setup-hint`,children:t(`setup.goBack.ready`,{version:s.version})}),L(`div`,{className:`setup-row`,children:L(`button`,{type:`button`,className:`btn-secondary go-back-action`,onClick:()=>{let e=rY();e&&(o(null),e.restart().catch(e=>{F.system.error(`Restarting into the last working version failed`,e),o(t(`setup.goBack.failed`,{reason:lY(e,t)}))}))},children:t(`setup.goBack.restart`,{version:s.version})})})]}):L(`div`,{className:`setup-row`,children:L(`button`,{type:`button`,className:`btn-secondary go-back-action`,onClick:()=>{let e=rY();e&&(i(!0),o(null),e.revertToLastWorking().catch(e=>{F.system.error(`Going back to the last working version failed`,e),o(t(`setup.goBack.failed`,{reason:lY(e,t)}))}).finally(()=>i(!1)))},disabled:r,children:t(`setup.goBack.action`,{version:s.version})})}),a&&L(`p`,{className:`setup-error`,role:`alert`,children:a}),z(`details`,{className:`dl-details`,children:[L(`summary`,{children:t(`setup.progress.details`)}),L(`p`,{className:`setup-hint`,children:t(`setup.goBack.note`,{version:s.version,current:n.currentVersion??``})})]})]})}function dY({state:e}){return e===`done`?L(Yr,{size:13,"aria-hidden":`true`}):e===`active`?L(Za,{size:13,className:`spin`,"aria-hidden":`true`}):L(e===`failed`?nc:e===`question`?pi:_i,{size:13,"aria-hidden":`true`})}function fY({hardware:e,hardwareError:t,plan:n,serverRun:r,awaitingChoice:i=!1}){let a=R(),[o,s]=(0,B.useState)(!1),c=!!n?.lemonade.reachable,l=r?.state===`failed`||r?.state===`cancelled`,u=a(n?.lemonade.mode===`external`?`setup.found.serverYours`:`setup.found.serverOwn`),d=n?.system?.lemonade_version?a(`setup.checks.serverFound`,{version:n.system.lemonade_version,whose:u}):u,f=e?`done`:t?`failed`:`active`,p=[e?.gpu_name,e?.npu_detected?a(`setup.checks.npu`):null].filter(Boolean).join(` · `),m=t?null:n?.capacity_gb==null?c?wk(n?.system?.physical_memory,e?.ram_gb):null:Sk(n.capacity_gb),h=t?`failed`:m?`done`:l?`failed`:i?`waiting`:`active`,g=[{id:`device`,label:a(`setup.checks.device`),value:t?`${a(`setup.system.unread`)} ${t}`:p||null,state:f},{id:`memory`,label:a(`setup.found.memory`),value:m,state:h},{id:`disk`,label:a(`setup.checks.disk`),value:e?.disk_free_gb==null?null:a(`setup.checks.diskValue`,{size:Ok(a.locale,`${Math.round(e.disk_free_gb)} GB`)}),state:f},{id:`server`,label:a(`setup.checks.server`),value:c?d:i?a(`setup.checks.serverChoose`):null,state:c?`done`:l?`failed`:i?`question`:e?`active`:`waiting`},{id:`models`,label:a(`setup.checks.backends`),value:c&&n?.catalog?a(`setup.checks.backendsValue`,{models:String(n.catalog.length),downloaded:String(n.catalog.filter(e=>e.downloaded).length)}):null,state:c&&n?.catalog?`done`:c?`active`:`waiting`}],_=g.filter(e=>e.state===`done`).length,v=Math.round(_/g.length*100),y=L(`ul`,{className:`setup-rows`,id:`setup-check-rows`,children:g.map(e=>z(`li`,{className:`setup-result is-${e.state}`,children:[L(dY,{state:e.state}),L(`span`,{className:`setup-result-label`,children:e.label}),e.value&&L(`bdi`,{className:`setup-result-value`,children:e.value})]},e.id))});return _===g.length?z(`section`,{className:`setup-card setup-checks-done`,"aria-label":a(`setup.check.title`),children:[L(`p`,{className:`setup-result is-done`,role:`status`,children:z(`button`,{type:`button`,className:`setup-checks-toggle`,"aria-expanded":o,"aria-controls":`setup-check-rows`,onClick:()=>s(e=>!e),children:[L(Yr,{size:13,"aria-hidden":`true`}),L(`span`,{className:`setup-result-label`,children:a(`setup.checks.allPassed`,{n:String(g.length)})}),L(ri,{size:13,className:o?`is-open`:``,"aria-hidden":`true`})]})}),o&&y]}):z(`section`,{className:`setup-card`,"aria-label":a(`setup.check.title`),children:[L(`div`,{className:`setup-bar-head`,children:i?L(`span`,{children:a(`setup.checks.waitingChoice`)}):z(P.Fragment,{children:[L(`span`,{children:a(`setup.checks.count`,{done:String(_),total:String(g.length)})}),z(`bdi`,{dir:`ltr`,children:[v,`%`]})]})}),L(`progress`,{className:`setup-progress`,max:100,value:v,"aria-label":a(`setup.check.title`)}),y]})}function pY({steps:e}){let t=R();return z(`nav`,{className:`setup-rail`,"aria-label":t(`setup.rail.label`),children:[L(`p`,{className:`setup-rail-title`,children:t(`setup.title`)}),L(`ol`,{className:`setup-rail-list`,children:e.map((e,t)=>{let n=e.status===`done`?L(Yr,{size:13,"aria-hidden":`true`}):e.status===`active`?L(Za,{size:13,className:`spin`,"aria-hidden":`true`}):e.status===`failed`?L(di,{size:13,"aria-hidden":`true`}):t+1,r=z(P.Fragment,{children:[L(`span`,{className:`setup-rail-num`,children:n}),L(`span`,{children:e.label})]}),i=`setup-rail-step is-${e.status}${e.shown?` is-shown`:``}`,a=e.shown?`step`:void 0;return L(`li`,{children:e.onOpen?L(`button`,{type:`button`,className:i,onClick:e.onOpen,children:r}):L(`span`,{className:i,"aria-current":a,children:r})},e.id)})})]})}var mY={memory:`setup.test.why.memory`,broken:`setup.test.why.broken`,stuck:`setup.test.why.stuck`,missing:`setup.test.why.missing`,agent:`setup.test.why.agent`,answer:`setup.test.why.answer`,window:`setup.test.why.window`};function hY(e,t){return t(`setup.test.job.${e}`)}function gY({state:e}){return e===`passed`?L(Yr,{size:13,"aria-hidden":`true`}):e===`running`?L(Za,{size:13,className:`spin`,"aria-hidden":`true`}):L(e===`failed`?nc:e===`skipped`?mo:_i,{size:13,"aria-hidden":`true`})}function _Y(e,t){return e.state===`running`?t(`setup.test.running`):e.state===`failed`?t(`setup.test.failed`):e.state===`skipped`?t(`setup.test.skipped`):e.seconds==null?t(`setup.test.passed`):t(`setup.test.passedIn`,{seconds:String(Math.round(e.seconds))})}function vY({run:e,expected:t,names:n,catalog:r,onRetry:i,onChooseAnother:a,onCancel:o,onDownloadAgain:s,busy:c}){let l=R(),u=e.tests??[],d=new Set(u.map(e=>e.job)),f=t.filter(e=>!d.has(e)),p=u.filter(e=>e.state!==`running`).length,m=Math.max(u.length+f.length,1),h=Math.round(p/m*100),g=u.filter(e=>e.state===`failed`).filter(e=>!r.find(t=>t.id===e.subject)?.roles.some(e=>[`speech`,`voice`,`image_creation`].includes(e))),_=e.state===`failed`||e.state===`cancelled`,v=s?[...new Set(g.filter(e=>e.kind===`broken`&&e.subject).map(e=>e.subject))]:[],[y,b]=(0,B.useState)(null),x=r.find(e=>e.id===y)?.full_size_gb,S=_&&e.components?.agent===`failed`,C=g.some(e=>e.subject&&e.kind!==`missing`),w=e.state===`verifying`&&!u.some(e=>e.state===`running`)?f[0]:void 0;return z(P.Fragment,{children:[z(`section`,{className:`setup-card`,"aria-label":l(`setup.test.title`),children:[z(`div`,{className:`setup-bar-head`,children:[L(`span`,{children:l(`setup.test.count`,{done:String(p),total:String(m)})}),z(`bdi`,{dir:`ltr`,children:[h,`%`]})]}),L(`progress`,{className:`setup-progress`,max:100,value:h,"aria-label":l(`setup.test.title`)}),z(`ul`,{className:`setup-rows`,children:[u.map(e=>z(`li`,{className:`setup-result is-${e.state}`,children:[L(gY,{state:e.state}),z(`span`,{className:`setup-result-label`,children:[hY(e.job,l),e.subject&&z(`bdi`,{className:`setup-result-model`,children:[` `,n[e.subject]??Uc(e.subject)]})]}),L(`span`,{className:`setup-result-value`,children:_Y(e,l)}),e.error&&z(`div`,{className:`setup-result-error`,children:[L(`p`,{children:l(e.kind===`broken`&&!s?`setup.test.why.brokenYours`:mY[e.kind??``]??`setup.test.why.other`)}),z(`details`,{className:`dl-details`,children:[L(`summary`,{children:l(`setup.progress.details`)}),L(`pre`,{dir:`ltr`,children:e.error})]})]})]},`${e.job}:${e.subject??``}`)),f.map(e=>e===`agent`&&S?z(`li`,{className:`setup-result is-failed`,children:[L(gY,{state:`failed`}),L(`span`,{className:`setup-result-label`,children:hY(e,l)}),L(`span`,{className:`setup-result-value`,children:l(`setup.test.failed`)}),L(`div`,{className:`setup-result-error`,children:L(`p`,{children:l(`setup.test.why.hub`)})})]},e):e===w?z(`li`,{className:`setup-result is-running`,children:[L(gY,{state:`running`}),L(`span`,{className:`setup-result-label`,children:hY(e,l)}),L(`span`,{className:`setup-result-value`,children:l(`setup.test.starting`)})]},e):z(`li`,{className:`setup-result is-waiting`,children:[L(gY,{state:`waiting`}),L(`span`,{className:`setup-result-label`,children:hY(e,l)}),L(`span`,{className:`setup-result-value`,children:l(`setup.test.waiting`)})]},e))]})]}),e.state===`verifying`&&o&&L(zq,{children:L(`button`,{type:`button`,className:`btn-secondary`,onClick:o,disabled:c,children:l(`setup.progress.cancel`)})}),_&&z(`div`,{className:`setup-failure`,role:`alert`,children:[L(`p`,{children:e.state===`cancelled`?l(`setup.test.cancelled`):g.some(e=>e.kind===`memory`)?l(`setup.test.failedMemory`):l(`setup.test.failedHelp`)}),z(zq,{children:[C&&a&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:a,disabled:c,children:l(`setup.test.chooseAnother`)}),L(`button`,{type:`button`,className:v.length?`btn-secondary`:`btn-primary`,onClick:i,disabled:c,children:l(`setup.test.tryAgain`)}),v.map(e=>L(`button`,{type:`button`,className:`btn-primary setup-wrap-btn`,onClick:()=>b(e),disabled:c,children:v.length===1?l(`setup.test.downloadItAgain`):l(`setup.test.downloadAgain`,{name:n[e]??e})},e))]})]}),y&&L(Bq,{title:l(`setup.redownload.title`,{name:n[y]??y}),confirmLabel:l(`setup.redownload.confirm`),cancelLabel:l(`setup.redownload.keep`),onConfirm:()=>{let e=y;b(null),s?.(e)},onCancel:()=>b(null),children:L(`p`,{children:l(`setup.redownload.body`,{name:n[y]??y,size:x==null?``:Sk(x)})})})]})}var yY=`https://app.fireworks.ai/settings/users/api-keys`,bY=`https://amd-gaia.ai/docs/guides/llm-gateway`,xY=[{id:`local`,title:`setup.where.local`,note:`setup.where.localNote`},{id:`fireworks`,title:`Fireworks AI`,note:`setup.where.fireworksNote`},{id:`amd`,title:`AMD LLM Gateway`,note:`setup.where.amdNote`}];function SY(e,t){return fe(e.title)?t(e.title):e.title}var CY=1e3,wY=`gaia-setup-choice`;function TY(){try{let e=localStorage.getItem(wY);return e===`local`||e===`fireworks`||e===`amd`?e:null}catch(e){return console.warn(`[SetupScreen] could not read the saved provider choice`,e),null}}function EY(e){try{localStorage.setItem(wY,e)}catch(e){console.warn(`[SetupScreen] could not save the provider choice; a reload will ask again`,e)}}var DY=[`ok`,`needs_key`,`too_old`];function OY({onChosen:e,onNothingToOffer:t,onFound:n,canInstallOwn:r=!0}){let i=R(),[a,o]=(0,B.useState)(null),[s,c]=(0,B.useState)(null),[l,u]=(0,B.useState)([]),[d,f]=(0,B.useState)(!1),[p,m]=(0,B.useState)(``),[h,g]=(0,B.useState)(!1),[_,v]=(0,B.useState)(!1),[y,b]=(0,B.useState)(null),[x,S]=(0,B.useState)(null),[C,w]=(0,B.useState)(null),[T,E]=(0,B.useState)(`gaia`),D=(0,B.useRef)(!0),O=(0,B.useCallback)(async()=>{c(null);try{let e=await ie();if(!e.offer){t?.();return}f(!0);let{found:r,unchecked:i=[]}=await er();if(!D.current)return;u(r?[]:i),r&&DY.includes(r.status)?(o({target:e,found:r}),n?.(r),g(r.status===`needs_key`),r.status===`too_old`&&t?.()):i.length===0&&t?.()}catch(e){D.current&&c(e instanceof Error?e.message:String(e))}finally{D.current&&f(!1)}},[t,n]);(0,B.useEffect)(()=>(D.current=!0,O(),()=>{D.current=!1}),[O]);let ee=(0,B.useCallback)(async t=>{if(a){b(t),S(null);try{await be(t===`external`?{mode:t,base_url:a.found.url,api_key:p.trim()||void 0}:{mode:t}),m(``),w(t),e(t)}catch(e){LK(e)&&g(!0),S(e instanceof Error?e.message:String(e))}finally{b(null)}}},[a,p,e]);if(s||l.length>0)return z(P.Fragment,{children:[L(`p`,{className:`setup-hint`,children:s?i(`setup.offer.checkFailed`):i(`setup.offer.noAnswer`,{url:l.join(`, `)})}),s&&z(`details`,{className:`dl-details`,children:[L(`summary`,{children:i(`setup.progress.details`)}),L(`pre`,{dir:`ltr`,children:s})]}),z(zq,{children:[z(`button`,{type:`button`,className:`btn-secondary`,disabled:d,onClick:()=>void O(),children:[d&&L(Za,{size:13,className:`spin`}),` `,i(`setup.offer.checkAgain`)]}),t&&r&&L(`button`,{type:`button`,className:`btn-primary`,disabled:d,onClick:t,children:i(`setup.offer.useOwn`)})]})]});if(!a)return d?z(`p`,{className:`setup-hint`,role:`status`,children:[L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,i(`setup.offer.looking`)]}):null;let{target:te,found:ne}=a;return C?L(`p`,{className:`setup-hint`,role:`status`,children:C===`external`?i(`setup.offer.usingYours`,{url:ne.url}):i(`setup.offer.usingOwn`)}):ne.status===`too_old`?z(`p`,{className:`setup-hint`,role:`status`,children:[i(`setup.offer.tooOld`),` `,z(`bdi`,{dir:`ltr`,className:`setup-choice-note`,children:[`Lemonade `,ne.version??``,` · `,ne.url]})]}):z(`form`,{id:`setup-lemonade-form`,className:`setup-lemonade`,"aria-label":i(`setup.offer.label`),onSubmit:e=>{e.preventDefault(),ee(T)},children:[z(`fieldset`,{className:`setup-choices`,disabled:!!y,children:[L(`legend`,{className:`setup-choice-title`,children:i(`setup.offer.title`)}),[{mode:`gaia`,title:`setup.offer.useOwn`,note:`setup.offer.ownNote`},{mode:`external`,title:`setup.offer.useMine`,note:`setup.offer.mineNote`}].map(e=>z(`label`,{className:`setup-choice${T===e.mode?` is-active`:``}`,children:[L(`input`,{type:`radio`,name:`setup-server`,value:e.mode,checked:T===e.mode,onChange:()=>{E(e.mode),S(null)}}),z(`span`,{children:[z(`span`,{className:`setup-choice-title`,children:[i(e.title),e.mode===`gaia`&&L(`span`,{className:`setup-choice-tag`,children:i(`setup.offer.recommended`)})]}),L(`span`,{className:`setup-choice-note`,children:i(e.note)})]})]},e.mode))]}),z(`button`,{type:`button`,className:`setup-log-toggle setup-offer-more`,onClick:()=>v(e=>!e),"aria-expanded":_,"aria-controls":`setup-offer-detail`,children:[L(ri,{size:13,className:_?`is-open`:``,"aria-hidden":`true`}),` `,i(`setup.offer.whatGaiaDoes`)]}),_&&z(`div`,{id:`setup-offer-detail`,children:[L(`p`,{className:`setup-choice-note`,children:z(`bdi`,{dir:`ltr`,children:[`Lemonade`,ne.version?` ${ne.version}`:``,` · `,ne.url]})}),L(`p`,{className:`setup-choice-note`,children:i(`setup.offer.whatGaiaDoesText`)})]}),T===`external`&&h&&L(`input`,{className:`settings-input`,type:`password`,autoComplete:`off`,value:p,onChange:e=>m(e.target.value),placeholder:i(`setup.offer.keyPlaceholder`),"aria-label":i(`setup.offer.keyLabel`)}),x&&(h&&T===`external`?L(`p`,{className:`setup-error`,role:`alert`,children:i(`setup.offer.keyRejected`)}):L(AY,{text:x})),L(zq,{children:z(`button`,{type:`submit`,form:`setup-lemonade-form`,className:`btn-primary`,disabled:!!y||T===`external`&&h&&!p.trim(),children:[y&&L(Za,{size:13,className:`spin`}),` `,i(`setup.continue`)]})})]})}function kY({problem:e,onRetry:t,onUseGaia:n}){let r=R(),i=e.kind===`server_too_old`&&e.use_gaia;return z(P.Fragment,{children:[e.start&&z(`details`,{className:`dl-details`,children:[L(`summary`,{children:r(`setup.server.howToStart`)}),L(`pre`,{dir:`ltr`,children:e.start})]}),z(zq,{children:[L(`button`,{type:`button`,className:i?`btn-secondary`:`btn-primary`,onClick:t,children:r(`setup.tryAgain`)}),e.use_gaia&&L(`button`,{type:`button`,className:i?`btn-primary`:`btn-secondary`,onClick:n,children:r(`setup.server.useGaia`)})]}),e.use_gaia&&L(`p`,{className:`setup-hint`,children:r(`setup.server.useGaiaNote`)}),e.use_gaia&&e.env_url&&L(`p`,{className:`setup-hint`,children:r(`setup.server.envIgnoredNote`,{url:e.env_url})})]})}function AY({text:e}){let t=R();return z(`div`,{className:`setup-error`,role:`alert`,children:[L(`p`,{children:t(`setup.failedLead`)}),z(`details`,{className:`dl-details`,children:[L(`summary`,{children:t(`setup.progress.details`)}),L(`pre`,{dir:`ltr`,children:e})]})]})}function jY({run:e}){let t=R();return e.problem?z(`div`,{className:`setup-error`,role:`alert`,children:[L(`p`,{children:t(e.problem.kind===`server_too_old`?`setup.server.tooOld`:`setup.server.unreachable`)}),z(`details`,{className:`dl-details`,children:[L(`summary`,{children:t(`setup.progress.details`)}),L(`pre`,{dir:`ltr`,children:e.problem.message})]})]}):z(`div`,{className:`setup-error`,role:`alert`,children:[L(`p`,{children:t(e.components?.server===`failed`?`setup.server.ownFailed`:`setup.stopped`)}),e.error&&z(`details`,{className:`dl-details`,children:[L(`summary`,{children:t(`setup.progress.details`)}),L(`pre`,{dir:`ltr`,children:e.error})]})]})}var MY=[`check`,`plan`,`key`,`models`,`gpu`,`download`,`test`,`ready`],NY=`gaia.setup.agentPick`,PY=`gaia.setup.heldRun`;function FY(e){try{let t=sessionStorage.getItem(e);return t?JSON.parse(t):null}catch(t){return console.warn(`[SetupScreen] could not read ${e}; the agent pick starts fresh`,t),null}}function IY(e,t){try{t==null?sessionStorage.removeItem(e):sessionStorage.setItem(e,JSON.stringify(t))}catch(t){console.warn(`[SetupScreen] could not save ${e}; a reload will lose the agent pick`,t)}}function LY(e){return e instanceof Error?e.message:String(e)}function RY({onReady:e,onClose:t}){let n=R(),r=zc(e=>e.refresh),i=zc(e=>e.select),[a,o]=(0,B.useState)(`local`),[s,c]=(0,B.useState)(`check`),[l,u]=(0,B.useState)(!1),[d,f]=(0,B.useState)(`models`),[p,m]=(0,B.useState)(null),[h,g]=(0,B.useState)(null),[_,v]=(0,B.useState)(()=>new Set([`check`])),y=(0,B.useRef)(`check`),[b,x]=(0,B.useState)(null),[C,w]=(0,B.useState)(null),[T,E]=(0,B.useState)(null),[D,O]=(0,B.useState)(null),[ee,te]=(0,B.useState)(null),[ne,re]=(0,B.useState)(``),[k,ae]=(0,B.useState)({busy:!1,error:null,done:!1}),[A,se]=(0,B.useState)(null),[ce,le]=(0,B.useState)(null),[de,fe]=(0,B.useState)(null),[j,he]=(0,B.useState)(null),[M,ge]=(0,B.useState)(null),[_e,ve]=(0,B.useState)(null),[ye,be]=(0,B.useState)(!1),[xe,Se]=(0,B.useState)(null),[Ce,we]=(0,B.useState)(!1),[Te,Ee]=(0,B.useState)(!1),[De,ke]=(0,B.useState)(null),[Ae,je]=(0,B.useState)(!1),[Ne,Pe]=(0,B.useState)(null),[Fe,Ie]=(0,B.useState)(null),[Le,Re]=(0,B.useState)(null),[ze,Be]=(0,B.useState)(!1),[Ve,He]=(0,B.useState)([]),[Ue,We]=(0,B.useState)([]),[Ge,qe]=(0,B.useState)([]),[Je,Ye]=(0,B.useState)(!1),[Ze,Qe]=(0,B.useState)(!1),$e=(0,B.useRef)({gaiaLemonade:!1,options:{}}),et=(0,B.useRef)(null),tt=(0,B.useRef)(!1),nt=(0,B.useRef)(!1),[rt,at]=(0,B.useState)(!1),[ot,st]=(0,B.useState)(!1),ct=(0,B.useCallback)(()=>st(!0),[]),[lt,ut]=(0,B.useState)(null),[dt,ft]=(0,B.useState)(null),pt=(0,B.useRef)(!0);(0,B.useEffect)(()=>(pt.current=!0,()=>{pt.current=!1}),[]);let{network:mt,providers:ht,recheck:gt}=rJ(),_t=e=>ht.find(t=>t.id===e),vt=_t(a),N=vt?.key_source===`environment`&&vt.key_hint?vt:void 0,yt=e=>!!_t(e)?.blocked,bt=mt?.reachable!==!1||a===`amd`,F=vt?.key_source===`stored`||vt?.key_source===`lemonade`,xt=yt(`fireworks`)&&yt(`amd`),St=e=>yt(e)||e===`amd`&&mt?.reachable===!1,Ct=e=>yt(e)?n(`settings.privacy.localOnlyBlocked`):n(`setup.key.gatewayOff`),wt=a!==`local`,Tt=T?.server_only?T:null,Et=T&&!T.server_only?T:null,Dt=T?.state===`running`||T?.state===`verifying`,Ot=Et?.state===`ready`,At=_J(T),jt=!(Et?.models??[]).some(e=>e.state===`downloading`||e.state===`queued`)&&((Et?.tests?.length??0)>0||Et?.state===`verifying`),Mt=(0,B.useCallback)(()=>{w(null),ue().then(x).catch(e=>w(LY(e)))},[]),Nt=(0,B.useRef)(0),Pt=(0,B.useCallback)(async()=>{let e=++Nt.current;le(null);try{let t=await En(!1);return e===Nt.current?(se(t),t):null}catch(t){return e===Nt.current&&le(LY(t)),null}},[]),Ft=(0,B.useCallback)(async()=>{try{let e=await Xe();pt.current&&ve(e??null)}catch(e){console.warn(`[SetupScreen] GPU memory could not be read; the step stays hidden`,e)}},[]),It=t!=null;(0,B.useEffect)(()=>{ie().then(e=>Ye(e.source===`config`)).catch(e=>console.warn(`[SetupScreen] could not read which Lemonade GAIA uses`,e)),Mt(),Pt(),oe().then(e=>{e.state===`idle`&&!e.models?.length||It&&e.state!==`running`&&e.state!==`verifying`||(E(e),e.server_only||c(`download`),e.skip_chat_model&&o(TY()===`amd`?`amd`:`fireworks`))}).catch(e=>te(LY(e))).finally(()=>at(!0))},[Mt,Pt,It]),(0,B.useEffect)(()=>{A?.catalog&&A.lemonade.reachable&&(fe(e=>e??oq(A)),Ft(),!T&&A.catalog.some(e=>e.partial&&e.selected)&&je(!0))},[A,Ft,T]);let Lt=(0,B.useCallback)(()=>{et.current&&clearInterval(et.current),et.current=null},[]),Rt=(T?.models??[]).filter(e=>e.state===`failed`&&e.error_kind===`disk_full`).length;(0,B.useEffect)(()=>{Rt>0&&Pt()},[Rt,Pt]);let zt=(0,B.useCallback)(async()=>{try{let e=await oe();if(O(null),e.state===`idle`&&!e.models?.length){E(null),c(`plan`),Qe(!0),Pt();return}E(e)}catch(e){O(LY(e))}},[Pt,n]);(0,B.useEffect)(()=>(!At&&!D||(et.current=setInterval(()=>{zt()},CY)),Lt),[At,D,zt,Lt]),(0,B.useEffect)(()=>{Tt&&Tt.state===`ready`&&(Mt(),Pt())},[Tt,Tt?.state,Mt,Pt]),(0,B.useEffect)(()=>{Ot&&(Mt(),Pt().then(e=>{e&&ge(e)}),Ft())},[Ot,Mt,Pt,Ft]);let I=(0,B.useRef)(!1),Bt=(0,B.useCallback)(async(e=!1,t={})=>{if(I.current)return!1;I.current=!0,te(null),ke(null),je(!1),Qe(!1);try{EY(a),$e.current={gaiaLemonade:e,options:t};let n=await dn(wt,e,t);E(n),g(null);let r=t.extraModels??[];return r.length&&qe(e=>e.filter(e=>!r.includes(e))),t.serverOnly||c(`download`),e&&Ye(!1),!0}catch(e){let t=kt(e);if(t)return Se({kind:`server`,detail:t,then:`run`}),!1;if(e instanceof Vn&&e.httpStatus===409){let e=await oe().catch(()=>null);if(e&&(e.state===`running`||e.state===`verifying`))return E(e),g(null),e.server_only||c(`download`),!0}return te(LY(e)),!1}finally{I.current=!1}},[a,wt]);(0,B.useEffect)(()=>{s===`check`&&rt&&ot&&A&&!A.lemonade.reachable&&!T&&!tt.current&&(tt.current=!0,Bt(!1,{serverOnly:!0}))},[s,rt,ot,A,T,Bt]);let Vt=!!(de&&A?.catalog&&A.lemonade.reachable&&(b||C)),Ht=(0,B.useCallback)(()=>{let{gaiaLemonade:e,options:t}=$e.current;Bt(e,t)},[Bt]),Ut=(0,B.useCallback)((e,t=A)=>{he(t);let n=t&&de&&!wt?gq(t,de):[];return Bt(!1,{acknowledgeLowDisk:e,keepTrying:ye,extraModels:n})},[A,de,wt,ye,Bt]),[Wt,Kt]=(0,B.useState)(!1),[qt,Jt]=(0,B.useState)(()=>FY(NY)),Yt=(0,B.useCallback)(e=>{Jt(e),IY(NY,e)},[]),[Xt,Zt]=(0,B.useState)(()=>FY(PY)),Qt=(0,B.useCallback)(e=>{Zt(e),IY(PY,e)},[]),[en,tn]=(0,B.useState)(null),[nn,rn]=(0,B.useState)(!1),an=(0,B.useCallback)(async(e,t,n)=>{if(tn(null),t){rn(!0);try{await pe({flagship_agent:t})}catch(e){tn(LY(e));return}finally{rn(!1)}}Yt(null),Qt(null),await Ut(e.acknowledgeLowDisk,n)},[Ut,Yt,Qt]),on=(0,B.useRef)(qt);on.current=qt;let sn=(0,B.useRef)(Xt);sn.current=Xt;let cn=(0,B.useRef)(an);cn.current=an;let un=AJ(()=>{let e=on.current;e&&Yt({...e,download:!1}),e&&sn.current&&cn.current(sn.current,e.id)}),fn=un.start,pn=un.follow,mn=(0,B.useCallback)(async(e,t)=>{let n=on.current;if(Qt(e),g(null),c(`download`),!n||!n.download){await an(e,n?.id??null,t);return}tn(null);let r;try{r=await $t()}catch(e){tn(LY(e));return}r.programs.find(e=>e.id===n.id)?.installed?await an(e,n.id,t):r.download.state===`downloading`?pn(r.download):fn()},[an,Qt,pn,fn]),hn=(0,B.useCallback)(()=>{Qt(null),tn(null),g(null),c(`models`)},[Qt]),gn=(0,B.useCallback)(()=>{Xt&&an(Xt,null)},[Xt,an]),_n=(0,B.useRef)(!1);(0,B.useEffect)(()=>{_n.current||(_n.current=!0,$t().then(e=>{let t=e.download.state===`downloading`;if(pn(e.download),!sn.current)return;if(t){c(`download`);return}Qt(null);let n=on.current;n&&e.programs.find(e=>e.id===n.id)?.installed&&Yt({...n,download:!1})}).catch(e=>console.warn(`[SetupScreen] could not read the agent programs; the Agent card says so on Customize`,e)))},[pn,Qt,Yt]);let vn=(0,B.useRef)(!1),yn=(0,B.useCallback)(async(e,t=Ce)=>{if(!A||!de||vn.current)return;ke(null),Kt(e);let r=GK(A),i=wt?[]:mq(r,de).filter(e=>!e.downloaded||e.id===de.defaultChat),a=i.find(YK);if(a){let e=a.id===de.defaultChat?`setup.models.cantRun.chat`:`setup.models.cantRun.other`;ke(n(e,{name:a.name,why:wq(a,n)}))}else if(!wt&&!t&&i.length>0&&i.every(e=>e.need_gb!=null))Se({kind:`no_fit`,models:i});else{Ee(!0),vn.current=!0;try{let n=A;if(!wt&&de.defaultChat&&de.defaultChat!==n.chat_model.id)try{n=await me(de.defaultChat,t,!1)}catch(e){let t=kt(e);if(t){Se({kind:`server`,detail:t,then:`chat`});return}throw e}if(!wt){await VJ();let e=nq(r,de);e!==(n.vision_model??null)&&(n=await Me(e,!1));for(let e of hq(n,de))n=await Rn(e.id,e.skipped,!1)}se(n),on.current?await mn({acknowledgeLowDisk:e},n):await Ut(e,n)}catch(e){ke(LY(e))}finally{vn.current=!1,Ee(!1)}}},[A,de,wt,Ce,Ut,mn,n]),bn=(0,B.useCallback)(e=>{ke(null),s===`download`?g(e===y.current?null:e):(g(null),c(e===`test`||e===`ready`?`download`:e))},[s]),xn=(0,B.useCallback)(()=>{h??o(`local`),bn(`plan`)},[bn,h]),Sn=(0,B.useCallback)(()=>{Dt&&h!=null||(o(`local`),u(!0),bn(`models`))},[bn,Dt,h]),[Cn,wn]=(0,B.useState)(`local`),Tn=zc(e=>e.active?.remote&&e.active.provider!==`local`?e.active.provider:null),Dn=zc(e=>e.active?.remote?e.active.model:null),On=(0,B.useCallback)(e=>{Dt&&h!=null||(u(!1),o(e),wn(`cloud`),Ie(e===Tn?Dn:null),bn(`key`))},[bn,Dt,h,Tn,Dn]),kn=(0,B.useCallback)(()=>On(TY()===`amd`?`amd`:`fireworks`),[On]),An=(0,B.useCallback)(()=>{Tn?On(Tn):bn(`plan`)},[Tn,On,bn]),jn=!!_e?.applies,Mn=(0,B.useCallback)(()=>{bn((h??s)===`gpu`?d:`plan`)},[d,bn,h,s]),Nn=(0,B.useCallback)(e=>{f(e),bn(`gpu`)},[bn]),Pn=(0,B.useRef)({prev:null,next:null});(0,B.useEffect)(()=>{let e=e=>{if(!e.altKey||xe||(e.target instanceof Element?e.target:null)?.closest(`input, textarea, select, [contenteditable="true"]`))return;let t=e.key===`ArrowLeft`?Pn.current.prev:e.key===`ArrowRight`?Pn.current.next:null;t&&(e.preventDefault(),bn(t))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[bn,xe]);let Fn=(0,B.useCallback)(async()=>{try{await S(),await zt()}catch(e){ke(LY(e))}},[zt]),In=(0,B.useCallback)(async(e,t)=>{ke(null),Ee(!0);try{t===`verify`&&await Oe(e),t===`disk_full`&&Pt();try{E(await Ke(e,{keepTrying:ye}))}catch(t){let n=kt(t);if(!n)throw t;Se({kind:`server`,detail:n,then:`retry`,id:e})}}catch(e){ke(LY(e))}finally{Ee(!1)}},[ye,Pt]),Ln=(0,B.useCallback)(async e=>{ke(null),Ee(!0);try{A?.catalog?.find(t=>t.id===e)?.planned&&se(await Rn(e,!0,!1)),E(t=>t&&{...t,models:t.models?.map(t=>t.id===e?{...t,state:`skipped`}:t)});let{options:t}=$e.current;$e.current.options={...t,extraModels:t.extraModels?.filter(t=>t!==e)},fe(t=>t&&t.ticked.has(e)?cq(t,GK(A),e,!1):t)}catch(e){ke(LY(e))}finally{Ee(!1)}},[A]),zn=(0,B.useCallback)(async()=>{await Fn(),Ht()},[Fn,Ht]),Bn=(0,B.useCallback)(async()=>{if(!Dt){ae({busy:!0,error:null,done:!1});try{await ln(a,{api_key:!Je&&ne||void 0},e=>ae({busy:!0,error:null,done:!1,waiting:e}),()=>!pt.current);let{models:e}=await Gt(a),t=Fe??Le,r=t?e.find(e=>e.id===t):e.find(e=>e.rank===1)??e[0];if(!r)throw Error(t?n(`setup.key.modelNotOffered`,{model:Xc(t)}):n(`setup.key.noModels`));await i(r.id),Pe(r.id),re(``),ae({busy:!1,error:null,done:!0}),Ut(!1)}catch(e){ae({busy:!1,error:LY(e),done:!1})}}},[a,ne,Fe,Le,i,Je,Ut,n,Dt]),Hn=(0,B.useCallback)(e=>{EY(e),o(e),Ie(e===Tn?Dn:null),Re(null),ae({busy:!1,error:null,done:!1})},[Tn,Dn]);(0,B.useEffect)(()=>{if(!Ot||Ue.length===0||nt.current)return;let e=Ue;nt.current=!0,Bt(!1,{keepTrying:ye,extraModels:e}).then(t=>{nt.current=!1,We(t=>t.filter(t=>!e.includes(t))),t||qe(t=>[...t,...e.filter(e=>!t.includes(e))])})},[Ot,Ue,ye,Bt]);let Un=Ot&&Ue.length===0,Wn=wt?Ne:Et?.chat_model??(A&&!A.decided_after_server?A.chat_model.id:null),Gn=(0,B.useCallback)(async t=>{ke(null);try{!wt&&Wn&&await i(Wn),await r()}catch(e){ke(LY(e));return}e(t)},[Wn,wt,e,r,i]);(0,B.useEffect)(()=>{Un&&it().then(e=>He(e.cards)).catch(e=>console.warn(`[SetupScreen] no first tasks to offer`,e))},[Un]);let Kn=(0,B.useMemo)(()=>{let e={};for(let t of A?.catalog??[])e[t.id]=t.name;return e},[A]),qn=T?.state===`failed`||T?.state===`cancelled`,Jn=T?.state===`failed`||!!ee||!!ce||!!C||!!D||!!De,Yn=It?Ve:Ve.filter(e=>e.skill!==`check-in`),Xn=Et&&(Et.state===`failed`||Et.state===`cancelled`)&&(Et.models??[]).length>0&&(Et.models??[]).every(e=>e.state===`ready`||e.state===`skipped`||e.state===`verifying`||e.state===`unchecked`)&&!At,Zn=!!Et&&qn&&!Et.problem&&Object.values(Et.components??{}).includes(`failed`),Qn=GK(A),$n=de?dq(Qn,de):[],er=A&&de?pq(A,de):null,tr=de?Qn.filter(e=>de.ticked.has(e.id)&&e.downloaded).length:0,nr=Qn.some(e=>e.downloaded),rr=Vt?tr===0?nr?`setup.check.ledeOthersOnPc`:`setup.check.ledeDone`:$n.length===0?`setup.check.ledeAllOnPc`:`setup.check.ledeSomeOnPc`:`setup.check.lede`,ir=Qn.find(e=>e.id===de?.defaultChat),ar=!!b&&!b.compatible&&b.blockers.length>0,or=Un?`ready`:s===`download`&&jt?`test`:s;y.current=or;let sr=h??or;(0,B.useEffect)(()=>{v(e=>e.has(sr)?e:new Set(e).add(sr))},[sr]);let cr=(0,B.useRef)(!0);(0,B.useEffect)(()=>{if(cr.current){cr.current=!1;return}let e=document.querySelector(`.setup-scroll`);e&&(e.scrollTop=0),document.getElementById(`setup-title`)?.focus({preventScroll:!0})},[sr]);let lr=[{id:`check`,label:n(`setup.check.title`),key:`setup.check.title`},{id:`plan`,label:n(`setup.plan.step`),key:`setup.plan.step`},{id:`download`,label:n(`setup.download.step`),key:`setup.download.step`},{id:`test`,label:n(`setup.test.step`),key:`setup.test.step`},{id:`ready`,label:n(`setup.ready.step`),key:`setup.ready.step`}],ur=e=>e===`models`||e===`key`?`plan`:e===`gpu`?d===`check`?`check`:`plan`:e,dr=wt?`key`:l?`models`:`plan`,fr=lr.findIndex(e=>e.id===ur(or)),pr=e=>e===`download`||e===`test`||e===`ready`,mr=[];if(b){let e=[A?.system?.physical_memory?`${wk(A.system.physical_memory,null)} installed`:null,b.ram_gb==null?null:`${b.ram_gb} GB the OS can use`].filter(Boolean).join(`, `),t=b.disk_free_gb==null?null:`${Math.round(b.disk_free_gb)} GB free on disk`;mr.push(`This PC: ${[b.gpu_name,b.npu_detected?`NPU`:null].filter(Boolean).join(`, `)||`no GPU reported`}`+[e,t].filter(Boolean).map(e=>`; ${e}`).join(``))}else C&&mr.push(`Couldn't read this PC: ${C}`);lt&&(mr.push(`Found your Lemonade${lt.version?` ${lt.version}`:``} at ${lt.url}`),mr.push(dt===`external`?`You chose your own Lemonade`:dt===`gaia`?`You chose GAIA's own Lemonade`:`Waiting for you to choose which Lemonade GAIA uses`)),A&&(!lt||dt)?mr.push(A.lemonade.reachable?`Model server answering at ${A.lemonade.url??`its address`}`:`No model server answering yet`):ce&&mr.push(`Couldn't read the model list: ${ce}`);let hr=(e,t)=>t<=fr||_.has(e)&&!pr(e),gr=lr.map((e,t)=>({id:e.id,label:e.label,status:t<fr?`done`:t>fr?`pending`:or===`ready`?`done`:qn&&(or===`download`||or===`test`||or===`check`)?`failed`:Dt&&(or===`download`||or===`test`)?`active`:`current`,shown:e.id===ur(sr),onOpen:e.id!==ur(sr)&&hr(e.id,t)?()=>bn(e.id===`plan`?dr:e.id):void 0})),_r=lr.findIndex(e=>e.id===ur(sr)),vr=sr===`gpu`&&d===`check`?.5:MY.indexOf(sr),yr=(0,B.useRef)(vr),br=(0,B.useRef)(`forward`);yr.current!==vr&&(br.current=vr>yr.current?`forward`:`back`,yr.current=vr);let xr=sr===`gpu`?d:sr===`models`||sr===`key`?`plan`:_r>0?lr[_r-1].id===`plan`?dr:lr[_r-1].id:null,Sr=(sr!==`gpu`&&_r>=0&&_r<lr.length-1&&hr(lr[_r+1].id,_r+1)?lr[_r+1].id:null)??(h==null?sr===`check`&&Vt?`plan`:sr===`gpu`?d:null:null);Pn.current={prev:xr,next:Sr};let Cr=sr===`gpu`||sr===`models`||sr===`key`,wr=h!=null&&Dt,Tr=[`server`];wt||Tr.push(`chat`),!wt&&de&&QK(Qn,de)&&Tr.push(`vision`),de&&Qn.some(e=>qK(e)&&de.ticked.has(e.id))&&Tr.push(`embedding`);for(let e of Qn)de&&XK(e)&&de.ticked.has(e.id)&&!e.downloaded&&Tr.push(e.roles[0]);Tr.push(`agent`);let Er=un.job,Dr=Er?.state===`failed`,Or=Xt?z(P.Fragment,{children:[Er&&Er.state!==`idle`&&Er.state!==`done`&&z(`section`,{className:`setup-agent-download`,"aria-labelledby":`setup-agent-download-title`,children:[L(`h3`,{className:`mc-job-title`,id:`setup-agent-download-title`,children:n(`setup.agent.title`)}),L(MJ,{job:Er,name:qt?.id??`gaiacpp`,onRetry:()=>void fn(),failedNote:n(`setup.agent.carryOnNote`,{name:qt?.current??`gaiapy`}),interrupted:un.interrupted})]}),en&&L(`p`,{className:`setup-error`,role:`alert`,children:n(`setup.agent.saveFailed`,{error:en})}),(nn||!Er&&!en)&&z(`p`,{className:`setup-hint`,role:`status`,children:[L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,n(`setup.download.starting`)]}),A&&L(`section`,{className:`setup-card`,"aria-label":n(`setup.contents.title`),children:L(cJ,{plan:A,models:$n})}),z(zq,{children:[(Dr||en)&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:gn,disabled:nn,children:n(`setup.agent.carryOn`,{name:qt?.current??`gaiapy`})}),en&&Xt&&L(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void mn(Xt),disabled:nn,children:n(`setup.tryAgain`)}),!Dr&&!en&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:hn,disabled:nn,children:n(`setup.progress.cancel`)})]})]}):null,kr=wt&&k.done&&Ne?z(`p`,{className:`setup-ok setup-key-accepted`,role:`status`,children:[L(Yr,{size:14,"aria-hidden":`true`}),` `,n(`setup.key.accepted`,{model:Xc(Ne)})]}):null,Ar=de&&!wt?Qn.filter(e=>XK(e)&&!de.ticked.has(e.id)&&!e.downloaded&&(ZK(ir)||!e.roles.includes(`image_creation`))):[],jr=Qn.find(e=>e.fit_code===`memory`&&e.chat_choice&&e.support===`verified`);return z(`main`,{className:`setup`,"aria-labelledby":`setup-title`,children:[L(pY,{steps:gr}),L(Rq,{value:p,children:z(`div`,{className:`setup-pane`,children:[L(`div`,{className:`setup-scroll`,children:z(`div`,{className:`setup-inner`,children:[_r>=0&&z(`nav`,{className:`setup-topnav`,"aria-label":n(`setup.nav.label`),children:[L(`button`,{type:`button`,className:`setup-arrow`,onClick:()=>xr&&bn(xr),disabled:!xr,"aria-label":n(`setup.nav.prev`),children:L(ti,{size:16,"aria-hidden":`true`})}),L(`button`,{type:`button`,className:`setup-arrow`,onClick:()=>Sr&&bn(Sr),disabled:!Sr,"aria-label":n(`setup.nav.next`),children:L(ri,{size:16,"aria-hidden":`true`})}),L(`span`,{children:L(`bdi`,{children:n(`setup.nav.stepOf`,{n:String(_r+1),total:String(lr.length)})})}),h!=null&&h!==or&&L(`button`,{type:`button`,className:`link-btn`,onClick:()=>g(null),children:n.compose(e=>e(`setup.nav.toLive`,{step:e(lr.find(e=>e.id===or)?.key??`setup.download.step`)}))}),L(DJ,{})]}),Ae&&s!==`download`&&z(`div`,{className:`setup-banner`,role:`status`,children:[L(Na,{size:14,"aria-hidden":`true`}),L(`span`,{children:n(`setup.resume.banner`)})]}),Ze&&s!==`download`&&L(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.interrupted`)}),z(`div`,{className:`setup-stage is-${br.current}`,children:[sr===`check`&&z(P.Fragment,{children:[L(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(Vt?`setup.check.headingDone`:`setup.check.heading`)}),L(`p`,{className:`setup-lede`,children:n(rr)}),L(fY,{hardware:b,hardwareError:C,plan:A,serverRun:Tt,awaitingChoice:!!lt&&!ot}),Tt?.state===`running`&&z(P.Fragment,{children:[L(xJ,{run:Tt,idle:n(`setup.check.serverWorking`),bar:!1}),L(zq,{children:L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void Fn(),children:n(`setup.progress.cancel`)})})]}),Vt&&A&&L(nY,{plan:A,hardware:b,onChangeMemory:jn&&h==null?()=>Nn(`check`):void 0}),Vt&&h==null&&!(lt&&!ot)&&L(zq,{children:L(`button`,{type:`button`,className:`btn-primary`,onClick:An,children:n(`setup.continue`)})}),Tt&&qn&&z(P.Fragment,{children:[L(jY,{run:Tt}),Tt.problem?L(kY,{problem:Tt.problem,onRetry:()=>void Bt(!1,{serverOnly:!0}),onUseGaia:()=>void Bt(!0,{serverOnly:!0})}):L(zq,{children:L(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Bt(!!Tt.gaia_lemonade,{serverOnly:!0}),children:n(`setup.tryAgain`)})})]}),ce&&!A&&z(P.Fragment,{children:[L(AY,{text:ce}),z(zq,{children:[L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void Bt(!1,{keepTrying:ye}),children:n(`setup.models.useRecommended`)}),L(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Pt(),children:n(`setup.tryAgain`)})]}),L(`p`,{className:`setup-hint`,children:n(`setup.models.useRecommendedNote`)})]}),ee&&L(AY,{text:ee}),ee&&!Tt&&A&&!A.lemonade.reachable&&L(zq,{children:L(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Bt(!1,{serverOnly:!0}),children:n(`setup.tryAgain`)})}),rt&&A&&(!A.lemonade.reachable&&!Tt||Vt&&h==null&&A.lemonade.mode!==`external`)&&L(OY,{onNothingToOffer:ct,canInstallOwn:!A.lemonade.reachable&&!Tt,onFound:ut,onChosen:e=>{Ye(e===`external`),ft(e),st(!0),Mt(),Pt()}})]}),sr===`plan`&&A&&de&&z(P.Fragment,{children:[L(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.plan.title`)}),L(`p`,{className:`setup-lede`,children:n(`setup.plan.lede`)}),z(`div`,{className:`setup-where`,children:[z(`section`,{className:`setup-hero setup-where-card${Cn===`local`?` is-active`:``}`,"aria-label":n(`setup.plan.label`),onClick:()=>!wr&&wn(`local`),children:[L(`p`,{className:`setup-eyebrow`,children:de.chatChosen?n(`setup.plan.yours`):n(`setup.plan.recommended`)}),z(`p`,{className:`setup-hero-title`,children:[L(`input`,{type:`radio`,name:`setup-where`,checked:Cn===`local`,onChange:()=>wn(`local`),disabled:wr,"aria-labelledby":`setup-where-local`}),L(`bdi`,{id:`setup-where-local`,children:n(`setup.plan.run`,{name:ir?.name??``})})]}),z(`dl`,{className:`setup-facts`,children:[z(`div`,{children:[L(`dt`,{children:n(`setup.summary.download`)}),L(`dd`,{children:L(`bdi`,{dir:`ltr`,children:Sk(fq(A,de).downloadGb??0)})})]}),z(`div`,{children:[L(`dt`,{children:n(`setup.plan.runsOn`)}),L(`dd`,{children:L(`bdi`,{children:ir&&JK(ir)?n(`setup.checks.npu`):b?.gpu_name??n(`setup.plan.cpu`)})})]}),z(`div`,{children:[L(`dt`,{children:n(`setup.plan.diskAfter`)}),L(`dd`,{children:L(`bdi`,{dir:`ltr`,children:fq(A,de).afterGb==null?`—`:Sk(Math.max(0,fq(A,de).afterGb))})})]})]}),z(`ul`,{className:`setup-reasons`,children:[!de.chatChosen&&L(`li`,{children:n(`setup.plan.why.evaluated`)}),ir?.need_gb!=null&&ir.capacity_gb!=null&&ir.fits&&L(`li`,{children:n(`setup.plan.why.fits`,{need:Tk(ir.need_gb),have:Tk(ir.capacity_gb)})}),L(`li`,{children:n(`setup.plan.why.private`)}),ir&&JK(ir)&&L(`li`,{children:n(`setup.plan.why.noImagesNpu`)}),jr&&jr.id!==ir?.id&&jr.need_gb!=null&&jr.capacity_gb!=null&&L(`li`,{children:n(`setup.plan.why.bigger`,{name:jr.name,need:Tk(jr.need_gb),have:Tk(jr.capacity_gb)})})]}),$n.length>0&&L(`p`,{className:`setup-hint`,children:n(`setup.plan.cancelAnytime`)})]}),z(`section`,{className:`setup-hero setup-where-card${Cn===`cloud`?` is-active`:``}${xt?` is-disabled`:``}`,"aria-label":n(`setup.plan.cloudLabel`),onClick:()=>!wr&&!xt&&wn(`cloud`),children:[z(`p`,{className:`setup-hero-title`,children:[L(`input`,{type:`radio`,name:`setup-where`,checked:Cn===`cloud`,onChange:()=>wn(`cloud`),disabled:wr||xt,"aria-labelledby":`setup-where-cloud`}),L(`span`,{id:`setup-where-cloud`,children:n(`setup.plan.cloud`)})]}),xt?L(`p`,{className:`setup-hint`,children:n(`settings.privacy.localOnlyBlocked`)}):z(`ul`,{className:`setup-reasons`,children:[L(`li`,{children:n(`setup.plan.cloudWhy.stillLocal`)}),L(`li`,{children:n(`setup.plan.cloudWhy.key`)}),L(`li`,{children:n(`setup.plan.cloudWhy.sent`)})]})]})]}),z(zq,{children:[Cn!==`cloud`&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:Sn,disabled:Te||wr,children:n(`setup.plan.customize`)}),Cn===`cloud`?L(`button`,{type:`button`,className:`btn-primary`,onClick:kn,disabled:wr,children:n(`setup.continue`)}):z(`button`,{type:`button`,className:`btn-primary`,onClick:()=>er?Se({kind:`low_disk`}):void yn(!1),disabled:Te||ar||wr,children:[Te&&L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,$n.length?n(`setup.plan.start`):n(`setup.plan.startNoDownload`)]})]}),t&&L(`div`,{className:`setup-row`,children:L(`button`,{type:`button`,className:`link-btn`,onClick:t,children:n(`setup.backToGaia`)})}),ar&&z(`div`,{className:`setup-error`,role:`alert`,children:[L(`p`,{children:n(`setup.blocked`)}),z(`details`,{className:`dl-details`,children:[L(`summary`,{children:n(`setup.progress.details`)}),L(`pre`,{dir:`ltr`,children:b?.blockers.join(`
|
|
213
|
-
`)})]})]}),er&&L(`p`,{className:`setup-error`,role:`alert`,children:n(`setup.summary.short`,{need:Sk(er.needGb),free:Sk(er.freeGb),drive:n(`setup.summary.theDrive`),freeUp:Sk(er.freeUpGb)})}),(De??ee)&&L(AY,{text:De??ee}),Cn!==`cloud`&&z(`details`,{className:`setup-disclosure`,children:[L(`summary`,{children:n(`setup.plan.whatDownloads`)}),L(cJ,{plan:A,models:$n})]})]}),sr===`gpu`&&_e&&z(P.Fragment,{children:[L(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.gpu.title`)}),L(`p`,{className:`setup-lede`,children:n(`setup.gpu.lede`)}),L(Yq,{status:_e,onStatus:ve,mode:`setup`,headingId:`setup-title`,names:Kn,cloud:a!==`local`,onBack:Mn,onSkip:()=>bn(d),onContinue:()=>bn(d)})]}),sr===`models`&&z(P.Fragment,{children:[L(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.models.title`)}),A&&de&&L(HJ,{plan:A,selection:de,onSelection:fe,disabled:Te||wr,onRecheck:()=>void Pt()}),jn&&_e?.total_gb!=null&&_e.gpu_gb!=null&&z(`p`,{className:`setup-hint setup-gpu-option`,children:[n(`setup.models.gpu`,{gpu:Sk(_e.gpu_gb),total:Sk(_e.total_gb)}),` `,L(`button`,{type:`button`,className:`link-btn`,onClick:()=>Nn(`models`),disabled:Te||wr,children:n(`setup.found.changeMemory`)})]}),L(IJ,{disabled:Te||wr,pending:qt?.id??null,onPending:Yt}),L(Xq,{plan:A,planError:ce,onRetryPlan:()=>void Pt(),onUseRecommended:()=>void Bt(!1,{keepTrying:ye}),selection:de,onSelection:fe,cloud:!1,keepTrying:ye,onKeepTrying:be,onBack:Mn,onContinue:e=>void yn(e),busy:Te||wr,error:De??ee})]}),sr===`key`&&z(`form`,{id:`setup-key-form`,onSubmit:e=>{e.preventDefault(),Bn()},className:`setup-form`,children:[L(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.key.title`)}),L(jB,{className:`setup-choices`,"aria-label":n(`setup.key.provider`),children:xY.filter(e=>e.id!==`local`&&(e.id!==`amd`||bt)).map(e=>z(`button`,{type:`button`,role:`radio`,"aria-checked":a===e.id,className:`setup-choice${a===e.id?` is-active`:``}${St(e.id)?` is-disabled`:``}`,onClick:()=>Hn(e.id),disabled:k.busy||St(e.id),title:yt(e.id)?n(`settings.privacy.localOnlyBlocked`):void 0,children:[L(xi,{size:16,"aria-hidden":`true`}),z(`span`,{children:[L(`span`,{className:`setup-choice-title`,children:L(`bdi`,{children:SY(e,n)})}),L(`span`,{className:`setup-choice-note`,children:St(e.id)?Ct(e.id):n(e.note)})]})]},e.id))}),mt?.reachable===!1&&bt&&L(`button`,{type:`button`,className:`link-btn setup-start`,onClick:gt,children:n(`setup.key.checkAgain`)}),yt(a)&&L(`p`,{className:`setup-a11y-alert`,role:`alert`,children:n(`settings.privacy.localOnlyBlocked`)}),a===`fireworks`&&!Je&&!yt(a)&&z(`section`,{className:`setup-card`,children:[L(`h3`,{className:`mc-job-title`,children:n(`setup.key.getOne`)}),z(`ol`,{className:`setup-key-steps`,children:[L(`li`,{children:L(`a`,{href:yY,target:`_blank`,rel:`noreferrer`,children:n(`setup.key.step1`)})}),L(`li`,{children:n(`setup.key.step2`)}),L(`li`,{children:n(`setup.key.step3`)})]})]}),a===`amd`&&!Je&&!yt(a)&&L(`section`,{className:`setup-card`,children:L(`p`,{className:`setup-hint`,children:L(`a`,{href:bY,target:`_blank`,rel:`noreferrer`,children:n(`setup.key.gatewayHelp`)})})}),!yt(a)&&L(RK,{provider:a,limit:3,picked:Fe,onPick:Ie,onDefault:Re,pickDisabled:k.busy||wr}),!Je&&z(P.Fragment,{children:[L(`label`,{className:`setup-key-label`,htmlFor:`setup-key-input`,children:n(`setup.key.labelFor`,{provider:SY(xY.find(e=>e.id===a)??xY[1],n)})}),z(`div`,{className:`setup-row setup-key-row`,children:[L(`input`,{id:`setup-key-input`,className:`settings-input`,type:ze?`text`:`password`,autoComplete:`off`,spellCheck:!1,value:ne,onChange:e=>re(e.target.value),placeholder:F?n.bare(`setup.key.placeholder`):n.bare(`setup.key.placeholderNew`)}),L(`button`,{type:`button`,className:`btn-secondary setup-key-show`,"aria-label":n(ze?`setup.key.hide`:`setup.key.show`),title:n(ze?`setup.key.hide`:`setup.key.show`),onClick:()=>Be(e=>!e),children:L(ze?Gi:qi,{size:14,"aria-hidden":`true`})})]})]}),L(`p`,{className:`setup-hint`,children:n(Je?`setup.key.usersServer`:`setup.key.where`)}),N&&!Je&&!ne&&L(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.key.foundEnv`,{name:N.name,hint:N.key_hint??``})}),k.busy&&!k.waiting&&L(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.key.testing`)}),k.busy&&k.waiting&&L(`p`,{className:`setup-hint`,role:`status`,children:k.waiting}),k.error&&L(`p`,{className:`setup-error`,role:`alert`,children:k.error}),z(zq,{children:[L(`button`,{type:`button`,className:`btn-secondary`,onClick:xn,disabled:k.busy,children:n(`setup.back`)}),z(`button`,{type:`submit`,form:`setup-key-form`,className:`btn-primary`,disabled:k.busy||St(a)||wr,children:[k.busy&&L(Za,{size:13,className:`spin`}),` `,n(`setup.key.connect`)]})]})]}),sr===`download`&&!Et&&z(P.Fragment,{children:[L(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.download.title`)}),L(`p`,{className:`setup-lede`,children:n(`setup.download.lede`)}),kr,Or??z(`p`,{className:`setup-hint`,role:`status`,children:[L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,n(`setup.download.starting`)]})]}),sr===`download`&&Et&&z(P.Fragment,{children:[L(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.download.title`)}),L(`p`,{className:`setup-lede`,children:n(`setup.download.lede`)}),kr,A&&L(`section`,{className:`setup-card`,"aria-label":n(`setup.contents.title`),children:L(cJ,{plan:A,run:Et,onRetry:Ht,retryDisabled:Te})}),(Et.models?.length??0)>0?L(`div`,{className:D?`is-stale`:void 0,children:L(bJ,{status:{...Et,overall:_q(Et,j??A)},names:Kn,freeGb:A?.disk?.free_gb??null,onCancel:()=>void Fn(),onRetry:(e,t)=>void In(e,t),onResume:e=>void In(e,null),onResumeAll:Ht,onSkip:e=>void Ln(e),onRestart:()=>void zn(),busy:Te||!!D,retryLater:Dt,labelledBy:`setup-title`})}):Dt?z(P.Fragment,{children:[L(xJ,{run:Et,plan:A,idle:n(`setup.download.working`)}),L(zq,{children:L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void Fn(),disabled:Te,children:n(`setup.progress.cancel`)})})]}):null,Ar.length>0&&z(`section`,{className:`setup-card`,"aria-label":n(`setup.optional.title`),children:[L(`h3`,{className:`mc-job-title`,children:n(`setup.optional.title`)}),L(`p`,{className:`setup-hint`,children:n(`setup.optional.lede`)}),L(`ul`,{className:`setup-rows`,children:Ar.map(e=>{let t=Ue.includes(e.id);return z(`li`,{className:`setup-result is-waiting`,children:[L(`span`,{className:`setup-result-label`,children:n(`setup.purpose.${e.roles[0]}`)}),z(`span`,{className:`setup-result-value`,children:[L(`bdi`,{dir:`ltr`,children:e.size_gb==null?n(`setup.contents.sizeOnDownload`):Sk(e.size_gb)}),L(`button`,{type:`button`,className:`btn-secondary`,"aria-pressed":t,onClick:()=>We(n=>t?n.filter(t=>t!==e.id):[...n,e.id]),children:n(t?`setup.optional.added`:`setup.optional.add`)})]})]},e.id)})})]}),D&&z(P.Fragment,{children:[L(`p`,{className:`setup-error`,role:`alert`,children:n(`setup.lostContact`,{error:D})}),L(zq,{children:L(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void zt(),children:n(`setup.reconnect`)})})]}),qn&&Xn&&!Zn&&Et.state===`failed`&&!Et.model_failed&&(Et.problem?L(kY,{problem:Et.problem,onRetry:Ht,onUseGaia:()=>void Bt(!0,$e.current.options)}):z(`div`,{className:`setup-error`,role:`alert`,children:[L(`p`,{children:n(`setup.download.stoppedBeforeCheck`)}),Et.error&&z(`details`,{className:`dl-details`,children:[L(`summary`,{children:n(`setup.progress.details`)}),L(`pre`,{dir:`ltr`,children:Et.error})]})]})),qn&&Xn&&!Zn&&z(P.Fragment,{children:[L(`p`,{className:`setup-hint`,children:n(`setup.download.finishNote`)}),L(zq,{children:L(`button`,{type:`button`,className:`btn-primary`,onClick:Ht,disabled:Te,children:n(`setup.finish`)})})]}),qn&&!Xn&&!Zn&&!(Et.models??[]).some(e=>e.state===`failed`||e.state===`cancelled`)&&z(P.Fragment,{children:[L(jY,{run:Et}),Et.problem?L(kY,{problem:Et.problem,onRetry:Ht,onUseGaia:()=>void Bt(!0,$e.current.options)}):L(zq,{children:L(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Bt(!!Et.gaia_lemonade,$e.current.options),children:n(`setup.tryAgain`)})})]}),(De||ee)&&L(AY,{text:De??ee})]}),sr===`test`&&Et&&z(P.Fragment,{children:[L(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.test.title`)}),L(`p`,{className:`setup-lede`,children:n(`setup.test.lede`)}),L(vY,{run:Et,expected:Tr,names:Kn,catalog:Qn,onRetry:Ht,onChooseAnother:wt?void 0:Sn,onCancel:()=>void Fn(),onDownloadAgain:A?.lemonade.mode===`external`?void 0:e=>void In(e,`verify`),busy:Te}),qn&&Et.error&&!(Et.tests??[]).some(e=>e.error===Et.error)&&z(`details`,{className:`dl-details`,children:[L(`summary`,{children:n(`setup.progress.details`)}),L(`pre`,{dir:`ltr`,children:Et.error})]}),(De||ee)&&L(AY,{text:De??ee})]}),sr===`ready`&&z(P.Fragment,{children:[L(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.ready.heading`)}),z(`div`,{className:`setup-done`,role:`status`,children:[L(`div`,{className:`setup-done-head`,children:Wn&&L(`p`,{children:n(wt?`setup.ready.answersCloud`:`setup.ready.answersLocal`,{model:wt?Uc(Wn):Kn[Wn]??M?.catalog?.find(e=>e.id===Wn)?.name??Uc(Wn)})})}),L(zq,{children:L(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Gn(),autoFocus:!0,children:n(`setup.ready.start`)})}),!wt&&M&&L(Zq,{plan:M,chatModel:Wn,gpu:_e}),ee&&L(AY,{text:ee}),(Et?.tests??[]).filter(e=>e.state===`failed`).map(e=>L(`p`,{className:`setup-failed-extra`,role:`alert`,children:n(`setup.ready.extraFailed`,{job:n(`setup.test.job.${e.job}`)})},`${e.job}:${e.subject??``}`)),Ge.length>0&&!xe&&L(`p`,{className:`setup-failed-extra`,role:`alert`,children:n(`setup.ready.extraNotFetched`,{names:Ge.map(e=>Kn[e]??e).join(`, `)})}),Yn.length>0&&z(P.Fragment,{children:[L(`p`,{className:`setup-hint`,children:n(`setup.ready.tasks`)}),L(nJ,{cards:Yn,onPick:e=>void Gn(e)})]})]})]}),T?.state===`failed`&&L(uY,{})]},sr),t&&!Dt&&sr!==`plan`&&sr!==`ready`&&L(`div`,{className:`setup-row`,children:L(`button`,{type:`button`,className:`link-btn setup-close`,onClick:t,children:n(`setup.backToGaia`)})}),wr&&(Cr||sr===`plan`)&&L(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.nav.runGoing`)}),L(EJ,{run:T,before:{check:mr},failed:Jn})]})}),L(`div`,{className:`setup-footer`,ref:m})]})}),xe?.kind===`no_fit`&&L(Bq,{title:xe.models.length===1?n(`setup.confirm.noFitOne`,{name:xe.models[0].name}):n(`setup.confirm.noFitMany`),confirmLabel:n(`setup.confirm.downloadAnyway`),cancelLabel:n(`setup.confirm.pickSmaller`),onConfirm:()=>{Se(null),we(!0),yn(Wt,!0)},onCancel:()=>Se(null),children:xe.models.map(e=>z(`p`,{children:[L(`bdi`,{children:e.name}),`: `,wq(e,n)]},e.id))}),xe?.kind===`low_disk`&&er&&L(Bq,{title:n(`setup.confirm.lowDiskTitle`),confirmLabel:n(`setup.confirm.downloadAnyway`),cancelLabel:n(`setup.confirm.changeModels`),onConfirm:()=>{Se(null),yn(!0)},onCancel:()=>{Se(null),Sn()},children:L(`p`,{children:n(`setup.summary.short`,{need:Sk(er.needGb),free:Sk(er.freeGb),drive:n(`setup.summary.theDrive`),freeUp:Sk(er.freeUpGb)})})}),xe?.kind===`server`&&L(Bq,{title:xe.detail.code===`low_disk`?n(`setup.confirm.lowDiskTitle`):n(`setup.confirm.noFitServerTitle`),confirmLabel:xe.detail.code===`low_disk`?n(`setup.confirm.downloadAnyway`):n(`setup.confirm.useAnyway`),cancelLabel:n(`setup.confirm.changeModels`),onConfirm:()=>{let e=xe;if(Se(null),e.then===`chat`)we(!0),yn(Wt,!0);else if(e.then===`retry`)Ke(e.id,{keepTrying:ye,acknowledgeLowDisk:!0}).then(E).catch(e=>ke(LY(e)));else{let{gaiaLemonade:e,options:t}=$e.current;Bt(e,{...t,acknowledgeLowDisk:!0})}},onCancel:()=>{let e=xe;Se(null),e.then!==`retry`&&!Ot&&Sn()},children:L(`p`,{children:xe.detail.message})})]})}function zY({title:e,titleId:t,count:n,hint:r,defaultOpen:i=!1,forceOpen:a=!1,targetId:o,children:s}){let[c,l]=(0,B.useState)(i);return z(`details`,{className:`settings-disclosure`,"data-settings-target":o,open:c||a,onToggle:e=>{a||l(e.currentTarget.open)},children:[z(`summary`,{onClick:e=>{a&&e.preventDefault()},children:[L($r,{size:15,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),z(`span`,{className:`settings-disclosure-text`,children:[L(`span`,{className:`settings-disclosure-title`,id:t,tabIndex:t?-1:void 0,children:e}),r&&L(`span`,{className:`settings-disclosure-hint`,children:r})]}),n!=null&&L(`bdi`,{dir:`ltr`,className:`settings-disclosure-count`,children:n})]}),L(`div`,{className:`settings-disclosure-body`,children:s})]})}var BY=We(pu()?`settings.desktop.menuBar`:`settings.desktop.tray`),VY=[{key:`minimizeToTray`,label:`settings.desktop.keepRunning`,hint:`settings.desktop.keepRunningHint`},{key:`startOnLogin`,label:`settings.desktop.startOnLogin`,hint:`settings.desktop.startOnLoginHint`},{key:`startMinimized`,label:`settings.desktop.startMinimized`,hint:`settings.desktop.startMinimizedHint`}],HY=new Set([`startMinimized`]),UY={minimizeToTray:`settings.desktop.keepRunningNoTray`};function WY(e){return e?.reason===`no-host`?`settings.desktop.noTray`:e?.reason===`check-failed`?`settings.desktop.noTrayCheckFailed`:null}function GY(){let e=R(),t=window.gaiaAPI?.tray,[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(null);(0,B.useEffect)(()=>{t&&t.getConfig().then(e=>{r(e.tray),a(e.host)}).catch(t=>s(e(`settings.desktop.readFailed`,{reason:t instanceof Error?t.message:String(t)})))},[t,e]);let u=(0,B.useCallback)(async e=>{if(t&&n&&c===null){l(e),s(null);try{let i=await t.setConfig({tray:{[e]:!n[e]}});r(i.tray),a(i.host)}catch(e){s(e instanceof Error?e.message:String(e))}finally{l(null)}}},[t,n,c]);if(!t)return null;let d=WY(i);return L(zY,{title:e(`settings.desktop.title`),children:z(`div`,{className:`settings-field`,role:`group`,"aria-labelledby":`desktop-app-label`,children:[L(`span`,{className:`settings-label`,id:`desktop-app-label`,children:e(`settings.desktop.title`)}),VY.map(({key:t,label:r,hint:i})=>{let a=HY.has(t)?d:null,o=d&&UY[t]||i;return z(`div`,{children:[z(`label`,{className:`setting-row`,children:[L(`span`,{children:e(r,{tray:BY})}),z(`span`,{className:`toggle-switch`,children:[L(`input`,{id:`desktop-${t}`,type:`checkbox`,role:`switch`,checked:!a&&!!n?.[t],"aria-describedby":`desktop-${t}-hint`,onChange:()=>void u(t),disabled:!!a||!n||c!==null&&c!==t,"aria-busy":c===t,"aria-label":e(r,{tray:BY})}),L(`span`,{className:`toggle-track`})]})]}),L(`p`,{className:`settings-hint`,id:`desktop-${t}-hint`,children:a?e(a):e(o,{tray:BY})})]},t)}),o&&L(`p`,{className:`settings-error`,role:`alert`,children:o})]})})}function KY(){return window.gaiaUpdater}function qY({onClose:e,manualInstall:t=!1}){let n=R(),[r,i]=(0,B.useState)({kind:`loading`}),a=(0,B.useRef)(null);(0,B.useEffect)(()=>{let e=KY();e?e.listReleases().then(e=>{i(Array.isArray(e)?{kind:`list`,releases:e}:{kind:`error`,message:e.error})}).catch(()=>{i({kind:`error`,message:`Couldn't reach GitHub to list releases — check your connection; you can still download installers from the Releases page.`})}):i({kind:`error`,message:`Couldn't reach GitHub to list releases — check your connection; you can still download installers from the Releases page.`})},[]),ut(!0,e),un(a,!0),(0,B.useEffect)(()=>{let e=a.current;e&&e.querySelector(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)?.focus()},[]),(0,B.useEffect)(()=>{let e=a.current;if(!e)return;function t(t){if(t.key!==`Tab`||!e)return;let n=e.querySelectorAll(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);if(n.length===0)return;let r=n[0],i=n[n.length-1];t.shiftKey?document.activeElement===r&&(t.preventDefault(),i?.focus()):document.activeElement===i&&(t.preventDefault(),r?.focus())}return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[]);function o(e,t){e.isCurrent||i({kind:`confirm`,release:e,releases:t})}async function s(t){i({kind:`installing`});let r=KY();if(!r)i({kind:`error`,message:n(`update.picker.noBridge`)});else try{await r.installVersion(t.tag),e()}catch(e){i({kind:`error`,message:n(`update.picker.failed`,{reason:cY(e)})})}}function c(e){if(!e)return``;try{return new Date(e).toLocaleDateString(On(n),{year:`numeric`,month:`short`,day:`numeric`})}catch{return e}}return L(`div`,{className:`version-picker-overlay`,onClick:t=>{t.target===t.currentTarget&&e()},children:z(`div`,{className:`version-picker-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":n(`update.picker.title`),ref:a,children:[z(`div`,{className:`version-picker-header`,children:[L(`h3`,{children:n(`update.picker.title`)}),L(`button`,{className:`version-picker-close`,onClick:e,"aria-label":n(`update.picker.close`),type:`button`,children:`×`})]}),z(`div`,{className:`version-picker-body`,children:[r.kind===`loading`&&z(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[L(`span`,{className:`version-picker-spinner`}),n(`update.picker.loading`)]}),r.kind===`error`&&z(`div`,{className:`version-picker-error`,children:[L(`p`,{children:r.message}),L(`p`,{children:L(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:n(`update.picker.browse`)})})]}),r.kind===`list`&&L(`ul`,{className:`version-picker-list`,role:`listbox`,"aria-label":n(`update.picker.listAria`),children:r.releases.map(e=>L(`li`,{children:z(`button`,{type:`button`,className:`version-picker-row`,"data-version":e.version,"aria-label":e.isCurrent?n(`update.picker.rowInstalled`,{version:e.version}):e.isPinned?n(`update.picker.rowPinned`,{version:e.version}):e.version,"aria-disabled":e.isCurrent?`true`:`false`,onClick:()=>o(e,r.releases),disabled:e.isCurrent,children:[L(`span`,{className:`vp-version`,children:e.version}),L(`span`,{className:`vp-date`,children:c(e.date)}),e.isCurrent&&L(`span`,{className:`vp-badge vp-badge-current`,children:n(`update.picker.installed`)}),e.isPinned&&!e.isCurrent&&L(`span`,{className:`vp-badge vp-badge-pinned`,children:n(`update.picker.pinned`)}),!e.isCurrent&&L(`span`,{className:`vp-arrow`,"aria-hidden":`true`,children:`›`})]})},e.tag))}),r.kind===`list`&&z(`p`,{className:`version-picker-more`,children:[n(`update.picker.recent`,{n:r.releases.length}),` `,L(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:n(`update.picker.browseAll`)})]}),r.kind===`confirm`&&z(`div`,{className:`version-picker-confirm`,children:[t?L(`p`,{children:n(`update.picker.manual`,{version:r.release.version})}):z(P.Fragment,{children:[L(`p`,{children:n(`update.picker.confirm`,{version:r.release.version})}),L(`p`,{className:`vp-confirm-note`,children:n(`update.picker.confirmNote`,{version:r.release.version})})]}),z(`div`,{className:`vp-confirm-actions`,children:[L(`button`,{type:`button`,className:`vp-btn-cancel`,onClick:()=>i({kind:`list`,releases:r.releases}),children:n(`update.picker.back`)}),t?L(`a`,{className:`vp-btn-confirm`,href:r.release.notesUrl??`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noopener noreferrer`,children:n(`update.picker.openRelease`)}):L(`button`,{type:`button`,className:`vp-btn-confirm`,onClick:()=>s(r.release),children:n(`update.picker.install`)})]})]}),r.kind===`installing`&&z(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[L(`span`,{className:`version-picker-spinner`}),n(`update.picker.starting`)]})]})]})})}var JY=`https://github.com/amd/gaia/releases`;function YY(e){return/^\d+\.\d+\.\d+-/.test(e??``)}function XY(e,t){let n=e.version??``;if(e.readFailed)return t(`update.status.readFailed`);switch(e.status){case`checking`:return t(`update.status.checking`);case`available`:return t(`update.status.available`,{version:n});case`downloading`:return e.preparing?t(`update.status.preparing`,{version:n}):t(`update.status.downloading`,{version:n,pct:e.progress});case`downloaded`:return t(`update.status.downloaded`,{version:n});case`error`:return t(`update.status.error`,{reason:e.error??t(`update.status.unknownError`)});case`no-channel`:return e.error??t(`update.status.noChannel`);case`disabled`:return t(`update.status.disabled`);default:return t(`update.status.upToDate`)}}function ZY(){let e=aY(),t=R(),n=rY(),[r,i]=(0,B.useState)(!1),[a,o]=(0,B.useState)(null),[s,c]=(0,B.useState)(!1);if(!n)return null;async function l(e,r){if(n){i(!0),o(null);try{await r(n)}catch(n){F.system.error(`${e} failed`,n),o(t(`update.settings.failed`,{action:We(e),reason:cY(n)}))}finally{i(!1)}}}let u=e.status===`disabled`,d=r||e.status===`checking`||e.status===`downloading`,f=e.readFailed?XY(e,t):`${t(`update.settings.running`,{version:e.currentVersion??t(`update.settings.unknownVersion`)})} ${XY(e,t)}`,p=[`available`,`downloaded`,`error`].includes(e.status)||!!e.pinnedVersion||!!e.installFailed||!!e.configError||!!e.readFailed||!!a;return L(zY,{title:t(`update.settings.title`),titleId:`updates-label`,hint:f,forceOpen:p,children:z(`div`,{className:`settings-field`,role:`group`,"aria-labelledby":`updates-label`,children:[L(`p`,{className:`visually-hidden`,role:`status`,children:f}),!e.manualInstall&&z(P.Fragment,{children:[z(`label`,{className:`setting-row`,children:[L(`span`,{children:t(`update.settings.auto`)}),z(`span`,{className:`toggle-switch`,children:[L(`input`,{type:`checkbox`,role:`switch`,checked:e.autoUpdate,"aria-describedby":`updates-auto-hint`,"aria-label":t(`update.settings.auto`),"aria-busy":r,disabled:u,onChange:()=>{r||l(`update.action.saveAuto`,t=>t.setAutoUpdate(!e.autoUpdate))}}),L(`span`,{className:`toggle-track`})]})]}),L(`p`,{className:`settings-hint`,id:`updates-auto-hint`,children:t(`update.settings.autoHint`)})]}),z(`label`,{className:`setting-row`,children:[L(`span`,{children:t(`update.settings.rc`)}),z(`span`,{className:`toggle-switch`,children:[L(`input`,{type:`checkbox`,role:`switch`,checked:!!e.includePrereleases,"aria-describedby":`updates-rc-hint`,"aria-label":t(`update.settings.rc`),"aria-busy":r,disabled:u,onChange:()=>{r||l(`update.action.saveRc`,t=>t.setIncludePrereleases(!e.includePrereleases))}}),L(`span`,{className:`toggle-track`})]})]}),z(`p`,{className:`settings-hint`,id:`updates-rc-hint`,children:[t(`update.settings.rcHint`),YY(e.currentVersion)&&` ${t(`update.settings.rcHintRunning`)}`]}),e.pinnedVersion&&z(`p`,{className:`settings-hint`,children:[t(`update.settings.pinned`,{version:e.pinnedVersion}),` `,L(`button`,{type:`button`,className:`btn-secondary`,disabled:r,onClick:()=>void l(`update.action.resume`,e=>e.resumeUpdates()),children:t(`update.settings.unpin`)})]}),z(`div`,{className:`setting-actions`,children:[e.status===`available`&&e.manualInstall&&L(`a`,{className:`btn-primary update-download-link`,href:e.downloadUrl??JY,target:`_blank`,rel:`noopener noreferrer`,"aria-describedby":`updates-manual-hint`,children:t(`update.settings.downloadVersion`,{version:e.version??``})}),e.status===`available`&&!e.manualInstall&&!e.pinnedVersion&&L(`button`,{type:`button`,className:`btn-primary`,disabled:r,onClick:()=>void l(`update.action.download`,e=>e.downloadUpdate()),children:t(`update.settings.updateTo`,{version:e.version??``})}),e.status===`downloaded`&&L(`button`,{type:`button`,className:`btn-primary`,disabled:r,onClick:()=>void l(`update.action.restart`,e=>e.restart()),children:t(`update.settings.restart`)}),e.readFailed?L(`button`,{type:`button`,className:`btn-secondary`,disabled:r,onClick:async()=>{i(!0);try{await e.reload()}finally{i(!1)}},children:t(`update.settings.retryRead`)}):L(`button`,{type:`button`,className:`btn-secondary`,disabled:d||u,onClick:()=>void l(`update.action.check`,e=>e.check()),children:t(`update.settings.check`)}),L(`button`,{type:`button`,className:`btn-secondary`,disabled:d||u,onClick:()=>c(!0),children:t(`update.settings.pick`)}),e.previousVersion&&L(`button`,{type:`button`,className:`btn-secondary`,"aria-describedby":`updates-back-hint`,disabled:d||u,onClick:()=>void l(`update.action.goBack`,e=>e.revertUpdate()),children:t(`update.settings.goBack`,{version:e.previousVersion})})]}),e.status===`available`&&e.manualInstall&&L(`p`,{className:`settings-hint`,id:`updates-manual-hint`,children:t(`update.settings.manualHint`)}),e.previousVersion&&L(`p`,{className:`settings-hint`,id:`updates-back-hint`,children:t(`update.settings.goBackHint`)}),e.installFailed&&L(`p`,{className:`settings-error`,role:`alert`,children:t(`update.settings.installFailed`,{...e.installFailed,url:JY})}),e.lastCheckError&&L(`p`,{className:`settings-hint`,children:t(`update.settings.lastCheckError`,{reason:e.lastCheckError})}),e.configError&&L(`p`,{className:`settings-error`,role:`alert`,children:e.configError}),a&&L(`p`,{className:`settings-error`,role:`alert`,children:a}),s&&L(qY,{onClose:()=>c(!1),manualInstall:e.manualInstall})]})})}var QY=[{value:`light`,label:`settings.theme.light`},{value:`dark`,label:`settings.theme.dark`},{value:`system`,label:`settings.theme.system`}],$Y={default:`palette.default`,stone:`palette.stone`,marble:`palette.marble`,glacier:`palette.glacier`,forest:`palette.forest`,sage:`palette.sage`,basalt:`palette.basalt`,gold:`palette.gold`,dusk:`palette.dusk`,custom:`settings.colors.custom`};function eX(){let e=R(),t=N(e=>e.locale),n=N(e=>e.setLocale),r=N(e=>e.themePreference),i=N(e=>e.setThemePreference),a=N(e=>e.palette),o=N(e=>e.setPalette),s=N(e=>e.customColors),c=N(e=>e.setCustomColors),l=pW(e=>e.visible),u=pW(e=>e.setVisible),d=e=>t=>c({...s,[e]:t.target.value.toUpperCase()});return z(`div`,{className:`settings-pane`,children:[L(`h2`,{className:`settings-pane-title`,children:e(`settings.section.general`)}),z(`div`,{className:`settings-field`,children:[L(`label`,{className:`settings-label`,htmlFor:`ui-language`,children:e(`settings.language`)}),L(`select`,{id:`ui-language`,className:`settings-input`,value:t,onChange:e=>n(e.target.value),children:_e.map(({meta:e})=>L(`option`,{value:e.code,lang:e.code,dir:e.dir,children:ir(e)},e.code))}),L(`span`,{className:`settings-hint`,children:e(`settings.languageHint`)})]}),z(`div`,{className:`settings-field`,children:[L(`span`,{className:`settings-label`,id:`appearance-label`,children:e(`settings.appearance`)}),L(jB,{className:`segmented`,"aria-labelledby":`appearance-label`,children:QY.map(t=>L(`button`,{type:`button`,role:`radio`,"aria-checked":r===t.value,className:r===t.value?`is-active`:``,onClick:()=>i(t.value),children:e(t.label)},t.value))})]}),z(`div`,{className:`settings-field`,children:[z(`label`,{className:`setting-row`,children:[L(`span`,{children:e(`resources.settings`)}),z(`span`,{className:`toggle-switch`,children:[L(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked),"aria-label":e(`resources.settings`),"aria-describedby":`resources-hint`}),L(`span`,{className:`toggle-track`})]})]}),L(`span`,{className:`settings-hint`,id:`resources-hint`,children:e(`resources.settingsHint`)})]}),z(zY,{title:e(`settings.colors`),titleId:`palette-label`,defaultOpen:a===`custom`,children:[z(jB,{className:`palette-grid`,"aria-labelledby":`palette-label`,children:[ae.map(t=>z(`button`,{type:`button`,role:`radio`,"aria-checked":a===t.id,className:`palette-tile${a===t.id?` is-active`:``}`,onClick:()=>o(t.id),children:[L(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:t.swatch.map(e=>L(`i`,{style:{background:e}},e))}),e($Y[t.id])]},t.id)),z(`button`,{type:`button`,role:`radio`,"aria-checked":a===`custom`,className:`palette-tile${a===`custom`?` is-active`:``}`,onClick:()=>o(`custom`),children:[z(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:[L(`i`,{style:{background:s.base}}),L(`i`,{style:{background:s.accent}})]}),e(`settings.colors.custom`)]})]}),a===`custom`&&z(`div`,{className:`palette-custom`,children:[z(`label`,{className:`palette-color`,htmlFor:`custom-accent`,children:[L(`input`,{id:`custom-accent`,type:`color`,value:s.accent,onChange:d(`accent`)}),z(`span`,{children:[e(`settings.colors.accent`),L(`small`,{children:e(`settings.colors.accentHint`)})]})]}),z(`label`,{className:`palette-color`,htmlFor:`custom-base`,children:[L(`input`,{id:`custom-base`,type:`color`,value:s.base,onChange:d(`base`)}),z(`span`,{children:[e(`settings.colors.base`),L(`small`,{children:e(`settings.colors.baseHint`)})]})]}),L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>c(wn),children:e(`settings.colors.reset`)}),L(`p`,{className:`settings-hint`,children:e(`settings.colors.hint`)})]})]}),L(GY,{}),L(ZY,{}),L(zY,{title:e(`settings.shortcuts`),children:L(`dl`,{className:`shortcut-list`,children:FK().map(({label:t,keys:n})=>z(`div`,{className:`shortcut-row`,children:[L(`dt`,{children:L(`kbd`,{children:_u(n)})}),L(`dd`,{children:e(t)})]},t))})})]})}function tX(e){return/not reachable|not answering|model server at|ConnectionPool|NewConnectionError|Connection refused|Max retries/i.test(e)}function nX(e){return/gaia init/i.test(e??``)}var rX=`GAIA doesn't run this model server, so it can't start it. Start it the way you usually do.`;function iX(e,t){return t?t===rX?e(`server.otherServerStart`):t:null}function aX(e){return!!e&&!e.lemonade_running&&(nX(e.start_command)||nX(e.start_instruction))}function oX({className:e=`btn-secondary`}){let t=R();return L(`button`,{type:`button`,className:e,onClick:()=>window.dispatchEvent(new CustomEvent(`gaia:set-up-local`)),children:t(`settings.errors.setUpLocal`)})}function sX({message:e,onRetry:t}){let n=R(),r=N(e=>aX(e.systemStatus));return tX(e)?z(`div`,{className:`settings-notice`,role:`alert`,children:[L(`strong`,{children:n(r?`settings.errors.notInstalledTitle`:`settings.errors.serverDownTitle`)}),L(`p`,{children:n(r?`settings.errors.notInstalled`:`settings.errors.serverDown`)}),r&&L(oX,{className:`btn-primary`}),t&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:t,children:n(`settings.key.checkAgain`)}),z(`details`,{className:`settings-more`,children:[z(`summary`,{children:[L($r,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,n(`settings.errors.details`)]}),L(`bdi`,{dir:`ltr`,className:`settings-notice-raw`,children:e})]})]}):L(`p`,{className:`settings-error`,role:`alert`,children:e})}function cX({onAdded:e}){let t=R(),[n,r]=(0,B.useState)(``),[i,a]=(0,B.useState)(``),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(null),[u,d]=(0,B.useState)(null),f=(0,B.useRef)(``),p=(0,B.useCallback)(async e=>{let t=n.trim();f.current=t,l(`check`),d(null);try{let n=await Cn(t,e);if(f.current!==t)return;s(n),a(n.file??e)}catch(e){if(f.current!==t)return;s(null),d(e instanceof Error?e.message:String(e))}finally{l(null)}},[n]),m=(0,B.useCallback)(async()=>{l(`add`),d(null);try{let{report:o}=await vt(n.trim(),i);r(``),a(``),s(null),e(o.display_name??o.model_id??t(`settings.custom.theModel`))}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(null)}},[e,i,n,t]);return z(`form`,{className:`settings-field custom-model-add`,onSubmit:e=>{e.preventDefault(),p(``)},children:[L(`label`,{className:`visually-hidden`,htmlFor:`custom-model-url`,children:t(`settings.custom.title`)}),L(`span`,{className:`settings-hint`,children:t(`settings.custom.hint`)}),z(`div`,{className:`settings-row`,children:[L(`input`,{id:`custom-model-url`,className:`settings-input`,type:`url`,inputMode:`url`,dir:`ltr`,spellCheck:!1,autoComplete:`off`,value:n,readOnly:c!==null,onChange:e=>{r(e.target.value),s(null),a(``),f.current=``},placeholder:`https://huggingface.co/unsloth/Qwen3-4B-Instruct-2507-GGUF`}),z(`button`,{type:`submit`,className:`btn-secondary`,disabled:c!==null||!n.trim(),children:[c===`check`?L(Za,{size:13,className:`spin`}):null,` `,t(`settings.custom.check`)]})]}),o&&(()=>{let e=L(`ul`,{className:`custom-model-checks`,"aria-label":t(`settings.custom.checks`),children:o.checks.map(e=>z(`li`,{className:e.ok?`is-ok`:`is-failed`,children:[e.ok?L(Yr,{size:13,"aria-label":t(`settings.custom.passed`)}):L(nc,{size:13,"aria-label":t(`settings.custom.failed`)}),z(`bdi`,{children:[L(`strong`,{children:e.label}),` — `,e.detail]})]},e.id))});return o.ok?z(`details`,{className:`custom-model-checks-summary`,children:[z(`summary`,{children:[L(Yr,{size:13,"aria-hidden":`true`}),` `,t(`settings.custom.allPassed`,{n:o.checks.length})]}),e]}):e})(),o&&o.warnings.length>0&&L(`ul`,{className:`custom-model-checks`,"aria-label":t(`settings.custom.warnings`),children:o.warnings.map(e=>z(`li`,{className:`is-warning`,children:[L(Ws,{size:13,"aria-label":t(`settings.custom.warning`)}),` `,L(`bdi`,{children:e})]},e))}),o&&o.variants.length>1&&z(`div`,{className:`settings-row`,children:[L(`label`,{className:`settings-hint`,htmlFor:`custom-model-quant`,children:t(`settings.custom.quantization`)}),L(`select`,{id:`custom-model-quant`,className:`settings-input`,value:i,onChange:e=>void p(e.target.value),disabled:c!==null,children:o.variants.map(e=>z(`option`,{value:e.file,children:[e.quant,` · `,e.size_gb,` GB`,e.fits?``:` · ${t.bare(`settings.custom.tooLarge`)}`]},e.file))})]}),o?.ok&&z(`div`,{className:`settings-row`,children:[z(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void m(),disabled:c!==null,children:[c===`add`?L(Za,{size:13,className:`spin`}):null,` `,t(`settings.custom.add`,{name:o.display_name??``})]}),L(`span`,{className:`settings-hint`,children:t(`settings.model.sizeDownload`,{size:`${o.size_gb} GB`})})]}),u&&L(sX,{message:u})]})}function lX(e){return e instanceof Error?e.message:String(e)}function uX(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function dX({downloadsSlot:e}){let t=R(),[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(null),[u,d]=(0,B.useState)(!1),[f,p]=(0,B.useState)(null),[m,h]=(0,B.useState)(!1),[g,_]=(0,B.useState)(null),[v,y]=(0,B.useState)(null),b=bl(e=>e.status),x=bl(e=>e.started),S=(0,B.useMemo)(()=>_l(b,x),[b,x]),C=bl(e=>e.error),w=bl(e=>e.refresh),T=bl(e=>e.enqueue),E=bl(e=>e.cancel),D=(0,B.useCallback)(async(e=!1)=>{a(null);try{let t=await En();r(t),s(n=>e||!n?oq(t):n)}catch(e){a(lX(e))}},[]);(0,B.useEffect)(()=>{D(!0),w(),(async()=>{try{_(await Xe()??null)}catch(e){y(lX(e))}})()},[D,w]);let O=(S?.models??[]).filter(e=>e.state===`ready`).map(e=>e.id).join(`,`),ee=(0,B.useRef)(O);(0,B.useEffect)(()=>{O!==ee.current&&(ee.current=O,D(!0))},[O,D]);let te=(0,B.useMemo)(()=>{let e={};for(let t of S?.models??[])e[t.id]=t;return e},[S]),ne=(0,B.useMemo)(()=>{let e={};for(let t of n?.catalog??[])e[t.id]=t.name;return e},[n]),re=(0,B.useMemo)(()=>n?oq(n):null,[n]),k=GK(n),ie=n&&o?dq(k,o).filter(e=>te[e.id]?.state!==`downloading`):[],ae=ie.reduce((e,t)=>e+(t.size_gb??0),0),A=!!n&&!!o&&!!re&&(!uX(o.ticked,re.ticked)||o.defaultChat!==re.defaultChat||ie.length>0),oe=(0,B.useCallback)(async(e,i)=>{if(!n||!o)return;if(p(null),!e){let e=mq(k,o).filter(e=>!e.downloaded||e.id===o.defaultChat);if(e.length>0&&e.every(e=>e.need_gb!=null)){l({kind:`no_fit`,models:e});return}}let a=pq(n,o);if(a&&!i)l({kind:`low_disk`,message:a.drop?t(`setup.summary.shortDrop`,{need:Sk(a.needGb),free:Sk(a.freeGb),drive:Oq(n.disk?.path??null)??t(`setup.summary.theDrive`),freeUp:Sk(a.freeUpGb),name:a.drop.name,saves:Sk(a.drop.size_gb??0)}):t(`setup.summary.short`,{need:Sk(a.needGb),free:Sk(a.freeGb),drive:Oq(n.disk?.path??null)??t(`setup.summary.theDrive`),freeUp:Sk(a.freeUpGb)})});else{d(!0);try{let i=n,a=!1;if(o.defaultChat&&o.defaultChat!==i.chat_model.id){a=!0;try{i=await me(o.defaultChat,e||m)}catch(e){let t=kt(e);if(t){l({kind:`server`,detail:t});return}throw e}}for(let e of hq(i,o))i=await Rn(e.id,e.skipped);let c=dq(GK(i),o).map(e=>e.id).filter(e=>te[e]?.state!==`downloading`);r(i),s({...o,defaultChat:i.chat_model.id});let u=null;if(a&&i.chat_model.downloaded)try{await zc.getState().select(i.chat_model.id)}catch(e){u=lX(e),zc.getState().refresh()}else zc.getState().refresh();c.length&&await T(c,{acknowledgeLowDisk:!0}),p(u===null?{ok:!0,text:t(`settings.models.applied`)}:{ok:!1,text:t(`settings.models.appliedNotSwitched`,{reason:u})})}catch(e){p({ok:!1,text:lX(e)})}finally{d(!1)}}},[n,o,k,m,te,T,t]),se=(0,B.useCallback)(async e=>{l(null),d(!0),p(null);try{let n=await Oe(e.id);bc(),r(n),s(oq(n)),p({ok:!0,text:t(`settings.models.removed`,{name:e.name,size:Sk(n.freed_gb)})})}catch(e){p({ok:!1,text:lX(e)})}finally{d(!1)}},[t]),ce=(0,B.useCallback)((e,t)=>{(async()=>{try{t===`verify`&&await Oe(e),await T([e])}catch(e){p({ok:!1,text:lX(e)})}})()},[T]),le=!!S&&(S.models?.length??0)>0&&(_J(S)||S.models.some(e=>e.state!==`skipped`))&&S&&z(`section`,{className:`settings-field models-pane-section`,"aria-labelledby":`settings-downloads-title`,children:[L(`span`,{className:`settings-label`,id:`settings-downloads-title`,children:t(`settings.models.downloads`)}),L(bJ,{status:S,names:ne,freeGb:n?.disk?.free_gb??null,onCancel:()=>void E(),onRetry:ce,onResume:e=>void T([e]),onResumeAll:()=>void T((S.models??[]).filter(e=>e.state===`cancelled`).map(e=>e.id))}),C&&L(`p`,{className:`settings-error`,role:`alert`,children:C})]});return z(P.Fragment,{children:[L(zY,{title:t(`settings.models.manage`),hint:t(`settings.models.manageHint`),forceOpen:!!i||f?.ok===!1,children:z(`section`,{className:`settings-field models-pane-section`,"aria-labelledby":`settings-models-title`,children:[L(`span`,{className:`visually-hidden`,id:`settings-models-title`,children:t(`settings.models.title`)}),L(`p`,{className:`settings-hint`,children:t(`settings.models.lede`)}),i&&L(sX,{message:i}),n&&!n.lemonade.reachable&&L(`p`,{className:`settings-hint`,children:t(`settings.models.unavailable`)}),!n&&!i&&z(`p`,{className:`settings-hint`,children:[L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,t(`setup.models.loading`)]}),n&&n.lemonade.reachable&&o&&z(P.Fragment,{children:[L(Aq,{plan:n,selection:o,onToggle:(e,t)=>s(cq(o,k,e,t)),onDefaultChat:e=>s(lq(o,k,e)),labelledBy:`settings-models-title`,place:`settings`,disabled:u,progress:te,rowActions:e=>e.downloaded&&e.id!==o.defaultChat?L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>l({kind:`remove`,entry:e}),disabled:u||te[e.id]?.state===`downloading`,"aria-label":t(`settings.models.removeAria`,{name:e.name}),children:t(`settings.models.remove`)}):null}),L(Dq,{plan:n,selection:o}),L(`div`,{className:`models-apply`,children:z(`button`,{type:`button`,className:`btn-primary`,disabled:!A||u,onClick:()=>void oe(!1,!1),children:[u&&L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),u?t(`settings.models.applying`):ie.length>0?t(`settings.models.applyDownload`,{size:Sk(Math.round(ae*10)/10)}):t(`settings.models.apply`)]})})]}),f?.ok&&L(`p`,{className:`settings-ok`,role:`status`,children:f.text}),f&&!f.ok&&L(sX,{message:f.text})]})}),(g?.applies||v&&!tX(v))&&L(zY,{title:t(`gpu.settingsTitle`),titleId:`settings-gpu-title`,defaultOpen:!!g?.pending||!!v,children:z(`section`,{className:`settings-field models-pane-section`,"aria-labelledby":`settings-gpu-title`,children:[v&&L(`p`,{className:`settings-error`,role:`alert`,children:v}),g?.applies&&L(Yq,{status:g,onStatus:_,mode:`settings`,names:ne,headingId:`settings-gpu-title`})]})}),e?(0,mM.createPortal)(le,e):e===void 0&&le,c?.kind===`remove`&&L(Bq,{title:t(`settings.models.removeTitle`,{name:c.entry.name}),confirmLabel:t(`settings.models.removeConfirm`),cancelLabel:t(`settings.models.keep`),danger:!0,onConfirm:()=>void se(c.entry),onCancel:()=>l(null),children:L(`p`,{children:KK(c.entry)?t(`settings.models.removeVision`,{size:Sk(c.entry.full_size_gb??0)}):t(`settings.models.removeBody`,{size:Sk(c.entry.full_size_gb??0)})})}),c?.kind===`no_fit`&&L(Bq,{title:c.models.length===1?t(`setup.confirm.noFitOne`,{name:c.models[0].name}):t(`setup.confirm.noFitMany`),confirmLabel:t(`setup.confirm.downloadAnyway`),cancelLabel:t(`setup.confirm.pickSmaller`),onConfirm:()=>{l(null),h(!0),oe(!0,!1)},onCancel:()=>l(null),children:c.models.map(e=>z(`p`,{children:[L(`bdi`,{children:e.name}),`: `,wq(e,t)]},e.id))}),c?.kind===`low_disk`&&L(Bq,{title:t(`setup.confirm.lowDiskTitle`),confirmLabel:t(`setup.confirm.downloadAnyway`),cancelLabel:t(`setup.confirm.changeModels`),onConfirm:()=>{l(null),oe(!0,!0)},onCancel:()=>l(null),children:L(`p`,{children:c.message})}),c?.kind===`server`&&L(Bq,{title:t(`setup.confirm.noFitServerTitle`),confirmLabel:t(`setup.confirm.useAnyway`),cancelLabel:t(`setup.confirm.changeModels`),onConfirm:()=>{l(null),h(!0),oe(!0,!1)},onCancel:()=>l(null),children:L(`p`,{children:c.detail.message})})]})}var fX=`auto`;function pX({model:e}){let t=R(),[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(null);(0,B.useEffect)(()=>{r(null),a(null),l(null),ge(e).then(r).catch(e=>a(e instanceof Error?e.message:String(e)))},[e]);let u=(0,B.useCallback)(async n=>{s(!0),a(null),l(null);try{let i=await h(e,n===fX?null:Number(n));r(i);let a={name:i.display_name,size:i.chosen?tl(i.chosen):We(`settings.ctx.automaticSize`)},o=i.reload?.reason;i.reload?.started?l(t(`settings.ctx.reloading`,a)):l(o===`already_loaded`?t(`settings.ctx.alreadyLoaded`,a):o===`warm_up`?t(`settings.ctx.warmUp`,a):o===`busy`?t(`settings.ctx.busy`,a):o===`not_gaias_server`?t(`settings.ctx.ownServer`,a):t(o===`restarting`?`settings.ctx.restarting`:`settings.ctx.nextLoad`))}catch(e){a(e instanceof Error?e.message:String(e))}finally{s(!1)}},[e,t]);if(i&&!n)return tX(i)?L(`p`,{className:`settings-hint`,children:t(`settings.ctx.serverDown`)}):L(`p`,{className:`settings-error`,role:`alert`,children:i});if(!n)return z(`p`,{className:`settings-hint`,children:[L(Za,{size:13,className:`spin`}),` `,t(`settings.ctx.checking`)]});let d=n.chosen==null?fX:String(n.chosen),f=n.chosen!=null&&n.loaded_ctx!=null&&n.loaded_ctx!==n.chosen;return z(P.Fragment,{children:[z(`div`,{className:`model-in-use-field`,children:[L(`label`,{className:`settings-label`,htmlFor:`ctx-size`,children:t(`settings.ctx.label`)}),z(`select`,{id:`ctx-size`,className:`settings-input`,value:d,onChange:e=>void u(e.target.value),disabled:o||n.options.length===0,children:[L(`option`,{value:fX,children:n.automatic?t.bare(`settings.ctx.automaticAt`,{size:tl(n.automatic)}):t.bare(`settings.ctx.automatic`)}),n.options.map(e=>L(`option`,{value:String(e),children:t.bare(`settings.ctx.tokens`,{size:tl(e)})},e))]})]}),n.note&&L(`span`,{className:`settings-hint`,children:L(`bdi`,{children:n.note})}),!n.note&&!!n.max_fit&&z(`details`,{className:`settings-more`,children:[z(`summary`,{children:[L($r,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,t(`settings.ctx.about`)]}),L(`span`,{className:`settings-hint`,children:t(`settings.ctx.explain`,{size:tl(n.max_fit),name:n.display_name,memory:n.memory_source})})]}),f&&L(`span`,{className:`settings-hint`,children:t(`settings.ctx.loadedAt`,{size:tl(n.loaded_ctx)})}),o&&z(`span`,{className:`settings-hint`,children:[L(Za,{size:13,className:`spin`}),` `,t(`settings.ctx.applying`)]}),c&&L(`p`,{className:`settings-ok`,role:`status`,children:c}),i&&L(`p`,{className:`settings-error`,role:`alert`,children:i})]})}function mX({row:e,providerName:t,choices:n,labels:r,disabled:i,onSwitch:a}){let o=R(),s=zc(e=>e.active),c=zc(e=>e.error),l=s?.model??null,u=!!s?.remote,d=n.some(e=>Hc(l,e.id)),f=s?.downloaded??e?.downloaded,p=u?null:e?.state===`loaded`?o(`settings.model.loaded`):f===!0?o(`settings.model.downloaded`):f===!1?o(`settings.model.notDownloaded`):null,m=e?.placement?.device;return z(`section`,{className:`settings-card model-in-use`,"aria-label":o(`settings.model.inUseTitle`),children:[L(`span`,{className:`model-in-use-label`,children:o(`settings.model.inUseTitle`)}),l?L(`bdi`,{className:`model-in-use-name`,title:l,children:e?.display_name||s?.display_name||Uc(l)}):s||c?L(`span`,{className:`settings-hint`,children:o(`settings.model.noneInUse`)}):L(`span`,{className:`settings-hint`,children:o(`settings.loading`)}),s?.config_error&&L(`p`,{className:`settings-error`,role:`alert`,children:L(`bdi`,{children:s.config_error})}),l&&!u&&e?.available===!1&&L(`p`,{className:`settings-error`,role:`alert`,children:o(`settings.model.inUseCantRun`)}),l&&z(`span`,{className:`model-chips`,children:[u&&L(`span`,{className:`model-badge is-device`,children:o(`settings.model.cloud`)}),u&&t&&L(`bdi`,{className:`model-badge is-ready`,children:t}),m&&L(`span`,{className:`model-badge is-device`,children:m.toUpperCase()}),p&&L(`span`,{className:`model-badge ${e?.state===`loaded`?`is-loaded`:`is-ready`}`,children:p}),e?.fits===!0&&L(`span`,{className:`model-badge is-fit`,children:o(`settings.model.fits`)}),!!e?.size_gb&&z(`bdi`,{dir:`ltr`,className:`model-badge is-size`,children:[e.size_gb,` GB`]}),u&&!!e?.context_length&&L(`span`,{className:`model-badge is-ready`,children:o(`settings.model.contextChip`,{size:tl(e.context_length)})})]}),(n.length>1||n.length===1&&!d)&&z(`div`,{className:`model-in-use-field`,children:[L(`label`,{className:`settings-label`,htmlFor:`model-switch`,children:o(`settings.model.switch`)}),z(`select`,{id:`model-switch`,className:`settings-input`,value:d?n.find(e=>Hc(l,e.id))?.id:``,onChange:e=>a(e.target.value),disabled:i,children:[!d&&L(`option`,{value:``,disabled:!0,children:o.bare(`settings.model.switchPlaceholder`)}),n.map(e=>L(`option`,{value:e.id,children:r[e.id]},e.id))]})]}),l&&!u&&s?.downloaded!==!1&&L(pX,{model:l})]})}var hX=e=>new Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:0}).format(e),gX={"best overall, fastest":`settings.model.note.bestFastest`,cheapest:`settings.model.note.cheapest`,"most truthful":`settings.model.note.mostTruthful`},_X=/^(\d+\/\d+) tasks · quality ([\d.]+\/5) · (\$[\d.]+) per (\d+)-task run$/;function vX(e,t){let n=_X.exec(t);return e.compose(e=>e(`settings.model.measured`,{evidence:n?e(`settings.model.evidence`,{tasks:n[1],quality:n[2],cost:n[3],n:n[4]}):t}))}function yX({model:e,label:t,current:n,remote:r,busy:i,onUse:a,onDownload:o,onAskRemove:s,onNpuRecheck:c}){let l=R(),u=rl(e)?e.download_progress:null,d=e.placement?.label,f=l.compose(t=>[d&&(e.placement?.source===`expected`?t(`settings.model.expected`,{label:d}):d),e.size_gb?t(e.downloaded?`settings.model.sizeOnDisk`:`settings.model.sizeDownload`,{size:`${e.size_gb} GB`}):null,e.tokens_per_second?t(`settings.model.speed`,{speed:`${Math.round(e.tokens_per_second)} tok/s`}):null,!e.placement&&e.context_length?t(`settings.model.contextTokens`,{size:hX(e.context_length)}):null].filter(Boolean).join(` · `)),p=!!(e.display_name||f||e.evidence||e.custom&&e.source_url);return z(`li`,{className:`model-row${n?` is-current`:``}`,children:[z(`div`,{className:`model-row-text`,children:[L(`bdi`,{className:`model-row-name`,title:e.id,children:t}),z(`div`,{className:`model-chips`,children:[e.placement?.device&&L(`span`,{className:`model-badge is-device`,children:e.placement.device.toUpperCase()}),e.rank&&z(`span`,{className:`model-badge is-rank`,children:[z(`bdi`,{dir:`ltr`,children:[`#`,e.rank]}),` `,e.note&&(gX[e.note]?l(gX[e.note]):L(`bdi`,{children:e.note}))]}),e.state===`loaded`&&L(`span`,{className:`model-badge is-loaded`,children:l(`settings.model.loaded`)}),e.fits===!0&&e.available!==!1&&L(`span`,{className:`model-badge is-fit`,children:l(`settings.model.fits`)}),e.custom&&L(`span`,{className:`model-badge is-custom`,children:l(`settings.model.custom`)}),!!e.size_gb&&z(`bdi`,{dir:`ltr`,className:`model-badge is-size`,children:[e.size_gb,` GB`]}),p&&z(`details`,{className:`settings-more model-row-facts`,children:[z(`summary`,{children:[L($r,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,l(`settings.model.details`)]}),e.display_name&&L(`span`,{className:`model-row-meta`,children:L(`bdi`,{children:e.id})}),f&&L(`span`,{className:`model-row-meta`,children:f}),e.evidence&&L(`span`,{className:`model-row-meta`,children:vX(l,e.evidence)}),e.custom&&e.source_url&&L(`span`,{className:`model-row-meta`,children:l(`settings.model.from`,{url:e.source_url})})]})]}),r&&L(`span`,{className:`model-row-meta${e.price?``:` is-unknown-price`}`,children:OR(e.price,l)}),e.placement?.warning&&L(`span`,{className:`model-row-meta is-warning`,role:`alert`,children:L(`bdi`,{children:e.placement.warning})}),e.npu_problems?.length?L(BJ,{problems:e.npu_problems,disabled:i!==null,onRecheck:c,id:`npu-problems-${e.id}`}):e.unavailable_reason&&L(`span`,{className:`model-row-meta`,children:l(`settings.model.cantRun`,{reason:e.unavailable_reason})}),u&&L(`progress`,{max:100,value:u.percent,"aria-label":l(`settings.model.downloadingAria`,{name:t})})]}),z(`div`,{className:`model-row-actions`,children:[e.custom&&!n&&!u&&z(`button`,{type:`button`,className:`btn-secondary`,onClick:s,disabled:i!==null,"aria-label":l(`settings.models.removeAria`,{name:t}),children:[i===`rm:${e.id}`?L(Za,{size:13,className:`spin`}):null,l(`settings.models.remove`)]}),n&&e.available===!1?L(`span`,{className:`model-row-current is-blocked`,children:l(`settings.model.inUseBlocked`)}):n?z(`span`,{className:`model-row-current`,children:[L(Yr,{size:13,"aria-hidden":`true`}),` `,l(`settings.model.inUse`)]}):e.available===!1?null:u?z(`span`,{className:`model-row-current`,children:[L(Za,{size:13,className:`spin`}),` `,u.message?L(`bdi`,{children:u.message}):z(`bdi`,{dir:`ltr`,children:[Math.round(u.percent),`%`]})]}):e.downloaded?z(`button`,{type:`button`,className:`btn-secondary`,onClick:a,disabled:i!==null,"aria-label":l(`settings.model.useAria`,{name:t}),children:[i===e.id?L(Za,{size:13,className:`spin`}):null,` `,l(`settings.model.use`)]}):z(`button`,{type:`button`,className:`btn-secondary`,onClick:o,disabled:i!==null,"aria-label":l(`settings.model.downloadAria`,{name:t}),children:[i===`dl:${e.id}`?L(Za,{size:13,className:`spin`}):null,` `,l(`settings.model.download`)]})]})]})}function bX(){let e=R(),[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(``),[c,l]=(0,B.useState)(!1),u=(0,B.useCallback)(async e=>{l(!0),i(null);try{let t=await e();n(t),o(t.limit_usd==null?``:String(t.limit_usd))}catch(e){i(e instanceof Error?e.message:String(e))}finally{l(!1)}},[]);if((0,B.useEffect)(()=>{u(Dn)},[u]),!t)return r?L(`p`,{className:`settings-error`,role:`alert`,children:r}):z(`p`,{className:`settings-hint`,children:[L(Za,{size:13,className:`spin`}),` `,e(`settings.spend.loading`)]});let d=t.limit_usd,f=a.trim()===``?null:Number(a),p=f===null||Number.isFinite(f)&&f>0,m=f!==d;return z(`section`,{className:`settings-field spending`,"aria-label":e(`settings.spend.aria`),children:[L(`span`,{className:`settings-label`,children:e(`settings.spend.title`)}),z(`p`,{className:`spending-total`,children:[L(`bdi`,{dir:`ltr`,children:L(`strong`,{children:kR(t.total_usd)})}),d!=null&&z(P.Fragment,{children:[` `,e(`settings.spend.ofLimit`,{limit:kR(d)})]}),z(`span`,{className:`settings-hint`,children:[` · `,e.plural(`settings.spend.turns`,t.turns-t.unpriced_turns-t.unreported_turns)]})]}),t.unpriced_turns>0&&L(`p`,{className:`settings-hint`,children:e.plural(`settings.spend.unpriced`,t.unpriced_turns)}),t.unreported_turns>0&&L(`p`,{className:`settings-hint`,children:e.plural(`settings.spend.unreported`,t.unreported_turns)}),t.state===`near`&&z(`p`,{className:`spending-warning`,role:`status`,children:[L(Ws,{size:13,"aria-hidden":`true`}),` `,e(`settings.spend.near`)]}),t.state===`reached`&&z(`div`,{className:`spending-warning`,role:`alert`,children:[z(`p`,{children:[L(Ws,{size:13,"aria-hidden":`true`}),` `,e(`settings.spend.reached`)]}),L(`button`,{type:`button`,className:`btn-secondary`,disabled:c,onClick:()=>void u(In),children:e(`settings.spend.allow`)})]}),t.state===`allowed_over`&&L(`p`,{className:`settings-hint`,children:e(`settings.spend.allowed`)}),z(`form`,{className:`settings-row`,onSubmit:e=>{e.preventDefault(),p&&m&&u(()=>s(f))},children:[L(`label`,{className:`spending-limit-label`,htmlFor:`spend-limit`,children:e(`settings.spend.limit`)}),L(`input`,{id:`spend-limit`,className:`settings-input`,type:`number`,min:`0.01`,step:`0.01`,inputMode:`decimal`,placeholder:e.bare(`settings.spend.noLimit`),value:a,onChange:e=>o(e.target.value),"aria-invalid":!p}),z(`button`,{type:`submit`,className:`btn-secondary`,disabled:c||!p||!m,children:[c?L(Za,{size:13,className:`spin`}):null,` `,e(`settings.advanced.save`)]}),d!=null&&L(`button`,{type:`button`,className:`btn-secondary`,disabled:c,onClick:()=>void u(()=>s(null)),children:e(`settings.spend.removeLimit`)})]}),L(`span`,{className:`settings-hint`,children:e(`settings.spend.how`)}),r&&L(`p`,{className:`settings-error`,role:`alert`,children:r})]})}var xX=2e3;function SX(e,t){return e.key_source===`environment`?t(`settings.key.setIn`,{name:e.env_var??``}):`••••••••••••••••••••${e.key_hint?` ${e.key_hint}`:``}`}function CX(){let e=R(),t=zc(e=>e.active),n=zc(e=>e.select),r=zc(e=>e.refresh),i=zc(e=>e.rememberNames),a=N(e=>!!e.systemStatus&&QI(e.systemStatus)===`unresponsive`),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(null),u=N(e=>e.settingsProvider),[d,f]=(0,B.useState)(u??t?.provider??`local`),[m,h]=(0,B.useState)(null),[g,_]=(0,B.useState)(null),[v,y]=(0,B.useState)(``),[b,x]=(0,B.useState)(!1),[S,C]=(0,B.useState)(``),[w,T]=(0,B.useState)(!1),[E,D]=(0,B.useState)(!1),[O,ee]=(0,B.useState)({base_url:``,auth_header_name:``,auth_header_prefix:``}),[te,ne]=(0,B.useState)(null),[re,k]=(0,B.useState)(null),[ie,ae]=(0,B.useState)(null),[A,oe]=(0,B.useState)(null),[se,ce]=(0,B.useState)(!1),[le,ue]=(0,B.useState)(null),[de,fe]=(0,B.useState)(null),pe=(0,B.useRef)(d);pe.current=d;let me=(0,B.useRef)(!0);(0,B.useEffect)(()=>(me.current=!0,()=>{me.current=!1}),[]);let j=o?.find(e=>e.id===d)??null,he=e=>e?.network?.reachable===!1,M=e=>!!e?.blocked,ge=!!j&&!M(j)&&(!j.remote||!!j.models_discovered),_e=(0,B.useCallback)(async()=>{l(null);try{let e=await gt();s(e.providers),e.lemonade_error&&l(e.lemonade_error)}catch(e){l(e instanceof Error?e.message:String(e))}},[]),ve=(0,B.useCallback)(async()=>{try{await Fe()}catch(e){l(e instanceof Error?e.message:String(e));return}await _e()},[_e]),ye=(0,B.useCallback)(async(t,n=!1)=>{n||(h(null),_(null));try{let n=await Gt(t);i(n.models),h(n.models),k(n.memory_gb?`${n.memory_gb} GB (${n.memory_source})`:n.capacity_error??null),n.blocked&&_(e(`settings.privacy.localOnlyBlocked`))}catch(e){_(e instanceof Error?e.message:String(e))}},[i,e]);(0,B.useEffect)(()=>{_e()},[_e]);let be=!!o?.some(e=>e.key_state===`waiting_for_os_permission`);(0,B.useEffect)(()=>{if(!be)return;let e=setInterval(()=>{_e()},xX);return()=>clearInterval(e)},[be,_e]);let xe=t?.provider;(0,B.useEffect)(()=>{xe&&!u&&f(xe)},[xe,u]),(0,B.useEffect)(()=>{C(``),T(!1),D(!1),ae(null),y(``),x(!1),ce(!1)},[d]),(0,B.useEffect)(()=>{ge?ye(d):h(null)},[d,ge,ye]);let Se=(0,B.useCallback)(async()=>{if(j){ne(`connect`),ae(null);try{let t=d===`amd`?{api_key:S||void 0,...Object.fromEntries(Object.entries(O).filter(([,e])=>e!==``))}:{api_key:S||void 0},n=()=>!me.current||pe.current!==d,r=await ln(d,t,e=>{n()||ae({ok:!0,text:e})},n);if(n())return;C(``),T(!1),ae({ok:!0,text:r.remember_error?e(`settings.key.sessionOnly`,{reason:r.remember_error}):r.known_models?e(`settings.key.knownModels`,{name:j.name}):r.remembered?e(`settings.key.kept`):e(`settings.key.connectedDone`)}),await _e()}catch(e){me.current&&pe.current===d&&ae({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{me.current&&ne(null)}}},[O,d,S,_e,j,e]),Ce=(0,B.useCallback)(async()=>{ne(`forget`),D(!1),ae(null);try{await ze(d),ae({ok:!0,text:e(`settings.key.cleared`)}),await _e(),await r()}catch(e){ae({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{ne(null)}},[d,_e,r,e]),we=(0,B.useCallback)(async t=>{ne(t),ae(null);try{await n(t),ae({ok:!0,text:e(`settings.model.switched`,{name:Uc(t)})}),await ye(d,!0)}catch(e){ae({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{ne(null)}},[d,ye,n,e]),Te=(0,B.useCallback)(async e=>{ne(`dl:${e}`),ae(null),ce(!1);try{await p(e),await ye(`local`,!0)}catch(e){ae({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{ne(null)}},[ye]),Ee=(0,B.useCallback)(async t=>{let n=zc.getState().active?.model;ne(`rm:${t}`),ae(null);try{let r=await nr(t);oe(null);let i=r.cleared.includes(`last_model`)?`settings.model.removedLast`:r.cleared.includes(`default_model`)?`settings.model.removedDefault`:`settings.model.removed`;ae({ok:!0,text:e(i,{name:r.display_name})}),await ye(`local`,!0),await Bc(n)}catch(e){ae({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{ne(null)}},[ye,e]),De=(0,B.useCallback)(async t=>{ae({ok:!0,text:e(`settings.model.added`,{name:t})}),ce(!0),await ye(`local`,!0)},[ye,e]),Oe=!!m?.some(rl);(0,B.useEffect)(()=>{if(Oe)return()=>{r()}},[Oe,r]),(0,B.useEffect)(()=>{if(d!==`local`||!Oe)return;let e=setInterval(()=>{ye(`local`,!0)},xX);return()=>clearInterval(e)},[Oe,d,ye]);let ke=t?.model,Ae=m?.find(e=>Hc(ke,e.id));(0,B.useEffect)(()=>{Ae&&ue(Ae)},[Ae]);let je=(0,B.useMemo)(()=>{let e=v.trim().toLowerCase();return(m??[]).filter(t=>!e||t.id.toLowerCase().includes(e)||(t.display_name??``).toLowerCase().includes(e))},[m,v]),Me=je.filter(e=>e.available!==!1),Ne=d===`fireworks`&&!b&&!v.trim()&&Me.some(e=>e.rank!==null),Pe=e=>e.rank!==null||e.id===t?.model,Ie=Ne?Me.filter(Pe):Me,Le=Ne?Me.filter(e=>!Pe(e)):[],Re=je.filter(e=>e.available===!1),Be=Zc(m??[]),Ve=!!v.trim(),He=e=>Hc(t?.model,e.id),Ue=j?.id===`local`,We=Ie.filter(e=>e.downloaded).sort((e,t)=>Number(He(t))-Number(He(e))),Ge=Ie.filter(e=>!e.downloaded),Ke=(m??[]).filter(e=>e.available!==!1&&e.downloaded),qe=Ke.filter(Pe),Je=A?(m??[]).find(e=>e.id===A)??null:null,Ye=d===`fireworks`&&qe.some(e=>e.rank!==null)?qe:Ke,Xe=e=>L(yX,{model:e,label:Be[e.id],current:He(e),remote:!!j?.remote,busy:te,onUse:()=>void we(e.id),onDownload:()=>void Te(e.id),onAskRemove:()=>oe(e.id),onNpuRecheck:()=>void ye(d,!0)},e.id);return z(`div`,{className:`settings-pane`,children:[L(`h2`,{className:`settings-pane-title`,children:e(`settings.section.model`)}),L(IJ,{inSettings:!0}),L(mX,{row:Ae??(Hc(le?.id,t?.model)?le:null),providerName:t?.provider_name??null,choices:ge?Ye:[],labels:Be,disabled:te!==null,onSwitch:e=>void we(e)}),L(jB,{className:`provider-tabs`,"aria-label":e(`settings.model.whereRuns`),children:(o??[{id:`local`,name:`Local`,remote:!1}]).map(t=>z(`button`,{type:`button`,role:`radio`,"aria-checked":d===t.id,className:`provider-tab${d===t.id?` is-active`:``}${he(t)||M(t)?` is-disabled`:``}`,onClick:()=>f(t.id),disabled:(he(t)||M(t))&&d!==t.id,title:M(t)?e(`settings.privacy.localOnlyBlocked`):he(t)?e(`setup.key.gatewayOff`):void 0,children:[t.remote?L(xi,{size:14,"aria-hidden":`true`}):L(ki,{size:14,"aria-hidden":`true`}),L(`span`,{children:jR(e,t)}),t.remote&&t.models_discovered&&L(`span`,{className:`provider-tab-dot`,"aria-label":e(`settings.key.connectedDot`)})]},t.id))}),!o&&!c&&z(`p`,{className:`settings-hint`,role:`status`,children:[L(Za,{size:13,className:`spin`}),` `,e(a?`settings.model.waitingServer`:`settings.loading`)]}),c&&L(sX,{message:c,onRetry:()=>{_e(),ye(d)}}),j&&z(`section`,{className:`settings-card`,"aria-label":jR(e,j),children:[j.remote&&L(`p`,{className:`settings-note`,children:L(`bdi`,{children:MR(e,j)})}),z(`details`,{className:`settings-more`,children:[z(`summary`,{children:[L($r,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,e(`settings.model.howItWorks`)]}),L(`p`,{className:`settings-hint`,children:e(`settings.model.lede`)}),Ue&&L(`p`,{className:`settings-hint`,children:L(`bdi`,{children:MR(e,j)})}),Ue&&L(`p`,{className:`settings-hint`,children:e(`settings.model.devices`)}),Ue&&re&&L(`p`,{className:`settings-hint`,children:e(`settings.model.memory`,{memory:re})})]}),j.remote&&!ge&&z(`div`,{className:`settings-field`,children:[L(`span`,{className:`settings-label`,children:e(`settings.model.prices`)}),L(RK,{provider:j.id})]}),M(j)&&L(`div`,{className:`settings-field`,children:L(`p`,{className:`settings-error`,role:`alert`,children:e(`settings.privacy.localOnlyBlocked`)})}),he(j)&&z(`div`,{className:`settings-field`,children:[L(`p`,{className:`settings-error`,role:`alert`,children:j.network?.detail}),L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void _e(),children:e(`settings.key.checkAgain`)})]}),j.remote&&!he(j)&&!M(j)&&z(`form`,{className:`settings-field`,"data-settings-target":`cloud-key`,onSubmit:e=>{e.preventDefault(),Se()},children:[z(`div`,{className:`settings-row settings-row-between`,children:[L(`span`,{className:`settings-label`,children:e(`settings.key.title`)}),j.key_source&&L(`span`,{className:`settings-key-status ${ge?`settings-ok`:`settings-error`}`,children:e(ge?`settings.key.connected`:`settings.key.notConnected`)})]}),!j.key_source&&j.key_state===`store_locked`&&z(`span`,{className:`settings-hint`,role:`status`,children:[e(`settings.key.storeLocked`),` `,L(`button`,{type:`button`,className:`link-btn`,onClick:()=>void ve(),children:e(`settings.key.unlockAgain`)})]}),!j.key_source&&j.key_state!==`store_locked`&&L(`span`,{className:`settings-hint`,children:j.key_state===`waiting_for_os_permission`?j.key_message??e(`settings.key.waitingOs`):e(`settings.key.none`)}),j.id===`amd`&&(!j.key_source||w)&&z(`div`,{className:`settings-grid`,children:[L(`input`,{className:`settings-input`,placeholder:e(`settings.key.gatewayPlaceholder`),value:O.base_url,onChange:e=>ee({...O,base_url:e.target.value}),"aria-label":e(`settings.key.gatewayUrl`)}),L(`input`,{className:`settings-input`,placeholder:e(`settings.key.headerPlaceholder`),value:O.auth_header_name,onChange:e=>ee({...O,auth_header_name:e.target.value}),"aria-label":e(`settings.key.headerName`)})]}),j.key_source&&!w?z(`div`,{className:`settings-row`,children:[L(`input`,{className:`settings-input settings-key-masked`,readOnly:!0,value:SX(j,e),"aria-label":e(`settings.key.savedAria`,{name:j.name})}),!ge&&z(`button`,{type:`submit`,className:`btn-primary`,disabled:te!==null,children:[te===`connect`?L(Za,{size:13,className:`spin`}):null,e(`settings.key.reconnect`)]}),(j.key_source!==`environment`||j.key_from_gaia_env)&&z(P.Fragment,{children:[L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>T(!0),disabled:te!==null,children:e(`settings.key.replace`)}),j.key_source!==`environment`&&L(`button`,{type:`button`,className:`btn-secondary settings-key-remove`,onClick:()=>D(!0),disabled:te!==null,"aria-label":e(`settings.key.remove`),title:e(`settings.key.remove`),children:L(Hs,{size:14,"aria-hidden":`true`})})]})]}):z(`div`,{className:`settings-row`,children:[L(`input`,{className:`settings-input`,type:`password`,autoComplete:`off`,spellCheck:!1,autoFocus:w,value:S,onChange:e=>C(e.target.value),placeholder:e(w?`settings.key.pasteNew`:`settings.key.paste`),"aria-label":e(`settings.key.fieldAria`,{name:j.name})}),z(`button`,{type:`submit`,className:`btn-primary`,disabled:te!==null||!S,children:[te===`connect`?L(Za,{size:13,className:`spin`}):null,e(w?`settings.key.save`:`settings.key.connect`)]}),w&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{C(``),T(!1)},disabled:te!==null,children:e(`settings.key.cancel`)})]}),j.key_source&&!ge&&!j.error&&!w&&L(`p`,{className:`settings-hint`,children:e(`settings.key.notConnectedHint`,{name:j.name})}),j.error&&L(`p`,{className:`settings-error`,role:`alert`,children:j.error})]}),ie?.ok&&L(`p`,{className:`settings-ok`,role:`status`,children:ie.text}),ie&&!ie.ok&&L(sX,{message:ie.text}),j.known_models&&L(`p`,{className:`settings-hint`,role:`status`,children:e(`settings.key.knownList`,{name:j.name})}),Ue&&L(`div`,{className:`models-downloads-slot`,ref:fe}),ge&&z(`div`,{className:`settings-field`,children:[L(`span`,{className:`settings-label`,children:e(`settings.model.models`)}),(m?.length??0)>6&&L(`input`,{className:`settings-input`,type:`search`,value:v,onChange:e=>y(e.target.value),placeholder:e(`settings.model.search`),"aria-label":e(`settings.model.search`)}),g&&!(c&&tX(g))&&L(sX,{message:g}),!m&&!g&&z(`p`,{className:`settings-hint`,children:[L(Za,{size:13,className:`spin`}),` `,e(`settings.loading`)]}),m&&je.length===0&&!g&&L(`p`,{className:`settings-hint`,children:e(Ve||!Ue?`settings.model.noMatch`:`settings.model.noModels`)}),Ue?z(P.Fragment,{children:[We.length>0&&L(zY,{title:e(`settings.model.groupDownloaded`),count:We.length,defaultOpen:!0,forceOpen:Ve,targetId:`models-on-pc`,children:L(`ul`,{className:`model-list`,children:We.map(Xe)})}),Ge.length>0&&L(zY,{title:e(`settings.model.groupAvailable`),count:Ge.length,defaultOpen:We.length===0,forceOpen:Ve||se||Ge.some(rl),children:L(`ul`,{className:`model-list`,children:Ge.map(Xe)})})]}):L(`ul`,{className:`model-list`,children:Ie.map(Xe)}),Ne&&Le.length>0&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>x(!0),children:e(`settings.model.showAll`)}),d===`fireworks`&&b&&!Ve&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>x(!1),children:e(`settings.model.showRecommended`)}),Re.length>0&&L(zY,{title:e(`settings.model.groupUnavailable`),count:Re.length,forceOpen:Ve,children:L(`ul`,{className:`model-list`,children:Re.map(Xe)})})]}),Ue&&ge&&L(zY,{title:e(`settings.custom.title`),children:L(cX,{onAdded:e=>void De(e)})}),Ue&&ge&&L(dX,{downloadsSlot:de}),j.remote&&L(bX,{})]}),Je&&L(Bq,{title:e(`settings.models.removeTitle`,{name:Be[Je.id]??Je.id}),confirmLabel:Je.downloaded?e(`settings.model.removeDownload`):e(`settings.models.remove`),cancelLabel:e(`settings.models.keep`),danger:!0,onConfirm:()=>{oe(null),Ee(Je.id)},onCancel:()=>oe(null),children:Je.downloaded&&L(`p`,{children:e(`settings.model.removeDownloadBody`)})}),E&&j&&L(Bq,{title:e(`settings.key.removeAsk`),confirmLabel:e(`settings.key.remove`),cancelLabel:e(`settings.models.keep`),danger:!0,onConfirm:()=>void Ce(),onCancel:()=>D(!1),children:L(`p`,{children:e(`settings.key.removeBody`,{name:j.name})})})]})}async function wX(){return Ct(`GET`,`/images/settings`)}async function TX(e){return Ct(`PUT`,`/images/settings`,e)}var EX=[4,8,12,20,30,50],DX=e=>`${e}`;function OX(e){return e instanceof Vn?e.detail||e.message:String(e)}function kX(){let e=R(),t=N(e=>e.openSettings);Vc();let[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(!1),u=()=>{a(null),wX().then(r).catch(e=>a({unreachable:e instanceof Vn&&e.httpStatus===503,detail:OX(e)}))};(0,B.useEffect)(u,[]);let d=e=>{l(!0),s(null),TX(e).then(r).catch(e=>s(OX(e))).finally(()=>l(!1))},f=L(`h2`,{className:`settings-pane-title`,children:e(`settings.section.images`)});if(i)return z(`div`,{className:`settings-pane`,children:[f,i.unreachable?z(P.Fragment,{children:[L(`p`,{className:`settings-error`,role:`alert`,children:e(`images.settings.unreachable`)}),L(`p`,{className:`settings-hint`,children:i.detail}),L(`button`,{type:`button`,className:`btn-secondary`,onClick:u,children:e(`images.settings.retry`)})]}):L(`p`,{className:`settings-error`,role:`alert`,children:e(`images.settings.loadFailed`,{reason:i.detail})})]});if(!n)return z(`p`,{className:`settings-hint`,children:[L(Za,{size:13,className:`spin`}),` `,e(`settings.loading`)]});let p=n.models.find(e=>e.id===n.model),m=p?[...new Set([...EX,p.default_steps,...n.steps?[n.steps]:[]])].filter(e=>e<=n.max_steps).sort((e,t)=>e-t):[];return z(`div`,{className:`settings-pane`,children:[f,L(`p`,{className:`settings-pane-lede`,children:e(`images.settings.lede`)}),!n.chat_model_creates_images&&z(`div`,{className:`settings-notice`,role:`status`,children:[L(`p`,{children:e(`images.settings.chatModelCannot`,{model:Uc(n.chat_model)})}),L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>t(`model`),children:e(`images.settings.chooseChatModel`)})]}),!n.model_available&&L(`p`,{className:`settings-error`,role:`alert`,children:e(`images.settings.modelGone`,{model:n.model})}),n.models.length===0?L(`p`,{className:`settings-hint`,children:e(`images.settings.noModels`)}):z(P.Fragment,{children:[z(`div`,{className:`settings-field`,children:[L(`label`,{className:`settings-label`,htmlFor:`image-model`,children:e(`images.settings.model`)}),z(`select`,{id:`image-model`,className:`settings-input`,value:n.model_available?n.model:``,disabled:c,onChange:e=>d({model:e.target.value}),children:[!n.model_available&&L(`option`,{value:``,disabled:!0,children:n.model}),n.models.map(t=>L(`option`,{value:t.id,children:t.downloads_on_first_use?e.bare(`images.settings.downloadsOnFirstUse`,{model:t.id,size:DX(`${t.size_gb??`?`} GB`)}):t.id},t.id))]})]}),p&&z(P.Fragment,{children:[z(`div`,{className:`settings-field`,children:[L(`label`,{className:`settings-label`,htmlFor:`image-size`,children:e(`images.settings.size`)}),z(`select`,{id:`image-size`,className:`settings-input`,value:n.size??``,disabled:c,onChange:e=>d({size:e.target.value||null}),children:[L(`option`,{value:``,children:e.bare(`images.settings.automatic`,{value:DX(p.default_size)})}),p.sizes.map(e=>L(`option`,{value:e,children:DX(e)},e))]})]}),z(`div`,{className:`settings-field`,children:[L(`label`,{className:`settings-label`,htmlFor:`image-steps`,children:e(`images.settings.steps`)}),z(`select`,{id:`image-steps`,className:`settings-input`,value:n.steps??``,disabled:c,onChange:e=>d({steps:e.target.value?Number(e.target.value):null}),children:[L(`option`,{value:``,children:e.bare(`images.settings.automatic`,{value:DX(String(p.default_steps))})}),m.map(e=>L(`option`,{value:e,children:DX(String(e))},e))]}),L(`span`,{className:`settings-hint`,children:e(`images.settings.stepsHint`)})]})]})]}),L(`p`,{className:`settings-hint`,children:e(`images.settings.shared`)}),o&&L(`p`,{className:`settings-error`,role:`alert`,children:e(`images.settings.saveFailed`,{reason:o})})]})}function AX(){let e=R(),t=N(e=>e.sessions),[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(null),u=(0,B.useCallback)(async()=>{l(null);try{let e=await nn();r(e.sessions),a(e.default_mode),N.getState().setDefaultPermissionMode(e.default_mode)}catch(e){l(e instanceof Error?e.message:String(e))}},[]);(0,B.useEffect)(()=>{u()},[u]);let d=(0,B.useCallback)(async e=>{l(null);try{await e(),await u()}catch(e){l(e instanceof Error?e.message:String(e))}},[u]),f=(0,B.useCallback)(async e=>{s(!1),await d(()=>cn(e))},[d]),p=()=>{i===`full_access`?f(`ask`):s(e=>!e)},m=e=>t.find(t=>t.id===e)?.title??e;return z(`div`,{className:`settings-pane`,children:[L(`h2`,{className:`settings-pane-title`,children:e(`settings.section.permissions`)}),L(`p`,{className:`settings-pane-lede`,children:e(`settings.permissions.lede`)}),z(`details`,{className:`settings-more`,children:[z(`summary`,{children:[L($r,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,e(`settings.model.howItWorks`)]}),L(`p`,{className:`settings-hint`,children:e(`settings.permissions.perChat`)})]}),z(`section`,{className:`settings-card`,"aria-label":e(`settings.permissions.newChats`),children:[z(`label`,{className:`setting-row`,children:[L(`span`,{className:`settings-label`,children:e(`settings.permissions.fullAccess`)}),z(`span`,{className:`toggle-switch`,children:[L(`input`,{type:`checkbox`,checked:i===`full_access`,onChange:p,disabled:i===null,"aria-label":e(`settings.permissions.fullAccess`)}),L(`span`,{className:`toggle-track`})]})]}),L(`p`,{className:`settings-hint`,children:e(i===`full_access`?`settings.permissions.on`:`settings.permissions.off`)}),o&&z(`div`,{className:`settings-warning`,role:`alert`,children:[L(`p`,{children:e(`settings.permissions.warning`)}),z(`div`,{className:`settings-row`,children:[L(`button`,{type:`button`,className:`btn-danger`,onClick:()=>void f(`full_access`),children:e(`settings.permissions.turnOn`)}),L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>s(!1),children:e(`settings.key.cancel`)})]})]})]}),c&&L(`p`,{className:`settings-error`,role:`alert`,children:c}),n&&n.length===0&&L(`p`,{className:`settings-hint`,children:e(`settings.permissions.none`)}),!!n?.length&&L(zY,{title:e(`settings.permissions.chats`),count:n.length,defaultOpen:!0,children:n.map(t=>z(`section`,{className:`settings-field permission-chat`,"aria-label":m(t.session_id),children:[z(`div`,{className:`settings-row settings-row-between`,children:[L(`bdi`,{className:`settings-label`,children:m(t.session_id)}),t.mode===`full_access`&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>d(async()=>{let e=(await Vt(t.session_id,`ask`)).mode;nz(t.session_id,e)}),children:e(`settings.permissions.turnOff`)})]}),t.grants.length>0&&L(`ul`,{className:`grant-list`,children:t.grants.map(n=>z(`li`,{className:`grant-row`,children:[L(`code`,{children:n.label}),L(`button`,{type:`button`,className:`link-btn`,onClick:()=>d(()=>It(t.session_id,n.key)),"aria-label":e(`settings.permissions.revokeAria`,{name:n.label}),children:e(`settings.permissions.revoke`)})]},n.key))}),t.grants.length>1&&L(`button`,{type:`button`,className:`link-btn`,onClick:()=>d(()=>It(t.session_id)),children:e(`settings.permissions.revokeAll`)})]},t.session_id))})]})}var jX=(e,t)=>!e.error&&(!e.installed||e.update)&&(t||!e.has_code);function MX(e,t){let n=e.added.filter(e=>e.updated).map(e=>e.name),r=e.added.filter(e=>!e.updated).map(e=>e.name),i=(e,n)=>n.length>3?t(`settings.skills.link.${e}Count`,{n:n.length}):t(`settings.skills.link.${e}`,{names:n.join(`, `)});return[r.length?i(`added`,r):``,n.length?i(`updated`,n):``].filter(Boolean).join(` `)}function NX({onAdded:e}){let t=R(),[n,r]=(0,B.useState)(``),[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(null),[u,d]=(0,B.useState)(new Set),[f,p]=(0,B.useState)(!1),[m,h]=(0,B.useState)(null),[g,_]=(0,B.useState)([]);(0,B.useEffect)(()=>{let e=!1;return An().then(t=>{e||_(t.libraries)}).catch(n=>{e||s(t(`settings.skills.link.featuredFailed`,{error:aN(n,t)}))}),()=>{e=!0}},[t]);let v=async e=>{if(e.trim()){a(`preview`),s(null),l(null),h(null);try{let t=await dt(e.trim());l(t),d(new Set(t.skills.filter(e=>jX(e,!1)).map(e=>e.name)))}catch(e){s(aN(e,t))}finally{a(null)}}},y=async()=>{if(c&&u.size!==0){a(`add`),s(null);try{let t=await vn(c.link,[...u],f,c.pin);h(t),l(null),r(``),t.added.length&&e()}catch(e){s(aN(e,t))}finally{a(null)}}},b=e=>d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),x=e=>{if(p(e),!e&&c){let e=new Set(c.skills.filter(e=>e.has_code).map(e=>e.name));d(t=>new Set([...t].filter(t=>!e.has(t))))}},S=c?.skills.filter(e=>jX(e,f))??[],C=S.length>0&&S.every(e=>u.has(e.name)),w=c?.skills.some(e=>e.has_code&&!e.error)??!1;return z(`div`,{className:`settings-card skill-link`,children:[z(`div`,{className:`skill-link-top`,children:[L(`span`,{className:`settings-label`,children:t(`settings.skills.link.title`)}),g.map(e=>{let n=`settings.skills.link.featured.${e.id}`,a=fe(n);return L(`button`,{type:`button`,className:`btn-secondary skill-link-chip`,onClick:()=>{r(e.url),v(e.url)},disabled:i!==null,title:a?t(n):e.description,"aria-label":t(`settings.skills.link.getAria`,{name:e.name,description:a?We(n):e.description}),children:t(`settings.skills.link.get`,{name:e.name})},e.id)})]}),z(`form`,{className:`skill-link-form`,onSubmit:e=>{e.preventDefault(),v(n)},children:[L(`input`,{className:`settings-input`,type:`text`,inputMode:`url`,value:n,onChange:e=>r(e.target.value),onPaste:e=>{let t=e.clipboardData.getData(`text`).trim();t&&(e.preventDefault(),r(t),v(t))},placeholder:t.bare(`settings.skills.link.placeholder`),title:t(`settings.skills.link.hint`),"aria-label":t(`settings.skills.link.aria`),disabled:i!==null}),L(`button`,{type:`submit`,className:`btn-secondary`,disabled:!n.trim()||i!==null,children:i===`preview`?z(P.Fragment,{children:[L(Za,{size:13,className:`spin`}),` `,t(`settings.skills.link.reading`)]}):t(`settings.skills.link.read`)})]}),o&&L(`p`,{className:`settings-error`,role:`alert`,children:o}),c&&z(`div`,{className:`skill-link-preview`,children:[z(`details`,{className:`skill-link-warning`,role:`note`,children:[z(`summary`,{children:[L(Ws,{size:14,"aria-hidden":`true`}),t(`settings.skills.link.trust`)]}),L(`p`,{children:L(`bdi`,{children:c.warning})})]}),z(`div`,{className:`skill-link-head`,children:[L(`span`,{children:t(`settings.skills.link.found`,{n:c.skills.length,source:c.source})}),S.length>1&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>d(C?new Set:new Set(S.map(e=>e.name))),children:t(C?`settings.skills.link.none`:`settings.skills.link.all`)})]}),L(`ul`,{className:`skill-list skill-link-list`,children:c.skills.map(e=>{let n=jX(e,f),r=e.error?e.verdict===`BLOCK`?t(`settings.skills.link.tagBlocked`):t(`settings.skills.link.tagUnreadable`):e.installed&&!e.update?t(`settings.skills.link.tagElsewhere`):e.update?t(`settings.skills.link.tagUpdate`):null,i=e.error??(e.installed&&!e.update?t(`settings.skills.link.whyElsewhere`):e.update?t(`settings.skills.link.whyUpdate`):null),a=!!i||e.findings.length>0||e.has_code&&!f;return L(`li`,{className:`skill-row`,children:z(`label`,{className:`skill-link-pick`,children:[L(`input`,{type:`checkbox`,checked:n&&u.has(e.name),disabled:!n,onChange:()=>b(e.name),"aria-label":t(`settings.skills.link.addAria`,{name:e.name})}),z(`span`,{className:`skill-row-text`,children:[z(`span`,{className:`skill-row-name`,children:[e.name,r&&L(`span`,{className:`skill-link-tag${e.error?` is-bad`:``}`,children:r}),e.has_code&&L(`span`,{className:`skill-link-tag`,children:t(`settings.skills.link.tagCode`)}),e.verdict===`REVIEW`&&L(`span`,{className:`skill-link-tag`,children:t(`settings.skills.link.tagReview`)})]}),e.description&&L(`span`,{className:`skill-row-desc skill-link-desc`,dir:`auto`,title:e.description,children:L(`bdi`,{children:e.description})}),e.permissions.length>0?z(`span`,{className:`skill-link-perms`,children:[L(`span`,{className:`skill-link-perms-label`,children:t(`settings.skills.link.can`)}),L(`ul`,{"aria-label":t(`settings.skills.link.permsAria`,{name:e.name}),children:e.permissions.map(e=>z(`li`,{children:[L(`bdi`,{children:e.text}),` `,L(`bdi`,{dir:`ltr`,children:L(`code`,{children:e.grant})})]},e.grant))})]}):L(`span`,{className:`skill-link-perms`,children:t(e.permissions_unreadable?`settings.skills.link.permissionsUnreadable`:`settings.skills.link.noPermissions`)}),a&&z(`details`,{className:`skill-link-findings`,children:[L(`summary`,{children:t(`settings.skills.link.details`)}),i&&L(`p`,{children:L(`bdi`,{children:i})}),e.has_code&&!f&&L(`p`,{children:t(`settings.skills.link.shipsCode`)}),e.findings.length>0&&L(`ul`,{children:e.findings.map(e=>L(`li`,{children:L(`bdi`,{children:e})},e))})]})]})]})},e.path)})}),z(`div`,{className:`skill-link-actions`,children:[w&&z(`label`,{className:`skill-link-code`,title:t(`settings.skills.link.codeHint`),children:[L(`input`,{type:`checkbox`,checked:f,onChange:e=>x(e.target.checked)}),L(`span`,{children:t(`settings.skills.link.includeCode`)})]}),L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>l(null),disabled:i!==null,children:t(`settings.skills.link.cancel`)}),L(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void y(),disabled:u.size===0||i!==null,children:i===`add`?z(P.Fragment,{children:[L(Za,{size:13,className:`spin`}),` `,t(`settings.skills.link.adding`)]}):t(`settings.skills.link.add`,{n:u.size})})]})]}),m&&z(`div`,{className:`skill-link-result`,role:`status`,children:[m.added.length>0&&L(`p`,{children:MX(m,t)}),Object.keys(m.failed).length>0&&z(`details`,{children:[L(`summary`,{children:t(`settings.skills.link.notAdded`,{n:Object.keys(m.failed).length})}),L(`ul`,{className:`grant-list`,children:Object.entries(m.failed).map(([e,t])=>z(`li`,{children:[L(`bdi`,{children:L(`strong`,{children:e})}),` — `,L(`bdi`,{children:t})]},e))})]})]})]})}var PX={path:`~/.gaia/skills`},FX=[{source:`agent-bundled`,title:`settings.skills.bundled`,note:`settings.skills.bundledNote`},{source:`user`,title:`settings.skills.yours`,note:`settings.skills.yoursNote`,empty:`settings.skills.yoursEmpty`,params:PX},{source:`claude-project`,title:`settings.skills.project`,note:`settings.skills.projectNote`,params:{path:`.claude/skills`}},{source:`claude-import`,title:`settings.skills.import`,note:`settings.skills.importNote`}];function IX(e){return/description is \d+ characters/.test(e)?`settings.skills.skipped.tooLong`:/'description' is missing/.test(e)?`settings.skills.skipped.noDescription`:`settings.skills.skipped.other`}function LX({text:e}){let t=R(),n=(0,B.useRef)(null),[r,i]=(0,B.useState)(!1),[a,o]=(0,B.useState)(!1);return(0,B.useLayoutEffect)(()=>{let e=n.current;if(!e||r)return;let t=()=>o(e.scrollHeight>e.clientHeight+1);if(t(),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(t);return i.observe(e),()=>i.disconnect()},[e,r]),z(P.Fragment,{children:[L(`span`,{ref:n,className:`skill-row-desc${r?` is-open`:``}${a||r?` is-toggle`:``}`,dir:`auto`,onClick:a||r?()=>i(!r):void 0,children:L(`bdi`,{children:e})}),(a||r)&&L(`button`,{type:`button`,className:`skill-row-more`,"aria-expanded":r,onClick:()=>i(!r),children:t(r?`settings.skills.less`:`settings.skills.more`)})]})}function RX({onUseSkill:e}){let t=R(),[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)({}),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(``),u=(0,B.useRef)(null),d=(0,B.useRef)(!0),f=(0,B.useCallback)(()=>{Pn().then(e=>{d.current&&(r(e.skills),a(e.invalid),s(null))}).catch(e=>{d.current&&s(e instanceof Error?e.message:String(e))})},[]);(0,B.useEffect)(()=>(d.current=!0,f(),window.addEventListener(`focus`,f),()=>{d.current=!1,window.removeEventListener(`focus`,f)}),[f]);let p=c.trim().toLowerCase(),m=(n??[]).filter(e=>!p||e.name.toLowerCase().includes(p)||e.description.toLowerCase().includes(p)),h=n?.every(e=>FX.some(t=>t.source===e.source))??!1,g=n=>z(`li`,{className:`skill-row`,children:[z(`div`,{className:`skill-row-text`,children:[z(`span`,{className:`skill-row-name`,children:[L(`span`,{title:n.version?`v${n.version}`:void 0,children:n.name}),n.always_on&&z(`span`,{className:`skill-row-meta`,children:[` · `,t(`settings.skills.alwaysOn`)]})]}),L(LX,{text:n.description})]}),!n.always_on&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>e(n.name),"aria-label":t(`settings.skills.useAria`,{name:n.name}),children:t(`settings.skills.try`)})]},n.name);return z(`div`,{className:`settings-pane`,children:[L(`h2`,{className:`settings-pane-title`,children:t(`settings.section.skills`)}),L(`p`,{className:`settings-pane-lede`,children:t(`settings.skills.lede`)}),z(`details`,{className:`settings-more`,children:[z(`summary`,{children:[L($r,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,t(`settings.model.howItWorks`)]}),L(`p`,{className:`settings-hint`,children:t(`settings.skills.how`,PX)})]}),L(NX,{onAdded:f}),o&&L(`p`,{className:`settings-error`,role:`alert`,children:o}),!n&&!o&&z(`p`,{className:`settings-hint`,children:[L(Za,{size:13,className:`spin`}),` `,t(`settings.loading`)]}),n&&n.length>6&&L(`input`,{ref:u,className:`settings-input`,type:`search`,value:c,onChange:e=>l(e.target.value),placeholder:t(`settings.skills.search`),"aria-label":t(`settings.skills.search`)}),n&&n.length===0&&L(`p`,{className:`settings-hint`,children:t(`settings.skills.none`)}),p&&n&&n.length>0&&m.length===0&&z(`p`,{className:`settings-hint`,role:`status`,children:[t(`settings.skills.noMatch`,{query:c.trim()}),` `,L(`button`,{type:`button`,className:`link-btn`,onClick:()=>{l(``),u.current?.focus()},children:t(`settings.skills.clearSearch`)})]}),h?FX.map(e=>{let n=m.filter(t=>t.source===e.source);return n.length===0&&(p||!e.empty)?null:L(zY,{title:t(e.title),count:n.length,hint:t(e.note,e.params),defaultOpen:e.source===`agent-bundled`||e.source===`user`&&n.length>0,forceOpen:!!p,children:L(`section`,{"aria-label":t(e.title),children:n.length===0?L(`p`,{className:`settings-hint`,children:e.empty&&t(e.empty,e.params)}):L(`ul`,{className:`skill-list`,children:n.map(g)})})},e.source)}):L(`ul`,{className:`skill-list`,children:m.map(g)}),Object.keys(i).length>0&&z(`div`,{className:`settings-card`,role:`alert`,children:[L(`span`,{className:`settings-label`,children:t(`settings.skills.skipped`)}),L(`ul`,{className:`grant-list`,children:Object.entries(i).map(([e,n])=>L(`li`,{children:t(IX(n),{name:e.split(/[\\/]/).filter(Boolean).pop()??e})},e))})]})]})}var zX=`profile`;function BX(){let e=R(),[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(!1);(0,B.useEffect)(()=>{VG().then(n).catch(e=>i(e instanceof Error?e.message:String(e)))},[]);let l=(0,B.useCallback)(async e=>{o(!0),i(null),c(!1);try{let t=await HG(e===zX?null:e);n(t),c(t.changed!==!1)}catch(e){i(e instanceof Error?e.message:String(e)),await VG().then(n).catch(()=>void 0)}finally{o(!1)}},[]);if(!t)return r?L(`p`,{className:`settings-error`,role:`alert`,children:r}):z(`p`,{className:`settings-hint`,children:[L(Za,{size:13,className:`spin`}),` `,e(`settings.memory.embedder.checking`)]});let u=t.options.find(e=>e.device===t.device),d=t=>e.bare(t===`npu`?`settings.memory.embedder.npu`:`settings.memory.embedder.gpu`);return z(P.Fragment,{children:[z(`div`,{className:`model-in-use-field`,children:[L(`label`,{className:`settings-label`,htmlFor:`embedder-device`,children:e(`settings.memory.embedder.label`)}),z(`select`,{id:`embedder-device`,className:`settings-input`,value:t.chosen?t.device:zX,onChange:e=>void l(e.target.value),disabled:a,children:[L(`option`,{value:zX,children:e.bare(`settings.memory.embedder.default`,{device:d(t.default_device)})}),t.options.map(t=>L(`option`,{value:t.device,disabled:t.available===!1,children:t.present===!1?e.bare(`settings.memory.embedder.unavailable`,{device:d(t.device)}):t.proven?d(t.device):e.bare(`settings.memory.embedder.unproven`,{device:d(t.device)})},t.device))]})]}),z(`span`,{className:`settings-hint`,children:[e(`settings.memory.embedder.runsOn`,{name:Ae(u?.display_name??t.device,`ltr`),device:d(t.device)}),` `,e(`settings.memory.embedder.why`)]}),t.options.some(e=>e.device===`npu`&&!e.proven&&e.present)&&L(`span`,{className:`settings-hint`,children:e(`settings.memory.embedder.npuUnproven`)}),u?.downloaded===!1&&L(`span`,{className:`settings-hint`,children:e(`settings.memory.embedder.notDownloaded`)}),a&&z(`span`,{className:`settings-hint`,children:[L(Za,{size:13,className:`spin`}),` `,e(`settings.memory.embedder.applying`)]}),s&&L(`p`,{className:`settings-ok`,role:`status`,children:e(`settings.memory.embedder.changed`)}),r&&L(`p`,{className:`settings-error`,role:`alert`,children:r})]})}function VX(){let e=R(),t=N(e=>e.setShowMemoryDashboard),n=N(e=>e.closeSettings),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(null),[s,c]=(0,B.useState)(!1);(0,B.useEffect)(()=>{zG().then(i).catch(e=>o(e instanceof Error?e.message:String(e)))},[]);let l=(0,B.useCallback)(async()=>{if(r){c(!0),o(null);try{i(await BG({memory_enabled:!r.memory_enabled}))}catch(e){o(e instanceof Error?e.message:String(e))}finally{c(!1)}}},[r]);return z(`div`,{className:`settings-pane`,children:[L(`h2`,{className:`settings-pane-title`,children:e(`settings.section.memory`)}),L(`p`,{className:`settings-pane-lede`,children:e(`settings.memory.lede`)}),z(`section`,{className:`settings-card`,"aria-label":e(`settings.section.memory`),children:[z(`label`,{className:`setting-row`,children:[L(`span`,{children:e(`settings.memory.remember`)}),z(`span`,{className:`toggle-switch`,children:[L(`input`,{type:`checkbox`,checked:!!r?.memory_enabled,onChange:()=>void l(),disabled:!r||s,"aria-label":e(`settings.memory.remember`)}),L(`span`,{className:`toggle-track`})]})]}),a&&L(`p`,{className:`settings-error`,role:`alert`,children:a}),z(`div`,{className:`settings-row settings-row-between`,children:[L(`span`,{className:`settings-hint`,children:e(`settings.memory.dashboardHint`)}),L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{n(),t(!0)},children:e(`settings.memory.dashboard`)})]})]}),L(`section`,{className:`settings-card`,"aria-label":e(`settings.memory.embedder.label`),children:L(BX,{})})]})}function HX(e,t,n){if(!/^\d+$/.test(e.trim()))return!1;let r=Number(e);return r>=t&&r<=n}function UX(e){return e<1048576?`${Math.ceil(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function WX(){let e=R(),[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)(``),[a,o]=(0,B.useState)(``),[s,c]=(0,B.useState)(null),[l,u]=(0,B.useState)(!1);(0,B.useEffect)(()=>{lt().then(e=>{n(e),i(String(e.retention_days)),o(String(e.max_mb))},t=>c({ok:!1,text:e(`settings.undo.readFailed`,{reason:t instanceof Error?t.message:String(t)})}))},[e]);let[d,f]=(0,B.useState)({days:!1,mb:!1}),p=!HX(r,1,365)||d.days,m=!HX(a,10,1e5)||d.mb,h=t!==null&&(r!==String(t.retention_days)||a!==String(t.max_mb)),g=async()=>{if(!(p||m)){u(!0),c(null);try{let t=await je(Number(r),Number(a));n(t),c({ok:!0,text:e(`settings.undo.saved`)})}catch(t){let n=t instanceof Vn&&t.httpStatus===422?t.fields:[],r=n.includes(`retention_days`),i=n.includes(`max_mb`);r||i?(f({days:r,mb:i}),c({ok:!1,text:e(`settings.undo.fix`)})):c({ok:!1,text:t instanceof Error?t.message:String(t)})}finally{u(!1)}}};return z(`div`,{className:`settings-field`,"aria-label":e(`settings.privacy.undo`),children:[L(`span`,{className:`settings-label`,children:e(`settings.privacy.undo`)}),L(`p`,{className:`settings-hint`,children:e(`settings.undo.hint`)}),t&&z(P.Fragment,{children:[z(`div`,{className:`setting-row`,children:[L(`label`,{htmlFor:`undo-days`,children:e(`settings.undo.days`)}),L(`input`,{id:`undo-days`,type:`number`,className:`model-input undo-history-input`,min:1,max:365,value:r,"aria-invalid":p,"aria-describedby":p?`undo-days-error`:void 0,onChange:e=>{i(e.target.value),f(e=>({...e,days:!1}))}})]}),p&&L(`p`,{id:`undo-days-error`,className:`settings-error`,children:e(`settings.undo.daysError`)}),z(`div`,{className:`setting-row`,children:[L(`label`,{htmlFor:`undo-mb`,children:e(`settings.undo.mb`)}),L(`input`,{id:`undo-mb`,type:`number`,className:`model-input undo-history-input`,min:10,max:1e5,value:a,"aria-invalid":m,"aria-describedby":m?`undo-mb-error`:void 0,onChange:e=>{o(e.target.value),f(e=>({...e,mb:!1}))}})]}),m&&L(`p`,{id:`undo-mb-error`,className:`settings-error`,children:e(`settings.undo.mbError`)}),z(`div`,{className:`setting-row setting-row-path`,children:[L(`span`,{children:e(`settings.undo.inUse`)}),z(`span`,{children:[e.plural(`settings.undo.used`,t.turns,{size:UX(t.used_bytes)}),` `,L(`bdi`,{dir:`ltr`,children:L(`code`,{className:`setting-path`,children:t.path})})]})]}),L(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void g(),disabled:!h||l||p||m,children:e(l?`settings.models.applying`:`settings.advanced.save`)})]}),s&&L(`p`,{className:s.ok?`settings-ok`:`settings-error`,role:s.ok?`status`:`alert`,children:s.text})]})}var GX={root:`settings-report`,button:`btn-secondary`,hint:`settings-hint`,error:`settings-error`};function KX(){let e=R(),t=N(e=>e.sessions),n=N(e=>e.removeSession),r=qc(),i=N(e=>e.systemStatus?.data_dir),[a,o]=(0,B.useState)(null),[s,c]=(0,B.useState)(!1),[l,u]=(0,B.useState)(null),[d,f]=(0,B.useState)(null),[p,m]=(0,B.useState)(!1),[h,g]=(0,B.useState)(null);(0,B.useEffect)(()=>{let e=!0;return de().then(t=>{e&&f(t.network_policy===`local_ai_only`)}).catch(t=>{e&&g({ok:!1,text:t instanceof Error?t.message:String(t)})}),()=>{e=!1}},[]);let _=(0,B.useCallback)(async()=>{if(d===null||p)return;let t=d,n=zc.getState().active?.model,r=!t;f(r),m(!0),g(null);try{let t=await pe({network_policy:r?`local_ai_only`:`cloud_allowed`});f(t.network_policy===`local_ai_only`),Bc(n);let i=t.policy_notices??[],a=i.some(e=>e.severity===`warning`),o=i.length?i.map(t=>t.code===`users_server_keeps_keys`?e(`settings.privacy.usersServerKeepsKeys`,{url:t.url??``}):t.code===`runtime_keys_not_dropped`?e(`settings.privacy.runtimeKeysNotDropped`,{reason:t.reason??``}):t.code===`saved_models_not_checked`&&t.cause===`model_server_down`&&t.models?.length?e.plural(`settings.privacy.savedModelNotCheckedServerDown`,t.models.length,{models:t.models.join(`, `)}):t.code===`saved_models_not_checked`?e(`settings.privacy.savedModelsNotChecked`,{reason:t.reason??``}):e(`settings.privacy.policyNoticeUnknown`)).join(` `):e(r?`settings.privacy.localOnlyOn`:`settings.privacy.localOnlyOff`);g({ok:!a,text:o})}catch(e){f(t),g({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{m(!1)}},[d,p,e]),v=(0,B.useCallback)(async t=>{try{await Ft(t,!1)}catch(t){u({ok:!1,text:e(`settings.privacy.openFolderFailed`,{reason:t instanceof Error?t.message:String(t)})})}},[e]),y=(0,B.useCallback)(async()=>{c(!0);let r=[];for(let e of t)try{await rr(e.id),n(e.id)}catch(t){r.push(`${e.title}: ${t instanceof Error?t.message:t}`)}c(!1),o(null),u(r.length?{ok:!1,text:e(`settings.privacy.deleteFailed`,{n:r.length,reason:r.join(`; `)})}:{ok:!0,text:e(`settings.privacy.deleted`)})},[n,t,e]);return z(`div`,{className:`settings-pane`,children:[L(`h2`,{className:`settings-pane-title`,children:e(`settings.section.privacy`)}),z(`section`,{className:`settings-card`,"aria-label":e(`settings.privacy.localOnlyTitle`),children:[z(`div`,{children:[z(`label`,{className:`setting-row`,children:[L(`strong`,{children:e(`settings.privacy.localOnlyTitle`)}),z(`span`,{className:`toggle-switch`,children:[L(`input`,{type:`checkbox`,role:`switch`,checked:d===!0,"aria-label":e(`settings.privacy.localOnlyTitle`),"aria-describedby":`privacy-local-only-hint`,onChange:()=>void _(),disabled:d===null,"aria-busy":p}),L(`span`,{className:`toggle-track`})]})]}),L(`p`,{className:`settings-hint`,id:`privacy-local-only-hint`,children:e(`settings.privacy.localOnlyHint`)})]}),h&&L(`p`,{className:h.ok?`settings-ok`:`settings-error`,role:h.ok?`status`:`alert`,children:h.text})]}),z(`section`,{className:`settings-card`,"aria-labelledby":`privacy-where-title`,children:[L(`h3`,{className:`settings-label`,id:`privacy-where-title`,children:e(`settings.privacy.whereTitle`)}),L(`p`,{className:`settings-note`,children:e(`settings.privacy.stays`)}),L(`p`,{className:r?.remote?`settings-note`:`settings-hint`,children:r?.remote?e(`settings.privacy.remote`,{name:r.label}):e(r?`settings.privacy.local`:`settings.privacy.unknown`)}),i&&z(`div`,{className:`setting-row setting-row-path`,children:[L(`span`,{children:e(`settings.privacy.dataFolder`)}),z(`span`,{className:`setting-path-actions`,children:[L(`bdi`,{dir:`ltr`,className:`setting-path`,children:i}),L(`button`,{type:`button`,className:`link-btn`,onClick:()=>void v(i),children:e(`settings.privacy.openFolder`)})]})]})]}),z(`section`,{className:`settings-card`,"aria-labelledby":`privacy-report-title`,children:[L(`h3`,{className:`settings-label`,id:`privacy-report-title`,children:e(`settings.privacy.reportTitle`)}),L(`p`,{className:`settings-note`,children:e(`settings.privacy.reportNote`)}),L(oP,{classes:GX})]}),L(zY,{title:e(`settings.privacy.undo`),children:L(WX,{})}),z(`section`,{className:`settings-card`,"aria-labelledby":`privacy-delete-title`,children:[L(`h3`,{className:`settings-label`,id:`privacy-delete-title`,children:e(`settings.privacy.deleteTitle`)}),L(`p`,{className:`danger-warning`,children:t.length===0?e(`settings.privacy.nothingToDelete`):e(`settings.privacy.deleteWarning`)}),L(`button`,{type:`button`,className:`btn-danger`,onClick:()=>{u(null),o(t.length)},disabled:t.length===0,children:e(`settings.privacy.delete`)})]}),a!==null&&z(Bq,{title:e.plural(`settings.privacy.deleteAsk`,a),confirmLabel:e.plural(`settings.privacy.deleteYes`,a),cancelLabel:e(`settings.privacy.deleteCancel`),onConfirm:()=>void y(),onCancel:()=>o(null),danger:!0,busy:s,children:[L(`p`,{children:e(`settings.privacy.deleteWarning`)}),L(`p`,{children:e(`settings.privacy.deleteFinal`)})]}),l&&L(`p`,{className:l.ok?`settings-ok`:`settings-error`,role:l.ok?`status`:`alert`,children:l.text})]})}var qX=[{id:`needs_approval`,label:`settings.alerts.approval`},{id:`question`,label:`settings.alerts.question`},{id:`finished`,label:`settings.alerts.finished`}],JX=[{value:`banner`,label:`settings.alerts.banner`},{value:`badge`,label:`settings.alerts.badge`},{value:`off`,label:`settings.alerts.off`}],YX=[0,10,20,30,50];function XX(){return typeof Notification>`u`?`unsupported`:Notification.permission}function ZX(){let e=R(),t=Zl(),n=!!window.gaiaAPI,[r,i]=(0,B.useState)(XX),a=Object.values(t.modes).includes(`banner`);return z(`div`,{className:`settings-pane`,children:[L(`h2`,{className:`settings-pane-title`,children:e(`settings.section.notifications`)}),L(`p`,{className:`settings-pane-lede`,children:e(`settings.alerts.lede`)}),z(`section`,{className:`settings-card`,"aria-label":e(`settings.alerts.when`),children:[qX.map(n=>z(`div`,{className:`setting-row`,children:[L(`span`,{id:`alert-${n.id}`,children:e(n.label)}),L(jB,{className:`segmented`,"aria-labelledby":`alert-${n.id}`,children:JX.map(r=>L(`button`,{type:`button`,role:`radio`,"aria-checked":t.modes[n.id]===r.value,className:t.modes[n.id]===r.value?`is-active`:``,onClick:()=>t.setMode(n.id,r.value),children:e(r.label)},r.value))})]},n.id)),!n&&a&&r!==`granted`&&(r==="default"?L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{Notification.requestPermission().then(i).catch(e=>{console.error(`[alerts] Notification permission request failed`,e),i(XX())})},children:e(`settings.alerts.allow`)}):L(`p`,{className:`settings-error`,role:`alert`,children:e(r===`unsupported`?`settings.alerts.unsupported`:`settings.alerts.blocked`)})),z(`label`,{className:`setting-row`,children:[L(`span`,{children:e(`settings.alerts.sound`)}),z(`span`,{className:`toggle-switch`,children:[L(`input`,{type:`checkbox`,checked:t.sound,onChange:()=>t.update({sound:!t.sound}),"aria-label":e(`settings.alerts.sound`)}),L(`span`,{className:`toggle-track`})]})]}),n&&z(`label`,{className:`setting-row`,children:[L(`span`,{children:e(`settings.alerts.flash`)}),z(`span`,{className:`toggle-switch`,children:[L(`input`,{type:`checkbox`,checked:t.flash,onChange:()=>t.update({flash:!t.flash}),"aria-label":e(`settings.alerts.flash`)}),L(`span`,{className:`toggle-track`})]})]})]}),z(`section`,{className:`settings-card`,"aria-labelledby":`keep-awake-title`,children:[L(`h3`,{className:`settings-label`,id:`keep-awake-title`,children:e(`settings.alerts.keepAwakeTitle`)}),n?z(P.Fragment,{children:[z(`label`,{className:`setting-row`,children:[L(`span`,{children:e(`settings.alerts.keepAwake`)}),z(`span`,{className:`toggle-switch`,children:[L(`input`,{type:`checkbox`,checked:t.keepAwake,onChange:()=>t.update({keepAwake:!t.keepAwake}),"aria-label":e(`settings.alerts.keepAwake`)}),L(`span`,{className:`toggle-track`})]})]}),z(`div`,{className:`setting-row`,children:[L(`label`,{htmlFor:`battery-floor`,children:e(`settings.alerts.battery`)}),L(`select`,{id:`battery-floor`,className:`settings-input settings-select-compact`,value:t.batteryFloor,disabled:!t.keepAwake,onChange:e=>t.update({batteryFloor:Number(e.target.value)}),children:YX.map(t=>L(`option`,{value:t,children:t===0?e.bare(`settings.alerts.never`):`${t}%`},t))})]}),L(`p`,{className:`settings-hint`,children:e(`settings.alerts.screen`)})]}):L(`p`,{className:`settings-hint`,children:e(`settings.alerts.desktopOnly`)})]})]})}var QX=[50,75,100,125,150,175,200],$X=[{accent:`american`,gender:`female`},{accent:`american`,gender:`male`},{accent:`british`,gender:`female`},{accent:`british`,gender:`male`}],eZ=`settings:preview`,tZ=`Hello, I'm GAIA. This is how I'll read my replies to you.`;function nZ(e){return e instanceof Vn?e.detail||e.message:String(e)}function rZ(){let e=R(),t=BN(e=>e.settings),n=BN(e=>e.setSettings),r=BN(e=>e.read),i=BN(e=>e.stop),a=BN(e=>e.messageId===eZ),o=BN(e=>e.messageId===eZ&&e.status===`loading`),[s,c]=(0,B.useState)(null),[l,u]=(0,B.useState)(null),[d,f]=(0,B.useState)(!1);(0,B.useEffect)(()=>{DN().then(n).catch(e=>c(nZ(e)))},[n]);let p=e=>{f(!0),u(null),BN.getState().messageId===eZ&&i(),ON(e).then(n).catch(e=>u(nZ(e))).finally(()=>f(!1))};return s?z(`div`,{className:`settings-pane`,children:[L(`h2`,{className:`settings-pane-title`,children:e(`settings.section.voice`)}),L(`p`,{className:`settings-error`,role:`alert`,children:e(`readAloud.settings.loadFailed`,{reason:s})})]}):t?z(`div`,{className:`settings-pane`,children:[L(`h2`,{className:`settings-pane-title`,children:e(`settings.section.voice`)}),L(`p`,{className:`settings-pane-lede`,children:e(`readAloud.settings.lede`)}),z(`div`,{className:`settings-field`,children:[L(`label`,{className:`settings-label`,htmlFor:`read-aloud-voice`,children:e(`readAloud.settings.voice`)}),z(`div`,{className:`read-aloud-voice-row`,children:[L(`select`,{id:`read-aloud-voice`,className:`settings-input`,value:t.voice,disabled:d,onChange:e=>p({voice:e.target.value}),children:$X.map(n=>L(`optgroup`,{label:e(`readAloud.group.${n.accent}.${n.gender}`),children:t.voices.filter(e=>e.accent===n.accent&&e.gender===n.gender).map(e=>L(`option`,{value:e.id,lang:`en`,children:e.name},e.id))},`${n.accent}-${n.gender}`))}),z(`button`,{type:`button`,className:`btn-secondary`,"aria-pressed":a,disabled:d,onClick:()=>a?i():void r(eZ,tZ),children:[o?L(Za,{size:13,className:`spin`}):L(a?Is:Xs,{size:13}),e(a?`readAloud.stop`:`readAloud.settings.preview`)]})]}),L(`span`,{className:`settings-hint`,children:e(`readAloud.settings.englishOnly`)}),L(UN,{messageId:eZ})]}),z(`div`,{className:`settings-field`,children:[L(`label`,{className:`settings-label`,htmlFor:`read-aloud-speed`,children:e(`readAloud.settings.speed`)}),L(`select`,{id:`read-aloud-speed`,className:`settings-input`,value:t.speed,disabled:d,onChange:e=>p({speed:Number(e.target.value)}),children:(QX.includes(t.speed)?QX:[...QX,t.speed].sort((e,t)=>e-t)).map(t=>L(`option`,{value:t,children:t===100?e.bare(`readAloud.settings.normalSpeed`):`${(t/100).toLocaleString(e.locale)}×`},t))})]}),z(`label`,{className:`setting-row`,children:[L(`span`,{children:e(`readAloud.settings.auto`)}),z(`span`,{className:`toggle-switch`,children:[L(`input`,{type:`checkbox`,checked:t.auto,disabled:d,onChange:()=>p({auto:!t.auto}),"aria-label":e(`readAloud.settings.auto`)}),L(`span`,{className:`toggle-track`})]})]}),L(`p`,{className:`settings-hint`,children:e(`readAloud.settings.shared`)}),l&&L(`p`,{className:`settings-error`,role:`alert`,children:e(`readAloud.settings.saveFailed`,{reason:l})})]}):z(`p`,{className:`settings-hint`,children:[L(Za,{size:13,className:`spin`}),` `,e(`settings.loading`)]})}function iZ(){let e=R(),t=N(e=>e.jumpToSetting),n=N(e=>e.closeSettings),r=N(e=>e.runSetupAgain),i=zc(e=>e.active),a=N(e=>e.systemStatus?.lemonade_running===!1),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(null),[u,d]=(0,B.useState)(null),[f,p]=(0,B.useState)(null),[m,h]=(0,B.useState)(null),[g,_]=(0,B.useState)(!1);(0,B.useEffect)(()=>{En().then(s).catch(e=>h(e instanceof Error?e.message:String(e))),ue().then(l).catch(e=>h(e instanceof Error?e.message:String(e))),Xe().then(e=>d(e??null)).catch(e=>p(e instanceof Error?e.message:String(e)))},[]);let v=o?.catalog?.find(e=>e.id===o.chat_model.id),y=(i?.model?i.remote?i.label??Uc(i.model):Uc(i.model):null)??v?.name??null,b=(o?.catalog??[]).filter(e=>e.downloaded),x=b.reduce((e,t)=>e+(t.full_size_gb??0),0),S=[c?.gpu_name,c?.npu_detected?e(`setup.checks.npu`):null].filter(Boolean).join(` · `),C=wk(o?.system?.physical_memory,c?.ram_gb),w=C&&Ok(e.locale,C),T=o?.capacity_gb==null?null:Ok(e.locale,Sk(o.capacity_gb)),E=T?w?e(`settings.setup.memoryOf`,{size:T,total:w}):e(`settings.setup.memoryFor`,{size:T}):w,D=[{title:e(`settings.setup.where`),rows:[{label:e(`settings.setup.chatRuns`),value:y,section:`model`,target:`.model-in-use`},{label:e(`settings.setup.cloudKeys`),value:null,section:`model`,target:`[data-settings-target="cloud-key"]`,provider:`fireworks`}]},{title:e(`setup.pc.step`),rows:[{label:e(`settings.setup.detected`),value:[S,E].filter(Boolean).join(` · `)||null},{label:e(`settings.setup.server`),value:o?.lemonade.mode===`external`?e(`settings.setup.serverYours`):e(`settings.setup.serverOwn`),section:`advanced`,target:`[data-settings-target="model-server"]`},{label:e(`setup.gpu.title`),value:null,section:`model`,target:`#settings-gpu-title`,provider:`local`,shown:!!u?.applies||!!f&&!tX(f)}]},{title:e(`setup.models.step`),rows:[{label:e(`settings.setup.models`),value:o?.catalog?e(`settings.setup.modelsValue`,{n:String(b.length),size:Sk(x)}):null,section:`model`,target:`[data-settings-target="models-on-pc"]`,provider:`local`},{label:e(`settings.setup.context`),value:null,section:`model`,target:`#ctx-size`,shown:!!i?.model&&!i.remote&&i.downloaded!==!1}]},{title:e(`settings.setup.after`),rows:[{label:e(`settings.section.connectors`),value:null,section:`connectors`},{label:e(`settings.section.memory`),value:null,section:`memory`},{label:e(`settings.language`),value:null,section:`general`,target:`#ui-language`},{label:e(`settings.setup.signIn`),value:null,section:`general`,target:`#desktop-startOnLogin`,shown:!!window.gaiaAPI?.tray}]}];return z(`div`,{className:`settings-pane`,children:[L(`h2`,{className:`settings-pane-title`,children:e(`settings.section.setup`)}),L(`p`,{className:`settings-hint`,children:e(`settings.setup.lede`)}),z(`div`,{className:`settings-setup-status`,children:[z(`span`,{children:[L(`strong`,{children:e(a?`settings.setup.serverDown`:`settings.setup.ready`)}),y&&!a&&z(`span`,{className:`settings-hint`,children:[` `,L(`bdi`,{children:e(`settings.setup.running`,{name:y})})]})]}),L(`button`,{type:`button`,className:`btn-secondary`,"data-testid":`setup-run-again`,onClick:()=>_(!0),children:e(`settings.setup.runAgain`)})]}),m&&L(`p`,{className:`setup-error`,role:`alert`,children:m}),D.map(e=>z(`section`,{className:`settings-setup-group`,"aria-label":e.title,children:[L(`h3`,{className:`settings-label`,children:e.title}),e.rows.filter(e=>e.shown!==!1).map(e=>{let n=z(`span`,{children:[L(`span`,{className:`settings-setup-row-label`,children:e.label}),e.value&&L(`bdi`,{className:`settings-hint settings-setup-row-value`,children:e.value})]}),r=e.section;return r?z(`button`,{type:`button`,className:`settings-setup-row`,onClick:()=>t({section:r,target:e.target??`.settings-pane-title`,from:`setup`},e.provider),children:[n,L(ri,{size:14,className:`settings-setup-chevron`,"aria-hidden":`true`})]},e.label):L(`div`,{className:`settings-setup-row is-fact`,children:n},e.label)})]},e.title)),g&&L(Bq,{title:e(`settings.setup.confirmTitle`),confirmLabel:e(`settings.setup.confirmYes`),cancelLabel:e(`setup.again.notNow`),onConfirm:()=>{_(!1),n(),r(!0)},onCancel:()=>_(!1),children:L(`p`,{children:e(`settings.setup.confirmBody`)})})]})}var aZ=[{label:`settings.about.whatsNew`,href:`https://github.com/amd/gaia/releases`},{label:`settings.about.docs`,href:`https://amd-gaia.ai/docs/guides/agent-ui`},{label:`settings.about.report`,href:`https://github.com/amd/gaia/issues/new/choose`},{label:`settings.about.license`,href:`https://github.com/amd/gaia/blob/main/LICENSE.md`}];function oZ(){let e=R(),t=N(e=>e.openSettings),n=`GAIA v0.27.0rc6`,[r,i]=(0,B.useState)(!1),[a,o]=(0,B.useState)(null),s=(0,B.useRef)(null);(0,B.useEffect)(()=>()=>{s.current&&clearTimeout(s.current)},[]);let c=(0,B.useCallback)(async()=>{o(null);try{await navigator.clipboard.writeText(n),i(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>i(!1),2e3)}catch(t){o(e(`settings.about.copyFailed`,{reason:t instanceof Error?t.message:String(t)}))}},[e,n]);return z(`div`,{className:`settings-pane`,children:[L(`h2`,{className:`settings-pane-title`,children:e(`settings.section.about`)}),z(`section`,{className:`settings-card`,"aria-labelledby":`about-version`,children:[z(`div`,{className:`settings-row settings-row-between`,children:[z(`span`,{children:[L(`strong`,{id:`about-version`,children:L(`bdi`,{dir:`ltr`,children:n})}),` `,L(`span`,{className:`beta-badge`,children:`BETA`})]}),z(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void c(),children:[L(r?Yr:Ti,{size:13,"aria-hidden":`true`}),e(r?`settings.about.copied`:`settings.about.copy`)]})]}),L(`p`,{className:`settings-hint`,children:e(`settings.advanced.about`)}),a&&L(`p`,{className:`settings-error`,role:`alert`,children:a})]}),z(`section`,{className:`settings-card`,"aria-label":e(`settings.about.links`),children:[L(`ul`,{className:`settings-about-links`,children:aZ.map(t=>L(`li`,{children:z(`a`,{href:t.href,target:`_blank`,rel:`noopener noreferrer`,children:[e(t.label),` `,L(Ui,{size:12,"aria-hidden":`true`})]})},t.href))}),z(`p`,{className:`settings-hint`,children:[e(`settings.about.reportHint`),` `,L(`button`,{type:`button`,className:`link-btn`,onClick:()=>t(`privacy`),children:e(`settings.about.reportWhere`)})]})]})]})}var sZ=class extends B.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidUpdate(e){this.state.hasError&&e.resetKey!==this.props.resetKey&&this.setState({hasError:!1})}componentDidCatch(e,t){console.error(`[ErrorBoundary] ${this.props.area} failed to render:`,e,t.componentStack)}render(){return this.state.hasError?L(cZ,{variant:this.props.variant??`fill`,onRetry:()=>this.setState({hasError:!1})}):this.props.children}};function cZ({onRetry:e,variant:t}){let n=R();return z(`div`,{role:`alert`,className:`error-boundary error-boundary-${t}`,children:[L(`p`,{className:`error-boundary-title`,children:n(`errorBoundary.title`)}),L(`p`,{className:`error-boundary-body`,children:n(t===`window`?`errorBoundary.bodyWindow`:`errorBoundary.body`)}),z(`div`,{className:`error-boundary-actions`,children:[L(`button`,{type:`button`,className:`btn-primary`,onClick:e,children:n(`errorBoundary.retry`)}),L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>window.location.reload(),children:n(`errorBoundary.reload`)})]})]})}var lZ=`modulepreload`,uZ=function(e,t){return new URL(e,t).href},dZ={},fZ=function(e){return e.pathname.endsWith(`.css`)},pZ=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},mZ=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=uZ(t,n);let r=s(t),i=fZ(r);return pZ(dZ,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:lZ,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{let i=a=>{t.removeEventListener(`load`,i),t.removeEventListener(`error`,i),a.type===`error`?n(Error(`Unable to preload CSS for ${r}`)):e(a)};t.addEventListener(`load`,i),t.addEventListener(`error`,i)})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},hZ=(0,B.lazy)(()=>mZ(()=>import(`./ConnectorsPane-M3EutXKJ.js`).then(e=>({default:e.ConnectorsPane})),__vite__mapDeps([0,1,2,3]),import.meta.url)),gZ=(0,B.lazy)(()=>mZ(()=>import(`./MessagingSettings-DaU8766C.js`).then(e=>({default:e.MessagingSettings})),__vite__mapDeps([4,1,2]),import.meta.url)),_Z=(0,B.lazy)(()=>mZ(()=>import(`./AutomationsSettings-gXZ4bqbG.js`).then(e=>({default:e.AutomationsSettings})),__vite__mapDeps([5,1,2]),import.meta.url)),vZ=(0,B.lazy)(()=>mZ(()=>import(`./AdvancedSettings-CqwfEYlx.js`).then(e=>({default:e.AdvancedSettings})),__vite__mapDeps([6,1,2]),import.meta.url)),yZ=[`general`,`setup`,`model`,`images`,`permissions`,`skills`,`connectors`,`messaging`,`automations`,`memory`,`notifications`,`voice`,`privacy`,`advanced`,`about`];function bZ({onUseSkill:e}){let t=R(),n=N(e=>e.settingsSection),r=N(e=>e.openSettings),i=N(e=>e.closeSettings),a=N(e=>e.settingsJump),o=(0,B.useRef)(null),s=(0,B.useRef)(null),c=n!==null;if(ut(c,i),un(o,c),xK(o,c,()=>o.current?.querySelector(`.settings-nav-item.is-active`)),(0,B.useLayoutEffect)(()=>{s.current&&(s.current.scrollTop=0)},[n]),(0,B.useEffect)(()=>{let e=s.current;if(!a||a.section!==n||!e)return;o.current?.querySelector(`[data-section="${n}"]`)?.focus();let t,r=null,i=()=>r?.scrollIntoView({block:`start`}),c=typeof ResizeObserver>`u`?null:new ResizeObserver(i),l=()=>c?.disconnect(),u=[`wheel`,`touchstart`,`pointerdown`,`keydown`],d=()=>{let n=e.querySelector(a.target);if(!n||n.disabled)return!1;for(let e=n.closest(`details`);e;e=e.parentElement?.closest(`details`)??null)e.open=!0;r=n.closest(`.model-in-use-field, .settings-field, details, .settings-card`)??n,r.classList.add(`settings-target-hit`),i();let o=n instanceof HTMLDetailsElement?n.querySelector(`summary`):n.closest(`summary`)??n;o&&(o.matches(`summary, button, input, select, textarea, a[href], [tabindex]`)||(o.tabIndex=-1),o.focus({preventScroll:!0}));let s=n.closest(`.settings-pane`);return s&&c?.observe(s),t=setTimeout(()=>r?.classList.remove(`settings-target-hit`),1600),!0},f=new MutationObserver(()=>{d()&&f.disconnect()});d()||f.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`disabled`]}),u.forEach(t=>e.addEventListener(t,l,{passive:!0}));let p=setTimeout(()=>f.disconnect(),5e3);return()=>{f.disconnect(),l(),u.forEach(t=>e.removeEventListener(t,l)),clearTimeout(p),clearTimeout(t)}},[a,n]),!n)return null;let l=a&&a.section===n?a.from:void 0,u=e=>{let t=yZ.indexOf(n),i=e.key===`ArrowDown`?(t+1)%yZ.length:e.key===`ArrowUp`?(t-1+yZ.length)%yZ.length:e.key===`Home`?0:e.key===`End`?yZ.length-1:null;i!==null&&(e.preventDefault(),r(yZ[i]),o.current?.querySelector(`[data-section="${yZ[i]}"]`)?.focus())},d=(()=>{switch(n){case`general`:return L(eX,{});case`setup`:return L(iZ,{});case`model`:return L(CX,{});case`images`:return L(kX,{});case`permissions`:return L(AX,{});case`skills`:return L(RX,{onUseSkill:t=>{i(),e(t)}});case`connectors`:return L(hZ,{});case`messaging`:return L(gZ,{});case`automations`:return L(_Z,{});case`memory`:return L(VX,{});case`notifications`:return L(ZX,{});case`voice`:return L(rZ,{});case`privacy`:return L(KX,{});case`advanced`:return L(vZ,{});case`about`:return L(oZ,{})}})();return L(`div`,{className:`settings-overlay`,onMouseDown:e=>{e.target===e.currentTarget&&i()},children:z(`div`,{ref:o,className:`settings-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`settings.title`),children:[z(`nav`,{className:`settings-nav`,"aria-label":t(`settings.sections`),onKeyDown:u,children:[L(`h1`,{className:`settings-nav-title`,children:t(`settings.title`)}),yZ.map(e=>L(`button`,{type:`button`,"data-section":e,className:`settings-nav-item${n===e?` is-active`:``}`,"aria-current":n===e?`page`:void 0,tabIndex:n===e?0:-1,onClick:t=>{t.currentTarget.focus(),r(e)},children:t(`settings.section.${e}`)},e))]}),z(`div`,{className:`settings-body`,children:[L(`button`,{type:`button`,className:`settings-close`,onClick:i,"aria-label":t(`settings.close`),children:L(nc,{size:18})}),l&&z(`button`,{type:`button`,className:`settings-back`,onClick:()=>{r(l),o.current?.querySelector(`[data-section="${l}"]`)?.focus()},children:[L(ti,{size:14,"aria-hidden":`true`}),t.compose(e=>e(`settings.backTo`,{section:e(`settings.section.${l}`)}))]}),L(`div`,{ref:s,className:`settings-scroll`,children:L(sZ,{area:`settings.${n}`,children:L(B.Suspense,{fallback:z(`p`,{className:`settings-hint`,children:[L(Za,{size:13,className:`spin`}),` `,t(`settings.loading`)]}),children:d})},n)})]})]})})}var xZ=`gaia:personalize-connector`,SZ=[[`google`,`my last two weeks of Gmail (and Google Calendar, if it is connected)`],[`microsoft`,`my last two weeks of Outlook mail (and calendar, if it is connected)`],[`slack`,`my recent Slack channels and direct messages`],[`github`,`my recent GitHub activity: open PRs, review requests, issues and notifications`]];function CZ(e,t){let n=e.toLowerCase().replace(/^mcp-/,``),r=SZ.find(([e])=>n.startsWith(e));return r?r[1]:`my recent activity in ${t}`}function wZ(e){let t=e.toLowerCase().replace(/^mcp-/,``),n=SZ.find(([e])=>t.startsWith(e));return n?n[0]:null}function TZ({connectorId:e,displayName:t}){return[`I just connected ${t}. Get to know me from ${CZ(e,t)}.`,`Read only — do not send, delete, label or change anything.`,`If you have no tools that read it, or they fail, tell me you couldn't reach it and stop. Never guess or count what it holds.`,`1. Skim the recent items and work out who I deal with most, what I work on, recurring meetings or threads, and what keeps landing on my plate.`,`2. Save the durable facts to memory (people, projects, preferences, routines). Skip one-off details and anything sensitive like passwords, codes or financial numbers.`,`3. Recommend up to five automations you could run for me on a schedule, each with what it does, how often, and why it fits what you saw.`,`Don't create any schedules yet — tell me what you saved and list the automations so I can pick which to set up.`].join(`
|
|
214
|
-
`)}function EZ(e){window.dispatchEvent(new CustomEvent(xZ,{detail:e}))}var DZ=Pt((e,t)=>({lifecycle:null,restartError:null,apply:n=>{n.apiBase&&Tt(n.apiBase),e({lifecycle:n,restartError:n.status===`running`?null:t().restartError})},restart:async()=>{let n=window.gaiaAPI?.backend;if(!n)throw Error(`Restart GAIA needs the desktop app.`);e({restartError:null});try{t().apply(await n.restart())}catch(t){F.system.error(`Restart GAIA failed`,t),e({restartError:t instanceof Error?t.message:String(t)})}}}));function OZ(){let e=window.gaiaAPI?.backend;e&&e.getState().then(e=>DZ.getState().apply(e)).catch(e=>F.system.error(`Could not read the backend state from the desktop app`,e))}function kZ(e){let t=window.gaiaAPI?.backend;if(!t)return()=>{};let n=t=>{let n=DZ.getState().lifecycle?.status;DZ.getState().apply(t),t.status===`running`&&n&&n!==`running`&&e()},r=t.onState(n);return t.getState().then(n).catch(e=>F.system.error(`Could not read the backend state from the desktop app`,e)),r}function AZ(e,t){let[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(null),c=(0,B.useRef)(null),l=(0,B.useRef)(null),u=(0,B.useRef)(null),d=(0,B.useCallback)(()=>{c.current&&=(clearTimeout(c.current),null),l.current&&=(clearTimeout(l.current),null),u.current&&=(clearInterval(u.current),null)},[]);(0,B.useEffect)(()=>d,[d]);let f=(0,B.useCallback)((e,t)=>{u.current&&clearInterval(u.current),u.current=setInterval(async()=>{try{let n=await se();t===`load`?Hc(n.model_loaded,e)&&(r(!1),c.current&&=(clearTimeout(c.current),null),u.current&&=(clearInterval(u.current),null)):(n.model_downloaded===!0||Hc(n.model_loaded,e))&&(a(!1),l.current&&=(clearTimeout(l.current),null),u.current&&=(clearInterval(u.current),null))}catch{}},Tu)},[]),m=e??`Gemma-4-E4B-it-GGUF`;return(0,B.useEffect)(()=>s(null),[m]),{isLoadingModel:n,isDownloadingModel:i,downloadError:o,loadModel:(0,B.useCallback)(async(e,n)=>{let i=e??m,a=n??t;r(!0);try{if(!await tn(i,a)){r(!1);return}F.system.info(`Load model triggered: ${i} (ctx=${a??`server default`})`),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>r(!1),Cu),f(i,`load`)}catch(e){F.system.error(`Failed to trigger model load`,e),r(!1)}},[m,t,f]),downloadModel:(0,B.useCallback)(async(e=!1,t,n=!1)=>{let r=t??m;a(!0),s(null);try{await p(r,e,n),F.system.info(`Download model triggered: ${r} (force=${e})`),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>a(!1),wu),f(r,`download`)}catch(e){F.system.error(`Failed to trigger model download`,e),s(e instanceof Error?e.message:String(e)),a(!1)}},[m,f])}}function jZ({onRetry:e,label:t,busyLabel:n=`Checking…`}){let[r,i]=(0,B.useState)(!1);return L(`button`,{className:`connection-banner__retry`,onClick:()=>{i(!0),Promise.resolve(e()).finally(()=>i(!1))},disabled:r,children:r?n:t})}function MZ(e){return`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)}`}function NZ({lifecycle:e}){let t=R(),n=DZ(e=>e.restart),r=DZ(e=>e.restartError),i=e.status===`restarting`,[a,o]=(0,B.useState)(()=>Date.now());if((0,B.useEffect)(()=>{if(!i)return;o(Date.now());let e=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(e)},[i]),i){let n=e.since?Math.max(0,Math.floor((a-e.since)/1e3)):0;return z(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[L(`div`,{className:`connection-banner__icon`,children:L(Za,{size:16,className:`connection-banner__spinner`})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[t(`banner.restarting`),` `,L(`bdi`,{dir:`ltr`,className:`connection-banner__timer`,children:MZ(n)}),` `,L(`span`,{className:`connection-banner__hint`,children:t(`banner.restartingHint`)})]})]})}return z(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[L(`div`,{className:`connection-banner__icon`,children:L(Ws,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[t(`banner.restartStopped`),` `,L(`span`,{className:`connection-banner__hint`,children:r?t(`banner.restartFailed`,{error:r}):t(`banner.restartStoppedHint`)})]}),L(jZ,{onRetry:n,label:t(`banner.restartButton`),busyLabel:t(`banner.restartingShort`)})]})}function PZ({onRetry:e,backendSlow:t=!1,backendError:n=null}){let r=R(),{backendConnected:i,systemStatus:a,currentSessionId:o,messages:s}=N(),c=DZ(e=>e.lifecycle),[l,u]=(0,B.useState)(!1),d=!!o&&s.length>0,f=a?.default_model_name??`Gemma-4-E4B-it-GGUF`,{isDownloadingModel:p,downloadError:m,downloadModel:h}=AZ(f),g=zc(e=>e.pickLoad),_=zc(e=>e.retryPickLoad),v=zc(e=>e.dismissPickLoad);Vc();let y=(0,B.useRef)(a?.lemonade_running),b=(0,B.useRef)(a?.model_downloaded),x=(0,B.useRef)(a?.context_size_sufficient),S=(0,B.useRef)(a?.expected_model_loaded);(0,B.useEffect)(()=>{if(d)return;let e=a?.lemonade_running,t=a?.model_downloaded,n=a?.context_size_sufficient,r=a?.expected_model_loaded,i=!1;y.current!==e&&(y.current=e,e===!1&&(i=!0)),b.current!==t&&(b.current=t,t===!1&&(i=!0)),x.current!==n&&(x.current=n,n===!1&&(i=!0)),S.current!==r&&(S.current=r,r===!1&&(i=!0)),i&&u(!1)},[a,d]);let C=a?.download_progress??null,w=p||C?.state===`downloading`||C?.state===`starting`,T=N(e=>e.dismissDownloadFailure);if(c&&c.status!==`running`)return L(NZ,{lifecycle:c});let E=C?.model_name||f,D=async()=>{try{await T(C?.model_name??E)}catch{}};if(w||C?.state===`error`){let e=C?.total_bytes?`${(C.total_bytes/1e9).toFixed(1)} GB`:`large download`,t=C?.state===`error`;return z(`div`,{className:`connection-banner ${t?`connection-banner--error`:`connection-banner--warning`}`,role:t?`alert`:`status`,children:[L(`div`,{className:`connection-banner__icon`,children:L(t?Ws:Ni,{size:16})}),L(`div`,{className:`connection-banner__text`,dir:`auto`,children:t?z(P.Fragment,{children:[`Download of `,L(`strong`,{children:E}),` failed.`,` `,(m??C?.message)&&L(`span`,{className:`connection-banner__hint`,children:m??C?.message})]}):z(P.Fragment,{children:[`Downloading `,L(`strong`,{children:E}),` (`,e,`).`,C?.state===`downloading`&&C.file&&z(P.Fragment,{children:[` `,z(`span`,{className:`connection-banner__hint`,children:[`File `,C.file_index,` / `,C.total_files,`: `,L(`code`,{children:C.file})]})]})]})}),t?L(`button`,{className:`connection-banner__retry`,onClick:()=>h(!1,E,!a?.model_loaded),children:`Retry`}):L(`span`,{className:`connection-banner__loading connection-banner__progress`,children:C&&C.state===`downloading`&&C.total_bytes>0?z(P.Fragment,{children:[L(`span`,{className:`connection-banner__progress-bar`,role:`progressbar`,"aria-valuenow":C.percent,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`Download progress`,children:L(`span`,{className:`connection-banner__progress-fill`,style:{width:`${C.percent}%`}})}),z(`span`,{className:`connection-banner__progress-label`,children:[C.percent,`% ·`,` `,(C.downloaded_bytes/1e9).toFixed(2),` /`,` `,(C.total_bytes/1e9).toFixed(2),` GB`]})]}):z(P.Fragment,{children:[L(Za,{size:13,className:`connection-banner__spinner`}),C?.state===`starting`?C.message??`Starting download…`:`Downloading…`]})}),t&&L(`button`,{className:`connection-banner__dismiss`,onClick:()=>void D(),"aria-label":`Dismiss`,children:L(nc,{size:14})})]})}if(g){let e=Uc(g.model);return g.error?z(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[L(`div`,{className:`connection-banner__icon`,children:L(Ws,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.pickLoad.failed`,{model:e}),` `,L(`span`,{className:`connection-banner__hint`,dir:`auto`,children:g.error.key?r(g.error.key,{reason:g.error.reason}):g.error.reason})]}),L(jZ,{onRetry:_,label:r(`banner.pickLoad.retry`)}),L(`button`,{className:`connection-banner__dismiss`,onClick:v,"aria-label":r(`banner.dismiss`),children:L(nc,{size:14})})]}):z(`div`,{className:`connection-banner connection-banner--init`,role:`status`,children:[L(`div`,{className:`connection-banner__icon`,children:L(Za,{size:16,className:`connection-banner__spinner`})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.pickLoad.loading`,{model:e}),` `,L(`bdi`,{dir:`ltr`,children:r(`banner.pickLoad.seconds`,{s:g.seconds})}),` `,L(`span`,{className:`connection-banner__hint`,children:r(`banner.pickLoad.canType`)})]})]})}if(ZI(a)&&!t&&!n){let e=a?.init_tasks?.find(e=>e.status===`running`)?.step,t=`banner.boot.${e}`,n=e&&fe(t)?r(t):r(`banner.boot.generic`);return z(`div`,{className:`connection-banner connection-banner--init`,role:`status`,children:[L(`div`,{className:`connection-banner__icon`,children:L(Za,{size:16,className:`connection-banner__spinner`})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[n,z(`span`,{className:`thinking-dots`,children:[L(`span`,{children:`.`}),L(`span`,{children:`.`}),L(`span`,{children:`.`})]})]})]})}if(l||d)return null;if(!i)return z(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[L(`div`,{className:`connection-banner__icon`,children:L(Qs,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.unreachable`),` `,L(`span`,{className:`connection-banner__hint`,children:r(`banner.unreachableHint`)})]}),e&&L(jZ,{onRetry:e,label:`Retry`})]});if(n)return z(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[L(`div`,{className:`connection-banner__icon`,children:L(Ws,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[`GAIA's backend answered with an error (`,n,`).`,` `,L(`span`,{className:`connection-banner__hint`,children:`It may be overloaded. GAIA keeps checking; if it lasts, restart GAIA.`})]}),e&&L(jZ,{onRetry:e,label:`Check again`})]});if(t)return z(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[L(`div`,{className:`connection-banner__icon`,children:L(Ws,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[`GAIA is slow to answer.`,` `,L(`span`,{className:`connection-banner__hint`,children:`It may be busy with another chat or app. GAIA keeps checking.`})]}),e&&L(jZ,{onRetry:e,label:`Check again`})]});if(a?.config_error)return z(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[L(`div`,{className:`connection-banner__icon`,children:L(Ws,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[`GAIA settings could not be loaded.`,` `,L(`span`,{className:`connection-banner__hint`,children:a.config_error})]}),e&&L(jZ,{onRetry:e,label:`Check again`})]});if(a&&!a.lemonade_running){let t=QI(a)===`unresponsive`,n=!t&&aX(a),i=t&&nX(a.start_command)?null:a.start_command,o=t&&nX(a.start_instruction)?null:a.start_instruction;return z(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[L(`div`,{className:`connection-banner__icon`,children:L(Ws,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(t?`banner.serverHung`:`banner.serverStopped`),` `,n?L(`span`,{className:`connection-banner__hint`,children:r(`banner.finishSetup`)}):i?z(`span`,{className:`connection-banner__hint`,children:[r(t?`banner.restartHint`:`banner.startHint`),` `,L(`code`,{dir:`ltr`,children:i})]}):o&&L(`span`,{className:`connection-banner__hint`,children:iX(r,o)})]}),n&&L(oX,{className:`connection-banner__retry`}),e&&L(jZ,{onRetry:e,label:r(`settings.key.checkAgain`)}),L(`button`,{className:`connection-banner__dismiss`,onClick:()=>u(!0),"aria-label":`Dismiss`,children:L(nc,{size:14})})]})}if(a&&a.lemonade_running&&a.model_loaded&&a.context_size_sufficient===!1){let t=a.model_context_size??0;return z(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[L(`div`,{className:`connection-banner__icon`,children:L(za,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[`LLM context window is too small (`,t.toLocaleString(),` tokens;`,` `,xu.toLocaleString(),` required).`,` `,L(`span`,{className:`connection-banner__hint`,children:`Reload it with a larger context in Settings → Advanced.`})]}),e&&L(jZ,{onRetry:e,label:`Check again`}),L(`button`,{className:`connection-banner__dismiss`,onClick:()=>u(!0),"aria-label":`Dismiss`,children:L(nc,{size:14})})]})}return null}var FZ=`https://github.com/amd/gaia/releases`;function IZ(){let e=aY(),t=R(),[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(null),o=(0,B.useCallback)(e=>{let n=rY();n&&(a(null),n[e]().catch(n=>{F.system.error(`Update ${e} failed`,n),a(lY(n,t))}))},[t]);if(n)return null;let s=e.installFailed?t(`update.chip.installFailedDetail`,e.installFailed):null,c=e.status===`downloading`||e.status===`downloaded`;if(e.startFailed&&e.previousVersion&&!c)return z(`div`,{className:`update-chip update-chip--error`,role:`status`,children:[L(Ws,{size:13,className:`update-chip__icon`}),L(`span`,{className:`update-chip__label`,title:i??void 0,children:t(i?`update.chip.updateFailed`:`update.chip.startFailed`)}),L(`button`,{type:`button`,className:`update-chip__action`,onClick:()=>o(`revertUpdate`),children:t(`update.chip.goBack`,{version:e.previousVersion})}),L(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>r(!0),"aria-label":t(`update.chip.dismissError`),children:L(nc,{size:11})})]});let l=e.status===`available`||e.status===`downloaded`;if(s&&!l)return z(`div`,{className:`update-chip update-chip--error`,role:`status`,title:s??void 0,children:[L(Ws,{size:13,className:`update-chip__icon`}),L(`span`,{className:`update-chip__label`,children:t(`update.chip.installFailed`)}),L(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>r(!0),"aria-label":t(`update.chip.dismissError`),children:L(nc,{size:11})})]});if(e.status===`idle`||e.status===`checking`||e.status===`disabled`||e.status===`no-channel`)return null;if(e.status===`downloading`){let n=Math.max(0,Math.min(100,e.progress));return z(`div`,{className:`update-chip update-chip--downloading`,role:`status`,"aria-live":`polite`,title:t(`update.chip.downloadingTitle`,{version:e.version??``}),children:[L(Ni,{size:13,className:`update-chip__icon`}),L(`span`,{className:`update-chip__label`,children:e.preparing?t(`update.chip.preparing`):t(`update.chip.downloading`,{pct:n})})]})}return e.status===`available`?z(`div`,{className:`update-chip update-chip--available`,role:`status`,title:e.manualInstall?t(`update.chip.manualTitle`,{version:e.version??``}):i||s||e.releaseNotes||t(`update.chip.availableTitle`),children:[L(Ni,{size:13,className:`update-chip__icon`}),L(`span`,{className:`update-chip__label`,children:i?t(`update.chip.updateFailed`):s?t(`update.chip.installFailed`):t(`update.chip.available`,{version:e.version??``})}),e.manualInstall?L(`a`,{className:`update-chip__action`,href:e.downloadUrl??FZ,target:`_blank`,rel:`noopener noreferrer`,children:t(`update.chip.download`)}):!e.pinnedVersion&&L(`button`,{type:`button`,className:`update-chip__action`,onClick:()=>o(`downloadUpdate`),children:t(`update.chip.updateNow`)}),L(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>r(!0),"aria-label":t(`update.chip.dismiss`),children:L(nc,{size:11})})]}):e.status===`downloaded`?z(`div`,{className:`update-chip update-chip--ready`,role:`status`,"aria-live":`polite`,children:[L(Qo,{size:13,className:`update-chip__icon`}),L(`button`,{type:`button`,className:`update-chip__action`,onClick:()=>o(`restart`),title:i||s||t(`update.chip.restartTitle`),children:t(i?`update.chip.restartFailed`:s?`update.chip.installFailedRetry`:`update.chip.ready`)})]}):e.status===`error`?z(`div`,{className:`update-chip update-chip--error`,role:`status`,title:e.error||t(`update.chip.checkFailed`),children:[L(Ws,{size:13,className:`update-chip__icon`}),L(`span`,{className:`update-chip__label`,children:t(`update.chip.checkFailed`)}),L(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>r(!0),"aria-label":t(`update.chip.dismissError`),children:L(nc,{size:11})})]}):null}var LZ={permission_request:{icon:L(bs,{size:16}),colorClass:`notif-type-permission`},policy_alert:{icon:L(bs,{size:16}),colorClass:`notif-type-policy`},security_alert:{icon:L(Ws,{size:16}),colorClass:`notif-type-security`},status_change:{icon:L(si,{size:16}),colorClass:`notif-type-status`},info:{icon:L(Na,{size:16}),colorClass:`notif-type-info`},error:{icon:L(di,{size:16}),colorClass:`notif-type-error`}},RZ=/([-])/;function zZ(e){return e.split(RZ).map((e,t)=>t%2?e:od(e,!0)).join(``)}function BZ(e,t){let n=Date.now()-e,r=Math.floor(n/1e3);if(r<60)return t(`time.justNow`);let i=Math.floor(r/60);if(i<60)return t(`time.minutesAgo`,{n:i});let a=Math.floor(i/60);if(a<24)return t(`time.hoursAgo`,{n:a});let o=Math.floor(a/24);return o<7?t(`time.daysAgo`,{n:o}):new Date(e).toLocaleDateString(On(t),{month:`short`,day:`numeric`})}function VZ({onClose:e,onOpenChat:t}){let n=R(),r=zl(dc(Vl)),i=zl(Bl),a=zl(e=>e.markRead),o=zl(e=>e.markAllRead),s=zl(e=>e.clearAll),c=zl(e=>e.dismiss),l=zl(e=>e.respondToPermission),u=zl(e=>e.typeFilter),d=zl(dc(Hl)),f=zl(e=>e.setTypeFilter),p=(0,B.useCallback)(e=>{a(e.id),e.sessionId&&e.type!==`permission_request`&&t?.(e.sessionId)},[a,t]),m=(0,B.useCallback)(e=>{l(e.id,`allow`).catch(e=>console.error(`[NotificationCenter] allow failed:`,e))},[l]),h=(0,B.useCallback)(e=>{l(e.id,`deny`).catch(e=>console.error(`[NotificationCenter] deny failed:`,e))},[l]);ut(!0,e);let g=[{key:null,label:n(`notifications.filter.all`)},{key:`permission_request`,label:n(`notifications.filter.permissions`)},{key:`policy_alert`,label:n(`notifications.filter.policy`)},{key:`error`,label:n(`notifications.filter.errors`)},{key:`security_alert`,label:n(`notifications.filter.security`)},{key:`status_change`,label:n(`notifications.filter.status`)},{key:`info`,label:n(`notifications.filter.info`)}].filter(e=>e.key===null||e.key===u||d.includes(e.key)),_=g.length>2||u!==null;return z(`div`,{className:`notification-center`,role:`dialog`,"aria-label":n(`notifications.dialogAria`),children:[z(`div`,{className:`notification-center-header`,children:[z(`div`,{className:`notification-center-title-row`,children:[L(`h2`,{className:`notification-center-title`,children:n(`notifications.title`)}),i>0&&L(`span`,{className:`notification-center-badge`,children:i})]}),L(`button`,{className:`btn-icon notification-center-close`,onClick:e,"aria-label":n(`notifications.close`),children:L(nc,{size:18})})]}),_&&L(`div`,{className:`notification-filter-bar`,role:`tablist`,"aria-label":n(`notifications.filterAria`),children:g.map(e=>L(`button`,{role:`tab`,"aria-selected":u===e.key,className:`notification-filter-tab ${u===e.key?`active`:``}`,onClick:()=>f(e.key),children:e.label},e.key??`all`))}),L(`div`,{className:`notification-list`,children:r.length===0?z(`div`,{className:`notification-empty`,children:[L(Nr,{size:40,strokeWidth:1.2}),L(`span`,{children:n(`notifications.empty`)})]}):r.map(e=>{let t=LZ[e.type],r=e.type===`permission_request`&&e.tool?Al(e,n,e=>il(od(e,!0))):null;return z(`div`,{className:`notification-item ${e.read?``:`unread`} ${t.colorClass}`,id:e.type===`policy_alert`&&e.receiptId?`policy-receipt-${encodeURIComponent(e.receiptId)}`:void 0,onClick:()=>p(e),role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&p(e)},children:[!e.read&&L(`span`,{className:`notification-unread-dot`}),L(`span`,{className:`notification-icon`,children:t.icon}),z(`div`,{className:`notification-content`,children:[z(`div`,{className:`notification-content-header`,children:[L(`span`,{className:`notification-agent`,dir:`auto`,children:e.agentName}),L(`span`,{className:`notification-time`,children:BZ(e.timestamp,n)})]}),r?z(P.Fragment,{children:[L(`span`,{className:`notification-title`,children:L(sl,{text:r.heading})}),L(`span`,{className:`notification-message`,dir:`auto`,children:L(sl,{text:r.question})})]}):z(P.Fragment,{children:[e.title&&L(`span`,{className:`notification-title`,children:zZ(e.title)}),L(`span`,{className:`notification-message`,dir:`auto`,children:zZ(e.message)})]}),e.type===`policy_alert`&&z(`div`,{className:`notification-policy-details`,children:[e.tool&&z(`span`,{className:`notification-tool`,children:[n(`activity.policy.tool`),`: `,L(`code`,{dir:`ltr`,children:e.tool})]}),e.reason&&z(`span`,{className:`notification-policy-reason`,children:[n(`notifications.reason`),`: `,e.reason]}),e.ruleIds&&e.ruleIds.length>0&&z(`span`,{className:`notification-tool`,children:[n(`activity.policy.rules`),`: `,L(`code`,{dir:`ltr`,children:e.ruleIds.join(`, `)})]}),e.policyVersion&&z(`span`,{className:`notification-tool`,children:[n(`activity.policy.policy`),`: `,L(`code`,{dir:`ltr`,children:e.policyVersion})]}),z(`span`,{className:`notification-tool`,children:[n(`activity.policy.receipt`),`:`,` `,e.receiptId?L(`code`,{dir:`ltr`,children:e.receiptId}):L(`em`,{children:n(`activity.policy.receiptUnavailable`)})]})]}),e.type===`permission_request`&&!e.response&&z(`div`,{className:`notification-actions`,children:[z(`button`,{className:`notification-action-btn notification-action-allow`,onClick:t=>{t.stopPropagation(),m(e)},children:[L(Yr,{size:14}),n(`notifications.approve`)]}),z(`button`,{className:`notification-action-btn notification-action-deny`,onClick:t=>{t.stopPropagation(),h(e)},children:[L(nc,{size:14}),n(`notifications.deny`)]})]}),e.type===`permission_request`&&e.response&&L(`span`,{className:`notification-response-badge ${e.response===`allow`?`response-allow`:`response-deny`}`,children:e.response===`allow`?n(`notifications.approved`):n(`notifications.denied`)})]}),L(`button`,{className:`notification-dismiss`,onClick:t=>{t.stopPropagation(),c(e.id)},"aria-label":n(`notifications.dismiss`),children:L(nc,{size:14})})]},e.id)})}),r.length>0&&z(`div`,{className:`notification-center-footer`,children:[z(`button`,{className:`notification-footer-btn`,onClick:o,disabled:i===0,children:[L(Yr,{size:14}),n(`notifications.markAllRead`)]}),z(`button`,{className:`notification-footer-btn notification-footer-clear`,onClick:s,children:[L(Hs,{size:14}),n(`notifications.clear`)]})]})]})}var HZ=1500,UZ=e=>new Promise(t=>setTimeout(t,e));async function WZ({onProgress:e,isCancelled:t=()=>!1,pollMs:n=HZ}={}){try{await At(nk)}catch(e){if(e?.httpStatus!==409)throw e;let t=await xe(nk).catch(()=>null);if(!t||t.status===`completed`||t.status===`failed`)throw e}for(;!t();){let t=await xe(nk);if(e?.(t),t.status===`completed`)return;if(t.status===`failed`)throw Error(t.error||`The GAIA agent could not be installed.`);await UZ(n)}}function GZ({onInstalled:e,noBuild:t=!1}){let n=R(),[r,i]=(0,B.useState)({kind:`idle`}),a=(0,B.useRef)(!1);(0,B.useEffect)(()=>()=>{a.current=!0},[]);let o=(0,B.useCallback)(async()=>{i({kind:`installing`,percent:0});try{if(await WZ({isCancelled:()=>a.current,onProgress:e=>{a.current||i({kind:`installing`,percent:e.percent??0})}}),a.current)return;await e(),a.current||i({kind:`idle`})}catch(e){a.current||i({kind:`failed`,error:e instanceof Error?e.message:String(e)})}},[e]);return t?L(`div`,{className:`app-notice is-warning`,role:`status`,children:L(`span`,{children:n(`agentNotice.noBuild`)})}):z(`div`,{className:`app-notice is-warning`,role:`status`,children:[r.kind===`installing`?L(`span`,{children:n(`agentNotice.installing`,{percent:Math.round(r.percent)})}):r.kind===`failed`?L(`span`,{children:n(`agentNotice.failed`,{error:r.error})}):L(`span`,{children:n(`agentNotice.missing`)}),r.kind!==`installing`&&L(`button`,{type:`button`,className:`link-btn`,onClick:()=>void o(),children:r.kind===`failed`?n(`agentNotice.retry`):n(`agentNotice.install`)})]})}var KZ=`goal-store-error-`,qZ=0;function JZ(){let e=zl.getState();for(let t of e.notifications)t.id.startsWith(KZ)&&!t.read&&e.markRead(t.id)}var YZ=Pt((e,t)=>({error:null,damaged:!1,check:async()=>{let n,r;try{({error:n,damaged:r}=await GG())}catch(e){F.api.error(`Could not check the goal store`,e);return}n&&n!==t().error&&(qZ+=1,zl.getState().addNotification({id:`${KZ}${qZ}`,type:`error`,agentId:`goals`,agentName:`GAIA`,title:Ut()(`mem.goals.storeError`),message:n,timestamp:Date.now(),read:!1,dismissed:!1,priority:`high`})),n||JZ(),e({error:n,damaged:!!r})}})),XZ=new Set([`loading_model`,`downloading_model`,`model_retry`,`waiting`]),ZZ=5;function QZ(e,t){return{id:e,title:t.get(e)?.title??`Untitled chat`}}function $Z(e){let t=new Map(e.sessions.map(e=>[e.id,e])),n=e.isStreaming&&e.currentSessionId!==null,r=[...e.runningSessionIds];n&&!r.includes(e.currentSessionId)&&r.push(e.currentSessionId);let i=new Set(r),a=new Set(e.notifications.filter(e=>e.type===`permission_request`&&!e.response&&!e.dismissed&&e.sessionId&&i.has(e.sessionId)).map(e=>e.sessionId)),o=[...a].map(e=>({...QZ(e,t),reason:`approval`}));n&&e.awaitingUser&&!a.has(e.currentSessionId)&&o.push({...QZ(e.currentSessionId,t),reason:`answer`});for(let[n,r]of Object.entries(e.awaitingBySession))o.some(e=>e.id===n)||o.push({...QZ(n,t),reason:r===`question`?`answer`:`approval`});let s=n&&!e.awaitingUser&&e.livePhase&&XZ.has(e.livePhase)?e.liveStatus:null,c=e.systemStatus,l=null;if(c?.default_model_is_cloud&&c.default_model_name)l={name:c.default_model_name,where:`cloud`};else if(c?.model_loaded){let e=c.model_labels?.includes(`cloud`),t=c.model_device&&c.model_device!==`none`?c.model_device:null;l={name:c.model_loaded,where:e?`cloud`:t}}let u=[...e.sessions].sort((e,t)=>t.updated_at.localeCompare(e.updated_at)).slice(0,ZZ).map(e=>QZ(e.id,t));return{backendConnected:e.backendConnected,modelServerRunning:c&&!c.default_model_is_cloud?c.lemonade_running:null,model:l,waitingOnModel:s||null,running:r.map(e=>QZ(e,t)),needsYou:o,recent:u}}function eQ(e){let t=(0,B.useRef)(e);t.current=e,(0,B.useEffect)(()=>{let e=window.gaiaAPI?.tray;if(!e)return;let n=``,r=null,i=()=>{let t=N.getState(),i={backendConnected:t.backendConnected,systemStatus:t.systemStatus,sessions:t.sessions,runningSessionIds:t.runningSessionIds,awaitingBySession:t.awaitingBySession,currentSessionId:t.currentSessionId,isStreaming:t.isStreaming,awaitingUser:t.awaitingUser,liveStatus:t.liveStatus,livePhase:t.livePhase,notifications:zl.getState().notifications},a=r;if(r=i,a&&Object.keys(i).every(e=>i[e]===a[e]))return;let o=$Z(i),s=JSON.stringify(o);s!==n&&(n=s,e.setActivity(o).catch(e=>{n=``,F.system.error(`The tray could not take the app state`,e)}))};i();let a=N.subscribe(i),o=zl.subscribe(i),s=e.onCommand(e=>{switch(e.type){case`open-chat`:t.current.openChat(e.sessionId);break;case`new-chat`:t.current.newChat();break;case`open-settings`:N.getState().openSettings(e.section);break;case`refresh-status`:t.current.refreshStatus();break;default:F.system.error(`Unknown tray command`,e)}});return()=>{a(),o(),s()}},[])}function tQ(){(0,B.useEffect)(()=>{let e=window.gaiaAPI;if(!e)return;let t=zl.getState().addNotification,n=[e.notification.onNotification(t),e.notification.onPermissionRequest(t),e.tray.onNavigate(e=>{let t=typeof e==`string`&&e.startsWith(`session:`)?e.slice(8):null;if(!t)return;let n=N.getState();n.currentSessionId!==t&&n.setMessages([]),n.setCurrentSession(t)})];return()=>n.forEach(e=>e())},[])}function nQ(e,t,n){let r=window.gaiaAPI;if(r){r.notification.show({title:t,body:n,sessionId:e}).then(e=>{e||F.system.warn(`This OS has no desktop notifications; the badge still counts it.`)}).catch(e=>F.system.error(`Could not show the desktop notification`,e));return}if(typeof Notification>`u`){F.system.warn(`This browser has no notifications; the alert was not shown.`);return}if(Notification.permission!==`granted`){F.system.warn(`Browser notifications are ${Notification.permission}; allow them in Settings → Notifications.`);return}let i=new Notification(t,{body:n,tag:`gaia-${e}`});i.onclick=()=>{window.focus(),N.getState().setCurrentSession(e)}}function rQ(){let[e,t]=(0,B.useState)(null);return(0,B.useEffect)(()=>{let e=navigator;if(!e.getBattery)return;let n=null,r=()=>{n&&t({charging:n.charging,level:n.level})};return e.getBattery().then(e=>{n=e,r(),e.addEventListener(`levelchange`,r),e.addEventListener(`chargingchange`,r)}).catch(e=>F.system.warn(`Battery level unavailable; keep-awake ignores the battery policy.`,e)),()=>{n?.removeEventListener(`levelchange`,r),n?.removeEventListener(`chargingchange`,r)}},[]),e}function iQ(){tQ();let e=N(e=>e.runningSessionIds),t=N(e=>e.awaitingBySession),n=N(e=>e.sessions),r=N(e=>e.currentSessionId),i=zl(dc(Wl)),a=Zl(),o=rQ(),s=(0,B.useRef)(null),c=iu(e,t,i),l=JSON.stringify(c);(0,B.useEffect)(()=>{let e=JSON.parse(l),t=s.current;if(s.current=e,t===null)return;let{sessions:n,currentSessionId:r}=N.getState(),i=document.hasFocus(),o=!1;for(let{sessionId:s,event:c}of au(t,e)){let e=n.find(e=>e.id===s);if(e?.kind===`eval`||e?.kind===`scheduled`)continue;let t=a.modes[c];if(!(t===`off`||cu(s,r,i))&&(o=!0,t===`banner`)){if(c!==`finished`){let{title:t,body:n}=su(c,e);nQ(s,t,n)}else D(s).then(e=>{N.getState().updateSessionInList(s,e);let{title:t,body:n}=su(c,e);nQ(s,t,n)}).catch(t=>{F.system.error(`Could not read how chat ${s} ended`,t);let{title:n,body:r}=su(c,{...e,last_run_status:null});nQ(s,n,r)})}}if(o){if(a.sound)try{du()}catch(e){F.system.warn(`Alert sound not played`,e)}a.flash&&!i&&window.gaiaAPI&&window.gaiaAPI.notification.flash().catch(e=>F.system.error(`Could not flash the taskbar button`,e))}},[l,a.modes,a.sound,a.flash]);let u=lu(n,c,a.modes,r);(0,B.useEffect)(()=>{window.gaiaAPI?.notification.setAttentionCount(u).catch(e=>F.system.error(`Could not update the taskbar badge`,e))},[u]);let d=a.keepAwake&&e.length>0&&uu(o,a.batteryFloor);(0,B.useEffect)(()=>{window.gaiaAPI?.power.setKeepAwake(d).catch(e=>F.system.error(`Could not change keep-awake`,e))},[d])}function aQ(e){return e.indexing_status===`failed`&&zL(e.error_kind)}function oQ(){let e=N(e=>e.systemStatus?.lemonade_running===!0),t=N(e=>e.setDocuments),n=(0,B.useRef)(!1),r=(0,B.useRef)(!1);(0,B.useEffect)(()=>{if(!e)return;if(n.current){r.current=!0;return}let i=async()=>{let{documents:e}=await fn(),n=(e||[]).filter(aQ).map(e=>e.id);if(n.length===0)return;F.doc.info(`Model server is back; retrying ${n.length} document(s) that were waiting for it`);for(let e of n){let n=(await fn()).documents||[],r=n.find(t=>t.id===e);if(r&&aQ(r)){t(n.map(t=>t.id===e?{...t,indexing_status:`indexing`}:t));try{await qn(e),F.doc.info(`Indexed "${r.filename}" now the model server is back`)}catch(e){F.doc.warn(`"${r.filename}" still couldn't be indexed after the model server came back`,e)}}}let r=await fn();t(r.documents||[])};n.current=!0,(async()=>{try{do{r.current=!1;try{await i()}catch(e){F.doc.warn(`Could not retry the documents waiting for the model server`,e)}}while(r.current&&N.getState().systemStatus?.lemonade_running===!0)}finally{n.current=!1}})()},[e,t])}var sQ=`GAIA Agent UI`;function cQ(){let e=N(e=>e.sessions.find(t=>t.id===e.currentSessionId)?.title);(0,B.useEffect)(()=>{document.title=e?.trim()?`${e.trim()} - GAIA`:sQ},[e])}function lQ(e,t,n){return!e||t&&(e===t||e===aR(t))?null:n.some(t=>t.id===e)?e:oR(n,e)}function uQ(e){return new URLSearchParams(e.search).get(`session`)||e.hash.replace(/^#/,``)||null}var dQ=`gaia:last-session`;function fQ(e){try{e?localStorage.setItem(dQ,e):localStorage.removeItem(dQ)}catch(e){F.ui.warn(`Could not save the open chat for the next launch`,e)}}function pQ(){try{return localStorage.getItem(dQ)}catch(e){return F.ui.warn(`Could not read the chat open at last launch`,e),null}}var mQ=1e3,hQ=3e4;function gQ(e,{initialMs:t=mQ,maxMs:n=hQ,onError:r}={}){let i=t,a=0,o=null,s=!1,c=!1,l=!1,u=()=>{l||c||s||(o&&=(clearTimeout(o),null),s=!0,a+=1,e().then(()=>{c=!0}).catch(e=>{l||(r?.(e,a),o=setTimeout(()=>{o=null,u()},i),i=Math.min(i*2,n))}).finally(()=>{s=!1}))};return u(),{kick:()=>{o&&u()},stop:()=>{l=!0,o&&clearTimeout(o),o=null},done:()=>c}}function _Q(e,t,n){return e&&!t&&!n}var vQ=(0,B.lazy)(()=>mZ(()=>import(`./MemoryDashboard-6GyDYAJB.js`).then(e=>({default:e.MemoryDashboard})),__vite__mapDeps([7,1,2,8]),import.meta.url)),yQ=(0,B.lazy)(()=>mZ(()=>import(`./ScheduleManager-aO0-jiBD.js`).then(e=>({default:e.ScheduleManager})),__vite__mapDeps([9,1,2,10]),import.meta.url)),bQ=(0,B.lazy)(()=>mZ(()=>import(`./DocumentLibrary-Dw4NolAa.js`).then(e=>({default:e.DocumentLibrary})),__vite__mapDeps([11,1,2,12]),import.meta.url)),xQ=(0,B.lazy)(()=>mZ(()=>import(`./FileBrowser-CLds5WqB.js`).then(e=>({default:e.FileBrowser})),__vite__mapDeps([13,1,2,14]),import.meta.url)),SQ=(0,B.lazy)(()=>mZ(()=>import(`./MobileAccessModal-D-OYiykI.js`).then(e=>({default:e.MobileAccessModal})),__vite__mapDeps([15,1,2,16]),import.meta.url)),CQ=3,wQ=3e5,TQ=6e3,EQ=6e4,DQ=e=>e instanceof TypeError,OQ=e=>new Promise(t=>setTimeout(t,e)),kQ=3e5,AQ=class extends Error{},jQ=class extends Error{constructor(e){super(Ut().bare(`setup.unknown.modelUnread`,{error:e}))}};async function MQ(){let e=Date.now()+kQ;for(;;){let t=await oe();if(t.state===`ready`)return;if(t.state===`failed`||t.state===`cancelled`)throw new AQ(t.error||Ut().bare(`setup.upgrading.stopped`));if(Date.now()>=e)throw Error(Ut().bare(`setup.upgrading.slow`));await OQ(mQ)}}function NQ(){return L(`div`,{className:`loading-spinner`,role:`status`,"aria-label":`Loading`})}var PQ=e=>e===1||e%10==0;function FQ(){zc.getState().active?.remote||rY()?.markSetupWorked().catch(e=>{F.system.warn(`Couldn't record that setup works on this version`,e)})}function IQ(){let e=R();cQ();let t=N(e=>e.currentSessionId),n=N(e=>e.setSessions),r=N(e=>e.setCurrentSession),i=N(e=>e.addSession),a=N(e=>e.setMessages),o=N(e=>e.showDocLibrary),s=N(e=>e.showFileBrowser),c=N(e=>e.showMemoryDashboard),l=N(e=>e.showSchedules),u=N(e=>e.sidebarOpen),d=N(e=>e.sidebarCollapsed),f=N(e=>e.setSidebarOpen),p=N(e=>e.setSystemStatus),m=N(e=>e.setBackendConnected),h=N(e=>e.setAgents),g=N(e=>e.agents),_=N(e=>e.setPendingPrompt),v=N(e=>e.setDefaultPermissionMode),y=N(e=>e.openSettings),b=N(e=>e.settingsSection),x=N(e=>e.syncSystemTheme),S=zc(e=>e.restoreNotice),C=zc(e=>e.dismissRestoreNotice),w=zl(e=>e.showPanel),T=N(e=>e.systemStatus?.initialized===!0),E=(0,B.useRef)(!1),D=zl(e=>e.setShowPanel);(0,B.useEffect)(()=>{if(!S?.ok)return;let e=setTimeout(C,TQ);return()=>clearTimeout(e)},[S,C]);let[O,ee]=(0,B.useState)({state:`checking`}),te=N(e=>e.setupAgain),ne=N(e=>e.runSetupAgain),re=(0,B.useRef)(O);re.current=O;let[ie,ae]=(0,B.useState)(!1),A=(0,B.useRef)(ie);A.current=ie;let[se,ce]=(0,B.useState)(!1),[le,ue]=(0,B.useState)(!1),de=se||ie&&!rk(g),fe=(0,B.useRef)(de);fe.current=de;let[pe,me]=(0,B.useState)(null),[j,he]=(0,B.useState)(!1),[ge,_e]=(0,B.useState)(``),[ye,be]=(0,B.useState)(0),[xe,Se]=(0,B.useState)(0),[Ce,we]=(0,B.useState)(!1),[Te,Ee]=(0,B.useState)(!1),[De,Oe]=(0,B.useState)(null),[ke,Ae]=(0,B.useState)(null),je=(0,B.useRef)(async()=>{}),Me=(0,B.useRef)(async()=>{}),Ne=(0,B.useCallback)(async(e=!1,t=!1)=>{e||ee({state:`checking`});let n=0;try{for(;;){await zc.getState().refresh();let e=zc.getState().active,r=!!e?.remote,i;try{if(i=await k(r),!e&&!i.ready)throw new jQ(zc.getState().error??`no answer`)}catch(e){let r=DQ(e)||e instanceof jQ;if(!t||!r||n>=EQ)throw e;await OQ(mQ),n+=mQ;continue}if(!i.ready&&i.stage===`upgrade`){ee({state:`upgrading`});let e=await oe();(!e.upgrade_embedded||e.state!==`running`&&e.state!==`verifying`)&&await dn(r,!1,{upgradeEmbedded:!0}),await MQ(),i=await k(r)}n>0&&await Promise.all([je.current(),Me.current()]),ue(!!i.no_agent_build),i.ready&&FQ();let a=!i.ready&&i.stage===`server`&&!!i.initialized;ee(i.ready?{state:`ready`}:a?{state:`serverDown`,modelListUnread:!!i.model_list_unread}:{state:`needed`,check:i});return}}catch(e){let t=e instanceof Error?e.message:String(e);if(e instanceof AQ){F.system.warn(`Updating the local model server failed`,e),ee({state:`unknown`,error:t,upgradeFailed:!0});return}F.system.warn(`Setup check could not be answered`,e),ee({state:`unknown`,error:t})}},[]),Pe=N(e=>!!e.systemStatus&&QI(e.systemStatus)===`unresponsive`),Fe=N(e=>e.systemStatus?.lemonade_running===!0);(0,B.useEffect)(()=>{O.state===`serverDown`&&Fe&&Ne(!0)},[O.state,Fe,Ne]);let Ie=N(e=>e.systemStatus?.lemonade_running===!1);(0,B.useEffect)(()=>{if(O.state!==`ready`||!Ie)return;let e=!1;return k(!!zc.getState().active?.remote).then(t=>{!e&&!t.ready&&t.stage===`server`&&t.initialized&&ee({state:`serverDown`,modelListUnread:!!t.model_list_unread})}).catch(e=>F.system.warn(`Could not confirm the model server is down`,e)),()=>{e=!0}},[O.state,Ie]);let Le=(0,B.useRef)(0),Re=(0,B.useCallback)(async()=>{let e=++Le.current,t=(await zn()).agents||[];e===Le.current&&(h(t),ae(!0),rk(t)&&ce(!1))},[h]),ze=(0,B.useCallback)(()=>{let e=A.current;ae(!1),Re().catch(t=>{F.api.warn(`Agent list unavailable after setup`,t),e&&ae(!0)})},[Re]);(0,B.useEffect)(()=>{let e=()=>{fe.current&&Re().catch(e=>F.api.warn(`Agent list unavailable`,e))};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[Re]);let Be=(0,B.useCallback)(async()=>{v((await nn()).default_mode)},[v]),Ve=(0,B.useRef)([]);(0,B.useEffect)(()=>{en(`0.27.0rc6`),Ne(!1,!0);let e=[gQ(Re,{onError:(e,t)=>{PQ(t)&&F.api.warn(`Agent list unavailable (attempt ${t}); retrying`,e)}}),gQ(Be,{onError:(e,t)=>{PQ(t)&&F.api.warn(`Default permission mode unavailable (attempt ${t}); retrying`,e)}})];return Ve.current=e,()=>e.forEach(e=>e.stop())},[Ne,Re,Be]);let He=(0,B.useCallback)(()=>{Ve.current.forEach(e=>e.kick()),zc.getState().retryNow(),Me.current();let e=re.current;e.state===`unknown`&&!e.upgradeFailed&&Ne(!0)},[Ne]),Ue=(0,B.useRef)(He);Ue.current=He;let We=(0,B.useRef)(0),Ge=(0,B.useRef)(0),Ke=(0,B.useRef)(null),qe=(0,B.useRef)(!1),[Je,Ye]=(0,B.useState)(!1),[Xe,Ze]=(0,B.useState)(null),Qe=(0,B.useCallback)(e=>{if(e.kind===`unreachable`){F.system.warn(`System status check failed`,e.error),OZ(),qe.current=!0,Ge.current=0,Ke.current=null,Ye(!1),Ze(null),m(!1),p(null);return}if(e.kind===`error`){F.system.warn(`System status answered HTTP ${e.httpStatus}`,e.message),qe.current&&Ue.current(),qe.current=!1,Ge.current=0,Ke.current=null,Ye(!1),Ze(`HTTP ${e.httpStatus}: ${e.message}`),m(!0);return}if(e.kind===`slow`){if(Ge.current+=1,Ke.current??=Date.now(),Ze(null),F.system.warn(`System status did not answer in time (${Ge.current} in a row)`),Date.now()-Ke.current>=wQ){Ye(!1),m(!1),p(null);return}m(!0),(qe.current||Ge.current>=CQ)&&Ye(!0);return}let{status:t}=e;qe.current&&Ue.current(),qe.current=!1,Ge.current=0,Ke.current=null,Ye(!1),Ze(null),m(!0),We.current=t.lemonade_running?0:We.current+1;let n=N.getState().systemStatus;t.lemonade_running||We.current>=CQ||!n?.lemonade_running?p(t):p({...n,download_progress:t.download_progress})},[m,p]),$e=(0,B.useRef)(Qe);$e.current=Qe;let[et]=(0,B.useState)(()=>tL(e=>$e.current(e))),tt=et.check;je.current=tt,(0,B.useEffect)(()=>LW(et.start),[et]),(0,B.useEffect)(()=>kZ(()=>{tt()}),[tt]);let nt=(0,B.useRef)(``);(0,B.useEffect)(()=>{let e=e=>gn().then(t=>{let r=t.sessions||[];if(!e&&r.length===0&&N.getState().sessions.length>0)return;let i=r.map(e=>`${e.id}|${e.updated_at}|${e.title}|${e.inference_remote}|${e.inference_provider}|${e.inference_description}|${e.effective_model}|${e.unread}|${e.pinned}|${e.last_run_status}|${e.kind}`).join(`
|
|
215
|
-
`);if(i===nt.current)return;nt.current=i,n(r);let a=zc.getState().active?.model;a&&r.some(e=>e.effective_model&&e.effective_model!==a)&&zc.getState().refresh()}).catch(t=>{e&&F.system.error(`Could not load chats`,t)});Me.current=()=>e(!1),e(!0);let t=setInterval(()=>void e(!1),5e3);return()=>clearInterval(t)},[n]),(0,B.useEffect)(()=>mL(),[]),(0,B.useEffect)(()=>{let e=()=>{ZH.getState().loadSchedules()};e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[]),(0,B.useEffect)(()=>{let e=()=>{
|
|
209
|
+
`]},t))})}),(r?.dropped??0)>0&&L(`p`,{className:`log-viewer-hint`,children:n(`logs.older`)}),h&&L(`p`,{className:h.ok?`settings-ok`:`log-viewer-warning`,role:h.ok?`status`:`alert`,children:h.text})]})}function MK(){let e=R(),[t,n]=(0,B.useState)(!1),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(null),s=(0,B.useCallback)(async()=>{n(!0),o(null),i(null);try{let e=await or(),t=await ee(e.name),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=e.name,r.click(),setTimeout(()=>URL.revokeObjectURL(n),6e4),i(e)}catch(t){o(e(`logs.saveAllFailed`,{error:kK(t)}))}finally{n(!1)}},[e]);return z(`div`,{className:`log-viewer-save-all`,children:[z(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void s(),disabled:t,children:[t?L(Za,{size:13,className:`spin`,"aria-hidden":`true`}):L(_r,{size:13,"aria-hidden":`true`}),e(`logs.saveAll`)]}),L(`span`,{className:`log-viewer-hint`,children:e(`setup.logs.reportNote`)}),r&&z(`p`,{className:`log-viewer-hint`,role:`status`,children:[e(`logs.savedAll`,{size:Ek(r.size_bytes)}),` `,L(`bdi`,{dir:`ltr`,children:r.path})]}),a&&L(`p`,{className:`log-viewer-warning`,role:`alert`,children:a})]})}function NK(){let e=R(),t=hc(e=>e.open),n=hc(e=>e.source),r=hc(e=>e.show),i=hc(e=>e.hide),a=(0,B.useRef)(null),o=(0,B.useRef)(null),[s,c]=(0,B.useState)({}),[l,u]=(0,B.useState)(null);if(ut(t,i),un(a,t),xK(a,t,()=>o.current),(0,B.useEffect)(()=>{t&&sr().then(e=>c(Object.fromEntries(e.sources.map(e=>[e.id,e.files??[]])))).catch(e=>console.warn(`[LogsDialog] could not list log files`,e))},[t]),(0,B.useEffect)(()=>{u(null)},[n]),!t)return null;let d=s[n]??[];return(0,mM.createPortal)(L(`div`,{className:`log-viewer-overlay`,onMouseDown:e=>{e.target===e.currentTarget&&i()},children:z(`div`,{ref:a,className:`log-viewer`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`log-viewer-title`,children:[z(`div`,{className:`log-viewer-head`,children:[L(`h2`,{id:`log-viewer-title`,className:`log-viewer-title`,children:e(`logs.title`)}),L(`button`,{ref:o,type:`button`,className:`log-viewer-close`,onClick:i,"aria-label":e(`logs.close`),title:e(`logs.close`),children:L(nc,{size:16,"aria-hidden":`true`})})]}),L(`div`,{className:`log-viewer-tabs`,role:`tablist`,"aria-label":e(`logs.title`),children:mc.map(t=>L(`button`,{type:`button`,role:`tab`,"aria-selected":t===n,className:t===n?`is-active`:``,onClick:()=>r(t),children:t===`gaia`?L(`bdi`,{children:e(TK[t])}):e(TK[t])},t))}),d.length>1&&z(`label`,{className:`log-viewer-file`,children:[e(`logs.file`),L(`select`,{dir:`ltr`,value:l??d[0].name,onChange:e=>u(e.target.value),children:d.map(e=>z(`option`,{value:e.name,children:[e.name,e.size_bytes==null?``:` (${CK}${iR(e.size_bytes)}${wK})`]},e.name))})]}),L(`div`,{role:`tabpanel`,className:`log-viewer-panel`,children:L(jK,{source:n,file:l},`${n}:${l??``}`)}),L(`p`,{className:`log-viewer-hint`,children:e(`logs.privacy`)}),L(MK,{})]})}),document.body)}var PK=[{label:`shortcuts.newChat`,keys:`Mod+Shift+O`},{label:`shortcuts.search`,keys:`Mod+K`},{label:`shortcuts.sidebar`,keys:`Mod+B`},{label:`shortcuts.settings`,keys:`Mod+,`},{label:`shortcuts.sheet`,keys:`Mod+/`},{label:`shortcuts.browserPane`,keys:`Mod+Shift+B`,desktopOnly:!0},{label:`shortcuts.send`,keys:`Enter`},{label:`shortcuts.newLine`,keys:`Shift+Enter`},{label:`shortcuts.editLast`,keys:`↑`},{label:`shortcuts.stop`,keys:`Esc`}];function FK(){let e=!!MV();return PK.filter(t=>e||!t.desktopOnly)}function IK({onClose:e}){let t=R(),n=(0,B.useRef)(null);return ut(!0,e),un(n,!0),xK(n,!0),L(`div`,{ref:n,className:`modal-overlay`,onClick:e,role:`dialog`,"aria-modal":`true`,"aria-label":t(`shortcuts.title`),children:z(`div`,{className:`modal-panel shortcuts-dialog`,onClick:e=>e.stopPropagation(),children:[z(`div`,{className:`modal-header`,children:[L(`h3`,{children:t(`shortcuts.title`)}),L(`button`,{type:`button`,className:`btn-icon`,onClick:e,"aria-label":t(`shortcuts.close`),children:L(nc,{size:18,"aria-hidden":`true`})})]}),L(`dl`,{className:`modal-body shortcuts-list`,children:FK().map(({label:e,keys:n})=>z(`div`,{className:`shortcuts-row`,children:[L(`dt`,{children:t(e)}),L(`dd`,{children:L(`kbd`,{dir:`ltr`,children:_u(n)})})]},e))})]})})}function LK(e){let t=e?.reason;return t===`needs_key`||t===`bad_key`}function RK({provider:e,limit:t,picked:n=null,onPick:r,pickDisabled:i=!1,onDefault:a}){let o=R(),[s,c]=(0,B.useState)(null),[l,u]=(0,B.useState)(null),d=(0,B.useRef)(a);if(d.current=a,(0,B.useEffect)(()=>{let t=!0;return c(null),u(null),d.current?.(null),Xt(e).then(e=>{t&&(c(e),d.current?.(e.models[0]?.model??null))}).catch(e=>{t&&u(e instanceof Error?e.message:String(e))}),()=>{t=!1}},[e]),l)return L(`p`,{className:`settings-error`,role:`alert`,children:o(`settings.price.loadFailed`,{reason:l})});if(!s)return z(`p`,{className:`settings-hint`,children:[L(Za,{size:13,className:`spin`}),` `,o(`settings.price.loading`)]});if(s.models.length===0)return z(`p`,{className:`settings-hint cloud-prices-note`,children:[o(`settings.price.unknownSentence`),` `,L(`bdi`,{children:s.note})]});let f=t?s.models.slice(0,t):s.models,p=n?s.models.find(e=>e.model===n&&!f.includes(e)):void 0,m=p?[...f,p]:f,h=n??m[0]?.model,g=r!==void 0;return z(`div`,{className:`cloud-prices`,"aria-label":o(`settings.model.prices`),children:[g&&L(`p`,{className:`cloud-prices-legend`,id:`cloud-prices-legend`,children:o(`settings.price.pickLegend`)}),L(`ul`,{className:`cloud-prices-list${g?` is-pickable`:``}`,role:g?`radiogroup`:void 0,"aria-labelledby":g?`cloud-prices-legend`:void 0,children:m.map((t,n)=>{let a=z(`span`,{className:`cloud-prices-name`,children:[L(`bdi`,{children:t.name}),n===0&&g&&z(`span`,{className:`cloud-prices-default`,children:[` · `,o(`settings.price.default`)]}),t.note&&z(`span`,{className:`cloud-prices-note`,children:[` · `,L(`bdi`,{children:t.note})]})]});return z(`li`,{className:g&&h===t.model?`is-chosen`:void 0,children:[g?z(`label`,{className:`cloud-prices-pick`,children:[L(`input`,{type:`radio`,name:`cloud-model-${e}`,value:t.model,checked:h===t.model,disabled:i,onChange:()=>r(t.model)}),a]}):a,L(`span`,{className:`cloud-prices-price`,children:OR(t.price,o)})]},t.model)})}),z(`span`,{className:`settings-hint`,children:[L(`bdi`,{children:s.source}),`. `,o(`settings.price.payProvider`)]})]})}function zK(){return Du(xB)}function BK(e,t=150){let n=zK(),[r,i]=(0,B.useState)(e),a=(0,B.useRef)(e);return(0,B.useEffect)(()=>{if(n||typeof requestAnimationFrame!=`function`){a.current=e,i(e);return}let r=a.current,o=performance.now(),s=0,c=n=>{let l=Math.min(1,(n-o)/t),u=1-(1-l)**3,d=r+(e-r)*u;a.current=d,i(d),l<1&&(s=requestAnimationFrame(c))};return s=requestAnimationFrame(c),()=>cancelAnimationFrame(s)},[e,t,n]),r}function VK(e,t){let[n,r]=(0,B.useState)(e);return(0,B.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}function HK(){let[e,t]=(0,B.useState)(()=>typeof document>`u`||document.visibilityState!==`hidden`);return(0,B.useEffect)(()=>{let e=()=>t(document.visibilityState!==`hidden`);return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),e}var UK=180;function WK({open:e,children:t}){let[n,r]=(0,B.useState)(e),[i,a]=(0,B.useState)(e),o=(0,B.useRef)(t);return e&&(o.current=t),(0,B.useEffect)(()=>{if(e){r(!0);let e=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(e)}a(!1);let t=setTimeout(()=>r(!1),UK);return()=>clearTimeout(t)},[e]),n?L(`div`,{className:`reveal${i?` is-open`:``}`,"aria-hidden":!e||void 0,children:L(`div`,{className:`reveal-inner`,children:e?t:o.current})}):null}var GK=e=>e?.catalog??[],KK=e=>e.roles.includes(`vision`),qK=e=>e.roles.includes(`embedding`),JK=e=>e.recipe===`flm`,YK=e=>e.fits===!1&&(e.fit_code===`npu`||e.fit_code===`backend`),XK=e=>e.support===null,ZK=e=>e?.feature_tier!==`compact`;function QK(e,t){let n=e.find(e=>e.id===t.defaultChat);return n&&JK(n)||t.vision===`none`?null:t.vision?t.vision:n?.reads_images?n.id:e.find(e=>KK(e)&&e.gaia_model)?.id??null}function $K(e,t){let n=QK(t,e),r=new Set(e.ticked),i=new Set(e.unticked);for(let a of t)KK(a)&&a.id!==e.defaultChat&&(a.id===n?(r.add(a.id),i.delete(a.id)):a.downloaded||(r.delete(a.id),i.add(a.id)));return{...e,ticked:r,unticked:i}}function eq(e,t,n){let r=new Set(e.ticked),i=t.find(t=>t.id===e.defaultChat);i&&!i.downloaded&&r.delete(i.id);let a=t.find(e=>e.id===n);if(a?.downloaded||r.add(n),!ZK(a))for(let e of t)e.roles.includes(`image_creation`)&&r.delete(e.id);return $K({...e,ticked:r,defaultChat:n,chatChosen:!0,vision:null},t)}function tq(e,t,n){return $K({...e,vision:n},t)}function nq(e,t){if(t.vision===`none`)return null;let n=QK(e,t),r=e.find(e=>e.id===t.defaultChat);return r&&JK(r)||n===(r?.reads_images?r.id:e.find(e=>KK(e)&&e.gaia_model)?.id)?null:n}function rq(e){return e.filter(e=>e.gaia_model&&(e.planned||e.recommended||e.downloaded||e.partial))}function iq(e){let t=new Set(rq(e).map(e=>e.id));return e.filter(e=>e.gaia_model&&!t.has(e.id))}function aq(e){return e.filter(e=>!e.gaia_model&&e.downloaded)}function oq(e){let t=GK(e),n=new Set(t.filter(e=>e.selected||e.gaia_model&&e.downloaded&&!e.skipped).map(e=>e.id)),r=!t.find(t=>t.id===e.chat_model.id)?.reads_images&&t.some(e=>KK(e)&&e.gaia_model&&e.skipped);return $K({ticked:n,defaultChat:e.chat_model.id,unticked:new Set,chatChosen:e.chat_model.user_set,vision:e.vision_model??(r?`none`:null)},t)}function sq(e,t){return e.filter(e=>e.chat_choice&&(t.has(e.id)||e.downloaded))}function cq(e,t,n,r){let i=new Set(e.ticked),a=new Set(e.unticked);r?(i.add(n),a.delete(n)):(i.delete(n),a.add(n));let o=sq(t,i),s=e.defaultChat;if(!s||!o.some(e=>e.id===s)){let e=t.find(e=>e.id===n);s=r&&e?.chat_choice?n:(o.find(e=>e.recommended)??o[0])?.id??null}return{...e,ticked:i,defaultChat:s,unticked:a}}function lq(e,t,n){let r=t.find(e=>e.id===n)?.downloaded;return{...e,defaultChat:n,chatChosen:!0,ticked:r?e.ticked:new Set([...e.ticked,n])}}function uq(e){let t=GK(e),n=new Set(t.filter(e=>e.recommended||e.gaia_model&&e.downloaded).map(e=>e.id)),r=sq(t,n);return $K({ticked:n,defaultChat:e.recommended_model&&r.some(t=>t.id===e.recommended_model)?e.recommended_model:(r.find(e=>e.recommended)??r[0])?.id??null,unticked:new Set,chatChosen:!1,vision:null},t)}function dq(e,t){return e.filter(e=>t.ticked.has(e.id)&&!e.downloaded).sort((e,t)=>(t.size_gb??0)-(e.size_gb??0))}function fq(e,t){let n=dq(GK(e),t).map(e=>e.size_gb),r=n.every(e=>e!=null)?yq(n.reduce((e,t)=>e+t,0)):null,i=e.disk?.free_gb??null;return{downloadGb:r,freeGb:i,afterGb:r!=null&&i!=null?yq(i-r):null}}function pq(e,t){let{downloadGb:n,freeGb:r}=fq(e,t);return n==null||r==null||n<=r?null:{needGb:n,freeGb:r,freeUpGb:yq(n-r),drop:dq(GK(e),t).find(e=>e.size_gb!=null&&n-e.size_gb<=r)??null}}function mq(e,t){return e.filter(e=>e.fits===!1&&(t.ticked.has(e.id)||e.id===t.defaultChat)||e.fits===!0&&!!e.tight&&e.id===t.defaultChat)}function hq(e){return e.length>0&&e.every(e=>e.fits===!0&&!!e.tight)}function gq(e,t){let n=[];for(let r of GK(e)){if(!r.planned){r.skipped&&t.ticked.has(r.id)&&n.push({id:r.id,skipped:!1});continue}if(r.id===e.chat_model.id){r.skipped&&n.push({id:r.id,skipped:!1});continue}let i=t.ticked.has(r.id);!i&&!r.skipped&&n.push({id:r.id,skipped:!0}),i&&r.skipped&&n.push({id:r.id,skipped:!1})}return n}function _q(e,t){return GK(e).filter(e=>t.ticked.has(e.id)&&!e.planned&&!e.downloaded).map(e=>e.id)}function vq(e,t){let n=(e.models??[]).filter(e=>e.state!==`skipped`);if(!t?.catalog||n.length===0)return e.overall;let r=0,i=0;for(let e of n){let n=t.catalog.find(t=>t.id===e.id),a=n?.downloaded?0:n?.size_gb==null?e.bytes_total:Math.min(e.bytes_total||1/0,n.size_gb*1e9),o=Math.max(0,e.bytes_total-a);i+=a,r+=e.state===`ready`||e.state===`verifying`?a:Math.min(a,Math.max(0,e.bytes_done-o))}return{bytes_done:r,bytes_total:i,speed_bps:e.overall?.speed_bps??0,eta_s:null,percent:i>0?Math.floor(r*100/i):100,failed:n.filter(e=>e.state===`failed`).length}}function yq(e){return Math.round(e*10)/10}var bq=6;function xq(e,t){let n=[];return e.chat_choice&&!qK(e)&&n.push(t(`setup.models.purpose.chat`)),KK(e)&&n.push(t(`setup.models.purpose.vision`)),qK(e)&&n.push(t(`setup.models.purpose.documents`)),e.roles.includes(`speech`)&&n.push(t(`setup.models.purpose.speech`)),e.roles.includes(`voice`)&&n.push(t(`setup.models.purpose.voice`)),e.roles.includes(`image_creation`)&&n.push(t(`setup.models.purpose.imageCreation`)),n}function Sq(e,t){return qK(e)?t(`setup.models.line.documents`):KK(e)?t(`setup.models.line.vision`):e.roles.includes(`speech`)?t(`setup.models.line.speech`):e.roles.includes(`voice`)?t(`setup.models.line.voice`):e.roles.includes(`image_creation`)?t(`setup.models.line.imageCreation`):t(`setup.models.line.chat`)}function Cq(e,t){return e.downloaded?t(`setup.models.status.onPc`):e.size_gb==null?t(`setup.models.status.sizeUnknown`):e.partial?t(`setup.models.status.partial`,{size:Sk(e.size_gb)}):t(`setup.models.status.download`,{size:Sk(e.size_gb)})}function wq(e,t){return e.fits!==!0||e.need_gb==null||e.capacity_gb==null?null:t(`setup.models.fit.ok`,{need:Tk(e.need_gb),have:Tk(e.capacity_gb)})}function Tq(e,t){return e.fits===!0&&e.tight?t(`setup.models.warn.tight`):e.fit_code===`npu`?t(`setup.models.warn.npu`):e.fit_code===`backend`?t(`setup.models.warn.backend`):e.need_gb!=null&&e.capacity_gb!=null?t(`setup.models.warn.tooBig`,{need:Tk(e.need_gb),have:Tk(e.capacity_gb)}):t(`setup.models.warn.tooBigNoNumbers`)}function Eq(e,t,n,r){return!KK(e)&&!qK(e)||KK(e)&&!e.downloaded&&r?null:n===`settings`?e.downloaded?t(`settings.models.warn.kept`,{name:e.name}):t(KK(e)?`settings.models.warn.vision`:`settings.models.warn.documents`,{name:e.name}):t(KK(e)?`setup.models.warn.vision`:`setup.models.warn.documents`,{name:e.name})}function Dq({entry:e,ticked:t,onToggle:n,disabled:r,progress:i,actions:a,place:o,imagesCovered:s}){let c=R(),l=(0,B.useId)(),u=e.fits===!1,d=t?null:Eq(e,c,o,s),f=i?.state===`downloading`&&i.bytes_total>0,p=e.fits===!0&&!!e.tight,m=u?Tq(e,c):d??(p?c(`setup.models.warn.tight`):null),h=[`${l}-status`,`${l}-note`,m?`${l}-warn`:null].filter(Boolean).join(` `);return z(`li`,{className:`mc-row${t?` is-ticked`:``}${m?` has-warning`:``}`,children:[z(`div`,{className:`mc-row-top`,children:[z(`label`,{className:`mc-row-main`,children:[L(`input`,{type:`checkbox`,className:`mc-input`,checked:t,disabled:r,onChange:e=>n(e.target.checked),"aria-describedby":h}),L(`span`,{className:`mc-box`,"aria-hidden":`true`,children:L(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,children:L(`path`,{className:`mc-tick`,d:`M3.5 8.5l3 3 6-7`})})}),z(`span`,{className:`mc-text`,children:[z(`span`,{className:`mc-name-line`,children:[L(`bdi`,{className:`mc-name`,title:e.id,children:e.name}),z(`span`,{className:`mc-chips`,children:[xq(e,c).map(e=>L(`span`,{className:`mc-chip`,children:e},e)),JK(e)&&L(`span`,{className:`mc-chip is-npu`,children:c(`setup.models.npu`)})]})]}),z(`span`,{className:`mc-status`,id:`${l}-status`,children:[f?c(`setup.models.status.downloading`,{done:Ek(i.bytes_done),total:Ek(i.bytes_total)}):Cq(e,c),e.recommended&&L(`span`,{className:`mc-pill`,children:c(`setup.models.recommended`)}),e.fits===null&&z(`span`,{className:`mc-chip is-unknown`,children:[L(pi,{size:11,"aria-hidden":`true`}),` `,c(`setup.models.fitUnknown`)]})]}),L(`span`,{className:`mc-note`,id:`${l}-note`,children:c.compose(t=>[Sq(e,t),wq(e,t),e.fits===null?t(`setup.models.fit.unknown`):null].filter(Boolean).join(` `))})]})]}),a&&L(`span`,{className:`mc-actions`,children:a})]}),f&&L(`progress`,{className:`mc-mini-progress`,max:i.bytes_total,value:i.bytes_done,"aria-label":c(`setup.progress.rowLabel`,{name:e.name,state:c(`setup.state.downloading`)})}),L(WK,{open:!!m,children:z(`p`,{className:`mc-warn${u?` is-big`:``}`,role:`note`,id:`${l}-warn`,children:[L(Ws,{size:13,"aria-hidden":`true`}),L(`span`,{children:m})]})})]})}function Oq({plan:e,selection:t}){let n=R(),{downloadGb:r,freeGb:i,afterGb:a}=fq(e,t),o=pq(e,t),s=BK(r??0),c=BK(a??0),l=kq(e.disk?.path??null),u=r!=null&&i?Math.min(1,r/i):0,d=VK(r==null?n(`setup.summary.spokenUnknown`):a==null?n(`setup.summary.spokenNoDisk`,{download:Sk(r)}):n(`setup.summary.spoken`,{download:Sk(r),after:Sk(Math.max(0,a))}),600);return z(`div`,{className:`mc-summary${o?` is-warn`:``}`,role:`group`,"aria-label":n(`setup.summary.label`),children:[z(`div`,{className:`mc-summary-stats`,children:[z(`span`,{className:`mc-stat`,children:[L(`span`,{className:`mc-stat-label`,children:n(`setup.summary.download`)}),L(`bdi`,{className:`mc-stat-value`,children:r==null?n(`setup.summary.sizeUnknown`):Sk(Aq(s))})]}),z(`span`,{className:`mc-stat`,children:[z(`span`,{className:`mc-stat-label`,children:[L(ka,{size:12,"aria-hidden":`true`}),` `,l?z(P.Fragment,{children:[n(`setup.summary.freeOn`),` `,L(`bdi`,{dir:`ltr`,className:`mc-stat-path`,children:l})]}):n(`setup.summary.free`)]}),L(`bdi`,{className:`mc-stat-value`,children:i==null?n(`setup.summary.freeUnknown`):Sk(i)})]}),a!=null&&!o&&z(`span`,{className:`mc-stat`,children:[L(`span`,{className:`mc-stat-label`,children:n(`setup.summary.after`)}),L(`bdi`,{className:`mc-stat-value`,children:Sk(Math.max(0,Aq(c)))})]})]}),i!=null&&L(`div`,{className:`mc-disk`,"aria-hidden":`true`,children:L(`span`,{className:`mc-disk-fill`,style:{inlineSize:`${(u*100).toFixed(1)}%`}})}),L(WK,{open:!!o,children:o&&z(`p`,{className:`mc-disk-warn`,role:`note`,children:[L(Ws,{size:13,"aria-hidden":`true`}),L(`span`,{children:o.drop?n(`setup.summary.shortDrop`,{need:Sk(o.needGb),free:Sk(o.freeGb),drive:l??n(`setup.summary.theDrive`),freeUp:Sk(o.freeUpGb),name:o.drop.name,saves:Sk(o.drop.size_gb??0)}):n(`setup.summary.short`,{need:Sk(o.needGb),free:Sk(o.freeGb),drive:l??n(`setup.summary.theDrive`),freeUp:Sk(o.freeUpGb)})})]})}),L(`span`,{className:`visually-hidden`,"aria-live":`polite`,children:d})]})}function kq(e){if(!e)return null;let t=/^([A-Za-z]:)[\\/]/.exec(e);return t?t[1]:e}function Aq(e){return Math.round(e*10)/10}function jq({plan:e,selection:t,onToggle:n,onDefaultChat:r,labelledBy:i,cloud:a,disabled:o,progress:s,rowActions:c,place:l=`setup`}){let u=R(),d=GK(e),[f,p]=(0,B.useState)(``),m=(0,B.useId)(),h=a?d.filter(qK):rq(d),g=a?[]:iq(d),_=a?[]:aq(d),v=(0,B.useMemo)(()=>{let e=f.trim().toLowerCase();return e?_.filter(t=>t.id.toLowerCase().includes(e)||t.name.toLowerCase().includes(e)):_},[_,f]),y=sq(d,t.ticked),b=e=>L(Dq,{entry:e,ticked:t.ticked.has(e.id),onToggle:t=>n(e.id,t),disabled:o,progress:s?.[e.id],actions:c?.(e),place:l,imagesCovered:d.some(n=>n.id!==e.id&&KK(n)&&(t.ticked.has(n.id)||n.downloaded===!0))},e.id);return z(`div`,{className:`mc`,children:[L(`ul`,{className:`mc-list`,role:`group`,"aria-labelledby":i,children:h.map(b)}),a?L(`p`,{className:`setup-hint`,children:u(`setup.models.cloudNote`)}):L(`p`,{className:`mc-foot`,children:u(`setup.models.neverDeletes`)}),g.length>0&&z(`details`,{className:`mc-more`,children:[L(`summary`,{children:u(`setup.models.more`,{n:String(g.length)})}),L(`ul`,{className:`mc-list`,role:`group`,"aria-label":u(`setup.models.moreLabel`),children:g.map(b)})]}),_.length>0&&z(`details`,{className:`mc-more`,children:[L(`summary`,{children:u(`setup.models.installed`,{n:String(_.length)})}),_.length>bq&&L(`input`,{className:`settings-input mc-search`,type:`search`,value:f,onChange:e=>p(e.target.value),placeholder:u(`setup.models.search`),"aria-label":u(`setup.models.search`)}),L(`ul`,{className:`mc-list`,role:`radiogroup`,"aria-label":u(`setup.models.installedLabel`),children:v.map(e=>L(`li`,{className:`mc-row is-installed${t.defaultChat===e.id?` is-ticked`:``}`,children:z(`label`,{className:`mc-row-main`,children:[L(`input`,{type:`radio`,name:`${m}-installed`,className:`mc-radio`,checked:t.defaultChat===e.id,disabled:o,onChange:()=>r(e.id)}),z(`span`,{className:`mc-text`,children:[z(`span`,{className:`mc-name-line`,children:[L(`bdi`,{className:`mc-name`,title:e.id,children:e.name}),z(`span`,{className:`mc-chips`,children:[L(`span`,{className:`mc-chip`,children:u(`setup.models.purpose.chat`)}),JK(e)&&L(`span`,{className:`mc-chip is-npu`,children:u(`setup.models.npu`)})]})]}),z(`span`,{className:`mc-status`,children:[u(`setup.models.status.onPc`),` · `,u(`setup.models.useAsDefault`)]})]})]})},e.id))})]}),!a&&z(`div`,{className:`mc-default`,children:[L(`label`,{htmlFor:m,className:`mc-default-label`,children:u(`setup.models.defaultChat`)}),z(`select`,{id:m,className:`settings-input mc-select`,value:t.defaultChat??``,disabled:o||y.length===0,onChange:e=>r(e.target.value),children:[y.length===0&&L(`option`,{value:``,children:u.bare(`setup.models.noChat`)}),y.map(e=>z(`option`,{value:e.id,children:[e.name,JK(e)?` (${u(`setup.models.npu`)})`:``]},e.id))]})]})]})}function Mq(){let e=R();return z(`div`,{className:`mc`,"aria-busy":`true`,children:[z(`p`,{className:`setup-hint`,role:`status`,children:[L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,e(`setup.models.loading`)]}),L(`ul`,{className:`mc-list`,"aria-hidden":`true`,children:[0,1,2].map(e=>L(`li`,{className:`mc-row is-skeleton`,children:L(`span`,{className:`mc-skeleton`})},e))})]})}function Nq({entry:e}){let t=R();return e.support===`verified`?L(`span`,{className:`mc-chip is-verified`,children:t(`setup.label.verified`)}):e.support===`untested`?L(`span`,{className:`mc-chip is-untested`,children:t(`setup.label.untested`)}):null}function Pq({name:e,entry:t,checked:n,recommended:r,disabled:i,onPick:a,children:o}){let s=R();return L(`li`,{className:`mc-row${n?` is-ticked`:``}`,children:z(`label`,{className:`mc-row-main`,children:[L(`input`,{type:`radio`,className:`mc-radio`,name:e,checked:n,disabled:i||YK(t),onChange:a}),z(`span`,{className:`mc-text`,children:[z(`span`,{className:`mc-name-line`,children:[L(`span`,{className:`mc-name`,title:t.id,children:L(`bdi`,{children:t.name})}),z(`span`,{className:`mc-chips`,children:[r&&L(`span`,{className:`mc-pill`,children:s(`setup.models.recommended`)}),L(Nq,{entry:t}),JK(t)&&L(`bdi`,{className:`mc-chip is-npu`,children:s(`setup.models.npu`)})]})]}),L(`span`,{className:`mc-status`,children:Cq(t,s)}),t.fits===!1&&z(`span`,{className:`mc-warn is-big`,role:`note`,children:[L(Ws,{size:13,"aria-hidden":`true`}),` `,Tq(t,s)]}),t.fits===!0&&t.tight&&z(`span`,{className:`mc-warn`,role:`note`,children:[L(Ws,{size:13,"aria-hidden":`true`}),` `,s(`setup.models.warn.tight`)]}),o]})]})})}function Fq({label:e,note:t,size:n,checked:r,disabled:i,warning:a,chips:o,onChange:s}){return L(`li`,{className:`mc-row${r?` is-ticked`:``}${i?` is-off`:``}`,children:z(`label`,{className:`mc-row-main`,children:[L(`input`,{type:`checkbox`,className:`mc-input`,checked:r,disabled:i,onChange:e=>s(e.target.checked)}),L(`span`,{className:`mc-box`,"aria-hidden":`true`,children:L(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,children:L(`path`,{className:`mc-tick`,d:`M3.5 8.5l3 3 6-7`})})}),z(`span`,{className:`mc-text`,children:[z(`span`,{className:`mc-name-line`,children:[L(`span`,{className:`mc-name`,children:L(`bdi`,{children:e})}),L(`span`,{className:`mc-chips`,children:o})]}),L(`span`,{className:`mc-status`,children:L(`bdi`,{dir:`ltr`,children:n})}),L(`span`,{className:`mc-note`,children:t}),a&&z(`span`,{className:`mc-warn`,role:`note`,children:[L(Ws,{size:13,"aria-hidden":`true`}),` `,a]})]})]})})}function Iq({plan:e,selection:t,onSelection:n,disabled:r}){let i=R(),a=(0,B.useId)(),o=GK(e),[s,c]=(0,B.useState)(!1),l=o.find(e=>e.id===t.defaultChat),u=!!l&&JK(l),d=o.filter(e=>e.chat_choice&&!qK(e)&&(e.gaia_model||e.downloaded)&&JK(e)===u),f=d.filter(e=>e.support===`verified`),p=d.filter(e=>e.support!==`verified`),m=QK(o,t),h=!!l?.reads_images,g=o.filter(e=>KK(e)&&e.id!==l?.id),_=o.find(qK),v=e=>o.find(t=>XK(t)&&t.roles.includes(e)),y=e=>e.downloaded?i(`setup.models.status.onPc`):e.size_gb==null?i(`setup.contents.sizeOnDownload`):Sk(e.size_gb),b=(e,r)=>n(cq(t,o,e,r)),x=e=>n(eq(t,o,e)),S=e=>n(tq(t,o,e)),C=v(`speech`),w=v(`voice`),T=v(`image_creation`),E=ZK(l),D=l?.support===`untested`;return z(`div`,{className:`mc`,children:[z(`section`,{className:`mc-job`,"aria-labelledby":`${a}-chat`,children:[L(`h3`,{className:`mc-job-title`,id:`${a}-chat`,children:i(`setup.job.chat`)}),L(`p`,{className:`setup-hint`,children:i(`setup.job.verifiedNote`)}),L(`ul`,{className:`mc-list`,role:`radiogroup`,"aria-labelledby":`${a}-chat`,children:f.map(n=>L(Pq,{name:`${a}-chat-model`,entry:n,checked:n.id===t.defaultChat,recommended:n.id===e.recommended_model,disabled:r,onPick:()=>x(n.id)},n.id))}),p.length>0&&z(P.Fragment,{children:[L(`p`,{className:`setup-hint`,children:i(`setup.job.untestedNote`)}),L(`ul`,{className:`mc-list`,role:`radiogroup`,"aria-labelledby":`${a}-chat`,children:p.map(e=>L(Pq,{name:`${a}-chat-model`,entry:e,checked:e.id===t.defaultChat,recommended:!1,disabled:r,onPick:()=>x(e.id)},e.id))})]}),D&&z(`p`,{className:`mc-warn`,role:`note`,children:[L(Ws,{size:13,"aria-hidden":`true`}),` `,i(`setup.job.untestedPicked`)]})]}),z(`section`,{className:`mc-job`,"aria-labelledby":`${a}-vision`,children:[L(`h3`,{className:`mc-job-title`,id:`${a}-vision`,children:i(`setup.job.vision`)}),u?L(`p`,{className:`setup-hint`,role:`note`,children:i(`setup.job.visionOffNpu`,{name:l?.name??``})}):h?z(`div`,{className:`setup-card`,children:[z(`p`,{className:`mc-job-line`,children:[L(`bdi`,{children:i(`setup.job.visionBuiltIn`,{name:l?.name??``})}),L(`span`,{className:`setup-ok`,children:i(`setup.job.nothingMore`)})]}),L(`button`,{type:`button`,className:`link-btn`,"aria-expanded":s,onClick:()=>c(e=>!e),children:i(s?`setup.job.hideVision`:`setup.job.otherVision`)})]}):L(`p`,{className:`setup-hint`,children:i(`setup.job.visionNeeded`,{name:l?.name??``})}),!u&&(!h||s)&&z(`ul`,{className:`mc-list`,role:`radiogroup`,"aria-labelledby":`${a}-vision`,children:[g.map(e=>L(Pq,{name:`${a}-vision-model`,entry:e,checked:m===e.id,recommended:!h&&e.gaia_model&&e.support===`verified`,disabled:r,onPick:()=>S(e.id)},e.id)),L(`li`,{className:`mc-row${m===null?` is-ticked`:``}`,children:z(`label`,{className:`mc-row-main`,children:[L(`input`,{type:`radio`,className:`mc-radio`,name:`${a}-vision-model`,checked:h?m===l?.id:m===null,disabled:r,onChange:()=>S(h?null:`none`)}),z(`span`,{className:`mc-text`,children:[L(`span`,{className:`mc-name`,children:i(h?`setup.job.useChatForVision`:`setup.job.skipVision`)}),m===null&&!h&&z(`span`,{className:`mc-warn`,role:`note`,children:[L(Ws,{size:13,"aria-hidden":`true`}),` `,i(`setup.job.skipVisionNote`)]})]})]})})]})]}),_&&z(`section`,{className:`mc-job`,"aria-labelledby":`${a}-docs`,children:[L(`h3`,{className:`mc-job-title`,id:`${a}-docs`,children:i(`setup.job.documents`)}),L(`ul`,{className:`mc-list`,children:L(Fq,{label:_.name,note:i(`setup.models.line.documents`),size:y(_),checked:t.ticked.has(_.id),disabled:r,warning:t.ticked.has(_.id)?null:i(`setup.job.documentsOff`),chips:z(P.Fragment,{children:[L(`span`,{className:`mc-pill`,children:i(`setup.models.recommended`)}),L(Nq,{entry:_})]}),onChange:e=>b(_.id,e)})})]}),z(`section`,{className:`mc-job`,"aria-labelledby":`${a}-extras`,children:[L(`h3`,{className:`mc-job-title`,id:`${a}-extras`,children:i(`setup.job.extras`)}),L(`p`,{className:`setup-hint`,children:i(`setup.job.extrasNote`)}),z(`ul`,{className:`mc-list`,children:[C&&L(Fq,{label:i(`setup.job.speech`),note:i(`setup.job.speechNote`),size:y(C),checked:t.ticked.has(C.id),disabled:r,onChange:e=>b(C.id,e)}),w&&L(Fq,{label:i(`setup.job.voice`),note:i(`setup.job.voiceNote`),size:y(w),checked:t.ticked.has(w.id),disabled:r,onChange:e=>b(w.id,e)}),T&&L(Fq,{label:i(`setup.job.images`),note:i(`setup.job.imagesNote`),size:y(T),checked:t.ticked.has(T.id),disabled:r||!E,warning:E?null:i(`setup.job.imagesBlocked`,{name:l?.name??``}),onChange:e=>b(T.id,e)})]})]}),L(Lq,{plan:e,selection:t})]})}function Lq({plan:e,selection:t}){let n=R(),r=GK(e),i=e=>r.find(t=>t.id===e)?.name??e??n(`setup.get.off`),a=e=>r.find(n=>XK(n)&&n.roles.includes(e)&&t.ticked.has(n.id)),o=r.find(e=>qK(e)&&t.ticked.has(e.id)),s=r.find(e=>e.id===t.defaultChat),c=QK(r,t),l=[a(`speech`)&&n(`setup.job.speech`),a(`voice`)&&n(`setup.job.voice`)].filter(Boolean).join(`, `);return z(`section`,{className:`setup-card`,"aria-label":n(`setup.get.title`),children:[L(`h3`,{className:`mc-job-title`,children:n(`setup.get.title`)}),z(`dl`,{className:`setup-summary-list`,children:[z(`div`,{children:[L(`dt`,{children:n(`setup.job.chat`)}),L(`dd`,{children:L(`bdi`,{children:i(t.defaultChat)})})]}),z(`div`,{children:[L(`dt`,{children:n(`setup.job.vision`)}),L(`dd`,{children:L(`bdi`,{children:s&&JK(s)?n(`setup.get.offNpu`):c?i(c):n(`setup.get.off`)})})]}),z(`div`,{children:[L(`dt`,{children:n(`setup.job.documents`)}),L(`dd`,{children:L(`bdi`,{children:o?o.name:n(`setup.get.off`)})})]}),z(`div`,{children:[L(`dt`,{children:n(`setup.get.voice`)}),L(`dd`,{children:l||n(`setup.get.off`)})]}),z(`div`,{children:[L(`dt`,{children:n(`setup.job.images`)}),L(`dd`,{children:ZK(s)?a(`image_creation`)?n(`setup.get.on`):n(`setup.get.off`):n(`setup.get.notAvailable`)})]})]})]})}var Rq=(0,B.createContext)(void 0),zq=Rq.Provider;function Bq({children:e}){let t=(0,B.useContext)(Rq);return t===void 0?L(`div`,{className:`setup-row setup-nav`,children:e}):t===null?null:(0,mM.createPortal)(L(`div`,{className:`setup-footer-row`,children:e}),t)}function Vq({title:e,children:t,confirmLabel:n,cancelLabel:r,onConfirm:i,onCancel:a,danger:o,busy:s}){let c=(0,B.useRef)(null),l=(0,B.useRef)(null),u=(0,B.useId)(),d=(0,B.useId)();return un(c,!0),(0,B.useEffect)(()=>{let e=document.activeElement;return l.current?.focus(),()=>e?.focus?.()},[]),ut(!0,a,!s),(0,mM.createPortal)(L(`div`,{className:`confirm-overlay`,children:z(`div`,{ref:c,className:`confirm-sheet`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":u,"aria-describedby":t?d:void 0,children:[L(`h2`,{id:u,className:`confirm-title`,children:e}),t&&L(`div`,{id:d,className:`confirm-body`,children:t}),z(`div`,{className:`confirm-actions`,children:[L(`button`,{ref:l,type:`button`,className:`btn-secondary`,onClick:a,disabled:s,children:r}),L(`button`,{type:`button`,className:o?`btn-danger`:`btn-primary`,onClick:i,disabled:s,children:n})]})]})}),document.body)}function Hq(e){return e===`windows`?`Windows`:e===`linux`?`Linux`:e}function Uq(e){let t=/^Run:\s*(.+)$/.exec(e)??/^(sudo .+)$/.exec(e);return t?t[1].trim():null}function Wq(e,t){return e.setting&&Math.abs(e.setting.current_gb-t)<.05&&e.gpu_gb!=null?e.gpu_gb:e.presets?.find(e=>Math.abs(e.setting_gb-t)<.05)?.gpu_gb??null}function Gq(e,t,n=!1){return t==null?e(n?`gpu.appliedAny`:`gpu.pending.restartAny`):e(n?`gpu.applied`:`gpu.pending.restart`,{gb:Sk(t)})}function Kq(e){e.focus({preventScroll:!0});for(let t=e.parentElement;t;t=t.parentElement){let n=getComputedStyle(t).overflowY;if(n!==`auto`&&n!==`scroll`)continue;let r=e.getBoundingClientRect().top-t.getBoundingClientRect().top;(r<0||r>t.clientHeight-40)&&(t.scrollTop+=r-16);return}}function qq(e){return e instanceof Error?e.message:String(e)}function Jq({status:e,targetGpuGb:t}){let n=R(),r=e=>Math.round(e*10),i=r(e.total_gb??0),a=r(e.gpu_gb??0),o=t!=null&&r(t)>a?r(t):null,s=o==null?0:o-a,c=Math.max(0,i-a-s),l=e=>Sk(e/10),u=e=>i>0?Math.min(100,e/i*100):0,d=e.pending?.state===`took_effect`;return z(`div`,{className:`gpu-split`,children:[z(`div`,{className:`gpu-bar${d?` is-new`:``}`,role:`img`,"aria-label":o==null?n(`gpu.split.aria`,{cpu:l(c),gpu:l(a)}):n(`gpu.split.ariaTarget`,{cpu:l(c),gpu:l(o),now:l(a)}),children:[L(`span`,{className:`gpu-seg is-gpu`,style:{inlineSize:`${u(a)}%`}}),L(`span`,{className:`gpu-seg is-target`,style:{inlineSize:`${u(s)}%`}}),L(`span`,{className:`gpu-seg is-cpu`}),o!=null&&L(`span`,{className:`gpu-marker`,style:{insetInlineStart:`${u(o)}%`}})]}),z(`div`,{className:`gpu-legend`,"aria-hidden":`true`,children:[L(`span`,{className:`gpu-key is-gpu`,children:L(`bdi`,{children:n(`gpu.split.gpu`,{gb:l(a)})})}),o!=null&&L(`span`,{className:`gpu-key is-target`,children:L(`bdi`,{children:n(`gpu.split.added`,{gb:l(s)})})}),L(`span`,{className:`gpu-key is-cpu`,children:L(`bdi`,{children:n(`gpu.split.cpu`,{gb:l(c)})})})]})]})}function Yq({presets:e,value:t,onChange:n,recommended:r,max:i,keepGb:a,disabled:o}){let s=R();return z(jB,{className:`gpu-presets`,"aria-label":s(`gpu.presets.label`),children:[a!=null&&L(`button`,{type:`button`,role:`radio`,"aria-checked":t===null,className:`gpu-preset${t===null?` is-active`:``}`,disabled:o,onClick:()=>n(null),children:L(`bdi`,{children:s(`gpu.presets.keep`,{gb:Sk(a)})})}),e.map(e=>z(`button`,{type:`button`,role:`radio`,"aria-checked":e.setting_gb===t,className:`gpu-preset${e.setting_gb===t?` is-active`:``}`,disabled:o,onClick:()=>n(e.setting_gb),children:[L(`bdi`,{children:s(`gpu.presets.gpu`,{gb:Sk(e.gpu_gb)})}),e.setting_gb===r&&z(P.Fragment,{children:[` `,L(`span`,{className:`gpu-tag is-recommended`,children:s(`gpu.presets.recommended`)})]}),e.setting_gb===i&&z(P.Fragment,{children:[` `,L(`span`,{className:`gpu-tag is-max`,children:s(`gpu.presets.max`)})]})]},e.setting_gb))]})}function Xq({status:e,onStatus:t,mode:n,names:r,onSkip:i,onContinue:o,onBack:s,headingId:c,cloud:l=!1}){let u=R(),f=zc(e=>!!e.active?.remote)||l,p=(0,B.useCallback)(()=>{let e=c?document.getElementById(c):null;e&&Kq(e)},[c]);(0,B.useEffect)(()=>{n===`setup`&&p()},[n,p]);let m=(0,B.useId)(),h=e.presets??[],g=f?null:e.recommended_setting_gb??null,[_,v]=(0,B.useState)(g??(e.gpu_gb==null?h[0]?.setting_gb??null:null)),[y,b]=(0,B.useState)(!1),[x,S]=(0,B.useState)(null),[C,w]=(0,B.useState)(void 0),[T,E]=(0,B.useState)(null),[D,O]=(0,B.useState)(null),[ee,te]=(0,B.useState)(null),[ne,re]=(0,B.useState)(null),k=h.find(e=>e.setting_gb===_)??null,ie=h.length>0&&h[h.length-1].setting_gb===e.setting?.max_gb?h[h.length-1].setting_gb:null,ae=k&&e.total_gb!=null?Math.max(0,e.total_gb-k.gpu_gb):null,A=g==null&&!f?(e.models??[]).find(e=>e.default&&e.fits_now):void 0,oe=(k?.unlocks??[]).slice(0,2).map(e=>r[e]??e),se=e.pending??null,ce=e.method===`apply`,le=e.guided_value!==null,ue=(0,B.useCallback)(async()=>{b(!0),S(null),O(`steps`),te(null);try{let e=await Xe(_??void 0);w(e.guided_value),S(e.guided_value===null?[]:e.guided_steps??[])}catch(e){w(void 0),S([]),te({kind:`error`,message:qq(e)})}finally{O(null)}},[_]),de=async()=>{if(_!=null){E(null),O(`apply`),te(null);try{t(await we(_)),te({kind:`applied`})}catch(e){let t=e instanceof Vn&&e.httpStatus===403;te(t?{kind:`denied`}:{kind:`error`,message:qq(e)}),t&&p()}finally{O(null)}}},fe=async()=>{E(null),O(`revert`),te(null);try{t(await a()),te({kind:`applied`})}catch(e){te(e instanceof Vn&&e.httpStatus===403?{kind:`denied`}:{kind:`error`,message:qq(e)})}finally{O(null)}},pe=async()=>{if(_!=null){O(`done`),te(null);try{t(await ct(_)),b(!1)}catch(e){te({kind:`error`,message:qq(e)})}finally{O(null)}}},me=async()=>{O(`keep`),te(null);try{t(await d())}catch(e){te({kind:`error`,message:qq(e)})}finally{O(null)}},j=async e=>{try{await navigator.clipboard.writeText(e),re(e)}catch(e){te({kind:`error`,message:u(`gpu.copyFailed`,{reason:qq(e)})})}},he=se?.state===`restart_required`;return z(`div`,{className:`gpu`,children:[L(`p`,{className:`setup-hint`,children:u(`gpu.body`,{total:Sk(e.total_gb??0),gpu:Sk(e.gpu_gb??0)})}),L(Jq,{status:e,targetGpuGb:!he&&!y?k?.gpu_gb??null:null}),se?.state===`took_effect`&&z(`div`,{className:`gpu-notice is-ok`,role:`status`,children:[L(Yr,{size:14,"aria-hidden":`true`}),L(`span`,{children:u(`gpu.pending.tookEffect`,{gb:Sk(e.gpu_gb??0)})}),L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void me(),disabled:D!==null,children:u(`gpu.ok`)})]}),he&&z(`div`,{className:`gpu-notice`,role:`status`,children:[L(Na,{size:14,"aria-hidden":`true`}),L(`span`,{children:u.compose(t=>[Gq(t,Wq(e,se.setting_gb),ee?.kind===`applied`),t(`gpu.pending.restartHow`),n===`setup`?t(`gpu.pending.downloadsFirst`):null].filter(Boolean).join(` `))}),se.source===`guided`&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void me(),disabled:D!==null,children:u(`gpu.keep`,{gb:Sk(e.gpu_gb??0)})})]}),se?.state===`not_applied`&&z(`div`,{className:`gpu-notice is-warn`,role:`status`,children:[L(Ws,{size:14,"aria-hidden":`true`}),L(`span`,{children:u(`gpu.pending.notApplied`,{gb:Sk(e.gpu_gb??0)})}),L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void me(),disabled:D!==null,children:u(`gpu.keep`,{gb:Sk(e.gpu_gb??0)})})]}),!he&&!y&&h.length>0&&z(P.Fragment,{children:[A&&z(`p`,{className:`gpu-unlock is-keep`,children:[L(Yr,{size:13,"aria-hidden":`true`}),` `,u(`gpu.keepRecommended`,{model:r[A.id]??A.id})]}),L(Yq,{presets:h,value:_,onChange:v,recommended:g,max:ie,keepGb:e.gpu_gb??null,disabled:D!==null}),k&&L(`p`,{className:`gpu-unlock`,children:oe.length>0?u(oe.length>1?`gpu.unlock.two`:`gpu.unlock.one`,{gb:Sk(k.gpu_gb),a:oe[0],b:oe[1]??``}):u(`gpu.unlock.none`,{gb:Sk(k.gpu_gb)})}),k&&k.setting_gb===ie&&ae!=null&&z(`p`,{className:`gpu-unlock is-warn`,role:`note`,children:[L(Ws,{size:13,"aria-hidden":`true`}),` `,u(`gpu.maxWarn`,{cpu:Sk(ae),os:Hq(e.os)})]}),L(`p`,{className:`setup-hint`,children:u.compose(t=>`${t(`gpu.reserve`,{gb:Sk(e.reserve_gb??16),os:Hq(e.os)})} ${t(`gpu.needs`)}`)}),!ce&&e.method_reason&&L(`p`,{className:`setup-hint`,children:L(`bdi`,{dir:`ltr`,children:e.method_reason})})]}),!he&&!y&&h.length===0&&L(`p`,{className:`setup-hint`,children:u(`gpu.noPresets`)}),y&&z(`div`,{className:`gpu-guided`,children:[k&&L(`p`,{className:`setup-hint`,id:m,children:u(`gpu.guided.lede`,{gb:Sk(k.gpu_gb)})}),x===null?z(`p`,{className:`setup-hint`,role:`status`,children:[L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,u(`gpu.guided.loading`)]}):C===null?L(`p`,{className:`setup-hint`,children:u(`gpu.noPresets`)}):L(`ol`,{className:`gpu-steps`,"aria-labelledby":m,children:x.map(e=>{let t=Uq(e);return z(`li`,{children:[L(`span`,{children:e}),t&&z(`button`,{type:`button`,className:`btn-secondary gpu-copy`,onClick:()=>void j(t),"aria-label":u(`gpu.copyAria`,{what:t}),children:[L(ne===t?Yr:Ti,{size:12,"aria-hidden":`true`}),u(ne===t?`gpu.copied`:`gpu.copy`)]})]},e)})}),z(Bq,{children:[L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>b(!1),disabled:D!==null,children:u(`gpu.guided.back`)}),!ce&&C!==null&&z(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void pe(),disabled:D!==null||_==null,children:[D===`done`&&L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,u(`gpu.guided.done`)]})]})]}),D===`apply`||D===`revert`?z(`p`,{className:`setup-hint`,role:`status`,children:[L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,u(`gpu.waiting`)]}):null,ee?.kind===`denied`&&z(`div`,{className:`gpu-notice is-warn`,role:`alert`,children:[L(Ws,{size:14,"aria-hidden":`true`}),L(`span`,{children:u(`gpu.denied`)})]}),ee?.kind===`error`&&L(`p`,{className:`setup-error`,role:`alert`,children:ee.message}),!y&&(()=>{let t=!he&&ce&&h.length>0&&L(`button`,{type:`button`,className:`btn-primary`,onClick:()=>E(`apply`),disabled:D!==null||_==null,children:ee?.kind===`denied`||se?.state===`not_applied`?u(`gpu.tryAgain`):u(`gpu.apply`)}),r=!he&&h.length>0&&le&&L(`button`,{type:`button`,className:ce?`btn-secondary`:`btn-primary`,onClick:()=>void ue(),disabled:D!==null||_==null,children:u(`gpu.showMe`)});return n===`setup`?z(Bq,{children:[s&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:s,children:u(`setup.back`)}),he?o&&L(`button`,{type:`button`,className:`btn-primary`,onClick:o,autoFocus:!0,children:u(`setup.continue`)}):_==null&&h.length>0?(i??o)&&L(`button`,{type:`button`,className:`btn-primary`,onClick:i??o,disabled:D!==null,children:u(`gpu.keepAsIs`)}):z(P.Fragment,{children:[i&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:i,disabled:D!==null,children:u(`gpu.skip`)}),ce?z(P.Fragment,{children:[r,t]}):r]})]}):z(`div`,{className:`setup-row gpu-actions`,children:[t,r,e.revert?.available&&z(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>E(`revert`),disabled:D!==null,children:[L(ns,{size:13,"aria-hidden":`true`}),` `,u(`gpu.undo`)]})]})})(),T===`apply`&&_!=null&&z(Vq,{title:k?u(`gpu.consent.title`,{gb:Sk(k.gpu_gb)}):u(`gpu.consent.titleAny`),confirmLabel:u(`setup.continue`),cancelLabel:u(`setup.cancel`),onConfirm:()=>void de(),onCancel:()=>E(null),children:[L(`p`,{children:k?u(`gpu.consent.body`,{name:e.setting?.name??``,gb:Sk(k.gpu_gb)}):u(`gpu.consent.bodyAny`,{name:e.setting?.name??``})}),L(`p`,{className:`confirm-note`,children:u(`gpu.consent.saved`,{gb:Sk(e.gpu_gb??0)})})]}),T===`revert`&&L(Vq,{title:u(`gpu.revert.title`),confirmLabel:u(`setup.continue`),cancelLabel:u(`setup.cancel`),onConfirm:()=>void fe(),onCancel:()=>E(null),children:L(`p`,{children:u(`gpu.revert.body`)})})]})}function Zq({plan:e,planError:t,onRetryPlan:n,onUseRecommended:r,selection:i,onSelection:a,cloud:o,keepTrying:s,onKeepTrying:c,onBack:l,onContinue:u,busy:d,error:f}){let p=R(),m=(0,B.useRef)(null),[h,g]=(0,B.useState)(!1),_=!!e&&!!i&&!!e.catalog,v=(0,B.useRef)(null);if(_&&v.current===null&&(v.current=!o&&dq(GK(e),i).length===0&&!!i.defaultChat&&GK(e).some(e=>e.downloaded)),(0,B.useEffect)(()=>{_&&m.current?.querySelector(`input:not([disabled])`)?.focus()},[_,h]),t&&!_)return z(`div`,{className:`setup-models-error`,children:[L(`p`,{className:`setup-error`,role:`alert`,children:p(`setup.models.listFailed`,{reason:t})}),z(`div`,{className:`setup-row`,children:[L(`button`,{type:`button`,className:`btn-primary`,onClick:n,children:p(`setup.tryAgain`)}),L(`button`,{type:`button`,className:`btn-secondary`,onClick:r,children:p(`setup.models.useRecommended`)})]}),L(`p`,{className:`setup-hint`,children:p(`setup.models.useRecommendedNote`)})]});if(!_)return L(Mq,{});let y=GK(e),b=dq(y,i),x=!o&&!i.defaultChat,S=pq(e,i),C=o?[]:y.filter(e=>e.fits===!1&&i.ticked.has(e.id)),w=!h&&!!v.current&&b.length===0,T=p(S?`setup.continueAnyway`:`setup.continue`);return w?z(`div`,{className:`setup-present`,role:`status`,children:[z(`p`,{children:[L(Yr,{size:14,"aria-hidden":`true`}),` `,p(`setup.models.allPresent`)]}),L(`button`,{type:`button`,className:`link-btn`,onClick:()=>g(!0),children:p(`setup.models.change`)}),z(Bq,{children:[L(`button`,{type:`button`,className:`btn-secondary`,onClick:l,disabled:d,children:p(`setup.back`)}),z(`button`,{type:`button`,className:`btn-primary`,onClick:()=>u(!1),disabled:d,children:[d&&L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,p(`setup.finish`)]})]}),f&&L(`p`,{className:`setup-error`,role:`alert`,children:f})]}):z(`div`,{className:`setup-models`,ref:m,children:[L(`p`,{className:`setup-hint`,children:p(`setup.job.lede`)}),L(Iq,{plan:e,selection:i,onSelection:a,disabled:d}),!o&&L(`button`,{type:`button`,className:`link-btn setup-reset`,onClick:()=>a(uq(e)),disabled:d,children:p(`setup.models.resetRecommended`)}),z(`div`,{className:`setup-models-footer`,children:[L(Oq,{plan:e,selection:i}),z(`label`,{className:`setup-keep-trying`,children:[L(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked),disabled:d}),L(`span`,{children:p(`setup.keepTrying`)})]}),L(WK,{open:x,children:L(`p`,{className:`setup-error`,id:`setup-no-chat`,children:p(`setup.models.noChatReason`)})}),C.length>0&&L(`span`,{className:`visually-hidden`,children:C.map(e=>Tq(e,p)).join(` `)}),f&&L(`p`,{className:`setup-error`,role:`alert`,children:f}),z(Bq,{children:[L(`button`,{type:`button`,className:`btn-secondary`,onClick:l,disabled:d,children:p(`setup.back`)}),z(`button`,{type:`button`,className:`btn-primary`,onClick:()=>u(!!S),disabled:d||x,"aria-describedby":x?`setup-no-chat`:void 0,children:[d&&L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,T]})]})]})]})}function Qq({plan:e,chatModel:t,gpu:n}){let r=R();if(!e?.catalog)return null;let i=e.catalog,a=e=>e?i.find(t=>t.id===e)?.name??e:null,o=QK(i,{ticked:new Set,unticked:new Set,chatChosen:!1,defaultChat:t,vision:e.vision_model??null}),s=i.find(e=>e.id===o)??i.find(e=>KK(e)&&e.gaia_model),c=i.find(e=>qK(e)&&e.downloaded),l=i.filter(e=>e.gaia_model&&e.planned&&e.skipped),u=n?.pending,d=i.find(e=>e.id===t);return z(`dl`,{className:`setup-summary-list`,children:[t&&z(`div`,{children:[L(`dt`,{children:r(`setup.ready.chat`)}),z(`dd`,{children:[L(`bdi`,{children:a(t)}),d?.recipe===`flm`?` (${r(`setup.models.npu`)})`:``]})]}),z(`div`,{children:[L(`dt`,{children:r(`setup.ready.vision`)}),L(`dd`,{children:s?.downloaded?L(`bdi`,{children:s.name}):r(`setup.ready.visionOff`,{name:s?.name??`Gemma-4-E4B-it`})})]}),c&&z(`div`,{children:[L(`dt`,{children:r(`setup.ready.documents`)}),L(`dd`,{children:L(`bdi`,{children:c.name})})]}),l.length>0&&z(`div`,{children:[L(`dt`,{children:r(`setup.ready.notInstalled`)}),L(`dd`,{children:l.map(e=>e.name).join(`, `)})]}),u?.state===`restart_required`&&z(`div`,{className:`is-warn`,children:[L(`dt`,{children:r(`setup.ready.gpu`)}),z(`dd`,{children:[L(Ws,{size:13,"aria-hidden":`true`}),` `,Gq(r,n?Wq(n,u.setting_gb):null)]})]}),u?.state===`took_effect`&&z(`div`,{children:[L(`dt`,{children:r(`setup.ready.gpu`)}),L(`dd`,{children:n?.gpu_gb==null?r(`setup.ready.gpuChanged`):r(`setup.ready.gpuNow`,{gb:Sk(n.gpu_gb)})})]})]})}function $q(e){if(e.skill===`document-brief`){let t=/^(\d+) /.exec(e.note)?.[1];return t?{n:Number(t)}:void 0}if(e.skill===`coding`){let t=/^In (.+)$/.exec(e.note)?.[1];return t?{folder:t}:void 0}}function eJ(e,t,n,r){let i=`${n}.one`,a=`${n}.other`,o=fe(i)&&fe(a)&&typeof r?.n==`number`?r.n===1?i:a:n;return!fe(o)||Be[o].includes(`{`)&&!r?t:mt(o,r)===t?e(o,r):t}function tJ(e,t){return{title:eJ(t,e.title,`card.${e.skill}.title`),note:eJ(t,e.note,`card.${e.skill}.note`,$q(e))}}function nJ({text:e}){let t=b(e);return t.length===1?L(P.Fragment,{children:e}):L(P.Fragment,{children:t.map((e,t)=>L(`span`,{className:`start-card-part`,children:e},t))})}function rJ({cards:e,onPick:t,disabled:n}){let r=R();return e.length===0?null:L(`ul`,{className:`start-cards`,"aria-label":r(`newChat.cardsLabel`),children:e.map(e=>{let{title:i,note:a}=tJ(e,r);return L(`li`,{children:z(`button`,{type:`button`,className:`start-card`,onClick:()=>t(e),disabled:n,title:e.needs_input?`${e.prompt}…`:e.prompt,children:[z(`span`,{className:`start-card-title`,children:[i,L(Tr,{size:13,"aria-hidden":`true`})]}),L(`span`,{className:`start-card-note`,children:L(nJ,{text:a})})]})},e.skill)})})}function iJ(){let[e,t]=(0,B.useState)(null),[n,r]=(0,B.useState)([]),i=(0,B.useCallback)(()=>{Promise.resolve(gt()).then(e=>{t(e?.providers?.find(e=>e.id===`amd`)?.network??null),r(e?.providers??[])}).catch(e=>{console.warn(`[useGatewayNetwork] could not check the AMD gateway`,e),t(null)})},[]);return(0,B.useEffect)(i,[i]),{network:e,providers:n,recheck:i}}function aJ(e,t,n){return t===`active`?n(`setup.contents.working`):t===`done`?n(`setup.contents.ready`):t===`failed`?n(`setup.contents.failed`):e.installed?n(`setup.contents.alreadyHere`):n(`setup.contents.waiting`)}function oJ(e,t){return e==null?t(`setup.contents.sizeOnDownload`):Sk(e)}function sJ({state:e}){return e===`done`?L(Yr,{size:13,"aria-hidden":`true`}):e===`active`?L(Za,{size:13,className:`spin`,"aria-hidden":`true`}):L(e===`failed`?nc:_i,{size:13,"aria-hidden":`true`})}function cJ({id:e,error:t,transient:n,onRetry:r,disabled:i}){let a=R(),o=a(`setup.component.${e}`);return z(`div`,{className:`setup-content-failure`,role:`alert`,children:[L(`p`,{children:a(n?`setup.contents.failedNetwork`:`setup.contents.failedOther`,{name:o})}),t&&z(`details`,{className:`dl-details`,children:[L(`summary`,{children:a(`setup.progress.details`)}),L(`pre`,{dir:`ltr`,children:t})]}),r&&L(`button`,{type:`button`,className:`btn-primary`,onClick:r,disabled:i,"aria-label":a(`setup.contents.retryNamed`,{name:o}),children:a(`setup.progress.retry`)})]})}function lJ({plan:e,run:t,models:n=[],onRetry:r,retryDisabled:i}){let a=R();return z(`ul`,{className:`setup-contents`,children:[(e.components??[]).map(e=>{let n=t?.components?.[e.id],o=t!=null&&t.state!==`running`&&t.state!==`verifying`,s=n===`active`&&o?void 0:n;return z(`li`,{className:`setup-content is-${s??(e.installed?`done`:`waiting`)}`,children:[L(`span`,{className:`setup-content-icon`,children:L(sJ,{state:s??(e.installed?`done`:void 0)})}),z(`span`,{className:`setup-content-main`,children:[L(`span`,{className:`setup-content-name`,children:a(`setup.component.${e.id}`)}),L(`span`,{className:`setup-content-note`,children:a(`setup.component.${e.id}Note`)}),e.bundled?L(`span`,{className:`setup-content-from`,children:a(`setup.contents.bundled`)}):z(`span`,{className:`setup-content-from`,children:[a(`setup.contents.from`),` `,L(`bdi`,{dir:`ltr`,children:e.source})]})]}),z(`span`,{className:`setup-content-side`,children:[L(`bdi`,{dir:`ltr`,children:oJ(e.size_gb,a)}),L(`span`,{children:aJ(e,s,a)})]}),s===`failed`&&o&&!t?.problem&&L(cJ,{id:e.id,error:t?.error,transient:t?.component_kinds?.[e.id]===`transient`,onRetry:r,disabled:i})]},e.id)}),n.map(e=>z(`li`,{className:`setup-content is-waiting`,children:[L(`span`,{className:`setup-content-icon`,children:L(sJ,{state:void 0})}),z(`span`,{className:`setup-content-main`,children:[L(`span`,{className:`setup-content-name`,children:L(`bdi`,{children:e.name})}),L(`span`,{className:`setup-content-note`,children:e.roles.map(e=>a(`setup.purpose.${e}`)).join(` · `)}),e.source&&z(`span`,{className:`setup-content-from`,children:[a(`setup.contents.from`),` `,L(`bdi`,{dir:`ltr`,children:e.source})]})]}),L(`span`,{className:`setup-content-side`,children:L(`bdi`,{dir:`ltr`,children:oJ(e.size_gb,a)})})]},e.id))]})}function uJ({lines:e,className:t,id:n}){let r=(0,B.useRef)(null),i=(0,B.useRef)(!0),a=e.join(`
|
|
210
|
+
`);return(0,B.useEffect)(()=>{let e=r.current;e&&i.current&&(e.scrollTop=e.scrollHeight)},[a]),L(`pre`,{ref:r,id:n,className:t,dir:`ltr`,tabIndex:0,onScroll:e=>{let t=e.currentTarget;i.current=t.scrollHeight-t.scrollTop-t.clientHeight<8},children:a})}var dJ=1e9,fJ={downloading:0,verifying:1,failed:2,ready:3,unchecked:3,cancelled:4,queued:5,skipped:6};function pJ(e){return e.roles.includes(`embedding`)?0:e.roles.includes(`chat`)?1:2}function mJ(e){return[...e].filter(e=>e.state!==`skipped`).sort((e,t)=>fJ[e.state]-fJ[t.state]||pJ(e)-pJ(t))}var hJ=/^\s*(Downloading:|Downloaded\b|\[[=\-\s>#]*\])/;function gJ(e){return e.some(e=>e.trim()&&!hJ.test(e))}var _J={queued:`setup.state.queued`,downloading:`setup.state.downloading`,verifying:`setup.state.verifying`,ready:`setup.state.ready`,failed:`setup.state.failed`,skipped:`setup.state.skipped`,cancelled:`setup.state.cancelled`,unchecked:`setup.state.unchecked`};function vJ(e){return e?e.state===`running`||e.state===`verifying`||!!e.models?.some(e=>e.state===`downloading`||e.state===`queued`||e.state===`verifying`):!1}function yJ(e,t,n,r){switch(e.error_kind){case`network`:return r(`setup.fail.network`,{name:t});case`disk_full`:{let i=Math.max(0,e.bytes_total-e.bytes_done)/1e9,a=n==null?i:Math.max(.1,i-n);return r(`setup.fail.diskFull`,{name:t,done:Ek(e.bytes_done),need:Sk(a)})}case`verify`:return r(`setup.fail.verify`,{name:t});case`memory`:return r(`setup.fail.testMemory`,{name:t});case`stuck`:return r(`setup.fail.testStuck`,{name:t});case`answer`:return r(`setup.fail.testAnswer`,{name:t});case`window`:return r(`setup.fail.testWindow`,{name:t});case`path_too_long`:return r(`setup.fail.pathTooLong`,{name:t});default:return r(`setup.fail.lemonade`,{name:t})}}function bJ({model:e,name:t,estimate:n,now:r,freeGb:i,onRetry:a,onResume:o,onSkip:s,onRestart:c,busy:l,retryLater:u,checking:d,checkingFor:f}){let p=R(),m=(0,B.useId)(),h=(0,B.useId)(),[g,_]=(0,B.useState)(!1),v=e.log??[],y=e.bytes_total>0?Math.min(100,e.bytes_done/e.bytes_total*100):e.state===`ready`?100:0,b=p(_J[e.state]),x=e.retrying_until?Math.max(0,Math.round(e.retrying_until-r/1e3)):0,S=e.state===`downloading`&&!x?n?.stalledFor??0:0,C=e.state===`verifying`&&d||e.state===`downloading`&&!x&&S<15,w;if(e.state===`downloading`){let t=Ok(p.locale,e.bytes_total>0?`${Ek(e.bytes_done)} / ${Ek(e.bytes_total)}`:Ek(e.bytes_done));if(x>0)w=p(`setup.progress.retrying`,{n:String(x)});else if(S>=60)w=p(`setup.progress.stuck`);else if(S>=15)w=p(`setup.progress.stalled`,{n:`15`});else if(n?.speed&&n.eta!=null){let{speed:e,eta:r}=n;w=p.compose(n=>`${t} · ${Ok(p.locale,Dk(e))} · ${kk(r,n)}`)}else w=p.compose(e=>`${t} · ${e(`setup.progress.estimating`)}`)}else w=e.state===`verifying`?d?f>=10?p(`setup.progress.checkingFor`,{n:String(f)}):p(`setup.progress.checkingLoad`):p(`setup.progress.waitingCheck`):e.state===`ready`?e.bytes_total?Ek(e.bytes_total):``:e.state===`unchecked`?p(`setup.progress.unchecked`):e.state===`cancelled`?e.bytes_done>0?p(`setup.progress.keptPartial`,{done:Ek(e.bytes_done)}):``:e.state===`queued`&&e.bytes_total?Ek(e.bytes_total):``;let T=e.state===`downloading`?p.compose(t=>[t(`setup.progress.percent`,{n:String(Math.floor(y))}),e.bytes_total?t(`setup.progress.of`,{done:Ek(e.bytes_done),total:Ek(e.bytes_total)}):null,n?.eta==null?null:Ak(n.eta,t)].filter(Boolean).join(`, `)):b;return z(`li`,{className:`dl-row is-${e.state}${C?` is-live`:``}${S>=15?` is-stalled`:``}`,children:[z(`div`,{className:`dl-row-head`,children:[L(`span`,{className:`dl-icon`,"aria-hidden":`true`,children:e.state===`ready`||e.state===`unchecked`?L(Yr,{size:14}):e.state===`failed`?L(di,{size:14}):e.state===`cancelled`?L(Mo,{size:13}):L(`span`,{className:`dl-dot`})}),L(`span`,{className:`dl-name`,children:L(`bdi`,{title:e.id,children:t})}),L(`span`,{className:`dl-state`,children:b}),e.state===`downloading`&&z(`bdi`,{className:`dl-pct`,children:[Math.floor(y),`%`]}),e.state!==`failed`&&gJ(v)&&L(`button`,{type:`button`,className:`dl-log-toggle`,onClick:()=>_(e=>!e),"aria-expanded":g,"aria-controls":h,"aria-label":p(`setup.progress.logFor`,{name:t}),title:p(`setup.progress.logFor`,{name:t}),children:L(ri,{size:14,className:g?`is-open`:``,"aria-hidden":`true`})})]}),L(`div`,{className:`dl-track`,role:`progressbar`,"aria-label":p(`setup.progress.rowLabel`,{name:t,state:b}),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":C&&e.state===`verifying`?void 0:Math.floor(y),"aria-valuetext":T,children:L(`span`,{className:`dl-fill`,style:{inlineSize:`${e.state===`verifying`?100:y}%`}})}),w&&L(`p`,{className:`dl-detail`,children:L(`bdi`,{children:w})}),g&&e.state!==`failed`&&gJ(v)&&L(uJ,{lines:v,id:h,className:`dl-log`}),e.state===`failed`&&z(`div`,{className:`dl-fail`,children:[L(`p`,{className:`dl-error`,id:m,children:yJ(e,t,i,p)}),(v.length>0||e.error)&&z(`details`,{className:`dl-details`,children:[L(`summary`,{children:p(`setup.progress.details`)}),L(`pre`,{dir:`ltr`,children:v.length>0?v.join(`
|
|
211
|
+
`):e.error})]}),u?L(`p`,{className:`dl-detail`,children:p(`setup.progress.retryLater`)}):z(`div`,{className:`setup-row`,children:[a&&z(`button`,{type:`button`,className:`btn-primary`,disabled:l,onClick:()=>a(e.id,e.error_kind),"aria-describedby":m,children:[L(is,{size:13,"aria-hidden":`true`}),` `,p(`setup.progress.retry`)]}),s&&L(`button`,{type:`button`,className:`btn-secondary`,disabled:l,onClick:()=>s(e.id),children:p(`setup.progress.skipModel`)})]})]}),e.state===`cancelled`&&o&&L(`div`,{className:`setup-row`,children:L(`button`,{type:`button`,className:`btn-secondary`,disabled:l,onClick:()=>o(e.id),children:p(`setup.progress.resume`)})}),S>=60&&c&&L(`div`,{className:`setup-row`,children:z(`button`,{type:`button`,className:`btn-secondary`,disabled:l,onClick:c,children:[L(is,{size:13,"aria-hidden":`true`}),` `,p(`setup.progress.retry`)]})})]})}function xJ({status:e,names:t,freeGb:n=null,onCancel:r,onRetry:i,onResume:a,onResumeAll:o,onSkip:s,onRestart:c,busy:l=!1,retryLater:u=!1,labelledBy:d}){let f=R(),p=HK(),m=(0,B.useMemo)(()=>mJ(e.models??[]),[e.models]),h=(0,B.useRef)(new Map),g=(0,B.useRef)(new Map),_=(0,B.useRef)(new Mk),v=(0,B.useRef)(!1),[y,b]=(0,B.useState)(()=>Date.now()),[x,S]=(0,B.useState)(!1),[C,w]=(0,B.useState)(null),T=i&&((e,t)=>{let n=m.find(t=>t.id===e);t===`verify`&&n?w(n):i(e,t)}),[E,D]=(0,B.useState)(``),[O,ee]=(0,B.useState)(``),te=(0,B.useRef)(null),ne=e.state===`verifying`||e.state!==`running`&&m.some(e=>e.state===`verifying`),re=(0,B.useRef)(new Map);(0,B.useEffect)(()=>{if(!p||!(m.some(e=>e.retrying_until)||ne))return;let e=setInterval(()=>b(Date.now()),1e3);return()=>clearInterval(e)},[m,p,ne]);let k=e.overall,{estimates:ie,overallEstimate:ae}=(0,B.useMemo)(()=>{let e=Date.now(),t={};for(let n of m){if(n.state!==`downloading`){h.current.delete(n.id);continue}let r=h.current.get(n.id),i=n.downloaded_before_gb??null;r&&g.current.get(n.id)===i||(r=new Mk,h.current.set(n.id,r),g.current.set(n.id,i)),t[n.id]=r.update(n.bytes_done,n.bytes_total,e)}let n=m.some(e=>e.state===`downloading`);n&&!v.current&&(_.current=new Mk),v.current=n;let r=m.filter(e=>e.state===`downloading`||e.state===`queued`).reduce((e,t)=>e+Math.max(0,t.bytes_total-t.bytes_done),0);return{estimates:t,overallEstimate:n&&k?_.current.update(k.bytes_done,k.bytes_done+r,e):void 0}},[m,k]);(0,B.useEffect)(()=>{let e=new Map(m.map(e=>[e.id,e.state])),n=Math.floor((k?.percent??0)/25),r=te.current;if(te.current={states:e,quarter:n},!r)return;let i=[];for(let e of m){if(r.states.get(e.id)===e.state)continue;let n=t[e.id]??e.id;e.state===`failed`?ee(f(`setup.progress.announceFailed`,{name:n})):i.push(f(`setup.progress.announceState`,{name:n,state:f(_J[e.state])}))}n>r.quarter&&n>0&&n<4&&i.push(f(`setup.progress.announceOverall`,{n:String(n*25)})),i.length&&D(i.join(`. `))},[m,k?.percent,t,f]);let A=e=>{if(!ne)return re.current.delete(e),0;let t=Date.now(),n=re.current.get(e)??t;return re.current.set(e,n),Math.floor((t-n)/1e3)},oe=vJ(e),se=m.filter(e=>e.state===`cancelled`),ce=k?.failed??m.filter(e=>e.state===`failed`).length,le=k?.percent??0,ue=()=>{(k?.bytes_done??0)>dJ?S(!0):r?.()},de=f.compose(e=>[e(`setup.progress.overallPct`,{n:String(le)}),k&&k.bytes_total>0?e(`setup.progress.of`,{done:Ek(k.bytes_done),total:Ek(k.bytes_total)}):null,oe&&ae?.speed?Ok(f.locale,Dk(ae.speed)):null,oe?ae?.eta==null?e(`setup.progress.estimating`):e(`setup.progress.left`,{eta:kk(ae.eta,e)}):null,ce>0?e(`setup.progress.failedCount`,{n:String(ce)}):null].filter(Boolean).join(` · `));return z(`section`,{className:`dl${p?``:` is-paused`}`,"aria-labelledby":d,children:[z(`div`,{className:`dl-overall`,children:[L(`p`,{className:`dl-overall-line`,children:L(`bdi`,{children:de})}),L(`div`,{className:`dl-track is-overall${m.some(e=>e.state===`downloading`)?` is-live`:``}`,role:`progressbar`,"aria-label":f(`setup.progress.overallLabel`),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":le,"aria-valuetext":f(`setup.progress.percent`,{n:String(le)}),children:L(`span`,{className:`dl-fill`,style:{inlineSize:`${le}%`}})})]}),L(`ul`,{className:`dl-list`,children:m.map(e=>L(bJ,{model:e,name:t[e.id]??e.id,estimate:ie[e.id],now:y,freeGb:n,onRetry:T,onResume:oe?void 0:a,onSkip:s,onRestart:c,busy:l,retryLater:u,checking:ne,checkingFor:A(e.id)},e.id))}),oe&&L(`p`,{className:`setup-hint dl-controls`,children:f(`setup.progress.keepsGoing`)}),(oe&&r||!oe&&se.length>0&&o)&&z(Bq,{children:[oe&&r&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:ue,disabled:l,children:f(`setup.progress.cancel`)}),!oe&&se.length>0&&o&&L(`button`,{type:`button`,className:`btn-primary`,onClick:o,disabled:l,children:f(`setup.progress.resumeAll`)})]}),L(`span`,{className:`visually-hidden`,"aria-live":`polite`,children:E}),L(`span`,{className:`visually-hidden`,role:`alert`,children:O}),x&&L(Vq,{title:f(`setup.progress.cancelTitle`),confirmLabel:f(`setup.progress.cancelConfirm`),cancelLabel:f(`setup.progress.cancelKeep`),onConfirm:()=>{S(!1),r?.()},onCancel:()=>S(!1),children:L(`p`,{children:f(`setup.progress.cancelBody`)})}),C&&L(Vq,{title:f(`setup.redownload.title`,{name:t[C.id]??C.id}),confirmLabel:f(`setup.redownload.confirm`),cancelLabel:f(`setup.redownload.keep`),onConfirm:()=>{let e=C;w(null),i?.(e.id,`verify`)},onCancel:()=>w(null),children:L(`p`,{children:f(`setup.redownload.body`,{name:t[C.id]??C.id,size:Ek(C.bytes_total)})})})]})}function SJ({run:e,plan:t,idle:n,bar:r=!0}){let i=R(),a=t?.components??[],o=a.find(t=>e.components?.[t.id]===`active`),s=a.filter(t=>e.components?.[t.id]===`done`||e.components?.[t.id]==null&&t.installed).length,c=e.percent==null?null:Math.max(0,Math.min(100,Math.round(e.percent))),l=o?i(`setup.download.now`,{name:i(`setup.component.${o.id}`)}):n;return z(`div`,{className:`setup-activity`,children:[z(`p`,{className:`setup-hint`,children:[L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,L(`span`,{role:`status`,children:l}),c!=null&&z(P.Fragment,{children:[` · `,z(`bdi`,{dir:`ltr`,children:[c,`%`]})]}),a.length>0&&z(P.Fragment,{children:[` · `,i(`setup.download.partsReady`,{done:String(s),total:String(a.length)})]})]}),r&&c!=null&&L(`progress`,{className:`setup-progress`,max:100,value:c,"aria-label":l})]})}var CJ=[`check`,`download`,`test`],wJ={root:`setup-report`,button:`btn-secondary setup-report-button`,hint:`setup-hint`,error:`setup-error`},TJ=/\d+(\.\d+)?\s*%/;function EJ(e){let t=[],n=null;for(let r of e){let e=r.search(TJ),i=e>=0?r.slice(0,e):null;i!==null&&i===n?t[t.length-1]=r:t.push(r),n=i}return t}function DJ({run:e,before:t={},failed:n=!1}){let r=R(),[i,a]=(0,B.useState)(n),[o,s]=(0,B.useState)(()=>new Set);(0,B.useEffect)(()=>{n&&a(!0)},[n]);let c=e=>s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),l=n=>EJ([...t[n]??[],...e?.logs?.[n]??[]]),u=CJ.filter(e=>l(e).length>0);return z(`section`,{className:`setup-logs`,"aria-label":r(`setup.logs.title`),children:[z(`button`,{type:`button`,className:`setup-log-toggle setup-help-toggle`,onClick:()=>a(e=>!e),"aria-expanded":i,"aria-controls":`setup-help`,children:[L(ri,{size:13,className:i?`is-open`:``,"aria-hidden":`true`}),` `,r(`setup.logs.help`)]}),i&&z(`div`,{id:`setup-help`,className:`setup-help`,children:[u.map(e=>{let t=l(e),n=o.has(e);return z(`div`,{className:`setup-log`,children:[z(`button`,{type:`button`,className:`setup-log-toggle`,onClick:()=>c(e),"aria-expanded":n,children:[L(ri,{size:13,className:n?`is-open`:``,"aria-hidden":`true`}),` `,r(`setup.logs.${e}`)]}),n&&L(uJ,{lines:t,className:`setup-log-pre`})]},e)}),L(oP,{classes:wJ,note:r(`setup.logs.reportNote`)})]})]})}function OJ(){let e=R(),t=N(e=>e.locale),n=N(e=>e.setLocale);return z(`label`,{className:`setup-language`,children:[L(La,{size:14,"aria-hidden":`true`}),L(`span`,{className:`visually-hidden`,children:e(`settings.language`)}),L(`select`,{value:t,onChange:e=>n(e.target.value),children:_e.map(({meta:e})=>L(`option`,{value:e.code,lang:e.code,dir:e.dir,children:ir(e)},e.code))})]})}var kJ=1e3,AJ=e=>e instanceof Error?e.message:String(e);function jJ(e){let[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)(!1),a=(0,B.useRef)(e);a.current=e;let o=(0,B.useRef)(!1),s=(0,B.useRef)(!1),c=(0,B.useCallback)(async()=>{o.current=!1,s.current=!0,i(!1),n({state:`downloading`,bytes_done:0,bytes_total:null,error:null});try{n(await Yt())}catch(e){n({state:`failed`,bytes_done:0,bytes_total:null,error:AJ(e)})}},[]),l=(0,B.useCallback)(e=>{e.state===`downloading`&&(o.current=!1,s.current=!1,i(!1),n(e))},[]),u=t?.state;return(0,B.useEffect)(()=>{if(u!==`downloading`)return;let e=!0,t=setTimeout(()=>{g().then(t=>{e&&(t.state===`idle`?(i(!0),n(e=>({...e??t,state:`failed`,error:null}))):n(t))}).catch(t=>{e&&n(e=>({...e??{bytes_done:0,bytes_total:null},state:`failed`,error:AJ(t)}))})},kJ);return()=>{e=!1,clearTimeout(t)}},[t,u]),(0,B.useEffect)(()=>{u!==`done`||o.current||(o.current=!0,a.current(s.current))},[u]),{job:t,start:c,follow:l,interrupted:r}}function MJ(e,t){return e.state===`done`?t(`setup.state.ready`):e.state===`failed`?t(`setup.state.failed`):t(`setup.state.downloading`)}function NJ({job:e,name:t,onRetry:n,failedNote:r,interrupted:i=!1}){let a=R(),o=(0,B.useId)(),s=e.bytes_total??0,c=e.state===`done`?100:s>0?Math.min(100,e.bytes_done/s*100):0,l=MJ(e,a),u=s>0?`${Ek(e.bytes_done)} / ${Ek(s)}`:Ek(e.bytes_done);return L(`ul`,{className:`dl-list agent-download`,children:z(`li`,{className:`dl-row is-${e.state===`done`?`ready`:e.state}${e.state===`downloading`?` is-live`:``}`,children:[z(`div`,{className:`dl-row-head`,children:[L(`span`,{className:`dl-icon`,"aria-hidden":`true`,children:e.state===`done`?L(Yr,{size:14}):e.state===`failed`?L(di,{size:14}):L(`span`,{className:`dl-dot`})}),L(`span`,{className:`dl-name`,children:L(`bdi`,{dir:`ltr`,children:t})}),L(`span`,{className:`dl-state`,children:l}),e.state===`downloading`&&z(`bdi`,{className:`dl-pct`,children:[Math.floor(c),`%`]})]}),L(`div`,{className:`dl-track`,role:`progressbar`,"aria-label":a(`setup.progress.rowLabel`,{name:t,state:l}),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.floor(c),"aria-valuetext":s>0?a(`setup.progress.of`,{done:Ek(e.bytes_done),total:Ek(s)}):l,children:L(`span`,{className:`dl-fill`,style:{inlineSize:`${c}%`}})}),e.state===`downloading`&&L(`p`,{className:`dl-detail`,children:L(`bdi`,{children:Ok(a.locale,u)})}),e.state===`failed`&&z(`div`,{className:`dl-fail`,role:`alert`,children:[L(`p`,{className:`dl-error`,id:o,children:a(`setup.agent.downloadFailed`,{name:t})}),i&&L(`p`,{className:`dl-detail`,children:a(`setup.agent.downloadInterrupted`)}),r&&L(`p`,{className:`dl-detail`,children:r}),e.error&&z(`details`,{className:`dl-details`,children:[L(`summary`,{children:a(`setup.progress.details`)}),L(`pre`,{dir:`ltr`,children:e.error})]}),L(`div`,{className:`setup-row`,children:z(`button`,{type:`button`,className:`btn-primary`,onClick:n,"aria-describedby":o,children:[L(is,{size:13,"aria-hidden":`true`}),` `,a(`setup.progress.retry`)]})})]})]})})}var PJ=[{id:`gaiapy`,label:`setup.agent.gaiapy`,more:`setup.agent.gaiapyMore`,tag:`setup.offer.recommended`},{id:`gaiacpp`,label:`setup.agent.gaiacpp`,more:`setup.agent.gaiacppMore`,tag:`setup.agent.beta`}],FJ={no_release:`setup.agent.why.noRelease`,unreachable:`setup.agent.why.unreachable`,unverifiable:`setup.agent.why.unverifiable`},IJ=e=>e instanceof Error?e.message:String(e);function LJ({inSettings:e=!1,disabled:t=!1,pending:n=null,onPending:r}){let i=R(),a=(0,B.useId)(),o=`${a}-title`,s=`${a}-more`,c=`${a}-off`,[l,u]=(0,B.useState)(null),[d,f]=(0,B.useState)(null),[p,m]=(0,B.useState)(null),[h,g]=(0,B.useState)(!1),[_,v]=(0,B.useState)(!1),y=(0,B.useRef)(!0),b=(0,B.useCallback)(async(e,t)=>{g(!0),m(null),u(t=>t&&{...t,current:e});try{let t=await pe({flagship_agent:e});y.current&&u(e=>e&&{...e,current:t.flagship_agent})}catch(e){if(!y.current)return;m(IJ(e));let n=e instanceof Vn&&(e.httpStatus===422||e.httpStatus===409)?null:await $t().catch(()=>null);y.current&&u(e=>n??(e&&{...e,current:t}))}finally{y.current&&g(!1)}},[]),x=(0,B.useRef)(`gaiapy`);x.current=l?.current??`gaiapy`;let{job:S,start:C,follow:w,interrupted:T}=jJ(e=>{let t=x.current;$t().then(e=>{y.current&&u(e)},e=>console.warn(`[AgentChoice] could not re-read the agents after the download`,e)).then(()=>{y.current&&e&&b(`gaiacpp`,t)})});(0,B.useEffect)(()=>(y.current=!0,$t().then(t=>{y.current&&(u(t),e&&w(t.download))}).catch(e=>{y.current&&f(IJ(e))}),()=>{y.current=!1}),[e,w]);let E=e=>l?.programs.find(t=>t.id===e),D=e=>e.id===`gaiapy`||e.installed,O=e=>!!e&&!D(e)&&!e.can_download,ee=t=>!!t&&e&&!D(t)&&t.can_download,te=S?.state===`downloading`,ne=n??l?.current,re=n=>{let i=E(n);l&&i&&!t&&!O(i)&&(e?h||te||ee(i)||n!==l.current&&b(n,l.current):r?.(n===l.current?null:{id:n,download:!D(i),current:l.current}))},k=E(`gaiacpp`),ie=k?.unavailable_code?i(FJ[k.unavailable_code]):k?.unavailable_reason,ae=!k||D(k)?null:k.can_download?i(e?`setup.agent.downloadsOnButton`:`setup.agent.downloadsLater`):ie?i(`setup.agent.cantDownload`,{reason:ie}):i(`setup.agent.notInstalledMore`);return z(`section`,{className:`agent-choice${e?` settings-card`:``}`,"aria-labelledby":o,"aria-busy":h||te||!l&&!d,children:[z(`h3`,{className:`agent-choice-title ${e?`settings-label`:`mc-job-title`}`,id:o,children:[i(`setup.agent.title`),h&&L(Za,{size:13,className:`spin`,"aria-hidden":`true`})]}),d&&L(`p`,{className:`agent-choice-error`,role:`alert`,children:i(`setup.agent.loadFailed`,{error:d})}),l&&z(P.Fragment,{children:[L(jB,{className:`setup-choices`,"aria-labelledby":o,children:PJ.map(n=>{let r=E(n.id),a=O(r),o=ee(r),s=z(`button`,{type:`button`,role:`radio`,"aria-checked":ne===n.id,"aria-disabled":a||o||t||void 0,"aria-describedby":a||o?c:void 0,className:`setup-choice agent-choice-row${ne===n.id?` is-active`:``}${a?` is-disabled`:``}${o?` is-pending`:``}`,onClick:()=>re(n.id),children:[z(`span`,{className:`agent-choice-what`,children:[L(`bdi`,{dir:`ltr`,className:`agent-choice-name`,children:n.id}),L(`span`,{className:`agent-choice-label`,children:i(n.label)}),r?.size_bytes!=null&&L(`bdi`,{dir:`ltr`,className:`agent-choice-size`,children:Ek(r.size_bytes)})]}),L(`span`,{className:`setup-choice-tag`,children:i(n.tag)}),a&&L(`span`,{className:`setup-choice-tag agent-choice-off`,children:i(`setup.agent.notInstalled`)}),r&&!D(r)&&!a&&!e&&L(`span`,{className:`setup-choice-tag agent-choice-off is-quiet`,children:i(`settings.model.notDownloaded`)})]},n.id);return a?z(`div`,{className:`agent-choice-blocked`,children:[s,L(`p`,{id:c,className:`agent-choice-why`,dir:`auto`,children:ae})]},n.id):!o||te||S?.state===`failed`?s:z(`div`,{className:`agent-choice-item`,children:[s,z(`button`,{type:`button`,className:`btn-secondary agent-choice-download`,onClick:()=>void C(),disabled:h||t,"aria-label":i(`setup.agent.downloadNamed`,{name:n.id}),children:[L(Ni,{size:13,"aria-hidden":`true`}),` `,i(`setup.agent.download`)]})]},n.id)})}),S&&(S.state===`downloading`||S.state===`failed`)&&L(NJ,{job:S,name:`gaiacpp`,onRetry:()=>void C(),failedNote:i(`setup.agent.stays`,{name:l.current}),interrupted:T}),z(`button`,{type:`button`,className:`agent-choice-more`,"aria-expanded":_,"aria-controls":s,onClick:()=>v(e=>!e),children:[L($r,{size:13,className:`agent-choice-chevron${_?` is-open`:``}`,"aria-hidden":`true`}),` `,i(`setup.agent.compare`)]}),z(`div`,{id:s,className:`agent-choice-detail`,hidden:!_,children:[PJ.map(e=>z(`p`,{children:[i(e.more,{name:e.id}),e.id===`gaiacpp`&&ae&&!O(k)&&z(P.Fragment,{children:[` `,L(`span`,{id:c,children:ae})]})]},e.id)),L(`p`,{children:i(e?`settings.agent.nextMessage`:`setup.agent.hint`)})]})]}),p&&L(`p`,{className:`agent-choice-error`,role:`alert`,children:i(`setup.agent.saveFailed`,{error:p})})]})}var RJ={driver:[`setup.npu.problem.driver`,`setup.npu.fix.driver`],device:[`setup.npu.problem.device`,`setup.npu.fix.device`],firmware:[`setup.npu.problem.firmware`,`setup.npu.fix.firmware`],access:[`setup.npu.problem.access`,`setup.npu.fix.access`],memlock:[`setup.npu.problem.memlock`,`setup.npu.fix.memlock`],runtime:[`setup.npu.problem.runtime`,`setup.npu.fix.runtime`]},zJ={cancelled:`setup.npu.fixError.cancelled`,timeout:`setup.npu.fixError.timeout`,not_authorized:`setup.npu.fixError.notAuthorized`,no_pkexec:`setup.npu.fixError.noPkexec`};function BJ({problem:e}){let t=R(),n=RJ[e.code];if(!n)return z(`li`,{children:[L(`strong`,{children:e.title}),` `,e.fix]});let r=e.params,i=n[1];e.code===`access`&&r.group&&(i=`setup.npu.fix.accessGroup`);let a=n[0];return e.code===`memlock`&&r.fix===`restart`&&(a=`setup.npu.problem.memlockStill`,i=`setup.npu.fix.memlockRestart`),e.code===`memlock`&&r.fix===`stuck`&&(a=`setup.npu.problem.memlockStuck`,i=`setup.npu.fix.memlockStuck`),z(`li`,{children:[L(`strong`,{children:t(a,{device:r.device??``,limit:r.limit??``,version:r.version??``,detail:r.detail??``})}),` `,t(i,{group:r.group??``})]})}function VJ({problems:e,disabled:t,onRecheck:n,id:r=`setup-npu-problems`}){let i=R(),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(null),l=e.some(e=>e.code===`memlock`&&e.params.fix===`apply`),u=async(e,t)=>{o(!0),c(null);try{await e(),n?.()}catch(e){let n=e instanceof Vn?e.body?.code:void 0,r=n&&n in zJ?zJ[n]:t;c(i(r))}finally{o(!1)}};return z(`div`,{className:`setup-npu-problems`,id:r,role:`note`,children:[L(`p`,{children:i(`setup.npu.notReady`)}),L(`ul`,{children:e.map(e=>L(BJ,{problem:e},e.code))}),L(`p`,{className:`setup-hint`,children:i(`setup.npu.meanwhile`)}),s&&L(`p`,{className:`setup-npu-error`,role:`alert`,children:s}),z(`div`,{className:`setup-npu-actions`,children:[l&&L(`button`,{type:`button`,className:`btn-primary`,disabled:t||a,onClick:()=>void u(He,`setup.npu.fixError.failed`),children:i(`setup.npu.fixMemlock`)}),n&&L(`button`,{type:`button`,className:`btn-secondary`,disabled:t||a,onClick:()=>void u(et,`setup.npu.recheckFailed`),children:i(`setup.npu.recheck`)})]})]})}async function HJ(){let e=await Ue();e.reachable&&(e.available_backends??[]).some(e=>e.name===`vulkan`)&&(e.preferred_backend??e.default_backend)!==`vulkan`&&await Qt(`vulkan`)}function UJ({plan:e,selection:t,onSelection:n,disabled:r=!1,onRecheck:i}){let a=R(),o=GK(e),s=e.npu?.present&&!e.npu.ready?e.npu.problems:[],c=s.length?void 0:o.find(e=>JK(e)&&e.gaia_model&&e.chat_choice&&e.fits!==!1)??o.find(e=>JK(e)&&e.chat_choice&&e.downloaded&&!YK(e)),l=!s.length&&!c&&o.some(e=>JK(e)&&e.fit_code===`npu`),u=!!o.find(e=>e.id===t.defaultChat&&JK(e)),d=uq(e).defaultChat,f=d&&!o.find(e=>e.id===d&&JK(e))?d:o.find(e=>e.chat_choice&&e.gaia_model&&e.support===`verified`&&!JK(e))?.id,p=e=>{e===`npu`&&c&&!u&&n(eq(t,o,c.id)),e===`gpu`&&u&&f&&n(eq(t,o,f))},m=[{id:`gpu`,label:a(`setup.backend.gpu`)},...c?[{id:`npu`,label:a(`setup.backend.npu`)}]:[],...s.length?[{id:`npu`,label:a(`setup.backend.npu`),unavailable:!0}]:[]],h=u?`npu`:`gpu`;return z(`section`,{className:`setup-backend`,"aria-labelledby":`setup-backend-title`,children:[L(`h3`,{className:`mc-job-title`,id:`setup-backend-title`,children:a(`setup.backend.title`)}),L(jB,{className:`segmented`,"aria-labelledby":`setup-backend-title`,children:m.map(e=>L(`button`,{type:`button`,role:`radio`,"aria-checked":h===e.id,"aria-describedby":e.unavailable?`setup-npu-problems`:void 0,className:h===e.id?`is-active`:``,disabled:r||e.unavailable,onClick:()=>p(e.id),children:L(`bdi`,{children:e.label})},e.id))}),s.length>0?L(VJ,{problems:s,disabled:r,onRecheck:i}):L(`p`,{className:`setup-hint`,children:a(c?`setup.backend.hint`:l?`setup.backend.hintNpuUnusable`:`setup.backend.hintNoNpu`)})]})}var WJ=({children:e})=>L(`bdi`,{dir:`ltr`,children:e});function GJ({label:e,children:t}){return z(`div`,{className:`found-row`,children:[L(`dt`,{children:e}),L(`dd`,{children:t})]})}function KJ(e){return e.family?`${e.name} (${e.family})`:e.name}var qJ=[[`llamacpp`,`llama.cpp`],[`flm`,`FastFlowLM`],[`whispercpp`,`whisper.cpp`],[`kokoro`,`Kokoro`],[`sd-cpp`,`stable-diffusion.cpp`]],JJ=new Set([`llamacpp`,`flm`]);function YJ(e){let t=[];for(let[n,r]of qJ){let i=(e.backends??[]).find(e=>e.recipe===n&&e.default);i&&i.state!==`unsupported`&&t.push({name:r,b:i})}return t}function XJ(e,t){return e?e.kind===`release_candidate`&&e.rc?`${e.version.replace(/rc\d+$/,``)} RC ${e.rc}`:e.kind===`source`&&e.commit?`${e.version} (${e.commit})`:e.version:t??null}var ZJ={release:`release`,release_candidate:`release candidate`,local:`local build`,source:`from source`};function QJ(e,t){let n=e.system,r=e=>(n?.devices??[]).filter(t=>t.available&&e(t.kind)),i=r(e=>e.endsWith(`gpu`)),a=r(e=>e.endsWith(`npu`)),o=YJ(e);return{sys:n,cpu:r(e=>e===`cpu`)[0],gpus:i,graphics:i.length?i.map(KJ).join(`; `):t?.gpu_name??null,npus:a,runsOn:i[0]?.name??t?.gpu_name??null,npu:a[0]??null,runtimes:o,gaia:XJ(n?.gaia_build,n?.gaia_version),build:n?.gaia_build?.kind??null,software:[XJ(n?.gaia_build,n?.gaia_version)?`GAIA ${XJ(n?.gaia_build,n?.gaia_version)}`:null,n?.lemonade_version?`Lemonade ${n.lemonade_version}`:null,...o.filter(({b:e})=>JJ.has(e.recipe)&&eY(e)).map(({name:e,b:t})=>`${e} ${t.version??t.backend}`)].filter(e=>!!e),totalMemory:wk(n?.physical_memory,t?.ram_gb),freeGb:e.disk?.free_gb??t?.disk_free_gb??null,modelsPath:e.disk?.path??null,gaiaHome:n?.gaia_home??null}}var $J={installed:`installed`,update_required:`installed, updates on first use`},eY=e=>e.state===`installed`||e.state===`update_required`,tY={chat:`setup.job.chat`,vision:`setup.job.vision`,embedding:`setup.job.documents`,speech:`setup.job.speech`,voice:`setup.job.voice`,image_creation:`setup.job.images`};function nY(e,t){let n=QJ(e,t),r=e.lemonade.mode===`external`?`the user's own`:`GAIA's own`;return[`GAIA: ${n.gaia??`unknown`}${n.build?`, ${ZJ[n.build]}`:``} (agent ${n.sys?.agent_version??`not installed yet`})`,`Model server: ${r} Lemonade ${n.sys?.lemonade_version??`(version not reported)`}${e.lemonade.url?` at ${e.lemonade.url}`:``}`,...n.runtimes.map(({name:e,b:t})=>`${e}: ${t.backend}${t.version?` ${t.version}`:``} (${$J[t.state??``]??`not installed`})`),`OS: ${n.sys?.os??t?.os??`unknown`}`,`Processor: ${n.cpu?.name??n.sys?.processor??`unknown`}${n.cpu?.cores?` (${n.cpu.cores} cores, ${n.cpu.threads??n.cpu.cores} threads)`:``}`,`Graphics: ${n.graphics??`none found`}`,`NPU: ${n.npus.map(KJ).join(`; `)||`none found`}`,`Memory: ${n.totalMemory??`unknown`}${e.capacity_gb==null?``:`, ${Sk(e.capacity_gb)} for models${e.memory_source?` (${e.memory_source})`:``}`}`,`Models folder: ${n.modelsPath??`unknown`}${n.freeGb==null?``:` (${Sk(n.freeGb)} free)`}`,`GAIA data and logs: ${n.gaiaHome??`unknown`}`].join(`
|
|
212
|
+
`)}function rY({plan:e,hardware:t,onChangeMemory:n}){let r=R(),i=QJ(e,t),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(null),[l,u]=(0,B.useState)(null),d=async e=>{u(null);try{await Ft(e,!1)}catch(e){u(r(`setup.found.openFailed`,{error:e instanceof Error?e.message:String(e)}))}},f=L(`span`,{className:`found-muted`,children:r(`setup.found.unknown`)}),p=[...t?.blockers??[],...(t?.warnings??[]).filter(e=>t?.lemonade_running||!/\bNPU\b/.test(e))],m=(0,B.useRef)(null);(0,B.useEffect)(()=>()=>{m.current&&clearTimeout(m.current)},[]);let h=e=>{c(e),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>c(null),2e3)};return z(`section`,{className:`setup-card found`,"aria-label":r(`setup.found.title`),children:[z(`div`,{className:`found-head`,children:[L(`h3`,{className:`mc-job-title`,children:r(`setup.found.title`)}),L(`button`,{type:`button`,className:`found-copy`,onClick:()=>{navigator.clipboard.writeText(nY(e,t)).then(()=>h(`done`),e=>{console.warn(`[DetectedSummary] could not copy the details`,e),h(`failed`)})},"aria-label":r(`setup.found.copy`),title:r(`setup.found.copy`),children:L(s===`done`?Yr:Ti,{size:14,"aria-hidden":`true`})}),s&&L(`span`,{className:`found-copied`,role:`status`,children:r(s===`done`?`setup.found.copied`:`setup.found.copyFailed`)})]}),z(`dl`,{className:`found-glance`,children:[z(GJ,{label:r(`setup.found.runsOn`),children:[i.runsOn?L(WJ,{children:i.runsOn}):f,i.npu&&L(`span`,{className:`found-chip`,children:L(WJ,{children:`NPU`})})]}),z(GJ,{label:r(`setup.found.memory`),children:[e.capacity_gb!=null&&i.totalMemory?r(`setup.found.memoryOf`,{size:Sk(e.capacity_gb),total:i.totalMemory}):e.capacity_gb==null?i.totalMemory?L(WJ,{children:i.totalMemory}):f:L(WJ,{children:Sk(e.capacity_gb)}),n&&L(`button`,{type:`button`,className:`link-btn found-link`,onClick:n,children:r(`setup.found.changeMemory`)})]}),L(GJ,{label:r(`setup.found.space`),children:i.freeGb==null?f:L(WJ,{children:Sk(i.freeGb)})}),z(GJ,{label:r(`setup.found.software`),children:[i.software.length?L(WJ,{children:i.software.join(` · `)}):f,i.build&&i.build!==`release`&&L(`span`,{className:`found-chip`,children:r(`setup.found.build.${i.build}`)})]})]}),z(`div`,{className:`found-paths`,children:[[[`setup.found.modelsFolder`,i.modelsPath],[`setup.found.gaiaFolder`,i.gaiaHome]].map(([e,t])=>t&&z(`button`,{type:`button`,className:`link-btn found-open`,onClick:()=>void d(t),title:t,children:[L(da,{size:13,"aria-hidden":`true`}),` `,r(e)]},e)),l&&L(`p`,{className:`setup-error`,role:`alert`,children:l})]}),p.length>0&&z(`details`,{className:`dl-details found-warnings`,children:[z(`summary`,{children:[L(di,{size:13,"aria-hidden":`true`}),` `,r(`setup.found.noticed`)]}),L(`ul`,{children:p.map(e=>L(`li`,{children:L(WJ,{children:e})},e))})]}),z(`button`,{type:`button`,className:`setup-log-toggle found-more`,onClick:()=>o(e=>!e),"aria-expanded":a,children:[L(ri,{size:13,className:a?`is-open`:``,"aria-hidden":`true`}),` `,r(`setup.found.details`)]}),a&&z(`div`,{className:`found-details`,children:[L(`h4`,{className:`found-group`,children:r(`setup.found.software`)}),z(`dl`,{className:`found-list`,children:[z(GJ,{label:L(WJ,{children:`GAIA`}),children:[i.gaia?L(WJ,{children:i.gaia}):f,i.build&&i.build!==`release`&&L(`span`,{className:`found-chip`,children:r(`setup.found.build.${i.build}`)})]}),L(GJ,{label:r(`setup.found.agent`),children:i.sys?.agent_version?L(WJ,{children:i.sys.agent_version}):L(`span`,{className:`found-muted`,children:r(`setup.found.agentLater`)})}),z(GJ,{label:r(`setup.found.server`),children:[e.lemonade.mode===`external`?r(`setup.found.serverYours`):r(`setup.found.serverOwn`),i.sys?.lemonade_version&&z(P.Fragment,{children:[` `,L(WJ,{children:i.sys.lemonade_version})]}),e.lemonade.url&&L(`span`,{className:`found-sub`,children:L(WJ,{children:e.lemonade.url})})]})]}),L(`h4`,{className:`found-group`,children:r(`setup.found.runtime`)}),i.runtimes.length?L(`div`,{className:`found-table-wrap`,children:z(`table`,{className:`found-table`,children:[L(`thead`,{className:`visually-hidden`,children:z(`tr`,{children:[L(`th`,{scope:`col`,children:r(`setup.found.col.runtime`)}),L(`th`,{scope:`col`,children:r(`setup.found.col.device`)}),L(`th`,{scope:`col`,children:r(`setup.found.col.version`)}),L(`th`,{scope:`col`,children:r(`setup.found.col.state`)})]})}),L(`tbody`,{children:i.runtimes.map(({name:e,b:t})=>z(`tr`,{children:[L(`th`,{scope:`row`,children:L(WJ,{children:e})}),L(`td`,{children:L(WJ,{children:t.backend})}),L(`td`,{children:L(WJ,{children:t.version??``})}),L(`td`,{className:eY(t)?`is-installed`:void 0,children:r(eY(t)?`setup.pc.backend.installed`:`setup.pc.backend.available`)})]},t.recipe))})]})}):L(`p`,{className:`found-muted`,children:r(`setup.found.unknown`)}),L(`h4`,{className:`found-group`,children:r(`setup.found.models`)}),(e.catalog??[]).length?L(`div`,{className:`found-table-wrap`,children:z(`table`,{className:`found-table`,children:[L(`thead`,{className:`visually-hidden`,children:z(`tr`,{children:[L(`th`,{scope:`col`,children:r(`setup.found.col.model`)}),L(`th`,{scope:`col`,children:r(`setup.found.col.job`)}),L(`th`,{scope:`col`,children:r(`setup.found.col.tested`)}),L(`th`,{scope:`col`,children:r(`setup.found.col.size`)}),L(`th`,{scope:`col`,children:r(`setup.found.col.state`)})]})}),L(`tbody`,{children:(e.catalog??[]).map(e=>z(`tr`,{children:[L(`th`,{scope:`row`,title:e.id,children:L(`bdi`,{children:e.name})}),L(`td`,{children:e.roles.map(e=>r(tY[e])).join(` · `)}),z(`td`,{children:[e.support===`verified`&&L(`span`,{className:`mc-chip is-verified`,children:r(`setup.label.verified`)}),e.support===`untested`&&L(`span`,{className:`mc-chip is-untested`,children:r(`setup.label.untested`)})]}),L(`td`,{children:L(WJ,{children:e.full_size_gb??e.size_gb?Sk(e.full_size_gb??e.size_gb):``})}),L(`td`,{className:e.downloaded?`is-installed`:void 0,children:r(e.downloaded?`setup.models.status.onPc`:`setup.found.notDownloaded`)})]},e.id))})]})}):L(`p`,{className:`found-muted`,children:r(`setup.found.unknown`)}),L(`h4`,{className:`found-group`,children:r(`setup.found.hardware`)}),z(`dl`,{className:`found-list`,children:[L(GJ,{label:r(`setup.found.os`),children:i.sys?.os??t?.os?L(WJ,{children:i.sys?.os??t?.os}):f}),z(GJ,{label:r(`setup.found.cpu`),children:[i.cpu||i.sys?.processor?L(WJ,{children:i.cpu?.name??i.sys?.processor}):f,i.cpu?.cores?L(`span`,{className:`found-sub`,children:r(`setup.found.cores`,{cores:String(i.cpu.cores),threads:String(i.cpu.threads??i.cpu.cores)})}):null]}),L(GJ,{label:r(`setup.found.gpu`),children:i.graphics?L(WJ,{children:i.graphics}):L(`span`,{className:`found-muted`,children:r(`setup.found.none`)})}),L(GJ,{label:r(`setup.found.npu`),children:i.npus.length?L(WJ,{children:i.npus.map(KJ).join(`; `)}):L(`span`,{className:`found-muted`,children:r(`setup.found.none`)})})]})]})]})}function iY(){return window.gaiaUpdater}var aY={status:`idle`,version:null,progress:0,releaseNotes:null,error:null,currentVersion:null,pinnedVersion:null,autoUpdate:!1,includePrereleases:!1};function oY(){let[e,t]=(0,B.useState)({...aY}),n=(0,B.useRef)(!1),r=(0,B.useRef)(0),i=(0,B.useCallback)(async()=>{let e=iY();if(!e)return;let i=r.current;try{let r=await e.getStatus();n.current&&r&&t(r)}catch(e){F.system.error(`Reading the update status failed`,e),n.current&&r.current===i&&t(e=>({...e,readFailed:!0}))}},[]);return(0,B.useEffect)(()=>{let e=iY();if(!e)return;n.current=!0;let a=e.onStatusChange(e=>{e&&(r.current+=1,n.current&&t(e))});return i(),()=>{n.current=!1,a()}},[i]),{...e,reload:i}}var sY=`gaia-update-error:`;function cY(e,t){let n=`update.err.${e}`;return fe(n)?We(n,t??{}):null}function lY(e){let t=e instanceof Error?e.message:String(e),n=t.indexOf(sY);if(n<0)return t.replace(/^Error invoking remote method '[^']+': (?:Error: )?/,``);let r;try{r=JSON.parse(t.slice(n+18))}catch{return t.slice(0,n)+t.slice(n+18)}let i=cY(r.code,r.params)??r.message??r.code,a=r.note&&cY(r.note.code,r.note.params);return a?We(`update.err.withNote`,{error:i,note:a}):i}function uY(e,t){let n=lY(e);return typeof n==`object`?t(n.ref,n.params):String(n)}function dY({className:e}){let t=R(),n=oY(),[r,i]=(0,B.useState)(!1),[a,o]=(0,B.useState)(null),s=n.lastWorking;if(!iY()||!s)return null;let c=(r||n.version===s.version)&&n.status===`downloading`,l=r&&n.status===`downloaded`,u=!r&&n.status===`downloaded`&&n.version===s.version,d=new Date(s.at).toLocaleDateString(On(t),{year:`numeric`,month:`short`,day:`numeric`}),f=t(`setup.goBack.title`);return z(`section`,{className:e?`setup-card ${e}`:`setup-card`,"aria-label":f,children:[L(`h3`,{className:`mc-job-title`,children:f}),L(`p`,{children:t(`setup.goBack.lead`,{version:s.version,date:d})}),L(`p`,{className:`setup-hint`,children:t(`setup.goBack.fixes`,{version:s.version})}),c||l?z(`p`,{className:`setup-hint`,role:`status`,children:[L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,c?t(`setup.goBack.downloading`,{version:s.version,pct:Math.max(0,Math.min(100,Math.round(n.progress)))}):t(`setup.goBack.restarting`,{version:s.version})]}):u?z(P.Fragment,{children:[L(`p`,{className:`setup-hint`,children:t(`setup.goBack.ready`,{version:s.version})}),L(`div`,{className:`setup-row`,children:L(`button`,{type:`button`,className:`btn-secondary go-back-action`,onClick:()=>{let e=iY();e&&(o(null),e.restart().catch(e=>{F.system.error(`Restarting into the last working version failed`,e),o(t(`setup.goBack.failed`,{reason:uY(e,t)}))}))},children:t(`setup.goBack.restart`,{version:s.version})})})]}):L(`div`,{className:`setup-row`,children:L(`button`,{type:`button`,className:`btn-secondary go-back-action`,onClick:()=>{let e=iY();e&&(i(!0),o(null),e.revertToLastWorking().catch(e=>{F.system.error(`Going back to the last working version failed`,e),o(t(`setup.goBack.failed`,{reason:uY(e,t)}))}).finally(()=>i(!1)))},disabled:r,children:t(`setup.goBack.action`,{version:s.version})})}),a&&L(`p`,{className:`setup-error`,role:`alert`,children:a}),z(`details`,{className:`dl-details`,children:[L(`summary`,{children:t(`setup.progress.details`)}),L(`p`,{className:`setup-hint`,children:t(`setup.goBack.note`,{version:s.version,current:n.currentVersion??``})})]})]})}function fY({state:e}){return e===`done`?L(Yr,{size:13,"aria-hidden":`true`}):e===`active`?L(Za,{size:13,className:`spin`,"aria-hidden":`true`}):L(e===`failed`?nc:e===`question`?pi:_i,{size:13,"aria-hidden":`true`})}function pY({hardware:e,hardwareError:t,plan:n,serverRun:r,awaitingChoice:i=!1}){let a=R(),[o,s]=(0,B.useState)(!1),c=!!n?.lemonade.reachable,l=r?.state===`failed`||r?.state===`cancelled`,u=a(n?.lemonade.mode===`external`?`setup.found.serverYours`:`setup.found.serverOwn`),d=n?.system?.lemonade_version?a(`setup.checks.serverFound`,{version:n.system.lemonade_version,whose:u}):u,f=e?`done`:t?`failed`:`active`,p=[e?.gpu_name,e?.npu_detected?a(`setup.checks.npu`):null].filter(Boolean).join(` · `),m=t?null:n?.capacity_gb==null?c?wk(n?.system?.physical_memory,e?.ram_gb):null:Sk(n.capacity_gb),h=t?`failed`:m?`done`:l?`failed`:i?`waiting`:`active`,g=[{id:`device`,label:a(`setup.checks.device`),value:t?`${a(`setup.system.unread`)} ${t}`:p||null,state:f},{id:`memory`,label:a(`setup.found.memory`),value:m,state:h},{id:`disk`,label:a(`setup.checks.disk`),value:e?.disk_free_gb==null?null:a(`setup.checks.diskValue`,{size:Ok(a.locale,`${Math.round(e.disk_free_gb)} GB`)}),state:f},{id:`server`,label:a(`setup.checks.server`),value:c?d:i?a(`setup.checks.serverChoose`):null,state:c?`done`:l?`failed`:i?`question`:e?`active`:`waiting`},{id:`models`,label:a(`setup.checks.backends`),value:c&&n?.catalog?a(`setup.checks.backendsValue`,{models:String(n.catalog.length),downloaded:String(n.catalog.filter(e=>e.downloaded).length)}):null,state:c&&n?.catalog?`done`:c?`active`:`waiting`}],_=g.filter(e=>e.state===`done`).length,v=Math.round(_/g.length*100),y=L(`ul`,{className:`setup-rows`,id:`setup-check-rows`,children:g.map(e=>z(`li`,{className:`setup-result is-${e.state}`,children:[L(fY,{state:e.state}),L(`span`,{className:`setup-result-label`,children:e.label}),e.value&&L(`bdi`,{className:`setup-result-value`,children:e.value})]},e.id))});return _===g.length?z(`section`,{className:`setup-card setup-checks-done`,"aria-label":a(`setup.check.title`),children:[L(`p`,{className:`setup-result is-done`,role:`status`,children:z(`button`,{type:`button`,className:`setup-checks-toggle`,"aria-expanded":o,"aria-controls":`setup-check-rows`,onClick:()=>s(e=>!e),children:[L(Yr,{size:13,"aria-hidden":`true`}),L(`span`,{className:`setup-result-label`,children:a(`setup.checks.allPassed`,{n:String(g.length)})}),L(ri,{size:13,className:o?`is-open`:``,"aria-hidden":`true`})]})}),o&&y]}):z(`section`,{className:`setup-card`,"aria-label":a(`setup.check.title`),children:[L(`div`,{className:`setup-bar-head`,children:i?L(`span`,{children:a(`setup.checks.waitingChoice`)}):z(P.Fragment,{children:[L(`span`,{children:a(`setup.checks.count`,{done:String(_),total:String(g.length)})}),z(`bdi`,{dir:`ltr`,children:[v,`%`]})]})}),L(`progress`,{className:`setup-progress`,max:100,value:v,"aria-label":a(`setup.check.title`)}),y]})}function mY({steps:e}){let t=R();return z(`nav`,{className:`setup-rail`,"aria-label":t(`setup.rail.label`),children:[L(`p`,{className:`setup-rail-title`,children:t(`setup.title`)}),L(`ol`,{className:`setup-rail-list`,children:e.map((e,t)=>{let n=e.status===`done`?L(Yr,{size:13,"aria-hidden":`true`}):e.status===`active`?L(Za,{size:13,className:`spin`,"aria-hidden":`true`}):e.status===`failed`?L(di,{size:13,"aria-hidden":`true`}):t+1,r=z(P.Fragment,{children:[L(`span`,{className:`setup-rail-num`,children:n}),L(`span`,{children:e.label})]}),i=`setup-rail-step is-${e.status}${e.shown?` is-shown`:``}`,a=e.shown?`step`:void 0;return L(`li`,{children:e.onOpen?L(`button`,{type:`button`,className:i,onClick:e.onOpen,children:r}):L(`span`,{className:i,"aria-current":a,children:r})},e.id)})})]})}var hY={memory:`setup.test.why.memory`,broken:`setup.test.why.broken`,stuck:`setup.test.why.stuck`,missing:`setup.test.why.missing`,agent:`setup.test.why.agent`,answer:`setup.test.why.answer`,window:`setup.test.why.window`};function gY(e,t){return t(`setup.test.job.${e}`)}function _Y({state:e}){return e===`passed`?L(Yr,{size:13,"aria-hidden":`true`}):e===`running`?L(Za,{size:13,className:`spin`,"aria-hidden":`true`}):L(e===`failed`?nc:e===`skipped`?mo:_i,{size:13,"aria-hidden":`true`})}function vY(e,t){return e.state===`running`?t(`setup.test.running`):e.state===`failed`?t(`setup.test.failed`):e.state===`skipped`?t(`setup.test.skipped`):e.seconds==null?t(`setup.test.passed`):t(`setup.test.passedIn`,{seconds:String(Math.round(e.seconds))})}function yY({run:e,expected:t,names:n,catalog:r,onRetry:i,onChooseAnother:a,onCancel:o,onDownloadAgain:s,busy:c}){let l=R(),u=e.tests??[],d=new Set(u.map(e=>e.job)),f=t.filter(e=>!d.has(e)),p=u.filter(e=>e.state!==`running`).length,m=Math.max(u.length+f.length,1),h=Math.round(p/m*100),g=u.filter(e=>e.state===`failed`).filter(e=>!r.find(t=>t.id===e.subject)?.roles.some(e=>[`speech`,`voice`,`image_creation`].includes(e))),_=e.state===`failed`||e.state===`cancelled`,v=s?[...new Set(g.filter(e=>e.kind===`broken`&&e.subject).map(e=>e.subject))]:[],[y,b]=(0,B.useState)(null),x=r.find(e=>e.id===y)?.full_size_gb,S=_&&e.components?.agent===`failed`,C=g.some(e=>e.subject&&e.kind!==`missing`),w=e.state===`verifying`&&!u.some(e=>e.state===`running`)?f[0]:void 0;return z(P.Fragment,{children:[z(`section`,{className:`setup-card`,"aria-label":l(`setup.test.title`),children:[z(`div`,{className:`setup-bar-head`,children:[L(`span`,{children:l(`setup.test.count`,{done:String(p),total:String(m)})}),z(`bdi`,{dir:`ltr`,children:[h,`%`]})]}),L(`progress`,{className:`setup-progress`,max:100,value:h,"aria-label":l(`setup.test.title`)}),z(`ul`,{className:`setup-rows`,children:[u.map(e=>z(`li`,{className:`setup-result is-${e.state}`,children:[L(_Y,{state:e.state}),z(`span`,{className:`setup-result-label`,children:[gY(e.job,l),e.subject&&z(`bdi`,{className:`setup-result-model`,children:[` `,n[e.subject]??Uc(e.subject)]})]}),L(`span`,{className:`setup-result-value`,children:vY(e,l)}),e.error&&z(`div`,{className:`setup-result-error`,children:[L(`p`,{children:l(e.kind===`broken`&&!s?`setup.test.why.brokenYours`:hY[e.kind??``]??`setup.test.why.other`)}),z(`details`,{className:`dl-details`,children:[L(`summary`,{children:l(`setup.progress.details`)}),L(`pre`,{dir:`ltr`,children:e.error})]})]})]},`${e.job}:${e.subject??``}`)),f.map(e=>e===`agent`&&S?z(`li`,{className:`setup-result is-failed`,children:[L(_Y,{state:`failed`}),L(`span`,{className:`setup-result-label`,children:gY(e,l)}),L(`span`,{className:`setup-result-value`,children:l(`setup.test.failed`)}),L(`div`,{className:`setup-result-error`,children:L(`p`,{children:l(`setup.test.why.hub`)})})]},e):e===w?z(`li`,{className:`setup-result is-running`,children:[L(_Y,{state:`running`}),L(`span`,{className:`setup-result-label`,children:gY(e,l)}),L(`span`,{className:`setup-result-value`,children:l(`setup.test.starting`)})]},e):z(`li`,{className:`setup-result is-waiting`,children:[L(_Y,{state:`waiting`}),L(`span`,{className:`setup-result-label`,children:gY(e,l)}),L(`span`,{className:`setup-result-value`,children:l(`setup.test.waiting`)})]},e))]})]}),e.state===`verifying`&&o&&L(Bq,{children:L(`button`,{type:`button`,className:`btn-secondary`,onClick:o,disabled:c,children:l(`setup.progress.cancel`)})}),_&&z(`div`,{className:`setup-failure`,role:`alert`,children:[L(`p`,{children:e.state===`cancelled`?l(`setup.test.cancelled`):g.some(e=>e.kind===`memory`)?l(`setup.test.failedMemory`):l(`setup.test.failedHelp`)}),z(Bq,{children:[C&&a&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:a,disabled:c,children:l(`setup.test.chooseAnother`)}),L(`button`,{type:`button`,className:v.length?`btn-secondary`:`btn-primary`,onClick:i,disabled:c,children:l(`setup.test.tryAgain`)}),v.map(e=>L(`button`,{type:`button`,className:`btn-primary setup-wrap-btn`,onClick:()=>b(e),disabled:c,children:v.length===1?l(`setup.test.downloadItAgain`):l(`setup.test.downloadAgain`,{name:n[e]??e})},e))]})]}),y&&L(Vq,{title:l(`setup.redownload.title`,{name:n[y]??y}),confirmLabel:l(`setup.redownload.confirm`),cancelLabel:l(`setup.redownload.keep`),onConfirm:()=>{let e=y;b(null),s?.(e)},onCancel:()=>b(null),children:L(`p`,{children:l(`setup.redownload.body`,{name:n[y]??y,size:x==null?``:Sk(x)})})})]})}var bY=`https://app.fireworks.ai/settings/users/api-keys`,xY=`https://amd-gaia.ai/docs/guides/llm-gateway`,SY=[{id:`local`,title:`setup.where.local`,note:`setup.where.localNote`},{id:`fireworks`,title:`Fireworks AI`,note:`setup.where.fireworksNote`},{id:`amd`,title:`AMD LLM Gateway`,note:`setup.where.amdNote`}];function CY(e,t){return fe(e.title)?t(e.title):e.title}var wY=1e3,TY=`gaia-setup-choice`;function EY(){try{let e=localStorage.getItem(TY);return e===`local`||e===`fireworks`||e===`amd`?e:null}catch(e){return console.warn(`[SetupScreen] could not read the saved provider choice`,e),null}}function DY(e){try{localStorage.setItem(TY,e)}catch(e){console.warn(`[SetupScreen] could not save the provider choice; a reload will ask again`,e)}}var OY=[`ok`,`needs_key`,`too_old`];function kY({onChosen:e,onNothingToOffer:t,onFound:n,canInstallOwn:r=!0}){let i=R(),[a,o]=(0,B.useState)(null),[s,c]=(0,B.useState)(null),[l,u]=(0,B.useState)([]),[d,f]=(0,B.useState)(!1),[p,m]=(0,B.useState)(``),[h,g]=(0,B.useState)(!1),[_,v]=(0,B.useState)(!1),[y,b]=(0,B.useState)(null),[x,S]=(0,B.useState)(null),[C,w]=(0,B.useState)(null),[T,E]=(0,B.useState)(`gaia`),D=(0,B.useRef)(!0),O=(0,B.useCallback)(async()=>{c(null);try{let e=await ie();if(!e.offer){t?.();return}f(!0);let{found:r,unchecked:i=[]}=await er();if(!D.current)return;u(r?[]:i),r&&OY.includes(r.status)?(o({target:e,found:r}),n?.(r),g(r.status===`needs_key`),r.status===`too_old`&&t?.()):i.length===0&&t?.()}catch(e){D.current&&c(e instanceof Error?e.message:String(e))}finally{D.current&&f(!1)}},[t,n]);(0,B.useEffect)(()=>(D.current=!0,O(),()=>{D.current=!1}),[O]);let ee=(0,B.useCallback)(async t=>{if(a){b(t),S(null);try{await be(t===`external`?{mode:t,base_url:a.found.url,api_key:p.trim()||void 0}:{mode:t}),m(``),w(t),e(t)}catch(e){LK(e)&&g(!0),S(e instanceof Error?e.message:String(e))}finally{b(null)}}},[a,p,e]);if(s||l.length>0)return z(P.Fragment,{children:[L(`p`,{className:`setup-hint`,children:s?i(`setup.offer.checkFailed`):i(`setup.offer.noAnswer`,{url:l.join(`, `)})}),s&&z(`details`,{className:`dl-details`,children:[L(`summary`,{children:i(`setup.progress.details`)}),L(`pre`,{dir:`ltr`,children:s})]}),z(Bq,{children:[z(`button`,{type:`button`,className:`btn-secondary`,disabled:d,onClick:()=>void O(),children:[d&&L(Za,{size:13,className:`spin`}),` `,i(`setup.offer.checkAgain`)]}),t&&r&&L(`button`,{type:`button`,className:`btn-primary`,disabled:d,onClick:t,children:i(`setup.offer.useOwn`)})]})]});if(!a)return d?z(`p`,{className:`setup-hint`,role:`status`,children:[L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,i(`setup.offer.looking`)]}):null;let{target:te,found:ne}=a;return C?L(`p`,{className:`setup-hint`,role:`status`,children:C===`external`?i(`setup.offer.usingYours`,{url:ne.url}):i(`setup.offer.usingOwn`)}):ne.status===`too_old`?z(`p`,{className:`setup-hint`,role:`status`,children:[i(`setup.offer.tooOld`),` `,z(`bdi`,{dir:`ltr`,className:`setup-choice-note`,children:[`Lemonade `,ne.version??``,` · `,ne.url]})]}):z(`form`,{id:`setup-lemonade-form`,className:`setup-lemonade`,"aria-label":i(`setup.offer.label`),onSubmit:e=>{e.preventDefault(),ee(T)},children:[z(`fieldset`,{className:`setup-choices`,disabled:!!y,children:[L(`legend`,{className:`setup-choice-title`,children:i(`setup.offer.title`)}),[{mode:`gaia`,title:`setup.offer.useOwn`,note:`setup.offer.ownNote`},{mode:`external`,title:`setup.offer.useMine`,note:`setup.offer.mineNote`}].map(e=>z(`label`,{className:`setup-choice${T===e.mode?` is-active`:``}`,children:[L(`input`,{type:`radio`,name:`setup-server`,value:e.mode,checked:T===e.mode,onChange:()=>{E(e.mode),S(null)}}),z(`span`,{children:[z(`span`,{className:`setup-choice-title`,children:[i(e.title),e.mode===`gaia`&&L(`span`,{className:`setup-choice-tag`,children:i(`setup.offer.recommended`)})]}),L(`span`,{className:`setup-choice-note`,children:i(e.note)})]})]},e.mode))]}),z(`button`,{type:`button`,className:`setup-log-toggle setup-offer-more`,onClick:()=>v(e=>!e),"aria-expanded":_,"aria-controls":`setup-offer-detail`,children:[L(ri,{size:13,className:_?`is-open`:``,"aria-hidden":`true`}),` `,i(`setup.offer.whatGaiaDoes`)]}),_&&z(`div`,{id:`setup-offer-detail`,children:[L(`p`,{className:`setup-choice-note`,children:z(`bdi`,{dir:`ltr`,children:[`Lemonade`,ne.version?` ${ne.version}`:``,` · `,ne.url]})}),L(`p`,{className:`setup-choice-note`,children:i(`setup.offer.whatGaiaDoesText`)})]}),T===`external`&&h&&L(`input`,{className:`settings-input`,type:`password`,autoComplete:`off`,value:p,onChange:e=>m(e.target.value),placeholder:i(`setup.offer.keyPlaceholder`),"aria-label":i(`setup.offer.keyLabel`)}),x&&(h&&T===`external`?L(`p`,{className:`setup-error`,role:`alert`,children:i(`setup.offer.keyRejected`)}):L(jY,{text:x})),L(Bq,{children:z(`button`,{type:`submit`,form:`setup-lemonade-form`,className:`btn-primary`,disabled:!!y||T===`external`&&h&&!p.trim(),children:[y&&L(Za,{size:13,className:`spin`}),` `,i(`setup.continue`)]})})]})}function AY({problem:e,onRetry:t,onUseGaia:n}){let r=R(),i=e.kind===`server_too_old`&&e.use_gaia;return z(P.Fragment,{children:[e.start&&z(`details`,{className:`dl-details`,children:[L(`summary`,{children:r(`setup.server.howToStart`)}),L(`pre`,{dir:`ltr`,children:e.start})]}),z(Bq,{children:[L(`button`,{type:`button`,className:i?`btn-secondary`:`btn-primary`,onClick:t,children:r(`setup.tryAgain`)}),e.use_gaia&&L(`button`,{type:`button`,className:i?`btn-primary`:`btn-secondary`,onClick:n,children:r(`setup.server.useGaia`)})]}),e.use_gaia&&L(`p`,{className:`setup-hint`,children:r(`setup.server.useGaiaNote`)}),e.use_gaia&&e.env_url&&L(`p`,{className:`setup-hint`,children:r(`setup.server.envIgnoredNote`,{url:e.env_url})})]})}function jY({text:e}){let t=R();return z(`div`,{className:`setup-error`,role:`alert`,children:[L(`p`,{children:t(`setup.failedLead`)}),z(`details`,{className:`dl-details`,children:[L(`summary`,{children:t(`setup.progress.details`)}),L(`pre`,{dir:`ltr`,children:e})]})]})}function MY({run:e}){let t=R();return e.problem?z(`div`,{className:`setup-error`,role:`alert`,children:[L(`p`,{children:t(e.problem.kind===`server_too_old`?`setup.server.tooOld`:`setup.server.unreachable`)}),z(`details`,{className:`dl-details`,children:[L(`summary`,{children:t(`setup.progress.details`)}),L(`pre`,{dir:`ltr`,children:e.problem.message})]})]}):z(`div`,{className:`setup-error`,role:`alert`,children:[L(`p`,{children:t(e.components?.server===`failed`?`setup.server.ownFailed`:`setup.stopped`)}),e.error&&z(`details`,{className:`dl-details`,children:[L(`summary`,{children:t(`setup.progress.details`)}),L(`pre`,{dir:`ltr`,children:e.error})]})]})}var NY=[`check`,`plan`,`key`,`models`,`gpu`,`download`,`test`,`ready`],PY=`gaia.setup.agentPick`,FY=`gaia.setup.heldRun`;function IY(e){try{let t=sessionStorage.getItem(e);return t?JSON.parse(t):null}catch(t){return console.warn(`[SetupScreen] could not read ${e}; the agent pick starts fresh`,t),null}}function LY(e,t){try{t==null?sessionStorage.removeItem(e):sessionStorage.setItem(e,JSON.stringify(t))}catch(t){console.warn(`[SetupScreen] could not save ${e}; a reload will lose the agent pick`,t)}}function RY(e){return e instanceof Error?e.message:String(e)}function zY({onReady:e,onClose:t}){let n=R(),r=zc(e=>e.refresh),i=zc(e=>e.select),[a,o]=(0,B.useState)(`local`),[s,c]=(0,B.useState)(`check`),[l,u]=(0,B.useState)(!1),[d,f]=(0,B.useState)(`models`),[p,m]=(0,B.useState)(null),[h,g]=(0,B.useState)(null),[_,v]=(0,B.useState)(()=>new Set([`check`])),y=(0,B.useRef)(`check`),[b,x]=(0,B.useState)(null),[C,w]=(0,B.useState)(null),[T,E]=(0,B.useState)(null),[D,O]=(0,B.useState)(null),[ee,te]=(0,B.useState)(null),[ne,re]=(0,B.useState)(``),[k,ae]=(0,B.useState)({busy:!1,error:null,done:!1}),[A,se]=(0,B.useState)(null),[ce,le]=(0,B.useState)(null),[de,fe]=(0,B.useState)(null),[j,he]=(0,B.useState)(null),[M,ge]=(0,B.useState)(null),[_e,ve]=(0,B.useState)(null),[ye,be]=(0,B.useState)(!1),[xe,Se]=(0,B.useState)(null),[Ce,we]=(0,B.useState)(!1),[Te,Ee]=(0,B.useState)(!1),[De,ke]=(0,B.useState)(null),[Ae,je]=(0,B.useState)(!1),[Ne,Pe]=(0,B.useState)(null),[Fe,Ie]=(0,B.useState)(null),[Le,Re]=(0,B.useState)(null),[ze,Be]=(0,B.useState)(!1),[Ve,He]=(0,B.useState)([]),[Ue,We]=(0,B.useState)([]),[Ge,qe]=(0,B.useState)([]),[Je,Ye]=(0,B.useState)(!1),[Ze,Qe]=(0,B.useState)(!1),$e=(0,B.useRef)({gaiaLemonade:!1,options:{}}),et=(0,B.useRef)(null),tt=(0,B.useRef)(!1),nt=(0,B.useRef)(!1),[rt,at]=(0,B.useState)(!1),[ot,st]=(0,B.useState)(!1),ct=(0,B.useCallback)(()=>st(!0),[]),[lt,ut]=(0,B.useState)(null),[dt,ft]=(0,B.useState)(null),pt=(0,B.useRef)(!0);(0,B.useEffect)(()=>(pt.current=!0,()=>{pt.current=!1}),[]);let{network:mt,providers:ht,recheck:gt}=iJ(),_t=e=>ht.find(t=>t.id===e),vt=_t(a),N=vt?.key_source===`environment`&&vt.key_hint?vt:void 0,yt=e=>!!_t(e)?.blocked,bt=mt?.reachable!==!1||a===`amd`,F=vt?.key_source===`stored`||vt?.key_source===`lemonade`,xt=yt(`fireworks`)&&yt(`amd`),St=e=>yt(e)||e===`amd`&&mt?.reachable===!1,Ct=e=>yt(e)?n(`settings.privacy.localOnlyBlocked`):n(`setup.key.gatewayOff`),wt=a!==`local`,Tt=T?.server_only?T:null,Et=T&&!T.server_only?T:null,Dt=T?.state===`running`||T?.state===`verifying`,Ot=Et?.state===`ready`,At=vJ(T),jt=!(Et?.models??[]).some(e=>e.state===`downloading`||e.state===`queued`)&&((Et?.tests?.length??0)>0||Et?.state===`verifying`),Mt=(0,B.useCallback)(()=>{w(null),ue().then(x).catch(e=>w(RY(e)))},[]),Nt=(0,B.useRef)(0),Pt=(0,B.useCallback)(async()=>{let e=++Nt.current;le(null);try{let t=await En(!1);return e===Nt.current?(se(t),t):null}catch(t){return e===Nt.current&&le(RY(t)),null}},[]),Ft=(0,B.useCallback)(async()=>{try{let e=await Xe();pt.current&&ve(e??null)}catch(e){console.warn(`[SetupScreen] GPU memory could not be read; the step stays hidden`,e)}},[]),It=t!=null;(0,B.useEffect)(()=>{ie().then(e=>Ye(e.source===`config`)).catch(e=>console.warn(`[SetupScreen] could not read which Lemonade GAIA uses`,e)),Mt(),Pt(),oe().then(e=>{e.state===`idle`&&!e.models?.length||It&&e.state!==`running`&&e.state!==`verifying`||(E(e),e.server_only||c(`download`),e.skip_chat_model&&o(EY()===`amd`?`amd`:`fireworks`))}).catch(e=>te(RY(e))).finally(()=>at(!0))},[Mt,Pt,It]),(0,B.useEffect)(()=>{A?.catalog&&A.lemonade.reachable&&(fe(e=>e??oq(A)),Ft(),!T&&A.catalog.some(e=>e.partial&&e.selected)&&je(!0))},[A,Ft,T]);let Lt=(0,B.useCallback)(()=>{et.current&&clearInterval(et.current),et.current=null},[]),Rt=(T?.models??[]).filter(e=>e.state===`failed`&&e.error_kind===`disk_full`).length;(0,B.useEffect)(()=>{Rt>0&&Pt()},[Rt,Pt]);let zt=(0,B.useCallback)(async()=>{try{let e=await oe();if(O(null),e.state===`idle`&&!e.models?.length){E(null),c(`plan`),Qe(!0),Pt();return}E(e)}catch(e){O(RY(e))}},[Pt,n]);(0,B.useEffect)(()=>(!At&&!D||(et.current=setInterval(()=>{zt()},wY)),Lt),[At,D,zt,Lt]),(0,B.useEffect)(()=>{Tt&&Tt.state===`ready`&&(Mt(),Pt())},[Tt,Tt?.state,Mt,Pt]),(0,B.useEffect)(()=>{Ot&&(Mt(),Pt().then(e=>{e&&ge(e)}),Ft())},[Ot,Mt,Pt,Ft]);let I=(0,B.useRef)(!1),Bt=(0,B.useCallback)(async(e=!1,t={})=>{if(I.current)return!1;I.current=!0,te(null),ke(null),je(!1),Qe(!1);try{DY(a),$e.current={gaiaLemonade:e,options:t};let n=await dn(wt,e,t);E(n),g(null);let r=t.extraModels??[];return r.length&&qe(e=>e.filter(e=>!r.includes(e))),t.serverOnly||c(`download`),e&&Ye(!1),!0}catch(e){let t=kt(e);if(t)return Se({kind:`server`,detail:t,then:`run`}),!1;if(e instanceof Vn&&e.httpStatus===409){let e=await oe().catch(()=>null);if(e&&(e.state===`running`||e.state===`verifying`))return E(e),g(null),e.server_only||c(`download`),!0}return te(RY(e)),!1}finally{I.current=!1}},[a,wt]);(0,B.useEffect)(()=>{s===`check`&&rt&&ot&&A&&!A.lemonade.reachable&&!T&&!tt.current&&(tt.current=!0,Bt(!1,{serverOnly:!0}))},[s,rt,ot,A,T,Bt]);let Vt=!!(de&&A?.catalog&&A.lemonade.reachable&&(b||C)),Ht=(0,B.useCallback)(()=>{let{gaiaLemonade:e,options:t}=$e.current;Bt(e,t)},[Bt]),Ut=(0,B.useCallback)((e,t=A)=>{he(t);let n=t&&de&&!wt?_q(t,de):[];return Bt(!1,{acknowledgeLowDisk:e,keepTrying:ye,extraModels:n})},[A,de,wt,ye,Bt]),[Wt,Kt]=(0,B.useState)(!1),[qt,Jt]=(0,B.useState)(()=>IY(PY)),Yt=(0,B.useCallback)(e=>{Jt(e),LY(PY,e)},[]),[Xt,Zt]=(0,B.useState)(()=>IY(FY)),Qt=(0,B.useCallback)(e=>{Zt(e),LY(FY,e)},[]),[en,tn]=(0,B.useState)(null),[nn,rn]=(0,B.useState)(!1),an=(0,B.useCallback)(async(e,t,n)=>{if(tn(null),t){rn(!0);try{await pe({flagship_agent:t})}catch(e){tn(RY(e));return}finally{rn(!1)}}Yt(null),Qt(null),await Ut(e.acknowledgeLowDisk,n)},[Ut,Yt,Qt]),on=(0,B.useRef)(qt);on.current=qt;let sn=(0,B.useRef)(Xt);sn.current=Xt;let cn=(0,B.useRef)(an);cn.current=an;let un=jJ(()=>{let e=on.current;e&&Yt({...e,download:!1}),e&&sn.current&&cn.current(sn.current,e.id)}),fn=un.start,pn=un.follow,mn=(0,B.useCallback)(async(e,t)=>{let n=on.current;if(Qt(e),g(null),c(`download`),!n||!n.download){await an(e,n?.id??null,t);return}tn(null);let r;try{r=await $t()}catch(e){tn(RY(e));return}r.programs.find(e=>e.id===n.id)?.installed?await an(e,n.id,t):r.download.state===`downloading`?pn(r.download):fn()},[an,Qt,pn,fn]),hn=(0,B.useCallback)(()=>{Qt(null),tn(null),g(null),c(`models`)},[Qt]),gn=(0,B.useCallback)(()=>{Xt&&an(Xt,null)},[Xt,an]),_n=(0,B.useRef)(!1);(0,B.useEffect)(()=>{_n.current||(_n.current=!0,$t().then(e=>{let t=e.download.state===`downloading`;if(pn(e.download),!sn.current)return;if(t){c(`download`);return}Qt(null);let n=on.current;n&&e.programs.find(e=>e.id===n.id)?.installed&&Yt({...n,download:!1})}).catch(e=>console.warn(`[SetupScreen] could not read the agent programs; the Agent card says so on Customize`,e)))},[pn,Qt,Yt]);let vn=(0,B.useRef)(!1),yn=(0,B.useCallback)(async(e,t=Ce)=>{if(!A||!de||vn.current)return;ke(null),Kt(e);let r=GK(A),i=wt?[]:mq(r,de).filter(e=>!e.downloaded||e.id===de.defaultChat),a=i.find(YK);if(a){let e=a.id===de.defaultChat?`setup.models.cantRun.chat`:`setup.models.cantRun.other`;ke(n(e,{name:a.name,why:Tq(a,n)}))}else if(!wt&&!t&&i.length>0&&i.every(e=>e.need_gb!=null))Se({kind:`no_fit`,models:i});else{Ee(!0),vn.current=!0;try{let n=A;if(!wt&&de.defaultChat&&de.defaultChat!==n.chat_model.id)try{n=await me(de.defaultChat,t,!1)}catch(e){let t=kt(e);if(t){Se({kind:`server`,detail:t,then:`chat`});return}throw e}if(!wt){await HJ();let e=nq(r,de);e!==(n.vision_model??null)&&(n=await Me(e,!1));for(let e of gq(n,de))n=await Rn(e.id,e.skipped,!1)}se(n),on.current?await mn({acknowledgeLowDisk:e},n):await Ut(e,n)}catch(e){ke(RY(e))}finally{vn.current=!1,Ee(!1)}}},[A,de,wt,Ce,Ut,mn,n]),bn=(0,B.useCallback)(e=>{ke(null),s===`download`?g(e===y.current?null:e):(g(null),c(e===`test`||e===`ready`?`download`:e))},[s]),xn=(0,B.useCallback)(()=>{h??o(`local`),bn(`plan`)},[bn,h]),Sn=(0,B.useCallback)(()=>{Dt&&h!=null||(o(`local`),u(!0),bn(`models`))},[bn,Dt,h]),[Cn,wn]=(0,B.useState)(`local`),Tn=zc(e=>e.active?.remote&&e.active.provider!==`local`?e.active.provider:null),Dn=zc(e=>e.active?.remote?e.active.model:null),On=(0,B.useCallback)(e=>{Dt&&h!=null||(u(!1),o(e),wn(`cloud`),Ie(e===Tn?Dn:null),bn(`key`))},[bn,Dt,h,Tn,Dn]),kn=(0,B.useCallback)(()=>On(EY()===`amd`?`amd`:`fireworks`),[On]),An=(0,B.useCallback)(()=>{Tn?On(Tn):bn(`plan`)},[Tn,On,bn]),jn=!!_e?.applies,Mn=(0,B.useCallback)(()=>{bn((h??s)===`gpu`?d:`plan`)},[d,bn,h,s]),Nn=(0,B.useCallback)(e=>{f(e),bn(`gpu`)},[bn]),Pn=(0,B.useRef)({prev:null,next:null});(0,B.useEffect)(()=>{let e=e=>{if(!e.altKey||xe||(e.target instanceof Element?e.target:null)?.closest(`input, textarea, select, [contenteditable="true"]`))return;let t=e.key===`ArrowLeft`?Pn.current.prev:e.key===`ArrowRight`?Pn.current.next:null;t&&(e.preventDefault(),bn(t))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[bn,xe]);let Fn=(0,B.useCallback)(async()=>{try{await S(),await zt()}catch(e){ke(RY(e))}},[zt]),In=(0,B.useCallback)(async(e,t)=>{ke(null),Ee(!0);try{t===`verify`&&await Oe(e),t===`disk_full`&&Pt();try{E(await Ke(e,{keepTrying:ye}))}catch(t){let n=kt(t);if(!n)throw t;Se({kind:`server`,detail:n,then:`retry`,id:e})}}catch(e){ke(RY(e))}finally{Ee(!1)}},[ye,Pt]),Ln=(0,B.useCallback)(async e=>{ke(null),Ee(!0);try{A?.catalog?.find(t=>t.id===e)?.planned&&se(await Rn(e,!0,!1)),E(t=>t&&{...t,models:t.models?.map(t=>t.id===e?{...t,state:`skipped`}:t)});let{options:t}=$e.current;$e.current.options={...t,extraModels:t.extraModels?.filter(t=>t!==e)},fe(t=>t&&t.ticked.has(e)?cq(t,GK(A),e,!1):t)}catch(e){ke(RY(e))}finally{Ee(!1)}},[A]),zn=(0,B.useCallback)(async()=>{await Fn(),Ht()},[Fn,Ht]),Bn=(0,B.useCallback)(async()=>{if(!Dt){ae({busy:!0,error:null,done:!1});try{await ln(a,{api_key:!Je&&ne||void 0},e=>ae({busy:!0,error:null,done:!1,waiting:e}),()=>!pt.current);let{models:e}=await Gt(a),t=Fe??Le,r=t?e.find(e=>e.id===t):e.find(e=>e.rank===1)??e[0];if(!r)throw Error(t?n(`setup.key.modelNotOffered`,{model:Xc(t)}):n(`setup.key.noModels`));await i(r.id),Pe(r.id),re(``),ae({busy:!1,error:null,done:!0}),Ut(!1)}catch(e){ae({busy:!1,error:RY(e),done:!1})}}},[a,ne,Fe,Le,i,Je,Ut,n,Dt]),Hn=(0,B.useCallback)(e=>{DY(e),o(e),Ie(e===Tn?Dn:null),Re(null),ae({busy:!1,error:null,done:!1})},[Tn,Dn]);(0,B.useEffect)(()=>{if(!Ot||Ue.length===0||nt.current)return;let e=Ue;nt.current=!0,Bt(!1,{keepTrying:ye,extraModels:e}).then(t=>{nt.current=!1,We(t=>t.filter(t=>!e.includes(t))),t||qe(t=>[...t,...e.filter(e=>!t.includes(e))])})},[Ot,Ue,ye,Bt]);let Un=Ot&&Ue.length===0,Wn=wt?Ne:Et?.chat_model??(A&&!A.decided_after_server?A.chat_model.id:null),Gn=(0,B.useCallback)(async t=>{ke(null);try{!wt&&Wn&&await i(Wn),await r()}catch(e){ke(RY(e));return}e(t)},[Wn,wt,e,r,i]);(0,B.useEffect)(()=>{Un&&it().then(e=>He(e.cards)).catch(e=>console.warn(`[SetupScreen] no first tasks to offer`,e))},[Un]);let Kn=(0,B.useMemo)(()=>{let e={};for(let t of A?.catalog??[])e[t.id]=t.name;return e},[A]),qn=T?.state===`failed`||T?.state===`cancelled`,Jn=T?.state===`failed`||!!ee||!!ce||!!C||!!D||!!De,Yn=It?Ve:Ve.filter(e=>e.skill!==`check-in`),Xn=Et&&(Et.state===`failed`||Et.state===`cancelled`)&&(Et.models??[]).length>0&&(Et.models??[]).every(e=>e.state===`ready`||e.state===`skipped`||e.state===`verifying`||e.state===`unchecked`)&&!At,Zn=!!Et&&qn&&!Et.problem&&Object.values(Et.components??{}).includes(`failed`),Qn=GK(A),$n=de?dq(Qn,de):[],er=A&&de?pq(A,de):null,tr=de?Qn.filter(e=>de.ticked.has(e.id)&&e.downloaded).length:0,nr=Qn.some(e=>e.downloaded),rr=Vt?tr===0?nr?`setup.check.ledeOthersOnPc`:`setup.check.ledeDone`:$n.length===0?`setup.check.ledeAllOnPc`:`setup.check.ledeSomeOnPc`:`setup.check.lede`,ir=Qn.find(e=>e.id===de?.defaultChat),ar=!!b&&!b.compatible&&b.blockers.length>0,or=Un?`ready`:s===`download`&&jt?`test`:s;y.current=or;let sr=h??or;(0,B.useEffect)(()=>{v(e=>e.has(sr)?e:new Set(e).add(sr))},[sr]);let cr=(0,B.useRef)(!0);(0,B.useEffect)(()=>{if(cr.current){cr.current=!1;return}let e=document.querySelector(`.setup-scroll`);e&&(e.scrollTop=0),document.getElementById(`setup-title`)?.focus({preventScroll:!0})},[sr]);let lr=[{id:`check`,label:n(`setup.check.title`),key:`setup.check.title`},{id:`plan`,label:n(`setup.plan.step`),key:`setup.plan.step`},{id:`download`,label:n(`setup.download.step`),key:`setup.download.step`},{id:`test`,label:n(`setup.test.step`),key:`setup.test.step`},{id:`ready`,label:n(`setup.ready.step`),key:`setup.ready.step`}],ur=e=>e===`models`||e===`key`?`plan`:e===`gpu`?d===`check`?`check`:`plan`:e,dr=wt?`key`:l?`models`:`plan`,fr=lr.findIndex(e=>e.id===ur(or)),pr=e=>e===`download`||e===`test`||e===`ready`,mr=[];if(b){let e=[A?.system?.physical_memory?`${wk(A.system.physical_memory,null)} installed`:null,b.ram_gb==null?null:`${b.ram_gb} GB the OS can use`].filter(Boolean).join(`, `),t=b.disk_free_gb==null?null:`${Math.round(b.disk_free_gb)} GB free on disk`;mr.push(`This PC: ${[b.gpu_name,b.npu_detected?`NPU`:null].filter(Boolean).join(`, `)||`no GPU reported`}`+[e,t].filter(Boolean).map(e=>`; ${e}`).join(``))}else C&&mr.push(`Couldn't read this PC: ${C}`);lt&&(mr.push(`Found your Lemonade${lt.version?` ${lt.version}`:``} at ${lt.url}`),mr.push(dt===`external`?`You chose your own Lemonade`:dt===`gaia`?`You chose GAIA's own Lemonade`:`Waiting for you to choose which Lemonade GAIA uses`)),A&&(!lt||dt)?mr.push(A.lemonade.reachable?`Model server answering at ${A.lemonade.url??`its address`}`:`No model server answering yet`):ce&&mr.push(`Couldn't read the model list: ${ce}`);let hr=(e,t)=>t<=fr||_.has(e)&&!pr(e),gr=lr.map((e,t)=>({id:e.id,label:e.label,status:t<fr?`done`:t>fr?`pending`:or===`ready`?`done`:qn&&(or===`download`||or===`test`||or===`check`)?`failed`:Dt&&(or===`download`||or===`test`)?`active`:`current`,shown:e.id===ur(sr),onOpen:e.id!==ur(sr)&&hr(e.id,t)?()=>bn(e.id===`plan`?dr:e.id):void 0})),_r=lr.findIndex(e=>e.id===ur(sr)),vr=sr===`gpu`&&d===`check`?.5:NY.indexOf(sr),yr=(0,B.useRef)(vr),br=(0,B.useRef)(`forward`);yr.current!==vr&&(br.current=vr>yr.current?`forward`:`back`,yr.current=vr);let xr=sr===`gpu`?d:sr===`models`||sr===`key`?`plan`:_r>0?lr[_r-1].id===`plan`?dr:lr[_r-1].id:null,Sr=(sr!==`gpu`&&_r>=0&&_r<lr.length-1&&hr(lr[_r+1].id,_r+1)?lr[_r+1].id:null)??(h==null?sr===`check`&&Vt?`plan`:sr===`gpu`?d:null:null);Pn.current={prev:xr,next:Sr};let Cr=sr===`gpu`||sr===`models`||sr===`key`,wr=h!=null&&Dt,Tr=[`server`];wt||Tr.push(`chat`),!wt&&de&&QK(Qn,de)&&Tr.push(`vision`),de&&Qn.some(e=>qK(e)&&de.ticked.has(e.id))&&Tr.push(`embedding`);for(let e of Qn)de&&XK(e)&&de.ticked.has(e.id)&&!e.downloaded&&Tr.push(e.roles[0]);Tr.push(`agent`);let Er=un.job,Dr=Er?.state===`failed`,Or=Xt?z(P.Fragment,{children:[Er&&Er.state!==`idle`&&Er.state!==`done`&&z(`section`,{className:`setup-agent-download`,"aria-labelledby":`setup-agent-download-title`,children:[L(`h3`,{className:`mc-job-title`,id:`setup-agent-download-title`,children:n(`setup.agent.title`)}),L(NJ,{job:Er,name:qt?.id??`gaiacpp`,onRetry:()=>void fn(),failedNote:n(`setup.agent.carryOnNote`,{name:qt?.current??`gaiapy`}),interrupted:un.interrupted})]}),en&&L(`p`,{className:`setup-error`,role:`alert`,children:n(`setup.agent.saveFailed`,{error:en})}),(nn||!Er&&!en)&&z(`p`,{className:`setup-hint`,role:`status`,children:[L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,n(`setup.download.starting`)]}),A&&L(`section`,{className:`setup-card`,"aria-label":n(`setup.contents.title`),children:L(lJ,{plan:A,models:$n})}),z(Bq,{children:[(Dr||en)&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:gn,disabled:nn,children:n(`setup.agent.carryOn`,{name:qt?.current??`gaiapy`})}),en&&Xt&&L(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void mn(Xt),disabled:nn,children:n(`setup.tryAgain`)}),!Dr&&!en&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:hn,disabled:nn,children:n(`setup.progress.cancel`)})]})]}):null,kr=wt&&k.done&&Ne?z(`p`,{className:`setup-ok setup-key-accepted`,role:`status`,children:[L(Yr,{size:14,"aria-hidden":`true`}),` `,n(`setup.key.accepted`,{model:Xc(Ne)})]}):null,Ar=de&&!wt?Qn.filter(e=>XK(e)&&!de.ticked.has(e.id)&&!e.downloaded&&(ZK(ir)||!e.roles.includes(`image_creation`))):[],jr=Qn.find(e=>e.fit_code===`memory`&&e.chat_choice&&e.support===`verified`);return z(`main`,{className:`setup`,"aria-labelledby":`setup-title`,children:[L(mY,{steps:gr}),L(zq,{value:p,children:z(`div`,{className:`setup-pane`,children:[L(`div`,{className:`setup-scroll`,children:z(`div`,{className:`setup-inner`,children:[_r>=0&&z(`nav`,{className:`setup-topnav`,"aria-label":n(`setup.nav.label`),children:[L(`button`,{type:`button`,className:`setup-arrow`,onClick:()=>xr&&bn(xr),disabled:!xr,"aria-label":n(`setup.nav.prev`),children:L(ti,{size:16,"aria-hidden":`true`})}),L(`button`,{type:`button`,className:`setup-arrow`,onClick:()=>Sr&&bn(Sr),disabled:!Sr,"aria-label":n(`setup.nav.next`),children:L(ri,{size:16,"aria-hidden":`true`})}),L(`span`,{children:L(`bdi`,{children:n(`setup.nav.stepOf`,{n:String(_r+1),total:String(lr.length)})})}),h!=null&&h!==or&&L(`button`,{type:`button`,className:`link-btn`,onClick:()=>g(null),children:n.compose(e=>e(`setup.nav.toLive`,{step:e(lr.find(e=>e.id===or)?.key??`setup.download.step`)}))}),L(OJ,{})]}),Ae&&s!==`download`&&z(`div`,{className:`setup-banner`,role:`status`,children:[L(Na,{size:14,"aria-hidden":`true`}),L(`span`,{children:n(`setup.resume.banner`)})]}),Ze&&s!==`download`&&L(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.interrupted`)}),z(`div`,{className:`setup-stage is-${br.current}`,children:[sr===`check`&&z(P.Fragment,{children:[L(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(Vt?`setup.check.headingDone`:`setup.check.heading`)}),L(`p`,{className:`setup-lede`,children:n(rr)}),L(pY,{hardware:b,hardwareError:C,plan:A,serverRun:Tt,awaitingChoice:!!lt&&!ot}),Tt?.state===`running`&&z(P.Fragment,{children:[L(SJ,{run:Tt,idle:n(`setup.check.serverWorking`),bar:!1}),L(Bq,{children:L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void Fn(),children:n(`setup.progress.cancel`)})})]}),Vt&&A&&L(rY,{plan:A,hardware:b,onChangeMemory:jn&&h==null?()=>Nn(`check`):void 0}),Vt&&h==null&&!(lt&&!ot)&&L(Bq,{children:L(`button`,{type:`button`,className:`btn-primary`,onClick:An,children:n(`setup.continue`)})}),Tt&&qn&&z(P.Fragment,{children:[L(MY,{run:Tt}),Tt.problem?L(AY,{problem:Tt.problem,onRetry:()=>void Bt(!1,{serverOnly:!0}),onUseGaia:()=>void Bt(!0,{serverOnly:!0})}):L(Bq,{children:L(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Bt(!!Tt.gaia_lemonade,{serverOnly:!0}),children:n(`setup.tryAgain`)})})]}),ce&&!A&&z(P.Fragment,{children:[L(jY,{text:ce}),z(Bq,{children:[L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void Bt(!1,{keepTrying:ye}),children:n(`setup.models.useRecommended`)}),L(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Pt(),children:n(`setup.tryAgain`)})]}),L(`p`,{className:`setup-hint`,children:n(`setup.models.useRecommendedNote`)})]}),ee&&L(jY,{text:ee}),ee&&!Tt&&A&&!A.lemonade.reachable&&L(Bq,{children:L(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Bt(!1,{serverOnly:!0}),children:n(`setup.tryAgain`)})}),rt&&A&&(!A.lemonade.reachable&&!Tt||Vt&&h==null&&A.lemonade.mode!==`external`)&&L(kY,{onNothingToOffer:ct,canInstallOwn:!A.lemonade.reachable&&!Tt,onFound:ut,onChosen:e=>{Ye(e===`external`),ft(e),st(!0),Mt(),Pt()}})]}),sr===`plan`&&A&&de&&z(P.Fragment,{children:[L(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.plan.title`)}),L(`p`,{className:`setup-lede`,children:n(`setup.plan.lede`)}),z(`div`,{className:`setup-where`,children:[z(`section`,{className:`setup-hero setup-where-card${Cn===`local`?` is-active`:``}`,"aria-label":n(`setup.plan.label`),onClick:()=>!wr&&wn(`local`),children:[L(`p`,{className:`setup-eyebrow`,children:de.chatChosen?n(`setup.plan.yours`):n(`setup.plan.recommended`)}),z(`p`,{className:`setup-hero-title`,children:[L(`input`,{type:`radio`,name:`setup-where`,checked:Cn===`local`,onChange:()=>wn(`local`),disabled:wr,"aria-labelledby":`setup-where-local`}),L(`bdi`,{id:`setup-where-local`,children:n(`setup.plan.run`,{name:ir?.name??``})})]}),z(`dl`,{className:`setup-facts`,children:[z(`div`,{children:[L(`dt`,{children:n(`setup.summary.download`)}),L(`dd`,{children:L(`bdi`,{dir:`ltr`,children:Sk(fq(A,de).downloadGb??0)})})]}),z(`div`,{children:[L(`dt`,{children:n(`setup.plan.runsOn`)}),L(`dd`,{children:L(`bdi`,{children:ir&&JK(ir)?n(`setup.checks.npu`):b?.gpu_name??n(`setup.plan.cpu`)})})]}),z(`div`,{children:[L(`dt`,{children:n(`setup.plan.diskAfter`)}),L(`dd`,{children:L(`bdi`,{dir:`ltr`,children:fq(A,de).afterGb==null?`—`:Sk(Math.max(0,fq(A,de).afterGb))})})]})]}),z(`ul`,{className:`setup-reasons`,children:[!de.chatChosen&&L(`li`,{children:n(`setup.plan.why.evaluated`)}),!de.chatChosen&&A.left_for_apps_gb!=null&&L(`li`,{children:n(`setup.plan.why.headroom`,{left:Tk(A.left_for_apps_gb)})}),ir?.need_gb!=null&&ir.capacity_gb!=null&&ir.fits&&L(`li`,{children:n(`setup.plan.why.fits`,{need:Tk(ir.need_gb),have:Tk(ir.capacity_gb)})}),L(`li`,{children:n(`setup.plan.why.private`)}),ir&&JK(ir)&&L(`li`,{children:n(`setup.plan.why.noImagesNpu`)}),jr&&jr.id!==ir?.id&&jr.need_gb!=null&&jr.capacity_gb!=null&&L(`li`,{children:n(`setup.plan.why.bigger`,{name:jr.name,need:Tk(jr.need_gb),have:Tk(jr.capacity_gb)})})]}),$n.length>0&&L(`p`,{className:`setup-hint`,children:n(`setup.plan.cancelAnytime`)})]}),z(`section`,{className:`setup-hero setup-where-card${Cn===`cloud`?` is-active`:``}${xt?` is-disabled`:``}`,"aria-label":n(`setup.plan.cloudLabel`),onClick:()=>!wr&&!xt&&wn(`cloud`),children:[z(`p`,{className:`setup-hero-title`,children:[L(`input`,{type:`radio`,name:`setup-where`,checked:Cn===`cloud`,onChange:()=>wn(`cloud`),disabled:wr||xt,"aria-labelledby":`setup-where-cloud`}),L(`span`,{id:`setup-where-cloud`,children:n(`setup.plan.cloud`)})]}),xt?L(`p`,{className:`setup-hint`,children:n(`settings.privacy.localOnlyBlocked`)}):z(`ul`,{className:`setup-reasons`,children:[L(`li`,{children:n(`setup.plan.cloudWhy.stillLocal`)}),L(`li`,{children:n(`setup.plan.cloudWhy.key`)}),L(`li`,{children:n(`setup.plan.cloudWhy.sent`)})]})]})]}),z(Bq,{children:[Cn!==`cloud`&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:Sn,disabled:Te||wr,children:n(`setup.plan.customize`)}),Cn===`cloud`?L(`button`,{type:`button`,className:`btn-primary`,onClick:kn,disabled:wr,children:n(`setup.continue`)}):z(`button`,{type:`button`,className:`btn-primary`,onClick:()=>er?Se({kind:`low_disk`}):void yn(!1),disabled:Te||ar||wr,children:[Te&&L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,$n.length?n(`setup.plan.start`):n(`setup.plan.startNoDownload`)]})]}),t&&L(`div`,{className:`setup-row`,children:L(`button`,{type:`button`,className:`link-btn`,onClick:t,children:n(`setup.backToGaia`)})}),ar&&z(`div`,{className:`setup-error`,role:`alert`,children:[L(`p`,{children:n(`setup.blocked`)}),z(`details`,{className:`dl-details`,children:[L(`summary`,{children:n(`setup.progress.details`)}),L(`pre`,{dir:`ltr`,children:b?.blockers.join(`
|
|
213
|
+
`)})]})]}),er&&L(`p`,{className:`setup-error`,role:`alert`,children:n(`setup.summary.short`,{need:Sk(er.needGb),free:Sk(er.freeGb),drive:n(`setup.summary.theDrive`),freeUp:Sk(er.freeUpGb)})}),(De??ee)&&L(jY,{text:De??ee}),Cn!==`cloud`&&z(`details`,{className:`setup-disclosure`,children:[L(`summary`,{children:n(`setup.plan.whatDownloads`)}),L(lJ,{plan:A,models:$n})]})]}),sr===`gpu`&&_e&&z(P.Fragment,{children:[L(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.gpu.title`)}),L(`p`,{className:`setup-lede`,children:n(`setup.gpu.lede`)}),L(Xq,{status:_e,onStatus:ve,mode:`setup`,headingId:`setup-title`,names:Kn,cloud:a!==`local`,onBack:Mn,onSkip:()=>bn(d),onContinue:()=>bn(d)})]}),sr===`models`&&z(P.Fragment,{children:[L(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.models.title`)}),A&&de&&L(UJ,{plan:A,selection:de,onSelection:fe,disabled:Te||wr,onRecheck:()=>void Pt()}),jn&&_e?.total_gb!=null&&_e.gpu_gb!=null&&z(`p`,{className:`setup-hint setup-gpu-option`,children:[n(`setup.models.gpu`,{gpu:Sk(_e.gpu_gb),total:Sk(_e.total_gb)}),` `,L(`button`,{type:`button`,className:`link-btn`,onClick:()=>Nn(`models`),disabled:Te||wr,children:n(`setup.found.changeMemory`)})]}),L(LJ,{disabled:Te||wr,pending:qt?.id??null,onPending:Yt}),L(Zq,{plan:A,planError:ce,onRetryPlan:()=>void Pt(),onUseRecommended:()=>void Bt(!1,{keepTrying:ye}),selection:de,onSelection:fe,cloud:!1,keepTrying:ye,onKeepTrying:be,onBack:Mn,onContinue:e=>void yn(e),busy:Te||wr,error:De??ee})]}),sr===`key`&&z(`form`,{id:`setup-key-form`,onSubmit:e=>{e.preventDefault(),Bn()},className:`setup-form`,children:[L(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.key.title`)}),L(jB,{className:`setup-choices`,"aria-label":n(`setup.key.provider`),children:SY.filter(e=>e.id!==`local`&&(e.id!==`amd`||bt)).map(e=>z(`button`,{type:`button`,role:`radio`,"aria-checked":a===e.id,className:`setup-choice${a===e.id?` is-active`:``}${St(e.id)?` is-disabled`:``}`,onClick:()=>Hn(e.id),disabled:k.busy||St(e.id),title:yt(e.id)?n(`settings.privacy.localOnlyBlocked`):void 0,children:[L(xi,{size:16,"aria-hidden":`true`}),z(`span`,{children:[L(`span`,{className:`setup-choice-title`,children:L(`bdi`,{children:CY(e,n)})}),L(`span`,{className:`setup-choice-note`,children:St(e.id)?Ct(e.id):n(e.note)})]})]},e.id))}),mt?.reachable===!1&&bt&&L(`button`,{type:`button`,className:`link-btn setup-start`,onClick:gt,children:n(`setup.key.checkAgain`)}),yt(a)&&L(`p`,{className:`setup-a11y-alert`,role:`alert`,children:n(`settings.privacy.localOnlyBlocked`)}),a===`fireworks`&&!Je&&!yt(a)&&z(`section`,{className:`setup-card`,children:[L(`h3`,{className:`mc-job-title`,children:n(`setup.key.getOne`)}),z(`ol`,{className:`setup-key-steps`,children:[L(`li`,{children:L(`a`,{href:bY,target:`_blank`,rel:`noreferrer`,children:n(`setup.key.step1`)})}),L(`li`,{children:n(`setup.key.step2`)}),L(`li`,{children:n(`setup.key.step3`)})]})]}),a===`amd`&&!Je&&!yt(a)&&L(`section`,{className:`setup-card`,children:L(`p`,{className:`setup-hint`,children:L(`a`,{href:xY,target:`_blank`,rel:`noreferrer`,children:n(`setup.key.gatewayHelp`)})})}),!yt(a)&&L(RK,{provider:a,limit:3,picked:Fe,onPick:Ie,onDefault:Re,pickDisabled:k.busy||wr}),!Je&&z(P.Fragment,{children:[L(`label`,{className:`setup-key-label`,htmlFor:`setup-key-input`,children:n(`setup.key.labelFor`,{provider:CY(SY.find(e=>e.id===a)??SY[1],n)})}),z(`div`,{className:`setup-row setup-key-row`,children:[L(`input`,{id:`setup-key-input`,className:`settings-input`,type:ze?`text`:`password`,autoComplete:`off`,spellCheck:!1,value:ne,onChange:e=>re(e.target.value),placeholder:F?n.bare(`setup.key.placeholder`):n.bare(`setup.key.placeholderNew`)}),L(`button`,{type:`button`,className:`btn-secondary setup-key-show`,"aria-label":n(ze?`setup.key.hide`:`setup.key.show`),title:n(ze?`setup.key.hide`:`setup.key.show`),onClick:()=>Be(e=>!e),children:L(ze?Gi:qi,{size:14,"aria-hidden":`true`})})]})]}),L(`p`,{className:`setup-hint`,children:n(Je?`setup.key.usersServer`:`setup.key.where`)}),N&&!Je&&!ne&&L(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.key.foundEnv`,{name:N.name,hint:N.key_hint??``})}),k.busy&&!k.waiting&&L(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.key.testing`)}),k.busy&&k.waiting&&L(`p`,{className:`setup-hint`,role:`status`,children:k.waiting}),k.error&&L(`p`,{className:`setup-error`,role:`alert`,children:k.error}),z(Bq,{children:[L(`button`,{type:`button`,className:`btn-secondary`,onClick:xn,disabled:k.busy,children:n(`setup.back`)}),z(`button`,{type:`submit`,form:`setup-key-form`,className:`btn-primary`,disabled:k.busy||St(a)||wr,children:[k.busy&&L(Za,{size:13,className:`spin`}),` `,n(`setup.key.connect`)]})]})]}),sr===`download`&&!Et&&z(P.Fragment,{children:[L(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.download.title`)}),L(`p`,{className:`setup-lede`,children:n(`setup.download.lede`)}),kr,Or??z(`p`,{className:`setup-hint`,role:`status`,children:[L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,n(`setup.download.starting`)]})]}),sr===`download`&&Et&&z(P.Fragment,{children:[L(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.download.title`)}),L(`p`,{className:`setup-lede`,children:n(`setup.download.lede`)}),kr,A&&L(`section`,{className:`setup-card`,"aria-label":n(`setup.contents.title`),children:L(lJ,{plan:A,run:Et,onRetry:Ht,retryDisabled:Te})}),(Et.models?.length??0)>0?L(`div`,{className:D?`is-stale`:void 0,children:L(xJ,{status:{...Et,overall:vq(Et,j??A)},names:Kn,freeGb:A?.disk?.free_gb??null,onCancel:()=>void Fn(),onRetry:(e,t)=>void In(e,t),onResume:e=>void In(e,null),onResumeAll:Ht,onSkip:e=>void Ln(e),onRestart:()=>void zn(),busy:Te||!!D,retryLater:Dt,labelledBy:`setup-title`})}):Dt?z(P.Fragment,{children:[L(SJ,{run:Et,plan:A,idle:n(`setup.download.working`)}),L(Bq,{children:L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void Fn(),disabled:Te,children:n(`setup.progress.cancel`)})})]}):null,Ar.length>0&&z(`section`,{className:`setup-card`,"aria-label":n(`setup.optional.title`),children:[L(`h3`,{className:`mc-job-title`,children:n(`setup.optional.title`)}),L(`p`,{className:`setup-hint`,children:n(`setup.optional.lede`)}),L(`ul`,{className:`setup-rows`,children:Ar.map(e=>{let t=Ue.includes(e.id);return z(`li`,{className:`setup-result is-waiting`,children:[L(`span`,{className:`setup-result-label`,children:n(`setup.purpose.${e.roles[0]}`)}),z(`span`,{className:`setup-result-value`,children:[L(`bdi`,{dir:`ltr`,children:e.size_gb==null?n(`setup.contents.sizeOnDownload`):Sk(e.size_gb)}),L(`button`,{type:`button`,className:`btn-secondary`,"aria-pressed":t,onClick:()=>We(n=>t?n.filter(t=>t!==e.id):[...n,e.id]),children:n(t?`setup.optional.added`:`setup.optional.add`)})]})]},e.id)})})]}),D&&z(P.Fragment,{children:[L(`p`,{className:`setup-error`,role:`alert`,children:n(`setup.lostContact`,{error:D})}),L(Bq,{children:L(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void zt(),children:n(`setup.reconnect`)})})]}),qn&&Xn&&!Zn&&Et.state===`failed`&&!Et.model_failed&&(Et.problem?L(AY,{problem:Et.problem,onRetry:Ht,onUseGaia:()=>void Bt(!0,$e.current.options)}):z(`div`,{className:`setup-error`,role:`alert`,children:[L(`p`,{children:n(`setup.download.stoppedBeforeCheck`)}),Et.error&&z(`details`,{className:`dl-details`,children:[L(`summary`,{children:n(`setup.progress.details`)}),L(`pre`,{dir:`ltr`,children:Et.error})]})]})),qn&&Xn&&!Zn&&z(P.Fragment,{children:[L(`p`,{className:`setup-hint`,children:n(`setup.download.finishNote`)}),L(Bq,{children:L(`button`,{type:`button`,className:`btn-primary`,onClick:Ht,disabled:Te,children:n(`setup.finish`)})})]}),qn&&!Xn&&!Zn&&!(Et.models??[]).some(e=>e.state===`failed`||e.state===`cancelled`)&&z(P.Fragment,{children:[L(MY,{run:Et}),Et.problem?L(AY,{problem:Et.problem,onRetry:Ht,onUseGaia:()=>void Bt(!0,$e.current.options)}):L(Bq,{children:L(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Bt(!!Et.gaia_lemonade,$e.current.options),children:n(`setup.tryAgain`)})})]}),(De||ee)&&L(jY,{text:De??ee})]}),sr===`test`&&Et&&z(P.Fragment,{children:[L(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.test.title`)}),L(`p`,{className:`setup-lede`,children:n(`setup.test.lede`)}),L(yY,{run:Et,expected:Tr,names:Kn,catalog:Qn,onRetry:Ht,onChooseAnother:wt?void 0:Sn,onCancel:()=>void Fn(),onDownloadAgain:A?.lemonade.mode===`external`?void 0:e=>void In(e,`verify`),busy:Te}),qn&&Et.error&&!(Et.tests??[]).some(e=>e.error===Et.error)&&z(`details`,{className:`dl-details`,children:[L(`summary`,{children:n(`setup.progress.details`)}),L(`pre`,{dir:`ltr`,children:Et.error})]}),(De||ee)&&L(jY,{text:De??ee})]}),sr===`ready`&&z(P.Fragment,{children:[L(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.ready.heading`)}),z(`div`,{className:`setup-done`,role:`status`,children:[L(`div`,{className:`setup-done-head`,children:Wn&&L(`p`,{children:n(wt?`setup.ready.answersCloud`:`setup.ready.answersLocal`,{model:wt?Uc(Wn):Kn[Wn]??M?.catalog?.find(e=>e.id===Wn)?.name??Uc(Wn)})})}),L(Bq,{children:L(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Gn(),autoFocus:!0,children:n(`setup.ready.start`)})}),!wt&&M&&L(Qq,{plan:M,chatModel:Wn,gpu:_e}),ee&&L(jY,{text:ee}),(Et?.tests??[]).filter(e=>e.state===`failed`).map(e=>L(`p`,{className:`setup-failed-extra`,role:`alert`,children:n(`setup.ready.extraFailed`,{job:n(`setup.test.job.${e.job}`)})},`${e.job}:${e.subject??``}`)),Ge.length>0&&!xe&&L(`p`,{className:`setup-failed-extra`,role:`alert`,children:n(`setup.ready.extraNotFetched`,{names:Ge.map(e=>Kn[e]??e).join(`, `)})}),Yn.length>0&&z(P.Fragment,{children:[L(`p`,{className:`setup-hint`,children:n(`setup.ready.tasks`)}),L(rJ,{cards:Yn,onPick:e=>void Gn(e)})]})]})]}),T?.state===`failed`&&L(dY,{})]},sr),t&&!Dt&&sr!==`plan`&&sr!==`ready`&&L(`div`,{className:`setup-row`,children:L(`button`,{type:`button`,className:`link-btn setup-close`,onClick:t,children:n(`setup.backToGaia`)})}),wr&&(Cr||sr===`plan`)&&L(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.nav.runGoing`)}),L(DJ,{run:T,before:{check:mr},failed:Jn})]})}),L(`div`,{className:`setup-footer`,ref:m})]})}),xe?.kind===`no_fit`&&L(Vq,{title:hq(xe.models)?n(`setup.confirm.tightOne`,{name:xe.models[0].name}):xe.models.length===1?n(`setup.confirm.noFitOne`,{name:xe.models[0].name}):n(`setup.confirm.noFitMany`),confirmLabel:hq(xe.models)?n(`setup.confirm.useAnyway`):n(`setup.confirm.downloadAnyway`),cancelLabel:n(`setup.confirm.pickSmaller`),onConfirm:()=>{Se(null),we(!0),yn(Wt,!0)},onCancel:()=>Se(null),children:xe.models.map(e=>z(`p`,{children:[L(`bdi`,{children:e.name}),`: `,Tq(e,n)]},e.id))}),xe?.kind===`low_disk`&&er&&L(Vq,{title:n(`setup.confirm.lowDiskTitle`),confirmLabel:n(`setup.confirm.downloadAnyway`),cancelLabel:n(`setup.confirm.changeModels`),onConfirm:()=>{Se(null),yn(!0)},onCancel:()=>{Se(null),Sn()},children:L(`p`,{children:n(`setup.summary.short`,{need:Sk(er.needGb),free:Sk(er.freeGb),drive:n(`setup.summary.theDrive`),freeUp:Sk(er.freeUpGb)})})}),xe?.kind===`server`&&L(Vq,{title:xe.detail.code===`low_disk`?n(`setup.confirm.lowDiskTitle`):n(`setup.confirm.noFitServerTitle`),confirmLabel:xe.detail.code===`low_disk`?n(`setup.confirm.downloadAnyway`):n(`setup.confirm.useAnyway`),cancelLabel:n(`setup.confirm.changeModels`),onConfirm:()=>{let e=xe;if(Se(null),e.then===`chat`)we(!0),yn(Wt,!0);else if(e.then===`retry`)Ke(e.id,{keepTrying:ye,acknowledgeLowDisk:!0}).then(E).catch(e=>ke(RY(e)));else{let{gaiaLemonade:e,options:t}=$e.current;Bt(e,{...t,acknowledgeLowDisk:!0})}},onCancel:()=>{let e=xe;Se(null),e.then!==`retry`&&!Ot&&Sn()},children:L(`p`,{children:xe.detail.message})})]})}function BY({title:e,titleId:t,count:n,hint:r,defaultOpen:i=!1,forceOpen:a=!1,targetId:o,children:s}){let[c,l]=(0,B.useState)(i);return z(`details`,{className:`settings-disclosure`,"data-settings-target":o,open:c||a,onToggle:e=>{a||l(e.currentTarget.open)},children:[z(`summary`,{onClick:e=>{a&&e.preventDefault()},children:[L($r,{size:15,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),z(`span`,{className:`settings-disclosure-text`,children:[L(`span`,{className:`settings-disclosure-title`,id:t,tabIndex:t?-1:void 0,children:e}),r&&L(`span`,{className:`settings-disclosure-hint`,children:r})]}),n!=null&&L(`bdi`,{dir:`ltr`,className:`settings-disclosure-count`,children:n})]}),L(`div`,{className:`settings-disclosure-body`,children:s})]})}var VY=We(pu()?`settings.desktop.menuBar`:`settings.desktop.tray`),HY=[{key:`minimizeToTray`,label:`settings.desktop.keepRunning`,hint:`settings.desktop.keepRunningHint`},{key:`startOnLogin`,label:`settings.desktop.startOnLogin`,hint:`settings.desktop.startOnLoginHint`},{key:`startMinimized`,label:`settings.desktop.startMinimized`,hint:`settings.desktop.startMinimizedHint`}],UY=new Set([`startMinimized`]),WY={minimizeToTray:`settings.desktop.keepRunningNoTray`};function GY(e){return e?.reason===`no-host`?`settings.desktop.noTray`:e?.reason===`check-failed`?`settings.desktop.noTrayCheckFailed`:null}function KY(){let e=R(),t=window.gaiaAPI?.tray,[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(null);(0,B.useEffect)(()=>{t&&t.getConfig().then(e=>{r(e.tray),a(e.host)}).catch(t=>s(e(`settings.desktop.readFailed`,{reason:t instanceof Error?t.message:String(t)})))},[t,e]);let u=(0,B.useCallback)(async e=>{if(t&&n&&c===null){l(e),s(null);try{let i=await t.setConfig({tray:{[e]:!n[e]}});r(i.tray),a(i.host)}catch(e){s(e instanceof Error?e.message:String(e))}finally{l(null)}}},[t,n,c]);if(!t)return null;let d=GY(i);return L(BY,{title:e(`settings.desktop.title`),children:z(`div`,{className:`settings-field`,role:`group`,"aria-labelledby":`desktop-app-label`,children:[L(`span`,{className:`settings-label`,id:`desktop-app-label`,children:e(`settings.desktop.title`)}),HY.map(({key:t,label:r,hint:i})=>{let a=UY.has(t)?d:null,o=d&&WY[t]||i;return z(`div`,{children:[z(`label`,{className:`setting-row`,children:[L(`span`,{children:e(r,{tray:VY})}),z(`span`,{className:`toggle-switch`,children:[L(`input`,{id:`desktop-${t}`,type:`checkbox`,role:`switch`,checked:!a&&!!n?.[t],"aria-describedby":`desktop-${t}-hint`,onChange:()=>void u(t),disabled:!!a||!n||c!==null&&c!==t,"aria-busy":c===t,"aria-label":e(r,{tray:VY})}),L(`span`,{className:`toggle-track`})]})]}),L(`p`,{className:`settings-hint`,id:`desktop-${t}-hint`,children:a?e(a):e(o,{tray:VY})})]},t)}),o&&L(`p`,{className:`settings-error`,role:`alert`,children:o})]})})}function qY(){return window.gaiaUpdater}function JY({onClose:e,manualInstall:t=!1}){let n=R(),[r,i]=(0,B.useState)({kind:`loading`}),a=(0,B.useRef)(null);(0,B.useEffect)(()=>{let e=qY();e?e.listReleases().then(e=>{i(Array.isArray(e)?{kind:`list`,releases:e}:{kind:`error`,message:e.error})}).catch(()=>{i({kind:`error`,message:`Couldn't reach GitHub to list releases — check your connection; you can still download installers from the Releases page.`})}):i({kind:`error`,message:`Couldn't reach GitHub to list releases — check your connection; you can still download installers from the Releases page.`})},[]),ut(!0,e),un(a,!0),(0,B.useEffect)(()=>{let e=a.current;e&&e.querySelector(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)?.focus()},[]),(0,B.useEffect)(()=>{let e=a.current;if(!e)return;function t(t){if(t.key!==`Tab`||!e)return;let n=e.querySelectorAll(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);if(n.length===0)return;let r=n[0],i=n[n.length-1];t.shiftKey?document.activeElement===r&&(t.preventDefault(),i?.focus()):document.activeElement===i&&(t.preventDefault(),r?.focus())}return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[]);function o(e,t){e.isCurrent||i({kind:`confirm`,release:e,releases:t})}async function s(t){i({kind:`installing`});let r=qY();if(!r)i({kind:`error`,message:n(`update.picker.noBridge`)});else try{await r.installVersion(t.tag),e()}catch(e){i({kind:`error`,message:n(`update.picker.failed`,{reason:lY(e)})})}}function c(e){if(!e)return``;try{return new Date(e).toLocaleDateString(On(n),{year:`numeric`,month:`short`,day:`numeric`})}catch{return e}}return L(`div`,{className:`version-picker-overlay`,onClick:t=>{t.target===t.currentTarget&&e()},children:z(`div`,{className:`version-picker-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":n(`update.picker.title`),ref:a,children:[z(`div`,{className:`version-picker-header`,children:[L(`h3`,{children:n(`update.picker.title`)}),L(`button`,{className:`version-picker-close`,onClick:e,"aria-label":n(`update.picker.close`),type:`button`,children:`×`})]}),z(`div`,{className:`version-picker-body`,children:[r.kind===`loading`&&z(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[L(`span`,{className:`version-picker-spinner`}),n(`update.picker.loading`)]}),r.kind===`error`&&z(`div`,{className:`version-picker-error`,children:[L(`p`,{children:r.message}),L(`p`,{children:L(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:n(`update.picker.browse`)})})]}),r.kind===`list`&&L(`ul`,{className:`version-picker-list`,role:`listbox`,"aria-label":n(`update.picker.listAria`),children:r.releases.map(e=>L(`li`,{children:z(`button`,{type:`button`,className:`version-picker-row`,"data-version":e.version,"aria-label":e.isCurrent?n(`update.picker.rowInstalled`,{version:e.version}):e.isPinned?n(`update.picker.rowPinned`,{version:e.version}):e.version,"aria-disabled":e.isCurrent?`true`:`false`,onClick:()=>o(e,r.releases),disabled:e.isCurrent,children:[L(`span`,{className:`vp-version`,children:e.version}),L(`span`,{className:`vp-date`,children:c(e.date)}),e.isCurrent&&L(`span`,{className:`vp-badge vp-badge-current`,children:n(`update.picker.installed`)}),e.isPinned&&!e.isCurrent&&L(`span`,{className:`vp-badge vp-badge-pinned`,children:n(`update.picker.pinned`)}),!e.isCurrent&&L(`span`,{className:`vp-arrow`,"aria-hidden":`true`,children:`›`})]})},e.tag))}),r.kind===`list`&&z(`p`,{className:`version-picker-more`,children:[n(`update.picker.recent`,{n:r.releases.length}),` `,L(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:n(`update.picker.browseAll`)})]}),r.kind===`confirm`&&z(`div`,{className:`version-picker-confirm`,children:[t?L(`p`,{children:n(`update.picker.manual`,{version:r.release.version})}):z(P.Fragment,{children:[L(`p`,{children:n(`update.picker.confirm`,{version:r.release.version})}),L(`p`,{className:`vp-confirm-note`,children:n(`update.picker.confirmNote`,{version:r.release.version})})]}),z(`div`,{className:`vp-confirm-actions`,children:[L(`button`,{type:`button`,className:`vp-btn-cancel`,onClick:()=>i({kind:`list`,releases:r.releases}),children:n(`update.picker.back`)}),t?L(`a`,{className:`vp-btn-confirm`,href:r.release.notesUrl??`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noopener noreferrer`,children:n(`update.picker.openRelease`)}):L(`button`,{type:`button`,className:`vp-btn-confirm`,onClick:()=>s(r.release),children:n(`update.picker.install`)})]})]}),r.kind===`installing`&&z(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[L(`span`,{className:`version-picker-spinner`}),n(`update.picker.starting`)]})]})]})})}var YY=`https://github.com/amd/gaia/releases`;function XY(e){return/^\d+\.\d+\.\d+-/.test(e??``)}function ZY(e,t){let n=e.version??``;if(e.readFailed)return t(`update.status.readFailed`);switch(e.status){case`checking`:return t(`update.status.checking`);case`available`:return t(`update.status.available`,{version:n});case`downloading`:return e.preparing?t(`update.status.preparing`,{version:n}):t(`update.status.downloading`,{version:n,pct:e.progress});case`downloaded`:return t(`update.status.downloaded`,{version:n});case`error`:return t(`update.status.error`,{reason:e.error??t(`update.status.unknownError`)});case`no-channel`:return e.error??t(`update.status.noChannel`);case`disabled`:return t(`update.status.disabled`);default:return t(`update.status.upToDate`)}}function QY(){let e=oY(),t=R(),n=iY(),[r,i]=(0,B.useState)(!1),[a,o]=(0,B.useState)(null),[s,c]=(0,B.useState)(!1);if(!n)return null;async function l(e,r){if(n){i(!0),o(null);try{await r(n)}catch(n){F.system.error(`${e} failed`,n),o(t(`update.settings.failed`,{action:We(e),reason:lY(n)}))}finally{i(!1)}}}let u=e.status===`disabled`,d=r||e.status===`checking`||e.status===`downloading`,f=e.readFailed?ZY(e,t):`${t(`update.settings.running`,{version:e.currentVersion??t(`update.settings.unknownVersion`)})} ${ZY(e,t)}`,p=[`available`,`downloaded`,`error`].includes(e.status)||!!e.pinnedVersion||!!e.installFailed||!!e.configError||!!e.readFailed||!!a;return L(BY,{title:t(`update.settings.title`),titleId:`updates-label`,hint:f,forceOpen:p,children:z(`div`,{className:`settings-field`,role:`group`,"aria-labelledby":`updates-label`,children:[L(`p`,{className:`visually-hidden`,role:`status`,children:f}),!e.manualInstall&&z(P.Fragment,{children:[z(`label`,{className:`setting-row`,children:[L(`span`,{children:t(`update.settings.auto`)}),z(`span`,{className:`toggle-switch`,children:[L(`input`,{type:`checkbox`,role:`switch`,checked:e.autoUpdate,"aria-describedby":`updates-auto-hint`,"aria-label":t(`update.settings.auto`),"aria-busy":r,disabled:u,onChange:()=>{r||l(`update.action.saveAuto`,t=>t.setAutoUpdate(!e.autoUpdate))}}),L(`span`,{className:`toggle-track`})]})]}),L(`p`,{className:`settings-hint`,id:`updates-auto-hint`,children:t(`update.settings.autoHint`)})]}),z(`label`,{className:`setting-row`,children:[L(`span`,{children:t(`update.settings.rc`)}),z(`span`,{className:`toggle-switch`,children:[L(`input`,{type:`checkbox`,role:`switch`,checked:!!e.includePrereleases,"aria-describedby":`updates-rc-hint`,"aria-label":t(`update.settings.rc`),"aria-busy":r,disabled:u,onChange:()=>{r||l(`update.action.saveRc`,t=>t.setIncludePrereleases(!e.includePrereleases))}}),L(`span`,{className:`toggle-track`})]})]}),z(`p`,{className:`settings-hint`,id:`updates-rc-hint`,children:[t(`update.settings.rcHint`),XY(e.currentVersion)&&` ${t(`update.settings.rcHintRunning`)}`]}),e.pinnedVersion&&z(`p`,{className:`settings-hint`,children:[t(`update.settings.pinned`,{version:e.pinnedVersion}),` `,L(`button`,{type:`button`,className:`btn-secondary`,disabled:r,onClick:()=>void l(`update.action.resume`,e=>e.resumeUpdates()),children:t(`update.settings.unpin`)})]}),z(`div`,{className:`setting-actions`,children:[e.status===`available`&&e.manualInstall&&L(`a`,{className:`btn-primary update-download-link`,href:e.downloadUrl??YY,target:`_blank`,rel:`noopener noreferrer`,"aria-describedby":`updates-manual-hint`,children:t(`update.settings.downloadVersion`,{version:e.version??``})}),e.status===`available`&&!e.manualInstall&&!e.pinnedVersion&&L(`button`,{type:`button`,className:`btn-primary`,disabled:r,onClick:()=>void l(`update.action.download`,e=>e.downloadUpdate()),children:t(`update.settings.updateTo`,{version:e.version??``})}),e.status===`downloaded`&&L(`button`,{type:`button`,className:`btn-primary`,disabled:r,onClick:()=>void l(`update.action.restart`,e=>e.restart()),children:t(`update.settings.restart`)}),e.readFailed?L(`button`,{type:`button`,className:`btn-secondary`,disabled:r,onClick:async()=>{i(!0);try{await e.reload()}finally{i(!1)}},children:t(`update.settings.retryRead`)}):L(`button`,{type:`button`,className:`btn-secondary`,disabled:d||u,onClick:()=>void l(`update.action.check`,e=>e.check()),children:t(`update.settings.check`)}),L(`button`,{type:`button`,className:`btn-secondary`,disabled:d||u,onClick:()=>c(!0),children:t(`update.settings.pick`)}),e.previousVersion&&L(`button`,{type:`button`,className:`btn-secondary`,"aria-describedby":`updates-back-hint`,disabled:d||u,onClick:()=>void l(`update.action.goBack`,e=>e.revertUpdate()),children:t(`update.settings.goBack`,{version:e.previousVersion})})]}),e.status===`available`&&e.manualInstall&&L(`p`,{className:`settings-hint`,id:`updates-manual-hint`,children:t(`update.settings.manualHint`)}),e.previousVersion&&L(`p`,{className:`settings-hint`,id:`updates-back-hint`,children:t(`update.settings.goBackHint`)}),e.installFailed&&L(`p`,{className:`settings-error`,role:`alert`,children:t(`update.settings.installFailed`,{...e.installFailed,url:YY})}),e.lastCheckError&&L(`p`,{className:`settings-hint`,children:t(`update.settings.lastCheckError`,{reason:e.lastCheckError})}),e.configError&&L(`p`,{className:`settings-error`,role:`alert`,children:e.configError}),a&&L(`p`,{className:`settings-error`,role:`alert`,children:a}),s&&L(JY,{onClose:()=>c(!1),manualInstall:e.manualInstall})]})})}var $Y=[{value:`light`,label:`settings.theme.light`},{value:`dark`,label:`settings.theme.dark`},{value:`system`,label:`settings.theme.system`}],eX={default:`palette.default`,stone:`palette.stone`,marble:`palette.marble`,glacier:`palette.glacier`,forest:`palette.forest`,sage:`palette.sage`,basalt:`palette.basalt`,gold:`palette.gold`,dusk:`palette.dusk`,custom:`settings.colors.custom`};function tX(){let e=R(),t=N(e=>e.locale),n=N(e=>e.setLocale),r=N(e=>e.themePreference),i=N(e=>e.setThemePreference),a=N(e=>e.palette),o=N(e=>e.setPalette),s=N(e=>e.customColors),c=N(e=>e.setCustomColors),l=pW(e=>e.visible),u=pW(e=>e.setVisible),d=e=>t=>c({...s,[e]:t.target.value.toUpperCase()});return z(`div`,{className:`settings-pane`,children:[L(`h2`,{className:`settings-pane-title`,children:e(`settings.section.general`)}),z(`div`,{className:`settings-field`,children:[L(`label`,{className:`settings-label`,htmlFor:`ui-language`,children:e(`settings.language`)}),L(`select`,{id:`ui-language`,className:`settings-input`,value:t,onChange:e=>n(e.target.value),children:_e.map(({meta:e})=>L(`option`,{value:e.code,lang:e.code,dir:e.dir,children:ir(e)},e.code))}),L(`span`,{className:`settings-hint`,children:e(`settings.languageHint`)})]}),z(`div`,{className:`settings-field`,children:[L(`span`,{className:`settings-label`,id:`appearance-label`,children:e(`settings.appearance`)}),L(jB,{className:`segmented`,"aria-labelledby":`appearance-label`,children:$Y.map(t=>L(`button`,{type:`button`,role:`radio`,"aria-checked":r===t.value,className:r===t.value?`is-active`:``,onClick:()=>i(t.value),children:e(t.label)},t.value))})]}),z(`div`,{className:`settings-field`,children:[z(`label`,{className:`setting-row`,children:[L(`span`,{children:e(`resources.settings`)}),z(`span`,{className:`toggle-switch`,children:[L(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked),"aria-label":e(`resources.settings`),"aria-describedby":`resources-hint`}),L(`span`,{className:`toggle-track`})]})]}),L(`span`,{className:`settings-hint`,id:`resources-hint`,children:e(`resources.settingsHint`)})]}),z(BY,{title:e(`settings.colors`),titleId:`palette-label`,defaultOpen:a===`custom`,children:[z(jB,{className:`palette-grid`,"aria-labelledby":`palette-label`,children:[ae.map(t=>z(`button`,{type:`button`,role:`radio`,"aria-checked":a===t.id,className:`palette-tile${a===t.id?` is-active`:``}`,onClick:()=>o(t.id),children:[L(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:t.swatch.map(e=>L(`i`,{style:{background:e}},e))}),e(eX[t.id])]},t.id)),z(`button`,{type:`button`,role:`radio`,"aria-checked":a===`custom`,className:`palette-tile${a===`custom`?` is-active`:``}`,onClick:()=>o(`custom`),children:[z(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:[L(`i`,{style:{background:s.base}}),L(`i`,{style:{background:s.accent}})]}),e(`settings.colors.custom`)]})]}),a===`custom`&&z(`div`,{className:`palette-custom`,children:[z(`label`,{className:`palette-color`,htmlFor:`custom-accent`,children:[L(`input`,{id:`custom-accent`,type:`color`,value:s.accent,onChange:d(`accent`)}),z(`span`,{children:[e(`settings.colors.accent`),L(`small`,{children:e(`settings.colors.accentHint`)})]})]}),z(`label`,{className:`palette-color`,htmlFor:`custom-base`,children:[L(`input`,{id:`custom-base`,type:`color`,value:s.base,onChange:d(`base`)}),z(`span`,{children:[e(`settings.colors.base`),L(`small`,{children:e(`settings.colors.baseHint`)})]})]}),L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>c(wn),children:e(`settings.colors.reset`)}),L(`p`,{className:`settings-hint`,children:e(`settings.colors.hint`)})]})]}),L(KY,{}),L(QY,{}),L(BY,{title:e(`settings.shortcuts`),children:L(`dl`,{className:`shortcut-list`,children:FK().map(({label:t,keys:n})=>z(`div`,{className:`shortcut-row`,children:[L(`dt`,{children:L(`kbd`,{children:_u(n)})}),L(`dd`,{children:e(t)})]},t))})})]})}function nX(e){return/not reachable|not answering|model server at|ConnectionPool|NewConnectionError|Connection refused|Max retries/i.test(e)}function rX(e){return/gaia init/i.test(e??``)}var iX=`GAIA doesn't run this model server, so it can't start it. Start it the way you usually do.`;function aX(e,t){return t?t===iX?e(`server.otherServerStart`):t:null}function oX(e){return!!e&&!e.lemonade_running&&(rX(e.start_command)||rX(e.start_instruction))}function sX({className:e=`btn-secondary`}){let t=R();return L(`button`,{type:`button`,className:e,onClick:()=>window.dispatchEvent(new CustomEvent(`gaia:set-up-local`)),children:t(`settings.errors.setUpLocal`)})}function cX({message:e,onRetry:t}){let n=R(),r=N(e=>oX(e.systemStatus));return nX(e)?z(`div`,{className:`settings-notice`,role:`alert`,children:[L(`strong`,{children:n(r?`settings.errors.notInstalledTitle`:`settings.errors.serverDownTitle`)}),L(`p`,{children:n(r?`settings.errors.notInstalled`:`settings.errors.serverDown`)}),r&&L(sX,{className:`btn-primary`}),t&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:t,children:n(`settings.key.checkAgain`)}),z(`details`,{className:`settings-more`,children:[z(`summary`,{children:[L($r,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,n(`settings.errors.details`)]}),L(`bdi`,{dir:`ltr`,className:`settings-notice-raw`,children:e})]})]}):L(`p`,{className:`settings-error`,role:`alert`,children:e})}function lX({onAdded:e}){let t=R(),[n,r]=(0,B.useState)(``),[i,a]=(0,B.useState)(``),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(null),[u,d]=(0,B.useState)(null),f=(0,B.useRef)(``),p=(0,B.useCallback)(async e=>{let t=n.trim();f.current=t,l(`check`),d(null);try{let n=await Cn(t,e);if(f.current!==t)return;s(n),a(n.file??e)}catch(e){if(f.current!==t)return;s(null),d(e instanceof Error?e.message:String(e))}finally{l(null)}},[n]),m=(0,B.useCallback)(async()=>{l(`add`),d(null);try{let{report:o}=await vt(n.trim(),i);r(``),a(``),s(null),e(o.display_name??o.model_id??t(`settings.custom.theModel`))}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(null)}},[e,i,n,t]);return z(`form`,{className:`settings-field custom-model-add`,onSubmit:e=>{e.preventDefault(),p(``)},children:[L(`label`,{className:`visually-hidden`,htmlFor:`custom-model-url`,children:t(`settings.custom.title`)}),L(`span`,{className:`settings-hint`,children:t(`settings.custom.hint`)}),z(`div`,{className:`settings-row`,children:[L(`input`,{id:`custom-model-url`,className:`settings-input`,type:`url`,inputMode:`url`,dir:`ltr`,spellCheck:!1,autoComplete:`off`,value:n,readOnly:c!==null,onChange:e=>{r(e.target.value),s(null),a(``),f.current=``},placeholder:`https://huggingface.co/unsloth/Qwen3-4B-Instruct-2507-GGUF`}),z(`button`,{type:`submit`,className:`btn-secondary`,disabled:c!==null||!n.trim(),children:[c===`check`?L(Za,{size:13,className:`spin`}):null,` `,t(`settings.custom.check`)]})]}),o&&(()=>{let e=L(`ul`,{className:`custom-model-checks`,"aria-label":t(`settings.custom.checks`),children:o.checks.map(e=>z(`li`,{className:e.ok?`is-ok`:`is-failed`,children:[e.ok?L(Yr,{size:13,"aria-label":t(`settings.custom.passed`)}):L(nc,{size:13,"aria-label":t(`settings.custom.failed`)}),z(`bdi`,{children:[L(`strong`,{children:e.label}),` — `,e.detail]})]},e.id))});return o.ok?z(`details`,{className:`custom-model-checks-summary`,children:[z(`summary`,{children:[L(Yr,{size:13,"aria-hidden":`true`}),` `,t(`settings.custom.allPassed`,{n:o.checks.length})]}),e]}):e})(),o&&o.warnings.length>0&&L(`ul`,{className:`custom-model-checks`,"aria-label":t(`settings.custom.warnings`),children:o.warnings.map(e=>z(`li`,{className:`is-warning`,children:[L(Ws,{size:13,"aria-label":t(`settings.custom.warning`)}),` `,L(`bdi`,{children:e})]},e))}),o&&o.variants.length>1&&z(`div`,{className:`settings-row`,children:[L(`label`,{className:`settings-hint`,htmlFor:`custom-model-quant`,children:t(`settings.custom.quantization`)}),L(`select`,{id:`custom-model-quant`,className:`settings-input`,value:i,onChange:e=>void p(e.target.value),disabled:c!==null,children:o.variants.map(e=>z(`option`,{value:e.file,children:[e.quant,` · `,e.size_gb,` GB`,e.fits?``:` · ${t.bare(`settings.custom.tooLarge`)}`]},e.file))})]}),o?.ok&&z(`div`,{className:`settings-row`,children:[z(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void m(),disabled:c!==null,children:[c===`add`?L(Za,{size:13,className:`spin`}):null,` `,t(`settings.custom.add`,{name:o.display_name??``})]}),L(`span`,{className:`settings-hint`,children:t(`settings.model.sizeDownload`,{size:`${o.size_gb} GB`})})]}),u&&L(cX,{message:u})]})}function uX(e){return e instanceof Error?e.message:String(e)}function dX(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function fX({downloadsSlot:e}){let t=R(),[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(null),[u,d]=(0,B.useState)(!1),[f,p]=(0,B.useState)(null),[m,h]=(0,B.useState)(!1),[g,_]=(0,B.useState)(null),[v,y]=(0,B.useState)(null),b=bl(e=>e.status),x=bl(e=>e.started),S=(0,B.useMemo)(()=>_l(b,x),[b,x]),C=bl(e=>e.error),w=bl(e=>e.refresh),T=bl(e=>e.enqueue),E=bl(e=>e.cancel),D=(0,B.useCallback)(async(e=!1)=>{a(null);try{let t=await En();r(t),s(n=>e||!n?oq(t):n)}catch(e){a(uX(e))}},[]);(0,B.useEffect)(()=>{D(!0),w(),(async()=>{try{_(await Xe()??null)}catch(e){y(uX(e))}})()},[D,w]);let O=(S?.models??[]).filter(e=>e.state===`ready`).map(e=>e.id).join(`,`),ee=(0,B.useRef)(O);(0,B.useEffect)(()=>{O!==ee.current&&(ee.current=O,D(!0))},[O,D]);let te=(0,B.useMemo)(()=>{let e={};for(let t of S?.models??[])e[t.id]=t;return e},[S]),ne=(0,B.useMemo)(()=>{let e={};for(let t of n?.catalog??[])e[t.id]=t.name;return e},[n]),re=(0,B.useMemo)(()=>n?oq(n):null,[n]),k=GK(n),ie=n&&o?dq(k,o).filter(e=>te[e.id]?.state!==`downloading`):[],ae=ie.reduce((e,t)=>e+(t.size_gb??0),0),A=!!n&&!!o&&!!re&&(!dX(o.ticked,re.ticked)||o.defaultChat!==re.defaultChat||ie.length>0),oe=(0,B.useCallback)(async(e,i)=>{if(!n||!o)return;if(p(null),!e){let e=mq(k,o).filter(e=>!e.downloaded||e.id===o.defaultChat);if(e.length>0&&e.every(e=>e.need_gb!=null)){l({kind:`no_fit`,models:e});return}}let a=pq(n,o);if(a&&!i)l({kind:`low_disk`,message:a.drop?t(`setup.summary.shortDrop`,{need:Sk(a.needGb),free:Sk(a.freeGb),drive:kq(n.disk?.path??null)??t(`setup.summary.theDrive`),freeUp:Sk(a.freeUpGb),name:a.drop.name,saves:Sk(a.drop.size_gb??0)}):t(`setup.summary.short`,{need:Sk(a.needGb),free:Sk(a.freeGb),drive:kq(n.disk?.path??null)??t(`setup.summary.theDrive`),freeUp:Sk(a.freeUpGb)})});else{d(!0);try{let i=n,a=!1;if(o.defaultChat&&o.defaultChat!==i.chat_model.id){a=!0;try{i=await me(o.defaultChat,e||m)}catch(e){let t=kt(e);if(t){l({kind:`server`,detail:t});return}throw e}}for(let e of gq(i,o))i=await Rn(e.id,e.skipped);let c=dq(GK(i),o).map(e=>e.id).filter(e=>te[e]?.state!==`downloading`);r(i),s({...o,defaultChat:i.chat_model.id});let u=null;if(a&&i.chat_model.downloaded)try{await zc.getState().select(i.chat_model.id)}catch(e){u=uX(e),zc.getState().refresh()}else zc.getState().refresh();c.length&&await T(c,{acknowledgeLowDisk:!0}),p(u===null?{ok:!0,text:t(`settings.models.applied`)}:{ok:!1,text:t(`settings.models.appliedNotSwitched`,{reason:u})})}catch(e){p({ok:!1,text:uX(e)})}finally{d(!1)}}},[n,o,k,m,te,T,t]),se=(0,B.useCallback)(async e=>{l(null),d(!0),p(null);try{let n=await Oe(e.id);bc(),r(n),s(oq(n)),p({ok:!0,text:t(`settings.models.removed`,{name:e.name,size:Sk(n.freed_gb)})})}catch(e){p({ok:!1,text:uX(e)})}finally{d(!1)}},[t]),ce=(0,B.useCallback)((e,t)=>{(async()=>{try{t===`verify`&&await Oe(e),await T([e])}catch(e){p({ok:!1,text:uX(e)})}})()},[T]),le=!!S&&(S.models?.length??0)>0&&(vJ(S)||S.models.some(e=>e.state!==`skipped`))&&S&&z(`section`,{className:`settings-field models-pane-section`,"aria-labelledby":`settings-downloads-title`,children:[L(`span`,{className:`settings-label`,id:`settings-downloads-title`,children:t(`settings.models.downloads`)}),L(xJ,{status:S,names:ne,freeGb:n?.disk?.free_gb??null,onCancel:()=>void E(),onRetry:ce,onResume:e=>void T([e]),onResumeAll:()=>void T((S.models??[]).filter(e=>e.state===`cancelled`).map(e=>e.id))}),C&&L(`p`,{className:`settings-error`,role:`alert`,children:C})]});return z(P.Fragment,{children:[L(BY,{title:t(`settings.models.manage`),hint:t(`settings.models.manageHint`),forceOpen:!!i||f?.ok===!1,children:z(`section`,{className:`settings-field models-pane-section`,"aria-labelledby":`settings-models-title`,children:[L(`span`,{className:`visually-hidden`,id:`settings-models-title`,children:t(`settings.models.title`)}),L(`p`,{className:`settings-hint`,children:t(`settings.models.lede`)}),i&&L(cX,{message:i}),n&&!n.lemonade.reachable&&L(`p`,{className:`settings-hint`,children:t(`settings.models.unavailable`)}),!n&&!i&&z(`p`,{className:`settings-hint`,children:[L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),` `,t(`setup.models.loading`)]}),n&&n.lemonade.reachable&&o&&z(P.Fragment,{children:[L(jq,{plan:n,selection:o,onToggle:(e,t)=>s(cq(o,k,e,t)),onDefaultChat:e=>s(lq(o,k,e)),labelledBy:`settings-models-title`,place:`settings`,disabled:u,progress:te,rowActions:e=>e.downloaded&&e.id!==o.defaultChat?L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>l({kind:`remove`,entry:e}),disabled:u||te[e.id]?.state===`downloading`,"aria-label":t(`settings.models.removeAria`,{name:e.name}),children:t(`settings.models.remove`)}):null}),L(Oq,{plan:n,selection:o}),L(`div`,{className:`models-apply`,children:z(`button`,{type:`button`,className:`btn-primary`,disabled:!A||u,onClick:()=>void oe(!1,!1),children:[u&&L(Za,{size:13,className:`spin`,"aria-hidden":`true`}),u?t(`settings.models.applying`):ie.length>0?t(`settings.models.applyDownload`,{size:Sk(Math.round(ae*10)/10)}):t(`settings.models.apply`)]})})]}),f?.ok&&L(`p`,{className:`settings-ok`,role:`status`,children:f.text}),f&&!f.ok&&L(cX,{message:f.text})]})}),(g?.applies||v&&!nX(v))&&L(BY,{title:t(`gpu.settingsTitle`),titleId:`settings-gpu-title`,defaultOpen:!!g?.pending||!!v,children:z(`section`,{className:`settings-field models-pane-section`,"aria-labelledby":`settings-gpu-title`,children:[v&&L(`p`,{className:`settings-error`,role:`alert`,children:v}),g?.applies&&L(Xq,{status:g,onStatus:_,mode:`settings`,names:ne,headingId:`settings-gpu-title`})]})}),e?(0,mM.createPortal)(le,e):e===void 0&&le,c?.kind===`remove`&&L(Vq,{title:t(`settings.models.removeTitle`,{name:c.entry.name}),confirmLabel:t(`settings.models.removeConfirm`),cancelLabel:t(`settings.models.keep`),danger:!0,onConfirm:()=>void se(c.entry),onCancel:()=>l(null),children:L(`p`,{children:KK(c.entry)?t(`settings.models.removeVision`,{size:Sk(c.entry.full_size_gb??0)}):t(`settings.models.removeBody`,{size:Sk(c.entry.full_size_gb??0)})})}),c?.kind===`no_fit`&&L(Vq,{title:hq(c.models)?t(`setup.confirm.tightOne`,{name:c.models[0].name}):c.models.length===1?t(`setup.confirm.noFitOne`,{name:c.models[0].name}):t(`setup.confirm.noFitMany`),confirmLabel:hq(c.models)?t(`setup.confirm.useAnyway`):t(`setup.confirm.downloadAnyway`),cancelLabel:t(`setup.confirm.pickSmaller`),onConfirm:()=>{l(null),h(!0),oe(!0,!1)},onCancel:()=>l(null),children:c.models.map(e=>z(`p`,{children:[L(`bdi`,{children:e.name}),`: `,Tq(e,t)]},e.id))}),c?.kind===`low_disk`&&L(Vq,{title:t(`setup.confirm.lowDiskTitle`),confirmLabel:t(`setup.confirm.downloadAnyway`),cancelLabel:t(`setup.confirm.changeModels`),onConfirm:()=>{l(null),oe(!0,!0)},onCancel:()=>l(null),children:L(`p`,{children:c.message})}),c?.kind===`server`&&L(Vq,{title:t(`setup.confirm.noFitServerTitle`),confirmLabel:t(`setup.confirm.useAnyway`),cancelLabel:t(`setup.confirm.changeModels`),onConfirm:()=>{l(null),h(!0),oe(!0,!1)},onCancel:()=>l(null),children:L(`p`,{children:c.detail.message})})]})}var pX=`auto`;function mX({model:e}){let t=R(),[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(null);(0,B.useEffect)(()=>{r(null),a(null),l(null),ge(e).then(r).catch(e=>a(e instanceof Error?e.message:String(e)))},[e]);let u=(0,B.useCallback)(async n=>{s(!0),a(null),l(null);try{let i=await h(e,n===pX?null:Number(n));r(i);let a={name:i.display_name,size:i.chosen?tl(i.chosen):We(`settings.ctx.automaticSize`)},o=i.reload?.reason;i.reload?.started?l(t(`settings.ctx.reloading`,a)):l(o===`already_loaded`?t(`settings.ctx.alreadyLoaded`,a):o===`warm_up`?t(`settings.ctx.warmUp`,a):o===`busy`?t(`settings.ctx.busy`,a):o===`not_gaias_server`?t(`settings.ctx.ownServer`,a):t(o===`restarting`?`settings.ctx.restarting`:`settings.ctx.nextLoad`))}catch(e){a(e instanceof Error?e.message:String(e))}finally{s(!1)}},[e,t]);if(i&&!n)return nX(i)?L(`p`,{className:`settings-hint`,children:t(`settings.ctx.serverDown`)}):L(`p`,{className:`settings-error`,role:`alert`,children:i});if(!n)return z(`p`,{className:`settings-hint`,children:[L(Za,{size:13,className:`spin`}),` `,t(`settings.ctx.checking`)]});let d=n.chosen==null?pX:String(n.chosen),f=n.chosen!=null&&n.loaded_ctx!=null&&n.loaded_ctx!==n.chosen;return z(P.Fragment,{children:[z(`div`,{className:`model-in-use-field`,children:[L(`label`,{className:`settings-label`,htmlFor:`ctx-size`,children:t(`settings.ctx.label`)}),z(`select`,{id:`ctx-size`,className:`settings-input`,value:d,onChange:e=>void u(e.target.value),disabled:o||n.options.length===0,children:[L(`option`,{value:pX,children:n.automatic?t.bare(`settings.ctx.automaticAt`,{size:tl(n.automatic)}):t.bare(`settings.ctx.automatic`)}),n.options.map(e=>L(`option`,{value:String(e),children:t.bare(`settings.ctx.tokens`,{size:tl(e)})},e))]})]}),n.note&&L(`span`,{className:`settings-hint`,children:L(`bdi`,{children:n.note})}),!n.note&&!!n.max_fit&&z(`details`,{className:`settings-more`,children:[z(`summary`,{children:[L($r,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,t(`settings.ctx.about`)]}),L(`span`,{className:`settings-hint`,children:t(`settings.ctx.explain`,{size:tl(n.max_fit),name:n.display_name,memory:n.memory_source})})]}),f&&L(`span`,{className:`settings-hint`,children:t(`settings.ctx.loadedAt`,{size:tl(n.loaded_ctx)})}),o&&z(`span`,{className:`settings-hint`,children:[L(Za,{size:13,className:`spin`}),` `,t(`settings.ctx.applying`)]}),c&&L(`p`,{className:`settings-ok`,role:`status`,children:c}),i&&L(`p`,{className:`settings-error`,role:`alert`,children:i})]})}function hX({row:e,providerName:t,choices:n,labels:r,disabled:i,onSwitch:a}){let o=R(),s=zc(e=>e.active),c=zc(e=>e.error),l=s?.model??null,u=!!s?.remote,d=n.some(e=>Hc(l,e.id)),f=s?.downloaded??e?.downloaded,p=u?null:e?.state===`loaded`?o(`settings.model.loaded`):f===!0?o(`settings.model.downloaded`):f===!1?o(`settings.model.notDownloaded`):null,m=e?.placement?.device;return z(`section`,{className:`settings-card model-in-use`,"aria-label":o(`settings.model.inUseTitle`),children:[L(`span`,{className:`model-in-use-label`,children:o(`settings.model.inUseTitle`)}),l?L(`bdi`,{className:`model-in-use-name`,title:l,children:e?.display_name||s?.display_name||Uc(l)}):s||c?L(`span`,{className:`settings-hint`,children:o(`settings.model.noneInUse`)}):L(`span`,{className:`settings-hint`,children:o(`settings.loading`)}),s?.config_error&&L(`p`,{className:`settings-error`,role:`alert`,children:L(`bdi`,{children:s.config_error})}),l&&!u&&e?.available===!1&&L(`p`,{className:`settings-error`,role:`alert`,children:o(`settings.model.inUseCantRun`)}),l&&z(`span`,{className:`model-chips`,children:[u&&L(`span`,{className:`model-badge is-device`,children:o(`settings.model.cloud`)}),u&&t&&L(`bdi`,{className:`model-badge is-ready`,children:t}),m&&L(`span`,{className:`model-badge is-device`,children:m.toUpperCase()}),p&&L(`span`,{className:`model-badge ${e?.state===`loaded`?`is-loaded`:`is-ready`}`,children:p}),e?.fits===!0&&L(`span`,{className:`model-badge is-fit`,children:o(`settings.model.fits`)}),!!e?.size_gb&&z(`bdi`,{dir:`ltr`,className:`model-badge is-size`,children:[e.size_gb,` GB`]}),u&&!!e?.context_length&&L(`span`,{className:`model-badge is-ready`,children:o(`settings.model.contextChip`,{size:tl(e.context_length)})})]}),(n.length>1||n.length===1&&!d)&&z(`div`,{className:`model-in-use-field`,children:[L(`label`,{className:`settings-label`,htmlFor:`model-switch`,children:o(`settings.model.switch`)}),z(`select`,{id:`model-switch`,className:`settings-input`,value:d?n.find(e=>Hc(l,e.id))?.id:``,onChange:e=>a(e.target.value),disabled:i,children:[!d&&L(`option`,{value:``,disabled:!0,children:o.bare(`settings.model.switchPlaceholder`)}),n.map(e=>L(`option`,{value:e.id,children:r[e.id]},e.id))]})]}),l&&!u&&s?.downloaded!==!1&&L(mX,{model:l})]})}var gX=e=>new Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:0}).format(e),_X={"best overall, fastest":`settings.model.note.bestFastest`,cheapest:`settings.model.note.cheapest`,"most truthful":`settings.model.note.mostTruthful`},vX=/^(\d+\/\d+) tasks · quality ([\d.]+\/5) · (\$[\d.]+) per (\d+)-task run$/;function yX(e,t){let n=vX.exec(t);return e.compose(e=>e(`settings.model.measured`,{evidence:n?e(`settings.model.evidence`,{tasks:n[1],quality:n[2],cost:n[3],n:n[4]}):t}))}function bX({model:e,label:t,current:n,remote:r,busy:i,onUse:a,onDownload:o,onAskRemove:s,onNpuRecheck:c}){let l=R(),u=rl(e)?e.download_progress:null,d=e.placement?.label,f=l.compose(t=>[d&&(e.placement?.source===`expected`?t(`settings.model.expected`,{label:d}):d),e.size_gb?t(e.downloaded?`settings.model.sizeOnDisk`:`settings.model.sizeDownload`,{size:`${e.size_gb} GB`}):null,e.tokens_per_second?t(`settings.model.speed`,{speed:`${Math.round(e.tokens_per_second)} tok/s`}):null,!e.placement&&e.context_length?t(`settings.model.contextTokens`,{size:gX(e.context_length)}):null].filter(Boolean).join(` · `)),p=!!(e.display_name||f||e.evidence||e.custom&&e.source_url);return z(`li`,{className:`model-row${n?` is-current`:``}`,children:[z(`div`,{className:`model-row-text`,children:[L(`bdi`,{className:`model-row-name`,title:e.id,children:t}),z(`div`,{className:`model-chips`,children:[e.placement?.device&&L(`span`,{className:`model-badge is-device`,children:e.placement.device.toUpperCase()}),e.rank&&z(`span`,{className:`model-badge is-rank`,children:[z(`bdi`,{dir:`ltr`,children:[`#`,e.rank]}),` `,e.note&&(_X[e.note]?l(_X[e.note]):L(`bdi`,{children:e.note}))]}),e.state===`loaded`&&L(`span`,{className:`model-badge is-loaded`,children:l(`settings.model.loaded`)}),e.fits===!0&&e.available!==!1&&!e.tight&&L(`span`,{className:`model-badge is-fit`,children:l(`settings.model.fits`)}),e.fits===!0&&e.available!==!1&&e.tight&&L(`span`,{className:`model-badge is-tight`,title:l(`setup.models.warn.tight`),children:l(`settings.model.tight`)}),e.custom&&L(`span`,{className:`model-badge is-custom`,children:l(`settings.model.custom`)}),!!e.size_gb&&z(`bdi`,{dir:`ltr`,className:`model-badge is-size`,children:[e.size_gb,` GB`]}),p&&z(`details`,{className:`settings-more model-row-facts`,children:[z(`summary`,{children:[L($r,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,l(`settings.model.details`)]}),e.display_name&&L(`span`,{className:`model-row-meta`,children:L(`bdi`,{children:e.id})}),f&&L(`span`,{className:`model-row-meta`,children:f}),e.evidence&&L(`span`,{className:`model-row-meta`,children:yX(l,e.evidence)}),e.custom&&e.source_url&&L(`span`,{className:`model-row-meta`,children:l(`settings.model.from`,{url:e.source_url})})]})]}),r&&L(`span`,{className:`model-row-meta${e.price?``:` is-unknown-price`}`,children:OR(e.price,l)}),e.placement?.warning&&L(`span`,{className:`model-row-meta is-warning`,role:`alert`,children:L(`bdi`,{children:e.placement.warning})}),e.npu_problems?.length?L(VJ,{problems:e.npu_problems,disabled:i!==null,onRecheck:c,id:`npu-problems-${e.id}`}):e.unavailable_reason&&L(`span`,{className:`model-row-meta`,children:l(`settings.model.cantRun`,{reason:e.unavailable_reason})}),u&&L(`progress`,{max:100,value:u.percent,"aria-label":l(`settings.model.downloadingAria`,{name:t})})]}),z(`div`,{className:`model-row-actions`,children:[e.custom&&!n&&!u&&z(`button`,{type:`button`,className:`btn-secondary`,onClick:s,disabled:i!==null,"aria-label":l(`settings.models.removeAria`,{name:t}),children:[i===`rm:${e.id}`?L(Za,{size:13,className:`spin`}):null,l(`settings.models.remove`)]}),n&&e.available===!1?L(`span`,{className:`model-row-current is-blocked`,children:l(`settings.model.inUseBlocked`)}):n?z(`span`,{className:`model-row-current`,children:[L(Yr,{size:13,"aria-hidden":`true`}),` `,l(`settings.model.inUse`)]}):e.available===!1?null:u?z(`span`,{className:`model-row-current`,children:[L(Za,{size:13,className:`spin`}),` `,u.message?L(`bdi`,{children:u.message}):z(`bdi`,{dir:`ltr`,children:[Math.round(u.percent),`%`]})]}):e.downloaded?z(`button`,{type:`button`,className:`btn-secondary`,onClick:a,disabled:i!==null,"aria-label":l(`settings.model.useAria`,{name:t}),children:[i===e.id?L(Za,{size:13,className:`spin`}):null,` `,l(`settings.model.use`)]}):z(`button`,{type:`button`,className:`btn-secondary`,onClick:o,disabled:i!==null,"aria-label":l(`settings.model.downloadAria`,{name:t}),children:[i===`dl:${e.id}`?L(Za,{size:13,className:`spin`}):null,` `,l(`settings.model.download`)]})]})]})}function xX(){let e=R(),[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(``),[c,l]=(0,B.useState)(!1),u=(0,B.useCallback)(async e=>{l(!0),i(null);try{let t=await e();n(t),o(t.limit_usd==null?``:String(t.limit_usd))}catch(e){i(e instanceof Error?e.message:String(e))}finally{l(!1)}},[]);if((0,B.useEffect)(()=>{u(Dn)},[u]),!t)return r?L(`p`,{className:`settings-error`,role:`alert`,children:r}):z(`p`,{className:`settings-hint`,children:[L(Za,{size:13,className:`spin`}),` `,e(`settings.spend.loading`)]});let d=t.limit_usd,f=a.trim()===``?null:Number(a),p=f===null||Number.isFinite(f)&&f>0,m=f!==d;return z(`section`,{className:`settings-field spending`,"aria-label":e(`settings.spend.aria`),children:[L(`span`,{className:`settings-label`,children:e(`settings.spend.title`)}),z(`p`,{className:`spending-total`,children:[L(`bdi`,{dir:`ltr`,children:L(`strong`,{children:kR(t.total_usd)})}),d!=null&&z(P.Fragment,{children:[` `,e(`settings.spend.ofLimit`,{limit:kR(d)})]}),z(`span`,{className:`settings-hint`,children:[` · `,e.plural(`settings.spend.turns`,t.turns-t.unpriced_turns-t.unreported_turns)]})]}),t.unpriced_turns>0&&L(`p`,{className:`settings-hint`,children:e.plural(`settings.spend.unpriced`,t.unpriced_turns)}),t.unreported_turns>0&&L(`p`,{className:`settings-hint`,children:e.plural(`settings.spend.unreported`,t.unreported_turns)}),t.state===`near`&&z(`p`,{className:`spending-warning`,role:`status`,children:[L(Ws,{size:13,"aria-hidden":`true`}),` `,e(`settings.spend.near`)]}),t.state===`reached`&&z(`div`,{className:`spending-warning`,role:`alert`,children:[z(`p`,{children:[L(Ws,{size:13,"aria-hidden":`true`}),` `,e(`settings.spend.reached`)]}),L(`button`,{type:`button`,className:`btn-secondary`,disabled:c,onClick:()=>void u(In),children:e(`settings.spend.allow`)})]}),t.state===`allowed_over`&&L(`p`,{className:`settings-hint`,children:e(`settings.spend.allowed`)}),z(`form`,{className:`settings-row`,onSubmit:e=>{e.preventDefault(),p&&m&&u(()=>s(f))},children:[L(`label`,{className:`spending-limit-label`,htmlFor:`spend-limit`,children:e(`settings.spend.limit`)}),L(`input`,{id:`spend-limit`,className:`settings-input`,type:`number`,min:`0.01`,step:`0.01`,inputMode:`decimal`,placeholder:e.bare(`settings.spend.noLimit`),value:a,onChange:e=>o(e.target.value),"aria-invalid":!p}),z(`button`,{type:`submit`,className:`btn-secondary`,disabled:c||!p||!m,children:[c?L(Za,{size:13,className:`spin`}):null,` `,e(`settings.advanced.save`)]}),d!=null&&L(`button`,{type:`button`,className:`btn-secondary`,disabled:c,onClick:()=>void u(()=>s(null)),children:e(`settings.spend.removeLimit`)})]}),L(`span`,{className:`settings-hint`,children:e(`settings.spend.how`)}),r&&L(`p`,{className:`settings-error`,role:`alert`,children:r})]})}var SX=2e3;function CX(e,t){return e.key_source===`environment`?t(`settings.key.setIn`,{name:e.env_var??``}):`••••••••••••••••••••${e.key_hint?` ${e.key_hint}`:``}`}function wX(){let e=R(),t=zc(e=>e.active),n=zc(e=>e.select),r=zc(e=>e.refresh),i=zc(e=>e.rememberNames),a=N(e=>!!e.systemStatus&&QI(e.systemStatus)===`unresponsive`),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(null),u=N(e=>e.settingsProvider),[d,f]=(0,B.useState)(u??t?.provider??`local`),[m,h]=(0,B.useState)(null),[g,_]=(0,B.useState)(null),[v,y]=(0,B.useState)(``),[b,x]=(0,B.useState)(!1),[S,C]=(0,B.useState)(``),[w,T]=(0,B.useState)(!1),[E,D]=(0,B.useState)(!1),[O,ee]=(0,B.useState)({base_url:``,auth_header_name:``,auth_header_prefix:``}),[te,ne]=(0,B.useState)(null),[re,k]=(0,B.useState)(null),[ie,ae]=(0,B.useState)(null),[A,oe]=(0,B.useState)(null),[se,ce]=(0,B.useState)(!1),[le,ue]=(0,B.useState)(null),[de,fe]=(0,B.useState)(null),pe=(0,B.useRef)(d);pe.current=d;let me=(0,B.useRef)(!0);(0,B.useEffect)(()=>(me.current=!0,()=>{me.current=!1}),[]);let j=o?.find(e=>e.id===d)??null,he=e=>e?.network?.reachable===!1,M=e=>!!e?.blocked,ge=!!j&&!M(j)&&(!j.remote||!!j.models_discovered),_e=(0,B.useCallback)(async()=>{l(null);try{let e=await gt();s(e.providers),e.lemonade_error&&l(e.lemonade_error)}catch(e){l(e instanceof Error?e.message:String(e))}},[]),ve=(0,B.useCallback)(async()=>{try{await Fe()}catch(e){l(e instanceof Error?e.message:String(e));return}await _e()},[_e]),ye=(0,B.useCallback)(async(t,n=!1)=>{n||(h(null),_(null));try{let n=await Gt(t);i(n.models),h(n.models),k(n.memory_gb?`${n.memory_gb} GB (${n.memory_source})`:n.capacity_error??null),n.blocked&&_(e(`settings.privacy.localOnlyBlocked`))}catch(e){_(e instanceof Error?e.message:String(e))}},[i,e]);(0,B.useEffect)(()=>{_e()},[_e]);let be=!!o?.some(e=>e.key_state===`waiting_for_os_permission`);(0,B.useEffect)(()=>{if(!be)return;let e=setInterval(()=>{_e()},SX);return()=>clearInterval(e)},[be,_e]);let xe=t?.provider;(0,B.useEffect)(()=>{xe&&!u&&f(xe)},[xe,u]),(0,B.useEffect)(()=>{C(``),T(!1),D(!1),ae(null),y(``),x(!1),ce(!1)},[d]),(0,B.useEffect)(()=>{ge?ye(d):h(null)},[d,ge,ye]);let Se=(0,B.useCallback)(async()=>{if(j){ne(`connect`),ae(null);try{let t=d===`amd`?{api_key:S||void 0,...Object.fromEntries(Object.entries(O).filter(([,e])=>e!==``))}:{api_key:S||void 0},n=()=>!me.current||pe.current!==d,r=await ln(d,t,e=>{n()||ae({ok:!0,text:e})},n);if(n())return;C(``),T(!1),ae({ok:!0,text:r.remember_error?e(`settings.key.sessionOnly`,{reason:r.remember_error}):r.known_models?e(`settings.key.knownModels`,{name:j.name}):r.remembered?e(`settings.key.kept`):e(`settings.key.connectedDone`)}),await _e()}catch(e){me.current&&pe.current===d&&ae({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{me.current&&ne(null)}}},[O,d,S,_e,j,e]),Ce=(0,B.useCallback)(async()=>{ne(`forget`),D(!1),ae(null);try{await ze(d),ae({ok:!0,text:e(`settings.key.cleared`)}),await _e(),await r()}catch(e){ae({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{ne(null)}},[d,_e,r,e]),we=(0,B.useCallback)(async t=>{ne(t),ae(null);try{await n(t),ae({ok:!0,text:e(`settings.model.switched`,{name:Uc(t)})}),await ye(d,!0)}catch(e){ae({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{ne(null)}},[d,ye,n,e]),Te=(0,B.useCallback)(async e=>{ne(`dl:${e}`),ae(null),ce(!1);try{await p(e),await ye(`local`,!0)}catch(e){ae({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{ne(null)}},[ye]),Ee=(0,B.useCallback)(async t=>{let n=zc.getState().active?.model;ne(`rm:${t}`),ae(null);try{let r=await nr(t);oe(null);let i=r.cleared.includes(`last_model`)?`settings.model.removedLast`:r.cleared.includes(`default_model`)?`settings.model.removedDefault`:`settings.model.removed`;ae({ok:!0,text:e(i,{name:r.display_name})}),await ye(`local`,!0),await Bc(n)}catch(e){ae({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{ne(null)}},[ye,e]),De=(0,B.useCallback)(async t=>{ae({ok:!0,text:e(`settings.model.added`,{name:t})}),ce(!0),await ye(`local`,!0)},[ye,e]),Oe=!!m?.some(rl);(0,B.useEffect)(()=>{if(Oe)return()=>{r()}},[Oe,r]),(0,B.useEffect)(()=>{if(d!==`local`||!Oe)return;let e=setInterval(()=>{ye(`local`,!0)},SX);return()=>clearInterval(e)},[Oe,d,ye]);let ke=t?.model,Ae=m?.find(e=>Hc(ke,e.id));(0,B.useEffect)(()=>{Ae&&ue(Ae)},[Ae]);let je=(0,B.useMemo)(()=>{let e=v.trim().toLowerCase();return(m??[]).filter(t=>!e||t.id.toLowerCase().includes(e)||(t.display_name??``).toLowerCase().includes(e))},[m,v]),Me=je.filter(e=>e.available!==!1),Ne=d===`fireworks`&&!b&&!v.trim()&&Me.some(e=>e.rank!==null),Pe=e=>e.rank!==null||e.id===t?.model,Ie=Ne?Me.filter(Pe):Me,Le=Ne?Me.filter(e=>!Pe(e)):[],Re=je.filter(e=>e.available===!1),Be=Zc(m??[]),Ve=!!v.trim(),He=e=>Hc(t?.model,e.id),Ue=j?.id===`local`,We=Ie.filter(e=>e.downloaded).sort((e,t)=>Number(He(t))-Number(He(e))),Ge=Ie.filter(e=>!e.downloaded),Ke=(m??[]).filter(e=>e.available!==!1&&e.downloaded),qe=Ke.filter(Pe),Je=A?(m??[]).find(e=>e.id===A)??null:null,Ye=d===`fireworks`&&qe.some(e=>e.rank!==null)?qe:Ke,Xe=e=>L(bX,{model:e,label:Be[e.id],current:He(e),remote:!!j?.remote,busy:te,onUse:()=>void we(e.id),onDownload:()=>void Te(e.id),onAskRemove:()=>oe(e.id),onNpuRecheck:()=>void ye(d,!0)},e.id);return z(`div`,{className:`settings-pane`,children:[L(`h2`,{className:`settings-pane-title`,children:e(`settings.section.model`)}),L(LJ,{inSettings:!0}),L(hX,{row:Ae??(Hc(le?.id,t?.model)?le:null),providerName:t?.provider_name??null,choices:ge?Ye:[],labels:Be,disabled:te!==null,onSwitch:e=>void we(e)}),L(jB,{className:`provider-tabs`,"aria-label":e(`settings.model.whereRuns`),children:(o??[{id:`local`,name:`Local`,remote:!1}]).map(t=>z(`button`,{type:`button`,role:`radio`,"aria-checked":d===t.id,className:`provider-tab${d===t.id?` is-active`:``}${he(t)||M(t)?` is-disabled`:``}`,onClick:()=>f(t.id),disabled:(he(t)||M(t))&&d!==t.id,title:M(t)?e(`settings.privacy.localOnlyBlocked`):he(t)?e(`setup.key.gatewayOff`):void 0,children:[t.remote?L(xi,{size:14,"aria-hidden":`true`}):L(ki,{size:14,"aria-hidden":`true`}),L(`span`,{children:jR(e,t)}),t.remote&&t.models_discovered&&L(`span`,{className:`provider-tab-dot`,"aria-label":e(`settings.key.connectedDot`)})]},t.id))}),!o&&!c&&z(`p`,{className:`settings-hint`,role:`status`,children:[L(Za,{size:13,className:`spin`}),` `,e(a?`settings.model.waitingServer`:`settings.loading`)]}),c&&L(cX,{message:c,onRetry:()=>{_e(),ye(d)}}),j&&z(`section`,{className:`settings-card`,"aria-label":jR(e,j),children:[j.remote&&L(`p`,{className:`settings-note`,children:L(`bdi`,{children:MR(e,j)})}),z(`details`,{className:`settings-more`,children:[z(`summary`,{children:[L($r,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,e(`settings.model.howItWorks`)]}),L(`p`,{className:`settings-hint`,children:e(`settings.model.lede`)}),Ue&&L(`p`,{className:`settings-hint`,children:L(`bdi`,{children:MR(e,j)})}),Ue&&L(`p`,{className:`settings-hint`,children:e(`settings.model.devices`)}),Ue&&re&&L(`p`,{className:`settings-hint`,children:e(`settings.model.memory`,{memory:re})})]}),j.remote&&!ge&&z(`div`,{className:`settings-field`,children:[L(`span`,{className:`settings-label`,children:e(`settings.model.prices`)}),L(RK,{provider:j.id})]}),M(j)&&L(`div`,{className:`settings-field`,children:L(`p`,{className:`settings-error`,role:`alert`,children:e(`settings.privacy.localOnlyBlocked`)})}),he(j)&&z(`div`,{className:`settings-field`,children:[L(`p`,{className:`settings-error`,role:`alert`,children:j.network?.detail}),L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void _e(),children:e(`settings.key.checkAgain`)})]}),j.remote&&!he(j)&&!M(j)&&z(`form`,{className:`settings-field`,"data-settings-target":`cloud-key`,onSubmit:e=>{e.preventDefault(),Se()},children:[z(`div`,{className:`settings-row settings-row-between`,children:[L(`span`,{className:`settings-label`,children:e(`settings.key.title`)}),j.key_source&&L(`span`,{className:`settings-key-status ${ge?`settings-ok`:`settings-error`}`,children:e(ge?`settings.key.connected`:`settings.key.notConnected`)})]}),!j.key_source&&j.key_state===`store_locked`&&z(`span`,{className:`settings-hint`,role:`status`,children:[e(`settings.key.storeLocked`),` `,L(`button`,{type:`button`,className:`link-btn`,onClick:()=>void ve(),children:e(`settings.key.unlockAgain`)})]}),!j.key_source&&j.key_state!==`store_locked`&&L(`span`,{className:`settings-hint`,children:j.key_state===`waiting_for_os_permission`?j.key_message??e(`settings.key.waitingOs`):e(`settings.key.none`)}),j.id===`amd`&&(!j.key_source||w)&&z(`div`,{className:`settings-grid`,children:[L(`input`,{className:`settings-input`,placeholder:e(`settings.key.gatewayPlaceholder`),value:O.base_url,onChange:e=>ee({...O,base_url:e.target.value}),"aria-label":e(`settings.key.gatewayUrl`)}),L(`input`,{className:`settings-input`,placeholder:e(`settings.key.headerPlaceholder`),value:O.auth_header_name,onChange:e=>ee({...O,auth_header_name:e.target.value}),"aria-label":e(`settings.key.headerName`)})]}),j.key_source&&!w?z(`div`,{className:`settings-row`,children:[L(`input`,{className:`settings-input settings-key-masked`,readOnly:!0,value:CX(j,e),"aria-label":e(`settings.key.savedAria`,{name:j.name})}),!ge&&z(`button`,{type:`submit`,className:`btn-primary`,disabled:te!==null,children:[te===`connect`?L(Za,{size:13,className:`spin`}):null,e(`settings.key.reconnect`)]}),(j.key_source!==`environment`||j.key_from_gaia_env)&&z(P.Fragment,{children:[L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>T(!0),disabled:te!==null,children:e(`settings.key.replace`)}),j.key_source!==`environment`&&L(`button`,{type:`button`,className:`btn-secondary settings-key-remove`,onClick:()=>D(!0),disabled:te!==null,"aria-label":e(`settings.key.remove`),title:e(`settings.key.remove`),children:L(Hs,{size:14,"aria-hidden":`true`})})]})]}):z(`div`,{className:`settings-row`,children:[L(`input`,{className:`settings-input`,type:`password`,autoComplete:`off`,spellCheck:!1,autoFocus:w,value:S,onChange:e=>C(e.target.value),placeholder:e(w?`settings.key.pasteNew`:`settings.key.paste`),"aria-label":e(`settings.key.fieldAria`,{name:j.name})}),z(`button`,{type:`submit`,className:`btn-primary`,disabled:te!==null||!S,children:[te===`connect`?L(Za,{size:13,className:`spin`}):null,e(w?`settings.key.save`:`settings.key.connect`)]}),w&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{C(``),T(!1)},disabled:te!==null,children:e(`settings.key.cancel`)})]}),j.key_source&&!ge&&!j.error&&!w&&L(`p`,{className:`settings-hint`,children:e(`settings.key.notConnectedHint`,{name:j.name})}),j.error&&L(`p`,{className:`settings-error`,role:`alert`,children:j.error})]}),ie?.ok&&L(`p`,{className:`settings-ok`,role:`status`,children:ie.text}),ie&&!ie.ok&&L(cX,{message:ie.text}),j.known_models&&L(`p`,{className:`settings-hint`,role:`status`,children:e(`settings.key.knownList`,{name:j.name})}),Ue&&L(`div`,{className:`models-downloads-slot`,ref:fe}),ge&&z(`div`,{className:`settings-field`,children:[L(`span`,{className:`settings-label`,children:e(`settings.model.models`)}),(m?.length??0)>6&&L(`input`,{className:`settings-input`,type:`search`,value:v,onChange:e=>y(e.target.value),placeholder:e(`settings.model.search`),"aria-label":e(`settings.model.search`)}),g&&!(c&&nX(g))&&L(cX,{message:g}),!m&&!g&&z(`p`,{className:`settings-hint`,children:[L(Za,{size:13,className:`spin`}),` `,e(`settings.loading`)]}),m&&je.length===0&&!g&&L(`p`,{className:`settings-hint`,children:e(Ve||!Ue?`settings.model.noMatch`:`settings.model.noModels`)}),Ue?z(P.Fragment,{children:[We.length>0&&L(BY,{title:e(`settings.model.groupDownloaded`),count:We.length,defaultOpen:!0,forceOpen:Ve,targetId:`models-on-pc`,children:L(`ul`,{className:`model-list`,children:We.map(Xe)})}),Ge.length>0&&L(BY,{title:e(`settings.model.groupAvailable`),count:Ge.length,defaultOpen:We.length===0,forceOpen:Ve||se||Ge.some(rl),children:L(`ul`,{className:`model-list`,children:Ge.map(Xe)})})]}):L(`ul`,{className:`model-list`,children:Ie.map(Xe)}),Ne&&Le.length>0&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>x(!0),children:e(`settings.model.showAll`)}),d===`fireworks`&&b&&!Ve&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>x(!1),children:e(`settings.model.showRecommended`)}),Re.length>0&&L(BY,{title:e(`settings.model.groupUnavailable`),count:Re.length,forceOpen:Ve,children:L(`ul`,{className:`model-list`,children:Re.map(Xe)})})]}),Ue&&ge&&L(BY,{title:e(`settings.custom.title`),children:L(lX,{onAdded:e=>void De(e)})}),Ue&&ge&&L(fX,{downloadsSlot:de}),j.remote&&L(xX,{})]}),Je&&L(Vq,{title:e(`settings.models.removeTitle`,{name:Be[Je.id]??Je.id}),confirmLabel:Je.downloaded?e(`settings.model.removeDownload`):e(`settings.models.remove`),cancelLabel:e(`settings.models.keep`),danger:!0,onConfirm:()=>{oe(null),Ee(Je.id)},onCancel:()=>oe(null),children:Je.downloaded&&L(`p`,{children:e(`settings.model.removeDownloadBody`)})}),E&&j&&L(Vq,{title:e(`settings.key.removeAsk`),confirmLabel:e(`settings.key.remove`),cancelLabel:e(`settings.models.keep`),danger:!0,onConfirm:()=>void Ce(),onCancel:()=>D(!1),children:L(`p`,{children:e(`settings.key.removeBody`,{name:j.name})})})]})}async function TX(){return Ct(`GET`,`/images/settings`)}async function EX(e){return Ct(`PUT`,`/images/settings`,e)}var DX=[4,8,12,20,30,50],OX=e=>`${e}`;function kX(e){return e instanceof Vn?e.detail||e.message:String(e)}function AX(){let e=R(),t=N(e=>e.openSettings);Vc();let[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(!1),u=()=>{a(null),TX().then(r).catch(e=>a({unreachable:e instanceof Vn&&e.httpStatus===503,detail:kX(e)}))};(0,B.useEffect)(u,[]);let d=e=>{l(!0),s(null),EX(e).then(r).catch(e=>s(kX(e))).finally(()=>l(!1))},f=L(`h2`,{className:`settings-pane-title`,children:e(`settings.section.images`)});if(i)return z(`div`,{className:`settings-pane`,children:[f,i.unreachable?z(P.Fragment,{children:[L(`p`,{className:`settings-error`,role:`alert`,children:e(`images.settings.unreachable`)}),L(`p`,{className:`settings-hint`,children:i.detail}),L(`button`,{type:`button`,className:`btn-secondary`,onClick:u,children:e(`images.settings.retry`)})]}):L(`p`,{className:`settings-error`,role:`alert`,children:e(`images.settings.loadFailed`,{reason:i.detail})})]});if(!n)return z(`p`,{className:`settings-hint`,children:[L(Za,{size:13,className:`spin`}),` `,e(`settings.loading`)]});let p=n.models.find(e=>e.id===n.model),m=p?[...new Set([...DX,p.default_steps,...n.steps?[n.steps]:[]])].filter(e=>e<=n.max_steps).sort((e,t)=>e-t):[];return z(`div`,{className:`settings-pane`,children:[f,L(`p`,{className:`settings-pane-lede`,children:e(`images.settings.lede`)}),!n.chat_model_creates_images&&z(`div`,{className:`settings-notice`,role:`status`,children:[L(`p`,{children:e(`images.settings.chatModelCannot`,{model:Uc(n.chat_model)})}),L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>t(`model`),children:e(`images.settings.chooseChatModel`)})]}),!n.model_available&&L(`p`,{className:`settings-error`,role:`alert`,children:e(`images.settings.modelGone`,{model:n.model})}),n.models.length===0?L(`p`,{className:`settings-hint`,children:e(`images.settings.noModels`)}):z(P.Fragment,{children:[z(`div`,{className:`settings-field`,children:[L(`label`,{className:`settings-label`,htmlFor:`image-model`,children:e(`images.settings.model`)}),z(`select`,{id:`image-model`,className:`settings-input`,value:n.model_available?n.model:``,disabled:c,onChange:e=>d({model:e.target.value}),children:[!n.model_available&&L(`option`,{value:``,disabled:!0,children:n.model}),n.models.map(t=>L(`option`,{value:t.id,children:t.downloads_on_first_use?e.bare(`images.settings.downloadsOnFirstUse`,{model:t.id,size:OX(`${t.size_gb??`?`} GB`)}):t.id},t.id))]})]}),p&&z(P.Fragment,{children:[z(`div`,{className:`settings-field`,children:[L(`label`,{className:`settings-label`,htmlFor:`image-size`,children:e(`images.settings.size`)}),z(`select`,{id:`image-size`,className:`settings-input`,value:n.size??``,disabled:c,onChange:e=>d({size:e.target.value||null}),children:[L(`option`,{value:``,children:e.bare(`images.settings.automatic`,{value:OX(p.default_size)})}),p.sizes.map(e=>L(`option`,{value:e,children:OX(e)},e))]})]}),z(`div`,{className:`settings-field`,children:[L(`label`,{className:`settings-label`,htmlFor:`image-steps`,children:e(`images.settings.steps`)}),z(`select`,{id:`image-steps`,className:`settings-input`,value:n.steps??``,disabled:c,onChange:e=>d({steps:e.target.value?Number(e.target.value):null}),children:[L(`option`,{value:``,children:e.bare(`images.settings.automatic`,{value:OX(String(p.default_steps))})}),m.map(e=>L(`option`,{value:e,children:OX(String(e))},e))]}),L(`span`,{className:`settings-hint`,children:e(`images.settings.stepsHint`)})]})]})]}),L(`p`,{className:`settings-hint`,children:e(`images.settings.shared`)}),o&&L(`p`,{className:`settings-error`,role:`alert`,children:e(`images.settings.saveFailed`,{reason:o})})]})}function jX(){let e=R(),t=N(e=>e.sessions),[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(null),u=(0,B.useCallback)(async()=>{l(null);try{let e=await nn();r(e.sessions),a(e.default_mode),N.getState().setDefaultPermissionMode(e.default_mode)}catch(e){l(e instanceof Error?e.message:String(e))}},[]);(0,B.useEffect)(()=>{u()},[u]);let d=(0,B.useCallback)(async e=>{l(null);try{await e(),await u()}catch(e){l(e instanceof Error?e.message:String(e))}},[u]),f=(0,B.useCallback)(async e=>{s(!1),await d(()=>cn(e))},[d]),p=()=>{i===`full_access`?f(`ask`):s(e=>!e)},m=e=>t.find(t=>t.id===e)?.title??e;return z(`div`,{className:`settings-pane`,children:[L(`h2`,{className:`settings-pane-title`,children:e(`settings.section.permissions`)}),L(`p`,{className:`settings-pane-lede`,children:e(`settings.permissions.lede`)}),z(`details`,{className:`settings-more`,children:[z(`summary`,{children:[L($r,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,e(`settings.model.howItWorks`)]}),L(`p`,{className:`settings-hint`,children:e(`settings.permissions.perChat`)})]}),z(`section`,{className:`settings-card`,"aria-label":e(`settings.permissions.newChats`),children:[z(`label`,{className:`setting-row`,children:[L(`span`,{className:`settings-label`,children:e(`settings.permissions.fullAccess`)}),z(`span`,{className:`toggle-switch`,children:[L(`input`,{type:`checkbox`,checked:i===`full_access`,onChange:p,disabled:i===null,"aria-label":e(`settings.permissions.fullAccess`)}),L(`span`,{className:`toggle-track`})]})]}),L(`p`,{className:`settings-hint`,children:e(i===`full_access`?`settings.permissions.on`:`settings.permissions.off`)}),o&&z(`div`,{className:`settings-warning`,role:`alert`,children:[L(`p`,{children:e(`settings.permissions.warning`)}),z(`div`,{className:`settings-row`,children:[L(`button`,{type:`button`,className:`btn-danger`,onClick:()=>void f(`full_access`),children:e(`settings.permissions.turnOn`)}),L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>s(!1),children:e(`settings.key.cancel`)})]})]})]}),c&&L(`p`,{className:`settings-error`,role:`alert`,children:c}),n&&n.length===0&&L(`p`,{className:`settings-hint`,children:e(`settings.permissions.none`)}),!!n?.length&&L(BY,{title:e(`settings.permissions.chats`),count:n.length,defaultOpen:!0,children:n.map(t=>z(`section`,{className:`settings-field permission-chat`,"aria-label":m(t.session_id),children:[z(`div`,{className:`settings-row settings-row-between`,children:[L(`bdi`,{className:`settings-label`,children:m(t.session_id)}),t.mode===`full_access`&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>d(async()=>{let e=(await Vt(t.session_id,`ask`)).mode;nz(t.session_id,e)}),children:e(`settings.permissions.turnOff`)})]}),t.grants.length>0&&L(`ul`,{className:`grant-list`,children:t.grants.map(n=>z(`li`,{className:`grant-row`,children:[L(`code`,{children:n.label}),L(`button`,{type:`button`,className:`link-btn`,onClick:()=>d(()=>It(t.session_id,n.key)),"aria-label":e(`settings.permissions.revokeAria`,{name:n.label}),children:e(`settings.permissions.revoke`)})]},n.key))}),t.grants.length>1&&L(`button`,{type:`button`,className:`link-btn`,onClick:()=>d(()=>It(t.session_id)),children:e(`settings.permissions.revokeAll`)})]},t.session_id))})]})}var MX=(e,t)=>!e.error&&(!e.installed||e.update)&&(t||!e.has_code);function NX(e,t){let n=e.added.filter(e=>e.updated).map(e=>e.name),r=e.added.filter(e=>!e.updated).map(e=>e.name),i=(e,n)=>n.length>3?t(`settings.skills.link.${e}Count`,{n:n.length}):t(`settings.skills.link.${e}`,{names:n.join(`, `)});return[r.length?i(`added`,r):``,n.length?i(`updated`,n):``].filter(Boolean).join(` `)}function PX({onAdded:e}){let t=R(),[n,r]=(0,B.useState)(``),[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(null),[u,d]=(0,B.useState)(new Set),[f,p]=(0,B.useState)(!1),[m,h]=(0,B.useState)(null),[g,_]=(0,B.useState)([]);(0,B.useEffect)(()=>{let e=!1;return An().then(t=>{e||_(t.libraries)}).catch(n=>{e||s(t(`settings.skills.link.featuredFailed`,{error:aN(n,t)}))}),()=>{e=!0}},[t]);let v=async e=>{if(e.trim()){a(`preview`),s(null),l(null),h(null);try{let t=await dt(e.trim());l(t),d(new Set(t.skills.filter(e=>MX(e,!1)).map(e=>e.name)))}catch(e){s(aN(e,t))}finally{a(null)}}},y=async()=>{if(c&&u.size!==0){a(`add`),s(null);try{let t=await vn(c.link,[...u],f,c.pin);h(t),l(null),r(``),t.added.length&&e()}catch(e){s(aN(e,t))}finally{a(null)}}},b=e=>d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),x=e=>{if(p(e),!e&&c){let e=new Set(c.skills.filter(e=>e.has_code).map(e=>e.name));d(t=>new Set([...t].filter(t=>!e.has(t))))}},S=c?.skills.filter(e=>MX(e,f))??[],C=S.length>0&&S.every(e=>u.has(e.name)),w=c?.skills.some(e=>e.has_code&&!e.error)??!1;return z(`div`,{className:`settings-card skill-link`,children:[z(`div`,{className:`skill-link-top`,children:[L(`span`,{className:`settings-label`,children:t(`settings.skills.link.title`)}),g.map(e=>{let n=`settings.skills.link.featured.${e.id}`,a=fe(n);return L(`button`,{type:`button`,className:`btn-secondary skill-link-chip`,onClick:()=>{r(e.url),v(e.url)},disabled:i!==null,title:a?t(n):e.description,"aria-label":t(`settings.skills.link.getAria`,{name:e.name,description:a?We(n):e.description}),children:t(`settings.skills.link.get`,{name:e.name})},e.id)})]}),z(`form`,{className:`skill-link-form`,onSubmit:e=>{e.preventDefault(),v(n)},children:[L(`input`,{className:`settings-input`,type:`text`,inputMode:`url`,value:n,onChange:e=>r(e.target.value),onPaste:e=>{let t=e.clipboardData.getData(`text`).trim();t&&(e.preventDefault(),r(t),v(t))},placeholder:t.bare(`settings.skills.link.placeholder`),title:t(`settings.skills.link.hint`),"aria-label":t(`settings.skills.link.aria`),disabled:i!==null}),L(`button`,{type:`submit`,className:`btn-secondary`,disabled:!n.trim()||i!==null,children:i===`preview`?z(P.Fragment,{children:[L(Za,{size:13,className:`spin`}),` `,t(`settings.skills.link.reading`)]}):t(`settings.skills.link.read`)})]}),o&&L(`p`,{className:`settings-error`,role:`alert`,children:o}),c&&z(`div`,{className:`skill-link-preview`,children:[z(`details`,{className:`skill-link-warning`,role:`note`,children:[z(`summary`,{children:[L(Ws,{size:14,"aria-hidden":`true`}),t(`settings.skills.link.trust`)]}),L(`p`,{children:L(`bdi`,{children:c.warning})})]}),z(`div`,{className:`skill-link-head`,children:[L(`span`,{children:t(`settings.skills.link.found`,{n:c.skills.length,source:c.source})}),S.length>1&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>d(C?new Set:new Set(S.map(e=>e.name))),children:t(C?`settings.skills.link.none`:`settings.skills.link.all`)})]}),L(`ul`,{className:`skill-list skill-link-list`,children:c.skills.map(e=>{let n=MX(e,f),r=e.error?e.verdict===`BLOCK`?t(`settings.skills.link.tagBlocked`):t(`settings.skills.link.tagUnreadable`):e.installed&&!e.update?t(`settings.skills.link.tagElsewhere`):e.update?t(`settings.skills.link.tagUpdate`):null,i=e.error??(e.installed&&!e.update?t(`settings.skills.link.whyElsewhere`):e.update?t(`settings.skills.link.whyUpdate`):null),a=!!i||e.findings.length>0||e.has_code&&!f;return L(`li`,{className:`skill-row`,children:z(`label`,{className:`skill-link-pick`,children:[L(`input`,{type:`checkbox`,checked:n&&u.has(e.name),disabled:!n,onChange:()=>b(e.name),"aria-label":t(`settings.skills.link.addAria`,{name:e.name})}),z(`span`,{className:`skill-row-text`,children:[z(`span`,{className:`skill-row-name`,children:[e.name,r&&L(`span`,{className:`skill-link-tag${e.error?` is-bad`:``}`,children:r}),e.has_code&&L(`span`,{className:`skill-link-tag`,children:t(`settings.skills.link.tagCode`)}),e.verdict===`REVIEW`&&L(`span`,{className:`skill-link-tag`,children:t(`settings.skills.link.tagReview`)})]}),e.description&&L(`span`,{className:`skill-row-desc skill-link-desc`,dir:`auto`,title:e.description,children:L(`bdi`,{children:e.description})}),e.permissions.length>0?z(`span`,{className:`skill-link-perms`,children:[L(`span`,{className:`skill-link-perms-label`,children:t(`settings.skills.link.can`)}),L(`ul`,{"aria-label":t(`settings.skills.link.permsAria`,{name:e.name}),children:e.permissions.map(e=>z(`li`,{children:[L(`bdi`,{children:e.text}),` `,L(`bdi`,{dir:`ltr`,children:L(`code`,{children:e.grant})})]},e.grant))})]}):L(`span`,{className:`skill-link-perms`,children:t(e.permissions_unreadable?`settings.skills.link.permissionsUnreadable`:`settings.skills.link.noPermissions`)}),a&&z(`details`,{className:`skill-link-findings`,children:[L(`summary`,{children:t(`settings.skills.link.details`)}),i&&L(`p`,{children:L(`bdi`,{children:i})}),e.has_code&&!f&&L(`p`,{children:t(`settings.skills.link.shipsCode`)}),e.findings.length>0&&L(`ul`,{children:e.findings.map(e=>L(`li`,{children:L(`bdi`,{children:e})},e))})]})]})]})},e.path)})}),z(`div`,{className:`skill-link-actions`,children:[w&&z(`label`,{className:`skill-link-code`,title:t(`settings.skills.link.codeHint`),children:[L(`input`,{type:`checkbox`,checked:f,onChange:e=>x(e.target.checked)}),L(`span`,{children:t(`settings.skills.link.includeCode`)})]}),L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>l(null),disabled:i!==null,children:t(`settings.skills.link.cancel`)}),L(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void y(),disabled:u.size===0||i!==null,children:i===`add`?z(P.Fragment,{children:[L(Za,{size:13,className:`spin`}),` `,t(`settings.skills.link.adding`)]}):t(`settings.skills.link.add`,{n:u.size})})]})]}),m&&z(`div`,{className:`skill-link-result`,role:`status`,children:[m.added.length>0&&L(`p`,{children:NX(m,t)}),Object.keys(m.failed).length>0&&z(`details`,{children:[L(`summary`,{children:t(`settings.skills.link.notAdded`,{n:Object.keys(m.failed).length})}),L(`ul`,{className:`grant-list`,children:Object.entries(m.failed).map(([e,t])=>z(`li`,{children:[L(`bdi`,{children:L(`strong`,{children:e})}),` — `,L(`bdi`,{children:t})]},e))})]})]})]})}var FX={path:`~/.gaia/skills`},IX=[{source:`agent-bundled`,title:`settings.skills.bundled`,note:`settings.skills.bundledNote`},{source:`user`,title:`settings.skills.yours`,note:`settings.skills.yoursNote`,empty:`settings.skills.yoursEmpty`,params:FX},{source:`claude-project`,title:`settings.skills.project`,note:`settings.skills.projectNote`,params:{path:`.claude/skills`}},{source:`claude-import`,title:`settings.skills.import`,note:`settings.skills.importNote`}];function LX(e){return/description is \d+ characters/.test(e)?`settings.skills.skipped.tooLong`:/'description' is missing/.test(e)?`settings.skills.skipped.noDescription`:`settings.skills.skipped.other`}function RX({text:e}){let t=R(),n=(0,B.useRef)(null),[r,i]=(0,B.useState)(!1),[a,o]=(0,B.useState)(!1);return(0,B.useLayoutEffect)(()=>{let e=n.current;if(!e||r)return;let t=()=>o(e.scrollHeight>e.clientHeight+1);if(t(),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(t);return i.observe(e),()=>i.disconnect()},[e,r]),z(P.Fragment,{children:[L(`span`,{ref:n,className:`skill-row-desc${r?` is-open`:``}${a||r?` is-toggle`:``}`,dir:`auto`,onClick:a||r?()=>i(!r):void 0,children:L(`bdi`,{children:e})}),(a||r)&&L(`button`,{type:`button`,className:`skill-row-more`,"aria-expanded":r,onClick:()=>i(!r),children:t(r?`settings.skills.less`:`settings.skills.more`)})]})}function zX({onUseSkill:e}){let t=R(),[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)({}),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(``),u=(0,B.useRef)(null),d=(0,B.useRef)(!0),f=(0,B.useCallback)(()=>{Pn().then(e=>{d.current&&(r(e.skills),a(e.invalid),s(null))}).catch(e=>{d.current&&s(e instanceof Error?e.message:String(e))})},[]);(0,B.useEffect)(()=>(d.current=!0,f(),window.addEventListener(`focus`,f),()=>{d.current=!1,window.removeEventListener(`focus`,f)}),[f]);let p=c.trim().toLowerCase(),m=(n??[]).filter(e=>!p||e.name.toLowerCase().includes(p)||e.description.toLowerCase().includes(p)),h=n?.every(e=>IX.some(t=>t.source===e.source))??!1,g=n=>z(`li`,{className:`skill-row`,children:[z(`div`,{className:`skill-row-text`,children:[z(`span`,{className:`skill-row-name`,children:[L(`span`,{title:n.version?`v${n.version}`:void 0,children:n.name}),n.always_on&&z(`span`,{className:`skill-row-meta`,children:[` · `,t(`settings.skills.alwaysOn`)]})]}),L(RX,{text:n.description})]}),!n.always_on&&L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>e(n.name),"aria-label":t(`settings.skills.useAria`,{name:n.name}),children:t(`settings.skills.try`)})]},n.name);return z(`div`,{className:`settings-pane`,children:[L(`h2`,{className:`settings-pane-title`,children:t(`settings.section.skills`)}),L(`p`,{className:`settings-pane-lede`,children:t(`settings.skills.lede`)}),z(`details`,{className:`settings-more`,children:[z(`summary`,{children:[L($r,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,t(`settings.model.howItWorks`)]}),L(`p`,{className:`settings-hint`,children:t(`settings.skills.how`,FX)})]}),L(PX,{onAdded:f}),o&&L(`p`,{className:`settings-error`,role:`alert`,children:o}),!n&&!o&&z(`p`,{className:`settings-hint`,children:[L(Za,{size:13,className:`spin`}),` `,t(`settings.loading`)]}),n&&n.length>6&&L(`input`,{ref:u,className:`settings-input`,type:`search`,value:c,onChange:e=>l(e.target.value),placeholder:t(`settings.skills.search`),"aria-label":t(`settings.skills.search`)}),n&&n.length===0&&L(`p`,{className:`settings-hint`,children:t(`settings.skills.none`)}),p&&n&&n.length>0&&m.length===0&&z(`p`,{className:`settings-hint`,role:`status`,children:[t(`settings.skills.noMatch`,{query:c.trim()}),` `,L(`button`,{type:`button`,className:`link-btn`,onClick:()=>{l(``),u.current?.focus()},children:t(`settings.skills.clearSearch`)})]}),h?IX.map(e=>{let n=m.filter(t=>t.source===e.source);return n.length===0&&(p||!e.empty)?null:L(BY,{title:t(e.title),count:n.length,hint:t(e.note,e.params),defaultOpen:e.source===`agent-bundled`||e.source===`user`&&n.length>0,forceOpen:!!p,children:L(`section`,{"aria-label":t(e.title),children:n.length===0?L(`p`,{className:`settings-hint`,children:e.empty&&t(e.empty,e.params)}):L(`ul`,{className:`skill-list`,children:n.map(g)})})},e.source)}):L(`ul`,{className:`skill-list`,children:m.map(g)}),Object.keys(i).length>0&&z(`div`,{className:`settings-card`,role:`alert`,children:[L(`span`,{className:`settings-label`,children:t(`settings.skills.skipped`)}),L(`ul`,{className:`grant-list`,children:Object.entries(i).map(([e,n])=>L(`li`,{children:t(LX(n),{name:e.split(/[\\/]/).filter(Boolean).pop()??e})},e))})]})]})}var BX=`profile`;function VX(){let e=R(),[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(!1);(0,B.useEffect)(()=>{VG().then(n).catch(e=>i(e instanceof Error?e.message:String(e)))},[]);let l=(0,B.useCallback)(async e=>{o(!0),i(null),c(!1);try{let t=await HG(e===BX?null:e);n(t),c(t.changed!==!1)}catch(e){i(e instanceof Error?e.message:String(e)),await VG().then(n).catch(()=>void 0)}finally{o(!1)}},[]);if(!t)return r?L(`p`,{className:`settings-error`,role:`alert`,children:r}):z(`p`,{className:`settings-hint`,children:[L(Za,{size:13,className:`spin`}),` `,e(`settings.memory.embedder.checking`)]});let u=t.options.find(e=>e.device===t.device),d=t=>e.bare(t===`npu`?`settings.memory.embedder.npu`:`settings.memory.embedder.gpu`);return z(P.Fragment,{children:[z(`div`,{className:`model-in-use-field`,children:[L(`label`,{className:`settings-label`,htmlFor:`embedder-device`,children:e(`settings.memory.embedder.label`)}),z(`select`,{id:`embedder-device`,className:`settings-input`,value:t.chosen?t.device:BX,onChange:e=>void l(e.target.value),disabled:a,children:[L(`option`,{value:BX,children:e.bare(`settings.memory.embedder.default`,{device:d(t.default_device)})}),t.options.map(t=>L(`option`,{value:t.device,disabled:t.available===!1,children:t.present===!1?e.bare(`settings.memory.embedder.unavailable`,{device:d(t.device)}):t.proven?d(t.device):e.bare(`settings.memory.embedder.unproven`,{device:d(t.device)})},t.device))]})]}),z(`span`,{className:`settings-hint`,children:[e(`settings.memory.embedder.runsOn`,{name:Ae(u?.display_name??t.device,`ltr`),device:d(t.device)}),` `,e(`settings.memory.embedder.why`)]}),t.options.some(e=>e.device===`npu`&&!e.proven&&e.present)&&L(`span`,{className:`settings-hint`,children:e(`settings.memory.embedder.npuUnproven`)}),u?.downloaded===!1&&L(`span`,{className:`settings-hint`,children:e(`settings.memory.embedder.notDownloaded`)}),a&&z(`span`,{className:`settings-hint`,children:[L(Za,{size:13,className:`spin`}),` `,e(`settings.memory.embedder.applying`)]}),s&&L(`p`,{className:`settings-ok`,role:`status`,children:e(`settings.memory.embedder.changed`)}),r&&L(`p`,{className:`settings-error`,role:`alert`,children:r})]})}function HX(){let e=R(),t=N(e=>e.setShowMemoryDashboard),n=N(e=>e.closeSettings),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(null),[s,c]=(0,B.useState)(!1);(0,B.useEffect)(()=>{zG().then(i).catch(e=>o(e instanceof Error?e.message:String(e)))},[]);let l=(0,B.useCallback)(async()=>{if(r){c(!0),o(null);try{i(await BG({memory_enabled:!r.memory_enabled}))}catch(e){o(e instanceof Error?e.message:String(e))}finally{c(!1)}}},[r]);return z(`div`,{className:`settings-pane`,children:[L(`h2`,{className:`settings-pane-title`,children:e(`settings.section.memory`)}),L(`p`,{className:`settings-pane-lede`,children:e(`settings.memory.lede`)}),z(`section`,{className:`settings-card`,"aria-label":e(`settings.section.memory`),children:[z(`label`,{className:`setting-row`,children:[L(`span`,{children:e(`settings.memory.remember`)}),z(`span`,{className:`toggle-switch`,children:[L(`input`,{type:`checkbox`,checked:!!r?.memory_enabled,onChange:()=>void l(),disabled:!r||s,"aria-label":e(`settings.memory.remember`)}),L(`span`,{className:`toggle-track`})]})]}),a&&L(`p`,{className:`settings-error`,role:`alert`,children:a}),z(`div`,{className:`settings-row settings-row-between`,children:[L(`span`,{className:`settings-hint`,children:e(`settings.memory.dashboardHint`)}),L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{n(),t(!0)},children:e(`settings.memory.dashboard`)})]})]}),L(`section`,{className:`settings-card`,"aria-label":e(`settings.memory.embedder.label`),children:L(VX,{})})]})}function UX(e,t,n){if(!/^\d+$/.test(e.trim()))return!1;let r=Number(e);return r>=t&&r<=n}function WX(e){return e<1048576?`${Math.ceil(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function GX(){let e=R(),[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)(``),[a,o]=(0,B.useState)(``),[s,c]=(0,B.useState)(null),[l,u]=(0,B.useState)(!1);(0,B.useEffect)(()=>{lt().then(e=>{n(e),i(String(e.retention_days)),o(String(e.max_mb))},t=>c({ok:!1,text:e(`settings.undo.readFailed`,{reason:t instanceof Error?t.message:String(t)})}))},[e]);let[d,f]=(0,B.useState)({days:!1,mb:!1}),p=!UX(r,1,365)||d.days,m=!UX(a,10,1e5)||d.mb,h=t!==null&&(r!==String(t.retention_days)||a!==String(t.max_mb)),g=async()=>{if(!(p||m)){u(!0),c(null);try{let t=await je(Number(r),Number(a));n(t),c({ok:!0,text:e(`settings.undo.saved`)})}catch(t){let n=t instanceof Vn&&t.httpStatus===422?t.fields:[],r=n.includes(`retention_days`),i=n.includes(`max_mb`);r||i?(f({days:r,mb:i}),c({ok:!1,text:e(`settings.undo.fix`)})):c({ok:!1,text:t instanceof Error?t.message:String(t)})}finally{u(!1)}}};return z(`div`,{className:`settings-field`,"aria-label":e(`settings.privacy.undo`),children:[L(`span`,{className:`settings-label`,children:e(`settings.privacy.undo`)}),L(`p`,{className:`settings-hint`,children:e(`settings.undo.hint`)}),t&&z(P.Fragment,{children:[z(`div`,{className:`setting-row`,children:[L(`label`,{htmlFor:`undo-days`,children:e(`settings.undo.days`)}),L(`input`,{id:`undo-days`,type:`number`,className:`model-input undo-history-input`,min:1,max:365,value:r,"aria-invalid":p,"aria-describedby":p?`undo-days-error`:void 0,onChange:e=>{i(e.target.value),f(e=>({...e,days:!1}))}})]}),p&&L(`p`,{id:`undo-days-error`,className:`settings-error`,children:e(`settings.undo.daysError`)}),z(`div`,{className:`setting-row`,children:[L(`label`,{htmlFor:`undo-mb`,children:e(`settings.undo.mb`)}),L(`input`,{id:`undo-mb`,type:`number`,className:`model-input undo-history-input`,min:10,max:1e5,value:a,"aria-invalid":m,"aria-describedby":m?`undo-mb-error`:void 0,onChange:e=>{o(e.target.value),f(e=>({...e,mb:!1}))}})]}),m&&L(`p`,{id:`undo-mb-error`,className:`settings-error`,children:e(`settings.undo.mbError`)}),z(`div`,{className:`setting-row setting-row-path`,children:[L(`span`,{children:e(`settings.undo.inUse`)}),z(`span`,{children:[e.plural(`settings.undo.used`,t.turns,{size:WX(t.used_bytes)}),` `,L(`bdi`,{dir:`ltr`,children:L(`code`,{className:`setting-path`,children:t.path})})]})]}),L(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void g(),disabled:!h||l||p||m,children:e(l?`settings.models.applying`:`settings.advanced.save`)})]}),s&&L(`p`,{className:s.ok?`settings-ok`:`settings-error`,role:s.ok?`status`:`alert`,children:s.text})]})}var KX={root:`settings-report`,button:`btn-secondary`,hint:`settings-hint`,error:`settings-error`};function qX(){let e=R(),t=N(e=>e.sessions),n=N(e=>e.removeSession),r=qc(),i=N(e=>e.systemStatus?.data_dir),[a,o]=(0,B.useState)(null),[s,c]=(0,B.useState)(!1),[l,u]=(0,B.useState)(null),[d,f]=(0,B.useState)(null),[p,m]=(0,B.useState)(!1),[h,g]=(0,B.useState)(null);(0,B.useEffect)(()=>{let e=!0;return de().then(t=>{e&&f(t.network_policy===`local_ai_only`)}).catch(t=>{e&&g({ok:!1,text:t instanceof Error?t.message:String(t)})}),()=>{e=!1}},[]);let _=(0,B.useCallback)(async()=>{if(d===null||p)return;let t=d,n=zc.getState().active?.model,r=!t;f(r),m(!0),g(null);try{let t=await pe({network_policy:r?`local_ai_only`:`cloud_allowed`});f(t.network_policy===`local_ai_only`),Bc(n);let i=t.policy_notices??[],a=i.some(e=>e.severity===`warning`),o=i.length?i.map(t=>t.code===`users_server_keeps_keys`?e(`settings.privacy.usersServerKeepsKeys`,{url:t.url??``}):t.code===`runtime_keys_not_dropped`?e(`settings.privacy.runtimeKeysNotDropped`,{reason:t.reason??``}):t.code===`saved_models_not_checked`&&t.cause===`model_server_down`&&t.models?.length?e.plural(`settings.privacy.savedModelNotCheckedServerDown`,t.models.length,{models:t.models.join(`, `)}):t.code===`saved_models_not_checked`?e(`settings.privacy.savedModelsNotChecked`,{reason:t.reason??``}):e(`settings.privacy.policyNoticeUnknown`)).join(` `):e(r?`settings.privacy.localOnlyOn`:`settings.privacy.localOnlyOff`);g({ok:!a,text:o})}catch(e){f(t),g({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{m(!1)}},[d,p,e]),v=(0,B.useCallback)(async t=>{try{await Ft(t,!1)}catch(t){u({ok:!1,text:e(`settings.privacy.openFolderFailed`,{reason:t instanceof Error?t.message:String(t)})})}},[e]),y=(0,B.useCallback)(async()=>{c(!0);let r=[];for(let e of t)try{await rr(e.id),n(e.id)}catch(t){r.push(`${e.title}: ${t instanceof Error?t.message:t}`)}c(!1),o(null),u(r.length?{ok:!1,text:e(`settings.privacy.deleteFailed`,{n:r.length,reason:r.join(`; `)})}:{ok:!0,text:e(`settings.privacy.deleted`)})},[n,t,e]);return z(`div`,{className:`settings-pane`,children:[L(`h2`,{className:`settings-pane-title`,children:e(`settings.section.privacy`)}),z(`section`,{className:`settings-card`,"aria-label":e(`settings.privacy.localOnlyTitle`),children:[z(`div`,{children:[z(`label`,{className:`setting-row`,children:[L(`strong`,{children:e(`settings.privacy.localOnlyTitle`)}),z(`span`,{className:`toggle-switch`,children:[L(`input`,{type:`checkbox`,role:`switch`,checked:d===!0,"aria-label":e(`settings.privacy.localOnlyTitle`),"aria-describedby":`privacy-local-only-hint`,onChange:()=>void _(),disabled:d===null,"aria-busy":p}),L(`span`,{className:`toggle-track`})]})]}),L(`p`,{className:`settings-hint`,id:`privacy-local-only-hint`,children:e(`settings.privacy.localOnlyHint`)})]}),h&&L(`p`,{className:h.ok?`settings-ok`:`settings-error`,role:h.ok?`status`:`alert`,children:h.text})]}),z(`section`,{className:`settings-card`,"aria-labelledby":`privacy-where-title`,children:[L(`h3`,{className:`settings-label`,id:`privacy-where-title`,children:e(`settings.privacy.whereTitle`)}),L(`p`,{className:`settings-note`,children:e(`settings.privacy.stays`)}),L(`p`,{className:r?.remote?`settings-note`:`settings-hint`,children:r?.remote?e(`settings.privacy.remote`,{name:r.label}):e(r?`settings.privacy.local`:`settings.privacy.unknown`)}),i&&z(`div`,{className:`setting-row setting-row-path`,children:[L(`span`,{children:e(`settings.privacy.dataFolder`)}),z(`span`,{className:`setting-path-actions`,children:[L(`bdi`,{dir:`ltr`,className:`setting-path`,children:i}),L(`button`,{type:`button`,className:`link-btn`,onClick:()=>void v(i),children:e(`settings.privacy.openFolder`)})]})]})]}),z(`section`,{className:`settings-card`,"aria-labelledby":`privacy-report-title`,children:[L(`h3`,{className:`settings-label`,id:`privacy-report-title`,children:e(`settings.privacy.reportTitle`)}),L(`p`,{className:`settings-note`,children:e(`settings.privacy.reportNote`)}),L(oP,{classes:KX})]}),L(BY,{title:e(`settings.privacy.undo`),children:L(GX,{})}),z(`section`,{className:`settings-card`,"aria-labelledby":`privacy-delete-title`,children:[L(`h3`,{className:`settings-label`,id:`privacy-delete-title`,children:e(`settings.privacy.deleteTitle`)}),L(`p`,{className:`danger-warning`,children:t.length===0?e(`settings.privacy.nothingToDelete`):e(`settings.privacy.deleteWarning`)}),L(`button`,{type:`button`,className:`btn-danger`,onClick:()=>{u(null),o(t.length)},disabled:t.length===0,children:e(`settings.privacy.delete`)})]}),a!==null&&z(Vq,{title:e.plural(`settings.privacy.deleteAsk`,a),confirmLabel:e.plural(`settings.privacy.deleteYes`,a),cancelLabel:e(`settings.privacy.deleteCancel`),onConfirm:()=>void y(),onCancel:()=>o(null),danger:!0,busy:s,children:[L(`p`,{children:e(`settings.privacy.deleteWarning`)}),L(`p`,{children:e(`settings.privacy.deleteFinal`)})]}),l&&L(`p`,{className:l.ok?`settings-ok`:`settings-error`,role:l.ok?`status`:`alert`,children:l.text})]})}var JX=[{id:`needs_approval`,label:`settings.alerts.approval`},{id:`question`,label:`settings.alerts.question`},{id:`finished`,label:`settings.alerts.finished`}],YX=[{value:`banner`,label:`settings.alerts.banner`},{value:`badge`,label:`settings.alerts.badge`},{value:`off`,label:`settings.alerts.off`}],XX=[0,10,20,30,50];function ZX(){return typeof Notification>`u`?`unsupported`:Notification.permission}function QX(){let e=R(),t=Zl(),n=!!window.gaiaAPI,[r,i]=(0,B.useState)(ZX),a=Object.values(t.modes).includes(`banner`);return z(`div`,{className:`settings-pane`,children:[L(`h2`,{className:`settings-pane-title`,children:e(`settings.section.notifications`)}),L(`p`,{className:`settings-pane-lede`,children:e(`settings.alerts.lede`)}),z(`section`,{className:`settings-card`,"aria-label":e(`settings.alerts.when`),children:[JX.map(n=>z(`div`,{className:`setting-row`,children:[L(`span`,{id:`alert-${n.id}`,children:e(n.label)}),L(jB,{className:`segmented`,"aria-labelledby":`alert-${n.id}`,children:YX.map(r=>L(`button`,{type:`button`,role:`radio`,"aria-checked":t.modes[n.id]===r.value,className:t.modes[n.id]===r.value?`is-active`:``,onClick:()=>t.setMode(n.id,r.value),children:e(r.label)},r.value))})]},n.id)),!n&&a&&r!==`granted`&&(r==="default"?L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{Notification.requestPermission().then(i).catch(e=>{console.error(`[alerts] Notification permission request failed`,e),i(ZX())})},children:e(`settings.alerts.allow`)}):L(`p`,{className:`settings-error`,role:`alert`,children:e(r===`unsupported`?`settings.alerts.unsupported`:`settings.alerts.blocked`)})),z(`label`,{className:`setting-row`,children:[L(`span`,{children:e(`settings.alerts.sound`)}),z(`span`,{className:`toggle-switch`,children:[L(`input`,{type:`checkbox`,checked:t.sound,onChange:()=>t.update({sound:!t.sound}),"aria-label":e(`settings.alerts.sound`)}),L(`span`,{className:`toggle-track`})]})]}),n&&z(`label`,{className:`setting-row`,children:[L(`span`,{children:e(`settings.alerts.flash`)}),z(`span`,{className:`toggle-switch`,children:[L(`input`,{type:`checkbox`,checked:t.flash,onChange:()=>t.update({flash:!t.flash}),"aria-label":e(`settings.alerts.flash`)}),L(`span`,{className:`toggle-track`})]})]})]}),z(`section`,{className:`settings-card`,"aria-labelledby":`keep-awake-title`,children:[L(`h3`,{className:`settings-label`,id:`keep-awake-title`,children:e(`settings.alerts.keepAwakeTitle`)}),n?z(P.Fragment,{children:[z(`label`,{className:`setting-row`,children:[L(`span`,{children:e(`settings.alerts.keepAwake`)}),z(`span`,{className:`toggle-switch`,children:[L(`input`,{type:`checkbox`,checked:t.keepAwake,onChange:()=>t.update({keepAwake:!t.keepAwake}),"aria-label":e(`settings.alerts.keepAwake`)}),L(`span`,{className:`toggle-track`})]})]}),z(`div`,{className:`setting-row`,children:[L(`label`,{htmlFor:`battery-floor`,children:e(`settings.alerts.battery`)}),L(`select`,{id:`battery-floor`,className:`settings-input settings-select-compact`,value:t.batteryFloor,disabled:!t.keepAwake,onChange:e=>t.update({batteryFloor:Number(e.target.value)}),children:XX.map(t=>L(`option`,{value:t,children:t===0?e.bare(`settings.alerts.never`):`${t}%`},t))})]}),L(`p`,{className:`settings-hint`,children:e(`settings.alerts.screen`)})]}):L(`p`,{className:`settings-hint`,children:e(`settings.alerts.desktopOnly`)})]})]})}var $X=[50,75,100,125,150,175,200],eZ=[{accent:`american`,gender:`female`},{accent:`american`,gender:`male`},{accent:`british`,gender:`female`},{accent:`british`,gender:`male`}],tZ=`settings:preview`,nZ=`Hello, I'm GAIA. This is how I'll read my replies to you.`;function rZ(e){return e instanceof Vn?e.detail||e.message:String(e)}function iZ(){let e=R(),t=BN(e=>e.settings),n=BN(e=>e.setSettings),r=BN(e=>e.read),i=BN(e=>e.stop),a=BN(e=>e.messageId===tZ),o=BN(e=>e.messageId===tZ&&e.status===`loading`),[s,c]=(0,B.useState)(null),[l,u]=(0,B.useState)(null),[d,f]=(0,B.useState)(!1);(0,B.useEffect)(()=>{DN().then(n).catch(e=>c(rZ(e)))},[n]);let p=e=>{f(!0),u(null),BN.getState().messageId===tZ&&i(),ON(e).then(n).catch(e=>u(rZ(e))).finally(()=>f(!1))};return s?z(`div`,{className:`settings-pane`,children:[L(`h2`,{className:`settings-pane-title`,children:e(`settings.section.voice`)}),L(`p`,{className:`settings-error`,role:`alert`,children:e(`readAloud.settings.loadFailed`,{reason:s})})]}):t?z(`div`,{className:`settings-pane`,children:[L(`h2`,{className:`settings-pane-title`,children:e(`settings.section.voice`)}),L(`p`,{className:`settings-pane-lede`,children:e(`readAloud.settings.lede`)}),z(`div`,{className:`settings-field`,children:[L(`label`,{className:`settings-label`,htmlFor:`read-aloud-voice`,children:e(`readAloud.settings.voice`)}),z(`div`,{className:`read-aloud-voice-row`,children:[L(`select`,{id:`read-aloud-voice`,className:`settings-input`,value:t.voice,disabled:d,onChange:e=>p({voice:e.target.value}),children:eZ.map(n=>L(`optgroup`,{label:e(`readAloud.group.${n.accent}.${n.gender}`),children:t.voices.filter(e=>e.accent===n.accent&&e.gender===n.gender).map(e=>L(`option`,{value:e.id,lang:`en`,children:e.name},e.id))},`${n.accent}-${n.gender}`))}),z(`button`,{type:`button`,className:`btn-secondary`,"aria-pressed":a,disabled:d,onClick:()=>a?i():void r(tZ,nZ),children:[o?L(Za,{size:13,className:`spin`}):L(a?Is:Xs,{size:13}),e(a?`readAloud.stop`:`readAloud.settings.preview`)]})]}),L(`span`,{className:`settings-hint`,children:e(`readAloud.settings.englishOnly`)}),L(UN,{messageId:tZ})]}),z(`div`,{className:`settings-field`,children:[L(`label`,{className:`settings-label`,htmlFor:`read-aloud-speed`,children:e(`readAloud.settings.speed`)}),L(`select`,{id:`read-aloud-speed`,className:`settings-input`,value:t.speed,disabled:d,onChange:e=>p({speed:Number(e.target.value)}),children:($X.includes(t.speed)?$X:[...$X,t.speed].sort((e,t)=>e-t)).map(t=>L(`option`,{value:t,children:t===100?e.bare(`readAloud.settings.normalSpeed`):`${(t/100).toLocaleString(e.locale)}×`},t))})]}),z(`label`,{className:`setting-row`,children:[L(`span`,{children:e(`readAloud.settings.auto`)}),z(`span`,{className:`toggle-switch`,children:[L(`input`,{type:`checkbox`,checked:t.auto,disabled:d,onChange:()=>p({auto:!t.auto}),"aria-label":e(`readAloud.settings.auto`)}),L(`span`,{className:`toggle-track`})]})]}),L(`p`,{className:`settings-hint`,children:e(`readAloud.settings.shared`)}),l&&L(`p`,{className:`settings-error`,role:`alert`,children:e(`readAloud.settings.saveFailed`,{reason:l})})]}):z(`p`,{className:`settings-hint`,children:[L(Za,{size:13,className:`spin`}),` `,e(`settings.loading`)]})}function aZ(){let e=R(),t=N(e=>e.jumpToSetting),n=N(e=>e.closeSettings),r=N(e=>e.runSetupAgain),i=zc(e=>e.active),a=N(e=>e.systemStatus?.lemonade_running===!1),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(null),[u,d]=(0,B.useState)(null),[f,p]=(0,B.useState)(null),[m,h]=(0,B.useState)(null),[g,_]=(0,B.useState)(!1);(0,B.useEffect)(()=>{En().then(s).catch(e=>h(e instanceof Error?e.message:String(e))),ue().then(l).catch(e=>h(e instanceof Error?e.message:String(e))),Xe().then(e=>d(e??null)).catch(e=>p(e instanceof Error?e.message:String(e)))},[]);let v=o?.catalog?.find(e=>e.id===o.chat_model.id),y=(i?.model?i.remote?i.label??Uc(i.model):Uc(i.model):null)??v?.name??null,b=(o?.catalog??[]).filter(e=>e.downloaded),x=b.reduce((e,t)=>e+(t.full_size_gb??0),0),S=[c?.gpu_name,c?.npu_detected?e(`setup.checks.npu`):null].filter(Boolean).join(` · `),C=wk(o?.system?.physical_memory,c?.ram_gb),w=C&&Ok(e.locale,C),T=o?.capacity_gb==null?null:Ok(e.locale,Sk(o.capacity_gb)),E=T?w?e(`settings.setup.memoryOf`,{size:T,total:w}):e(`settings.setup.memoryFor`,{size:T}):w,D=[{title:e(`settings.setup.where`),rows:[{label:e(`settings.setup.chatRuns`),value:y,section:`model`,target:`.model-in-use`},{label:e(`settings.setup.cloudKeys`),value:null,section:`model`,target:`[data-settings-target="cloud-key"]`,provider:`fireworks`}]},{title:e(`setup.pc.step`),rows:[{label:e(`settings.setup.detected`),value:[S,E].filter(Boolean).join(` · `)||null},{label:e(`settings.setup.server`),value:o?.lemonade.mode===`external`?e(`settings.setup.serverYours`):e(`settings.setup.serverOwn`),section:`advanced`,target:`[data-settings-target="model-server"]`},{label:e(`setup.gpu.title`),value:null,section:`model`,target:`#settings-gpu-title`,provider:`local`,shown:!!u?.applies||!!f&&!nX(f)}]},{title:e(`setup.models.step`),rows:[{label:e(`settings.setup.models`),value:o?.catalog?e(`settings.setup.modelsValue`,{n:String(b.length),size:Sk(x)}):null,section:`model`,target:`[data-settings-target="models-on-pc"]`,provider:`local`},{label:e(`settings.setup.context`),value:null,section:`model`,target:`#ctx-size`,shown:!!i?.model&&!i.remote&&i.downloaded!==!1}]},{title:e(`settings.setup.after`),rows:[{label:e(`settings.section.connectors`),value:null,section:`connectors`},{label:e(`settings.section.memory`),value:null,section:`memory`},{label:e(`settings.language`),value:null,section:`general`,target:`#ui-language`},{label:e(`settings.setup.signIn`),value:null,section:`general`,target:`#desktop-startOnLogin`,shown:!!window.gaiaAPI?.tray}]}];return z(`div`,{className:`settings-pane`,children:[L(`h2`,{className:`settings-pane-title`,children:e(`settings.section.setup`)}),L(`p`,{className:`settings-hint`,children:e(`settings.setup.lede`)}),z(`div`,{className:`settings-setup-status`,children:[z(`span`,{children:[L(`strong`,{children:e(a?`settings.setup.serverDown`:`settings.setup.ready`)}),y&&!a&&z(`span`,{className:`settings-hint`,children:[` `,L(`bdi`,{children:e(`settings.setup.running`,{name:y})})]})]}),L(`button`,{type:`button`,className:`btn-secondary`,"data-testid":`setup-run-again`,onClick:()=>_(!0),children:e(`settings.setup.runAgain`)})]}),m&&L(`p`,{className:`setup-error`,role:`alert`,children:m}),D.map(e=>z(`section`,{className:`settings-setup-group`,"aria-label":e.title,children:[L(`h3`,{className:`settings-label`,children:e.title}),e.rows.filter(e=>e.shown!==!1).map(e=>{let n=z(`span`,{children:[L(`span`,{className:`settings-setup-row-label`,children:e.label}),e.value&&L(`bdi`,{className:`settings-hint settings-setup-row-value`,children:e.value})]}),r=e.section;return r?z(`button`,{type:`button`,className:`settings-setup-row`,onClick:()=>t({section:r,target:e.target??`.settings-pane-title`,from:`setup`},e.provider),children:[n,L(ri,{size:14,className:`settings-setup-chevron`,"aria-hidden":`true`})]},e.label):L(`div`,{className:`settings-setup-row is-fact`,children:n},e.label)})]},e.title)),g&&L(Vq,{title:e(`settings.setup.confirmTitle`),confirmLabel:e(`settings.setup.confirmYes`),cancelLabel:e(`setup.again.notNow`),onConfirm:()=>{_(!1),n(),r(!0)},onCancel:()=>_(!1),children:L(`p`,{children:e(`settings.setup.confirmBody`)})})]})}var oZ=[{label:`settings.about.whatsNew`,href:`https://github.com/amd/gaia/releases`},{label:`settings.about.docs`,href:`https://amd-gaia.ai/docs/guides/agent-ui`},{label:`settings.about.report`,href:`https://github.com/amd/gaia/issues/new/choose`},{label:`settings.about.license`,href:`https://github.com/amd/gaia/blob/main/LICENSE.md`}];function sZ(){let e=R(),t=N(e=>e.openSettings),n=`GAIA v0.27.0rc7`,[r,i]=(0,B.useState)(!1),[a,o]=(0,B.useState)(null),s=(0,B.useRef)(null);(0,B.useEffect)(()=>()=>{s.current&&clearTimeout(s.current)},[]);let c=(0,B.useCallback)(async()=>{o(null);try{await navigator.clipboard.writeText(n),i(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>i(!1),2e3)}catch(t){o(e(`settings.about.copyFailed`,{reason:t instanceof Error?t.message:String(t)}))}},[e,n]);return z(`div`,{className:`settings-pane`,children:[L(`h2`,{className:`settings-pane-title`,children:e(`settings.section.about`)}),z(`section`,{className:`settings-card`,"aria-labelledby":`about-version`,children:[z(`div`,{className:`settings-row settings-row-between`,children:[z(`span`,{children:[L(`strong`,{id:`about-version`,children:L(`bdi`,{dir:`ltr`,children:n})}),` `,L(`span`,{className:`beta-badge`,children:`BETA`})]}),z(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void c(),children:[L(r?Yr:Ti,{size:13,"aria-hidden":`true`}),e(r?`settings.about.copied`:`settings.about.copy`)]})]}),L(`p`,{className:`settings-hint`,children:e(`settings.advanced.about`)}),a&&L(`p`,{className:`settings-error`,role:`alert`,children:a})]}),z(`section`,{className:`settings-card`,"aria-label":e(`settings.about.links`),children:[L(`ul`,{className:`settings-about-links`,children:oZ.map(t=>L(`li`,{children:z(`a`,{href:t.href,target:`_blank`,rel:`noopener noreferrer`,children:[e(t.label),` `,L(Ui,{size:12,"aria-hidden":`true`})]})},t.href))}),z(`p`,{className:`settings-hint`,children:[e(`settings.about.reportHint`),` `,L(`button`,{type:`button`,className:`link-btn`,onClick:()=>t(`privacy`),children:e(`settings.about.reportWhere`)})]})]})]})}var cZ=class extends B.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidUpdate(e){this.state.hasError&&e.resetKey!==this.props.resetKey&&this.setState({hasError:!1})}componentDidCatch(e,t){console.error(`[ErrorBoundary] ${this.props.area} failed to render:`,e,t.componentStack)}render(){return this.state.hasError?L(lZ,{variant:this.props.variant??`fill`,onRetry:()=>this.setState({hasError:!1})}):this.props.children}};function lZ({onRetry:e,variant:t}){let n=R();return z(`div`,{role:`alert`,className:`error-boundary error-boundary-${t}`,children:[L(`p`,{className:`error-boundary-title`,children:n(`errorBoundary.title`)}),L(`p`,{className:`error-boundary-body`,children:n(t===`window`?`errorBoundary.bodyWindow`:`errorBoundary.body`)}),z(`div`,{className:`error-boundary-actions`,children:[L(`button`,{type:`button`,className:`btn-primary`,onClick:e,children:n(`errorBoundary.retry`)}),L(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>window.location.reload(),children:n(`errorBoundary.reload`)})]})]})}var uZ=`modulepreload`,dZ=function(e,t){return new URL(e,t).href},fZ={},pZ=function(e){return e.pathname.endsWith(`.css`)},mZ=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},hZ=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=dZ(t,n);let r=s(t),i=pZ(r);return mZ(fZ,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:uZ,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{let i=a=>{t.removeEventListener(`load`,i),t.removeEventListener(`error`,i),a.type===`error`?n(Error(`Unable to preload CSS for ${r}`)):e(a)};t.addEventListener(`load`,i),t.addEventListener(`error`,i)})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},gZ=(0,B.lazy)(()=>hZ(()=>import(`./ConnectorsPane-Dfw_U1zK.js`).then(e=>({default:e.ConnectorsPane})),__vite__mapDeps([0,1,2,3]),import.meta.url)),_Z=(0,B.lazy)(()=>hZ(()=>import(`./MessagingSettings-DVdUqQ1T.js`).then(e=>({default:e.MessagingSettings})),__vite__mapDeps([4,1,2]),import.meta.url)),vZ=(0,B.lazy)(()=>hZ(()=>import(`./AutomationsSettings-BhcaMHRu.js`).then(e=>({default:e.AutomationsSettings})),__vite__mapDeps([5,1,2]),import.meta.url)),yZ=(0,B.lazy)(()=>hZ(()=>import(`./AdvancedSettings-Biw1bDji.js`).then(e=>({default:e.AdvancedSettings})),__vite__mapDeps([6,1,2]),import.meta.url)),bZ=[`general`,`setup`,`model`,`images`,`permissions`,`skills`,`connectors`,`messaging`,`automations`,`memory`,`notifications`,`voice`,`privacy`,`advanced`,`about`];function xZ({onUseSkill:e}){let t=R(),n=N(e=>e.settingsSection),r=N(e=>e.openSettings),i=N(e=>e.closeSettings),a=N(e=>e.settingsJump),o=(0,B.useRef)(null),s=(0,B.useRef)(null),c=n!==null;if(ut(c,i),un(o,c),xK(o,c,()=>o.current?.querySelector(`.settings-nav-item.is-active`)),(0,B.useLayoutEffect)(()=>{s.current&&(s.current.scrollTop=0)},[n]),(0,B.useEffect)(()=>{let e=s.current;if(!a||a.section!==n||!e)return;o.current?.querySelector(`[data-section="${n}"]`)?.focus();let t,r=null,i=()=>r?.scrollIntoView({block:`start`}),c=typeof ResizeObserver>`u`?null:new ResizeObserver(i),l=()=>c?.disconnect(),u=[`wheel`,`touchstart`,`pointerdown`,`keydown`],d=()=>{let n=e.querySelector(a.target);if(!n||n.disabled)return!1;for(let e=n.closest(`details`);e;e=e.parentElement?.closest(`details`)??null)e.open=!0;r=n.closest(`.model-in-use-field, .settings-field, details, .settings-card`)??n,r.classList.add(`settings-target-hit`),i();let o=n instanceof HTMLDetailsElement?n.querySelector(`summary`):n.closest(`summary`)??n;o&&(o.matches(`summary, button, input, select, textarea, a[href], [tabindex]`)||(o.tabIndex=-1),o.focus({preventScroll:!0}));let s=n.closest(`.settings-pane`);return s&&c?.observe(s),t=setTimeout(()=>r?.classList.remove(`settings-target-hit`),1600),!0},f=new MutationObserver(()=>{d()&&f.disconnect()});d()||f.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`disabled`]}),u.forEach(t=>e.addEventListener(t,l,{passive:!0}));let p=setTimeout(()=>f.disconnect(),5e3);return()=>{f.disconnect(),l(),u.forEach(t=>e.removeEventListener(t,l)),clearTimeout(p),clearTimeout(t)}},[a,n]),!n)return null;let l=a&&a.section===n?a.from:void 0,u=e=>{let t=bZ.indexOf(n),i=e.key===`ArrowDown`?(t+1)%bZ.length:e.key===`ArrowUp`?(t-1+bZ.length)%bZ.length:e.key===`Home`?0:e.key===`End`?bZ.length-1:null;i!==null&&(e.preventDefault(),r(bZ[i]),o.current?.querySelector(`[data-section="${bZ[i]}"]`)?.focus())},d=(()=>{switch(n){case`general`:return L(tX,{});case`setup`:return L(aZ,{});case`model`:return L(wX,{});case`images`:return L(AX,{});case`permissions`:return L(jX,{});case`skills`:return L(zX,{onUseSkill:t=>{i(),e(t)}});case`connectors`:return L(gZ,{});case`messaging`:return L(_Z,{});case`automations`:return L(vZ,{});case`memory`:return L(HX,{});case`notifications`:return L(QX,{});case`voice`:return L(iZ,{});case`privacy`:return L(qX,{});case`advanced`:return L(yZ,{});case`about`:return L(sZ,{})}})();return L(`div`,{className:`settings-overlay`,onMouseDown:e=>{e.target===e.currentTarget&&i()},children:z(`div`,{ref:o,className:`settings-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`settings.title`),children:[z(`nav`,{className:`settings-nav`,"aria-label":t(`settings.sections`),onKeyDown:u,children:[L(`h1`,{className:`settings-nav-title`,children:t(`settings.title`)}),bZ.map(e=>L(`button`,{type:`button`,"data-section":e,className:`settings-nav-item${n===e?` is-active`:``}`,"aria-current":n===e?`page`:void 0,tabIndex:n===e?0:-1,onClick:t=>{t.currentTarget.focus(),r(e)},children:t(`settings.section.${e}`)},e))]}),z(`div`,{className:`settings-body`,children:[L(`button`,{type:`button`,className:`settings-close`,onClick:i,"aria-label":t(`settings.close`),children:L(nc,{size:18})}),l&&z(`button`,{type:`button`,className:`settings-back`,onClick:()=>{r(l),o.current?.querySelector(`[data-section="${l}"]`)?.focus()},children:[L(ti,{size:14,"aria-hidden":`true`}),t.compose(e=>e(`settings.backTo`,{section:e(`settings.section.${l}`)}))]}),L(`div`,{ref:s,className:`settings-scroll`,children:L(cZ,{area:`settings.${n}`,children:L(B.Suspense,{fallback:z(`p`,{className:`settings-hint`,children:[L(Za,{size:13,className:`spin`}),` `,t(`settings.loading`)]}),children:d})},n)})]})]})})}var SZ=`gaia:personalize-connector`,CZ=[[`google`,`my last two weeks of Gmail (and Google Calendar, if it is connected)`],[`microsoft`,`my last two weeks of Outlook mail (and calendar, if it is connected)`],[`slack`,`my recent Slack channels and direct messages`],[`github`,`my recent GitHub activity: open PRs, review requests, issues and notifications`]];function wZ(e,t){let n=e.toLowerCase().replace(/^mcp-/,``),r=CZ.find(([e])=>n.startsWith(e));return r?r[1]:`my recent activity in ${t}`}function TZ(e){let t=e.toLowerCase().replace(/^mcp-/,``),n=CZ.find(([e])=>t.startsWith(e));return n?n[0]:null}function EZ({connectorId:e,displayName:t}){return[`I just connected ${t}. Get to know me from ${wZ(e,t)}.`,`Read only — do not send, delete, label or change anything.`,`If you have no tools that read it, or they fail, tell me you couldn't reach it and stop. Never guess or count what it holds.`,`1. Skim the recent items and work out who I deal with most, what I work on, recurring meetings or threads, and what keeps landing on my plate.`,`2. Save the durable facts to memory (people, projects, preferences, routines). Skip one-off details and anything sensitive like passwords, codes or financial numbers.`,`3. Recommend up to five automations you could run for me on a schedule, each with what it does, how often, and why it fits what you saw.`,`Don't create any schedules yet — tell me what you saved and list the automations so I can pick which to set up.`].join(`
|
|
214
|
+
`)}function DZ(e){window.dispatchEvent(new CustomEvent(SZ,{detail:e}))}var OZ=Pt((e,t)=>({lifecycle:null,restartError:null,apply:n=>{n.apiBase&&Tt(n.apiBase),e({lifecycle:n,restartError:n.status===`running`?null:t().restartError})},restart:async()=>{let n=window.gaiaAPI?.backend;if(!n)throw Error(`Restart GAIA needs the desktop app.`);e({restartError:null});try{t().apply(await n.restart())}catch(t){F.system.error(`Restart GAIA failed`,t),e({restartError:t instanceof Error?t.message:String(t)})}}}));function kZ(){let e=window.gaiaAPI?.backend;e&&e.getState().then(e=>OZ.getState().apply(e)).catch(e=>F.system.error(`Could not read the backend state from the desktop app`,e))}function AZ(e){let t=window.gaiaAPI?.backend;if(!t)return()=>{};let n=t=>{let n=OZ.getState().lifecycle?.status;OZ.getState().apply(t),t.status===`running`&&n&&n!==`running`&&e()},r=t.onState(n);return t.getState().then(n).catch(e=>F.system.error(`Could not read the backend state from the desktop app`,e)),r}function jZ(e,t){let[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(null),c=(0,B.useRef)(null),l=(0,B.useRef)(null),u=(0,B.useRef)(null),d=(0,B.useCallback)(()=>{c.current&&=(clearTimeout(c.current),null),l.current&&=(clearTimeout(l.current),null),u.current&&=(clearInterval(u.current),null)},[]);(0,B.useEffect)(()=>d,[d]);let f=(0,B.useCallback)((e,t)=>{u.current&&clearInterval(u.current),u.current=setInterval(async()=>{try{let n=await se();t===`load`?Hc(n.model_loaded,e)&&(r(!1),c.current&&=(clearTimeout(c.current),null),u.current&&=(clearInterval(u.current),null)):(n.model_downloaded===!0||Hc(n.model_loaded,e))&&(a(!1),l.current&&=(clearTimeout(l.current),null),u.current&&=(clearInterval(u.current),null))}catch{}},Tu)},[]),m=e??`Gemma-4-E4B-it-GGUF`;return(0,B.useEffect)(()=>s(null),[m]),{isLoadingModel:n,isDownloadingModel:i,downloadError:o,loadModel:(0,B.useCallback)(async(e,n)=>{let i=e??m,a=n??t;r(!0);try{if(!await tn(i,a)){r(!1);return}F.system.info(`Load model triggered: ${i} (ctx=${a??`server default`})`),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>r(!1),Cu),f(i,`load`)}catch(e){F.system.error(`Failed to trigger model load`,e),r(!1)}},[m,t,f]),downloadModel:(0,B.useCallback)(async(e=!1,t,n=!1)=>{let r=t??m;a(!0),s(null);try{await p(r,e,n),F.system.info(`Download model triggered: ${r} (force=${e})`),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>a(!1),wu),f(r,`download`)}catch(e){F.system.error(`Failed to trigger model download`,e),s(e instanceof Error?e.message:String(e)),a(!1)}},[m,f])}}function MZ({onRetry:e,label:t,busyLabel:n=`Checking…`}){let[r,i]=(0,B.useState)(!1);return L(`button`,{className:`connection-banner__retry`,onClick:()=>{i(!0),Promise.resolve(e()).finally(()=>i(!1))},disabled:r,children:r?n:t})}function NZ(e){return`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)}`}function PZ({lifecycle:e}){let t=R(),n=OZ(e=>e.restart),r=OZ(e=>e.restartError),i=e.status===`restarting`,[a,o]=(0,B.useState)(()=>Date.now());if((0,B.useEffect)(()=>{if(!i)return;o(Date.now());let e=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(e)},[i]),i){let n=e.since?Math.max(0,Math.floor((a-e.since)/1e3)):0;return z(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[L(`div`,{className:`connection-banner__icon`,children:L(Za,{size:16,className:`connection-banner__spinner`})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[t(`banner.restarting`),` `,L(`bdi`,{dir:`ltr`,className:`connection-banner__timer`,children:NZ(n)}),` `,L(`span`,{className:`connection-banner__hint`,children:t(`banner.restartingHint`)})]})]})}return z(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[L(`div`,{className:`connection-banner__icon`,children:L(Ws,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[t(`banner.restartStopped`),` `,L(`span`,{className:`connection-banner__hint`,children:r?t(`banner.restartFailed`,{error:r}):t(`banner.restartStoppedHint`)})]}),L(MZ,{onRetry:n,label:t(`banner.restartButton`),busyLabel:t(`banner.restartingShort`)})]})}function FZ({onRetry:e,backendSlow:t=!1,backendError:n=null}){let r=R(),{backendConnected:i,systemStatus:a,currentSessionId:o,messages:s}=N(),c=OZ(e=>e.lifecycle),[l,u]=(0,B.useState)(!1),d=!!o&&s.length>0,f=a?.default_model_name??`Gemma-4-E4B-it-GGUF`,{isDownloadingModel:p,downloadError:m,downloadModel:h}=jZ(f),g=zc(e=>e.pickLoad),_=zc(e=>e.retryPickLoad),v=zc(e=>e.dismissPickLoad);Vc();let y=(0,B.useRef)(a?.lemonade_running),b=(0,B.useRef)(a?.model_downloaded),x=(0,B.useRef)(a?.context_size_sufficient),S=(0,B.useRef)(a?.expected_model_loaded);(0,B.useEffect)(()=>{if(d)return;let e=a?.lemonade_running,t=a?.model_downloaded,n=a?.context_size_sufficient,r=a?.expected_model_loaded,i=!1;y.current!==e&&(y.current=e,e===!1&&(i=!0)),b.current!==t&&(b.current=t,t===!1&&(i=!0)),x.current!==n&&(x.current=n,n===!1&&(i=!0)),S.current!==r&&(S.current=r,r===!1&&(i=!0)),i&&u(!1)},[a,d]);let C=a?.download_progress??null,w=p||C?.state===`downloading`||C?.state===`starting`,T=N(e=>e.dismissDownloadFailure);if(c&&c.status!==`running`)return L(PZ,{lifecycle:c});let E=C?.model_name||f,D=async()=>{try{await T(C?.model_name??E)}catch{}};if(w||C?.state===`error`){let e=C?.total_bytes?`${(C.total_bytes/1e9).toFixed(1)} GB`:`large download`,t=C?.state===`error`;return z(`div`,{className:`connection-banner ${t?`connection-banner--error`:`connection-banner--warning`}`,role:t?`alert`:`status`,children:[L(`div`,{className:`connection-banner__icon`,children:L(t?Ws:Ni,{size:16})}),L(`div`,{className:`connection-banner__text`,dir:`auto`,children:t?z(P.Fragment,{children:[`Download of `,L(`strong`,{children:E}),` failed.`,` `,(m??C?.message)&&L(`span`,{className:`connection-banner__hint`,children:m??C?.message})]}):z(P.Fragment,{children:[`Downloading `,L(`strong`,{children:E}),` (`,e,`).`,C?.state===`downloading`&&C.file&&z(P.Fragment,{children:[` `,z(`span`,{className:`connection-banner__hint`,children:[`File `,C.file_index,` / `,C.total_files,`: `,L(`code`,{children:C.file})]})]})]})}),t?L(`button`,{className:`connection-banner__retry`,onClick:()=>h(!1,E,!a?.model_loaded),children:`Retry`}):L(`span`,{className:`connection-banner__loading connection-banner__progress`,children:C&&C.state===`downloading`&&C.total_bytes>0?z(P.Fragment,{children:[L(`span`,{className:`connection-banner__progress-bar`,role:`progressbar`,"aria-valuenow":C.percent,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`Download progress`,children:L(`span`,{className:`connection-banner__progress-fill`,style:{width:`${C.percent}%`}})}),z(`span`,{className:`connection-banner__progress-label`,children:[C.percent,`% ·`,` `,(C.downloaded_bytes/1e9).toFixed(2),` /`,` `,(C.total_bytes/1e9).toFixed(2),` GB`]})]}):z(P.Fragment,{children:[L(Za,{size:13,className:`connection-banner__spinner`}),C?.state===`starting`?C.message??`Starting download…`:`Downloading…`]})}),t&&L(`button`,{className:`connection-banner__dismiss`,onClick:()=>void D(),"aria-label":`Dismiss`,children:L(nc,{size:14})})]})}if(g){let e=Uc(g.model);return g.error?z(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[L(`div`,{className:`connection-banner__icon`,children:L(Ws,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.pickLoad.failed`,{model:e}),` `,L(`span`,{className:`connection-banner__hint`,dir:`auto`,children:g.error.key?r(g.error.key,{reason:g.error.reason}):g.error.reason})]}),L(MZ,{onRetry:_,label:r(`banner.pickLoad.retry`)}),L(`button`,{className:`connection-banner__dismiss`,onClick:v,"aria-label":r(`banner.dismiss`),children:L(nc,{size:14})})]}):z(`div`,{className:`connection-banner connection-banner--init`,role:`status`,children:[L(`div`,{className:`connection-banner__icon`,children:L(Za,{size:16,className:`connection-banner__spinner`})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.pickLoad.loading`,{model:e}),` `,L(`bdi`,{dir:`ltr`,children:r(`banner.pickLoad.seconds`,{s:g.seconds})}),` `,L(`span`,{className:`connection-banner__hint`,children:r(`banner.pickLoad.canType`)})]})]})}if(ZI(a)&&!t&&!n){let e=a?.init_tasks?.find(e=>e.status===`running`)?.step,t=`banner.boot.${e}`,n=e&&fe(t)?r(t):r(`banner.boot.generic`);return z(`div`,{className:`connection-banner connection-banner--init`,role:`status`,children:[L(`div`,{className:`connection-banner__icon`,children:L(Za,{size:16,className:`connection-banner__spinner`})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[n,z(`span`,{className:`thinking-dots`,children:[L(`span`,{children:`.`}),L(`span`,{children:`.`}),L(`span`,{children:`.`})]})]})]})}if(l||d)return null;if(!i)return z(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[L(`div`,{className:`connection-banner__icon`,children:L(Qs,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.unreachable`),` `,L(`span`,{className:`connection-banner__hint`,children:r(`banner.unreachableHint`)})]}),e&&L(MZ,{onRetry:e,label:`Retry`})]});if(n)return z(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[L(`div`,{className:`connection-banner__icon`,children:L(Ws,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[`GAIA's backend answered with an error (`,n,`).`,` `,L(`span`,{className:`connection-banner__hint`,children:`It may be overloaded. GAIA keeps checking; if it lasts, restart GAIA.`})]}),e&&L(MZ,{onRetry:e,label:`Check again`})]});if(t)return z(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[L(`div`,{className:`connection-banner__icon`,children:L(Ws,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[`GAIA is slow to answer.`,` `,L(`span`,{className:`connection-banner__hint`,children:`It may be busy with another chat or app. GAIA keeps checking.`})]}),e&&L(MZ,{onRetry:e,label:`Check again`})]});if(a?.config_error)return z(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[L(`div`,{className:`connection-banner__icon`,children:L(Ws,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[`GAIA settings could not be loaded.`,` `,L(`span`,{className:`connection-banner__hint`,children:a.config_error})]}),e&&L(MZ,{onRetry:e,label:`Check again`})]});if(a&&!a.lemonade_running){let t=QI(a)===`unresponsive`,n=!t&&oX(a),i=t&&rX(a.start_command)?null:a.start_command,o=t&&rX(a.start_instruction)?null:a.start_instruction;return z(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[L(`div`,{className:`connection-banner__icon`,children:L(Ws,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(t?`banner.serverHung`:`banner.serverStopped`),` `,n?L(`span`,{className:`connection-banner__hint`,children:r(`banner.finishSetup`)}):i?z(`span`,{className:`connection-banner__hint`,children:[r(t?`banner.restartHint`:`banner.startHint`),` `,L(`code`,{dir:`ltr`,children:i})]}):o&&L(`span`,{className:`connection-banner__hint`,children:aX(r,o)})]}),n&&L(sX,{className:`connection-banner__retry`}),e&&L(MZ,{onRetry:e,label:r(`settings.key.checkAgain`)}),L(`button`,{className:`connection-banner__dismiss`,onClick:()=>u(!0),"aria-label":`Dismiss`,children:L(nc,{size:14})})]})}if(a&&a.lemonade_running&&a.model_loaded&&a.context_size_sufficient===!1){let t=a.model_context_size??0;return z(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[L(`div`,{className:`connection-banner__icon`,children:L(za,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[`LLM context window is too small (`,t.toLocaleString(),` tokens;`,` `,xu.toLocaleString(),` required).`,` `,L(`span`,{className:`connection-banner__hint`,children:`Reload it with a larger context in Settings → Advanced.`})]}),e&&L(MZ,{onRetry:e,label:`Check again`}),L(`button`,{className:`connection-banner__dismiss`,onClick:()=>u(!0),"aria-label":`Dismiss`,children:L(nc,{size:14})})]})}return null}var IZ=`https://github.com/amd/gaia/releases`;function LZ(){let e=oY(),t=R(),[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(null),o=(0,B.useCallback)(e=>{let n=iY();n&&(a(null),n[e]().catch(n=>{F.system.error(`Update ${e} failed`,n),a(uY(n,t))}))},[t]);if(n)return null;let s=e.installFailed?t(`update.chip.installFailedDetail`,e.installFailed):null,c=e.status===`downloading`||e.status===`downloaded`;if(e.startFailed&&e.previousVersion&&!c)return z(`div`,{className:`update-chip update-chip--error`,role:`status`,children:[L(Ws,{size:13,className:`update-chip__icon`}),L(`span`,{className:`update-chip__label`,title:i??void 0,children:t(i?`update.chip.updateFailed`:`update.chip.startFailed`)}),L(`button`,{type:`button`,className:`update-chip__action`,onClick:()=>o(`revertUpdate`),children:t(`update.chip.goBack`,{version:e.previousVersion})}),L(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>r(!0),"aria-label":t(`update.chip.dismissError`),children:L(nc,{size:11})})]});let l=e.status===`available`||e.status===`downloaded`;if(s&&!l)return z(`div`,{className:`update-chip update-chip--error`,role:`status`,title:s??void 0,children:[L(Ws,{size:13,className:`update-chip__icon`}),L(`span`,{className:`update-chip__label`,children:t(`update.chip.installFailed`)}),L(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>r(!0),"aria-label":t(`update.chip.dismissError`),children:L(nc,{size:11})})]});if(e.status===`idle`||e.status===`checking`||e.status===`disabled`||e.status===`no-channel`)return null;if(e.status===`downloading`){let n=Math.max(0,Math.min(100,e.progress));return z(`div`,{className:`update-chip update-chip--downloading`,role:`status`,"aria-live":`polite`,title:t(`update.chip.downloadingTitle`,{version:e.version??``}),children:[L(Ni,{size:13,className:`update-chip__icon`}),L(`span`,{className:`update-chip__label`,children:e.preparing?t(`update.chip.preparing`):t(`update.chip.downloading`,{pct:n})})]})}return e.status===`available`?z(`div`,{className:`update-chip update-chip--available`,role:`status`,title:e.manualInstall?t(`update.chip.manualTitle`,{version:e.version??``}):i||s||e.releaseNotes||t(`update.chip.availableTitle`),children:[L(Ni,{size:13,className:`update-chip__icon`}),L(`span`,{className:`update-chip__label`,children:i?t(`update.chip.updateFailed`):s?t(`update.chip.installFailed`):t(`update.chip.available`,{version:e.version??``})}),e.manualInstall?L(`a`,{className:`update-chip__action`,href:e.downloadUrl??IZ,target:`_blank`,rel:`noopener noreferrer`,children:t(`update.chip.download`)}):!e.pinnedVersion&&L(`button`,{type:`button`,className:`update-chip__action`,onClick:()=>o(`downloadUpdate`),children:t(`update.chip.updateNow`)}),L(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>r(!0),"aria-label":t(`update.chip.dismiss`),children:L(nc,{size:11})})]}):e.status===`downloaded`?z(`div`,{className:`update-chip update-chip--ready`,role:`status`,"aria-live":`polite`,children:[L(Qo,{size:13,className:`update-chip__icon`}),L(`button`,{type:`button`,className:`update-chip__action`,onClick:()=>o(`restart`),title:i||s||t(`update.chip.restartTitle`),children:t(i?`update.chip.restartFailed`:s?`update.chip.installFailedRetry`:`update.chip.ready`)})]}):e.status===`error`?z(`div`,{className:`update-chip update-chip--error`,role:`status`,title:e.error||t(`update.chip.checkFailed`),children:[L(Ws,{size:13,className:`update-chip__icon`}),L(`span`,{className:`update-chip__label`,children:t(`update.chip.checkFailed`)}),L(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>r(!0),"aria-label":t(`update.chip.dismissError`),children:L(nc,{size:11})})]}):null}var RZ={permission_request:{icon:L(bs,{size:16}),colorClass:`notif-type-permission`},policy_alert:{icon:L(bs,{size:16}),colorClass:`notif-type-policy`},security_alert:{icon:L(Ws,{size:16}),colorClass:`notif-type-security`},status_change:{icon:L(si,{size:16}),colorClass:`notif-type-status`},info:{icon:L(Na,{size:16}),colorClass:`notif-type-info`},error:{icon:L(di,{size:16}),colorClass:`notif-type-error`}},zZ=/([-])/;function BZ(e){return e.split(zZ).map((e,t)=>t%2?e:od(e,!0)).join(``)}function VZ(e,t){let n=Date.now()-e,r=Math.floor(n/1e3);if(r<60)return t(`time.justNow`);let i=Math.floor(r/60);if(i<60)return t(`time.minutesAgo`,{n:i});let a=Math.floor(i/60);if(a<24)return t(`time.hoursAgo`,{n:a});let o=Math.floor(a/24);return o<7?t(`time.daysAgo`,{n:o}):new Date(e).toLocaleDateString(On(t),{month:`short`,day:`numeric`})}function HZ({onClose:e,onOpenChat:t}){let n=R(),r=zl(dc(Vl)),i=zl(Bl),a=zl(e=>e.markRead),o=zl(e=>e.markAllRead),s=zl(e=>e.clearAll),c=zl(e=>e.dismiss),l=zl(e=>e.respondToPermission),u=zl(e=>e.typeFilter),d=zl(dc(Hl)),f=zl(e=>e.setTypeFilter),p=(0,B.useCallback)(e=>{a(e.id),e.sessionId&&e.type!==`permission_request`&&t?.(e.sessionId)},[a,t]),m=(0,B.useCallback)(e=>{l(e.id,`allow`).catch(e=>console.error(`[NotificationCenter] allow failed:`,e))},[l]),h=(0,B.useCallback)(e=>{l(e.id,`deny`).catch(e=>console.error(`[NotificationCenter] deny failed:`,e))},[l]);ut(!0,e);let g=[{key:null,label:n(`notifications.filter.all`)},{key:`permission_request`,label:n(`notifications.filter.permissions`)},{key:`policy_alert`,label:n(`notifications.filter.policy`)},{key:`error`,label:n(`notifications.filter.errors`)},{key:`security_alert`,label:n(`notifications.filter.security`)},{key:`status_change`,label:n(`notifications.filter.status`)},{key:`info`,label:n(`notifications.filter.info`)}].filter(e=>e.key===null||e.key===u||d.includes(e.key)),_=g.length>2||u!==null;return z(`div`,{className:`notification-center`,role:`dialog`,"aria-label":n(`notifications.dialogAria`),children:[z(`div`,{className:`notification-center-header`,children:[z(`div`,{className:`notification-center-title-row`,children:[L(`h2`,{className:`notification-center-title`,children:n(`notifications.title`)}),i>0&&L(`span`,{className:`notification-center-badge`,children:i})]}),L(`button`,{className:`btn-icon notification-center-close`,onClick:e,"aria-label":n(`notifications.close`),children:L(nc,{size:18})})]}),_&&L(`div`,{className:`notification-filter-bar`,role:`tablist`,"aria-label":n(`notifications.filterAria`),children:g.map(e=>L(`button`,{role:`tab`,"aria-selected":u===e.key,className:`notification-filter-tab ${u===e.key?`active`:``}`,onClick:()=>f(e.key),children:e.label},e.key??`all`))}),L(`div`,{className:`notification-list`,children:r.length===0?z(`div`,{className:`notification-empty`,children:[L(Nr,{size:40,strokeWidth:1.2}),L(`span`,{children:n(`notifications.empty`)})]}):r.map(e=>{let t=RZ[e.type],r=e.type===`permission_request`&&e.tool?Al(e,n,e=>il(od(e,!0))):null;return z(`div`,{className:`notification-item ${e.read?``:`unread`} ${t.colorClass}`,id:e.type===`policy_alert`&&e.receiptId?`policy-receipt-${encodeURIComponent(e.receiptId)}`:void 0,onClick:()=>p(e),role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&p(e)},children:[!e.read&&L(`span`,{className:`notification-unread-dot`}),L(`span`,{className:`notification-icon`,children:t.icon}),z(`div`,{className:`notification-content`,children:[z(`div`,{className:`notification-content-header`,children:[L(`span`,{className:`notification-agent`,dir:`auto`,children:e.agentName}),L(`span`,{className:`notification-time`,children:VZ(e.timestamp,n)})]}),r?z(P.Fragment,{children:[L(`span`,{className:`notification-title`,children:L(sl,{text:r.heading})}),L(`span`,{className:`notification-message`,dir:`auto`,children:L(sl,{text:r.question})})]}):z(P.Fragment,{children:[e.title&&L(`span`,{className:`notification-title`,children:BZ(e.title)}),L(`span`,{className:`notification-message`,dir:`auto`,children:BZ(e.message)})]}),e.type===`policy_alert`&&z(`div`,{className:`notification-policy-details`,children:[e.tool&&z(`span`,{className:`notification-tool`,children:[n(`activity.policy.tool`),`: `,L(`code`,{dir:`ltr`,children:e.tool})]}),e.reason&&z(`span`,{className:`notification-policy-reason`,children:[n(`notifications.reason`),`: `,e.reason]}),e.ruleIds&&e.ruleIds.length>0&&z(`span`,{className:`notification-tool`,children:[n(`activity.policy.rules`),`: `,L(`code`,{dir:`ltr`,children:e.ruleIds.join(`, `)})]}),e.policyVersion&&z(`span`,{className:`notification-tool`,children:[n(`activity.policy.policy`),`: `,L(`code`,{dir:`ltr`,children:e.policyVersion})]}),z(`span`,{className:`notification-tool`,children:[n(`activity.policy.receipt`),`:`,` `,e.receiptId?L(`code`,{dir:`ltr`,children:e.receiptId}):L(`em`,{children:n(`activity.policy.receiptUnavailable`)})]})]}),e.type===`permission_request`&&!e.response&&z(`div`,{className:`notification-actions`,children:[z(`button`,{className:`notification-action-btn notification-action-allow`,onClick:t=>{t.stopPropagation(),m(e)},children:[L(Yr,{size:14}),n(`notifications.approve`)]}),z(`button`,{className:`notification-action-btn notification-action-deny`,onClick:t=>{t.stopPropagation(),h(e)},children:[L(nc,{size:14}),n(`notifications.deny`)]})]}),e.type===`permission_request`&&e.response&&L(`span`,{className:`notification-response-badge ${e.response===`allow`?`response-allow`:`response-deny`}`,children:e.response===`allow`?n(`notifications.approved`):n(`notifications.denied`)})]}),L(`button`,{className:`notification-dismiss`,onClick:t=>{t.stopPropagation(),c(e.id)},"aria-label":n(`notifications.dismiss`),children:L(nc,{size:14})})]},e.id)})}),r.length>0&&z(`div`,{className:`notification-center-footer`,children:[z(`button`,{className:`notification-footer-btn`,onClick:o,disabled:i===0,children:[L(Yr,{size:14}),n(`notifications.markAllRead`)]}),z(`button`,{className:`notification-footer-btn notification-footer-clear`,onClick:s,children:[L(Hs,{size:14}),n(`notifications.clear`)]})]})]})}var UZ=1500,WZ=e=>new Promise(t=>setTimeout(t,e));async function GZ({onProgress:e,isCancelled:t=()=>!1,pollMs:n=UZ}={}){try{await At(nk)}catch(e){if(e?.httpStatus!==409)throw e;let t=await xe(nk).catch(()=>null);if(!t||t.status===`completed`||t.status===`failed`)throw e}for(;!t();){let t=await xe(nk);if(e?.(t),t.status===`completed`)return;if(t.status===`failed`)throw Error(t.error||`The GAIA agent could not be installed.`);await WZ(n)}}function KZ({onInstalled:e,noBuild:t=!1}){let n=R(),[r,i]=(0,B.useState)({kind:`idle`}),a=(0,B.useRef)(!1);(0,B.useEffect)(()=>()=>{a.current=!0},[]);let o=(0,B.useCallback)(async()=>{i({kind:`installing`,percent:0});try{if(await GZ({isCancelled:()=>a.current,onProgress:e=>{a.current||i({kind:`installing`,percent:e.percent??0})}}),a.current)return;await e(),a.current||i({kind:`idle`})}catch(e){a.current||i({kind:`failed`,error:e instanceof Error?e.message:String(e)})}},[e]);return t?L(`div`,{className:`app-notice is-warning`,role:`status`,children:L(`span`,{children:n(`agentNotice.noBuild`)})}):z(`div`,{className:`app-notice is-warning`,role:`status`,children:[r.kind===`installing`?L(`span`,{children:n(`agentNotice.installing`,{percent:Math.round(r.percent)})}):r.kind===`failed`?L(`span`,{children:n(`agentNotice.failed`,{error:r.error})}):L(`span`,{children:n(`agentNotice.missing`)}),r.kind!==`installing`&&L(`button`,{type:`button`,className:`link-btn`,onClick:()=>void o(),children:r.kind===`failed`?n(`agentNotice.retry`):n(`agentNotice.install`)})]})}var qZ=`goal-store-error-`,JZ=0;function YZ(){let e=zl.getState();for(let t of e.notifications)t.id.startsWith(qZ)&&!t.read&&e.markRead(t.id)}var XZ=Pt((e,t)=>({error:null,damaged:!1,check:async()=>{let n,r;try{({error:n,damaged:r}=await GG())}catch(e){F.api.error(`Could not check the goal store`,e);return}n&&n!==t().error&&(JZ+=1,zl.getState().addNotification({id:`${qZ}${JZ}`,type:`error`,agentId:`goals`,agentName:`GAIA`,title:Ut()(`mem.goals.storeError`),message:n,timestamp:Date.now(),read:!1,dismissed:!1,priority:`high`})),n||YZ(),e({error:n,damaged:!!r})}})),ZZ=new Set([`loading_model`,`downloading_model`,`model_retry`,`waiting`]),QZ=5;function $Z(e,t){return{id:e,title:t.get(e)?.title??`Untitled chat`}}function eQ(e){let t=new Map(e.sessions.map(e=>[e.id,e])),n=e.isStreaming&&e.currentSessionId!==null,r=[...e.runningSessionIds];n&&!r.includes(e.currentSessionId)&&r.push(e.currentSessionId);let i=new Set(r),a=new Set(e.notifications.filter(e=>e.type===`permission_request`&&!e.response&&!e.dismissed&&e.sessionId&&i.has(e.sessionId)).map(e=>e.sessionId)),o=[...a].map(e=>({...$Z(e,t),reason:`approval`}));n&&e.awaitingUser&&!a.has(e.currentSessionId)&&o.push({...$Z(e.currentSessionId,t),reason:`answer`});for(let[n,r]of Object.entries(e.awaitingBySession))o.some(e=>e.id===n)||o.push({...$Z(n,t),reason:r===`question`?`answer`:`approval`});let s=n&&!e.awaitingUser&&e.livePhase&&ZZ.has(e.livePhase)?e.liveStatus:null,c=e.systemStatus,l=null;if(c?.default_model_is_cloud&&c.default_model_name)l={name:c.default_model_name,where:`cloud`};else if(c?.model_loaded){let e=c.model_labels?.includes(`cloud`),t=c.model_device&&c.model_device!==`none`?c.model_device:null;l={name:c.model_loaded,where:e?`cloud`:t}}let u=[...e.sessions].sort((e,t)=>t.updated_at.localeCompare(e.updated_at)).slice(0,QZ).map(e=>$Z(e.id,t));return{backendConnected:e.backendConnected,modelServerRunning:c&&!c.default_model_is_cloud?c.lemonade_running:null,model:l,waitingOnModel:s||null,running:r.map(e=>$Z(e,t)),needsYou:o,recent:u}}function tQ(e){let t=(0,B.useRef)(e);t.current=e,(0,B.useEffect)(()=>{let e=window.gaiaAPI?.tray;if(!e)return;let n=``,r=null,i=()=>{let t=N.getState(),i={backendConnected:t.backendConnected,systemStatus:t.systemStatus,sessions:t.sessions,runningSessionIds:t.runningSessionIds,awaitingBySession:t.awaitingBySession,currentSessionId:t.currentSessionId,isStreaming:t.isStreaming,awaitingUser:t.awaitingUser,liveStatus:t.liveStatus,livePhase:t.livePhase,notifications:zl.getState().notifications},a=r;if(r=i,a&&Object.keys(i).every(e=>i[e]===a[e]))return;let o=eQ(i),s=JSON.stringify(o);s!==n&&(n=s,e.setActivity(o).catch(e=>{n=``,F.system.error(`The tray could not take the app state`,e)}))};i();let a=N.subscribe(i),o=zl.subscribe(i),s=e.onCommand(e=>{switch(e.type){case`open-chat`:t.current.openChat(e.sessionId);break;case`new-chat`:t.current.newChat();break;case`open-settings`:N.getState().openSettings(e.section);break;case`refresh-status`:t.current.refreshStatus();break;default:F.system.error(`Unknown tray command`,e)}});return()=>{a(),o(),s()}},[])}function nQ(){(0,B.useEffect)(()=>{let e=window.gaiaAPI;if(!e)return;let t=zl.getState().addNotification,n=[e.notification.onNotification(t),e.notification.onPermissionRequest(t),e.tray.onNavigate(e=>{let t=typeof e==`string`&&e.startsWith(`session:`)?e.slice(8):null;if(!t)return;let n=N.getState();n.currentSessionId!==t&&n.setMessages([]),n.setCurrentSession(t)})];return()=>n.forEach(e=>e())},[])}function rQ(e,t,n){let r=window.gaiaAPI;if(r){r.notification.show({title:t,body:n,sessionId:e}).then(e=>{e||F.system.warn(`This OS has no desktop notifications; the badge still counts it.`)}).catch(e=>F.system.error(`Could not show the desktop notification`,e));return}if(typeof Notification>`u`){F.system.warn(`This browser has no notifications; the alert was not shown.`);return}if(Notification.permission!==`granted`){F.system.warn(`Browser notifications are ${Notification.permission}; allow them in Settings → Notifications.`);return}let i=new Notification(t,{body:n,tag:`gaia-${e}`});i.onclick=()=>{window.focus(),N.getState().setCurrentSession(e)}}function iQ(){let[e,t]=(0,B.useState)(null);return(0,B.useEffect)(()=>{let e=navigator;if(!e.getBattery)return;let n=null,r=()=>{n&&t({charging:n.charging,level:n.level})};return e.getBattery().then(e=>{n=e,r(),e.addEventListener(`levelchange`,r),e.addEventListener(`chargingchange`,r)}).catch(e=>F.system.warn(`Battery level unavailable; keep-awake ignores the battery policy.`,e)),()=>{n?.removeEventListener(`levelchange`,r),n?.removeEventListener(`chargingchange`,r)}},[]),e}function aQ(){nQ();let e=N(e=>e.runningSessionIds),t=N(e=>e.awaitingBySession),n=N(e=>e.sessions),r=N(e=>e.currentSessionId),i=zl(dc(Wl)),a=Zl(),o=iQ(),s=(0,B.useRef)(null),c=iu(e,t,i),l=JSON.stringify(c);(0,B.useEffect)(()=>{let e=JSON.parse(l),t=s.current;if(s.current=e,t===null)return;let{sessions:n,currentSessionId:r}=N.getState(),i=document.hasFocus(),o=!1;for(let{sessionId:s,event:c}of au(t,e)){let e=n.find(e=>e.id===s);if(e?.kind===`eval`||e?.kind===`scheduled`)continue;let t=a.modes[c];if(!(t===`off`||cu(s,r,i))&&(o=!0,t===`banner`)){if(c!==`finished`){let{title:t,body:n}=su(c,e);rQ(s,t,n)}else D(s).then(e=>{N.getState().updateSessionInList(s,e);let{title:t,body:n}=su(c,e);rQ(s,t,n)}).catch(t=>{F.system.error(`Could not read how chat ${s} ended`,t);let{title:n,body:r}=su(c,{...e,last_run_status:null});rQ(s,n,r)})}}if(o){if(a.sound)try{du()}catch(e){F.system.warn(`Alert sound not played`,e)}a.flash&&!i&&window.gaiaAPI&&window.gaiaAPI.notification.flash().catch(e=>F.system.error(`Could not flash the taskbar button`,e))}},[l,a.modes,a.sound,a.flash]);let u=lu(n,c,a.modes,r);(0,B.useEffect)(()=>{window.gaiaAPI?.notification.setAttentionCount(u).catch(e=>F.system.error(`Could not update the taskbar badge`,e))},[u]);let d=a.keepAwake&&e.length>0&&uu(o,a.batteryFloor);(0,B.useEffect)(()=>{window.gaiaAPI?.power.setKeepAwake(d).catch(e=>F.system.error(`Could not change keep-awake`,e))},[d])}function oQ(e){return e.indexing_status===`failed`&&zL(e.error_kind)}function sQ(){let e=N(e=>e.systemStatus?.lemonade_running===!0),t=N(e=>e.setDocuments),n=(0,B.useRef)(!1),r=(0,B.useRef)(!1);(0,B.useEffect)(()=>{if(!e)return;if(n.current){r.current=!0;return}let i=async()=>{let{documents:e}=await fn(),n=(e||[]).filter(oQ).map(e=>e.id);if(n.length===0)return;F.doc.info(`Model server is back; retrying ${n.length} document(s) that were waiting for it`);for(let e of n){let n=(await fn()).documents||[],r=n.find(t=>t.id===e);if(r&&oQ(r)){t(n.map(t=>t.id===e?{...t,indexing_status:`indexing`}:t));try{await qn(e),F.doc.info(`Indexed "${r.filename}" now the model server is back`)}catch(e){F.doc.warn(`"${r.filename}" still couldn't be indexed after the model server came back`,e)}}}let r=await fn();t(r.documents||[])};n.current=!0,(async()=>{try{do{r.current=!1;try{await i()}catch(e){F.doc.warn(`Could not retry the documents waiting for the model server`,e)}}while(r.current&&N.getState().systemStatus?.lemonade_running===!0)}finally{n.current=!1}})()},[e,t])}var cQ=`GAIA Agent UI`;function lQ(){let e=N(e=>e.sessions.find(t=>t.id===e.currentSessionId)?.title);(0,B.useEffect)(()=>{document.title=e?.trim()?`${e.trim()} - GAIA`:cQ},[e])}function uQ(e,t,n){return!e||t&&(e===t||e===aR(t))?null:n.some(t=>t.id===e)?e:oR(n,e)}function dQ(e){return new URLSearchParams(e.search).get(`session`)||e.hash.replace(/^#/,``)||null}var fQ=`gaia:last-session`;function pQ(e){try{e?localStorage.setItem(fQ,e):localStorage.removeItem(fQ)}catch(e){F.ui.warn(`Could not save the open chat for the next launch`,e)}}function mQ(){try{return localStorage.getItem(fQ)}catch(e){return F.ui.warn(`Could not read the chat open at last launch`,e),null}}var hQ=1e3,gQ=3e4;function _Q(e,{initialMs:t=hQ,maxMs:n=gQ,onError:r}={}){let i=t,a=0,o=null,s=!1,c=!1,l=!1,u=()=>{l||c||s||(o&&=(clearTimeout(o),null),s=!0,a+=1,e().then(()=>{c=!0}).catch(e=>{l||(r?.(e,a),o=setTimeout(()=>{o=null,u()},i),i=Math.min(i*2,n))}).finally(()=>{s=!1}))};return u(),{kick:()=>{o&&u()},stop:()=>{l=!0,o&&clearTimeout(o),o=null},done:()=>c}}function vQ(e,t,n){return e&&!t&&!n}var yQ=(0,B.lazy)(()=>hZ(()=>import(`./MemoryDashboard-BsbzPxKH.js`).then(e=>({default:e.MemoryDashboard})),__vite__mapDeps([7,1,2,8]),import.meta.url)),bQ=(0,B.lazy)(()=>hZ(()=>import(`./ScheduleManager-wj9BdhrA.js`).then(e=>({default:e.ScheduleManager})),__vite__mapDeps([9,1,2,10]),import.meta.url)),xQ=(0,B.lazy)(()=>hZ(()=>import(`./DocumentLibrary-CoHBPrsI.js`).then(e=>({default:e.DocumentLibrary})),__vite__mapDeps([11,1,2,12]),import.meta.url)),SQ=(0,B.lazy)(()=>hZ(()=>import(`./FileBrowser-DYrnvgKL.js`).then(e=>({default:e.FileBrowser})),__vite__mapDeps([13,1,2,14]),import.meta.url)),CQ=(0,B.lazy)(()=>hZ(()=>import(`./MobileAccessModal-DATZSrW1.js`).then(e=>({default:e.MobileAccessModal})),__vite__mapDeps([15,1,2,16]),import.meta.url)),wQ=3,TQ=3e5,EQ=6e3,DQ=6e4,OQ=e=>e instanceof TypeError,kQ=e=>new Promise(t=>setTimeout(t,e)),AQ=3e5,jQ=class extends Error{},MQ=class extends Error{constructor(e){super(Ut().bare(`setup.unknown.modelUnread`,{error:e}))}};async function NQ(){let e=Date.now()+AQ;for(;;){let t=await oe();if(t.state===`ready`)return;if(t.state===`failed`||t.state===`cancelled`)throw new jQ(t.error||Ut().bare(`setup.upgrading.stopped`));if(Date.now()>=e)throw Error(Ut().bare(`setup.upgrading.slow`));await kQ(hQ)}}function PQ(){return L(`div`,{className:`loading-spinner`,role:`status`,"aria-label":`Loading`})}var FQ=e=>e===1||e%10==0;function IQ(){zc.getState().active?.remote||iY()?.markSetupWorked().catch(e=>{F.system.warn(`Couldn't record that setup works on this version`,e)})}function LQ(){let e=R();lQ();let t=N(e=>e.currentSessionId),n=N(e=>e.setSessions),r=N(e=>e.setCurrentSession),i=N(e=>e.addSession),a=N(e=>e.setMessages),o=N(e=>e.showDocLibrary),s=N(e=>e.showFileBrowser),c=N(e=>e.showMemoryDashboard),l=N(e=>e.showSchedules),u=N(e=>e.sidebarOpen),d=N(e=>e.sidebarCollapsed),f=N(e=>e.setSidebarOpen),p=N(e=>e.setSystemStatus),m=N(e=>e.setBackendConnected),h=N(e=>e.setAgents),g=N(e=>e.agents),_=N(e=>e.setPendingPrompt),v=N(e=>e.setDefaultPermissionMode),y=N(e=>e.openSettings),b=N(e=>e.settingsSection),x=N(e=>e.syncSystemTheme),S=zc(e=>e.restoreNotice),C=zc(e=>e.dismissRestoreNotice),w=zl(e=>e.showPanel),T=N(e=>e.systemStatus?.initialized===!0),E=(0,B.useRef)(!1),D=zl(e=>e.setShowPanel);(0,B.useEffect)(()=>{if(!S?.ok)return;let e=setTimeout(C,EQ);return()=>clearTimeout(e)},[S,C]);let[O,ee]=(0,B.useState)({state:`checking`}),te=N(e=>e.setupAgain),ne=N(e=>e.runSetupAgain),re=(0,B.useRef)(O);re.current=O;let[ie,ae]=(0,B.useState)(!1),A=(0,B.useRef)(ie);A.current=ie;let[se,ce]=(0,B.useState)(!1),[le,ue]=(0,B.useState)(!1),de=se||ie&&!rk(g),fe=(0,B.useRef)(de);fe.current=de;let[pe,me]=(0,B.useState)(null),[j,he]=(0,B.useState)(!1),[ge,_e]=(0,B.useState)(``),[ye,be]=(0,B.useState)(0),[xe,Se]=(0,B.useState)(0),[Ce,we]=(0,B.useState)(!1),[Te,Ee]=(0,B.useState)(!1),[De,Oe]=(0,B.useState)(null),[ke,Ae]=(0,B.useState)(null),je=(0,B.useRef)(async()=>{}),Me=(0,B.useRef)(async()=>{}),Ne=(0,B.useCallback)(async(e=!1,t=!1)=>{e||ee({state:`checking`});let n=0;try{for(;;){await zc.getState().refresh();let e=zc.getState().active,r=!!e?.remote,i;try{if(i=await k(r),!e&&!i.ready)throw new MQ(zc.getState().error??`no answer`)}catch(e){let r=OQ(e)||e instanceof MQ;if(!t||!r||n>=DQ)throw e;await kQ(hQ),n+=hQ;continue}if(!i.ready&&i.stage===`upgrade`){ee({state:`upgrading`});let e=await oe();(!e.upgrade_embedded||e.state!==`running`&&e.state!==`verifying`)&&await dn(r,!1,{upgradeEmbedded:!0}),await NQ(),i=await k(r)}n>0&&await Promise.all([je.current(),Me.current()]),ue(!!i.no_agent_build),i.ready&&IQ();let a=!i.ready&&i.stage===`server`&&!!i.initialized;ee(i.ready?{state:`ready`}:a?{state:`serverDown`,modelListUnread:!!i.model_list_unread}:{state:`needed`,check:i});return}}catch(e){let t=e instanceof Error?e.message:String(e);if(e instanceof jQ){F.system.warn(`Updating the local model server failed`,e),ee({state:`unknown`,error:t,upgradeFailed:!0});return}F.system.warn(`Setup check could not be answered`,e),ee({state:`unknown`,error:t})}},[]),Pe=N(e=>!!e.systemStatus&&QI(e.systemStatus)===`unresponsive`),Fe=N(e=>e.systemStatus?.lemonade_running===!0);(0,B.useEffect)(()=>{O.state===`serverDown`&&Fe&&Ne(!0)},[O.state,Fe,Ne]);let Ie=N(e=>e.systemStatus?.lemonade_running===!1);(0,B.useEffect)(()=>{if(O.state!==`ready`||!Ie)return;let e=!1;return k(!!zc.getState().active?.remote).then(t=>{!e&&!t.ready&&t.stage===`server`&&t.initialized&&ee({state:`serverDown`,modelListUnread:!!t.model_list_unread})}).catch(e=>F.system.warn(`Could not confirm the model server is down`,e)),()=>{e=!0}},[O.state,Ie]);let Le=(0,B.useRef)(0),Re=(0,B.useCallback)(async()=>{let e=++Le.current,t=(await zn()).agents||[];e===Le.current&&(h(t),ae(!0),rk(t)&&ce(!1))},[h]),ze=(0,B.useCallback)(()=>{let e=A.current;ae(!1),Re().catch(t=>{F.api.warn(`Agent list unavailable after setup`,t),e&&ae(!0)})},[Re]);(0,B.useEffect)(()=>{let e=()=>{fe.current&&Re().catch(e=>F.api.warn(`Agent list unavailable`,e))};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[Re]);let Be=(0,B.useCallback)(async()=>{v((await nn()).default_mode)},[v]),Ve=(0,B.useRef)([]);(0,B.useEffect)(()=>{en(`0.27.0rc7`),Ne(!1,!0);let e=[_Q(Re,{onError:(e,t)=>{FQ(t)&&F.api.warn(`Agent list unavailable (attempt ${t}); retrying`,e)}}),_Q(Be,{onError:(e,t)=>{FQ(t)&&F.api.warn(`Default permission mode unavailable (attempt ${t}); retrying`,e)}})];return Ve.current=e,()=>e.forEach(e=>e.stop())},[Ne,Re,Be]);let He=(0,B.useCallback)(()=>{Ve.current.forEach(e=>e.kick()),zc.getState().retryNow(),Me.current();let e=re.current;e.state===`unknown`&&!e.upgradeFailed&&Ne(!0)},[Ne]),Ue=(0,B.useRef)(He);Ue.current=He;let We=(0,B.useRef)(0),Ge=(0,B.useRef)(0),Ke=(0,B.useRef)(null),qe=(0,B.useRef)(!1),[Je,Ye]=(0,B.useState)(!1),[Xe,Ze]=(0,B.useState)(null),Qe=(0,B.useCallback)(e=>{if(e.kind===`unreachable`){F.system.warn(`System status check failed`,e.error),kZ(),qe.current=!0,Ge.current=0,Ke.current=null,Ye(!1),Ze(null),m(!1),p(null);return}if(e.kind===`error`){F.system.warn(`System status answered HTTP ${e.httpStatus}`,e.message),qe.current&&Ue.current(),qe.current=!1,Ge.current=0,Ke.current=null,Ye(!1),Ze(`HTTP ${e.httpStatus}: ${e.message}`),m(!0);return}if(e.kind===`slow`){if(Ge.current+=1,Ke.current??=Date.now(),Ze(null),F.system.warn(`System status did not answer in time (${Ge.current} in a row)`),Date.now()-Ke.current>=TQ){Ye(!1),m(!1),p(null);return}m(!0),(qe.current||Ge.current>=wQ)&&Ye(!0);return}let{status:t}=e;qe.current&&Ue.current(),qe.current=!1,Ge.current=0,Ke.current=null,Ye(!1),Ze(null),m(!0),We.current=t.lemonade_running?0:We.current+1;let n=N.getState().systemStatus;t.lemonade_running||We.current>=wQ||!n?.lemonade_running?p(t):p({...n,download_progress:t.download_progress})},[m,p]),$e=(0,B.useRef)(Qe);$e.current=Qe;let[et]=(0,B.useState)(()=>tL(e=>$e.current(e))),tt=et.check;je.current=tt,(0,B.useEffect)(()=>LW(et.start),[et]),(0,B.useEffect)(()=>AZ(()=>{tt()}),[tt]);let nt=(0,B.useRef)(``);(0,B.useEffect)(()=>{let e=e=>gn().then(t=>{let r=t.sessions||[];if(!e&&r.length===0&&N.getState().sessions.length>0)return;let i=r.map(e=>`${e.id}|${e.updated_at}|${e.title}|${e.inference_remote}|${e.inference_provider}|${e.inference_description}|${e.effective_model}|${e.unread}|${e.pinned}|${e.last_run_status}|${e.kind}`).join(`
|
|
215
|
+
`);if(i===nt.current)return;nt.current=i,n(r);let a=zc.getState().active?.model;a&&r.some(e=>e.effective_model&&e.effective_model!==a)&&zc.getState().refresh()}).catch(t=>{e&&F.system.error(`Could not load chats`,t)});Me.current=()=>e(!1),e(!0);let t=setInterval(()=>void e(!1),5e3);return()=>clearInterval(t)},[n]),(0,B.useEffect)(()=>mL(),[]),(0,B.useEffect)(()=>{let e=()=>{ZH.getState().loadSchedules()};e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[]),(0,B.useEffect)(()=>{let e=()=>{XZ.getState().check()};e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[]),(0,B.useEffect)(()=>ML(),[]),aQ(),sQ();let rt=(0,B.useRef)(!1),it=(0,B.useRef)(!1);(0,B.useEffect)(()=>{let e=()=>{let e=dQ(window.location),{currentSessionId:t,sessions:n}=N.getState(),i=uQ(e,t,n);return i&&(r(i),a([])),i},t=()=>{if(rt.current||(rt.current=!0,e()||N.getState().currentSessionId))return;if(window.location.hash){window.history.replaceState(null,``,window.location.pathname+window.location.search);return}if(it.current||hn(`new-chat`))return;let{sessions:t}=N.getState(),n=uQ(mQ(),null,t);n&&(r(n),a([]))},n=N.subscribe(e=>{e.sessions.length>0&&t()});return N.getState().sessions.length>0&&t(),window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{n(),window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[r,a]),(0,B.useEffect)(()=>{let e=null,t=2e3,n=!1,i=null,o=()=>{n||(e=new EventSource(`${Hn()}/sessions/events`),e.onopen=()=>{t=2e3},e.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch(e){F.api.warn(`Malformed session event`,e);return}t.type===`set_active_session`&&t.session_id&&t.session_id!==N.getState().currentSessionId&&(r(t.session_id),a([]))},e.onerror=()=>{e?.close(),e=null,n||(i=setTimeout(o,t),t=Math.min(t*2,3e4))})};return o(),()=>{n=!0,i&&clearTimeout(i),e?.close()}},[r,a]),(0,B.useEffect)(()=>{if(rt.current&&pQ(t),t){let e=aR(t);window.location.hash!==`#${e}`&&window.history.replaceState(null,``,`#${e}`)}else rt.current&&window.location.hash&&window.history.replaceState(null,``,window.location.pathname+window.location.search)},[t]);let ot=(0,B.useCallback)(async e=>{if(me(null),he(!1),!await Sc(`chat`))return _e(e),!1;let t=N.getState(),n;try{n=await Ht({title:`New chat`,agent_type:nk,document_ids:t.draftDocumentIds,private:t.draftPrivate,folders:t.draftFolder?[t.draftFolder]:[]})}catch(e){throw ak(e)?(ce(!0),new ik):e}fe.current&&(ce(!1),Re().catch(e=>F.api.warn(`Agent list unavailable`,e))),t.defaultPermissionModeKnown||(await Be().catch(e=>F.api.warn(`Default permission mode unavailable; using the chip's mode`,e)),t=N.getState()),t.clearDraftDocuments(),t.setDraftPrivate(!1),t.adoptDraftResearch(n.id,e),t.setDraftFolder(null);let o=null;try{await Vt(n.id,t.draftPermissionMode)}catch(e){o=e}return ht(kn),o&&!n.private&&Nn(Wt(n.id),e),i(n),BV.getState().claimDraft(n.id),r(n.id),a([]),_e(``),o?(me(`The chat was created, but its permission mode could not be set, so your message was not sent${n.private?``:` — it is in the chat's box`}: ${o instanceof Error?o.message:o}`),!1):(t.resetDraftPermissionMode(),_({sessionId:n.id,text:e}),!0)},[i,r,a,_,Re,Be]),st=(0,B.useCallback)(async e=>{try{return await ot(e)}catch(t){if(!(t instanceof ik))throw t;let n=hn(kn),r=n.trimEnd().endsWith(e)?n:[n,e].filter(Boolean).join(`
|
|
216
216
|
|
|
217
|
-
`);return Nn(kn,r),_e(r),he(!0),Se(e=>e+1),!1}},[ot]),ct=(0,B.useCallback)(()=>{let e=N.getState(),t=e.currentSessionId,n=e.pendingPrompt?.sessionId===t?e.pendingPrompt:null;n&&(e.setPendingPrompt(null),_e(n.text)),t&&yu(t,N.getState())&&bu(t),e.setShowMemoryDashboard(!1),e.setShowSchedules(!1),it.current=!0,he(!1),r(null),a([]),be(e=>e+1)},[r,a]),lt=(0,B.useCallback)(e=>{let t=N.getState();t.closeSettings(),e!==t.currentSessionId&&(bu(t.currentSessionId),a([])),r(e)},[r,a]),ut=(0,B.useCallback)(e=>{let t=N.getState();t.setShowMemoryDashboard(!1),t.setShowSchedules(!1),D(!1),lt(e)},[lt]);
|
|
217
|
+
`);return Nn(kn,r),_e(r),he(!0),Se(e=>e+1),!1}},[ot]),ct=(0,B.useCallback)(()=>{let e=N.getState(),t=e.currentSessionId,n=e.pendingPrompt?.sessionId===t?e.pendingPrompt:null;n&&(e.setPendingPrompt(null),_e(n.text)),t&&yu(t,N.getState())&&bu(t),e.setShowMemoryDashboard(!1),e.setShowSchedules(!1),it.current=!0,he(!1),r(null),a([]),be(e=>e+1)},[r,a]),lt=(0,B.useCallback)(e=>{let t=N.getState();t.closeSettings(),e!==t.currentSessionId&&(bu(t.currentSessionId),a([])),r(e)},[r,a]),ut=(0,B.useCallback)(e=>{let t=N.getState();t.setShowMemoryDashboard(!1),t.setShowSchedules(!1),D(!1),lt(e)},[lt]);tQ({openChat:lt,newChat:(0,B.useCallback)(()=>{N.getState().closeSettings(),ct()},[ct]),refreshStatus:()=>void tt()});let dt=(0,B.useCallback)(t=>{let n=N.getState(),r=n.pendingPrompt?.sessionId===n.currentSessionId?n.pendingPrompt?.text:null;ct();let i=e.bare(`settings.skills.tryPrompt`,{name:t}),a=[hn(kn),r].filter(Boolean).join(`
|
|
218
218
|
|
|
219
219
|
`),o=a.trimEnd().endsWith(i)?a:[a,i].filter(Boolean).join(`
|
|
220
220
|
|
|
221
|
-
`);Nn(kn,o),_e(o),Se(e=>e+1)},[ct,e]);(0,B.useEffect)(()=>{let e=e=>{let t=e.detail;N.getState().closeSettings(),ct(),st(
|
|
222
|
-
`)}),L(`button`,{type:`button`,className:`btn-secondary`,onClick:s,children:c(`engine.openLog`)})]})]})}function
|
|
221
|
+
`);Nn(kn,o),_e(o),Se(e=>e+1)},[ct,e]);(0,B.useEffect)(()=>{let e=e=>{let t=e.detail;N.getState().closeSettings(),ct(),st(EZ(t)).catch(e=>me(e instanceof Error?e.message:String(e)))};return window.addEventListener(SZ,e),()=>window.removeEventListener(SZ,e)},[ct,st]);let ft=(0,B.useCallback)(e=>{IQ(),ee({state:`ready`}),ze(),tt(),e&&(e.needs_input?_e(e.prompt):st(e.prompt).catch(e=>me(e instanceof Error?e.message:String(e))))},[tt,st,ze]),pt=(0,B.useCallback)(()=>{ee({state:`ready`}),tt()},[tt]);(0,B.useEffect)(()=>{let e=()=>{N.getState().closeSettings(),ee({state:`addingLocal`})};return window.addEventListener(`gaia:set-up-local`,e),()=>window.removeEventListener(`gaia:set-up-local`,e)},[]);let[mt,gt]=(0,B.useState)(!1);(0,B.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&(e.shiftKey&&e.key.toLowerCase()===`o`?(e.preventDefault(),ct()):!e.shiftKey&&e.key.toLowerCase()===`k`?(e.preventDefault(),window.dispatchEvent(new CustomEvent(`gaia:focus-search`))):!e.shiftKey&&e.key.toLowerCase()===`b`?(e.preventDefault(),N.getState().toggleSidebarCollapsed()):!e.shiftKey&&e.key===`,`?(e.preventDefault(),y()):e.key===`/`&&(e.preventDefault(),gt(e=>!e)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[ct,y]),(0,B.useEffect)(()=>{let e=window.matchMedia?.(`(max-width: 768px)`);if(!e)return;let t=()=>f(!e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[f]),(0,B.useEffect)(()=>{if(typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(prefers-color-scheme: light)`);return e.addEventListener(`change`,x),()=>e.removeEventListener(`change`,x)},[x]),(0,B.useEffect)(()=>{at().then(e=>Ee(e.active===!0)).catch(e=>F.system.debug(`Mobile access unavailable`,e))},[]);let _t=(0,B.useCallback)(async()=>{if(we(!0),Oe(null),Te)Ae(null);else try{let e=await M(),t=e.reason===`ngrok_not_installed`;if(Ae(t?e.installCommands??[]:null),t)return;e.error?Oe(e.error):Ee(!0)}catch(e){Ae(null),Oe(e instanceof Error?e.message:`Could not start mobile access`)}},[Te]),vt=(0,B.useCallback)(async()=>{try{await ve(),Ee(!1),we(!1)}catch(e){Oe(e instanceof Error?e.message:`Could not stop mobile access`)}},[]);LB(e=>{e?_t():vt()}),(0,B.useEffect)(()=>{FB(Te)},[Te]);let yt=Du(`(max-width: 768px)`),bt=vQ(O.state===`checking`,T,E.current);if(!bt&&O.state!==`needed`&&(E.current=!0),bt)return L(`div`,{className:`app`,children:z(`main`,{className:`startup`,role:`status`,"aria-label":`Starting GAIA`,children:[L(`div`,{className:`loading-spinner`,"aria-hidden":`true`}),L(`p`,{className:`startup-text`,children:`Starting GAIA…`})]})});if(O.state===`upgrading`)return L(`div`,{className:`app`,children:z(`main`,{className:`startup`,role:`status`,"aria-live":`polite`,"aria-label":e(`setup.upgrading.notice`),children:[L(`div`,{className:`loading-spinner`,"aria-hidden":`true`}),L(`p`,{className:`startup-text`,children:e(`setup.upgrading.notice`)})]})});if(O.state===`needed`||O.state===`addingLocal`||te){let e=te?()=>ne(!1):O.state===`addingLocal`?pt:void 0;return z(`div`,{className:`app`,children:[L(zY,{onReady:e=>{ne(!1),ft(e)},onClose:e}),L(bK,{}),L(LZ,{})]})}let xt=!c&&!l?MV():void 0,St=c?L(B.Suspense,{fallback:L(PQ,{}),children:L(yQ,{})}):t?L(tG,{sessionId:t},t):L(hK,{onSend:ot,initialText:ge,focusRequest:ye,agentMissing:de,agentRefused:j},`${xe}:${ge}`);return z(`div`,{className:`app`,children:[!u&&L(`button`,{className:`sidebar-toggle`,onClick:()=>f(!0),"aria-label":e(`sidebar.open`),children:L(so,{size:18})}),L(`div`,{className:`sidebar-overlay ${u?`visible`:``}`,onClick:()=>f(!1),"aria-hidden":`true`}),L(cZ,{area:`sidebar`,variant:`compact`,children:L(Md,{onNewChat:ct,onMobileAccess:yt?void 0:()=>void _t(),tunnelActive:Te})}),z(`div`,{className:`main-content`,children:[(O.state===`ready`||O.state===`checking`||O.state===`serverDown`&&Pe)&&L(FZ,{onRetry:tt,backendSlow:Je,backendError:Xe}),O.state===`serverDown`&&!Pe&&z(`div`,{className:`app-notice is-warning`,role:`status`,children:[L(`span`,{children:e(O.modelListUnread?`setup.modelListUnread.notice`:`setup.serverDown.notice`)}),L(`button`,{type:`button`,className:`link-btn`,onClick:()=>void Ne(!0),children:e(`setup.unknown.retry`)}),!O.modelListUnread&&L(`button`,{type:`button`,className:`link-btn`,onClick:()=>ne(!0),children:e(`setup.serverDown.setup`)})]}),O.state===`unknown`&&(O.upgradeFailed?z(P.Fragment,{children:[z(`div`,{className:`app-notice is-warning`,role:`status`,children:[L(`span`,{children:e(`setup.upgrading.failed`,{error:O.error})}),L(`button`,{type:`button`,className:`link-btn`,onClick:()=>void Ne(),children:e(`setup.upgrading.retry`)})]}),L(dY,{className:`app-go-back`})]}):z(`div`,{className:`app-notice is-warning`,role:`status`,children:[L(`span`,{children:e(`setup.unknown.failed`,{error:O.error})}),L(`button`,{type:`button`,className:`link-btn`,onClick:()=>void Ne(),children:e(`setup.unknown.retry`)})]})),(!u||d)&&L(xl,{placement:`main`}),de&&L(KZ,{onInstalled:Re,noBuild:le}),S&&z(`div`,{className:`app-notice${S.ok?``:` is-warning`}`,role:`status`,children:[L(`span`,{children:S.message}),!S.ok&&L(`button`,{type:`button`,className:`link-btn`,onClick:()=>{C(),y(`model`)},children:`Pick a model`}),L(`button`,{type:`button`,className:`app-notice-close`,onClick:C,"aria-label":`Dismiss`,children:L(nc,{size:14})})]}),L(cZ,{resetKey:c?`memory`:t??`new-${ye}`,area:`main`,children:St})]}),xt&&L(gH,{api:xt}),l&&L(B.Suspense,{fallback:null,children:L(bQ,{})}),o&&L(B.Suspense,{fallback:null,children:L(xQ,{})}),s&&L(B.Suspense,{fallback:null,children:L(SQ,{onStartChat:st})}),w&&L(`div`,{className:`notification-center-popover`,children:L(HZ,{onClose:()=>D(!1),onOpenChat:ut})}),Ce&&L(B.Suspense,{fallback:null,children:L(CQ,{isOpen:Ce,onClose:()=>we(!1),onStop:()=>void vt(),error:De,setupCommands:ke,onRetry:()=>void _t()})}),b&&L(xZ,{onUseSkill:dt}),L(bK,{}),L(NK,{}),mt&&L(IK,{onClose:()=>gt(!1)}),L(LZ,{}),pe&&z(`div`,{className:`toast toast-dismissible`,role:`alert`,children:[L(`span`,{children:pe}),L(`button`,{type:`button`,className:`toast-dismiss`,onClick:()=>me(null),"aria-label":e(`banner.dismiss`),children:L(nc,{size:14,"aria-hidden":`true`})})]})]})}var RQ=`agent-refresh`,zQ={"pre-checks":`engine.stage.preChecks`,"ensure-uv":`engine.stage.ensureUv`,"create-venv":`engine.stage.createVenv`,"install-package":`engine.stage.installPackage`,verify:`engine.stage.verify`,[RQ]:`engine.stage.agentRefresh`,start:`engine.stage.start`},BQ={disk:`engine.hint.disk`,network:`engine.hint.network`,tls:`engine.hint.tls`,locked:`engine.hint.locked`,daemon:`engine.hint.daemon`};function VQ(e,t){if(!e)return t(`engine.stage.neutral`);let n=zQ[e];return n?t(n):(console.warn(`[EngineInstallScreen] install stage "${e}" has no label`),t(`engine.stage.neutral`))}function HQ(e,t){return e.reason?t(BQ[e.reason]):t(e.stage===RQ?`engine.hint.agent`:`engine.hint.other`)}function UQ(e){return e.reason===`locked`&&e.lockedBy?.length?e.lockedBy:null}function WQ(e,t){let n=e.name??String(e.pid),r=e.folder;return e.isGaia?r?t(`engine.locked.gaia`,{name:n,folder:r}):t(`engine.locked.gaiaNoFolder`,{name:n}):r?t(`engine.locked.other`,{name:n,folder:r}):t(`engine.locked.otherNoFolder`,{name:n})}function GQ({status:e}){let t=R(),n=VQ(e.stage,t);return z(`div`,{className:`engine-progress`,role:`status`,children:[z(`div`,{className:`engine-progress-head`,children:[L(`span`,{children:n}),e.percent!==null&&z(`bdi`,{dir:`ltr`,children:[e.percent,`%`]})]}),L(`progress`,{className:`engine-bar`,"aria-label":n,max:100,value:e.percent??void 0})]})}function KQ({error:e,busy:t,notice:n,onRetry:r,onCloseLockers:i,onContinue:a,onRevert:o,onOpenLog:s}){let c=R(),l=UQ(e),u=l!==null&&l.every(e=>e.isGaia),d=(l?.length??0)>1;return z(`div`,{className:`engine-failure`,children:[z(`div`,{role:`alert`,children:[l?z(P.Fragment,{children:[l.map(e=>L(`p`,{className:`engine-hint`,children:WQ(e,c)},e.pid)),!u&&L(`p`,{className:`engine-hint`,children:c(d?`engine.locked.closeThenMany`:`engine.locked.closeThen`)})]}):L(`p`,{className:`engine-hint`,children:HQ(e,c)}),L(`p`,{className:`engine-error`,children:L(`bdi`,{dir:`ltr`,children:e.message})})]}),u&&L(`button`,{type:`button`,className:`btn-primary engine-retry`,disabled:t,onClick:i,autoFocus:!0,children:c(d?`engine.locked.closeMany`:`engine.locked.close`)}),L(`button`,{type:`button`,className:`${u?`btn-secondary`:`btn-primary`} engine-retry`,disabled:t,onClick:r,autoFocus:!u,children:c(`engine.tryAgain`)}),e.stage===RQ&&L(`button`,{type:`button`,className:`btn-secondary engine-retry`,disabled:t,onClick:a,children:c(`engine.continueWithout`)}),e.previousVersion&&L(`button`,{type:`button`,className:`btn-secondary engine-retry`,disabled:t,onClick:o,children:c(`update.chip.goBack`,{version:e.previousVersion})}),n&&L(`p`,{className:`engine-error`,role:`alert`,children:L(`bdi`,{dir:`ltr`,children:n})}),z(`details`,{className:`engine-details`,children:[L(`summary`,{children:c(`engine.details`)}),L(`pre`,{className:`engine-log`,dir:`ltr`,children:e.logTail.join(`
|
|
222
|
+
`)}),L(`button`,{type:`button`,className:`btn-secondary`,onClick:s,children:c(`engine.openLog`)})]})]})}function qQ(){let e=R(),[t,n]=(0,B.useState)({phase:`running`,stage:null,percent:null,message:``,error:null}),[r,i]=(0,B.useState)(!1),[a,o]=(0,B.useState)(null),s=(0,B.useCallback)(e=>{console.error(`[EngineInstallScreen] the desktop app did not answer`,e),o(e instanceof Error?e.message:String(e))},[]);(0,B.useEffect)(()=>{let e=window.gaiaInstall,t=e.onProgress(n);return e.status().then(n).catch(s),t},[s]);let c=(0,B.useCallback)(()=>{i(!0),o(null),window.gaiaInstall.retry().catch(s).finally(()=>i(!1))},[s]),l=(0,B.useCallback)(()=>{i(!0),o(null),window.gaiaInstall.closeLockingPrograms().catch(s).finally(()=>i(!1))},[s]),u=(0,B.useCallback)(()=>{i(!0),o(null),window.gaiaInstall.continueWithoutAgentUpdate().catch(s).finally(()=>i(!1))},[s]),d=(0,B.useCallback)(()=>{i(!0),o(null),window.gaiaInstall.revert().then(e=>{e||i(!1)}).catch(e=>{s(e),i(!1)})},[s]),f=(0,B.useCallback)(()=>{o(null),window.gaiaInstall.openLogFile().then(e=>{e.ok||o(e.message)}).catch(s)},[s]),{error:p}=t,m=t.phase===`failed`&&p,h=e(m?p.stage===RQ?`engine.failed.agentTitle`:`engine.failed.title`:`engine.title`);return L(`div`,{className:`app`,children:L(`main`,{className:`engine`,children:z(`div`,{className:`engine-inner`,children:[L(`h1`,{className:`engine-title`,children:h}),m?L(KQ,{error:p,busy:r,notice:a,onRetry:c,onCloseLockers:l,onContinue:u,onRevert:d,onOpenLog:f}):z(P.Fragment,{children:[L(`p`,{className:`engine-lede`,children:e(`engine.lede`)}),L(GQ,{status:t}),a&&L(`p`,{className:`engine-error`,role:`alert`,children:L(`bdi`,{dir:`ltr`,children:a})})]})]})})})}function JQ(){return!!window.gaiaInstall&&new URLSearchParams(window.location.search).get(`engine`)===`install`}async function YQ(e){if(!e.isProduction||e.protocol!==`https:`&&e.protocol!==`http:`||!e.serviceWorker)return!1;try{return await e.serviceWorker.register(`./sw.js`,{scope:`./`}),!0}catch(e){return console.error(`[pwa] Service worker registration failed, so the UI is not cached for an installed app:`,e),!1}}wl(),ot();var XQ=localStorage.getItem(`gaia-chat-theme`);Qe(Ee(XQ===`light`||XQ===`dark`?XQ:`system`));var ZQ=N.getState();nt(ZQ.palette,ZQ.customColors,ZQ.theme),Se(ZQ.locale),r(),Mt(),ac.createRoot(document.getElementById(`root`)).render(L(B.StrictMode,{children:L(cZ,{area:`app`,variant:`window`,children:JQ()?L(qQ,{}):L(LQ,{})})})),window.addEventListener(`load`,()=>{YQ({isProduction:!0,protocol:window.location.protocol,serviceWorker:`serviceWorker`in navigator?navigator.serviceWorker:void 0})});export{tU as $,Mo as $t,CG as A,xr as An,mu as At,FG as B,Js as Bt,YG as C,ai as Cn,ck as Ct,xG as D,Yr as Dn,ud as Dt,SG as E,$r as En,yv as Et,zG as F,Sc as Ft,PG as G,Es as Gt,jG as H,Ws as Ht,_G as I,hc as It,KG as J,is as Jt,WG as K,us as Kt,wG as L,ic as Lt,yG as M,Uc as Mt,vG as N,Bc as Nt,DG as O,Lr as On,V as Ot,TG as P,zc as Pt,cU as Q,Io as Qt,OG as R,nc as Rt,AG as S,si as Sn,sk as St,$G as T,ti as Tn,Mv as Tt,NG as U,Hs as Ut,IG as V,Ks as Vt,MG as W,Os as Wt,BG as X,Ko as Xt,EG as Y,Qo as Yt,IW as Z,Ho as Zt,XG as _,yi as _n,Ok as _t,hZ as a,ka as an,HH as at,LG as b,di as bn,uk as bt,rX as c,la as cn,XL as ct,BY as d,Ui as dn,KL as dt,vo as en,$H as et,Vq as f,zi as fn,BL as ft,oK as g,Ti as gn,iN as gt,xK as h,ki as hn,zL as ht,DZ as i,qa as in,ZH as it,qG as j,pu as jt,kG as k,Dr as kn,Su as kt,oX as l,sa as ln,QL as lt,MK as m,ji as mn,VL as mt,jZ as n,Za as nn,nU as nt,cX as o,_a as on,jB as ot,LK as p,Ni as pn,RL as pt,ZG as q,cs as qt,TZ as r,Ya as rn,eU as rt,sX as s,da as sn,iR as st,XZ as t,fo as tn,QH as tt,aX as u,qi as un,WL as ut,QG as v,_i as vn,bk as vt,bG as w,ri as wn,wv as wt,RG as x,li as xn,hk as xt,UG as y,hi as yn,gk as yt,JG as z,ec as zt};
|