@amd-gaia/agent-ui 0.27.0-rc.21 → 0.27.0-rc.22
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-DD-RVnWp.js → AdvancedSettings-CDgnCM7O.js} +1 -1
- package/dist/assets/{AutomationsSettings-rLo6mWU6.js → AutomationsSettings-D4YxWU3Q.js} +1 -1
- package/dist/assets/{ConnectorsPane-DdYiHRhD.js → ConnectorsPane-BUyODU0h.js} +1 -1
- package/dist/assets/{DocumentLibrary-BY3B6vwk.js → DocumentLibrary-fGmvS5bZ.js} +1 -1
- package/dist/assets/{FileBrowser-DZVXejEq.js → FileBrowser--eUruCkG.js} +1 -1
- package/dist/assets/{MemoryDashboard-BlNGTH6-.js → MemoryDashboard-BX86YZvy.js} +1 -1
- package/dist/assets/{MessagingSettings-BHd7ftWx.js → MessagingSettings-DQWJatxm.js} +1 -1
- package/dist/assets/{MobileAccessModal-DbSJ06l7.js → MobileAccessModal-B3248O8O.js} +1 -1
- package/dist/assets/{ScheduleManager-ClE3JXAN.js → ScheduleManager-C_dc4t2S.js} +1 -1
- package/dist/assets/{index-DDO2kO5x.js → index-Cvtm_IdK.js} +4 -4
- package/dist/index.html +1 -1
- package/dist/sw.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ConnectorsPane-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ConnectorsPane-BUyODU0h.js","./rolldown-runtime-XKyaHtl9.js","./useFocusTrap-Cy_PGcml.js","./ConnectorsPane-BxG6qzLb.css","./MessagingSettings-DQWJatxm.js","./AutomationsSettings-D4YxWU3Q.js","./AdvancedSettings-CDgnCM7O.js","./MemoryDashboard-BX86YZvy.js","./MemoryDashboard-Bfy9g6TS.css","./ScheduleManager-C_dc4t2S.js","./ScheduleManager-CEBoBLPV.css","./DocumentLibrary-fGmvS5bZ.js","./folderIndexResult-BIoxqF5I.js","./DocumentLibrary-Ctwq2m2t.css","./FileBrowser--eUruCkG.js","./FileBrowser-DxS29ShT.css","./MobileAccessModal-B3248O8O.js","./MobileAccessModal-DSFjH6di.css"])))=>i.map(i=>d[i]);
|
|
2
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,$t as o,A as s,An as c,At as l,B as u,Bn as d,Br as f,Bt as p,C as m,Ci as h,Cn as g,Cr as _,Ct as v,D as y,Dn as b,Dt as x,E as S,En as C,Et as w,F as T,Fn as E,Ft as ee,G as D,Gn as O,Gr as te,H as k,Hn as A,Hr as ne,Ht as re,I as j,In as ie,Ir as ae,It as oe,J as se,Jn as ce,Jr as le,Jt as ue,K as M,Kr as de,Kt as fe,L as N,Ln as pe,Lt as me,M as he,Mn as ge,Mt as _e,N as ve,Nn as ye,Nt as be,O as xe,On as Se,Ot as Ce,P as we,Pn as Te,Pt as Ee,Q as De,Qn as Oe,Qr as ke,Qt as Ae,R as je,Rn as Me,S as Ne,Si as Pe,Sn as Fe,St as Ie,T as Le,Ti as Re,Tn as ze,Tt as Be,U as Ve,Un as He,Ur as Ue,Ut as We,V as Ge,Vn as Ke,Vr as qe,Vt as Je,W as Ye,Wn as Xe,Wr as Ze,Wt as Qe,X as $e,Xn as et,Xr as tt,Xt as nt,Y as rt,Yn as it,Yr as at,Yt as ot,Z as st,Zn as ct,Zr as lt,Zt as ut,_ as dt,_i as ft,_n as pt,_r as mt,a as ht,ai as gt,an as _t,ar as vt,at as yt,b as bt,bi as xt,bn as St,br as Ct,bt as wt,c as P,ci as Tt,cn as Et,cr as Dt,ct as Ot,d as kt,di as At,dn as jt,dr as Mt,dt as Nt,ei as Pt,en as Ft,er as It,et as Lt,f as Rt,fi as zt,fn as Bt,fr as Vt,ft as Ht,g as Ut,gi as F,gn as Wt,gr as Gt,gt as Kt,h as qt,hi as Jt,hn as Yt,hr as Xt,ht as Zt,i as Qt,ii as $t,ir as en,it as tn,j as nn,jn as rn,jt as an,k as on,kt as sn,l as I,li as cn,ln,lr as un,lt as dn,m as fn,mi as pn,mn,mr as hn,mt as gn,n as _n,ni as vn,nn as yn,nr as bn,nt as xn,o as Sn,oi as Cn,on as wn,or as Tn,ot as En,p as Dn,pi as On,pn as kn,pr as An,pt as jn,qn as Mn,qr as Nn,qt as Pn,r as Fn,ri as In,rn as Ln,rr as Rn,rt as zn,s as L,si as Bn,sn as Vn,sr as Hn,t as Un,ti as Wn,tn as Gn,tr as Kn,tt as qn,u as R,ui as Jn,un as Yn,ur as Xn,ut as Zn,v as Qn,vi as $n,vn as er,vr as tr,vt as nr,w as rr,wi as z,wn as ir,wt as ar,x as B,xi as or,xr as sr,y as cr,yi as lr,yn as ur,yr as dr,yt as fr,z as pr,zn as mr,zt as hr}from"./useFocusTrap-Cy_PGcml.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 gr=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,D());else{var t=n(l);t!==null&&k(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function ee(){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&&k(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?D():S=!1}}}var D;if(typeof y==`function`)D=function(){y(ee)};else if(typeof MessageChannel<`u`){var O=new MessageChannel,te=O.port2;O.port1.onmessage=ee,D=function(){te.postMessage(null)}}else D=function(){_(ee,0)};function k(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,k(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,D()))),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}}}})),_r=n(((e,t)=>{t.exports=gr()})),vr=n((e=>{var t=Re();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`})),yr=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=vr()})),br=n((e=>{var t=_r(),n=Re(),r=yr();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`),ee=Symbol.for(`react.portal`),D=Symbol.for(`react.fragment`),O=Symbol.for(`react.strict_mode`),te=Symbol.for(`react.profiler`),k=Symbol.for(`react.consumer`),A=Symbol.for(`react.context`),ne=Symbol.for(`react.forward_ref`),re=Symbol.for(`react.suspense`),j=Symbol.for(`react.suspense_list`),ie=Symbol.for(`react.memo`),ae=Symbol.for(`react.lazy`),oe=Symbol.for(`react.activity`),se=Symbol.for(`react.legacy_hidden`),ce=Symbol.for(`react.memo_cache_sentinel`),le=Symbol.for(`react.view_transition`),ue=Symbol.for(`react.recoverable`),M=Symbol.iterator;function de(e){return typeof e!=`object`||!e?null:(e=M&&e[M]||e[`@@iterator`],typeof e==`function`?e:null)}var fe=Symbol.for(`react.client.reference`);function N(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===fe?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case D:return`Fragment`;case te:return`Profiler`;case O:return`StrictMode`;case re:return`Suspense`;case j:return`SuspenseList`;case oe:return`Activity`;case le:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case ee:return`Portal`;case A:return e.displayName||`Context`;case k:return(e._context.displayName||`Context`)+`.Consumer`;case ne:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ie:return t=e.displayName||null,t===null?N(e.type)||`Memo`:t;case ae:t=e._payload,e=e._init;try{return N(e(t))}catch{}}return null}var pe=Array.isArray,me=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,he=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ge={pending:!1,data:null,method:null,action:null},_e=[],ve=-1;function ye(e){return{current:e}}function be(e){0>ve||(e.current=_e[ve],_e[ve]=null,ve--)}function xe(e,t){ve++,_e[ve]=e.current,e.current=t}var Se=ye(null),Ce=ye(null),we=ye(null),Te=ye(null);function Ee(e,t){switch(xe(we,t),xe(Ce,e),xe(Se,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}}be(Se),xe(Se,e)}function De(){be(Se),be(Ce),be(we)}function Oe(e){var t=e.memoizedState;t!==null&&(vh._currentValue=t.memoizedState,xe(Te,e)),t=Se.current;var n=Sp(t,e.type);t!==n&&(xe(Ce,e),xe(Se,n))}function ke(e){Ce.current===e&&(be(Se),be(Ce)),Te.current===e&&(be(Te),vh._currentValue=ge)}var Ae,je;function Me(e){if(Ae===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Ae=t&&t[1]||``,je=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+Ae+e+je}var Ne=!1;function Pe(e,t){if(!e||Ne)return``;Ne=!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(`
|
|
@@ -188,7 +188,7 @@ Error generating stack: `+e.message+`
|
|
|
188
188
|
`)}function JI(e,t){return e?new Date(e).toLocaleString(Fn(t),{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`,second:`2-digit`,hour12:!0}):``}function YI(e,t,n=new Date){if(!e)return``;let r=new Date(e),i=Fn(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 XI=`Cancelled.`,ZI=[[`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`]],QI=/(?:^|\n\n)Before it stopped, it had started these tools: (.+)\.$/;function $I(e){let t=e.trim(),n=ZI.find(([e])=>t.endsWith(e));if(!n)return null;t=t.slice(0,-n[0].length).trimEnd();let r=QI.exec(t);return r&&(t=t.slice(0,r.index).trimEnd()),{body:t,notice:n[1],tools:r?r[1]:null}}function eL(e,t,n=!1){return t?`stopped`:$I(e)?`interrupted`:n?`failed`:void 0}var tL=320;function nL({original:e,draft:t,onDraft:n,onSend:r,onCancel:i,confirming:a=!1}){let o=L(),{text:s,links:c}=(0,V.useMemo)(()=>sy(e),[e]),[l,u]=(0,V.useState)(()=>t==null?s:sy(t).text),d=(0,V.useRef)(null),f=l.trim()!==``&&l!==s,p=()=>r(cy(l,c));return(0,V.useLayoutEffect)(()=>{let e=d.current;e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},[]),(0,V.useLayoutEffect)(()=>{let e=d.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,tL)}px`)},[l]),R(`div`,{className:`msg-edit`,children:[I(`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`,...Rt}),c.length>0&&I(`ul`,{className:`msg-edit-attachments`,"aria-label":o(`composer.attached`),children:c.map((e,t)=>R(`li`,{className:`msg-edit-attachment`,children:[I(_a,{size:14,"aria-hidden":`true`}),I(`span`,{className:`msg-edit-attachment-name`,title:e.name,dir:`auto`,children:e.name})]},t))}),!a&&R(`div`,{className:`msg-edit-actions`,children:[I(`button`,{type:`button`,className:`btn-secondary msg-edit-btn`,onClick:i,children:o(`msg.editCancel`)}),I(`button`,{type:`button`,className:`btn-primary msg-edit-btn`,onClick:p,disabled:!f,children:o(`msg.editSend`)})]})]})}var rL=/^\[schedule-run\] Run #(\d+) \u00b7 (.+)$/;function iL({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=L();Qc();let w=(0,V.useMemo)(()=>{if(e.role!==`assistant`||!n)return{steps:n,echoed:!1,endedBy:null};let r=BF(n,e.content);return t?{steps:r,echoed:!1,endedBy:null}:PI(r,e.content)},[n,e.content,e.role,t]),T=e.role===`assistant`&&(w.echoed||e.failed===!0||e.stalled===!0||MI(e.content)),E=il(),ee=Ec(e=>e.show),D=B(e=>e.openSettings),O=B(e=>e.jumpToSetting),te=(0,V.useMemo)(()=>T&&!t?QF(e.content):null,[T,t,e.content]),k=e.role===`assistant`?e.stopState??(e.content.trim()===XI?`stopped`:void 0):void 0,A=(0,V.useMemo)(()=>e.role===`assistant`&&!t?$I(e.content):null,[e.content,e.role,t]),ne=A?null:w.endedBy,re=(0,V.useMemo)(()=>e.role===`user`?nI(e.content):null,[e.content,e.role]),j=(0,V.useMemo)(()=>re?wd(re.text):KI(A?A.body:ne?e.content.trimEnd().slice(0,-ne.length):e.content,!!t),[e.content,re,t,A,ne]),ie=!!j.trim()&&!(k&&j.trim()===XI),ae=e.turnSummary?.files,oe=(0,V.useMemo)(()=>ae?.map(e=>e.path)??[],[ae]),se=`${e.session_id}:${e.id}`,[ce,le]=BO(),[ue,M]=(0,V.useState)(!1),de=e.role===`user`&&UO(e.content),fe=(0,V.useMemo)(()=>de?GO(e.content):null,[de,e.content]),[N,pe]=(0,V.useState)(!1),me=(0,V.useId)(),he=(0,V.useRef)(null),ge=(0,V.useRef)(!1),_e=(0,V.useCallback)(()=>{N&&(ge.current=!0),pe(!N)},[N]);(0,V.useEffect)(()=>{!N&&ge.current&&(ge.current=!1,he.current?.scrollIntoView?.({block:`nearest`}))},[N]);let ve=(0,V.useRef)(null);(0,V.useEffect)(()=>()=>{ve.current&&clearTimeout(ve.current)},[]);let ye=(0,V.useCallback)(()=>{le(e.role===`assistant`?sP(j):e.content)},[le,j,e.content,e.role]),be=(0,V.useCallback)(()=>{ue?(M(!1),ve.current&&clearTimeout(ve.current),a?.(e.id)):(M(!0),ve.current&&clearTimeout(ve.current),ve.current=setTimeout(()=>M(!1),3e3))},[ue,e.id,a]),[xe,Se]=(0,V.useState)(null),Ce=(0,V.useCallback)(e=>{_>0?Se(()=>e):e()},[_]),we=(0,V.useCallback)(()=>{Ce(()=>o?.(e))},[e,o,Ce]),Te=e.created_at?C(e.role===`user`?`msg.sent`:`msg.replied`,{time:JI(e.created_at,C)}):void 0,Ee=e.role===`system`?rL.exec(e.content):null;return Ee?I(`div`,{className:`msg-run-divider`,role:`separator`,children:C(`msg.scheduledRun`,{n:Ee[1],time:Ee[2]})}):I(`div`,{className:`msg msg-${e.role} ${T?`msg-error`:``}${v?` msg-latest`:``}`,title:Te,children:R(`div`,{className:`msg-inner`,children:[R(`div`,{className:`msg-header`,children:[I(`div`,{className:`msg-header-left`}),!t&&!f&&R(`div`,{className:`msg-actions`,children:[e.role===`user`&&d&&h&&I(`button`,{type:`button`,className:`msg-action-btn`,onClick:()=>d(e),title:C(`msg.edit`),"aria-label":C(`msg.edit`),children:I(Wo,{size:12})}),e.role===`user`&&o&&I(`button`,{className:`msg-action-btn`,onClick:we,title:C(`msg.resend`),"aria-label":C(`msg.resend`),children:I(os,{size:12})}),e.role===`assistant`&&u&&I(`button`,{type:`button`,className:`msg-action-btn`,onClick:u,title:C(`msg.tryAgain`),"aria-label":C(`msg.tryAgain`),children:I(ms,{size:12})}),s,e.role===`assistant`&&!T&&ie&&I(oF,{messageId:se,content:j}),ie&&I(`button`,{className:`msg-copy ${ce===`idle`?``:ce}`,onClick:ye,title:C(ce===`copied`?`msg.copied`:ce===`failed`?`msg.copyFailed`:`msg.copy`),"aria-label":C(ce===`copied`?`msg.copiedAria`:ce===`failed`?`msg.copyFailed`:`msg.copy`),children:I(ce===`copied`?ri:ce===`failed`?yi:Fi,{size:12})}),a&&I(`button`,{className:`msg-action-btn msg-delete ${ue?`confirm`:``}`,onClick:be,title:C(ue?`msg.confirmDelete`:`msg.delete`),"aria-label":C(ue?`msg.confirmDeleteAria`:`msg.delete`),children:I(Qs,{size:12})})]})]}),R(`div`,{className:`msg-body`,children:[e.role===`assistant`&&(w.steps&&w.steps.length>0||t)&&I(Wk,{steps:w.steps??[],isActive:r??!1,running:!!t,awaitingUser:S,toolStatus:t?x:null,answer:t?void 0:j,liveLine:t&&I(wI,{active:!!r||!j,label:b,awaitingUser:S})}),T&&R(`div`,{className:`error-banner`,children:[I(ec,{size:14}),I(`span`,{children:C(te&&te.kind!==`unknown`?`failedTurn.${te.kind}.title`:`msg.error`)})]}),(e.cards??i)?.map((e,t)=>I(iP,{render:e.render,data:e.data},t)),e.page_elements&&e.page_elements.length>0&&I(FF,{elements:e.page_elements}),f&&h?I(nL,{original:e.content,draft:p,onDraft:m,onSend:t=>Ce(()=>h(e,t)),onCancel:()=>{Se(null),g?.()},confirming:xe!==null&&!t}):de?R(P.Fragment,{children:[!N&&fe?R(`div`,{ref:he,id:me,className:`msg-excerpt md-content`,children:[I(`div`,{className:`msg-excerpt-lines`,dir:`auto`,children:fe.head}),I(`div`,{className:`msg-excerpt-gap`,children:C.plural(`msg.moreLines`,fe.hidden)}),I(`div`,{className:`msg-excerpt-lines`,dir:`auto`,children:fe.tail})]}):I(`div`,{ref:he,id:me,className:`msg-collapsible${N?``:` is-collapsed`}`,children:I(OL,{content:j})}),I(qO,{expanded:N,onToggle:_e,controls:me,collapsedLabel:C.hint(C(`msg.showAll`),KO(C,e.content)),expandedLabel:C(`msg.showLess`),className:`msg-expand-toggle`})]}):te?.raw?R(P.Fragment,{children:[I(`p`,{className:`msg-failed-lead`,children:C(`failedTurn.${te.kind}.body`)}),R(`details`,{className:`msg-failed-details`,children:[I(`summary`,{children:C(`failedTurn.details`)}),I(OL,{content:$F(j)})]})]}):!(k&&j.trim()===XI)&&I(OL,{content:j,showCursor:t&&!!j&&!r,isStreaming:t,writtenFiles:oe}),!f&&re&&I(iI,{images:re.images}),xe&&!t&&R(`div`,{className:`msg-drop-confirm`,role:`alertdialog`,"aria-labelledby":`${me}-drop`,children:[I(`span`,{id:`${me}-drop`,children:C.plural(`msg.dropLater`,_)}),R(`div`,{className:`msg-edit-actions`,children:[I(`button`,{type:`button`,className:`btn-secondary msg-edit-btn`,onClick:()=>Se(null),autoFocus:!0,children:C(`msg.editCancel`)}),I(`button`,{type:`button`,className:`btn-primary msg-edit-btn`,onClick:()=>{Se(null),xe()},children:C(`msg.dropLaterGo`)})]})]}),k&&R(`div`,{className:`msg-stopped${k===`unconfirmed`||e.stopError?` is-unconfirmed`:``}`,role:`note`,children:[I(Ks,{size:9,fill:`currentColor`,"aria-hidden":`true`}),I(`span`,{children:k===`unconfirmed`?C(`msg.stoppedUnconfirmed`):e.stopError?C(`msg.stoppedError`,{error:e.stopError}):C(`msg.stopped`)})]}),A&&I(`p`,{className:`msg-cut-off`,role:`note`,children:C.compose(e=>A.tools?`${e(`msg.cutOff.toolsRan`,{tools:A.tools})} ${e(A.notice)}`:e(A.notice))}),ne&&I(`p`,{className:`msg-cut-off`,role:`note`,dir:`auto`,children:ne}),l&&k&&!t&&j.trim()&&j.trim()!==XI&&R(`button`,{type:`button`,className:`msg-try-again`,onClick:l,children:[I(Xo,{size:12,"aria-hidden":`true`}),C(`msg.continue`)]}),c&&!t&&R(`button`,{type:`button`,className:`msg-try-again`,onClick:c,children:[I(ms,{size:12,"aria-hidden":`true`}),C(`msg.tryAgain`)]}),te?.sections.map(e=>R(`button`,{type:`button`,className:`msg-try-again`,onClick:()=>{let t=te?.targets[e];t?O({section:e,target:t}):D(e)},children:[I(ws,{size:12,"aria-hidden":`true`}),C.compose(t=>t(`failedTurn.openSettings`,{tab:t(`settings.section.${e}`)}))]},e)),(T||ne)&&!t&&AI(ne??e.content)?R(`button`,{type:`button`,className:`msg-try-again`,onClick:()=>ee(`agent`),children:[I(vs,{size:12,"aria-hidden":`true`}),C(`logs.agentLog`)]}):(T||e.role===`assistant`&&OI(e.content))&&!t&&(e.turnSummary?.model?.remote??E?.remote)===!1&&R(`button`,{type:`button`,className:`msg-try-again`,onClick:()=>ee(`model_server`),children:[I(vs,{size:12,"aria-hidden":`true`}),C(`logs.serverLog`)]}),e.role===`assistant`&&!t&&(CF(e.content)||CF(e.failureText??``))&&I(EF,{classes:jI,note:C(`msg.reportNote`)}),e.role===`assistant`&&!t&&XA(j)&&I(nj,{content:j}),e.role===`assistant`&&!t&&(e.stats||y!=null||e.created_at)&&R(`div`,{className:`msg-stats`,"aria-label":C(`msg.about`),children:[e.created_at&&I(`span`,{className:`msg-stats-ts`,title:JI(e.created_at,C),children:YI(e.created_at,C)}),e.stats?.retried&&e.stats.model&&I(`span`,{title:`This answer was kept from Retry with… (${e.stats.model})`,children:el(e.stats.model)}),!e.stats?.retried&&e.stats?.route?.model&&I(`span`,{className:`msg-stats-route`,title:C(`msg.route`,{reason:e.stats.route.reason??``}),children:el(e.stats.route.model)}),I(zj,{latencyMs:y,stats:e.stats,ended:eL(e.content,k,T||!!ne)})]}),e.role===`assistant`&&!t&&e.stats?.route?.degraded&&e.stats.route.notice&&I(`div`,{className:`msg-route-notice`,role:`status`,children:e.stats.route.notice}),e.role===`assistant`&&!t&&e.id>0&&e.session_id&&I(GP,{sessionId:e.session_id,messageId:e.id,ranChangingTool:kP(n),agentProgram:e.agentProgram}),e.role===`assistant`&&I(sF,{messageId:se}),e.role===`assistant`&&I(cF,{messageId:se})]})]})})}var aL=(0,V.createContext)(!1);function oL({lang:e,code:t}){let n=L(),[r,i]=BO(),[a,o]=(0,V.useState)(!1),s=(0,V.useContext)(aL),c=(0,V.useId)(),l=HO(t),u=l>(s?20:25);return R(`div`,{className:`code-block${u&&!a?` is-collapsed`:``}`,dir:`ltr`,children:[R(`div`,{className:`code-header`,children:[I(`span`,{className:`code-lang`,children:e||`code`}),R(`button`,{className:`code-copy ${r===`idle`?``:r}`,onClick:()=>i(t),title:n(r===`copied`?`msg.copied`:r===`failed`?`msg.copyFailed`:`code.copy`),"aria-label":n(r===`copied`?`msg.copiedAria`:r===`failed`?`msg.copyFailed`:`code.copyAria`),children:[I(r===`copied`?ri:r===`failed`?yi:Fi,{size:13}),I(`span`,{children:n(r===`copied`?`code.copied`:r===`failed`?`msg.copyFailed`:`code.copy`)})]})]}),I(`pre`,{id:c,children:I(`code`,{children:t})}),u&&I(qO,{expanded:a,onToggle:()=>o(e=>!e),controls:c,collapsedLabel:n(`code.expand`,{size:VO(n,l)}),expandedLabel:n(`code.collapse`),className:`code-expand-toggle`})]})}var sL=/(?<=["\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,cL=/[.:!']+$/,lL=RegExp(`^(?:${sL.source})$`,`i`),uL=(0,V.createContext)([]);function dL(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 fL(e){if(typeof e!=`string`)return null;let t=e.trim();return lL.test(t)?t:null}function pL({path:e,label:t}){let n=t=>{t.preventDefault(),pt(e).catch(e=>{F.ui.error(`Failed to open path`,e)})};return R(`span`,{className:`file-path-link`,dir:`ltr`,onClick:n,title:`Open in file explorer: ${bd(e)}`,role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n(e))},children:[I(xa,{size:12,className:`file-path-icon`}),bd(t??e)]})}function mL(e){return[...e.matchAll(new RegExp(sL.source,`gi`))].map(t=>{let n=t.index+t[0].length,r=`"“`.includes(e[t.index-1]??`
|
|
189
189
|
`)&&`"”`.includes(e[n]??`
|
|
190
190
|
`);return{start:t.index,path:r?t[0]:t[0].replace(cL,``)}})}function hL(e){let t=[],n=0;for(let{start:r,path:i}of mL(e))r>n&&t.push(e.slice(n,r)),t.push(I(pL,{path:i},r)),n=r+i.length;return t.length===0?e:(n<e.length&&t.push(e.slice(n)),I(P.Fragment,{children:t}))}var gL=(0,V.createContext)(mI([]));function _L({doc:e,page:t,t:n}){return R(`a`,{className:`citation-link`,href:x(e.id,t),target:`_blank`,rel:`noopener noreferrer`,dir:`ltr`,title:t?n(`citation.openPage`,{page:t}):n(`citation.open`,{name:bd(e.label)}),"data-doc-id":e.id,"data-page":t,children:[I(_a,{size:12,className:`citation-icon`,"aria-hidden":`true`}),bd(e.label)]})}function vL({doc:e,page:t,label:n,t:r}){return I(`a`,{className:`citation-page`,href:x(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 yL(e,t){let n=gI(e,t)[0];return CI(n?t.slice(0,n.start):t)}function bL(e,t,n,r){let i=mL(e),a=gI(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:I(vL,{doc:t,page:a.page,label:e.slice(r,s),t:n},`p${r}`)})}};if(r&&s(r,CI(e.slice(0,a[0]?.start??e.length)),0),a.forEach((t,r)=>{let i=CI(e.slice(t.end,a[r+1]?.start??e.length));o.push({start:t.start,end:t.end,node:I(_L,{doc:t.doc,page:i[0]?.page,t:n},`c${t.start}`)}),s(t.doc,i,t.end)}),o.length===0)return hL(e);o.sort((e,t)=>e.start-t.start);let c=[],l=0;for(let t of o)t.start>l&&c.push(I(V.Fragment,{children:hL(e.slice(l,t.start))},`t${l}`)),c.push(t.node),l=t.end;return l<e.length&&c.push(I(V.Fragment,{children:hL(e.slice(l))},`t${l}`)),I(P.Fragment,{children:c})}function xL(e,t){return typeof t==`string`?hI(e,t):null}function SL({children:e}){let t=(0,V.useContext)(gL),n=L(),r=V.Children.toArray(e),i=null,a=r.map((e,a)=>{if(typeof e==`string`){let r=bL(e,t,n,i);return i=null,I(V.Fragment,{children:r},`s${a}`)}if(i=null,V.isValidElement(e)&&e.type===wL){let o=xL(t,e.props.children);if(o){let e=r[a+1],s=typeof e==`string`?yL(t,e):[];return i=o,I(_L,{doc:o,page:s[0]?.page,t:n},`k${a}`)}}return e});return I(P.Fragment,{children:a})}function CL({tex:e,display:t}){let n=(0,V.useMemo)(()=>SD.renderToString(e,{displayMode:t,throwOnError:!1,errorColor:`var(--danger)`}),[e,t]),r=(0,V.useRef)(null),[i,a]=(0,V.useState)(!1);return(0,V.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]),I(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 wL({className:e,children:t,node:n,...r}){let i=(0,V.useContext)(gL),a=(0,V.useContext)(uL),o=L();if(e?.includes(`math-inline`))return I(CL,{tex:String(t),display:!1});let s=xL(i,t);if(s)return I(_L,{doc:s,t:o});let c=fL(t);if(c)return I(pL,{path:c});let l=dL(a,t);return l?I(pL,{path:l,label:String(t).trim()}):I(`code`,{className:`inline-code`,dir:`ltr`,...r,children:t})}var TL={code:wL,pre({children:e}){let t=V.Children.toArray(e)[0];if(V.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 I(CL,{tex:i,display:!0});let a=r?.[1]||``;return I(oL,{lang:a,code:i})}return I(`pre`,{dir:`ltr`,children:e})},table({children:e}){return I(`div`,{className:`md-table-wrap`,children:I(`table`,{className:`md-table`,dir:`auto`,children:e})})},a({href:e,children:t}){return ly(e)?I(gy,{href:e,children:t}):I(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`md-link`,children:t})},p({children:e}){return I(`p`,{className:`md-p`,dir:`auto`,children:I(SL,{children:e})})},h1({children:e}){return I(`h2`,{className:`md-h2`,dir:`auto`,children:I(SL,{children:e})})},h2({children:e}){return I(`h3`,{className:`md-h3`,dir:`auto`,children:I(SL,{children:e})})},h3({children:e}){return I(`h4`,{className:`md-h4`,dir:`auto`,children:I(SL,{children:e})})},h4({children:e}){return I(`h5`,{className:`md-h4`,dir:`auto`,children:I(SL,{children:e})})},ul({children:e}){return I(`ul`,{className:`md-ul`,dir:`auto`,children:e})},ol({children:e,start:t}){return I(`ol`,{className:`md-ol`,start:t,dir:`auto`,children:e})},li({children:e,className:t}){return I(`li`,{className:t?`md-li ${t}`:`md-li`,dir:`auto`,children:I(SL,{children:e})})},blockquote({children:e}){return I(`blockquote`,{className:`md-blockquote`,dir:`auto`,children:I(SL,{children:e})})},hr(){return I(`hr`,{className:`md-hr`})},td({children:e,className:t,style:n}){return I(`td`,{className:t,style:n,children:I(SL,{children:e})})},th({children:e,className:t,style:n}){return I(`th`,{className:t,style:n,children:I(SL,{children:e})})}},EL=[],DL=[OS,{singleDollarTextMath:!1}];function OL({content:e,showCursor:t,isStreaming:n=!1,writtenFiles:r=EL}){let i=B(e=>e.documents),a=(0,V.useMemo)(()=>mI(i),[i]),o=(0,V.useMemo)(()=>ID(e),[e]);return!e&&!t?null:!e&&t?I(`span`,{className:`cursor`}):I(aL.Provider,{value:n,children:I(gL.Provider,{value:a,children:I(uL.Provider,{value:r,children:R(`div`,{className:`md-content`,children:[I(Xv,{remarkPlugins:[gS,DL,HD,DD,kD],disallowedElements:[...ty],urlTransform:uy,components:TL,children:o}),t&&I(`span`,{className:`cursor`})]})})})})}var kL=()=>[...B.getState().messages].reverse().find(e=>e.role===`assistant`)?.id;function AL({busy:e}){let t=L(),[n,r]=(0,V.useState)({n:0,text:``}),i=(0,V.useRef)(kL());return(0,V.useEffect)(()=>{e&&(i.current=kL())},[e]),df(e,()=>{let e=B.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||MI(n.content);r(e=>({n:e.n+1,text:t(a?`live.replyFailed`:`live.replyReady`)}))}),I(`div`,{className:`turn-announcer`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:I(`span`,{children:n.text},n.n)})}function jL(e){return e.type===`status`&&e.status===`working`&&!e.phase&&(e.message??``).startsWith(`Model is processing`)}function ML(e){return e.phase===`loading_tools`?Qt()(`chat.loadingTools`):e.phase===`model_queue`&&e.queue?NL(e.queue):e.phase===`reasoning`&&typeof e.words==`number`?Qt().plural(`chat.reasoningWords`,e.words,{n:e.words.toLocaleString(`en-US`)}):(e.message||``).trim()}function NL(e){let t=Qt(),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 PL(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}}function FL(e){let t=new Map,n;for(let r of e)if(r.role===`user`&&r.created_at)n=new Date(r.created_at).getTime();else if(r.role===`assistant`&&r.created_at&&n!==void 0){let e=new Date(r.created_at).getTime()-n-(r.stats?.waiting_seconds??0)*1e3;e>0&&t.set(r.id,e),n=void 0}return t}var IL=`speech_model_downloaded`,LL=new Set([`tool`,`waiting`]);function RL(e){return e.livePhase&&!LL.has(e.livePhase)?e.liveStatus:null}function zL(e,t){let n=B.getState(),r=e.status,i=ML(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===IL&&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`||jL(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=PL({...e,message:i},t);o&&n.addAgentStep(o)}var BL=/\s*\{\s*"?(?:tool|thought|goal)"?\s*:\s*"[^"]*"[^}]*(?:"?tool_args"?\s*:\s*\{[^}]*\})?\s*\}/g;function VL(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,`
|
|
191
|
-
`).replace(/\\\\/g,`\\`)}function HL(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 UL(e){let t=(e||[]).filter(e=>typeof e.render==`string`&&e.render.length>0).reduce((e,t)=>$e(e,{render:t.render,data:t.data}),[]);return t.length>0?t:void 0}function WL(e){return(e||[]).map(e=>{let t=e.agentSteps||e.agent_steps||void 0;return{...e,agentSteps:t,cards:e.cards||UL(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),agentProgram:e.agentProgram||e.agent_program||void 0}})}function GL(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 KL(e,t){return!!e&&e.role===`assistant`&&!!t.failureText&&e.content.trim()===t.failureText.trim()}function qL(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||KL(r[0],n))}function JL(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 YL(e,t){let n=e[e.length-1],r=t[t.length-1];if(!n?.failed||!KL(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 XL(e){return`policy-receipt-${encodeURIComponent(e)}`}var ZL=xt((e,t)=>({lifecycle:null,restartError:null,apply:n=>{n.apiBase&&lr(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 QL(){let e=window.gaiaAPI?.backend;e&&e.getState().then(e=>ZL.getState().apply(e)).catch(e=>F.system.error(`Could not read the backend state from the desktop app`,e))}function $L(e){let t=window.gaiaAPI?.backend;if(!t)return()=>{};let n=t=>{let n=ZL.getState().lifecycle?.status;ZL.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 eR(e){let t=e.content.trim();return!t||e.stopState||e.failed||e.failure||MI(t)||$P(t,1e3).length===0?!1:!PI(e.agentSteps??[],t).echoed}function tR(){(0,V.useEffect)(()=>{let e=!0,t=async()=>{try{let t=await KP();e&&t&&aF.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 nR=[`download`,`decode`,`transcribe`,`voices`,`prepare`,`analyze`],rR=0,iR=5;function aR(e,t){return e==null?``:e<60?t(`recording.leftUnderMinute`):t(`recording.leftMinutes`,{minutes:Math.ceil(e/60)})}function oR(e){return nR.map((e,t)=>t).filter(t=>t!==rR&&t!==iR||t in e)}function sR({state:e}){return e===1?I(ri,{size:14,"aria-hidden":`true`}):e===2?I(So,{size:14,"aria-hidden":`true`}):I(`span`,{className:`recording-progress-dot`,"aria-hidden":`true`})}function cR({index:e,stage:t}){let n=L(),r=n(`recording.stage.${nR[e]}`),i=t?.state===0,a=t?.percent,o=i?aR(t?.etaSeconds,n):``,s=t?.state===2?n(`recording.skipped`):o;return R(`li`,{className:`recording-progress-row${i?` is-running`:``}${t?``:` is-waiting`}${t?.state===1?` is-done`:``}`,children:[I(`span`,{className:`recording-progress-mark`,children:I(sR,{state:t?.state})}),I(`span`,{className:`recording-progress-label`,children:r}),i&&a!=null&&R(`bdi`,{className:`recording-progress-percent`,dir:`ltr`,children:[a,`%`]}),s&&I(`span`,{className:`recording-progress-left`,children:s}),i&&I(`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:I(`div`,{className:`recording-progress-fill`,style:a==null?void 0:{inlineSize:`${a}%`}})})]})}var lR=120;function uR(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)<lR);return r||t.push({title:n,seconds:e.seconds}),!r});return{...e,items:n}})}function dR({sections:e}){let t=L(),n=uR(e),r=n[0]?.sections??0;return R(`section`,{className:`recording-found`,"aria-label":t(`recording.found.title`),children:[R(`h4`,{className:`recording-found-title`,children:[t(`recording.found.title`),I(`span`,{className:`recording-found-count`,children:t(`recording.found.count`,{done:n.length,total:r})})]}),n.map(e=>R(`div`,{className:`recording-found-section`,children:[R(`p`,{className:`recording-found-span`,children:[R(`bdi`,{dir:`ltr`,className:`recording-found-time`,children:[e.start,`–`,e.end]}),e.summary&&I(`span`,{dir:`auto`,children:e.summary})]}),e.items.length>0&&I(`ul`,{className:`recording-found-items`,children:e.items.map(e=>R(`li`,{children:[I(`bdi`,{dir:`ltr`,className:`recording-found-time`,children:e.start}),I(`span`,{dir:`auto`,children:e.title})]},`${e.seconds}-${e.title}`))})]},e.section))]})}function fR(){let e=L(),t=B(e=>e.recordingStages),n=B(e=>e.recordingSections);return t?R(`section`,{className:`recording-progress`,"aria-label":e(`recording.title`),children:[I(`ol`,{className:`recording-progress-list`,children:oR(t).map(e=>I(cR,{index:e,stage:t[e]},e))}),n&&I(dR,{sections:n})]}):null}function pR(e,t){let n=e.tool||``,r=e.tool_label||n,{addNotification:i,notifications:a}=ru.getState(),o=e.confirm_id?a.find(t=>t.id===e.confirm_id):void 0;if(o){!o.response&&o.dismissed&&ru.setState(e=>({notifications:e.notifications.map(e=>e.id===o.id?{...e,dismissed:!1}:e)}));return}let s=n===Bl,c=s&&eu(a,t,e.args);i({id:e.confirm_id??`perm-${Date.now()}`,type:`permission_request`,agentId:t,sessionId:t,agentName:`GAIA`,title:s?Ul(e.args,c):n===`trust_project_folder`?`Trust this folder's instructions and skills?`:`Allow ${r}?`,message:s?Hl(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 mR(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 hR(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 gR(e){let t={result:e.summary||e.title||`Done`,active:!1,success:e.success!==!1,latencyMs:e.latency_ms},n=hR(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 _R=5e3,vR=2e3,yR=3e4,bR=6e4;function xR(e){return e?.init_state===`initializing`?!e.init_tasks||e.init_tasks.some(e=>e.status===`pending`||e.status===`running`):!1}function SR(e){return e.lemonade_running?`up`:e.lemonade_error?`unresponsive`:`down`}function CR(e){return e.kind===`slow`||e.kind===`error`||e.kind===`ok`&&SR(e.status)===`unresponsive`}function wR(e){let t=e.kind===`ok`?e.status.download_progress?.state:void 0;return t===`downloading`||t===`starting`}function TR(e){let t=null,n=0,r=!1,i=null,a=null,s=!1,c=!1,l=()=>{s||!c||a||(a=setTimeout(()=>{a=null,p()},m()))},u=0,d=null,f=async()=>{let e={controller:new AbortController,cancelled:!1};d=e;let{controller:t}=e,n=setTimeout(()=>t.abort(),bR);try{return{kind:`ok`,status:await o(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),d===e&&(d=null)}},p=()=>{if(t)return t;let i=f().then(t=>{if(t!==null){n=CR(t)?n+1:0,r=wR(t),t.kind===`ok`?c=xR(t.status):t.kind===`unreachable`&&(c=!1),l();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},m=()=>Math.min((r?vR:_R)*2**n,yR),h=e=>{p().finally(()=>{e===u&&(i=setTimeout(()=>h(e),m()))})};return{check:p,start:()=>{let e=++u;return s=!0,a&&clearTimeout(a),a=null,h(e),()=>{e===u&&(u++,s=!1,l(),i&&clearTimeout(i),i=null,d&&(d.cancelled=!0,d.controller.abort(),d=null,t=null))}}}}var ER=1e3,DR=15e3,OR=null,kR=null,AR=ER,jR=0,MR=null;function NR(){if(OR)return OR;let e=Date.now();return OR=Xn().then(t=>B.getState().setActiveRuns(t,e)).catch(e=>{F.api.warn(`Could not read which chats are running`,e),uP(e)&&B.getState().loseActiveRuns()}).finally(()=>{OR=null}),OR}function PR(){let e=B.getState();return e.isStreaming||e.runningSessionIds.length>0}function FR(){return PR()?(AR=ER,ER):(AR=Math.min(AR*2,DR),AR)}function IR(e){NR().then(()=>{e===jR&&(kR=setTimeout(()=>IR(e),FR()))})}function LR(){MR&&(kR&&clearTimeout(kR),kR=null,AR=ER,IR(++jR))}function RR(){MR?.();let e=B.subscribe((e,t)=>{e.isStreaming&&!t.isStreaming&&LR()}),t=()=>LR();window.addEventListener(`focus`,t);let n=()=>{jR++,kR&&clearTimeout(kR),kR=null,e(),window.removeEventListener(`focus`,t),MR===n&&(MR=null)};return MR=n,AR=ER,IR(++jR),n}var zR=3e3,BR=new Set,VR=new Map,HR=new Set,UR=null;function WR(e,t=Date.now()){VR.set(e,t)}function GR(e){let t=B.getState();return t.activeRunsAt>0&&t.activeRunsAt>=(VR.get(e)??0)&&!t.runningSessionIds.includes(e)&&!t.queuedSessionIds.includes(e)}function KR(e){return HR.add(e),()=>{HR.delete(e),UR?.()}}function qR(e){return e instanceof Error?mF(e)??(e.message||`Unknown error`):String(e)}function JR(e){let t=e?.httpStatus;return typeof t==`number`?t:void 0}function YR(e){let t=JR(e);return t===409||t===429}function XR(e){F.chat.warn(`Chat ${e} no longer exists; dropping its queued messages`),B.getState().updateQueue(e,()=>[])}function ZR(e){B.getState().setQueueHold(e,!0),setTimeout(()=>B.getState().setQueueHold(e,!1),zR)}function QR(e,t,n){return JR(n)===409&&(F.chat.info(`Chat ${e} was busy; queueing the message to try again`),B.getState().updateQueue(e,e=>rr(e,t,`queued`)),ZR(e),!0)}async function $R(e,t,n){let r=B.getState;if(BR.has(e)||r().queueHolds[e])return;let i=r().messageQueues[e]??[];if(i.some(e=>e.state===`sending`))return;let a=y(i);if(a||xe(i)){BR.add(e);try{if(a){let t;try{t=await An(e)}catch(t){if(JR(t)===409){F.chat.info(`Chat ${e} is answering again; its queue waits for that turn to end`);return}if(JR(t)===404){XR(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=>Le(e,`GAIA could not say whether it read this message: ${qR(t)}`));return}r().updateQueue(e,e=>nn(e,t))}let i=xe(r().messageQueues[e]??[]);if(!i||!n())return;r().updateQueue(e,e=>s(e,i.id,`queued`,`starting`));let o;try{o=await t(e,i.text)}catch(e){o={kind:`failed`,error:qR(e)}}if(o.kind===`accepted`){WR(e),r().updateQueue(e,e=>he(e,i.id)),LR();return}if(o.kind===`busy`){F.chat.info(`Queued message found chat ${e} busy; holding it`),r().updateQueue(e,e=>on(e,i.id)),ZR(e);return}if(o.kind===`gone`){XR(e);return}F.chat.error(`Queued message for chat ${e} was not sent: ${typeof o.error==`string`?o.error:o.error.key}`),r().updateQueue(e,e=>on(e,i.id,o.error))}finally{BR.delete(e)}}}function ez(e){return e.type!==`status`||e.phase!==`waiting`}var tz=(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=ge(e,t,{onChunk:s,onAgentEvent:e=>{ez(e)&&s()},onDone:s,onError:e=>{dF(e)?s():YR(e)?o({kind:`busy`}):JR(e)===404?o({kind:`gone`}):o({kind:`failed`,error:qR(e)})}}),a&&i.abort()});function nz(e=tz){let t=()=>{let t=B.getState();if(!xR(t.systemStatus))for(let n of Object.keys(t.messageQueues))!HR.has(n)&&GR(n)&&$R(n,e,()=>!HR.has(n))},n=B.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 UR=t,t(),()=>{n(),UR===t&&(UR=null)}}var rz=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`]),iz=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 az(e){let t=e.lastIndexOf(`.`);return t<0?``:e.slice(t).toLowerCase()}function oz(e){return rz.has(az(e))}function sz(e){let t=az(e);return rz.has(t)||iz.has(t)}function cz(e,t){return e===`model_server_down`?t(`docs.serverDown`):e===`model_server_busy`?t(`docs.serverBusy`):null}function lz(e){return e===`model_server_down`}function uz(e){return e===`model_server_busy`}function dz(e,t,n){return e===`model_server_down`?n(`docs.notAddedServer`,{name:t}):e===`model_server_busy`?n(`docs.notAddedServerBusy`,{name:t}):null}var fz=`https://github.com/amd/gaia/issues/new`,pz=[{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:rz,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:iz,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 mz(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;for(let e of pz)if(e.extensions.has(t))return e;return null}var hz=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 gz(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;return hz.has(t)}function _z(){let e=navigator.userAgent;return`**Environment:**\n- GAIA Version: 0.27.0rc21\n- Platform: ${navigator.platform||`unknown`}\n- User Agent: ${e}\n- Interface: Agent UI (Web)`}function vz(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?_`,``,`---`,_z(),``,`_Submitted from GAIA Agent UI_`].join(`
|
|
191
|
+
`).replace(/\\\\/g,`\\`)}function HL(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 UL(e){let t=(e||[]).filter(e=>typeof e.render==`string`&&e.render.length>0).reduce((e,t)=>$e(e,{render:t.render,data:t.data}),[]);return t.length>0?t:void 0}function WL(e){return(e||[]).map(e=>{let t=e.agentSteps||e.agent_steps||void 0;return{...e,agentSteps:t,cards:e.cards||UL(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),agentProgram:e.agentProgram||e.agent_program||void 0}})}function GL(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 KL(e,t){return!!e&&e.role===`assistant`&&!!t.failureText&&e.content.trim()===t.failureText.trim()}function qL(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||KL(r[0],n))}function JL(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 YL(e,t){let n=e[e.length-1],r=t[t.length-1];if(!n?.failed||!KL(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 XL(e){return`policy-receipt-${encodeURIComponent(e)}`}var ZL=xt((e,t)=>({lifecycle:null,restartError:null,apply:n=>{n.apiBase&&lr(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 QL(){let e=window.gaiaAPI?.backend;e&&e.getState().then(e=>ZL.getState().apply(e)).catch(e=>F.system.error(`Could not read the backend state from the desktop app`,e))}function $L(e){let t=window.gaiaAPI?.backend;if(!t)return()=>{};let n=t=>{let n=ZL.getState().lifecycle?.status;ZL.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 eR(e){let t=e.content.trim();return!t||e.stopState||e.failed||e.failure||MI(t)||$P(t,1e3).length===0?!1:!PI(e.agentSteps??[],t).echoed}function tR(){(0,V.useEffect)(()=>{let e=!0,t=async()=>{try{let t=await KP();e&&t&&aF.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 nR=[`download`,`decode`,`transcribe`,`voices`,`prepare`,`analyze`],rR=0,iR=5;function aR(e,t){return e==null?``:e<60?t(`recording.leftUnderMinute`):t(`recording.leftMinutes`,{minutes:Math.ceil(e/60)})}function oR(e){return nR.map((e,t)=>t).filter(t=>t!==rR&&t!==iR||t in e)}function sR({state:e}){return e===1?I(ri,{size:14,"aria-hidden":`true`}):e===2?I(So,{size:14,"aria-hidden":`true`}):I(`span`,{className:`recording-progress-dot`,"aria-hidden":`true`})}function cR({index:e,stage:t}){let n=L(),r=n(`recording.stage.${nR[e]}`),i=t?.state===0,a=t?.percent,o=i?aR(t?.etaSeconds,n):``,s=t?.state===2?n(`recording.skipped`):o;return R(`li`,{className:`recording-progress-row${i?` is-running`:``}${t?``:` is-waiting`}${t?.state===1?` is-done`:``}`,children:[I(`span`,{className:`recording-progress-mark`,children:I(sR,{state:t?.state})}),I(`span`,{className:`recording-progress-label`,children:r}),i&&a!=null&&R(`bdi`,{className:`recording-progress-percent`,dir:`ltr`,children:[a,`%`]}),s&&I(`span`,{className:`recording-progress-left`,children:s}),i&&I(`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:I(`div`,{className:`recording-progress-fill`,style:a==null?void 0:{inlineSize:`${a}%`}})})]})}var lR=120;function uR(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)<lR);return r||t.push({title:n,seconds:e.seconds}),!r});return{...e,items:n}})}function dR({sections:e}){let t=L(),n=uR(e),r=n[0]?.sections??0;return R(`section`,{className:`recording-found`,"aria-label":t(`recording.found.title`),children:[R(`h4`,{className:`recording-found-title`,children:[t(`recording.found.title`),I(`span`,{className:`recording-found-count`,children:t(`recording.found.count`,{done:n.length,total:r})})]}),n.map(e=>R(`div`,{className:`recording-found-section`,children:[R(`p`,{className:`recording-found-span`,children:[R(`bdi`,{dir:`ltr`,className:`recording-found-time`,children:[e.start,`–`,e.end]}),e.summary&&I(`span`,{dir:`auto`,children:e.summary})]}),e.items.length>0&&I(`ul`,{className:`recording-found-items`,children:e.items.map(e=>R(`li`,{children:[I(`bdi`,{dir:`ltr`,className:`recording-found-time`,children:e.start}),I(`span`,{dir:`auto`,children:e.title})]},`${e.seconds}-${e.title}`))})]},e.section))]})}function fR(){let e=L(),t=B(e=>e.recordingStages),n=B(e=>e.recordingSections);return t?R(`section`,{className:`recording-progress`,"aria-label":e(`recording.title`),children:[I(`ol`,{className:`recording-progress-list`,children:oR(t).map(e=>I(cR,{index:e,stage:t[e]},e))}),n&&I(dR,{sections:n})]}):null}function pR(e,t){let n=e.tool||``,r=e.tool_label||n,{addNotification:i,notifications:a}=ru.getState(),o=e.confirm_id?a.find(t=>t.id===e.confirm_id):void 0;if(o){!o.response&&o.dismissed&&ru.setState(e=>({notifications:e.notifications.map(e=>e.id===o.id?{...e,dismissed:!1}:e)}));return}let s=n===Bl,c=s&&eu(a,t,e.args);i({id:e.confirm_id??`perm-${Date.now()}`,type:`permission_request`,agentId:t,sessionId:t,agentName:`GAIA`,title:s?Ul(e.args,c):n===`trust_project_folder`?`Trust this folder's instructions and skills?`:`Allow ${r}?`,message:s?Hl(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 mR(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 hR(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 gR(e){let t={result:e.summary||e.title||`Done`,active:!1,success:e.success!==!1,latencyMs:e.latency_ms},n=hR(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 _R=5e3,vR=2e3,yR=3e4,bR=6e4;function xR(e){return e?.init_state===`initializing`?!e.init_tasks||e.init_tasks.some(e=>e.status===`pending`||e.status===`running`):!1}function SR(e){return e.lemonade_running?`up`:e.lemonade_error?`unresponsive`:`down`}function CR(e){return e.kind===`slow`||e.kind===`error`||e.kind===`ok`&&SR(e.status)===`unresponsive`}function wR(e){let t=e.kind===`ok`?e.status.download_progress?.state:void 0;return t===`downloading`||t===`starting`}function TR(e){let t=null,n=0,r=!1,i=null,a=null,s=!1,c=!1,l=()=>{s||!c||a||(a=setTimeout(()=>{a=null,p()},m()))},u=0,d=null,f=async()=>{let e={controller:new AbortController,cancelled:!1};d=e;let{controller:t}=e,n=setTimeout(()=>t.abort(),bR);try{return{kind:`ok`,status:await o(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),d===e&&(d=null)}},p=()=>{if(t)return t;let i=f().then(t=>{if(t!==null){n=CR(t)?n+1:0,r=wR(t),t.kind===`ok`?c=xR(t.status):t.kind===`unreachable`&&(c=!1),l();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},m=()=>Math.min((r?vR:_R)*2**n,yR),h=e=>{p().finally(()=>{e===u&&(i=setTimeout(()=>h(e),m()))})};return{check:p,start:()=>{let e=++u;return s=!0,a&&clearTimeout(a),a=null,h(e),()=>{e===u&&(u++,s=!1,l(),i&&clearTimeout(i),i=null,d&&(d.cancelled=!0,d.controller.abort(),d=null,t=null))}}}}var ER=1e3,DR=15e3,OR=null,kR=null,AR=ER,jR=0,MR=null;function NR(){if(OR)return OR;let e=Date.now();return OR=Xn().then(t=>B.getState().setActiveRuns(t,e)).catch(e=>{F.api.warn(`Could not read which chats are running`,e),uP(e)&&B.getState().loseActiveRuns()}).finally(()=>{OR=null}),OR}function PR(){let e=B.getState();return e.isStreaming||e.runningSessionIds.length>0}function FR(){return PR()?(AR=ER,ER):(AR=Math.min(AR*2,DR),AR)}function IR(e){NR().then(()=>{e===jR&&(kR=setTimeout(()=>IR(e),FR()))})}function LR(){MR&&(kR&&clearTimeout(kR),kR=null,AR=ER,IR(++jR))}function RR(){MR?.();let e=B.subscribe((e,t)=>{e.isStreaming&&!t.isStreaming&&LR()}),t=()=>LR();window.addEventListener(`focus`,t);let n=()=>{jR++,kR&&clearTimeout(kR),kR=null,e(),window.removeEventListener(`focus`,t),MR===n&&(MR=null)};return MR=n,AR=ER,IR(++jR),n}var zR=3e3,BR=new Set,VR=new Map,HR=new Set,UR=null;function WR(e,t=Date.now()){VR.set(e,t)}function GR(e){let t=B.getState();return t.activeRunsAt>0&&t.activeRunsAt>=(VR.get(e)??0)&&!t.runningSessionIds.includes(e)&&!t.queuedSessionIds.includes(e)}function KR(e){return HR.add(e),()=>{HR.delete(e),UR?.()}}function qR(e){return e instanceof Error?mF(e)??(e.message||`Unknown error`):String(e)}function JR(e){let t=e?.httpStatus;return typeof t==`number`?t:void 0}function YR(e){let t=JR(e);return t===409||t===429}function XR(e){F.chat.warn(`Chat ${e} no longer exists; dropping its queued messages`),B.getState().updateQueue(e,()=>[])}function ZR(e){B.getState().setQueueHold(e,!0),setTimeout(()=>B.getState().setQueueHold(e,!1),zR)}function QR(e,t,n){return JR(n)===409&&(F.chat.info(`Chat ${e} was busy; queueing the message to try again`),B.getState().updateQueue(e,e=>rr(e,t,`queued`)),ZR(e),!0)}async function $R(e,t,n){let r=B.getState;if(BR.has(e)||r().queueHolds[e])return;let i=r().messageQueues[e]??[];if(i.some(e=>e.state===`sending`))return;let a=y(i);if(a||xe(i)){BR.add(e);try{if(a){let t;try{t=await An(e)}catch(t){if(JR(t)===409){F.chat.info(`Chat ${e} is answering again; its queue waits for that turn to end`);return}if(JR(t)===404){XR(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=>Le(e,`GAIA could not say whether it read this message: ${qR(t)}`));return}r().updateQueue(e,e=>nn(e,t))}let i=xe(r().messageQueues[e]??[]);if(!i||!n())return;r().updateQueue(e,e=>s(e,i.id,`queued`,`starting`));let o;try{o=await t(e,i.text)}catch(e){o={kind:`failed`,error:qR(e)}}if(o.kind===`accepted`){WR(e),r().updateQueue(e,e=>he(e,i.id)),LR();return}if(o.kind===`busy`){F.chat.info(`Queued message found chat ${e} busy; holding it`),r().updateQueue(e,e=>on(e,i.id)),ZR(e);return}if(o.kind===`gone`){XR(e);return}F.chat.error(`Queued message for chat ${e} was not sent: ${typeof o.error==`string`?o.error:o.error.key}`),r().updateQueue(e,e=>on(e,i.id,o.error))}finally{BR.delete(e)}}}function ez(e){return e.type!==`status`||e.phase!==`waiting`}var tz=(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=ge(e,t,{onChunk:s,onAgentEvent:e=>{ez(e)&&s()},onDone:s,onError:e=>{dF(e)?s():YR(e)?o({kind:`busy`}):JR(e)===404?o({kind:`gone`}):o({kind:`failed`,error:qR(e)})}}),a&&i.abort()});function nz(e=tz){let t=()=>{let t=B.getState();if(!xR(t.systemStatus))for(let n of Object.keys(t.messageQueues))!HR.has(n)&&GR(n)&&$R(n,e,()=>!HR.has(n))},n=B.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 UR=t,t(),()=>{n(),UR===t&&(UR=null)}}var rz=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`]),iz=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 az(e){let t=e.lastIndexOf(`.`);return t<0?``:e.slice(t).toLowerCase()}function oz(e){return rz.has(az(e))}function sz(e){let t=az(e);return rz.has(t)||iz.has(t)}function cz(e,t){return e===`model_server_down`?t(`docs.serverDown`):e===`model_server_busy`?t(`docs.serverBusy`):null}function lz(e){return e===`model_server_down`}function uz(e){return e===`model_server_busy`}function dz(e,t,n){return e===`model_server_down`?n(`docs.notAddedServer`,{name:t}):e===`model_server_busy`?n(`docs.notAddedServerBusy`,{name:t}):null}var fz=`https://github.com/amd/gaia/issues/new`,pz=[{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:rz,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:iz,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 mz(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;for(let e of pz)if(e.extensions.has(t))return e;return null}var hz=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 gz(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;return hz.has(t)}function _z(){let e=navigator.userAgent;return`**Environment:**\n- GAIA Version: 0.27.0rc22\n- Platform: ${navigator.platform||`unknown`}\n- User Agent: ${e}\n- Interface: Agent UI (Web)`}function vz(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?_`,``,`---`,_z(),``,`_Submitted from GAIA Agent UI_`].join(`
|
|
192
192
|
`);return`${fz}?${new URLSearchParams({title:`[Feature] ${e}`,body:n,labels:`enhancement,agent-ui`}).toString()}`}function yz(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?_`,``,`---`,_z(),``,`_Submitted from GAIA Agent UI_`].join(`
|
|
193
193
|
`);return`${fz}?${new URLSearchParams({title:`[Bug] ${e}`,body:n,labels:`bug,agent-ui`}).toString()}`}var bz={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 xz(e,t){if(!e.startsWith(t))return e;let n=e.slice(t.length).trim();return n.charAt(0).toUpperCase()+n.slice(1)}function Sz({filename:e,error:t,status:n,kind:r,onDismiss:i,timeout:a=0}){let o=L(),s=(0,V.useRef)(null);(0,V.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?mz(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=yi,g=r?bz[r]:void 0;return g?(f=`"${e}" can't be read`,p=g,m=null,h=ec):cz(r,o)?(f=dz(r,e,o)??o(`docs.notAddedServer`,{name:e}),p=cz(r,o)??t,m=null,h=ec):r===`too_large`?(f=o(`docs.tooLarge`,{name:e}),p=t,m=null,h=ec):n===404?(f=o(`docs.notFound`,{name:e}),p=o(`docs.notFoundDetail`),m=null,h=ec):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=ec):u&&l?(f=`${l.label} files not supported`,p=l.message,m=vz(l.featureTitle),h=ec):u&&!c?(f=`"${e}" has no file extension`,p=xz(t,`File type not allowed:`),m=null,h=ec):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=vz(`Support ${c} file indexing`),h=ec):d?(f=`Connection error`,p=`Could not reach the GAIA server. Make sure the backend is running.`,m=yz(`Upload connection error for ${e}`),h=yi):(f=`Failed to index "${e}"`,p=t||`An unexpected error occurred during indexing.`,m=yz(`Indexing error: ${t.slice(0,80)}`),h=qr),R(`div`,{className:`upload-error-toast`,role:`alert`,children:[I(h,{size:16}),R(`div`,{className:`upload-error-content`,children:[I(`div`,{className:`upload-error-title`,children:f}),R(`div`,{className:`upload-error-detail`,children:[p,m&&` `,m===null?null:u?I(`a`,{href:m,target:`_blank`,rel:`noopener noreferrer`,children:`Request this feature →`}):I(`a`,{href:m,target:`_blank`,rel:`noopener noreferrer`,children:`Report this issue →`})]})]}),I(`button`,{className:`upload-error-dismiss`,onClick:i,"aria-label":`Dismiss`,children:I(fc,{size:14})})]})}function Cz(e,t,n=[],r=[],i={}){let a=wz(t,r,i);if(n.length>0)return n.some(a);let o=ZA(e);return o===`google`?a(`google`):o===`microsoft`?a(`microsoft`):a(`google`)||a(`microsoft`)}function wz(e,t,n){return r=>wA(e.find(e=>e.id===r),t.find(e=>e.id===r),n[r])}function Tz(e,t,n=[],r=[],i={}){let a=wz(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=ZA(e);return s===`google`?`Google`:s===`microsoft`?`Microsoft`:a(`google`)?`Google`:a(`microsoft`)?`Microsoft`:`Google`}function Ez({content:e,providers:t=[],accounts:n,onRetry:r}){let i=L(),[a,o]=(0,V.useState)([]),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1),d=(0,V.useCallback)(()=>{ae().then(e=>{let t=e.connectors||[];o(t),c(e=>e??t)}).catch(e=>F.ui.warn(`ConnectorRetryBanner: connector fetch failed`,e))},[]),f=s!==null&&Cz(e,a,t,s,n);if((0,V.useEffect)(()=>{d();let e=()=>d();return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[d]),Zj(!f,d),!f||l)return null;let p=Tz(e,a,t,s??[],n);return R(`div`,{className:`connector-retry-banner`,role:`status`,children:[I(_i,{size:14,className:`connector-retry-banner__icon`}),I(`span`,{className:`connector-retry-banner__text`,children:i(`retryBanner.connected`,{name:p})}),R(`button`,{type:`button`,className:`connector-retry-banner__btn`,onClick:()=>{u(!0),r()},children:[I(os,{size:12}),I(`span`,{children:i(`retryBanner.askAgain`)})]}),I(`button`,{type:`button`,className:`connector-retry-banner__dismiss`,onClick:()=>u(!0),"aria-label":i(`retryBanner.dismiss`),children:`×`})]})}var Dz=0,Oz=xt(e=>({current:null,refresh:async()=>{let t=++Dz;try{let n=await Ee();t===Dz&&e({current:n.current})}catch(n){F.api.warn(`Could not read which agent is in use`,n),t===Dz&&e({current:null})}},setCurrent:t=>{Dz++,e({current:t})}}));function kz(){let e=L(),t=Oz(e=>e.current),n=Oz(e=>e.refresh),r=B(e=>e.settingsSection!==null),i=B(e=>e.openSettings);return(0,V.useEffect)(()=>{r||n()},[r,n]),t===`gaiacpp`?R(`button`,{type:`button`,className:`composer-chip composer-chip-agent`,onClick:()=>i(`model`),title:e(`composer.agentFastTitle`),children:[I(ra,{size:13,"aria-hidden":`true`}),I(`span`,{className:`composer-chip-label`,dir:`auto`,children:e(`composer.agentFast`)})]}):null}function Az(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 jz(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 Mz(e){return e.replace(/-/g,``).slice(0,7)}function Nz(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 Pz(e,t){return e.key===`ArrowUp`&&!e.shiftKey&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.nativeEvent?.isComposing&&t===``}function Fz(e){for(let t=e.length-1;t>=0;t--)if(e[t].role===`user`)return e[t]}function Iz(e,t){for(let n=t+1;n<e.length;n++)if(e[n].role===`user`)return e.length-n;return 0}var Lz=/^\/[a-z0-9-]*$/i;function Rz(e){let t=Lz.test(e),[n,r]=(0,V.useState)([]),[i,a]=(0,V.useState)(`loading`),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(0),[u,d]=(0,V.useState)(null);(0,V.useEffect)(()=>{if(!t)return;let e=!0;return a(e=>e===`ready`?e:`loading`),Bt().then(t=>{Pe(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,V.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,V.useCallback)(e=>l(e),[]),g=(0,V.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 zz=`composer-skill-menu`;function Bz(e){return`${zz}-${e}`}function Vz(e){let t=e.replace(/\s+/g,` `).trim(),n=t.indexOf(`. `);return n>=0?t.slice(0,n+1):t}var Hz=320,Uz=6,Wz=8;function Gz(e,t,n){let r=Math.max(0,e.top-Uz-Wz),i=Math.max(0,t-e.bottom-Uz-Wz),a=r<Math.min(Hz,n)&&i>r;return{below:a,maxHeight:Math.floor(Math.min(Hz,a?i:r))}}function Kz({menu:e,onPick:t}){let n=L(),r=(0,V.useRef)(null),[i,a]=(0,V.useState)(null),o=e.open&&e.status===`ready`?e.matches.length:-1;if((0,V.useLayoutEffect)(()=>{let e=r.current,t=e?.parentElement;if(!e||!t){a(null);return}let n=()=>{let n=Gz(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,V.useLayoutEffect)(()=>{o>0&&document.getElementById(Bz(e.selected))?.scrollIntoView?.({block:`nearest`})},[e.selected,o,i]),!e.open)return null;let s=`skill-menu${i?.below?` is-below`:``}`,c=i?{maxHeight:i.maxHeight}:void 0;return e.status===`ready`?R(`div`,{ref:r,className:s,style:c,children:[I(`p`,{className:`skill-menu-title`,children:n(`composer.skillsTitle`)}),I(`ul`,{id:zz,role:`listbox`,"aria-label":n(`composer.skillsTitle`),children:e.matches.map((n,r)=>R(`li`,{id:Bz(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:[R(`span`,{className:`skill-menu-name`,dir:`ltr`,children:[`/`,n.name]}),I(`span`,{className:`skill-menu-desc`,dir:`auto`,children:Vz(n.description)})]},n.name))})]}):I(`div`,{ref:r,className:s,style:c,role:e.status===`error`?`alert`:`status`,children:I(`p`,{className:`skill-menu-note`,children:e.status===`error`?n(`composer.skillsFailed`,{error:e.error??``}):n(`composer.skillsLoading`)})})}function qz(e){return e.isMedia?oz(e.name)?pa:la:_a}var Jz=240,Yz=1e5;function Xz({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=L(),_=(0,V.useRef)(null),v=f??_,y=(0,V.useRef)(null),b=!!c,x=e.trim().length>0||l.hasUploaded,S=l.compose(e.trim()).length,C=S>Yz,w=PF(i),T=l.attachments.filter(e=>e.error).map(e=>e.name).join(`, `),E=!b&&(!i||o)&&!l.uploading&&x&&!C&&!T&&!w,ee=c||u||g(`composer.placeholder`),D=Rz(b?``:e),O=(0,V.useCallback)(e=>{t(`/${e} `),v.current?.focus()},[t,v]);(0,V.useLayoutEffect)(()=>{let e=v.current;if(!e)return;let t=()=>{e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,Jz)}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,ee,v]);let te=(0,V.useCallback)(t=>{if(D.open&&!t.nativeEvent.isComposing){let{matches:n,selected:r}=D;if(t.key===`Escape`){t.preventDefault(),D.dismiss();return}if(n.length>0&&(t.key===`ArrowDown`||t.key===`ArrowUp`)){t.preventDefault();let e=t.key===`ArrowDown`?1:-1;D.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(),O(i);return}}h&&Pz(t,e)?(t.preventDefault(),h()):t.key===`Enter`&&!t.shiftKey&&!t.nativeEvent.isComposing&&(t.preventDefault(),E&&n())},[E,n,h,e,D,O]),k=(0,V.useCallback)(e=>{e.dataTransfer?.files?.length&&(e.preventDefault(),e.stopPropagation(),l.addFiles(Array.from(e.dataTransfer.files)))},[l]);return R(`div`,{className:`composer${b?` composer-disabled`:``}`,onDrop:k,onDragOver:e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault()},children:[I(NF,{}),l.attachments.length>0&&I(`ul`,{className:`composer-attachments`,"aria-label":g(`composer.attached`),children:l.attachments.map(e=>{let t=qz(e);return R(`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?I(`img`,{src:e.url,alt:``,className:`composer-attachment-thumb`}):I(t,{size:14,"aria-hidden":`true`}),I(`span`,{className:`composer-attachment-name`,title:e.name,dir:`ltr`,children:Az(e.name)}),e.uploading&&I(`span`,{className:`composer-attachment-state`,children:e.progress===void 0?g(`composer.uploading`):g(`composer.uploadingPercent`,{percent:e.progress})}),e.uploaded&&e.isMedia&&I(`span`,{className:`composer-attachment-state`,children:g(`composer.mediaReady`)}),e.error&&I(`span`,{className:`composer-attachment-state`,role:`alert`,title:e.error,children:e.error}),I(`button`,{type:`button`,className:`composer-icon-btn`,onClick:()=>l.remove(e.id),"aria-label":g(`composer.remove`,{name:e.name}),children:I(fc,{size:12})})]},e.id)})}),I(Kz,{menu:D,onPick:O}),I(`textarea`,{ref:v,className:`composer-input`,value:e,onChange:e=>t(e.target.value),onKeyDown:te,onPaste:e=>{l.handlePaste(e)},placeholder:ee,rows:1,disabled:b,autoFocus:d,"aria-label":g(`composer.message`),"aria-autocomplete":`list`,"aria-expanded":D.open&&D.matches.length>0,"aria-controls":D.open&&D.matches.length>0?zz:void 0,"aria-activedescendant":D.open&&D.matches.length>0?Bz(D.selected):void 0,dir:e?`auto`:void 0}),C&&R(`p`,{className:`composer-limit-error`,role:`alert`,children:[g(`composer.tooLong`,{sent:S.toLocaleString(),max:1e5.toLocaleString()}),` `,g(`composer.tooLongHint`)]}),T&&x&&I(`p`,{className:`composer-limit-error`,role:`alert`,children:g(`composer.removeRefused`,{names:T})}),R(`div`,{className:`composer-row`,children:[R(`div`,{className:`composer-row-left`,children:[I(`button`,{type:`button`,className:`composer-icon-btn`,onClick:()=>y.current?.click(),disabled:b,"aria-label":g(`composer.attach`),title:g(`composer.attach`),children:I(es,{size:16})}),I(`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]}),R(`div`,{className:`composer-row-right`,children:[m,i&&o&&x&&I(`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:I(Fr,{size:16})}),i?I(`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:I(Ks,{size:12,fill:`currentColor`})}):I(`button`,{type:`button`,className:`composer-send`,onClick:n,disabled:!E,"aria-label":g(`composer.send`),title:w??g.hint(g(`composer.send`),`Enter`),children:I(Fr,{size:16})})]})]})]})}var Zz=8,Qz=8;function $z({label:e,warning:t,children:n,id:r,pinned:i=!1,onUnpin:a,tabIndex:o}){let s=(0,V.useId)(),c=r??s,l=(0,V.useRef)(null),u=(0,V.useRef)(null),[d,f]=(0,V.useState)(!1),p=d||i,[m,h]=(0,V.useState)(null);return(0,V.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+Zz+t.width<=r-Qz?(a=n.right+Zz,o=e.top+e.height/2-t.height/2):n.left-Zz-t.width>=Qz?(a=n.left-Zz-t.width,o=e.top+e.height/2-t.height/2):(a=Math.min(Math.max(Qz,e.right-t.width),r-Qz-t.width),o=e.top-Zz-t.height>=Qz?e.top-Zz-t.height:e.bottom+Zz),o=Math.min(Math.max(Qz,o),i-Qz-t.height),h({left:a,top:o})},[p]),(0,V.useEffect)(()=>{if(!p)return;let e=()=>{f(!1),a?.()};return window.addEventListener(`scroll`,e,!0),()=>window.removeEventListener(`scroll`,e,!0)},[p,a]),R(P.Fragment,{children:[I(`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:I(Ua,{size:13,"aria-hidden":`true`})}),p&&(0,dy.createPortal)(I(`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 eB({support:e}){let t=L();return e===`verified`?I(`span`,{className:`mc-chip is-verified`,children:t(`setup.label.verified`)}):e===`untested`?I(`span`,{className:`mc-chip is-untested`,children:t(`setup.label.untested`)}):null}function tB(e){return e<.1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function nB(e,t=ht){return e?t(`settings.price.perMillion`,{input:tB(e.input_per_million),output:tB(e.output_per_million)}):t(`settings.price.unknown`)}function rB(e){return`$${e.toFixed(2)}`}function iB(e,t,n,r=!1){return!k(t)||ht(t)!==n?n:r?e.bare(t):e(t)}function aB(e,t){return iB(e,`providers.${t.id}.name`,t.name,!0)}function oB(e,t){return iB(e,`providers.${t.id}.notice`,t.privacy_notice)}var sB=2e3,cB=`waiting_for_os_permission`,lB=`store_locked`,uB=5;function dB(e,t,n){let r=e.note?dl[e.note]:void 0,i=e.rank?{key:`rank`,content:R(P.Fragment,{children:[R(`bdi`,{dir:`ltr`,children:[`#`,e.rank]}),e.note?R(P.Fragment,{children:[` `,r?n(r):I(`bdi`,{children:e.note})]}):null]})}:null;if(t){let t=nB(e.price,n);return[i,t?{key:`price`,content:t}:null].filter(e=>e!==null)}let a=fl(e.placement,n);return[a?{key:`placement`,content:a}:null,e.size_gb?{key:`size`,content:R(`bdi`,{dir:`ltr`,children:[e.size_gb,` GB`]})}:null,e.tokens_per_second?{key:`speed`,content:I(bl,{text:n(`settings.model.speed`,{speed:_l(`${Math.round(e.tokens_per_second)} tok/s`)})})}:null,i,e.custom?{key:`custom`,content:n(`settings.model.custom`)}:null].filter(e=>e!==null)}function fB(e,t){return!$c(t,e.id)&&(gl(e)||hl(e)===`not_downloaded`)}function pB(e,t,n){let r=e=>e.provider.id===t?0:1,i=e=>fB(e,n)?e.support===`verified`?1:2:0;return[...e].sort((e,t)=>r(e)-r(t)).map(e=>e.provider.remote?e:{...e,models:[...e.models].sort((e,t)=>i(e)-i(t))})}function mB({m:e,onDownload:t,busy:n}){let r=L();if(gl(e)){let t=Math.round(e.download_progress?.percent??0);return R(`span`,{className:`model-state is-downloading`,title:`Downloading, ${t}%`,children:[I(so,{size:12,className:`spin`,"aria-hidden":`true`}),` `,t,`%`]})}let i=hl(e);return i===`not_downloaded`?I(`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?`${ul.not_downloaded} (${e.size_gb} GB)`:ul.not_downloaded,tabIndex:-1,children:I(Ui,{size:13,"aria-hidden":`true`})}):i===`loaded`?I(`span`,{className:`model-state is-loaded`,role:`img`,"aria-label":ul.loaded,title:ul.loaded}):I(`span`,{className:`model-state is-ready`,title:ul.downloaded,children:r(`modelMenu.ready`)})}function hB(){let e=L(),t=Xc(e=>e.active),n=Xc(e=>e.select),r=Xc(e=>e.queued),i=r??t?.model,a=Xc(e=>e.queue),o=Xc(e=>e.queueError),s=Xc(e=>e.rememberNames);Xc(e=>e.names);let c=il(),l=B(e=>al(t,e.sessions,e.currentSessionId)),u=B(e=>e.isStreaming),d=B(e=>e.openSettings),f=(0,V.useRef)(null),[p,m]=(0,V.useState)(!1),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(0),[x,S]=(0,V.useState)(null),[C,w]=(0,V.useState)(null),[T,E]=(0,V.useState)(null),[ee,D]=(0,V.useState)(null),[O,te]=(0,V.useState)(null),[k,A]=(0,V.useState)(null),[ne,re]=(0,V.useState)(0),[j,ie]=(0,V.useState)(null),ae=(0,V.useRef)(0),oe=(0,V.useRef)(null),se=(0,V.useId)(),ce=(0,V.useRef)(null),le=(0,V.useRef)(null),[ue,M]=(0,V.useState)(null),[de,fe]=(0,V.useState)(null),N=(0,V.useCallback)(()=>fe(null),[]),pe=(0,V.useCallback)(()=>m(!1),[]),me=(0,V.useRef)(!1),he=(0,V.useRef)(null),ge=(0,V.useCallback)(async(t=!1)=>{t||(me.current=!1,S(null),g(null));try{let{providers:n,lemonade_error:r}=await Yn();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 ln(t.id);return{provider:t,models:n.models,error:n.blocked?e(`settings.privacy.localOnlyBlocked`):void 0}}catch(e){return{provider:t,models:[],error:fP(e)}}}));s(a.flatMap(e=>e.models)),b(a.flatMap(e=>e.models).filter(e=>e.available===!1).length),t||(me.current=!0),g(a.map(e=>({...e,models:e.models.filter(e=>e.available!==!1)})))}catch(e){S(fP(e))}},[s,e]),_e=(0,V.useCallback)(async()=>{try{await Se()}catch(e){S(fP(e));return}await ge(!0)},[ge]);(0,V.useEffect)(()=>{p&&(w(null),E(null),v(!1),M(null),fe(null),ge())},[p,ge]),(0,V.useEffect)(()=>{if(!p||!h||!me.current)return;let e=ce.current?.querySelector(`[role="option"][tabindex="0"]`);e&&(me.current=!1,e.focus(),e.scrollIntoView?.({block:`nearest`}))},[p,h]),(0,V.useEffect)(()=>{let e=he.current;if(!p||!h||!e||!_)return;let t=h.find(t=>t.provider.id===e)?.models.find(e=>e.rank===null&&!$c(i,e.id));if(!t)return;let n=Array.from(ce.current?.querySelectorAll(`[role="option"]`)??[]).find(e=>e.dataset.row===t.id);n&&(he.current=null,M(t.id),n.focus(),n.scrollIntoView?.({block:`nearest`}))},[p,h,_,i]),(0,V.useEffect)(()=>{(C||T)&&le.current?.scrollIntoView?.({block:`nearest`})},[C,T]);let ve=e=>{if(e.altKey||e.ctrlKey||e.metaKey)return;let t=Array.from(ce.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(),fe(t=>e.key===`i`&&t===r?null:r);return}case`ArrowLeft`:e.preventDefault(),fe(null);return;default:return}e.preventDefault(),t[r].focus(),t[r].scrollIntoView?.({block:`nearest`})},ye=!!h?.some(e=>e.models.some(gl)),be=!!h?.some(e=>e.provider.key_state===cB);(0,V.useEffect)(()=>{if(!(p||k)||!(ye||k||be))return;let e=()=>{ge(!0)};if(k){let t=setInterval(e,sB);return()=>clearInterval(t)}return Sl(e,sB)},[p,ye,k,be,ge]);let xe=(0,V.useCallback)(async e=>{te(e),re(e=>e+1),S(null);try{await Ce(e),await ge(!0)}catch(t){A(t=>t?.model===e?null:t),S(fP(t))}finally{te(null),re(e=>e-1)}},[ge]),we=(0,V.useCallback)((e,t,n)=>{E(null),n&&(ae.current=0,ie(null),A({model:e,provider:t})),xe(e)},[xe]),Te=(0,V.useCallback)(async(e,r)=>{if(r.remote&&!t?.remote&&C?.model!==e)return w({model:e,provider:r}),null;if(w(null),u)return a(e===t?.model?null:e),m(!1),null;D(e),S(null);try{return await n(e),ie(null),m(!1),null}catch(e){let t=fP(e);return S(t),t}finally{D(null)}},[t?.model,t?.remote,C,a,n,u]);(0,V.useEffect)(()=>{if(!k||!h||ne>0)return;let{model:e,provider:t}=k,n=()=>(oe.current!==h&&(oe.current=h,ae.current+=1),ae.current>=uB),r=h.flatMap(e=>e.models).find(t=>t.id===e);if(!r){if(!n())return;A(null),ie(`${el(e)} is no longer in the model list, so it wasn't switched to.`);return}if(gl(r)){ae.current=0;return}let i=r.download_progress;if(i?.state===`error`)A(null),ie(`Downloading ${el(e)} failed: ${i.message??`no reason given`}`);else if(i?.state!==`complete`&&hl(r)===`not_downloaded`){if(!n())return;A(null),ie(`The download of ${el(e)} never started. Try the download button again.`)}else A(null),Te(e,t).then(t=>{t&&ie(`${el(e)} downloaded, but switching to it failed: ${t}`)})},[h,k,ne,Te]);let Ee=(e,t)=>e.id===`fireworks`&&!_&&t.some(e=>e.rank!==null),De=(e,t)=>Ee(e,t)?t.filter(e=>e.rank!==null||$c(i,e.id)):t,Oe=(e,t)=>Ee(e,t)&&t.some(e=>e.rank===null&&!$c(i,e.id)),ke=h?.flatMap(({provider:e,models:t})=>[...e.remote&&!e.models_discovered?[`key:${e.id}`]:[],...De(e,t).filter(e=>ee===null&&!gl(e)).map(e=>e.id),...Oe(e,t)?[`showall:${e.id}`]:[]])??[],Ae=ue&&ke.includes(ue)?ue:i&&ke.includes(i)?i:ke[0],je=e=>({role:`option`,tabIndex:e===Ae?0:-1,"data-row":e,onFocus:()=>M(e),onBlur:()=>fe(null)}),Me=c?.remote?ki:c?zi:xi,Ne=l?el(l):`Model`,Pe=`${Ne}${c?` · ${c.label}`:``}`,Fe=Object.fromEntries((h??[]).map(e=>[e.provider.id,cl(e.models)])),Ie=h&&pB(h,t?.provider,i),Le=t?.downloaded===!1&&l===t.model,Re=j||o||(r?e(`modelChip.queuedTitle`,{model:el(r)}):t?.config_error?t.config_error:Le?e(`modelChip.notDownloadedTitle`,{name:Ne}):c?c.description?.replace(/`/g,``)??(c.remote?e(`modelStatus.runsRemote`,{name:c.label}):e(`modelStatus.runsHere`)):rl);return R(`div`,{className:`composer-chip-wrap`,children:[R(`button`,{ref:f,type:`button`,className:`composer-chip${Le||o||j?` is-warning`:``}`,onClick:()=>m(e=>!e),"aria-haspopup":`dialog`,"aria-expanded":p,title:Re,children:[I(Me,{size:13,"aria-hidden":`true`}),I(`span`,{className:`composer-chip-label`,dir:`auto`,children:Pe}),r&&R(`span`,{className:`composer-chip-next`,children:[I(jr,{size:11,className:`composer-chip-next-arrow`,"aria-hidden":`true`}),I(`bdi`,{dir:`ltr`,className:`composer-chip-next-model`,children:el(r)}),I(`span`,{className:`composer-chip-next-tag`,children:e.bare(`modelChip.next`)})]}),Le&&I(Ui,{size:12,"aria-label":e(`modelChip.notDownloaded`)}),j&&I(yi,{size:12,"aria-label":e(`modelChip.switchFailed`)}),I(si,{size:12,"aria-hidden":`true`})]}),R(wc,{open:p,onClose:pe,anchor:f,label:e(`modelMenu.label`),align:`end`,className:`model-menu`,children:[u&&I(`div`,{className:`popover-message`,role:`status`,children:l?e(`modelMenu.keepsModel`,{model:el(l)}):e(`modelMenu.keepsItsModel`)}),j&&I(`div`,{className:`popover-message is-error`,role:`alert`,children:j}),o&&I(`div`,{className:`popover-message is-error`,role:`alert`,children:o}),x&&I(`div`,{className:`popover-message is-error`,role:`alert`,children:x}),!h&&!x&&R(`div`,{className:`popover-message`,children:[I(so,{size:13,className:`spin`}),` `,e(`modelMenu.loading`)]}),h&&I(`div`,{ref:ce,role:`listbox`,"aria-label":e(`modelMenu.models`),onKeyDown:ve,children:Ie.map(({provider:n,models:a,error:o})=>R(`div`,{role:`group`,"aria-labelledby":`${se}-${n.id}`,children:[I(`div`,{className:`popover-heading`,id:`${se}-${n.id}`,children:aB(e,n)}),o&&I(`div`,{className:`popover-message is-error`,children:o}),n.key_state===cB?R(`div`,{className:`popover-message`,role:`status`,children:[I(so,{size:13,className:`spin`,"aria-hidden":`true`}),` `,n.key_message]}):n.key_state===lB?R(`button`,{type:`button`,className:`popover-item`,...je(`unlock:${n.id}`),"aria-selected":!1,onClick:()=>void _e(),children:[I(`span`,{className:`popover-item-check`,children:I(Ga,{size:13,"aria-hidden":`true`})}),R(`span`,{className:`popover-item-body`,children:[I(`span`,{className:`popover-item-title`,children:e(`settings.key.unlockAgain`)}),I(`span`,{className:`popover-item-note`,children:e(`settings.key.storeLocked`)})]})]}):n.remote&&!n.models_discovered&&R(`button`,{type:`button`,className:`popover-item`,...je(`key:${n.id}`),"aria-selected":!1,onClick:()=>{m(!1),d(`model`,n.id)},children:[I(`span`,{className:`popover-item-check`,children:I(Ga,{size:13,"aria-hidden":`true`})}),R(`span`,{className:`popover-item-body`,children:[I(`span`,{className:`popover-item-title`,children:e(`modelMenu.addKey`)}),I(`span`,{className:`popover-item-note`,children:e(`modelMenu.connectInSettings`,{provider:n.name})})]})]}),!o&&a.length===0&&n.models_discovered!==!1&&I(`div`,{className:`popover-message`,children:e(`modelMenu.noModels`)}),De(n,a).map((a,o,s)=>{let c=!n.remote&&fB(a,i)&&o===s.findIndex(e=>fB(e,i)),l=$c(r??t?.model,a.id),u=!n.remote&&hl(a)===`not_downloaded`,d=Fe[n.id][a.id],f=dB(a,n.remote,e),p=`${se}-info-${n.id}-${a.id}`;return R(V.Fragment,{children:[c&&I(`div`,{className:`popover-subheading`,children:e(`modelMenu.availableToDownload`)}),R(`div`,{className:`popover-row`,children:[R(`button`,{type:`button`,className:`popover-item`,onClick:()=>{u?(w(null),E({model:a.id,provider:n,pick:!0})):(A(null),E(null),Te(a.id,n))},disabled:ee!==null||gl(a),...je(a.id),"aria-selected":l,"aria-describedby":de===a.id?p:void 0,children:[I(`span`,{className:`popover-item-check`,"aria-hidden":`true`,children:ee===a.id?I(so,{size:13,className:`spin`}):l?I(ri,{size:13}):null}),R(`span`,{className:`popover-item-body is-inline`,children:[I(`span`,{className:`popover-item-title is-model`,children:d}),!n.remote&&I(eB,{support:a.support}),!n.remote&&a.size_gb?I(`span`,{className:`popover-item-meta`,children:R(`bdi`,{dir:`ltr`,children:[a.size_gb,` GB`]})}):null]})]}),R($z,{label:e(`modelMenu.aboutModel`,{name:d}),warning:!!a.placement?.warning,id:p,pinned:de===a.id,onUnpin:N,tabIndex:-1,children:[I(`div`,{className:`info-bubble-title`,children:I(`bdi`,{dir:`ltr`,children:d})}),f.length>0&&I(`ul`,{className:`info-bubble-lines`,children:f.map(e=>I(`li`,{children:e.content},e.key))}),a.placement?.warning&&I(`ul`,{className:`info-bubble-lines`,children:I(`li`,{className:`is-warning`,children:a.placement.warning})}),I(`div`,{className:`info-bubble-id`,dir:`ltr`,children:a.id})]}),I(`span`,{className:`popover-row-state`,children:!n.remote&&I(mB,{m:a,busy:O!==null,onDownload:()=>{w(null),E({model:a.id,provider:n,pick:!1})}})})]}),T?.model===a.id&&T.provider.id===n.id&&R(`div`,{ref:le,className:`popover-message model-download-confirm`,role:`alert`,children:[R(`span`,{children:[I(bl,{text:a.size_gb?e(`modelMenu.downloadConfirm`,{name:_l(d),size:_l(`${a.size_gb} GB`)}):e(`modelMenu.downloadConfirmNoSize`,{name:_l(d)})}),T.pick&&` ${e(`modelMenu.switchWhenDone`)}`]}),R(`span`,{className:`model-download-confirm-actions`,children:[I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>we(a.id,n,T.pick),children:e(`modelMenu.download`)}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>E(null),children:e(`modelMenu.cancel`)})]})]}),C?.model===a.id&&C.provider.id===n.id&&R(`div`,{ref:le,className:`popover-message`,role:`alert`,children:[oB(e,C.provider),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>Te(C.model,C.provider),children:e(`modelMenu.useModel`,{name:el(C.model)})})]})]},a.id)}),Oe(n,a)&&R(`button`,{type:`button`,className:`popover-item`,...je(`showall:${n.id}`),"aria-selected":!1,onClick:()=>{he.current=n.id,v(!0)},children:[I(`span`,{className:`popover-item-check`}),I(`span`,{className:`popover-item-body`,children:I(`span`,{className:`popover-item-title`,children:e(`settings.model.showAll`)})})]})]},n.id))}),y>0&&R(`button`,{type:`button`,className:`popover-item`,onClick:()=>{m(!1),d(`model`)},children:[I(`span`,{className:`popover-item-check`}),I(`span`,{className:`popover-item-body`,children:I(`span`,{className:`popover-item-note`,children:e.plural(`modelMenu.unavailable`,y)})})]}),I(`div`,{className:`popover-divider`}),R(`button`,{type:`button`,className:`popover-item`,onClick:()=>{m(!1),d(`model`)},children:[I(`span`,{className:`popover-item-check`,children:I(to,{size:13,"aria-hidden":`true`})}),R(`span`,{className:`popover-item-body`,children:[I(`span`,{className:`popover-item-title`,children:e(`modelMenu.addFromLink`)}),I(`span`,{className:`popover-item-note`,children:e(`modelMenu.addFromLinkNote`)})]})]}),R(`button`,{type:`button`,className:`popover-item`,onClick:()=>{m(!1),d(`model`)},children:[I(`span`,{className:`popover-item-check`}),I(`span`,{className:`popover-item-body`,children:I(`span`,{className:`popover-item-title`,children:e(`modelMenu.providers`)})})]})]})]})}function gB(e,t,n){if(e==null||!t(e))throw Error(`the server sent no ${n}`);return e}var _B=e=>e.startsWith(`.`);function vB({onPick:e,onClose:t}){let n=L(),[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(``),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1),[d,f]=(0,V.useState)(!1);Qn(!0,t);let p=(0,V.useRef)(null);_n(p,!0);let m=(0,V.useCallback)(e=>{u(!0),c(null),Promise.resolve().then(()=>Kt(e)).then(e=>{let t=gB(e,e=>Array.isArray(e.entries),`folder listing`);i(t),o(t.current_path)}).catch(e=>c(e instanceof En?e.detail||e.message:String(e))).finally(()=>u(!1))},[]);(0,V.useEffect)(()=>m(),[m]);let h=r?.entries.filter(e=>e.type===`folder`)??[],g=d?h:h.filter(e=>!_B(e.name));return I(`div`,{className:`modal-overlay`,onClick:t,children:R(`div`,{ref:p,className:`modal-panel sp-picker`,role:`dialog`,"aria-modal":`true`,"aria-label":n(`pick.label`),onClick:e=>e.stopPropagation(),children:[R(`div`,{className:`modal-header`,children:[I(`h3`,{children:n(`pick.title`)}),I(`button`,{type:`button`,className:`btn-icon`,onClick:t,"aria-label":n(`sp.closeShort`),children:I(fc,{size:18})})]}),R(`div`,{className:`modal-body sp-picker-body`,children:[I(`p`,{className:`sp-meta`,children:n(`pick.note`)}),R(`form`,{className:`sp-picker-path`,onSubmit:e=>{e.preventDefault(),a.trim()&&m(a.trim())},children:[I(`input`,{value:a,onChange:e=>o(e.target.value),"aria-label":n(`pick.path`),spellCheck:!1,dir:`ltr`}),I(`button`,{type:`submit`,className:`sp-action`,children:n(`pick.go`)})]}),r&&R(`div`,{className:`sp-picker-quick`,children:[r.quick_links.map(e=>I(`button`,{type:`button`,className:`sp-action`,onClick:()=>m(e.path),children:e.name},e.path)),R(`label`,{className:`sp-picker-hidden`,children:[I(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked)}),n(`pick.showHidden`)]})]}),R(`ul`,{className:`sp-picker-list`,"aria-busy":l,children:[r?.parent_path&&I(`li`,{children:R(`button`,{type:`button`,onClick:()=>m(r.parent_path??void 0),children:[I(Fr,{size:13,"aria-hidden":`true`}),` `,n(`pick.up`)]})}),g.map(e=>I(`li`,{children:R(`button`,{type:`button`,onClick:()=>m(e.path),children:[I(Da,{size:13,"aria-hidden":`true`}),` `,e.name]})},e.path)),r&&g.length===0&&I(`li`,{className:`sp-meta`,children:n(h.length>0?`pick.onlyHidden`:`pick.none`)}),l&&R(`li`,{className:`sp-meta`,children:[I(so,{size:12,className:`spin`,"aria-hidden":`true`}),` `,n(`pick.loading`)]})]}),s&&I(`p`,{className:`sp-error`,role:`alert`,children:s}),r?.folder_refusal&&I(`p`,{className:`sp-meta`,role:`status`,children:r.folder_refusal})]}),R(`div`,{className:`sp-picker-actions`,children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:t,children:n(`sp.cancel`)}),I(`button`,{type:`button`,className:`btn-primary`,disabled:!r||!!r.folder_refusal,onClick:()=>r&&e(r.current_path),children:n(`pick.use`)})]})]})})}var yB=e=>e instanceof En?e.detail||e.message:e instanceof Error?e.message:String(e);function bB(e){let t=L(),[n,r]=(0,V.useState)(!1),[i,a]=(0,V.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 et(n))}catch(e){a(t(`pick.checkFailed`,{error:yB(e)}));return}r?a(r):e(n)},e=>a(t(`pick.openFailed`,{error:yB(e)}))):r(!0)},picker:n?I(vB,{onPick:t=>{r(!1),e(t)},onClose:()=>r(!1)}):null,error:i}}var xB=new Map;function SB(e){let t=xB.get(e);return t||(t={env:null,error:null,inFlight:null,version:0,listeners:new Set},xB.set(e,t)),t}function CB(e,t,n){let r=SB(e);r.env=t??r.env,r.error=n,r.listeners.forEach(e=>e())}function wB(e){let t=SB(e);if(t.inFlight)return t.inFlight;let n=t.version;return t.inFlight=Promise.resolve().then(()=>It(e)).then(r=>{let i=gB(r,e=>Array.isArray(e.folders),`chat's environment`);t.version===n&&CB(e,i,null)}).catch(t=>CB(e,null,t instanceof Error?t.message:String(t))).finally(()=>{t.inFlight=null}),t.inFlight}function TB(e){let[,t]=(0,V.useState)(0);(0,V.useEffect)(()=>{let n=SB(e),r=()=>t(e=>e+1);return n.listeners.add(r),!n.env&&!n.inFlight&&wB(e),()=>{n.listeners.delete(r)}},[e]);let n=(0,V.useCallback)(()=>wB(e),[e]),r=(0,V.useCallback)(async t=>{let n=await t();return SB(e).version+=1,CB(e,n,null),n},[e]),i=SB(e);return{env:i.env,error:i.error,refresh:n,change:r}}var EB=e=>e.split(/[\\/]/).filter(Boolean).pop()??e;function DB({folder:e,disabled:t}){let n=L(),r=B(e=>e.draftFolder),i=B(e=>e.setDraftFolder),{open:a,picker:o,error:s}=bB(i),c=e.gaia_folder?n(`folderChip.worksInOwn`,{path:e.path}):n(`folderChip.worksIn`,{path:e.path}),l=!e.gaia_folder&&R(`span`,{className:`new-chat-folder`,title:c,children:[I(Da,{size:13,"aria-hidden":`true`}),I(`span`,{className:`new-chat-folder-name`,dir:`auto`,children:e.name})]});return e.choosable?R(P.Fragment,{children:[l,r?R(`span`,{className:`new-chat-folder is-on`,title:n(`folderChip.picked`,{path:r}),children:[I(Da,{size:13,"aria-hidden":`true`}),I(`span`,{className:`new-chat-folder-name`,dir:`auto`,children:EB(r)}),I(`button`,{type:`button`,className:`new-chat-folder-clear`,onClick:()=>i(null),disabled:t,"aria-label":n(`folderChip.remove`,{name:EB(r)}),title:n(`folderChip.remove`,{name:EB(r)}),children:I(fc,{size:12,"aria-hidden":`true`})})]}):R(`button`,{type:`button`,className:`new-chat-folder is-button`,onClick:()=>a(e.path),disabled:t,"aria-haspopup":`dialog`,title:`${c} ${n(`folderChip.addHint`)}`,children:[I(es,{size:13,"aria-hidden":`true`}),I(`span`,{className:`new-chat-folder-name`,children:n(`folderChip.add`)})]}),s&&I(`span`,{className:`new-chat-folder-error`,role:`alert`,children:s}),o]}):l||R(`span`,{className:`new-chat-folder`,title:`${c} ${n(`folderChip.ownFixedHint`)}`,children:[I(Da,{size:13,"aria-hidden":`true`}),I(`span`,{className:`new-chat-folder-name`,children:n(`folderChip.gaiaFolder`)})]})}function OB({sessionId:e,onOpen:t}){let{env:n}=TB(e),r=n?.folders.find(e=>e.source===`working_folder`);if(!r)return null;let i=EB(r.path);return R(`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:[I(Da,{size:13,"aria-hidden":`true`}),I(`span`,{className:`composer-chip-label`,dir:`auto`,children:i})]})}var kB=`gaia:permission-mode`;function AB(e,t){window.dispatchEvent(new CustomEvent(kB,{detail:{sessionId:e,mode:t}}))}function jB(e,t){let n=(0,V.useRef)(t);n.current=t,(0,V.useEffect)(()=>{if(!e)return;let t=t=>{let r=t.detail;r?.sessionId===e&&n.current(r.mode)};return window.addEventListener(kB,t),()=>window.removeEventListener(kB,t)},[e])}var MB=[{mode:`ask`,label:`perm.ask`,note:`perm.askNote`},{mode:`full_access`,label:`perm.full`,note:`perm.fullNote`}];function NB({sessionId:e,disabled:t}){let n=L(),r=B(e=>e.draftPermissionMode),i=B(e=>e.setDraftPermissionMode),[a,o]=(0,V.useState)(e?null:r),[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(!1),[d,f]=(0,V.useState)(null),p=(0,V.useRef)(null),m=ru(t=>e!==null&&su(e)(t)!==null);(0,V.useEffect)(()=>{e||o(r)},[e,r]),(0,V.useEffect)(()=>{if(!e)return;let t=!1;return o(null),f(null),hn(e).then(e=>{t||o(e.mode)}).catch(e=>{t||f(fP(e))}),()=>{t=!0}},[e]),jB(e,(0,V.useCallback)(e=>{f(null),o(e)},[]));let h=(0,V.useCallback)(async t=>{if(t===`full_access`&&!l)u(!0);else{f(null);try{if(e){let n=(await sr(e,t)).mode;o(n),AB(e,n),n===`full_access`&&m||c(!1)}else i(t),o(t),c(!1)}catch(t){f(fP(t)),e&&hn(e).then(e=>o(e.mode)).catch(e=>f(t=>`${t??``} Couldn't re-read the saved mode: ${fP(e)}`.trim()))}finally{u(!1)}}},[l,m,e,i]),g=a===`full_access`,_=a===null,v=g||_&&d?As:Os,y=n(g?`perm.full`:_?d?`perm.unknown`:`perm.checking`:`env.ask`);return R(`div`,{className:`composer-chip-wrap`,children:[R(`button`,{ref:p,type:`button`,className:`composer-chip${g||_&&d?` is-warning`:``}`,onClick:()=>{u(!1),c(e=>!e)},disabled:t,"aria-haspopup":`dialog`,"aria-expanded":s,"aria-label":_?n(`perm.chipAriaUnread`,{state:y}):n(`perm.chipAria`,{mode:M(g?`perm.fullLower`:`perm.askLower`)}),children:[I(v,{size:13,"aria-hidden":`true`}),I(`span`,{className:`composer-chip-label`,dir:`auto`,children:y}),I(si,{size:12,"aria-hidden":`true`})]}),R(wc,{open:s,onClose:()=>c(!1),anchor:p,label:n(`env.permission`),children:[MB.map(e=>R(`button`,{type:`button`,className:`popover-item`,onClick:()=>h(e.mode),"aria-pressed":a===e.mode,children:[I(`span`,{className:`popover-item-check`,"aria-hidden":`true`,children:a===e.mode&&I(ri,{size:13})}),R(`span`,{className:`popover-item-body`,children:[I(`span`,{className:`popover-item-title`,children:n(e.label)}),I(`span`,{className:`popover-item-note`,children:n(e.note)})]})]},e.mode)),l&&R(`div`,{className:`popover-message`,role:`alert`,children:[n(`env.fullAccessWarn`),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>h(`full_access`),children:n(`env.turnOn`)})]}),g&&m&&!l&&I(`div`,{className:`popover-message`,role:`status`,children:n(`perm.fullPendingNote`)}),d&&I(`div`,{className:`popover-message is-error`,role:`alert`,children:d})]})]})}var PB=`gaiacpp`;function FB(e){return e!==PB}function IB(e){let t=Oz(e=>FB(e.current)),n=B(t=>bt(t,e));return t&&n}function LB(e,t){let n=FB(Oz.getState().current)&&bt(B.getState(),t);return h(e,n)}async function RB(e,t){zB(e,t)&&Pe((await Bt()).skills.map(e=>e.name))}function zB(e,t){let n=FB(Oz.getState().current)&&bt(B.getState(),t);return or(e,n)}function BB({sessionId:e,disabled:t,compact:n=!1}){let r=L(),i=Oz(e=>FB(e.current)),a=IB(e),o=B(e=>e.setResearch),s=t=>o(e,t);return(0,V.useEffect)(()=>{if(!i||!a)return;let e=!0;return Bt().then(t=>{e&&Pe(t.skills.map(e=>e.name))},e=>F.chat.warn(`Research mode could not read the installed skills; a /<name> message will ask again`,e)),()=>{e=!1}},[i,a]),i?R(`button`,{type:`button`,className:`composer-chip composer-chip-research${a?` is-on`:``}`,onClick:()=>s(!a),disabled:t,"aria-pressed":a,"aria-label":r(`composer.research`),title:r(a?`composer.researchOnTitle`:`composer.researchOffTitle`),children:[I(Js,{size:13,"aria-hidden":`true`}),!n&&I(`span`,{className:`composer-chip-label`,dir:`auto`,children:r(`composer.research`)})]}):null}function VB({text:e}){return I(`div`,{className:`history-notice`,role:`note`,children:e})}function HB({notices:e}){return I(`div`,{className:`library-notices`,role:`note`,children:e.map((e,t)=>I(`div`,{dir:`auto`,children:e},`${t}-${e}`))})}var UB={sending:`queue.sending`,delivered:`queue.delivered`,queued:`queue.queued`};function WB(e,t,n){return n(e?UB.queued:t?`queue.busy`:`queue.next`)}function GB(e,t){return e?t.compose(t=>t(`queue.notSent`,{error:typeof e==`string`?e:t(e.key,e.params)})):t(`queue.notSentBare`)}function KB({items:e,onRemove:t,onSteer:n,onRetry:r,replying:i=!0,busyRetry:a=!1}){let o=L(),s=e.filter(e=>e.state!==`starting`);return s.length===0?null:I(`ul`,{className:`queued-messages`,"aria-label":o(`queue.listAria`),"aria-live":`polite`,children:s.map(e=>R(`li`,{className:`queued-message is-${e.state}`,children:[e.state===`failed`?I(yi,{size:12,"aria-hidden":`true`}):e.state===`queued`?I(Di,{size:12,"aria-hidden":`true`}):I(Li,{size:12,"aria-hidden":`true`}),I(`span`,{className:`queued-message-text`,dir:`auto`,title:e.text,children:e.text}),I(`span`,{className:`queued-message-state`,title:e.state===`failed`?GB(e.error,o):void 0,children:e.state===`failed`?GB(e.error,o):e.state===`queued`?(i&&e.note?o(e.note):``)||WB(i,a,o):o(UB[e.state])}),e.state===`failed`&&R(`button`,{type:`button`,className:`queued-message-steer`,onClick:()=>r(e.id),"aria-label":o(`queue.sendAgainAria`,{text:e.text}),children:[I(ms,{size:11,"aria-hidden":`true`}),` `,o(`queue.sendAgain`)]}),e.state===`queued`&&n&&I(`button`,{type:`button`,className:`queued-message-steer`,onClick:()=>n(e.id),title:o(`queue.steerTitle`),children:o(`queue.steer`)}),(e.state===`queued`||e.state===`failed`)&&I(`button`,{type:`button`,className:`queued-message-remove`,onClick:()=>t(e.id),"aria-label":o(`queue.removeAria`,{text:e.text}),title:o(`queue.remove`),children:I(fc,{size:12})})]},e.id))})}function qB(e,{reason:t,code:n}){let r=`ctx.reason.${n}`;return n?!k(r)||ht(r)!==t?t:e(r):ok(e,t)}var JB=e=>e.toLocaleString(`en-US`);function YB({n:e,window:t=!1}){let n=L();if(e==null)return I(`span`,{className:`cp-unknown`,children:n(`ctx.unknown`)});let r=t?ml(e):e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(+(e<1e4))}K`:`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`;return I(`span`,{title:n(`ctx.tokens`,{n:JB(e)}),dir:`ltr`,children:r})}function XB({s:e}){let t=L();if(e==null)return I(`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 I(`span`,{title:`${(e*1e3).toFixed(0)} ms`,dir:`ltr`,children:n})}function ZB({r:e}){let t=L();return e==null?I(`span`,{className:`cp-unknown`,children:t(`ctx.unknown`)}):I(`span`,{title:t(`ctx.rateTitle`,{n:e}),children:t(`ctx.rate`,{n:Math.round(e).toLocaleString(`en-US`)})})}var QB=(e,t)=>t>0?Math.round(e/t*100):0,$B=(e,t)=>{let n=QB(e,t);return n===0&&e>0?`<1`:String(n)},eV=(e,t)=>t&&e!=null?Math.floor(e/t*100):null,tV=256;function nV(e,t=ht){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:ll(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 rV({label:e,children:t,hint:n}){return R(`div`,{className:`cp-row`,title:n,children:[I(`dt`,{children:e}),I(`dd`,{children:t})]})}function iV({t:e}){let t=L();if(e.model_seconds==null||e.gaia_seconds==null)return R(rV,{label:t(`ctx.took`),children:[I(XB,{s:e.wall_seconds}),` · `,t.bare(`ctx.split`),` `,I(`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 R(P.Fragment,{children:[I(rV,{label:t(`ctx.took`),hint:t(`ctx.tookHint`),children:I(XB,{s:e.wall_seconds})}),I(`div`,{className:`cp-stack`,"aria-hidden":`true`,children:n.map(t=>I(`span`,{className:`cp-time-${t.key}`,style:{width:`${QB(t.s,e.wall_seconds)}%`}},t.key))}),R(`dl`,{className:`cp-rows cp-indent`,children:[I(rV,{label:t(`ctx.inModel`),children:I(XB,{s:e.model_seconds})}),I(rV,{label:t(`ctx.inGaia`),hint:t(`ctx.inGaiaHint`),children:I(XB,{s:e.gaia_seconds})}),n.slice(1).filter(e=>e.s>0).map(e=>R(rV,{label:`· ${e.label}`,children:[I(`span`,{className:`swatch cp-time-${e.key}`,"aria-hidden":`true`}),` `,I(XB,{s:e.s})]},e.key))]})]})}function aV({why:e}){let t=L();return I(`span`,{className:`cp-unknown`,title:e,children:t(`ctx.unknown`)})}var oV={server:`ctx.src.server`,client:`ctx.src.client`};function sV(e,t){return e?t(oV[e]):void 0}function cV({turn:e}){let t=L(),n=eV(e.tokens_cached,e.tokens_in),r=e.unknown??{},i=e.tools.map(e=>`${e.name??t(`ctx.toolOutside`)}: ${e.seconds??`?`} s`).join(`
|
|
194
194
|
`);return R(P.Fragment,{children:[I(iV,{t:e.time}),R(`dl`,{className:`cp-rows`,children:[I(rV,{label:t(`ctx.firstWord`),hint:sV(e.first_token_source,t),children:e.first_token_seconds==null?I(aV,{why:r.first_token_seconds}):R(P.Fragment,{children:[t.bare(`ctx.in`),` `,I(XB,{s:e.first_token_seconds})]})}),I(rV,{label:t(`ctx.readingPrompt`),hint:t(`ctx.readingHint`),children:e.tokens_new!=null&&e.tokens_new<tV?I(`span`,{title:t(`ctx.tooFewTitle`),children:t(`ctx.onlyNew`,{n:e.tokens_new})}):e.prefill_tokens_per_second==null?I(aV,{why:r.prefill_tokens_per_second}):R(P.Fragment,{children:[I(ZB,{r:e.prefill_tokens_per_second}),e.prefill_source===`client`&&I(`span`,{className:`cp-chip`,title:t(`ctx.approxTitle`),children:t(`ctx.approx`)})]})}),I(rV,{label:t(`ctx.writing`),hint:sV(e.generation_source,t)??t(`ctx.writingHint`),children:e.generation_tokens_per_second==null?I(aV,{why:r.generation_tokens_per_second}):I(ZB,{r:e.generation_tokens_per_second})}),I(rV,{label:t(`ctx.tokensInOut`),hint:r.tokens,children:R(`span`,{dir:`ltr`,children:[I(YB,{n:e.tokens_in}),` → `,I(YB,{n:e.tokens_out})]})}),I(rV,{label:t(`ctx.cache`),hint:t(`ctx.cacheHint`),children:e.tokens_cached==null?I(aV,{why:r.tokens_cached}):R(P.Fragment,{children:[I(YB,{n:e.tokens_cached}),n!=null&&` (${n}%)`]})}),I(rV,{label:t(`ctx.modelCalls`),children:e.model_calls}),I(rV,{label:t(`ctx.toolCalls`),hint:i||void 0,children:e.tool_calls===0&&!e.tool_seconds_total?t(`ctx.none`):R(P.Fragment,{children:[e.tool_calls,` · `,I(XB,{s:e.tool_seconds_total??0})]})}),I(rV,{label:t(`ctx.loads`),children:e.loads.length===0?t(`ctx.none`):R(`span`,{title:e.loads.map(e=>`${e.model}${e.replaced?.length?` replaced ${e.replaced.join(`, `)}`:``}: ${e.seconds} s`).join(`
|
|
@@ -213,9 +213,9 @@ Error generating stack: `+e.message+`
|
|
|
213
213
|
`);return(0,V.useEffect)(()=>{let e=r.current;e&&i.current&&(e.scrollTop=e.scrollHeight)},[a]),I(`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 bX=1e9,xX={downloading:0,verifying:1,failed:2,ready:3,unchecked:3,cancelled:4,queued:5,skipped:6};function SX(e){return e.roles.includes(`embedding`)?0:e.roles.includes(`chat`)?1:2}function CX(e){return[...e].filter(e=>e.state!==`skipped`).sort((e,t)=>xX[e.state]-xX[t.state]||SX(e)-SX(t))}var wX=/^\s*(Downloading:|Downloaded\b|\[[=\-\s>#]*\])/;function TX(e){return e.some(e=>e.trim()&&!wX.test(e))}var EX={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 DX(e){return e?e.state===`running`||e.state===`verifying`||!!e.models?.some(e=>e.state===`downloading`||e.state===`queued`||e.state===`verifying`):!1}function OX(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:zA(e.bytes_done),need:PA(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 kX({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=L(),m=(0,V.useId)(),h=(0,V.useId)(),[g,_]=(0,V.useState)(!1),v=e.log??[],y=e.state===`ready`||e.state===`unchecked`?100:e.bytes_total>0?Math.min(100,e.bytes_done/e.bytes_total*100):0,b=p(EX[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=VA(p.locale,e.bytes_total>0?`${zA(e.bytes_done)} / ${zA(e.bytes_total)}`:zA(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} · ${VA(p.locale,BA(e))} · ${WA(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?zA(e.bytes_total):``:e.state===`unchecked`?p(`setup.progress.unchecked`):e.state===`cancelled`?e.bytes_done>0?p(`setup.progress.keptPartial`,{done:zA(e.bytes_done)}):``:e.state===`queued`&&e.bytes_total?zA(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:zA(e.bytes_done),total:zA(e.bytes_total)}):null,n?.eta==null?null:GA(n.eta,t)].filter(Boolean).join(`, `)):b;return R(`li`,{className:`dl-row is-${e.state}${C?` is-live`:``}${S>=15?` is-stalled`:``}`,children:[R(`div`,{className:`dl-row-head`,children:[I(`span`,{className:`dl-icon`,"aria-hidden":`true`,children:e.state===`ready`||e.state===`unchecked`?I(ri,{size:14}):e.state===`failed`?I(yi,{size:14}):e.state===`cancelled`?I(Bo,{size:13}):I(`span`,{className:`dl-dot`})}),I(`span`,{className:`dl-name`,children:I(`bdi`,{title:e.id,children:t})}),I(`span`,{className:`dl-state`,children:b}),e.state===`downloading`&&R(`bdi`,{className:`dl-pct`,children:[Math.floor(y),`%`]}),e.state!==`failed`&&TX(v)&&I(`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:I(di,{size:14,className:g?`is-open`:``,"aria-hidden":`true`})})]}),I(`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:I(`span`,{className:`dl-fill`,style:{inlineSize:`${e.state===`verifying`?100:y}%`}})}),w&&I(`p`,{className:`dl-detail`,children:I(`bdi`,{children:w})}),g&&e.state!==`failed`&&TX(v)&&I(yX,{lines:v,id:h,className:`dl-log`}),e.state===`failed`&&R(`div`,{className:`dl-fail`,children:[I(`p`,{className:`dl-error`,id:m,children:OX(e,t,i,p)}),(v.length>0||e.error)&&R(`details`,{className:`dl-details`,children:[I(`summary`,{children:p(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:v.length>0?v.join(`
|
|
214
214
|
`):e.error})]}),u?I(`p`,{className:`dl-detail`,children:p(`setup.progress.retryLater`)}):R(`div`,{className:`setup-row`,children:[a&&R(`button`,{type:`button`,className:`btn-primary`,disabled:l,onClick:()=>a(e.id,e.error_kind),"aria-describedby":m,children:[I(ms,{size:13,"aria-hidden":`true`}),` `,p(`setup.progress.retry`)]}),s&&I(`button`,{type:`button`,className:`btn-secondary`,disabled:l,onClick:()=>s(e.id),children:p(`setup.progress.skipModel`)})]})]}),e.state===`cancelled`&&o&&I(`div`,{className:`setup-row`,children:I(`button`,{type:`button`,className:`btn-secondary`,disabled:l,onClick:()=>o(e.id),children:p(`setup.progress.resume`)})}),S>=60&&c&&I(`div`,{className:`setup-row`,children:R(`button`,{type:`button`,className:`btn-secondary`,disabled:l,onClick:c,children:[I(ms,{size:13,"aria-hidden":`true`}),` `,p(`setup.progress.retry`)]})})]})}function AX({status:e,names:t,freeGb:n=null,onCancel:r,onRetry:i,onResume:a,onResumeAll:o,onFinishWithout:s,onSkip:c,onRestart:l,busy:u=!1,retryLater:d=!1,labelledBy:f}){let p=L(),m=nY(),h=(0,V.useMemo)(()=>CX(e.models??[]),[e.models]),g=(0,V.useRef)(new Map),_=(0,V.useRef)(new Map),v=(0,V.useRef)(new JA),y=(0,V.useRef)(!1),[b,x]=(0,V.useState)(()=>Date.now()),[S,C]=(0,V.useState)(!1),[w,T]=(0,V.useState)(null),E=i&&((e,t)=>{let n=h.find(t=>t.id===e);t===`verify`&&n?T(n):i(e,t)}),[ee,D]=(0,V.useState)(``),[O,te]=(0,V.useState)(``),k=(0,V.useRef)(null),A=e.state===`verifying`||e.state!==`running`&&h.some(e=>e.state===`verifying`),ne=(0,V.useRef)(new Map);(0,V.useEffect)(()=>{if(!m||!(h.some(e=>e.retrying_until)||A))return;let e=setInterval(()=>x(Date.now()),1e3);return()=>clearInterval(e)},[h,m,A]);let re=e.overall,{estimates:j,overallEstimate:ie}=(0,V.useMemo)(()=>{let e=Date.now(),t={};for(let n of h){if(n.state!==`downloading`){g.current.delete(n.id);continue}let r=g.current.get(n.id),i=n.downloaded_before_gb??null;r&&_.current.get(n.id)===i||(r=new JA,g.current.set(n.id,r),_.current.set(n.id,i)),t[n.id]=r.update(n.bytes_done,n.bytes_total,e)}let n=h.some(e=>e.state===`downloading`);n&&!y.current&&(v.current=new JA),y.current=n;let r=h.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&&re?v.current.update(re.bytes_done,re.bytes_done+r,e):void 0}},[h,re]);(0,V.useEffect)(()=>{let e=new Map(h.map(e=>[e.id,e.state])),n=Math.floor((re?.percent??0)/25),r=k.current;if(k.current={states:e,quarter:n},!r)return;let i=[];for(let e of h){if(r.states.get(e.id)===e.state)continue;let n=t[e.id]??e.id;e.state===`failed`?te(p(`setup.progress.announceFailed`,{name:n})):i.push(p(`setup.progress.announceState`,{name:n,state:p(EX[e.state])}))}n>r.quarter&&n>0&&n<4&&i.push(p(`setup.progress.announceOverall`,{n:String(n*25)})),i.length&&D(i.join(`. `))},[h,re?.percent,t,p]);let ae=e=>{if(!A)return ne.current.delete(e),0;let t=Date.now(),n=ne.current.get(e)??t;return ne.current.set(e,n),Math.floor((t-n)/1e3)},oe=DX(e),se=h.filter(e=>e.state===`cancelled`),ce=re?.failed??h.filter(e=>e.state===`failed`).length,le=re?.percent??0,ue=()=>{(re?.bytes_done??0)>bX?C(!0):r?.()},M=p.compose(e=>[e(`setup.progress.overallPct`,{n:String(le)}),re&&re.bytes_total>0?e(`setup.progress.of`,{done:zA(re.bytes_done),total:zA(re.bytes_total)}):null,oe&&ie?.speed?VA(p.locale,BA(ie.speed)):null,oe?ie?.eta==null?e(`setup.progress.estimating`):e(`setup.progress.left`,{eta:WA(ie.eta,e)}):null,ce>0?e(`setup.progress.failedCount`,{n:String(ce)}):null].filter(Boolean).join(` · `));return R(`section`,{className:`dl${m?``:` is-paused`}`,"aria-labelledby":f,children:[R(`div`,{className:`dl-overall`,children:[I(`p`,{className:`dl-overall-line`,children:I(`bdi`,{children:M})}),I(`div`,{className:`dl-track is-overall${h.some(e=>e.state===`downloading`)?` is-live`:``}`,role:`progressbar`,"aria-label":p(`setup.progress.overallLabel`),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":le,"aria-valuetext":p(`setup.progress.percent`,{n:String(le)}),children:I(`span`,{className:`dl-fill`,style:{inlineSize:`${le}%`}})})]}),I(`ul`,{className:`dl-list`,children:h.map(e=>I(kX,{model:e,name:t[e.id]??e.id,estimate:j[e.id],now:b,freeGb:n,onRetry:E,onResume:oe?void 0:a,onSkip:c,onRestart:l,busy:u,retryLater:d,checking:A,checkingFor:ae(e.id)},e.id))}),oe&&I(`p`,{className:`setup-hint dl-controls`,children:p(`setup.progress.keepsGoing`)}),(oe&&r||!oe&&(se.length>0&&o||s))&&R(eX,{children:[oe&&r&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:ue,disabled:u,children:p(`setup.progress.cancel`)}),!oe&&s&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:s,disabled:u,children:p(`setup.download.finishWithoutExtras`)}),!oe&&se.length>0&&o&&I(`button`,{type:`button`,className:`btn-primary`,onClick:o,disabled:u,children:p(`setup.progress.resumeAll`)})]}),I(`span`,{className:`visually-hidden`,"aria-live":`polite`,children:ee}),I(`span`,{className:`visually-hidden`,role:`alert`,children:O}),S&&I(tX,{title:p(`setup.progress.cancelTitle`),confirmLabel:p(`setup.progress.cancelConfirm`),cancelLabel:p(`setup.progress.cancelKeep`),onConfirm:()=>{C(!1),r?.()},onCancel:()=>C(!1),children:I(`p`,{children:p(`setup.progress.cancelBody`)})}),w&&I(tX,{title:p(`setup.redownload.title`,{name:t[w.id]??w.id}),confirmLabel:p(`setup.redownload.confirm`),cancelLabel:p(`setup.redownload.keep`),onConfirm:()=>{let e=w;T(null),i?.(e.id,`verify`)},onCancel:()=>T(null),children:I(`p`,{children:p(`setup.redownload.body`,{name:t[w.id]??w.id,size:zA(w.bytes_total)})})})]})}function jX({run:e,plan:t,idle:n,bar:r=!0}){let i=L(),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 R(`div`,{className:`setup-activity`,children:[R(`p`,{className:`setup-hint`,children:[I(so,{size:13,className:`spin`,"aria-hidden":`true`}),` `,I(`span`,{role:`status`,children:l}),c!=null&&R(P.Fragment,{children:[` · `,R(`bdi`,{dir:`ltr`,children:[c,`%`]})]}),a.length>0&&R(P.Fragment,{children:[` · `,i(`setup.download.partsReady`,{done:String(s),total:String(a.length)})]})]}),r&&c!=null&&I(`progress`,{className:`setup-progress`,max:100,value:c,"aria-label":l})]})}var MX=[`check`,`download`,`test`],NX={root:`setup-report`,button:`btn-secondary setup-report-button`,hint:`setup-hint`,error:`setup-error`},PX=/\d+(\.\d+)?\s*%/;function FX(e){let t=[],n=null;for(let r of e){let e=r.search(PX),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 IX({run:e,before:t={},failed:n=!1}){let r=L(),[i,a]=(0,V.useState)(n),[o,s]=(0,V.useState)(()=>new Set);(0,V.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=>FX([...t[n]??[],...e?.logs?.[n]??[]]),u=MX.filter(e=>l(e).length>0);return R(`section`,{className:`setup-logs`,"aria-label":r(`setup.logs.title`),children:[R(`button`,{type:`button`,className:`setup-log-toggle setup-help-toggle`,onClick:()=>a(e=>!e),"aria-expanded":i,"aria-controls":`setup-help`,children:[I(di,{size:13,className:i?`is-open`:``,"aria-hidden":`true`}),` `,r(`setup.logs.help`)]}),i&&R(`div`,{id:`setup-help`,className:`setup-help`,children:[u.map(e=>{let t=l(e),n=o.has(e);return R(`div`,{className:`setup-log`,children:[R(`button`,{type:`button`,className:`setup-log-toggle`,onClick:()=>c(e),"aria-expanded":n,children:[I(di,{size:13,className:n?`is-open`:``,"aria-hidden":`true`}),` `,r(`setup.logs.${e}`)]}),n&&I(yX,{lines:t,className:`setup-log-pre`})]},e)}),I(EF,{classes:NX,note:r(`setup.logs.reportNote`)})]})]})}function LX(){let e=L(),t=B(e=>e.locale),n=B(e=>e.setLocale);return R(`label`,{className:`setup-language`,children:[I(qa,{size:14,"aria-hidden":`true`}),I(`span`,{className:`visually-hidden`,children:e(`settings.language`)}),I(`select`,{value:t,onChange:e=>n(e.target.value),children:je.map(({meta:e})=>I(`option`,{value:e.code,lang:e.code,dir:e.dir,children:Ye(e)},e.code))})]})}var RX={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`]},zX={cancelled:`setup.npu.fixError.cancelled`,timeout:`setup.npu.fixError.timeout`,not_authorized:`setup.npu.fixError.notAuthorized`,no_pkexec:`setup.npu.fixError.noPkexec`};function BX({problem:e}){let t=L(),n=RX[e.code];if(!n)return R(`li`,{children:[I(`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`),R(`li`,{children:[I(`strong`,{children:t(a,{device:r.device??``,limit:r.limit??``,version:r.version??``,detail:r.detail??``})}),` `,t(i,{group:r.group??``})]})}function VX({problems:e,disabled:t,onRecheck:n,id:r=`setup-npu-problems`}){let i=L(),[a,o]=(0,V.useState)(!1),[s,c]=(0,V.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 En?e.body?.code:void 0,r=n&&n in zX?zX[n]:t;c(i(r))}finally{o(!1)}};return R(`div`,{className:`setup-npu-problems`,id:r,role:`note`,children:[I(`p`,{children:i(`setup.npu.notReady`)}),I(`ul`,{children:e.map(e=>I(BX,{problem:e},e.code))}),I(`p`,{className:`setup-hint`,children:i(`setup.npu.meanwhile`)}),s&&I(`p`,{className:`setup-npu-error`,role:`alert`,children:s}),R(`div`,{className:`setup-npu-actions`,children:[l&&I(`button`,{type:`button`,className:`btn-primary`,disabled:t||a,onClick:()=>void u(at,`setup.npu.fixError.failed`),children:i(`setup.npu.fixMemlock`)}),n&&I(`button`,{type:`button`,className:`btn-secondary`,disabled:t||a,onClick:()=>void u(vn,`setup.npu.recheckFailed`),children:i(`setup.npu.recheck`)})]})]})}async function HX(){let e=await ue();e.reachable&&(e.available_backends??[]).some(e=>e.name===`vulkan`)&&(e.preferred_backend??e.default_backend)!==`vulkan`&&await E(`vulkan`)}function UX({plan:e,selection:t,onSelection:n,disabled:r=!1,onRecheck:i}){let a=L(),o=aY(e),s=e.npu?.present&&!e.npu.ready?e.npu.problems:[],c=s.length?void 0:o.find(e=>cY(e)&&e.gaia_model&&e.chat_choice&&e.fits!==!1)??o.find(e=>cY(e)&&e.chat_choice&&e.downloaded&&!lY(e)),l=!s.length&&!c&&o.some(e=>cY(e)&&e.fit_code===`npu`),u=!!o.find(e=>e.id===t.defaultChat&&cY(e)),d=wY(e).defaultChat,f=d&&!o.find(e=>e.id===d&&cY(e))?d:o.find(e=>e.chat_choice&&e.gaia_model&&e.support===`verified`&&!cY(e))?.id,p=e=>{e===`npu`&&c&&!u&&n(mY(t,o,c.id)),e===`gpu`&&u&&f&&n(mY(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 R(`section`,{className:`setup-backend`,"aria-labelledby":`setup-backend-title`,children:[I(`h3`,{className:`mc-job-title`,id:`setup-backend-title`,children:a(`setup.backend.title`)}),I(VV,{className:`segmented`,"aria-labelledby":`setup-backend-title`,children:m.map(e=>I(`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:I(`bdi`,{children:e.label})},e.id))}),s.length>0?I(VX,{problems:s,disabled:r,onRecheck:i}):I(`p`,{className:`setup-hint`,children:a(c?`setup.backend.hint`:l?`setup.backend.hintNpuUnusable`:`setup.backend.hintNoNpu`)})]})}var WX=({children:e})=>I(`bdi`,{dir:`ltr`,children:e});function GX({label:e,children:t}){return R(`div`,{className:`found-row`,children:[I(`dt`,{children:e}),I(`dd`,{children:t})]})}function KX(e){return e.family?`${e.name} (${e.family})`:e.name}var qX=[[`llamacpp`,`llama.cpp`],[`flm`,`FastFlowLM`],[`whispercpp`,`whisper.cpp`],[`kokoro`,`Kokoro`],[`sd-cpp`,`stable-diffusion.cpp`]],JX=new Set([`llamacpp`,`flm`]);function YX(e){let t=[];for(let[n,r]of qX){let i=(e.backends??[]).find(e=>e.recipe===n&&e.default);i&&i.state!==`unsupported`&&t.push({name:r,b:i})}return t}function XX(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 ZX={release:`release`,release_candidate:`release candidate`,local:`local build`,source:`from source`};function QX(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=YX(e);return{sys:n,cpu:r(e=>e===`cpu`)[0],gpus:i,graphics:i.length?i.map(KX).join(`; `):t?.gpu_name??null,npus:a,runsOn:i[0]?.name??t?.gpu_name??null,npu:a[0]??null,runtimes:o,gaia:XX(n?.gaia_build,n?.gaia_version),build:n?.gaia_build?.kind??null,software:[XX(n?.gaia_build,n?.gaia_version)?`GAIA ${XX(n?.gaia_build,n?.gaia_version)}`:null,n?.lemonade_version?`Lemonade ${n.lemonade_version}`:null,...o.filter(({b:e})=>JX.has(e.recipe)&&eZ(e)).map(({name:e,b:t})=>`${e} ${t.version??t.backend}`)].filter(e=>!!e),totalMemory:LA(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 $X={installed:`installed`,update_required:`installed, updates on first use`},eZ=e=>e.state===`installed`||e.state===`update_required`,tZ={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 nZ(e,t){let n=QX(e,t),r=e.lemonade.mode===`external`?`the user's own`:`GAIA's own`;return[`GAIA: ${n.gaia??`unknown`}${n.build?`, ${ZX[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}`:``} (${$X[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(KX).join(`; `)||`none found`}`,`Memory: ${n.totalMemory??`unknown`}${e.capacity_gb==null?``:`, ${PA(e.capacity_gb)} for models${e.memory_source?` (${e.memory_source})`:``}`}`,`Models folder: ${n.modelsPath??`unknown`}${n.freeGb==null?``:` (${PA(n.freeGb)} free)`}`,`GAIA data and logs: ${n.gaiaHome??`unknown`}`].join(`
|
|
215
215
|
`)}function rZ({plan:e,hardware:t,onChangeMemory:n}){let r=L(),i=QX(e,t),[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(null),d=async e=>{u(null);try{await pt(e,!1)}catch(e){u(r(`setup.found.openFailed`,{error:e instanceof Error?e.message:String(e)}))}},f=I(`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,V.useRef)(null);(0,V.useEffect)(()=>()=>{m.current&&clearTimeout(m.current)},[]);let h=e=>{c(e),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>c(null),2e3)};return R(`section`,{className:`setup-card found`,"aria-label":r(`setup.found.title`),children:[R(`div`,{className:`found-head`,children:[I(`h3`,{className:`mc-job-title`,children:r(`setup.found.title`)}),I(`button`,{type:`button`,className:`found-copy`,onClick:()=>{navigator.clipboard.writeText(nZ(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:I(s===`done`?ri:Fi,{size:14,"aria-hidden":`true`})}),s&&I(`span`,{className:`found-copied`,role:`status`,children:r(s===`done`?`setup.found.copied`:`setup.found.copyFailed`)})]}),R(`dl`,{className:`found-glance`,children:[R(GX,{label:r(`setup.found.runsOn`),children:[i.runsOn?I(WX,{children:i.runsOn}):f,i.npu&&I(`span`,{className:`found-chip`,children:I(WX,{children:`NPU`})})]}),R(GX,{label:r(`setup.found.memory`),children:[e.capacity_gb!=null&&i.totalMemory?r(`setup.found.memoryOf`,{size:PA(e.capacity_gb),total:i.totalMemory}):e.capacity_gb==null?i.totalMemory?I(WX,{children:i.totalMemory}):f:I(WX,{children:PA(e.capacity_gb)}),n&&I(`button`,{type:`button`,className:`link-btn found-link`,onClick:n,children:r(`setup.found.changeMemory`)})]}),I(GX,{label:r(`setup.found.space`),children:i.freeGb==null?f:I(WX,{children:PA(i.freeGb)})}),R(GX,{label:r(`setup.found.software`),children:[i.software.length?I(WX,{children:i.software.join(` · `)}):f,i.build&&i.build!==`release`&&I(`span`,{className:`found-chip`,children:r(`setup.found.build.${i.build}`)})]})]}),R(`div`,{className:`found-paths`,children:[[[`setup.found.modelsFolder`,i.modelsPath],[`setup.found.gaiaFolder`,i.gaiaHome]].map(([e,t])=>t&&R(`button`,{type:`button`,className:`link-btn found-open`,onClick:()=>void d(t),title:t,children:[I(xa,{size:13,"aria-hidden":`true`}),` `,r(e)]},e)),l&&I(`p`,{className:`setup-error`,role:`alert`,children:l})]}),p.length>0&&R(`details`,{className:`dl-details found-warnings`,children:[R(`summary`,{children:[I(yi,{size:13,"aria-hidden":`true`}),` `,r(`setup.found.noticed`)]}),I(`ul`,{children:p.map(e=>I(`li`,{children:I(WX,{children:e})},e))})]}),R(`button`,{type:`button`,className:`setup-log-toggle found-more`,onClick:()=>o(e=>!e),"aria-expanded":a,children:[I(di,{size:13,className:a?`is-open`:``,"aria-hidden":`true`}),` `,r(`setup.found.details`)]}),a&&R(`div`,{className:`found-details`,children:[I(`h4`,{className:`found-group`,children:r(`setup.found.software`)}),R(`dl`,{className:`found-list`,children:[R(GX,{label:I(WX,{children:`GAIA`}),children:[i.gaia?I(WX,{children:i.gaia}):f,i.build&&i.build!==`release`&&I(`span`,{className:`found-chip`,children:r(`setup.found.build.${i.build}`)})]}),I(GX,{label:r(`setup.found.agent`),children:i.sys?.agent_version?I(WX,{children:i.sys.agent_version}):I(`span`,{className:`found-muted`,children:r(`setup.found.agentLater`)})}),R(GX,{label:r(`setup.found.server`),children:[e.lemonade.mode===`external`?r(`setup.found.serverYours`):r(`setup.found.serverOwn`),i.sys?.lemonade_version&&R(P.Fragment,{children:[` `,I(WX,{children:i.sys.lemonade_version})]}),e.lemonade.url&&I(`span`,{className:`found-sub`,children:I(WX,{children:e.lemonade.url})})]})]}),I(`h4`,{className:`found-group`,children:r(`setup.found.runtime`)}),i.runtimes.length?I(`div`,{className:`found-table-wrap`,children:R(`table`,{className:`found-table`,children:[I(`thead`,{className:`visually-hidden`,children:R(`tr`,{children:[I(`th`,{scope:`col`,children:r(`setup.found.col.runtime`)}),I(`th`,{scope:`col`,children:r(`setup.found.col.device`)}),I(`th`,{scope:`col`,children:r(`setup.found.col.version`)}),I(`th`,{scope:`col`,children:r(`setup.found.col.state`)})]})}),I(`tbody`,{children:i.runtimes.map(({name:e,b:t})=>R(`tr`,{children:[I(`th`,{scope:`row`,children:I(WX,{children:e})}),I(`td`,{children:I(WX,{children:t.backend})}),I(`td`,{children:I(WX,{children:t.version??``})}),I(`td`,{className:eZ(t)?`is-installed`:void 0,children:r(eZ(t)?`setup.pc.backend.installed`:`setup.pc.backend.available`)})]},t.recipe))})]})}):I(`p`,{className:`found-muted`,children:r(`setup.found.unknown`)}),I(`h4`,{className:`found-group`,children:r(`setup.found.models`)}),(e.catalog??[]).length?I(`div`,{className:`found-table-wrap`,children:R(`table`,{className:`found-table`,children:[I(`thead`,{className:`visually-hidden`,children:R(`tr`,{children:[I(`th`,{scope:`col`,children:r(`setup.found.col.model`)}),I(`th`,{scope:`col`,children:r(`setup.found.col.job`)}),I(`th`,{scope:`col`,children:r(`setup.found.col.tested`)}),I(`th`,{scope:`col`,children:r(`setup.found.col.size`)}),I(`th`,{scope:`col`,children:r(`setup.found.col.state`)})]})}),I(`tbody`,{children:(e.catalog??[]).map(e=>R(`tr`,{children:[I(`th`,{scope:`row`,title:e.id,children:I(`bdi`,{children:e.name})}),I(`td`,{children:e.roles.map(e=>r(tZ[e])).join(` · `)}),R(`td`,{children:[e.support===`verified`&&I(`span`,{className:`mc-chip is-verified`,children:r(`setup.label.verified`)}),e.support===`untested`&&I(`span`,{className:`mc-chip is-untested`,children:r(`setup.label.untested`)})]}),I(`td`,{children:I(WX,{children:e.full_size_gb??e.size_gb?PA(e.full_size_gb??e.size_gb):``})}),I(`td`,{className:e.downloaded?`is-installed`:void 0,children:r(e.downloaded?`setup.models.status.onPc`:`setup.found.notDownloaded`)})]},e.id))})]})}):I(`p`,{className:`found-muted`,children:r(`setup.found.unknown`)}),I(`h4`,{className:`found-group`,children:r(`setup.found.hardware`)}),R(`dl`,{className:`found-list`,children:[I(GX,{label:r(`setup.found.os`),children:i.sys?.os??t?.os?I(WX,{children:i.sys?.os??t?.os}):f}),R(GX,{label:r(`setup.found.cpu`),children:[i.cpu||i.sys?.processor?I(WX,{children:i.cpu?.name??i.sys?.processor}):f,i.cpu?.cores?I(`span`,{className:`found-sub`,children:r(`setup.found.cores`,{cores:String(i.cpu.cores),threads:String(i.cpu.threads??i.cpu.cores)})}):null]}),I(GX,{label:r(`setup.found.gpu`),children:i.graphics?I(WX,{children:i.graphics}):I(`span`,{className:`found-muted`,children:r(`setup.found.none`)})}),I(GX,{label:r(`setup.found.npu`),children:i.npus.length?I(WX,{children:i.npus.map(KX).join(`; `)}):I(`span`,{className:`found-muted`,children:r(`setup.found.none`)})})]})]})]})}function iZ(){return window.gaiaUpdater}var aZ={status:`idle`,version:null,progress:0,releaseNotes:null,error:null,currentVersion:null,pinnedVersion:null,autoUpdate:!1,includePrereleases:!1};function oZ(){let[e,t]=(0,V.useState)({...aZ}),n=(0,V.useRef)(!1),r=(0,V.useRef)(0),i=(0,V.useCallback)(async()=>{let e=iZ();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,V.useEffect)(()=>{let e=iZ();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 sZ=`gaia-update-error:`;function cZ(e,t){let n=`update.err.${e}`;return k(n)?M(n,t??{}):null}function lZ(e){let t=e instanceof Error?e.message:String(e),n=t.indexOf(sZ);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=cZ(r.code,r.params)??r.message??r.code,a=r.note&&cZ(r.note.code,r.note.params);return a?M(`update.err.withNote`,{error:i,note:a}):i}function uZ(e,t){let n=lZ(e);return typeof n==`object`?t(n.ref,n.params):String(n)}function dZ({className:e}){let t=L(),n=oZ(),[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(null),s=n.lastWorking;if(!iZ()||!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(Fn(t),{year:`numeric`,month:`short`,day:`numeric`}),f=t(`setup.goBack.title`);return R(`section`,{className:e?`setup-card ${e}`:`setup-card`,"aria-label":f,children:[I(`h3`,{className:`mc-job-title`,children:f}),I(`p`,{children:t(`setup.goBack.lead`,{version:s.version,date:d})}),I(`p`,{className:`setup-hint`,children:t(`setup.goBack.fixes`,{version:s.version})}),c||l?R(`p`,{className:`setup-hint`,role:`status`,children:[I(so,{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?R(P.Fragment,{children:[I(`p`,{className:`setup-hint`,children:t(`setup.goBack.ready`,{version:s.version})}),I(`div`,{className:`setup-row`,children:I(`button`,{type:`button`,className:`btn-secondary go-back-action`,onClick:()=>{let e=iZ();e&&(o(null),e.restart().catch(e=>{F.system.error(`Restarting into the last working version failed`,e),o(t(`setup.goBack.failed`,{reason:uZ(e,t)}))}))},children:t(`setup.goBack.restart`,{version:s.version})})})]}):I(`div`,{className:`setup-row`,children:I(`button`,{type:`button`,className:`btn-secondary go-back-action`,onClick:()=>{let e=iZ();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:uZ(e,t)}))}).finally(()=>i(!1)))},disabled:r,children:t(`setup.goBack.action`,{version:s.version})})}),a&&I(`p`,{className:`setup-error`,role:`alert`,children:a}),R(`details`,{className:`dl-details`,children:[I(`summary`,{children:t(`setup.progress.details`)}),I(`p`,{className:`setup-hint`,children:t(`setup.goBack.note`,{version:s.version,current:n.currentVersion??``})})]})]})}function fZ({state:e}){return e===`done`?I(ri,{size:13,"aria-hidden":`true`}):e===`active`?I(so,{size:13,className:`spin`,"aria-hidden":`true`}):I(e===`failed`?fc:e===`question`?xi:Ti,{size:13,"aria-hidden":`true`})}function pZ({hardware:e,hardwareError:t,plan:n,serverRun:r,awaitingChoice:i=!1}){let a=L(),[o,s]=(0,V.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?LA(n?.system?.physical_memory,e?.ram_gb):null:PA(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:VA(a.locale,FA(e.disk_free_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=I(`ul`,{className:`setup-rows`,id:`setup-check-rows`,children:g.map(e=>R(`li`,{className:`setup-result is-${e.state}`,children:[I(fZ,{state:e.state}),I(`span`,{className:`setup-result-label`,children:e.label}),e.value&&I(`bdi`,{className:`setup-result-value`,children:e.value})]},e.id))});return _===g.length?R(`section`,{className:`setup-card setup-checks-done`,"aria-label":a(`setup.check.title`),children:[I(`p`,{className:`setup-result is-done`,role:`status`,children:R(`button`,{type:`button`,className:`setup-checks-toggle`,"aria-expanded":o,"aria-controls":`setup-check-rows`,onClick:()=>s(e=>!e),children:[I(ri,{size:13,"aria-hidden":`true`}),I(`span`,{className:`setup-result-label`,children:a(`setup.checks.allPassed`,{n:String(g.length)})}),I(di,{size:13,className:o?`is-open`:``,"aria-hidden":`true`})]})}),o&&y]}):R(`section`,{className:`setup-card`,"aria-label":a(`setup.check.title`),children:[I(`div`,{className:`setup-bar-head`,children:i?I(`span`,{children:a(`setup.checks.waitingChoice`)}):R(P.Fragment,{children:[I(`span`,{children:a(`setup.checks.count`,{done:String(_),total:String(g.length)})}),R(`bdi`,{dir:`ltr`,children:[v,`%`]})]})}),I(`progress`,{className:`setup-progress`,max:100,value:v,"aria-label":a(`setup.check.title`)}),y]})}function mZ({steps:e}){let t=L();return R(`nav`,{className:`setup-rail`,"aria-label":t(`setup.rail.label`),children:[I(`p`,{className:`setup-rail-title`,children:t(`setup.title`)}),I(`ol`,{className:`setup-rail-list`,children:e.map((e,t)=>{let n=e.status===`done`?I(ri,{size:13,"aria-hidden":`true`}):e.status===`active`?I(so,{size:13,className:`spin`,"aria-hidden":`true`}):e.status===`failed`?I(yi,{size:13,"aria-hidden":`true`}):t+1,r=R(P.Fragment,{children:[I(`span`,{className:`setup-rail-num`,children:n}),I(`span`,{children:e.label})]}),i=`setup-rail-step is-${e.status}${e.shown?` is-shown`:``}`,a=e.shown?`step`:void 0;return I(`li`,{children:e.onOpen?I(`button`,{type:`button`,className:i,onClick:e.onOpen,children:r}):I(`span`,{className:i,"aria-current":a,children:r})},e.id)})})]})}var hZ={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`},gZ=`gaiacpp`,_Z=e=>e.job===`agent`&&e.agent===gZ;function vZ(e,t){return t(`setup.test.job.${e}`)}function yZ({state:e}){return e===`passed`?I(ri,{size:13,"aria-hidden":`true`}):e===`running`?I(so,{size:13,className:`spin`,"aria-hidden":`true`}):I(e===`failed`?fc:e===`skipped`?So:Ti,{size:13,"aria-hidden":`true`})}function bZ(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 xZ({run:e,expected:t,names:n,catalog:r,onRetry:i,onChooseAnother:a,onCancel:o,onDownloadAgain:s,busy:c}){let l=L(),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,V.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`&&!_Z(e)),w=_&&e.state===`failed`&&g.some(_Z),T=w?g.find(e=>_Z(e)&&e.agent_problem)?.agent_problem??null:null,[E,ee]=(0,V.useState)(!1),[D,O]=(0,V.useState)(!1),[te,k]=(0,V.useState)(null),A=async()=>{ee(!0),k(null);try{if((await Ee()).programs.find(e=>e.id===`gaiapy`)?.installed!==!0){k(M(`newChat.agent.pythonMissing`,{name:gZ}));return}await He({flagship_agent:`gaiapy`}),i()}catch(e){k(dP(e))}finally{ee(!1)}},ne=e.state===`verifying`&&!u.some(e=>e.state===`running`)?f[0]:void 0;return R(P.Fragment,{children:[R(`section`,{className:`setup-card`,"aria-label":l(`setup.test.title`),children:[R(`div`,{className:`setup-bar-head`,children:[I(`span`,{children:l(`setup.test.count`,{done:String(p),total:String(m)})}),R(`bdi`,{dir:`ltr`,children:[h,`%`]})]}),I(`progress`,{className:`setup-progress`,max:100,value:h,"aria-label":l(`setup.test.title`)}),R(`ul`,{className:`setup-rows`,children:[u.map(e=>R(`li`,{className:`setup-result is-${e.state}`,children:[I(yZ,{state:e.state}),R(`span`,{className:`setup-result-label`,children:[vZ(e.job,l),e.subject&&R(`bdi`,{className:`setup-result-model`,children:[` `,n[e.subject]??el(e.subject)]})]}),I(`span`,{className:`setup-result-value`,children:bZ(e,l)}),e.error&&R(`div`,{className:`setup-result-error`,children:[I(`p`,{children:_Z(e)?l(`setup.test.why.agentNative`,{name:gZ}):l(e.kind===`broken`&&!s?`setup.test.why.brokenYours`:hZ[e.kind??``]??`setup.test.why.other`)}),_Z(e)&&e.agent_error&&!e.agent_problem&&R(`p`,{className:`setup-result-error-said`,children:[l(`setup.test.agentSaid`,{name:gZ}),` `,I(`bdi`,{dir:`ltr`,children:e.agent_error})]}),R(`details`,{className:`dl-details`,children:[I(`summary`,{children:l(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:e.error})]})]})]},`${e.job}:${e.subject??``}`)),f.map(e=>e===`agent`&&S?R(`li`,{className:`setup-result is-failed`,children:[I(yZ,{state:`failed`}),I(`span`,{className:`setup-result-label`,children:vZ(e,l)}),I(`span`,{className:`setup-result-value`,children:l(`setup.test.failed`)}),I(`div`,{className:`setup-result-error`,children:I(`p`,{children:l(`setup.test.why.hub`)})})]},e):e===ne?R(`li`,{className:`setup-result is-running`,children:[I(yZ,{state:`running`}),I(`span`,{className:`setup-result-label`,children:vZ(e,l)}),I(`span`,{className:`setup-result-value`,children:l(`setup.test.starting`)})]},e):R(`li`,{className:`setup-result is-waiting`,children:[I(yZ,{state:`waiting`}),I(`span`,{className:`setup-result-label`,children:vZ(e,l)}),I(`span`,{className:`setup-result-value`,children:l(`setup.test.waiting`)})]},e))]})]}),e.state===`verifying`&&o&&I(eX,{children:I(`button`,{type:`button`,className:`btn-secondary`,onClick:o,disabled:c,children:l(`setup.progress.cancel`)})}),_&&R(`div`,{className:`setup-failure`,role:`alert`,children:[T?I(XV,{problem:T,onRetry:i,onBusy:O,nested:!0}):I(`p`,{children:e.state===`cancelled`?l(`setup.test.cancelled`):w?l(`setup.test.failedNative`,{name:gZ}):g.some(e=>e.kind===`memory`)?l(`setup.test.failedMemory`):l(`setup.test.failedHelp`)}),w&&I(`p`,{className:`setup-failure-hint`,children:l(`setup.agent.hint`)}),te&&I(`p`,{className:`setup-result-error`,children:l(`newChat.agent.switchFailed`,{error:te})}),R(eX,{children:[C&&a&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:a,disabled:c,children:l(`setup.test.chooseAnother`)}),I(`button`,{type:`button`,className:v.length||w?`btn-secondary`:`btn-primary`,onClick:i,disabled:c||E||T!==null&&D,children:l(`setup.test.tryAgain`)}),w&&!T&&R(`button`,{type:`button`,className:`btn-primary setup-wrap-btn`,onClick:()=>void A(),disabled:c||E,children:[E&&I(so,{size:13,className:`spin`,"aria-hidden":`true`}),` `,l(`setup.test.finishOnPython`)]}),v.map(e=>I(`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&&I(tX,{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:I(`p`,{children:l(`setup.redownload.body`,{name:n[y]??y,size:x==null?``:PA(x)})})})]})}var SZ=`https://app.fireworks.ai/settings/users/api-keys`,CZ=`https://amd-gaia.ai/docs/guides/llm-gateway`,wZ=[{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 TZ(e,t){return k(e.title)?t(e.title):e.title}var EZ=1e3,DZ=`gaia-setup-choice`;function OZ(){try{let e=localStorage.getItem(DZ);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 kZ(e){try{localStorage.setItem(DZ,e)}catch(e){console.warn(`[SetupScreen] could not save the provider choice; a reload will ask again`,e)}}var AZ=[`ok`,`needs_key`,`too_old`];function jZ({onChosen:e,onNothingToOffer:t,onFound:n,canInstallOwn:r=!0}){let i=L(),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)([]),[d,f]=(0,V.useState)(!1),[p,m]=(0,V.useState)(``),[h,g]=(0,V.useState)(!1),[_,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(null),[x,S]=(0,V.useState)(null),[C,T]=(0,V.useState)(null),[E,ee]=(0,V.useState)(`gaia`),D=(0,V.useRef)(!0),O=(0,V.useCallback)(async()=>{c(null);try{let e=await Je();if(!e.offer){t?.();return}f(!0);let{found:r,unchecked:i=[]}=await w();if(!D.current)return;u(r?[]:i),r&&AZ.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,V.useEffect)(()=>(D.current=!0,O(),()=>{D.current=!1}),[O]);let te=(0,V.useCallback)(async t=>{if(a){b(t),S(null);try{await Te(t===`external`?{mode:t,base_url:a.found.url,api_key:p.trim()||void 0}:{mode:t}),m(``),T(t),e(t)}catch(e){ZJ(e)&&g(!0),S(e instanceof Error?e.message:String(e))}finally{b(null)}}},[a,p,e]);if(s||l.length>0)return R(P.Fragment,{children:[I(`p`,{className:`setup-hint`,children:s?i(`setup.offer.checkFailed`):i(`setup.offer.noAnswer`,{url:l.join(`, `)})}),s&&R(`details`,{className:`dl-details`,children:[I(`summary`,{children:i(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:s})]}),R(eX,{children:[R(`button`,{type:`button`,className:`btn-secondary`,disabled:d,onClick:()=>void O(),children:[d&&I(so,{size:13,className:`spin`}),` `,i(`setup.offer.checkAgain`)]}),t&&r&&I(`button`,{type:`button`,className:`btn-primary`,disabled:d,onClick:t,children:i(`setup.offer.useOwn`)})]})]});if(!a)return d?R(`p`,{className:`setup-hint`,role:`status`,children:[I(so,{size:13,className:`spin`,"aria-hidden":`true`}),` `,i(`setup.offer.looking`)]}):null;let{target:k,found:A}=a;return C?I(`p`,{className:`setup-hint`,role:`status`,children:C===`external`?i(`setup.offer.usingYours`,{url:A.url}):i(`setup.offer.usingOwn`)}):A.status===`too_old`?R(`p`,{className:`setup-hint`,role:`status`,children:[i(`setup.offer.tooOld`),` `,R(`bdi`,{dir:`ltr`,className:`setup-choice-note`,children:[`Lemonade `,A.version??``,` · `,A.url]})]}):R(`form`,{id:`setup-lemonade-form`,className:`setup-lemonade`,"aria-label":i(`setup.offer.label`),onSubmit:e=>{e.preventDefault(),te(E)},children:[R(`fieldset`,{className:`setup-choices`,disabled:!!y,children:[I(`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=>R(`label`,{className:`setup-choice${E===e.mode?` is-active`:``}`,children:[I(`input`,{type:`radio`,name:`setup-server`,value:e.mode,checked:E===e.mode,onChange:()=>{ee(e.mode),S(null)}}),R(`span`,{children:[R(`span`,{className:`setup-choice-title`,children:[i(e.title),e.mode===`gaia`&&I(`span`,{className:`setup-choice-tag`,children:i(`setup.offer.recommended`)})]}),I(`span`,{className:`setup-choice-note`,children:i(e.note)})]})]},e.mode))]}),R(`button`,{type:`button`,className:`setup-log-toggle setup-offer-more`,onClick:()=>v(e=>!e),"aria-expanded":_,"aria-controls":`setup-offer-detail`,children:[I(di,{size:13,className:_?`is-open`:``,"aria-hidden":`true`}),` `,i(`setup.offer.whatGaiaDoes`)]}),_&&R(`div`,{id:`setup-offer-detail`,children:[I(`p`,{className:`setup-choice-note`,children:R(`bdi`,{dir:`ltr`,children:[`Lemonade`,A.version?` ${A.version}`:``,` · `,A.url]})}),I(`p`,{className:`setup-choice-note`,children:i(`setup.offer.whatGaiaDoesText`)})]}),E===`external`&&h&&I(`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&&E===`external`?I(`p`,{className:`setup-error`,role:`alert`,children:i(`setup.offer.keyRejected`)}):I(NZ,{text:x})),I(eX,{children:R(`button`,{type:`submit`,form:`setup-lemonade-form`,className:`btn-primary`,disabled:!!y||E===`external`&&h&&!p.trim(),children:[y&&I(so,{size:13,className:`spin`}),` `,i(`setup.continue`)]})})]})}function MZ({problem:e,onRetry:t,onUseGaia:n}){let r=L(),i=e.kind===`server_too_old`&&e.use_gaia;return R(P.Fragment,{children:[e.start&&R(`details`,{className:`dl-details`,children:[I(`summary`,{children:r(`setup.server.howToStart`)}),I(`pre`,{dir:`ltr`,children:e.start})]}),R(eX,{children:[I(`button`,{type:`button`,className:i?`btn-secondary`:`btn-primary`,onClick:t,children:r(`setup.tryAgain`)}),e.use_gaia&&I(`button`,{type:`button`,className:i?`btn-primary`:`btn-secondary`,onClick:n,children:r(`setup.server.useGaia`)})]}),e.use_gaia&&I(`p`,{className:`setup-hint`,children:r(`setup.server.useGaiaNote`)}),e.use_gaia&&e.env_url&&I(`p`,{className:`setup-hint`,children:r(`setup.server.envIgnoredNote`,{url:e.env_url})})]})}function NZ({text:e}){let t=L();return R(`div`,{className:`setup-error`,role:`alert`,children:[I(`p`,{children:t(`setup.failedLead`)}),R(`details`,{className:`dl-details`,children:[I(`summary`,{children:t(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:e})]})]})}function PZ({run:e}){let t=L();return e.problem?R(`div`,{className:`setup-error`,role:`alert`,children:[I(`p`,{children:t(e.problem.kind===`server_too_old`?`setup.server.tooOld`:`setup.server.unreachable`)}),R(`details`,{className:`dl-details`,children:[I(`summary`,{children:t(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:e.problem.message})]})]}):R(`div`,{className:`setup-error`,role:`alert`,children:[I(`p`,{children:t(e.components?.server===`failed`?`setup.server.ownFailed`:`setup.stopped`)}),e.error&&R(`details`,{className:`dl-details`,children:[I(`summary`,{children:t(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:e.error})]})]})}var FZ=[`check`,`plan`,`key`,`models`,`gpu`,`download`,`test`,`ready`],IZ=`gaia.setup.agentPick`,LZ=`setup-agent-title`,RZ=`gaia.setup.heldRun`,zZ=`gaia.setup.queuedExtras`;function BZ(){try{let e=localStorage.getItem(zZ),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch(e){return console.warn(`[SetupScreen] could not read the extras added during setup; they show as Add again`,e),[]}}function VZ(e){try{e.length?localStorage.setItem(zZ,JSON.stringify(e)):localStorage.removeItem(zZ)}catch(e){console.warn(`[SetupScreen] could not save the extras added during setup; a restart will forget them`,e)}}function HZ(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 UZ(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 WZ(e){return e instanceof Error?e.message:String(e)}function GZ({onReady:e,onClose:t}){let n=L(),r=Xc(e=>e.refresh),i=Xc(e=>e.select),[o,s]=(0,V.useState)(`local`),[c,l]=(0,V.useState)(`check`),[u,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)(`models`),[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)(null),[v,y]=(0,V.useState)(()=>new Set([`check`])),b=(0,V.useRef)(`check`),[x,S]=(0,V.useState)(null),[C,w]=(0,V.useState)(null),[T,E]=(0,V.useState)(null),[ee,D]=(0,V.useState)(null),[O,te]=(0,V.useState)(null),[k,A]=(0,V.useState)(``),[ne,re]=(0,V.useState)({busy:!1,error:null,done:!1}),[j,ie]=(0,V.useState)(null),[ae,oe]=(0,V.useState)(null),[se,ce]=(0,V.useState)(null),[le,ue]=(0,V.useState)(null),[M,de]=(0,V.useState)(null),[fe,N]=(0,V.useState)(null),[pe,me]=(0,V.useState)(!0),[he,ge]=(0,V.useState)(null),[_e,ve]=(0,V.useState)(!1),[ye,be]=(0,V.useState)(!1),[xe,Se]=(0,V.useState)(null),[Ce,we]=(0,V.useState)(!1),[Te,De]=(0,V.useState)(null),[Oe,Ae]=(0,V.useState)(null),[je,Me]=(0,V.useState)(null),[Ne,Pe]=(0,V.useState)(!1),[Fe,Ie]=(0,V.useState)([]),[Le,Re]=(0,V.useState)(BZ);(0,V.useEffect)(()=>VZ(Le),[Le]);let[ze,Be]=(0,V.useState)([]),[Ve,We]=(0,V.useState)(!1),[Ge,Ke]=(0,V.useState)(!1),Ye=(0,V.useRef)({gaiaLemonade:!1,options:{}}),Xe=(0,V.useRef)(null),Qe=(0,V.useRef)(!1),$e=(0,V.useRef)(!1),[et,nt]=(0,V.useState)(!1),[rt,it]=(0,V.useState)(!1),at=(0,V.useCallback)(()=>it(!0),[]),[ot,st]=(0,V.useState)(null),[ct,lt]=(0,V.useState)(null),ut=(0,V.useRef)(!0);(0,V.useEffect)(()=>(ut.current=!0,()=>{ut.current=!1}),[]);let{network:dt,providers:ft,recheck:pt}=pX(),mt=e=>ft.find(t=>t.id===e),ht=mt(o),gt=ht?.key_source===`environment`&&ht.key_hint?ht:void 0,_t=e=>!!mt(e)?.blocked,vt=dt?.reachable!==!1||o===`amd`,yt=ht?.key_source===`stored`||ht?.key_source===`lemonade`,bt=_t(`fireworks`)&&_t(`amd`),xt=e=>_t(e)||e===`amd`&&dt?.reachable===!1,St=e=>_t(e)?n(`settings.privacy.localOnlyBlocked`):n(`setup.key.gatewayOff`),Ct=o!==`local`,wt=T?.server_only?T:null,Et=T&&!T.server_only?T:null,Dt=T?.state===`running`||T?.state===`verifying`,Ot=Et?.state===`ready`,kt=DX(T),At=!(Et?.models??[]).some(e=>e.state===`downloading`||e.state===`queued`)&&((Et?.tests?.length??0)>0||Et?.state===`verifying`),jt=(0,V.useCallback)(()=>{w(null),ke().then(S).catch(e=>w(WZ(e)))},[]),Mt=(0,V.useRef)(0),Nt=(0,V.useCallback)(async()=>{let e=++Mt.current;oe(null);try{let t=await a(!1);return e===Mt.current?(ie(t),t):null}catch(t){return e===Mt.current&&oe(WZ(t)),null}},[]),Ft=(0,V.useCallback)(async()=>{try{let e=await tt();ut.current&&N(e??null)}catch(e){console.warn(`[SetupScreen] GPU memory could not be read; the step stays hidden`,e)}},[]),It=t!=null;(0,V.useEffect)(()=>{Je().then(e=>We(e.source===`config`)).catch(e=>console.warn(`[SetupScreen] could not read which Lemonade GAIA uses`,e)),jt(),Nt(),Pt().then(e=>{e.state===`idle`&&!e.models?.length||It&&e.state!==`running`&&e.state!==`verifying`||(E(e),e.server_only||l(`download`),e.skip_chat_model&&s(OZ()===`amd`?`amd`:`fireworks`))}).catch(e=>te(WZ(e))).finally(()=>nt(!0))},[jt,Nt,It]),(0,V.useEffect)(()=>{j?.catalog&&j.lemonade.reachable&&(ce(e=>e??bY(j)),Ft(),!T&&j.catalog.some(e=>e.partial&&e.selected)&&we(!0))},[j,Ft,T]);let Lt=(0,V.useCallback)(()=>{Xe.current&&clearInterval(Xe.current),Xe.current=null},[]),Rt=(T?.models??[]).filter(e=>e.state===`failed`&&e.error_kind===`disk_full`).length;(0,V.useEffect)(()=>{Rt>0&&Nt()},[Rt,Nt]);let zt=(0,V.useCallback)(async()=>{try{let e=await Pt();if(D(null),e.state===`idle`&&!e.models?.length){E(null),l(`plan`),Ke(!0),Nt();return}E(e)}catch(e){D(WZ(e))}},[Nt,n]);(0,V.useEffect)(()=>(!kt&&!ee||(Xe.current=setInterval(()=>{zt()},EZ)),Lt),[kt,ee,zt,Lt]),(0,V.useEffect)(()=>{wt&&wt.state===`ready`&&(jt(),Nt())},[wt,wt?.state,jt,Nt]),(0,V.useEffect)(()=>{Ot&&(jt(),Nt().then(e=>{e&&de(e)}),Ft())},[Ot,jt,Nt,Ft]);let Bt=(0,V.useRef)(!1),Vt=(0,V.useCallback)(async(e=!1,t={})=>{if(Bt.current)return!1;Bt.current=!0,te(null),Se(null),we(!1),Ke(!1);try{kZ(o),Ye.current={gaiaLemonade:e,options:t};let n=await Tt(Ct,e,t);E(n),_(null);let r=t.extraModels??[];return r.length&&Be(e=>e.filter(e=>!r.includes(e))),t.serverOnly||l(`download`),e&&We(!1),!0}catch(e){let t=Cn(e);if(t)return ge({kind:`server`,detail:t,then:`run`}),!1;if(e instanceof En&&e.httpStatus===409){let e=await Pt().catch(()=>null);if(e&&(e.state===`running`||e.state===`verifying`))return E(e),_(null),e.server_only||l(`download`),!0}return te(WZ(e)),!1}finally{Bt.current=!1}},[o,Ct]);(0,V.useEffect)(()=>{c===`check`&&et&&rt&&j&&!j.lemonade.reachable&&!T&&!Qe.current&&(Qe.current=!0,Vt(!1,{serverOnly:!0}))},[c,et,rt,j,T,Vt]);let Ht=!!(se&&j?.catalog&&j.lemonade.reachable&&(x||C)),Ut=(0,V.useCallback)(()=>{let{gaiaLemonade:e,options:t}=Ye.current;Vt(e,t)},[Vt]),F=(0,V.useCallback)((e,t=j)=>{ue(t);let n=t&&se&&!Ct?jY(t,se):[];return Vt(!1,{acknowledgeLowDisk:e,keepTrying:pe,extraModels:n})},[j,se,Ct,pe,Vt]),[Wt,Gt]=(0,V.useState)(!1),[Kt,qt]=(0,V.useState)(()=>HZ(IZ)),Jt=(0,V.useCallback)(e=>{qt(e),UZ(IZ,e)},[]),[Yt,Xt]=(0,V.useState)(()=>HZ(RZ)),Zt=(0,V.useCallback)(e=>{Xt(e),UZ(RZ,e)},[]),[Qt,en]=(0,V.useState)(null),[tn,nn]=(0,V.useState)(!1),rn=(0,V.useCallback)(async(e,t,n)=>{if(en(null),t){nn(!0);try{await He({flagship_agent:t})}catch(e){en(WZ(e));return}finally{nn(!1)}}Jt(null),Zt(null),await F(e.acknowledgeLowDisk,n)},[F,Jt,Zt]),an=(0,V.useRef)(Kt);an.current=Kt;let on=(0,V.useRef)(Yt);on.current=Yt;let sn=(0,V.useRef)(rn);sn.current=rn;let cn=IV(()=>{let e=an.current;e&&Jt({...e,download:!1}),e&&on.current&&sn.current(on.current,e.id)}),un=cn.start,dn=cn.follow,fn=(0,V.useCallback)(async(e,t)=>{let n=an.current;if(Zt(e),_(null),l(`download`),!n||!n.download){await rn(e,n?.id??null,t);return}en(null);let r;try{r=await Ee()}catch(e){en(WZ(e));return}r.programs.find(e=>e.id===n.id)?.installed?await rn(e,n.id,t):r.download.state===`downloading`?dn(r.download):un()},[rn,Zt,dn,un]),pn=(0,V.useCallback)(()=>{Zt(null),en(null),_(null),l(`models`)},[Zt]),mn=(0,V.useCallback)(()=>{Yt&&rn(Yt,null)},[Yt,rn]),hn=(0,V.useRef)(!1);(0,V.useEffect)(()=>{hn.current||(hn.current=!0,Ee().then(e=>{let t=e.download.state===`downloading`;if(dn(e.download),!on.current)return;if(t){l(`download`);return}Zt(null);let n=an.current;n&&e.programs.find(e=>e.id===n.id)?.installed&&Jt({...n,download:!1})}).catch(e=>console.warn(`[SetupScreen] could not read the agent programs; the Agent card says so on Customize`,e)))},[dn,Zt,Jt]);let gn=(0,V.useRef)(!1),_n=(0,V.useCallback)(async(e,t=_e)=>{if(!j||!se||gn.current)return;Se(null),Gt(e);let r=aY(j),i=Ct?[]:OY(r,se).filter(e=>!e.downloaded||e.id===se.defaultChat),a=i.find(lY);if(a){let e=a.id===se.defaultChat?`setup.models.cantRun.chat`:`setup.models.cantRun.other`;Se(n(e,{name:a.name,why:zY(a,n)}))}else if(!Ct&&!t&&i.length>0&&i.every(e=>e.need_gb!=null))ge({kind:`no_fit`,models:i});else{be(!0),gn.current=!0;try{let n=j;if(!Ct&&se.defaultChat&&se.defaultChat!==n.chat_model.id)try{n=await Ue(se.defaultChat,t,!1)}catch(e){let t=Cn(e);if(t){ge({kind:`server`,detail:t,then:`chat`});return}throw e}if(!Ct){await HX();let e=gY(r,se);e!==(n.vision_model??null)&&(n=await Ze(e,!1));for(let e of AY(n,se))n=await Bn(e.id,e.skipped,!1)}ie(n),an.current?await fn({acknowledgeLowDisk:e},n):await F(e,n)}catch(e){Se(WZ(e))}finally{gn.current=!1,be(!1)}}},[j,se,Ct,_e,F,fn,n]),vn=(0,V.useCallback)(e=>{Se(null),c===`download`?_(e===b.current?null:e):(_(null),l(e===`test`||e===`ready`?`download`:e))},[c]),yn=(0,V.useCallback)(()=>{g??s(`local`),vn(`plan`)},[vn,g]),bn=(0,V.useCallback)(()=>{Dt&&g!=null||(s(`local`),d(!0),vn(`models`))},[vn,Dt,g]),xn=(0,V.useRef)(!1),Sn=(0,V.useCallback)(()=>{xn.current=!0,bn()},[bn]),[wn,Tn]=(0,V.useState)(`local`),Dn=Xc(e=>e.active?.remote&&e.active.provider!==`local`?e.active.provider:null),On=Xc(e=>e.active?.remote?e.active.model:null),kn=(0,V.useCallback)(e=>{Dt&&g!=null||(d(!1),s(e),Tn(`cloud`),Ae(e===Dn?On:null),vn(`key`))},[vn,Dt,g,Dn,On]),An=(0,V.useCallback)(()=>kn(OZ()===`amd`?`amd`:`fireworks`),[kn]),jn=(0,V.useCallback)(()=>{Dn?kn(Dn):vn(`plan`)},[Dn,kn,vn]),Mn=!!fe?.applies,Pn=(0,V.useCallback)(()=>{vn((g??c)===`gpu`?f:`plan`)},[f,vn,g,c]),Fn=(0,V.useCallback)(e=>{p(e),vn(`gpu`)},[vn]),In=(0,V.useRef)({prev:null,next:null});(0,V.useEffect)(()=>{let e=e=>{if(!e.altKey||he||(e.target instanceof Element?e.target:null)?.closest(`input, textarea, select, [contenteditable="true"]`))return;let t=e.key===`ArrowLeft`?In.current.prev:e.key===`ArrowRight`?In.current.next:null;t&&(e.preventDefault(),vn(t))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[vn,he]);let Ln=(0,V.useCallback)(async()=>{try{await qe(),await zt()}catch(e){Se(WZ(e))}},[zt]),Rn=(0,V.useCallback)(async(e,t)=>{Se(null),be(!0);try{t===`verify`&&await $t(e),t===`disk_full`&&Nt();try{E(await Nn(e,{keepTrying:pe}))}catch(t){let n=Cn(t);if(!n)throw t;ge({kind:`server`,detail:n,then:`retry`,id:e})}}catch(e){Se(WZ(e))}finally{be(!1)}},[pe,Nt]),zn=(0,V.useCallback)(async e=>{Se(null),be(!0);try{j?.catalog?.find(t=>t.id===e)?.planned&&ie(await Bn(e,!0,!1)),E(t=>t&&{...t,models:t.models?.map(t=>t.id===e?{...t,state:`skipped`}:t)});let{options:t}=Ye.current;return Ye.current.options={...t,extraModels:t.extraModels?.filter(t=>t!==e)},ce(t=>t&&t.ticked.has(e)?SY(t,aY(j),e,!1):t),!0}catch(e){return Se(WZ(e)),!1}finally{be(!1)}},[j]),Vn=(0,V.useCallback)(async e=>{for(let t of e)if(!await zn(t))return;Be(t=>[...t,...e.filter(e=>!t.includes(e))]),Ut()},[zn,Ut]),Hn=(0,V.useCallback)(async()=>{await Ln(),Ut()},[Ln,Ut]),Un=(0,V.useCallback)(async()=>{if(!Dt){re({busy:!0,error:null,done:!1});try{await fr(o,{api_key:!Ve&&k||void 0},e=>re({busy:!0,error:null,done:!1,waiting:e}),()=>!ut.current);let{models:e}=await ln(o),t=Oe??je,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:sl(t)}):n(`setup.key.noModels`));await i(r.id),De(r.id),A(``),re({busy:!1,error:null,done:!0}),F(!1)}catch(e){re({busy:!1,error:WZ(e),done:!1})}}},[o,k,Oe,je,i,Ve,F,n,Dt]),Gn=(0,V.useCallback)(e=>{kZ(e),s(e),Ae(e===Dn?On:null),Me(null),re({busy:!1,error:null,done:!1})},[Dn,On]);(0,V.useEffect)(()=>{if(!Ot||Le.length===0||$e.current)return;let e=Le;$e.current=!0,(async()=>{let t=[];for(let n of e)try{E(await Nn(n,{keepTrying:pe}))}catch(e){t.push(n);let r=Cn(e);r?ge(e=>e??{kind:`server`,detail:r,then:`retry`,id:n}):te(WZ(e))}$e.current=!1,Re(t=>t.filter(t=>!e.includes(t))),t.length&&Be(e=>[...e,...t.filter(t=>!e.includes(t))])})()},[Ot,Le,pe]);let Kn=Ot&&Le.length===0,qn=Ct?Te:Et?.chat_model??(j&&!j.decided_after_server?j.chat_model.id:null),Jn=(0,V.useCallback)(async t=>{Se(null);try{!Ct&&qn&&await i(qn),await r()}catch(e){Se(WZ(e));return}e(t)},[qn,Ct,e,r,i]);(0,V.useEffect)(()=>{Kn&&Wn().then(e=>Ie(e.cards)).catch(e=>console.warn(`[SetupScreen] no first tasks to offer`,e))},[Kn]);let Yn=(0,V.useMemo)(()=>{let e={};for(let t of j?.catalog??[])e[t.id]=t.name;return e},[j]),Xn=T?.state===`failed`||T?.state===`cancelled`,Zn=T?.state===`failed`||!!O||!!ae||!!C||!!ee||!!xe,Qn=It?Fe:Fe.filter(e=>e.skill!==`check-in`),$n=e=>e.state===`ready`||e.state===`skipped`||e.state===`verifying`||e.state===`unchecked`,er=Et&&(Et.state===`failed`||Et.state===`cancelled`)&&(Et.models??[]).length>0&&(Et.models??[]).every($n)&&!kt,tr=e=>!!Ye.current.options.extraModels?.includes(e)||!!j?.catalog?.some(t=>t.id===e&&uY(t)),nr=Et&&Xn&&!kt&&!er&&(Et.models??[]).every(e=>$n(e)||tr(e.id))?(Et.models??[]).filter(e=>!$n(e)).map(e=>e.id):[],rr=!!Et&&Xn&&!Et.problem&&Object.values(Et.components??{}).includes(`failed`),z=aY(j),ir=se?TY(z,se):[],ar=j&&se?DY(j,se):null,B=se?z.filter(e=>se.ticked.has(e.id)&&e.downloaded).length:0,or=z.some(e=>e.downloaded),sr=Ht?B===0?or?`setup.check.ledeOthersOnPc`:`setup.check.ledeDone`:ir.length===0?`setup.check.ledeAllOnPc`:`setup.check.ledeSomeOnPc`:`setup.check.lede`,cr=z.find(e=>e.id===se?.defaultChat),lr=!!x&&!x.compatible&&x.blockers.length>0,ur=Kn?`ready`:c===`download`&&At?`test`:c;b.current=ur;let dr=g??ur;(0,V.useEffect)(()=>{y(e=>e.has(dr)?e:new Set(e).add(dr))},[dr]);let pr=(0,V.useRef)(!0);(0,V.useEffect)(()=>{if(pr.current){pr.current=!1;return}let e=document.querySelector(`.setup-scroll`);e&&(e.scrollTop=0);let t=xn.current&&dr===`models`?document.getElementById(LZ):null;xn.current=!1,t?(t.scrollIntoView({block:`start`,behavior:AH()}),t.focus({preventScroll:!0})):document.getElementById(`setup-title`)?.focus({preventScroll:!0})},[dr]);let[mr,hr]=(0,V.useState)(null);(0,V.useEffect)(()=>{if(dr!==`plan`)return;let e=!0;return Ee().then(t=>{e&&hr(t)}).catch(e=>console.warn(`[SetupScreen] could not read the agents; the plan leaves out the agent line`,e)),()=>{e=!1}},[dr]);let gr=mr?.programs.find(e=>e.id===`gaiacpp`),_r=Kt?.id??mr?.current,vr=!gr||!(gr.installed||gr.can_download)?null:_r===`gaiapy`?`setup.agent.gaiapy`:_r===`gaiacpp`?`setup.agent.gaiacpp`:null,yr=[{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`}],br=e=>e===`models`||e===`key`?`plan`:e===`gpu`?f===`check`?`check`:`plan`:e,xr=Ct?`key`:u?`models`:`plan`,Sr=yr.findIndex(e=>e.id===br(ur)),Cr=e=>e===`download`||e===`test`||e===`ready`,wr=[];if(x){let e=[j?.system?.physical_memory?`${LA(j.system.physical_memory,null)} installed`:null,x.ram_gb==null?null:`${x.ram_gb} GB the OS can use`].filter(Boolean).join(`, `),t=x.disk_free_gb==null?null:`${Math.round(x.disk_free_gb)} GB free on disk`;wr.push(`This PC: ${[x.gpu_name,x.npu_detected?`NPU`:null].filter(Boolean).join(`, `)||`no GPU reported`}`+[e,t].filter(Boolean).map(e=>`; ${e}`).join(``))}else C&&wr.push(`Couldn't read this PC: ${C}`);ot&&(wr.push(`Found your Lemonade${ot.version?` ${ot.version}`:``} at ${ot.url}`),wr.push(ct===`external`?`You chose your own Lemonade`:ct===`gaia`?`You chose GAIA's own Lemonade`:`Waiting for you to choose which Lemonade GAIA uses`)),j&&(!ot||ct)?wr.push(j.lemonade.reachable?`Model server answering at ${j.lemonade.url??`its address`}`:`No model server answering yet`):ae&&wr.push(`Couldn't read the model list: ${ae}`);let Tr=(e,t)=>t<=Sr||v.has(e)&&!Cr(e),Er=yr.map((e,t)=>({id:e.id,label:e.label,status:t<Sr?`done`:t>Sr?`pending`:ur===`ready`?`done`:T?.state===`failed`&&(ur===`download`||ur===`test`||ur===`check`)?`failed`:Dt&&(ur===`download`||ur===`test`)?`active`:`current`,shown:e.id===br(dr),onOpen:e.id!==br(dr)&&Tr(e.id,t)?()=>vn(e.id===`plan`?xr:e.id):void 0})),Dr=yr.findIndex(e=>e.id===br(dr)),Or=dr===`gpu`&&f===`check`?.5:FZ.indexOf(dr),kr=(0,V.useRef)(Or),Ar=(0,V.useRef)(`forward`);kr.current!==Or&&(Ar.current=Or>kr.current?`forward`:`back`,kr.current=Or);let jr=dr===`gpu`?f:dr===`models`||dr===`key`?`plan`:Dr>0?yr[Dr-1].id===`plan`?xr:yr[Dr-1].id:null,Mr=(dr!==`gpu`&&Dr>=0&&Dr<yr.length-1&&Tr(yr[Dr+1].id,Dr+1)?yr[Dr+1].id:null)??(g==null?dr===`check`&&Ht?`plan`:dr===`gpu`?f:null:null);In.current={prev:jr,next:Mr};let Nr=dr===`gpu`||dr===`models`||dr===`key`,Pr=g!=null&&Dt,Fr=[`server`];Ct||Fr.push(`chat`),!Ct&&se&&fY(z,se)&&Fr.push(`vision`),se&&z.some(e=>sY(e)&&se.ticked.has(e.id))&&Fr.push(`embedding`);for(let e of z)se&&uY(e)&&se.ticked.has(e.id)&&!e.downloaded&&Fr.push(e.roles[0]);Fr.push(`agent`);let Ir=cn.job,Lr=Ir?.state===`failed`,Rr=Yt?R(P.Fragment,{children:[Ir&&Ir.state!==`idle`&&Ir.state!==`done`&&R(`section`,{className:`setup-agent-download`,"aria-labelledby":`setup-agent-download-title`,children:[I(`h3`,{className:`mc-job-title`,id:`setup-agent-download-title`,children:n(`setup.agent.title`)}),I(RV,{job:Ir,name:Kt?.id??`gaiacpp`,onRetry:()=>void un(),failedNote:n(`setup.agent.carryOnNote`,{name:Kt?.current??`gaiapy`}),interrupted:cn.interrupted})]}),Qt&&I(`p`,{className:`setup-error`,role:`alert`,children:n(`setup.agent.saveFailed`,{error:Qt})}),(tn||!Ir&&!Qt)&&R(`p`,{className:`setup-hint`,role:`status`,children:[I(so,{size:13,className:`spin`,"aria-hidden":`true`}),` `,n(`setup.download.starting`)]}),j&&I(`section`,{className:`setup-card`,"aria-label":n(`setup.contents.title`),children:I(vX,{plan:j,models:ir})}),R(eX,{children:[(Lr||Qt)&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:mn,disabled:tn,children:n(`setup.agent.carryOn`,{name:Kt?.current??`gaiapy`})}),Qt&&Yt&&I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void fn(Yt),disabled:tn,children:n(`setup.tryAgain`)}),!Lr&&!Qt&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:pn,disabled:tn,children:n(`setup.progress.cancel`)})]})]}):null,zr=Ct&&ne.done&&Te?R(`p`,{className:`setup-ok setup-key-accepted`,role:`status`,children:[I(ri,{size:14,"aria-hidden":`true`}),` `,n(`setup.key.accepted`,{model:sl(Te)})]}):null,Br=(Et?.models??[]).filter(e=>e.state!==`skipped`).map(e=>e.id),Vr=Ot?(Et?.models??[]).filter(e=>e.state===`downloading`||e.state===`queued`).map(e=>e.id):[],Hr=[...new Set([...ze,...Ot?(Et?.models??[]).filter(e=>e.state===`failed`).map(e=>e.id):[]])],Ur=se&&!Ct?z.filter(e=>uY(e)&&!se.ticked.has(e.id)&&!e.downloaded&&(dY(cr)||!e.roles.includes(`image_creation`))):[],Wr=z.find(e=>e.fit_code===`memory`&&e.chat_choice&&e.support===`verified`);return R(`main`,{className:`setup`,"aria-labelledby":`setup-title`,children:[I(mZ,{steps:Er}),I($Y,{value:m,children:R(`div`,{className:`setup-pane`,children:[I(`div`,{className:`setup-scroll`,children:R(`div`,{className:`setup-inner`,children:[Dr>=0&&R(`nav`,{className:`setup-topnav`,"aria-label":n(`setup.nav.label`),children:[I(`button`,{type:`button`,className:`setup-arrow`,onClick:()=>jr&&vn(jr),disabled:!jr,"aria-label":n(`setup.nav.prev`),children:I(li,{size:16,"aria-hidden":`true`})}),I(`button`,{type:`button`,className:`setup-arrow`,onClick:()=>Mr&&vn(Mr),disabled:!Mr,"aria-label":n(`setup.nav.next`),children:I(di,{size:16,"aria-hidden":`true`})}),I(`span`,{children:I(`bdi`,{children:n(`setup.nav.stepOf`,{n:String(Dr+1),total:String(yr.length)})})}),g!=null&&g!==ur&&I(`button`,{type:`button`,className:`link-btn`,onClick:()=>_(null),children:n.compose(e=>e(`setup.nav.toLive`,{step:e(yr.find(e=>e.id===ur)?.key??`setup.download.step`)}))}),I(LX,{})]}),Ce&&c!==`download`&&R(`div`,{className:`setup-banner`,role:`status`,children:[I(Ua,{size:14,"aria-hidden":`true`}),I(`span`,{children:n(`setup.resume.banner`)})]}),Ge&&c!==`download`&&I(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.interrupted`)}),R(`div`,{className:`setup-stage is-${Ar.current}`,children:[dr===`check`&&R(P.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(Ht?`setup.check.headingDone`:`setup.check.heading`)}),I(`p`,{className:`setup-lede`,children:n(sr)}),I(pZ,{hardware:x,hardwareError:C,plan:j,serverRun:wt,awaitingChoice:!!ot&&!rt}),wt?.state===`running`&&R(P.Fragment,{children:[I(jX,{run:wt,idle:n(`setup.check.serverWorking`),bar:!1}),I(eX,{children:I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void Ln(),children:n(`setup.progress.cancel`)})})]}),Ht&&j&&I(rZ,{plan:j,hardware:x,onChangeMemory:Mn&&g==null?()=>Fn(`check`):void 0}),Ht&&g==null&&!(ot&&!rt)&&I(eX,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:jn,children:n(`setup.continue`)})}),wt&&Xn&&R(P.Fragment,{children:[I(PZ,{run:wt}),wt.problem?I(MZ,{problem:wt.problem,onRetry:()=>void Vt(!1,{serverOnly:!0}),onUseGaia:()=>void Vt(!0,{serverOnly:!0})}):I(eX,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Vt(!!wt.gaia_lemonade,{serverOnly:!0}),children:n(`setup.tryAgain`)})})]}),ae&&!j&&R(P.Fragment,{children:[I(NZ,{text:ae}),R(eX,{children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void Vt(!1,{keepTrying:pe}),children:n(`setup.models.useRecommended`)}),I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Nt(),children:n(`setup.tryAgain`)})]}),I(`p`,{className:`setup-hint`,children:n(`setup.models.useRecommendedNote`)})]}),O&&I(NZ,{text:O}),O&&!wt&&j&&!j.lemonade.reachable&&I(eX,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Vt(!1,{serverOnly:!0}),children:n(`setup.tryAgain`)})}),et&&j&&(!j.lemonade.reachable&&!wt||Ht&&g==null&&j.lemonade.mode!==`external`)&&I(jZ,{onNothingToOffer:at,canInstallOwn:!j.lemonade.reachable&&!wt,onFound:st,onChosen:e=>{We(e===`external`),lt(e),it(!0),jt(),Nt()}})]}),dr===`plan`&&j&&se&&R(P.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.plan.title`)}),I(`p`,{className:`setup-lede`,children:n(`setup.plan.lede`)}),R(`div`,{className:`setup-where`,children:[R(`section`,{className:`setup-hero setup-where-card${wn===`local`?` is-active`:``}`,"aria-label":n(`setup.plan.label`),onClick:()=>!Pr&&Tn(`local`),children:[I(`p`,{className:`setup-eyebrow`,children:se.chatChosen?n(`setup.plan.yours`):n(`setup.plan.recommended`)}),R(`p`,{className:`setup-hero-title`,children:[I(`input`,{type:`radio`,name:`setup-where`,checked:wn===`local`,onChange:()=>Tn(`local`),disabled:Pr,"aria-labelledby":`setup-where-local`}),I(`bdi`,{id:`setup-where-local`,children:n(`setup.plan.run`,{name:cr?.name??``})})]}),R(`dl`,{className:`setup-facts`,children:[R(`div`,{children:[I(`dt`,{children:n(`setup.summary.download`)}),I(`dd`,{children:I(`bdi`,{dir:`ltr`,children:PA(EY(j,se).downloadGb??0)})})]}),R(`div`,{children:[I(`dt`,{children:n(`setup.plan.runsOn`)}),I(`dd`,{children:I(`bdi`,{children:cr&&cY(cr)?n(`setup.checks.npu`):x?.gpu_name??n(`setup.plan.cpu`)})})]}),R(`div`,{children:[I(`dt`,{children:n(`setup.plan.diskAfter`)}),I(`dd`,{children:I(`bdi`,{dir:`ltr`,children:EY(j,se).afterGb==null?`—`:PA(Math.max(0,EY(j,se).afterGb))})})]})]}),R(`ul`,{className:`setup-reasons`,children:[!se.chatChosen&&I(`li`,{children:n(`setup.plan.why.evaluated`)}),!se.chatChosen&&j.left_for_apps_gb!=null&&I(`li`,{children:n(`setup.plan.why.headroom`,{left:RA(j.left_for_apps_gb)})}),cr&&(cr.fits===!1||cr.fits===!0&&cr.tight)&&I(`li`,{role:`note`,children:zY(cr,n)}),cr?.need_gb!=null&&cr.capacity_gb!=null&&cr.fits&&!cr.tight&&I(`li`,{children:n(`setup.plan.why.fits`,{need:RA(cr.need_gb),have:RA(cr.capacity_gb)})}),I(`li`,{children:n(`setup.plan.why.private`)}),cr&&cY(cr)&&I(`li`,{children:n(`setup.plan.why.noImagesNpu`)}),Wr&&Wr.id!==cr?.id&&Wr.need_gb!=null&&Wr.capacity_gb!=null&&cr?.fits!==!1&&!cr?.tight&&I(`li`,{children:n(`setup.plan.why.bigger`,{name:Wr.name,need:RA(Wr.need_gb),have:RA(Wr.capacity_gb)})})]}),vr&&R(`p`,{className:`setup-agent-line`,children:[n.compose(e=>e(`setup.plan.agent`,{name:e(vr)})),I(`span`,{"aria-hidden":`true`,children:` · `}),I(`button`,{type:`button`,className:`link-btn`,onClick:Sn,disabled:ye||Pr,"aria-label":n(`setup.plan.agentChangeAria`),children:n(`setup.plan.agentChange`)})]}),ir.length>0&&I(`p`,{className:`setup-hint`,children:n(`setup.plan.cancelAnytime`)})]}),R(`section`,{className:`setup-hero setup-where-card${wn===`cloud`?` is-active`:``}${bt?` is-disabled`:``}`,"aria-label":n(`setup.plan.cloudLabel`),onClick:()=>!Pr&&!bt&&Tn(`cloud`),children:[R(`p`,{className:`setup-hero-title`,children:[I(`input`,{type:`radio`,name:`setup-where`,checked:wn===`cloud`,onChange:()=>Tn(`cloud`),disabled:Pr||bt,"aria-labelledby":`setup-where-cloud`}),I(`span`,{id:`setup-where-cloud`,children:n(`setup.plan.cloud`)})]}),bt?I(`p`,{className:`setup-hint`,children:n(`settings.privacy.localOnlyBlocked`)}):R(`ul`,{className:`setup-reasons`,children:[I(`li`,{children:n(`setup.plan.cloudWhy.stillLocal`)}),I(`li`,{children:n(`setup.plan.cloudWhy.key`)}),I(`li`,{children:n(`setup.plan.cloudWhy.sent`)})]})]})]}),R(eX,{children:[wn!==`cloud`&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:bn,disabled:ye||Pr,children:n(`setup.plan.customize`)}),wn===`cloud`?I(`button`,{type:`button`,className:`btn-primary`,onClick:An,disabled:Pr,children:n(`setup.continue`)}):R(`button`,{type:`button`,className:`btn-primary`,onClick:()=>ar?ge({kind:`low_disk`}):void _n(!1),disabled:ye||lr||Pr,children:[ye&&I(so,{size:13,className:`spin`,"aria-hidden":`true`}),` `,ir.length?n(`setup.plan.start`):n(`setup.plan.startNoDownload`)]})]}),t&&I(`div`,{className:`setup-row`,children:I(`button`,{type:`button`,className:`link-btn`,onClick:t,children:n(`setup.backToGaia`)})}),lr&&R(`div`,{className:`setup-error`,role:`alert`,children:[I(`p`,{children:n(`setup.blocked`)}),R(`details`,{className:`dl-details`,children:[I(`summary`,{children:n(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:x?.blockers.join(`
|
|
216
|
-
`)})]})]}),ar&&I(`p`,{className:`setup-error`,role:`alert`,children:n(`setup.summary.short`,{need:PA(ar.needGb),free:PA(ar.freeGb),drive:n(`setup.summary.theDrive`),freeUp:PA(ar.freeUpGb)})}),(xe??O)&&I(NZ,{text:xe??O}),wn!==`cloud`&&R(`details`,{className:`setup-disclosure`,children:[I(`summary`,{children:n(`setup.plan.whatDownloads`)}),I(vX,{plan:j,models:ir})]})]}),dr===`gpu`&&fe&&R(P.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.gpu.title`)}),I(`p`,{className:`setup-lede`,children:n(`setup.gpu.lede`)}),I(uX,{status:fe,onStatus:N,mode:`setup`,headingId:`setup-title`,names:Yn,cloud:o!==`local`,onBack:Pn,onSkip:()=>vn(f),onContinue:()=>vn(f)})]}),dr===`models`&&R(P.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.models.title`)}),j&&se&&I(UX,{plan:j,selection:se,onSelection:ce,disabled:ye||Pr,onRecheck:()=>void Nt()}),Mn&&fe?.total_gb!=null&&fe.gpu_gb!=null&&R(`p`,{className:`setup-hint setup-gpu-option`,children:[n(`setup.models.gpu`,{gpu:PA(fe.gpu_gb),total:PA(fe.total_gb)}),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>Fn(`models`),disabled:ye||Pr,children:n(`setup.found.changeMemory`)})]}),I(JV,{disabled:ye||Pr,pending:Kt?.id??null,onPending:Jt,headingId:LZ}),I(dX,{plan:j,planError:ae,onRetryPlan:()=>void Nt(),onUseRecommended:()=>void Vt(!1,{keepTrying:pe}),selection:se,onSelection:ce,cloud:!1,keepTrying:pe,onKeepTrying:me,onBack:Pn,onContinue:e=>void _n(e),busy:ye||Pr,error:xe??O})]}),dr===`key`&&R(`form`,{id:`setup-key-form`,onSubmit:e=>{e.preventDefault(),Un()},className:`setup-form`,children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.key.title`)}),I(VV,{className:`setup-choices`,"aria-label":n(`setup.key.provider`),children:wZ.filter(e=>e.id!==`local`&&(e.id!==`amd`||vt)).map(e=>R(`button`,{type:`button`,role:`radio`,"aria-checked":o===e.id,className:`setup-choice${o===e.id?` is-active`:``}${xt(e.id)?` is-disabled`:``}`,onClick:()=>Gn(e.id),disabled:ne.busy||xt(e.id),title:_t(e.id)?n(`settings.privacy.localOnlyBlocked`):void 0,children:[I(ki,{size:16,"aria-hidden":`true`}),R(`span`,{children:[I(`span`,{className:`setup-choice-title`,children:I(`bdi`,{children:TZ(e,n)})}),I(`span`,{className:`setup-choice-note`,children:xt(e.id)?St(e.id):n(e.note)})]})]},e.id))}),dt?.reachable===!1&&vt&&I(`button`,{type:`button`,className:`link-btn setup-start`,onClick:pt,children:n(`setup.key.checkAgain`)}),_t(o)&&I(`p`,{className:`setup-a11y-alert`,role:`alert`,children:n(`settings.privacy.localOnlyBlocked`)}),o===`fireworks`&&!Ve&&!_t(o)&&R(`section`,{className:`setup-card`,children:[I(`h3`,{className:`mc-job-title`,children:n(`setup.key.getOne`)}),R(`ol`,{className:`setup-key-steps`,children:[I(`li`,{children:I(`a`,{href:SZ,target:`_blank`,rel:`noreferrer`,children:n(`setup.key.step1`)})}),I(`li`,{children:n(`setup.key.step2`)}),I(`li`,{children:n(`setup.key.step3`)})]})]}),o===`amd`&&!Ve&&!_t(o)&&I(`section`,{className:`setup-card`,children:I(`p`,{className:`setup-hint`,children:I(`a`,{href:CZ,target:`_blank`,rel:`noreferrer`,children:n(`setup.key.gatewayHelp`)})})}),!_t(o)&&I(QJ,{provider:o,limit:3,picked:Oe,onPick:Ae,onDefault:Me,pickDisabled:ne.busy||Pr}),!Ve&&R(P.Fragment,{children:[I(`label`,{className:`setup-key-label`,htmlFor:`setup-key-input`,children:n(`setup.key.labelFor`,{provider:TZ(wZ.find(e=>e.id===o)??wZ[1],n)})}),R(`div`,{className:`setup-row setup-key-row`,children:[I(`input`,{id:`setup-key-input`,className:`settings-input`,type:Ne?`text`:`password`,autoComplete:`off`,spellCheck:!1,value:k,onChange:e=>A(e.target.value),placeholder:yt?n.bare(`setup.key.placeholder`):n.bare(`setup.key.placeholderNew`)}),I(`button`,{type:`button`,className:`btn-secondary setup-key-show`,"aria-label":n(Ne?`setup.key.hide`:`setup.key.show`),title:n(Ne?`setup.key.hide`:`setup.key.show`),onClick:()=>Pe(e=>!e),children:I(Ne?$i:ta,{size:14,"aria-hidden":`true`})})]})]}),I(`p`,{className:`setup-hint`,children:n(Ve?`setup.key.usersServer`:`setup.key.where`)}),gt&&!Ve&&!k&&I(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.key.foundEnv`,{name:gt.name,hint:gt.key_hint??``})}),ne.busy&&!ne.waiting&&I(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.key.testing`)}),ne.busy&&ne.waiting&&I(`p`,{className:`setup-hint`,role:`status`,children:ne.waiting}),ne.error&&I(`p`,{className:`setup-error`,role:`alert`,children:ne.error}),R(eX,{children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:yn,disabled:ne.busy,children:n(`setup.back`)}),R(`button`,{type:`submit`,form:`setup-key-form`,className:`btn-primary`,disabled:ne.busy||xt(o)||Pr,children:[ne.busy&&I(so,{size:13,className:`spin`}),` `,n(`setup.key.connect`)]})]})]}),dr===`download`&&!Et&&R(P.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.download.title`)}),I(`p`,{className:`setup-lede`,children:n(`setup.download.lede`)}),zr,Rr??R(`p`,{className:`setup-hint`,role:`status`,children:[I(so,{size:13,className:`spin`,"aria-hidden":`true`}),` `,n(`setup.download.starting`)]})]}),dr===`download`&&Et&&R(P.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.download.title`)}),I(`p`,{className:`setup-lede`,children:n(`setup.download.lede`)}),zr,j&&I(`section`,{className:`setup-card`,"aria-label":n(`setup.contents.title`),children:I(vX,{plan:j,run:Et,onRetry:Ut,retryDisabled:ye})}),(Et.models?.length??0)>0?I(`div`,{className:ee?`is-stale`:void 0,children:I(AX,{status:{...Et,overall:MY(Et,le??j)},names:Yn,freeGb:j?.disk?.free_gb??null,onCancel:()=>void Ln(),onRetry:(e,t)=>void Rn(e,t),onResume:e=>void Rn(e,null),onResumeAll:Ut,onFinishWithout:nr.length>0&&!rr?()=>void Vn(nr):void 0,onSkip:e=>void zn(e),onRestart:()=>void Hn(),busy:ye||!!ee,retryLater:Dt,labelledBy:`setup-title`})}):Dt?R(P.Fragment,{children:[I(jX,{run:Et,plan:j,idle:n(`setup.download.working`)}),I(eX,{children:I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void Ln(),disabled:ye,children:n(`setup.progress.cancel`)})})]}):null,Ur.length>0&&R(`section`,{className:`setup-card`,"aria-label":n(`setup.optional.title`),children:[I(`h3`,{className:`mc-job-title`,children:n(`setup.optional.title`)}),I(`p`,{className:`setup-hint`,children:n(`setup.optional.lede`)}),I(`ul`,{className:`setup-rows`,children:Ur.map(e=>{let t=Le.includes(e.id)||Br.includes(e.id);return R(`li`,{className:`setup-result is-waiting`,children:[I(`span`,{className:`setup-result-label`,children:n(`setup.purpose.${e.roles[0]}`)}),R(`span`,{className:`setup-result-value`,children:[I(`bdi`,{dir:`ltr`,children:e.size_gb==null?n(`setup.contents.sizeOnDownload`):PA(e.size_gb)}),I(`button`,{type:`button`,className:`btn-secondary`,"aria-pressed":t,disabled:Br.includes(e.id),onClick:()=>Re(n=>t?n.filter(t=>t!==e.id):[...n,e.id]),children:n(t?`setup.optional.added`:`setup.optional.add`)})]})]},e.id)})})]}),ee&&R(P.Fragment,{children:[I(`p`,{className:`setup-error`,role:`alert`,children:n(`setup.lostContact`,{error:ee})}),I(eX,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void zt(),children:n(`setup.reconnect`)})})]}),Xn&&er&&!rr&&Et.state===`failed`&&!Et.model_failed&&(Et.problem?I(MZ,{problem:Et.problem,onRetry:Ut,onUseGaia:()=>void Vt(!0,Ye.current.options)}):R(`div`,{className:`setup-error`,role:`alert`,children:[I(`p`,{children:n(`setup.download.stoppedBeforeCheck`)}),Et.error&&R(`details`,{className:`dl-details`,children:[I(`summary`,{children:n(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:Et.error})]})]})),Xn&&er&&!rr&&R(P.Fragment,{children:[I(`p`,{className:`setup-hint`,children:n(`setup.download.finishNote`)}),I(eX,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:Ut,disabled:ye,children:n(`setup.finish`)})})]}),nr.length>0&&!rr&&I(`p`,{className:`setup-hint`,children:n(`setup.download.extrasLeftNote`,{names:nr.map(e=>Yn[e]??e).join(`, `)})}),Xn&&!er&&!rr&&!(Et.models??[]).some(e=>e.state===`failed`||e.state===`cancelled`)&&R(P.Fragment,{children:[I(PZ,{run:Et}),Et.problem?I(MZ,{problem:Et.problem,onRetry:Ut,onUseGaia:()=>void Vt(!0,Ye.current.options)}):I(eX,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Vt(!!Et.gaia_lemonade,Ye.current.options),children:n(`setup.tryAgain`)})})]}),(xe||O)&&I(NZ,{text:xe??O})]}),dr===`test`&&Et&&R(P.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.test.title`)}),I(`p`,{className:`setup-lede`,children:n(`setup.test.lede`)}),I(xZ,{run:Et,expected:Fr,names:Yn,catalog:z,onRetry:Ut,onChooseAnother:Ct?void 0:bn,onCancel:()=>void Ln(),onDownloadAgain:j?.lemonade.mode===`external`?void 0:e=>void Rn(e,`verify`),busy:ye}),Xn&&Et.error&&!(Et.tests??[]).some(e=>e.error===Et.error)&&R(`details`,{className:`dl-details`,children:[I(`summary`,{children:n(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:Et.error})]}),(xe||O)&&I(NZ,{text:xe??O})]}),dr===`ready`&&R(P.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.ready.heading`)}),R(`div`,{className:`setup-done`,role:`status`,children:[I(`div`,{className:`setup-done-head`,children:qn&&I(`p`,{children:n(Ct?`setup.ready.answersCloud`:`setup.ready.answersLocal`,{model:Ct?el(qn):Yn[qn]??M?.catalog?.find(e=>e.id===qn)?.name??el(qn)})})}),I(eX,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Jn(),autoFocus:!0,children:n(`setup.ready.start`)})}),!Ct&&M&&I(fX,{plan:M,chatModel:qn,gpu:fe}),O&&I(NZ,{text:O}),(Et?.tests??[]).filter(e=>e.state===`failed`).map(e=>I(`p`,{className:`setup-failed-extra`,role:`alert`,children:n(`setup.ready.extraFailed`,{job:n(`setup.test.job.${e.job}`)})},`${e.job}:${e.subject??``}`)),Vr.length>0&&I(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.ready.extraDownloading`,{names:Vr.map(e=>Yn[e]??e).join(`, `)})}),Hr.length>0&&!he&&I(`p`,{className:`setup-failed-extra`,role:`alert`,children:n(`setup.ready.extraNotFetched`,{names:Hr.map(e=>Yn[e]??e).join(`, `)})}),Qn.length>0&&R(P.Fragment,{children:[I(`p`,{className:`setup-hint`,children:n(`setup.ready.tasks`)}),I(fJ,{cards:Qn,onPick:e=>void Jn(e)})]})]})]}),T?.state===`failed`&&I(dZ,{})]},dr),t&&!Dt&&dr!==`plan`&&dr!==`ready`&&I(`div`,{className:`setup-row`,children:I(`button`,{type:`button`,className:`link-btn setup-close`,onClick:t,children:n(`setup.backToGaia`)})}),Pr&&(Nr||dr===`plan`)&&I(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.nav.runGoing`)}),I(IX,{run:T,before:{check:wr},failed:Zn})]})}),I(`div`,{className:`setup-footer`,ref:h})]})}),he?.kind===`no_fit`&&I(tX,{title:kY(he.models)?n(`setup.confirm.tightOne`,{name:he.models[0].name}):he.models.length===1?n(`setup.confirm.noFitOne`,{name:he.models[0].name}):n(`setup.confirm.noFitMany`),confirmLabel:kY(he.models)?n(`setup.confirm.useAnyway`):n(`setup.confirm.downloadAnyway`),cancelLabel:n(`setup.confirm.pickSmaller`),onConfirm:()=>{ge(null),ve(!0),_n(Wt,!0)},onCancel:()=>ge(null),children:he.models.map(e=>R(`p`,{children:[I(`bdi`,{children:e.name}),`: `,zY(e,n)]},e.id))}),he?.kind===`low_disk`&&ar&&I(tX,{title:n(`setup.confirm.lowDiskTitle`),confirmLabel:n(`setup.confirm.downloadAnyway`),cancelLabel:n(`setup.confirm.changeModels`),onConfirm:()=>{ge(null),_n(!0)},onCancel:()=>{ge(null),bn()},children:I(`p`,{children:n(`setup.summary.short`,{need:PA(ar.needGb),free:PA(ar.freeGb),drive:n(`setup.summary.theDrive`),freeUp:PA(ar.freeUpGb)})})}),he?.kind===`server`&&I(tX,{title:he.detail.code===`low_disk`?n(`setup.confirm.lowDiskTitle`):n(`setup.confirm.noFitServerTitle`),confirmLabel:he.detail.code===`low_disk`?n(`setup.confirm.downloadAnyway`):n(`setup.confirm.useAnyway`),cancelLabel:n(`setup.confirm.changeModels`),onConfirm:()=>{let e=he;if(ge(null),e.then===`chat`)ve(!0),_n(Wt,!0);else if(e.then===`retry`)Nn(e.id,{keepTrying:pe,acknowledgeLowDisk:!0}).then(t=>{E(t),Be(t=>t.filter(t=>t!==e.id))}).catch(e=>Se(WZ(e)));else{let{gaiaLemonade:e,options:t}=Ye.current;Vt(e,{...t,acknowledgeLowDisk:!0})}},onCancel:()=>{let e=he;ge(null),e.then!==`retry`&&!Ot&&bn()},children:I(`p`,{children:he.detail.message})})]})}function KZ({title:e,titleId:t,count:n,hint:r,defaultOpen:i=!1,forceOpen:a=!1,targetId:o,children:s}){let[c,l]=(0,V.useState)(i);return R(`details`,{className:`settings-disclosure`,"data-settings-target":o,open:c||a,onToggle:e=>{a||l(e.currentTarget.open)},children:[R(`summary`,{onClick:e=>{a&&e.preventDefault()},children:[I(si,{size:15,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),R(`span`,{className:`settings-disclosure-text`,children:[I(`span`,{className:`settings-disclosure-title`,id:t,tabIndex:t?-1:void 0,children:e}),r&&I(`span`,{className:`settings-disclosure-hint`,children:r})]}),n!=null&&I(`bdi`,{dir:`ltr`,className:`settings-disclosure-count`,children:n})]}),I(`div`,{className:`settings-disclosure-body`,children:s})]})}var qZ=M(Mu()?`settings.desktop.menuBar`:`settings.desktop.tray`),JZ=[{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`}],YZ=new Set([`startMinimized`]),XZ={minimizeToTray:`settings.desktop.keepRunningNoTray`};function ZZ(e){return e?.reason===`no-host`?`settings.desktop.noTray`:e?.reason===`check-failed`?`settings.desktop.noTrayCheckFailed`:null}function QZ(){let e=L(),t=window.gaiaAPI?.tray,[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(null);(0,V.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,V.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=ZZ(i);return I(KZ,{title:e(`settings.desktop.title`),children:R(`div`,{className:`settings-field`,role:`group`,"aria-labelledby":`desktop-app-label`,children:[I(`span`,{className:`settings-label`,id:`desktop-app-label`,children:e(`settings.desktop.title`)}),JZ.map(({key:t,label:r,hint:i})=>{let a=YZ.has(t)?d:null,o=d&&XZ[t]||i;return R(`div`,{children:[R(`label`,{className:`setting-row`,children:[I(`span`,{children:e(r,{tray:qZ})}),R(`span`,{className:`toggle-switch`,children:[I(`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:qZ})}),I(`span`,{className:`toggle-track`})]})]}),I(`p`,{className:`settings-hint`,id:`desktop-${t}-hint`,children:a?e(a):e(o,{tray:qZ})})]},t)}),o&&I(`p`,{className:`settings-error`,role:`alert`,children:o})]})})}function $Z({onClose:e,manualInstall:t=!1}){let n=L(),[r,i]=(0,V.useState)({kind:`loading`}),a=(0,V.useRef)(null);(0,V.useEffect)(()=>{let e=iZ();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.`})},[]),Qn(!0,e),_n(a,!0),(0,V.useEffect)(()=>{let e=a.current;e&&e.querySelector(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)?.focus()},[]),(0,V.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=iZ();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:lZ(e)})})}}function c(e){if(!e)return``;try{return new Date(e).toLocaleDateString(Fn(n),{year:`numeric`,month:`short`,day:`numeric`})}catch{return e}}return I(`div`,{className:`version-picker-overlay`,onClick:t=>{t.target===t.currentTarget&&e()},children:R(`div`,{className:`version-picker-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":n(`update.picker.title`),ref:a,children:[R(`div`,{className:`version-picker-header`,children:[I(`h3`,{children:n(`update.picker.title`)}),I(`button`,{className:`version-picker-close`,onClick:e,"aria-label":n(`update.picker.close`),type:`button`,children:`×`})]}),R(`div`,{className:`version-picker-body`,children:[r.kind===`loading`&&R(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[I(`span`,{className:`version-picker-spinner`}),n(`update.picker.loading`)]}),r.kind===`error`&&R(`div`,{className:`version-picker-error`,children:[I(`p`,{children:r.message}),I(`p`,{children:I(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:n(`update.picker.browse`)})})]}),r.kind===`list`&&I(`ul`,{className:`version-picker-list`,role:`listbox`,"aria-label":n(`update.picker.listAria`),children:r.releases.map(e=>I(`li`,{children:R(`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:[I(`span`,{className:`vp-version`,children:e.version}),I(`span`,{className:`vp-date`,children:c(e.date)}),e.isCurrent&&I(`span`,{className:`vp-badge vp-badge-current`,children:n(`update.picker.installed`)}),e.isPinned&&!e.isCurrent&&I(`span`,{className:`vp-badge vp-badge-pinned`,children:n(`update.picker.pinned`)}),!e.isCurrent&&I(`span`,{className:`vp-arrow`,"aria-hidden":`true`,children:`›`})]})},e.tag))}),r.kind===`list`&&R(`p`,{className:`version-picker-more`,children:[n(`update.picker.recent`,{n:r.releases.length}),` `,I(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:n(`update.picker.browseAll`)})]}),r.kind===`confirm`&&R(`div`,{className:`version-picker-confirm`,children:[t?I(`p`,{children:n(`update.picker.manual`,{version:r.release.version})}):R(P.Fragment,{children:[I(`p`,{children:n(`update.picker.confirm`,{version:r.release.version})}),I(`p`,{className:`vp-confirm-note`,children:n(`update.picker.confirmNote`,{version:r.release.version})})]}),R(`div`,{className:`vp-confirm-actions`,children:[I(`button`,{type:`button`,className:`vp-btn-cancel`,onClick:()=>i({kind:`list`,releases:r.releases}),children:n(`update.picker.back`)}),t?I(`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`)}):I(`button`,{type:`button`,className:`vp-btn-confirm`,onClick:()=>s(r.release),children:n(`update.picker.install`)})]})]}),r.kind===`installing`&&R(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[I(`span`,{className:`version-picker-spinner`}),n(`update.picker.starting`)]})]})]})})}var eQ=`https://github.com/amd/gaia/releases`;function tQ(e){return/^\d+\.\d+\.\d+-/.test(e??``)}function nQ(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 rQ(){let e=oZ(),t=L(),n=iZ(),[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(null),[s,c]=(0,V.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:M(e),reason:lZ(n)}))}finally{i(!1)}}}let u=e.status===`disabled`,d=r||e.status===`checking`||e.status===`downloading`,f=e.readFailed?nQ(e,t):`${t(`update.settings.running`,{version:e.currentVersion??t(`update.settings.unknownVersion`)})} ${nQ(e,t)}`,p=[`available`,`downloaded`,`error`].includes(e.status)||!!e.pinnedVersion||!!e.installFailed||!!e.configError||!!e.readFailed||!!a;return I(KZ,{title:t(`update.settings.title`),titleId:`updates-label`,hint:f,forceOpen:p,children:R(`div`,{className:`settings-field`,role:`group`,"aria-labelledby":`updates-label`,children:[I(`p`,{className:`visually-hidden`,role:`status`,children:f}),!e.manualInstall&&R(P.Fragment,{children:[R(`label`,{className:`setting-row`,children:[I(`span`,{children:t(`update.settings.auto`)}),R(`span`,{className:`toggle-switch`,children:[I(`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))}}),I(`span`,{className:`toggle-track`})]})]}),I(`p`,{className:`settings-hint`,id:`updates-auto-hint`,children:t(`update.settings.autoHint`)})]}),R(`label`,{className:`setting-row`,children:[I(`span`,{children:t(`update.settings.rc`)}),R(`span`,{className:`toggle-switch`,children:[I(`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))}}),I(`span`,{className:`toggle-track`})]})]}),R(`p`,{className:`settings-hint`,id:`updates-rc-hint`,children:[t(`update.settings.rcHint`),tQ(e.currentVersion)&&` ${t(`update.settings.rcHintRunning`)}`]}),e.pinnedVersion&&R(`p`,{className:`settings-hint`,children:[t(`update.settings.pinned`,{version:e.pinnedVersion}),` `,I(`button`,{type:`button`,className:`btn-secondary`,disabled:r,onClick:()=>void l(`update.action.resume`,e=>e.resumeUpdates()),children:t(`update.settings.unpin`)})]}),R(`div`,{className:`setting-actions`,children:[e.status===`available`&&e.manualInstall&&I(`a`,{className:`btn-primary update-download-link`,href:e.downloadUrl??eQ,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&&I(`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`&&I(`button`,{type:`button`,className:`btn-primary`,disabled:r,onClick:()=>void l(`update.action.restart`,e=>e.restart()),children:t(`update.settings.restart`)}),e.readFailed?I(`button`,{type:`button`,className:`btn-secondary`,disabled:r,onClick:async()=>{i(!0);try{await e.reload()}finally{i(!1)}},children:t(`update.settings.retryRead`)}):I(`button`,{type:`button`,className:`btn-secondary`,disabled:d||u,onClick:()=>void l(`update.action.check`,e=>e.check()),children:t(`update.settings.check`)}),I(`button`,{type:`button`,className:`btn-secondary`,disabled:d||u,onClick:()=>c(!0),children:t(`update.settings.pick`)}),e.previousVersion&&I(`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&&I(`p`,{className:`settings-hint`,id:`updates-manual-hint`,children:t(`update.settings.manualHint`)}),e.previousVersion&&I(`p`,{className:`settings-hint`,id:`updates-back-hint`,children:t(`update.settings.goBackHint`)}),e.installFailed&&I(`p`,{className:`settings-error`,role:`alert`,children:t(`update.settings.installFailed`,{...e.installFailed,url:eQ})}),e.lastCheckError&&I(`p`,{className:`settings-hint`,children:t(`update.settings.lastCheckError`,{reason:e.lastCheckError})}),e.configError&&I(`p`,{className:`settings-error`,role:`alert`,children:e.configError}),a&&I(`p`,{className:`settings-error`,role:`alert`,children:a}),s&&I($Z,{onClose:()=>c(!1),manualInstall:e.manualInstall})]})})}var iQ=[{value:`light`,label:`settings.theme.light`},{value:`dark`,label:`settings.theme.dark`},{value:`system`,label:`settings.theme.system`}],aQ={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 oQ(){let e=L(),t=B(e=>e.locale),n=B(e=>e.setLocale),i=B(e=>e.themePreference),a=B(e=>e.setThemePreference),o=B(e=>e.palette),s=B(e=>e.setPalette),c=B(e=>e.customColors),l=B(e=>e.setCustomColors),u=SK(e=>e.visible),d=SK(e=>e.setVisible),f=e=>t=>l({...c,[e]:t.target.value.toUpperCase()});return R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.general`)}),R(`div`,{className:`settings-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`ui-language`,children:e(`settings.language`)}),I(`select`,{id:`ui-language`,className:`settings-input`,value:t,onChange:e=>n(e.target.value),children:je.map(({meta:e})=>I(`option`,{value:e.code,lang:e.code,dir:e.dir,children:Ye(e)},e.code))}),I(`span`,{className:`settings-hint`,children:e(`settings.languageHint`)})]}),R(`div`,{className:`settings-field`,children:[I(`span`,{className:`settings-label`,id:`appearance-label`,children:e(`settings.appearance`)}),I(VV,{className:`segmented`,"aria-labelledby":`appearance-label`,children:iQ.map(t=>I(`button`,{type:`button`,role:`radio`,"aria-checked":i===t.value,className:i===t.value?`is-active`:``,onClick:()=>a(t.value),children:e(t.label)},t.value))})]}),R(`div`,{className:`settings-field`,children:[R(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`resources.settings`)}),R(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked),"aria-label":e(`resources.settings`),"aria-describedby":`resources-hint`}),I(`span`,{className:`toggle-track`})]})]}),I(`span`,{className:`settings-hint`,id:`resources-hint`,children:e(`resources.settingsHint`)})]}),R(KZ,{title:e(`settings.colors`),titleId:`palette-label`,defaultOpen:o===`custom`,children:[R(VV,{className:`palette-grid`,"aria-labelledby":`palette-label`,children:[r.map(t=>R(`button`,{type:`button`,role:`radio`,"aria-checked":o===t.id,className:`palette-tile${o===t.id?` is-active`:``}`,onClick:()=>s(t.id),children:[I(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:t.swatch.map(e=>I(`i`,{style:{background:e}},e))}),e(aQ[t.id])]},t.id)),R(`button`,{type:`button`,role:`radio`,"aria-checked":o===`custom`,className:`palette-tile${o===`custom`?` is-active`:``}`,onClick:()=>s(`custom`),children:[R(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:[I(`i`,{style:{background:c.base}}),I(`i`,{style:{background:c.accent}})]}),e(`settings.colors.custom`)]})]}),o===`custom`&&R(`div`,{className:`palette-custom`,children:[R(`label`,{className:`palette-color`,htmlFor:`custom-accent`,children:[I(`input`,{id:`custom-accent`,type:`color`,value:c.accent,onChange:f(`accent`)}),R(`span`,{children:[e(`settings.colors.accent`),I(`small`,{children:e(`settings.colors.accentHint`)})]})]}),R(`label`,{className:`palette-color`,htmlFor:`custom-base`,children:[I(`input`,{id:`custom-base`,type:`color`,value:c.base,onChange:f(`base`)}),R(`span`,{children:[e(`settings.colors.base`),I(`small`,{children:e(`settings.colors.baseHint`)})]})]}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>l(De),children:e(`settings.colors.reset`)}),I(`p`,{className:`settings-hint`,children:e(`settings.colors.hint`)})]})]}),I(QZ,{}),I(rQ,{}),I(KZ,{title:e(`settings.shortcuts`),children:I(`dl`,{className:`shortcut-list`,children:YJ().map(({label:t,keys:n})=>R(`div`,{className:`shortcut-row`,children:[I(`dt`,{children:I(`kbd`,{children:Iu(n)})}),I(`dd`,{children:e(t)})]},t))})})]})}function sQ(e){return/not reachable|not answering|model server at|ConnectionPool|NewConnectionError|Connection refused|Max retries/i.test(e)}function cQ(e){return/gaia init/i.test(e??``)}var lQ=`GAIA doesn't run this model server, so it can't start it. Start it the way you usually do.`,uQ=/^The model server GAIA uses is at (\S+)\. (.*)$/s;function dQ(e,t){if(!t)return null;if(t===lQ)return e(`server.otherServerStart`);let n=uQ.exec(t);return n&&n[2]===lQ?`${e(`server.chosenServerAt`,{address:n[1]})} ${e(`server.otherServerStart`)}`:t}function fQ(e){return!!e&&!e.lemonade_running&&(cQ(e.start_command)||cQ(e.start_instruction))}function pQ({className:e=`btn-secondary`}){let t=L();return I(`button`,{type:`button`,className:e,onClick:()=>window.dispatchEvent(new CustomEvent(`gaia:set-up-local`)),children:t(`settings.errors.setUpLocal`)})}function mQ({message:e,onRetry:t}){let n=L(),r=B(e=>fQ(e.systemStatus));return sQ(e)?R(`div`,{className:`settings-notice`,role:`alert`,children:[I(`strong`,{children:n(r?`settings.errors.notInstalledTitle`:`settings.errors.serverDownTitle`)}),I(`p`,{children:n(r?`settings.errors.notInstalled`:`settings.errors.serverDown`)}),r&&I(pQ,{className:`btn-primary`}),t&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:t,children:n(`settings.key.checkAgain`)}),R(`details`,{className:`settings-more`,children:[R(`summary`,{children:[I(si,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,n(`settings.errors.details`)]}),I(`bdi`,{dir:`ltr`,className:`settings-notice-raw`,children:e})]})]}):I(`p`,{className:`settings-error`,role:`alert`,children:e})}function hQ({onAdded:e}){let t=L(),[n,r]=(0,V.useState)(``),[i,a]=(0,V.useState)(``),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(null),f=(0,V.useRef)(``),p=(0,V.useCallback)(async e=>{let t=n.trim();f.current=t,l(`check`),d(null);try{let n=await nr(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,V.useCallback)(async()=>{l(`add`),d(null);try{let{report:o}=await Zn(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 R(`form`,{className:`settings-field custom-model-add`,onSubmit:e=>{e.preventDefault(),p(``)},children:[I(`label`,{className:`visually-hidden`,htmlFor:`custom-model-url`,children:t(`settings.custom.title`)}),I(`span`,{className:`settings-hint`,children:t(`settings.custom.hint`)}),R(`div`,{className:`settings-row`,children:[I(`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`}),R(`button`,{type:`submit`,className:`btn-secondary`,disabled:c!==null||!n.trim(),children:[c===`check`?I(so,{size:13,className:`spin`}):null,` `,t(`settings.custom.check`)]})]}),o&&(()=>{let e=I(`ul`,{className:`custom-model-checks`,"aria-label":t(`settings.custom.checks`),children:o.checks.map(e=>R(`li`,{className:e.ok?`is-ok`:`is-failed`,children:[e.ok?I(ri,{size:13,"aria-label":t(`settings.custom.passed`)}):I(fc,{size:13,"aria-label":t(`settings.custom.failed`)}),R(`bdi`,{children:[I(`strong`,{children:e.label}),` — `,e.detail]})]},e.id))});return o.ok?R(`details`,{className:`custom-model-checks-summary`,children:[R(`summary`,{children:[I(ri,{size:13,"aria-hidden":`true`}),` `,t(`settings.custom.allPassed`,{n:o.checks.length})]}),e]}):e})(),o&&o.warnings.length>0&&I(`ul`,{className:`custom-model-checks`,"aria-label":t(`settings.custom.warnings`),children:o.warnings.map(e=>R(`li`,{className:`is-warning`,children:[I(ec,{size:13,"aria-label":t(`settings.custom.warning`)}),` `,I(`bdi`,{children:e})]},e))}),o&&o.variants.length>1&&R(`div`,{className:`settings-row`,children:[I(`label`,{className:`settings-hint`,htmlFor:`custom-model-quant`,children:t(`settings.custom.quantization`)}),I(`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=>R(`option`,{value:e.file,children:[e.quant,` · `,e.size_gb,` GB`,e.fits?``:` · ${t.bare(`settings.custom.tooLarge`)}`]},e.file))})]}),o?.ok&&R(`div`,{className:`settings-row`,children:[R(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void m(),disabled:c!==null,children:[c===`add`?I(so,{size:13,className:`spin`}):null,` `,t(`settings.custom.add`,{name:o.display_name??``})]}),I(`span`,{className:`settings-hint`,children:t(`settings.model.sizeDownload`,{size:`${o.size_gb} GB`})})]}),u&&I(mQ,{message:u})]})}function gQ(e){return e instanceof Error?e.message:String(e)}function _Q(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function vQ({downloadsSlot:e}){let t=L(),[n,r]=(0,V.useState)(null),[i,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(null),[d,f]=(0,V.useState)(!1),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(!1),[_,v]=(0,V.useState)(null),[y,b]=(0,V.useState)(null),x=Fl(e=>e.status),S=Fl(e=>e.started),C=(0,V.useMemo)(()=>Ml(x,S),[x,S]),w=Fl(e=>e.error),T=Fl(e=>e.refresh),E=Fl(e=>e.enqueue),ee=Fl(e=>e.cancel),D=(0,V.useCallback)(async(e=!1)=>{o(null);try{let t=await a();r(t),c(n=>e||!n?bY(t):n)}catch(e){o(gQ(e))}},[]);(0,V.useEffect)(()=>{D(!0),T(),(async()=>{try{v(await tt()??null)}catch(e){b(gQ(e))}})()},[D,T]);let O=(C?.models??[]).filter(e=>e.state===`ready`).map(e=>e.id).join(`,`),te=(0,V.useRef)(O);(0,V.useEffect)(()=>{O!==te.current&&(te.current=O,D(!0))},[O,D]);let k=(0,V.useMemo)(()=>{let e={};for(let t of C?.models??[])e[t.id]=t;return e},[C]),A=(0,V.useMemo)(()=>{let e={};for(let t of n?.catalog??[])e[t.id]=t.name;return e},[n]),ne=(0,V.useMemo)(()=>n?bY(n):null,[n]),re=aY(n),j=n&&s?TY(re,s).filter(e=>k[e.id]?.state!==`downloading`):[],ie=j.reduce((e,t)=>e+(t.size_gb??0),0),ae=!!n&&!!s&&!!ne&&(!_Q(s.ticked,ne.ticked)||s.defaultChat!==ne.defaultChat||j.length>0),oe=(0,V.useCallback)(async(e,i)=>{if(!n||!s)return;if(m(null),!e){let e=OY(re,s).filter(e=>!e.downloaded||e.id===s.defaultChat);if(e.length>0&&e.every(e=>e.need_gb!=null)){u({kind:`no_fit`,models:e});return}}let a=DY(n,s);if(a&&!i)u({kind:`low_disk`,message:a.drop?t(`setup.summary.shortDrop`,{need:PA(a.needGb),free:PA(a.freeGb),drive:UY(n.disk?.path??null)??t(`setup.summary.theDrive`),freeUp:PA(a.freeUpGb),name:a.drop.name,saves:PA(a.drop.size_gb??0)}):t(`setup.summary.short`,{need:PA(a.needGb),free:PA(a.freeGb),drive:UY(n.disk?.path??null)??t(`setup.summary.theDrive`),freeUp:PA(a.freeUpGb)})});else{f(!0);try{let i=n,a=!1;if(s.defaultChat&&s.defaultChat!==i.chat_model.id){a=!0;try{i=await Ue(s.defaultChat,e||h)}catch(e){let t=Cn(e);if(t){u({kind:`server`,detail:t});return}throw e}}for(let e of AY(i,s))i=await Bn(e.id,e.skipped);let o=TY(aY(i),s).map(e=>e.id).filter(e=>k[e]?.state!==`downloading`);r(i),c({...s,defaultChat:i.chat_model.id});let l=null;if(a&&i.chat_model.downloaded)try{await Xc.getState().select(i.chat_model.id)}catch(e){l=gQ(e),Xc.getState().refresh()}else Xc.getState().refresh();o.length&&await E(o,{acknowledgeLowDisk:!0}),m(l===null?{ok:!0,text:t(`settings.models.applied`)}:{ok:!1,text:t(`settings.models.appliedNotSwitched`,{reason:l})})}catch(e){m({ok:!1,text:gQ(e)})}finally{f(!1)}}},[n,s,re,h,k,E,t]),se=(0,V.useCallback)(async e=>{u(null),f(!0),m(null);try{let n=await $t(e.id);jc(),r(n),c(bY(n)),m({ok:!0,text:t(`settings.models.removed`,{name:e.name,size:PA(n.freed_gb)})})}catch(e){m({ok:!1,text:gQ(e)})}finally{f(!1)}},[t]),ce=(0,V.useCallback)((e,t)=>{(async()=>{try{t===`verify`&&await $t(e),await E([e])}catch(e){m({ok:!1,text:gQ(e)})}})()},[E]),le=!!C&&(C.models?.length??0)>0&&(DX(C)||C.models.some(e=>e.state!==`skipped`))&&C&&R(`section`,{className:`settings-field models-pane-section`,"aria-labelledby":`settings-downloads-title`,children:[I(`span`,{className:`settings-label`,id:`settings-downloads-title`,children:t(`settings.models.downloads`)}),I(AX,{status:C,names:A,freeGb:n?.disk?.free_gb??null,onCancel:()=>void ee(),onRetry:ce,onResume:e=>void E([e]),onResumeAll:()=>void E((C.models??[]).filter(e=>e.state===`cancelled`).map(e=>e.id))}),w&&I(`p`,{className:`settings-error`,role:`alert`,children:w})]});return R(P.Fragment,{children:[I(KZ,{title:t(`settings.models.manage`),hint:t(`settings.models.manageHint`),forceOpen:!!i||p?.ok===!1,children:R(`section`,{className:`settings-field models-pane-section`,"aria-labelledby":`settings-models-title`,children:[I(`span`,{className:`visually-hidden`,id:`settings-models-title`,children:t(`settings.models.title`)}),I(`p`,{className:`settings-hint`,children:t(`settings.models.lede`)}),i&&I(mQ,{message:i}),n&&!n.lemonade.reachable&&I(`p`,{className:`settings-hint`,children:t(`settings.models.unavailable`)}),!n&&!i&&R(`p`,{className:`settings-hint`,children:[I(so,{size:13,className:`spin`,"aria-hidden":`true`}),` `,t(`setup.models.loading`)]}),n&&n.lemonade.reachable&&s&&R(P.Fragment,{children:[I(GY,{plan:n,selection:s,onToggle:(e,t)=>c(SY(s,re,e,t)),onDefaultChat:e=>c(CY(s,re,e)),labelledBy:`settings-models-title`,place:`settings`,disabled:d,progress:k,rowActions:e=>e.downloaded&&e.id!==s.defaultChat?I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>u({kind:`remove`,entry:e}),disabled:d||k[e.id]?.state===`downloading`,"aria-label":t(`settings.models.removeAria`,{name:e.name}),children:t(`settings.models.remove`)}):null}),I(HY,{plan:n,selection:s}),I(`div`,{className:`models-apply`,children:R(`button`,{type:`button`,className:`btn-primary`,disabled:!ae||d,onClick:()=>void oe(!1,!1),children:[d&&I(so,{size:13,className:`spin`,"aria-hidden":`true`}),d?t(`settings.models.applying`):j.length>0?t(`settings.models.applyDownload`,{size:PA(Math.round(ie*10)/10)}):t(`settings.models.apply`)]})})]}),p?.ok&&I(`p`,{className:`settings-ok`,role:`status`,children:p.text}),p&&!p.ok&&I(mQ,{message:p.text})]})}),(_?.applies||y&&!sQ(y))&&I(KZ,{title:t(`gpu.settingsTitle`),titleId:`settings-gpu-title`,defaultOpen:!!_?.pending||!!y,children:R(`section`,{className:`settings-field models-pane-section`,"aria-labelledby":`settings-gpu-title`,children:[y&&I(`p`,{className:`settings-error`,role:`alert`,children:y}),_?.applies&&I(uX,{status:_,onStatus:v,mode:`settings`,names:A,headingId:`settings-gpu-title`})]})}),e?(0,dy.createPortal)(le,e):e===void 0&&le,l?.kind===`remove`&&I(tX,{title:t(`settings.models.removeTitle`,{name:l.entry.name}),confirmLabel:t(`settings.models.removeConfirm`),cancelLabel:t(`settings.models.keep`),danger:!0,onConfirm:()=>void se(l.entry),onCancel:()=>u(null),children:I(`p`,{children:oY(l.entry)?t(`settings.models.removeVision`,{size:PA(l.entry.full_size_gb??0)}):t(`settings.models.removeBody`,{size:PA(l.entry.full_size_gb??0)})})}),l?.kind===`no_fit`&&I(tX,{title:kY(l.models)?t(`setup.confirm.tightOne`,{name:l.models[0].name}):l.models.length===1?t(`setup.confirm.noFitOne`,{name:l.models[0].name}):t(`setup.confirm.noFitMany`),confirmLabel:kY(l.models)?t(`setup.confirm.useAnyway`):t(`setup.confirm.downloadAnyway`),cancelLabel:t(`setup.confirm.pickSmaller`),onConfirm:()=>{u(null),g(!0),oe(!0,!1)},onCancel:()=>u(null),children:l.models.map(e=>R(`p`,{children:[I(`bdi`,{children:e.name}),`: `,zY(e,t)]},e.id))}),l?.kind===`low_disk`&&I(tX,{title:t(`setup.confirm.lowDiskTitle`),confirmLabel:t(`setup.confirm.downloadAnyway`),cancelLabel:t(`setup.confirm.changeModels`),onConfirm:()=>{u(null),oe(!0,!0)},onCancel:()=>u(null),children:I(`p`,{children:l.message})}),l?.kind===`server`&&I(tX,{title:t(`setup.confirm.noFitServerTitle`),confirmLabel:t(`setup.confirm.useAnyway`),cancelLabel:t(`setup.confirm.changeModels`),onConfirm:()=>{u(null),g(!0),oe(!0,!1)},onCancel:()=>u(null),children:I(`p`,{children:l.detail.message})})]})}var yQ=`auto`;function bQ({model:e}){let t=L(),[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(null);(0,V.useEffect)(()=>{r(null),a(null),l(null),me(e).then(r).catch(e=>a(e instanceof Error?e.message:String(e)))},[e]);let u=(0,V.useCallback)(async n=>{s(!0),a(null),l(null);try{let i=await ye(e,n===yQ?null:Number(n));r(i);let a={name:i.display_name,size:i.chosen?pl(i.chosen):M(`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 sQ(i)?I(`p`,{className:`settings-hint`,children:t(`settings.ctx.serverDown`)}):I(`p`,{className:`settings-error`,role:`alert`,children:i});if(!n)return R(`p`,{className:`settings-hint`,children:[I(so,{size:13,className:`spin`}),` `,t(`settings.ctx.checking`)]});let d=n.chosen==null?yQ:String(n.chosen),f=n.chosen!=null&&n.loaded_ctx!=null&&n.loaded_ctx!==n.chosen;return R(P.Fragment,{children:[R(`div`,{className:`model-in-use-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`ctx-size`,children:t(`settings.ctx.label`)}),R(`select`,{id:`ctx-size`,className:`settings-input`,value:d,onChange:e=>void u(e.target.value),disabled:o||n.options.length===0,children:[I(`option`,{value:yQ,children:n.automatic?t.bare(`settings.ctx.automaticAt`,{size:pl(n.automatic)}):t.bare(`settings.ctx.automatic`)}),n.options.map(e=>I(`option`,{value:String(e),children:t.bare(`settings.ctx.tokens`,{size:pl(e)})},e))]})]}),n.note&&I(`span`,{className:`settings-hint`,children:I(`bdi`,{children:n.note})}),!n.note&&!!n.max_fit&&R(`details`,{className:`settings-more`,children:[R(`summary`,{children:[I(si,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,t(`settings.ctx.about`)]}),I(`span`,{className:`settings-hint`,children:t(`settings.ctx.explain`,{size:pl(n.max_fit),name:n.display_name,memory:n.memory_source})})]}),f&&I(`span`,{className:`settings-hint`,children:t(`settings.ctx.loadedAt`,{size:pl(n.loaded_ctx)})}),o&&R(`span`,{className:`settings-hint`,children:[I(so,{size:13,className:`spin`}),` `,t(`settings.ctx.applying`)]}),c&&I(`p`,{className:`settings-ok`,role:`status`,children:c}),i&&I(`p`,{className:`settings-error`,role:`alert`,children:i})]})}function xQ({row:e,providerName:t,choices:n,labels:r,disabled:i,onSwitch:a}){let o=L(),s=Xc(e=>e.active),c=Xc(e=>e.error),l=s?.model??null,u=!!s?.remote,d=n.some(e=>$c(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 R(`section`,{className:`settings-card model-in-use`,"aria-label":o(`settings.model.inUseTitle`),children:[I(`span`,{className:`model-in-use-label`,children:o(`settings.model.inUseTitle`)}),l?I(`bdi`,{className:`model-in-use-name`,title:l,children:e?.display_name||s?.display_name||el(l)}):s||c?I(`span`,{className:`settings-hint`,children:o(`settings.model.noneInUse`)}):I(`span`,{className:`settings-hint`,children:o(`settings.loading`)}),s?.config_error&&I(`p`,{className:`settings-error`,role:`alert`,children:I(`bdi`,{children:s.config_error})}),l&&!u&&e?.available===!1&&I(`p`,{className:`settings-error`,role:`alert`,children:o(`settings.model.inUseCantRun`)}),l&&R(`span`,{className:`model-chips`,children:[u&&I(`span`,{className:`model-badge is-device`,children:o(`settings.model.cloud`)}),u&&t&&I(`bdi`,{className:`model-badge is-ready`,children:t}),m&&I(`span`,{className:`model-badge is-device`,children:m.toUpperCase()}),p&&I(`span`,{className:`model-badge ${e?.state===`loaded`?`is-loaded`:`is-ready`}`,children:p}),e?.fits===!0&&I(`span`,{className:`model-badge is-fit`,children:o(`settings.model.fits`)}),!!e?.size_gb&&R(`bdi`,{dir:`ltr`,className:`model-badge is-size`,children:[e.size_gb,` GB`]}),u&&!!e?.context_length&&I(`span`,{className:`model-badge is-ready`,children:o(`settings.model.contextChip`,{size:pl(e.context_length)})})]}),(n.length>1||n.length===1&&!d)&&R(`div`,{className:`model-in-use-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`model-switch`,children:o(`settings.model.switch`)}),R(`select`,{id:`model-switch`,className:`settings-input`,value:d?n.find(e=>$c(l,e.id))?.id:``,onChange:e=>a(e.target.value),disabled:i,children:[!d&&I(`option`,{value:``,disabled:!0,children:o.bare(`settings.model.switchPlaceholder`)}),n.map(e=>I(`option`,{value:e.id,children:r[e.id]},e.id))]})]}),l&&!u&&s?.downloaded!==!1&&I(bQ,{model:l})]})}var SQ=e=>new Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:0}).format(e),CQ=/^(\d+\/\d+) tasks · quality ([\d.]+\/5) · (\$[\d.]+) per (\d+)-task run$/;function wQ(e,t){let n=CQ.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 TQ({model:e,label:t,current:n,remote:r,busy:i,onUse:a,onDownload:o,onAskRemove:s,onNpuRecheck:c}){let l=L(),u=gl(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:SQ(e.context_length)}):null].filter(Boolean).join(` · `)),p=!!(e.display_name||f||e.evidence||e.custom&&e.source_url);return R(`li`,{className:`model-row${n?` is-current`:``}`,children:[R(`div`,{className:`model-row-text`,children:[I(`bdi`,{className:`model-row-name`,title:e.id,children:t}),R(`div`,{className:`model-chips`,children:[e.placement?.device&&I(`span`,{className:`model-badge is-device`,children:e.placement.device.toUpperCase()}),e.rank&&R(`span`,{className:`model-badge is-rank`,children:[R(`bdi`,{dir:`ltr`,children:[`#`,e.rank]}),` `,e.note&&(dl[e.note]?l(dl[e.note]):I(`bdi`,{children:e.note}))]}),e.state===`loaded`&&I(`span`,{className:`model-badge is-loaded`,children:l(`settings.model.loaded`)}),e.fits===!0&&e.available!==!1&&!e.tight&&I(`span`,{className:`model-badge is-fit`,children:l(`settings.model.fits`)}),e.fits===!0&&e.available!==!1&&e.tight&&I(`span`,{className:`model-badge is-tight`,title:l(`setup.models.warn.tight`),children:l(`settings.model.tight`)}),!r&&I(eB,{support:e.support}),e.custom&&I(`span`,{className:`model-badge is-custom`,children:l(`settings.model.custom`)}),!!e.size_gb&&R(`bdi`,{dir:`ltr`,className:`model-badge is-size`,children:[e.size_gb,` GB`]}),p&&R(`details`,{className:`settings-more model-row-facts`,children:[R(`summary`,{children:[I(si,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,l(`settings.model.details`)]}),e.display_name&&I(`span`,{className:`model-row-meta`,children:I(`bdi`,{children:e.id})}),f&&I(`span`,{className:`model-row-meta`,children:f}),e.evidence&&I(`span`,{className:`model-row-meta`,children:wQ(l,e.evidence)}),e.custom&&e.source_url&&I(`span`,{className:`model-row-meta`,children:l(`settings.model.from`,{url:e.source_url})})]})]}),r&&I(`span`,{className:`model-row-meta${e.price?``:` is-unknown-price`}`,children:nB(e.price,l)}),e.placement?.warning&&I(`span`,{className:`model-row-meta is-warning`,role:`alert`,children:I(`bdi`,{children:e.placement.warning})}),e.npu_problems?.length?I(VX,{problems:e.npu_problems,disabled:i!==null,onRecheck:c,id:`npu-problems-${e.id}`}):e.unavailable_reason&&I(`span`,{className:`model-row-meta`,children:l(`settings.model.cantRun`,{reason:e.unavailable_reason})}),u&&I(`progress`,{max:100,value:u.percent,"aria-label":l(`settings.model.downloadingAria`,{name:t})})]}),R(`div`,{className:`model-row-actions`,children:[e.custom&&!n&&!u&&R(`button`,{type:`button`,className:`btn-secondary`,onClick:s,disabled:i!==null,"aria-label":l(`settings.models.removeAria`,{name:t}),children:[i===`rm:${e.id}`?I(so,{size:13,className:`spin`}):null,l(`settings.models.remove`)]}),n&&e.available===!1?I(`span`,{className:`model-row-current is-blocked`,children:l(`settings.model.inUseBlocked`)}):n?R(`span`,{className:`model-row-current`,children:[I(ri,{size:13,"aria-hidden":`true`}),` `,l(`settings.model.inUse`)]}):e.available===!1?null:u?R(`span`,{className:`model-row-current`,children:[I(so,{size:13,className:`spin`}),` `,u.message?I(`bdi`,{children:u.message}):R(`bdi`,{dir:`ltr`,children:[Math.round(u.percent),`%`]})]}):e.downloaded?R(`button`,{type:`button`,className:`btn-secondary`,onClick:a,disabled:i!==null,"aria-label":l(`settings.model.useAria`,{name:t}),children:[i===e.id?I(so,{size:13,className:`spin`}):null,` `,l(`settings.model.use`)]}):R(`button`,{type:`button`,className:`btn-secondary`,onClick:o,disabled:i!==null,"aria-label":l(`settings.model.downloadAria`,{name:t}),children:[i===`dl:${e.id}`?I(so,{size:13,className:`spin`}):null,` `,l(`settings.model.download`)]})]})]})}function EQ(){let e=L(),[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(``),[s,c]=(0,V.useState)(!1),l=(0,V.useCallback)(async e=>{c(!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{c(!1)}},[]);if((0,V.useEffect)(()=>{l(Ae)},[l]),!t)return r?I(`p`,{className:`settings-error`,role:`alert`,children:r}):R(`p`,{className:`settings-hint`,children:[I(so,{size:13,className:`spin`}),` `,e(`settings.spend.loading`)]});let u=t.limit_usd,d=a.trim()===``?null:Number(a),f=d===null||Number.isFinite(d)&&d>0,p=d!==u;return R(`section`,{className:`settings-field spending`,"aria-label":e(`settings.spend.aria`),children:[I(`span`,{className:`settings-label`,children:e(`settings.spend.title`)}),R(`p`,{className:`spending-total`,children:[I(`bdi`,{dir:`ltr`,children:I(`strong`,{children:rB(t.total_usd)})}),u!=null&&R(P.Fragment,{children:[` `,e(`settings.spend.ofLimit`,{limit:rB(u)})]}),R(`span`,{className:`settings-hint`,children:[` · `,e.plural(`settings.spend.turns`,t.turns-t.unpriced_turns-t.unreported_turns)]})]}),t.unpriced_turns>0&&I(`p`,{className:`settings-hint`,children:e.plural(`settings.spend.unpriced`,t.unpriced_turns)}),t.unreported_turns>0&&I(`p`,{className:`settings-hint`,children:e.plural(`settings.spend.unreported`,t.unreported_turns)}),t.state===`near`&&R(`p`,{className:`spending-warning`,role:`status`,children:[I(ec,{size:13,"aria-hidden":`true`}),` `,e(`settings.spend.near`)]}),t.state===`reached`&&R(`div`,{className:`spending-warning`,role:`alert`,children:[R(`p`,{children:[I(ec,{size:13,"aria-hidden":`true`}),` `,e(`settings.spend.reached`)]}),I(`button`,{type:`button`,className:`btn-secondary`,disabled:s,onClick:()=>void l(Ht),children:e(`settings.spend.allow`)})]}),t.state===`allowed_over`&&I(`p`,{className:`settings-hint`,children:e(`settings.spend.allowed`)}),R(`form`,{className:`settings-row`,onSubmit:e=>{e.preventDefault(),f&&p&&l(()=>ie(d))},children:[I(`label`,{className:`spending-limit-label`,htmlFor:`spend-limit`,children:e(`settings.spend.limit`)}),I(`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":!f}),R(`button`,{type:`submit`,className:`btn-secondary`,disabled:s||!f||!p,children:[s?I(so,{size:13,className:`spin`}):null,` `,e(`settings.advanced.save`)]}),u!=null&&I(`button`,{type:`button`,className:`btn-secondary`,disabled:s,onClick:()=>void l(()=>ie(null)),children:e(`settings.spend.removeLimit`)})]}),I(`span`,{className:`settings-hint`,children:e(`settings.spend.how`)}),r&&I(`p`,{className:`settings-error`,role:`alert`,children:r})]})}var DQ=2e3;function OQ(e,t){return e.key_source===`environment`?t(`settings.key.setIn`,{name:e.env_var??``}):`••••••••••••••••••••${e.key_hint?` ${e.key_hint}`:``}`}function kQ(){let e=L(),t=Xc(e=>e.active),n=Xc(e=>e.select),r=Xc(e=>e.refresh),i=Xc(e=>e.rememberNames),a=B(e=>!!e.systemStatus&&SR(e.systemStatus)===`unresponsive`),[o,s]=(0,V.useState)(null),[c,u]=(0,V.useState)(null),d=B(e=>e.settingsProvider),[f,p]=(0,V.useState)(d??t?.provider??`local`),[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)(null),[v,y]=(0,V.useState)(``),[b,x]=(0,V.useState)(!1),[S,C]=(0,V.useState)(``),[w,T]=(0,V.useState)(!1),[E,ee]=(0,V.useState)(!1),[D,O]=(0,V.useState)({base_url:``,auth_header_name:``,auth_header_prefix:``}),[te,k]=(0,V.useState)(null),[A,ne]=(0,V.useState)(null),[re,j]=(0,V.useState)(null),[ie,ae]=(0,V.useState)(null),[oe,se]=(0,V.useState)(!1),[ce,le]=(0,V.useState)(null),[ue,M]=(0,V.useState)(null),de=(0,V.useRef)(f);de.current=f;let fe=(0,V.useRef)(!0);(0,V.useEffect)(()=>(fe.current=!0,()=>{fe.current=!1}),[]);let N=o?.find(e=>e.id===f)??null,pe=e=>e?.network?.reachable===!1,me=e=>!!e?.blocked,he=!!N&&!me(N)&&(!N.remote||!!N.models_discovered),ge=(0,V.useCallback)(async()=>{u(null);try{let e=await Yn();s(e.providers),e.lemonade_error&&u(e.lemonade_error)}catch(e){u(e instanceof Error?e.message:String(e))}},[]),_e=(0,V.useCallback)(async()=>{try{await Se()}catch(e){u(e instanceof Error?e.message:String(e));return}await ge()},[ge]),ve=(0,V.useCallback)(async(t,n=!1)=>{n||(h(null),_(null));try{let n=await ln(t);i(n.models),h(n.models),ne(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,V.useEffect)(()=>{ge()},[ge]);let ye=!!o?.some(e=>e.key_state===`waiting_for_os_permission`);(0,V.useEffect)(()=>{if(ye)return Sl(()=>{ge()},DQ)},[ye,ge]);let be=t?.provider;(0,V.useEffect)(()=>{be&&!d&&p(be)},[be,d]),(0,V.useEffect)(()=>{C(``),T(!1),ee(!1),j(null),y(``),x(!1),se(!1)},[f]),(0,V.useEffect)(()=>{he?ve(f):h(null)},[f,he,ve]);let xe=(0,V.useCallback)(async()=>{if(N){k(`connect`),j(null);try{let t=f===`amd`?{api_key:S||void 0,...Object.fromEntries(Object.entries(D).filter(([,e])=>e!==``))}:{api_key:S||void 0},n=()=>!fe.current||de.current!==f,r=await fr(f,t,e=>{n()||j({ok:!0,text:e})},n);if(n())return;C(``),T(!1),j({ok:!0,text:r.remember_error?e(`settings.key.sessionOnly`,{reason:r.remember_error}):r.known_models?e(`settings.key.knownModels`,{name:N.name}):r.remembered?e(`settings.key.kept`):e(`settings.key.connectedDone`)}),await ge()}catch(e){fe.current&&de.current===f&&j({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{fe.current&&k(null)}}},[D,f,S,ge,N,e]),we=(0,V.useCallback)(async()=>{k(`forget`),ee(!1),j(null);try{await l(f),j({ok:!0,text:e(`settings.key.cleared`)}),await ge(),await r()}catch(e){j({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{k(null)}},[f,ge,r,e]),Te=(0,V.useCallback)(async t=>{k(t),j(null);try{await n(t),j({ok:!0,text:e(`settings.model.switched`,{name:el(t)})}),await ve(f,!0)}catch(e){j({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{k(null)}},[f,ve,n,e]),Ee=(0,V.useCallback)(async e=>{k(`dl:${e}`),j(null),se(!1);try{await Ce(e),await ve(`local`,!0)}catch(e){j({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{k(null)}},[ve]),De=(0,V.useCallback)(async t=>{let n=Xc.getState().active?.model;k(`rm:${t}`),j(null);try{let r=await ir(t);ae(null);let i=r.cleared.includes(`last_model`)?`settings.model.removedLast`:r.cleared.includes(`default_model`)?`settings.model.removedDefault`:`settings.model.removed`;j({ok:!0,text:e(i,{name:r.display_name})}),await ve(`local`,!0),await Zc(n)}catch(e){j({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{k(null)}},[ve,e]),Oe=(0,V.useCallback)(async t=>{j({ok:!0,text:e(`settings.model.added`,{name:t})}),se(!0),await ve(`local`,!0)},[ve,e]),ke=!!m?.some(gl);(0,V.useEffect)(()=>{if(ke)return()=>{r()}},[ke,r]),(0,V.useEffect)(()=>{if(f===`local`&&ke)return Sl(()=>{ve(`local`,!0)},DQ)},[ke,f,ve]);let Ae=t?.model,je=m?.find(e=>$c(Ae,e.id));(0,V.useEffect)(()=>{je&&le(je)},[je]);let Me=(0,V.useMemo)(()=>{let e=v.trim().toLowerCase();return(m??[]).filter(t=>!e||t.id.toLowerCase().includes(e)||(t.display_name??``).toLowerCase().includes(e))},[m,v]),Ne=Me.filter(e=>e.available!==!1),Pe=f===`fireworks`&&!b&&!v.trim()&&Ne.some(e=>e.rank!==null),Fe=e=>e.rank!==null||e.id===t?.model,Ie=Pe?Ne.filter(Fe):Ne,Le=Pe?Ne.filter(e=>!Fe(e)):[],Re=Me.filter(e=>e.available===!1),ze=cl(m??[]),Be=!!v.trim(),Ve=e=>$c(t?.model,e.id),He=N?.id===`local`,Ue=Ie.filter(e=>e.downloaded).sort((e,t)=>Number(Ve(t))-Number(Ve(e))),We=Ie.filter(e=>!e.downloaded),Ge=(m??[]).filter(e=>e.available!==!1&&e.downloaded),Ke=Ge.filter(Fe),qe=ie?(m??[]).find(e=>e.id===ie)??null:null,Je=f===`fireworks`&&Ke.some(e=>e.rank!==null)?Ke:Ge,Ye=e=>I(TQ,{model:e,label:ze[e.id],current:Ve(e),remote:!!N?.remote,busy:te,onUse:()=>void Te(e.id),onDownload:()=>void Ee(e.id),onAskRemove:()=>ae(e.id),onNpuRecheck:()=>void ve(f,!0)},e.id);return R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.model`)}),I(JV,{inSettings:!0}),I(xQ,{row:je??($c(ce?.id,t?.model)?ce:null),providerName:t?.provider_name??null,choices:he?Je:[],labels:ze,disabled:te!==null,onSwitch:e=>void Te(e)}),I(VV,{className:`provider-tabs`,"aria-label":e(`settings.model.whereRuns`),children:(o??[{id:`local`,name:`Local`,remote:!1}]).map(t=>R(`button`,{type:`button`,role:`radio`,"aria-checked":f===t.id,className:`provider-tab${f===t.id?` is-active`:``}${pe(t)||me(t)?` is-disabled`:``}`,onClick:()=>p(t.id),disabled:(pe(t)||me(t))&&f!==t.id,title:me(t)?e(`settings.privacy.localOnlyBlocked`):pe(t)?e(`setup.key.gatewayOff`):void 0,children:[t.remote?I(ki,{size:14,"aria-hidden":`true`}):I(zi,{size:14,"aria-hidden":`true`}),I(`span`,{children:aB(e,t)}),t.remote&&t.models_discovered&&I(`span`,{className:`provider-tab-dot`,"aria-label":e(`settings.key.connectedDot`)})]},t.id))}),!o&&!c&&R(`p`,{className:`settings-hint`,role:`status`,children:[I(so,{size:13,className:`spin`}),` `,e(a?`settings.model.waitingServer`:`settings.loading`)]}),c&&I(mQ,{message:c,onRetry:()=>{ge(),ve(f)}}),N&&R(`section`,{className:`settings-card`,"aria-label":aB(e,N),children:[N.remote&&I(`p`,{className:`settings-note`,children:I(`bdi`,{children:oB(e,N)})}),R(`details`,{className:`settings-more`,children:[R(`summary`,{children:[I(si,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,e(`settings.model.howItWorks`)]}),I(`p`,{className:`settings-hint`,children:e(`settings.model.lede`)}),He&&I(`p`,{className:`settings-hint`,children:I(`bdi`,{children:oB(e,N)})}),He&&I(`p`,{className:`settings-hint`,children:e(`settings.model.devices`)}),He&&A&&I(`p`,{className:`settings-hint`,children:e(`settings.model.memory`,{memory:A})})]}),N.remote&&!he&&R(`div`,{className:`settings-field`,children:[I(`span`,{className:`settings-label`,children:e(`settings.model.prices`)}),I(QJ,{provider:N.id})]}),me(N)&&I(`div`,{className:`settings-field`,children:I(`p`,{className:`settings-error`,role:`alert`,children:e(`settings.privacy.localOnlyBlocked`)})}),pe(N)&&R(`div`,{className:`settings-field`,children:[I(`p`,{className:`settings-error`,role:`alert`,children:N.network?.detail}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void ge(),children:e(`settings.key.checkAgain`)})]}),N.remote&&!pe(N)&&!me(N)&&R(`form`,{className:`settings-field`,"data-settings-target":`cloud-key`,onSubmit:e=>{e.preventDefault(),xe()},children:[R(`div`,{className:`settings-row settings-row-between`,children:[I(`span`,{className:`settings-label`,children:e(`settings.key.title`)}),N.key_source&&I(`span`,{className:`settings-key-status ${he?`settings-ok`:`settings-error`}`,children:e(he?`settings.key.connected`:`settings.key.notConnected`)})]}),!N.key_source&&N.key_state===`store_locked`&&R(`span`,{className:`settings-hint`,role:`status`,children:[e(`settings.key.storeLocked`),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>void _e(),children:e(`settings.key.unlockAgain`)})]}),!N.key_source&&N.key_state!==`store_locked`&&I(`span`,{className:`settings-hint`,children:N.key_state===`waiting_for_os_permission`?N.key_message??e(`settings.key.waitingOs`):e(`settings.key.none`)}),N.id===`amd`&&(!N.key_source||w)&&R(`div`,{className:`settings-grid`,children:[I(`input`,{className:`settings-input`,placeholder:e(`settings.key.gatewayPlaceholder`),value:D.base_url,onChange:e=>O({...D,base_url:e.target.value}),"aria-label":e(`settings.key.gatewayUrl`)}),I(`input`,{className:`settings-input`,placeholder:e(`settings.key.headerPlaceholder`),value:D.auth_header_name,onChange:e=>O({...D,auth_header_name:e.target.value}),"aria-label":e(`settings.key.headerName`)})]}),N.key_source&&!w?R(`div`,{className:`settings-row`,children:[I(`input`,{className:`settings-input settings-key-masked`,readOnly:!0,value:OQ(N,e),"aria-label":e(`settings.key.savedAria`,{name:N.name})}),!he&&R(`button`,{type:`submit`,className:`btn-primary`,disabled:te!==null,children:[te===`connect`?I(so,{size:13,className:`spin`}):null,e(`settings.key.reconnect`)]}),(N.key_source!==`environment`||N.key_from_gaia_env)&&R(P.Fragment,{children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>T(!0),disabled:te!==null,children:e(`settings.key.replace`)}),N.key_source!==`environment`&&I(`button`,{type:`button`,className:`btn-secondary settings-key-remove`,onClick:()=>ee(!0),disabled:te!==null,"aria-label":e(`settings.key.remove`),title:e(`settings.key.remove`),children:I(Qs,{size:14,"aria-hidden":`true`})})]})]}):R(`div`,{className:`settings-row`,children:[I(`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:N.name})}),R(`button`,{type:`submit`,className:`btn-primary`,disabled:te!==null||!S,children:[te===`connect`?I(so,{size:13,className:`spin`}):null,e(w?`settings.key.save`:`settings.key.connect`)]}),w&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{C(``),T(!1)},disabled:te!==null,children:e(`settings.key.cancel`)})]}),N.key_source&&!he&&!N.error&&!w&&I(`p`,{className:`settings-hint`,children:e(`settings.key.notConnectedHint`,{name:N.name})}),N.error&&I(`p`,{className:`settings-error`,role:`alert`,children:N.error})]}),re?.ok&&I(`p`,{className:`settings-ok`,role:`status`,children:re.text}),re&&!re.ok&&I(mQ,{message:re.text}),N.known_models&&I(`p`,{className:`settings-hint`,role:`status`,children:e(`settings.key.knownList`,{name:N.name})}),He&&I(`div`,{className:`models-downloads-slot`,ref:M}),he&&R(`div`,{className:`settings-field`,children:[I(`span`,{className:`settings-label`,children:e(`settings.model.models`)}),(m?.length??0)>6&&I(`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&&sQ(g))&&I(mQ,{message:g}),!m&&!g&&R(`p`,{className:`settings-hint`,children:[I(so,{size:13,className:`spin`}),` `,e(`settings.loading`)]}),m&&Me.length===0&&!g&&I(`p`,{className:`settings-hint`,children:e(Be||!He?`settings.model.noMatch`:`settings.model.noModels`)}),He?R(P.Fragment,{children:[Ue.length>0&&I(KZ,{title:e(`settings.model.groupDownloaded`),count:Ue.length,defaultOpen:!0,forceOpen:Be,targetId:`models-on-pc`,children:I(`ul`,{className:`model-list`,children:Ue.map(Ye)})}),We.length>0&&I(KZ,{title:e(`settings.model.groupAvailable`),count:We.length,defaultOpen:Ue.length===0,forceOpen:Be||oe||We.some(gl),children:I(`ul`,{className:`model-list`,children:We.map(Ye)})})]}):I(`ul`,{className:`model-list`,children:Ie.map(Ye)}),Pe&&Le.length>0&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>x(!0),children:e(`settings.model.showAll`)}),f===`fireworks`&&b&&!Be&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>x(!1),children:e(`settings.model.showRecommended`)}),Re.length>0&&I(KZ,{title:e(`settings.model.groupUnavailable`),count:Re.length,forceOpen:Be,children:I(`ul`,{className:`model-list`,children:Re.map(Ye)})})]}),He&&he&&I(KZ,{title:e(`settings.custom.title`),children:I(hQ,{onAdded:e=>void Oe(e)})}),He&&he&&I(vQ,{downloadsSlot:ue}),N.remote&&I(EQ,{})]}),qe&&I(tX,{title:e(`settings.models.removeTitle`,{name:ze[qe.id]??qe.id}),confirmLabel:qe.downloaded?e(`settings.model.removeDownload`):e(`settings.models.remove`),cancelLabel:e(`settings.models.keep`),danger:!0,onConfirm:()=>{ae(null),De(qe.id)},onCancel:()=>ae(null),children:qe.downloaded&&I(`p`,{children:e(`settings.model.removeDownloadBody`)})}),E&&N&&I(tX,{title:e(`settings.key.removeAsk`),confirmLabel:e(`settings.key.remove`),cancelLabel:e(`settings.models.keep`),danger:!0,onConfirm:()=>void we(),onCancel:()=>ee(!1),children:I(`p`,{children:e(`settings.key.removeBody`,{name:N.name})})})]})}async function AQ(){return jn(`GET`,`/images/settings`)}async function jQ(e){return jn(`PUT`,`/images/settings`,e)}var MQ=[4,8,12,20,30,50],NQ=e=>`${e}`;function PQ(e){return e instanceof En?e.detail||e.message:String(e)}function FQ(){let e=L(),t=B(e=>e.openSettings),n=Oz(e=>e.current)===`gaiacpp`;Qc();let[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1),d=()=>{o(null),AQ().then(i).catch(e=>o({unreachable:e instanceof En&&e.httpStatus===503,detail:PQ(e)}))};(0,V.useEffect)(()=>{n||d()},[n]);let f=e=>{u(!0),c(null),jQ(e).then(i).catch(e=>c(PQ(e))).finally(()=>u(!1))},p=I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.images`)});if(n)return R(`div`,{className:`settings-pane`,children:[p,R(`div`,{className:`settings-notice`,role:`status`,children:[I(`p`,{children:e(`images.settings.fastAgentCannot`)}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>t(`model`),children:e.compose(e=>e(`mem.store.change`,{tab:e(`settings.section.model`)}))})]})]});if(a)return R(`div`,{className:`settings-pane`,children:[p,a.unreachable?R(P.Fragment,{children:[I(`p`,{className:`settings-error`,role:`alert`,children:e(`images.settings.unreachable`)}),I(`p`,{className:`settings-hint`,children:a.detail}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:d,children:e(`images.settings.retry`)})]}):I(`p`,{className:`settings-error`,role:`alert`,children:e(`images.settings.loadFailed`,{reason:a.detail})})]});if(!r)return R(`p`,{className:`settings-hint`,children:[I(so,{size:13,className:`spin`}),` `,e(`settings.loading`)]});let m=r.models.find(e=>e.id===r.model),h=m?[...new Set([...MQ,m.default_steps,...r.steps?[r.steps]:[]])].filter(e=>e<=r.max_steps).sort((e,t)=>e-t):[];return R(`div`,{className:`settings-pane`,children:[p,I(`p`,{className:`settings-pane-lede`,children:e(`images.settings.lede`)}),!r.chat_model_creates_images&&R(`div`,{className:`settings-notice`,role:`status`,children:[I(`p`,{children:e(`images.settings.chatModelCannot`,{model:el(r.chat_model)})}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>t(`model`),children:e(`images.settings.chooseChatModel`)})]}),!r.model_available&&I(`p`,{className:`settings-error`,role:`alert`,children:e(`images.settings.modelGone`,{model:r.model})}),r.models.length===0?I(`p`,{className:`settings-hint`,children:e(`images.settings.noModels`)}):R(P.Fragment,{children:[R(`div`,{className:`settings-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`image-model`,children:e(`images.settings.model`)}),R(`select`,{id:`image-model`,className:`settings-input`,value:r.model_available?r.model:``,disabled:l,onChange:e=>f({model:e.target.value}),children:[!r.model_available&&I(`option`,{value:``,disabled:!0,children:r.model}),r.models.map(t=>I(`option`,{value:t.id,children:t.downloads_on_first_use?e.bare(`images.settings.downloadsOnFirstUse`,{model:t.id,size:NQ(`${t.size_gb??`?`} GB`)}):t.id},t.id))]})]}),m&&R(P.Fragment,{children:[R(`div`,{className:`settings-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`image-size`,children:e(`images.settings.size`)}),R(`select`,{id:`image-size`,className:`settings-input`,value:r.size??``,disabled:l,onChange:e=>f({size:e.target.value||null}),children:[I(`option`,{value:``,children:e.bare(`images.settings.automatic`,{value:NQ(m.default_size)})}),m.sizes.map(e=>I(`option`,{value:e,children:NQ(e)},e))]})]}),R(`div`,{className:`settings-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`image-steps`,children:e(`images.settings.steps`)}),R(`select`,{id:`image-steps`,className:`settings-input`,value:r.steps??``,disabled:l,onChange:e=>f({steps:e.target.value?Number(e.target.value):null}),children:[I(`option`,{value:``,children:e.bare(`images.settings.automatic`,{value:NQ(String(m.default_steps))})}),h.map(e=>I(`option`,{value:e,children:NQ(String(e))},e))]}),I(`span`,{className:`settings-hint`,children:e(`images.settings.stepsHint`)})]})]})]}),I(`p`,{className:`settings-hint`,children:e(`images.settings.shared`)}),s&&I(`p`,{className:`settings-error`,role:`alert`,children:e(`images.settings.saveFailed`,{reason:s})})]})}function IQ(){let e=L(),t=B(e=>e.sessions),[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(null),u=(0,V.useCallback)(async()=>{l(null);try{let e=await Xt();r(e.sessions),a(e.default_mode),B.getState().setDefaultPermissionMode(e.default_mode)}catch(e){l(e instanceof Error?e.message:String(e))}},[]);(0,V.useEffect)(()=>{u()},[u]);let d=(0,V.useCallback)(async e=>{l(null);try{await e(),await u()}catch(e){l(e instanceof Error?e.message:String(e))}},[u]),f=(0,V.useCallback)(async e=>{s(!1),await d(()=>Ct(e))},[d]),p=()=>{i===`full_access`?f(`ask`):s(e=>!e)},m=e=>t.find(t=>t.id===e)?.title??e;return R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.permissions`)}),I(`p`,{className:`settings-pane-lede`,children:e(`settings.permissions.lede`)}),R(`details`,{className:`settings-more`,children:[R(`summary`,{children:[I(si,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,e(`settings.model.howItWorks`)]}),I(`p`,{className:`settings-hint`,children:e(`settings.permissions.perChat`)})]}),R(`section`,{className:`settings-card`,"aria-label":e(`settings.permissions.newChats`),children:[R(`label`,{className:`setting-row`,children:[I(`span`,{className:`settings-label`,children:e(`settings.permissions.fullAccess`)}),R(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,checked:i===`full_access`,onChange:p,disabled:i===null,"aria-label":e(`settings.permissions.fullAccess`)}),I(`span`,{className:`toggle-track`})]})]}),I(`p`,{className:`settings-hint`,children:e(i===`full_access`?`settings.permissions.on`:`settings.permissions.off`)}),o&&R(`div`,{className:`settings-warning`,role:`alert`,children:[I(`p`,{children:e(`settings.permissions.warning`)}),R(`div`,{className:`settings-row`,children:[I(`button`,{type:`button`,className:`btn-danger`,onClick:()=>void f(`full_access`),children:e(`settings.permissions.turnOn`)}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>s(!1),children:e(`settings.key.cancel`)})]})]})]}),c&&I(`p`,{className:`settings-error`,role:`alert`,children:c}),n&&n.length===0&&I(`p`,{className:`settings-hint`,children:e(`settings.permissions.none`)}),!!n?.length&&I(KZ,{title:e(`settings.permissions.chats`),count:n.length,defaultOpen:!0,children:n.map(t=>R(`section`,{className:`settings-field permission-chat`,"aria-label":m(t.session_id),children:[R(`div`,{className:`settings-row settings-row-between`,children:[I(`bdi`,{className:`settings-label`,children:m(t.session_id)}),t.mode===`full_access`&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>d(async()=>{let e=(await sr(t.session_id,`ask`)).mode;AB(t.session_id,e)}),children:e(`settings.permissions.turnOff`)})]}),t.grants.length>0&&I(`ul`,{className:`grant-list`,children:t.grants.map(n=>R(`li`,{className:`grant-row`,children:[I(`code`,{children:n.label}),I(`button`,{type:`button`,className:`link-btn`,onClick:()=>d(()=>tr(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&&I(`button`,{type:`button`,className:`link-btn`,onClick:()=>d(()=>tr(t.session_id)),children:e(`settings.permissions.revokeAll`)})]},t.session_id))})]})}function LQ({text:e}){let t=L(),n=(0,V.useRef)(null),[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(!1);return(0,V.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]),R(P.Fragment,{children:[I(`span`,{ref:n,className:`skill-row-desc${r?` is-open`:``}${a||r?` is-toggle`:``}`,dir:`auto`,onClick:a||r?e=>{e.preventDefault(),i(!r)}:void 0,children:I(`bdi`,{children:e})}),(a||r)&&I(`button`,{type:`button`,className:`skill-row-more`,"aria-expanded":r,onClick:()=>i(!r),children:t(r?`settings.skills.less`:`settings.skills.more`)})]})}function RQ(e,t){if(e instanceof En&&e.reason===`link_not_found`){let n=e.body?.link;if(typeof n==`string`&&ht(`settings.skills.link.notFound`,{link:n})===e.detail)return t(`settings.skills.link.notFound`,{link:n})}return fP(e,t)}var zQ=(e,t)=>!e.error&&(!e.installed||e.update)&&(t||!e.has_code);function BQ(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 VQ({onAdded:e}){let t=L(),[n,r]=(0,V.useState)(``),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(new Set),[f,p]=(0,V.useState)(!1),[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)([]);(0,V.useEffect)(()=>{let e=!1;return Et().then(t=>{e||_(t.libraries)}).catch(n=>{e||s(t(`settings.skills.link.featuredFailed`,{error:fP(n,t)}))}),()=>{e=!0}},[t]);let v=async e=>{if(e.trim()){a(`preview`),s(null),l(null),h(null);try{let t=await Fe(e.trim());l(t),d(new Set(t.skills.filter(e=>zQ(e,!1)).map(e=>e.name)))}catch(e){s(RQ(e,t))}finally{a(null)}}},y=async()=>{if(c&&u.size!==0){a(`add`),s(null);try{let t=await Nt(c.link,[...u],f,c.pin);h(t),l(null),r(``),t.added.length&&e()}catch(e){s(RQ(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=>zQ(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 R(`div`,{className:`settings-card skill-link`,children:[R(`div`,{className:`skill-link-top`,children:[I(`span`,{className:`settings-label`,children:t(`settings.skills.link.title`)}),g.map(e=>{let n=`settings.skills.link.featured.${e.id}`,a=k(n);return I(`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?M(n):e.description}),children:t(`settings.skills.link.get`,{name:e.name})},e.id)})]}),R(`form`,{className:`skill-link-form`,onSubmit:e=>{e.preventDefault(),v(n)},children:[I(`input`,{className:`settings-input`,type:`text`,inputMode:`url`,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Escape`&&i===null&&(c||n)&&(e.preventDefault(),c?l(null):r(``))},...Rt,onPaste:e=>{if(i!==null)return;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`),readOnly:i!==null,"aria-busy":i===`preview`}),I(`button`,{type:`submit`,className:`btn-secondary`,disabled:!n.trim()||i!==null,children:i===`preview`?R(P.Fragment,{children:[I(so,{size:13,className:`spin`}),` `,t(`settings.skills.link.reading`)]}):t(`settings.skills.link.read`)})]}),o&&I(`p`,{className:`settings-error`,role:`alert`,children:o}),c&&R(`div`,{className:`skill-link-preview`,children:[R(`details`,{className:`skill-link-warning`,role:`note`,children:[R(`summary`,{children:[I(ec,{size:14,"aria-hidden":`true`}),t(`settings.skills.link.trust`)]}),I(`p`,{children:I(`bdi`,{children:c.warning})})]}),R(`div`,{className:`skill-link-head`,children:[I(`span`,{children:t(`settings.skills.link.found`,{n:c.skills.length,source:c.source})}),S.length>1&&I(`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`)})]}),I(`ul`,{className:`skill-list skill-link-list`,children:c.skills.map(e=>{let n=zQ(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 I(`li`,{className:`skill-row`,children:R(`label`,{className:`skill-link-pick`,children:[I(`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})}),R(`span`,{className:`skill-row-text`,children:[R(`span`,{className:`skill-row-name`,children:[e.name,r&&I(`span`,{className:`skill-link-tag${e.error?` is-bad`:``}`,children:r}),e.has_code&&I(`span`,{className:`skill-link-tag`,children:t(`settings.skills.link.tagCode`)}),e.verdict===`REVIEW`&&I(`span`,{className:`skill-link-tag`,children:t(`settings.skills.link.tagReview`)})]}),e.description&&I(LQ,{text:e.description}),e.permissions.length>0?R(`span`,{className:`skill-link-perms`,children:[I(`span`,{className:`skill-link-perms-label`,children:t(`settings.skills.link.can`)}),I(`ul`,{"aria-label":t(`settings.skills.link.permsAria`,{name:e.name}),children:e.permissions.map(e=>R(`li`,{children:[I(`bdi`,{children:e.text}),` `,I(`bdi`,{dir:`ltr`,children:I(`code`,{children:e.grant})})]},e.grant))})]}):I(`span`,{className:`skill-link-perms`,children:t(e.permissions_unreadable?`settings.skills.link.permissionsUnreadable`:`settings.skills.link.noPermissions`)}),a&&R(`details`,{className:`skill-link-findings`,children:[I(`summary`,{children:t(`settings.skills.link.details`)}),i&&I(`p`,{children:I(`bdi`,{children:i})}),e.has_code&&!f&&I(`p`,{children:t(`settings.skills.link.shipsCode`)}),e.findings.length>0&&I(`ul`,{children:e.findings.map(e=>I(`li`,{children:I(`bdi`,{children:e})},e))})]})]})]})},e.path)})}),R(`div`,{className:`skill-link-actions`,children:[w&&R(`label`,{className:`skill-link-code`,title:t(`settings.skills.link.codeHint`),children:[I(`input`,{type:`checkbox`,checked:f,onChange:e=>x(e.target.checked)}),I(`span`,{children:t(`settings.skills.link.includeCode`)})]}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>l(null),disabled:i!==null,children:t(`settings.skills.link.cancel`)}),I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void y(),disabled:u.size===0||i!==null,children:i===`add`?R(P.Fragment,{children:[I(so,{size:13,className:`spin`}),` `,t(`settings.skills.link.adding`)]}):t(`settings.skills.link.add`,{n:u.size})})]})]}),m&&R(`div`,{className:`skill-link-result`,role:`status`,children:[m.added.length>0&&I(`p`,{children:BQ(m,t)}),Object.keys(m.failed).length>0&&R(`details`,{children:[I(`summary`,{children:t(`settings.skills.link.notAdded`,{n:Object.keys(m.failed).length})}),I(`ul`,{className:`grant-list`,children:Object.entries(m.failed).map(([e,t])=>R(`li`,{children:[I(`bdi`,{children:I(`strong`,{children:e})}),` — `,I(`bdi`,{children:t})]},e))})]})]})]})}var HQ={path:`~/.gaia/skills`},UQ=[{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:HQ},{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 WQ(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 GQ({onUseSkill:e}){let t=L(),[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)({}),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(``),[u,d]=(0,V.useState)(null),[f,p]=(0,V.useState)(null),m=(0,V.useRef)(null),h=(0,V.useRef)(!0),g=(0,V.useCallback)(()=>{Bt().then(e=>{h.current&&(r(e.skills),a(e.invalid),s(null))}).catch(e=>{h.current&&s(e instanceof Error?e.message:String(e))})},[]);(0,V.useEffect)(()=>(h.current=!0,g(),window.addEventListener(`focus`,g),()=>{h.current=!1,window.removeEventListener(`focus`,g)}),[g]);let _=async e=>{d({name:e,busy:!0}),p(null);try{await ze(e)}catch(n){h.current&&p(t(`settings.skills.removeFailed`,{name:e,error:fP(n,t)}))}finally{h.current&&d(null),g()}},v=c.trim().toLowerCase(),y=(n??[]).filter(e=>!v||e.name.toLowerCase().includes(v)||e.description.toLowerCase().includes(v)),b=n?.every(e=>UQ.some(t=>t.source===e.source))??!1,x=n=>R(`li`,{className:`skill-row`,children:[R(`div`,{className:`skill-row-text`,children:[R(`span`,{className:`skill-row-name`,children:[I(`span`,{title:n.version?`v${n.version}`:void 0,children:n.name}),n.always_on&&R(`span`,{className:`skill-row-meta`,children:[` · `,t(`settings.skills.alwaysOn`)]})]}),I(LQ,{text:n.description})]}),R(`div`,{className:`skill-row-actions`,children:[!n.always_on&&I(`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.source===`user`&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{p(null),d({name:n.name,busy:!1})},"aria-label":t(`settings.skills.removeAria`,{name:n.name}),children:t(`settings.skills.remove`)})]})]},n.name);return R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:t(`settings.section.skills`)}),I(`p`,{className:`settings-pane-lede`,children:t(`settings.skills.lede`)}),R(`details`,{className:`settings-more`,children:[R(`summary`,{children:[I(si,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,t(`settings.model.howItWorks`)]}),I(`p`,{className:`settings-hint`,children:t(`settings.skills.how`,HQ)})]}),I(VQ,{onAdded:g}),o&&I(`p`,{className:`settings-error`,role:`alert`,children:o}),f&&I(`p`,{className:`settings-error`,role:`alert`,children:f}),!n&&!o&&R(`p`,{className:`settings-hint`,children:[I(so,{size:13,className:`spin`}),` `,t(`settings.loading`)]}),n&&n.length>6&&I(`input`,{ref:m,className:`settings-input`,type:`search`,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&c&&(e.preventDefault(),l(``))},...Rt,placeholder:t(`settings.skills.search`),"aria-label":t(`settings.skills.search`)}),n&&n.length===0&&I(`p`,{className:`settings-hint`,children:t(`settings.skills.none`)}),v&&n&&n.length>0&&y.length===0&&R(`p`,{className:`settings-hint`,role:`status`,children:[t(`settings.skills.noMatch`,{query:c.trim()}),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>{l(``),m.current?.focus()},children:t(`settings.skills.clearSearch`)})]}),b?UQ.map(e=>{let n=y.filter(t=>t.source===e.source);return n.length===0&&(v||!e.empty)?null:I(KZ,{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:!!v,children:I(`section`,{"aria-label":t(e.title),children:n.length===0?I(`p`,{className:`settings-hint`,children:e.empty&&t(e.empty,e.params)}):I(`ul`,{className:`skill-list`,children:n.map(x)})})},e.source)}):I(`ul`,{className:`skill-list`,children:y.map(x)}),Object.keys(i).length>0&&R(`div`,{className:`settings-card`,role:`alert`,children:[I(`span`,{className:`settings-label`,children:t(`settings.skills.skipped`)}),I(`ul`,{className:`grant-list`,children:Object.entries(i).map(([e,n])=>I(`li`,{children:t(WQ(n),{name:e.split(/[\\/]/).filter(Boolean).pop()??e})},e))})]}),u&&I(tX,{title:t(`settings.skills.removeTitle`,{name:u.name}),confirmLabel:t(`settings.skills.remove`),cancelLabel:t(`settings.skills.keep`),danger:!0,busy:u.busy,onConfirm:()=>void _(u.name),onCancel:()=>d(null),children:I(`p`,{children:t(`settings.skills.removeBody`,HQ)})})]})}var KQ=`profile`;function qQ(){let e=L(),[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(!1);(0,V.useEffect)(()=>{qq().then(n).catch(e=>i(e instanceof Error?e.message:String(e)))},[]);let l=(0,V.useCallback)(async e=>{o(!0),i(null),c(!1);try{let t=await Jq(e===KQ?null:e);n(t),c(t.changed!==!1)}catch(e){i(e instanceof Error?e.message:String(e)),await qq().then(n).catch(()=>void 0)}finally{o(!1)}},[]);if(!t)return r?I(`p`,{className:`settings-error`,role:`alert`,children:r}):R(`p`,{className:`settings-hint`,children:[I(so,{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 R(P.Fragment,{children:[R(`div`,{className:`model-in-use-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`embedder-device`,children:e(`settings.memory.embedder.label`)}),R(`select`,{id:`embedder-device`,className:`settings-input`,value:t.chosen?t.device:KQ,onChange:e=>void l(e.target.value),disabled:a,children:[I(`option`,{value:KQ,children:e.bare(`settings.memory.embedder.default`,{device:d(t.default_device)})}),t.options.map(t=>I(`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))]})]}),R(`span`,{className:`settings-hint`,children:[e(`settings.memory.embedder.runsOn`,{name:Ve(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)&&I(`span`,{className:`settings-hint`,children:e(`settings.memory.embedder.npuUnproven`)}),u?.downloaded===!1&&I(`span`,{className:`settings-hint`,children:e(`settings.memory.embedder.notDownloaded`)}),a&&R(`span`,{className:`settings-hint`,children:[I(so,{size:13,className:`spin`}),` `,e(`settings.memory.embedder.applying`)]}),s&&I(`p`,{className:`settings-ok`,role:`status`,children:e(`settings.memory.embedder.changed`)}),r&&I(`p`,{className:`settings-error`,role:`alert`,children:r})]})}function JQ(){let e=L(),t=B(e=>e.setShowMemoryDashboard),n=B(e=>e.closeSettings),r=B(e=>e.openSettings),i=Oz(e=>e.current)===`gaiacpp`,[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1);(0,V.useEffect)(()=>{Gq().then(o).catch(e=>c(e instanceof Error?e.message:String(e)))},[]);let d=(0,V.useCallback)(async()=>{if(a){u(!0),c(null);try{o(await Kq({memory_enabled:!a.memory_enabled}))}catch(e){c(e instanceof Error?e.message:String(e))}finally{u(!1)}}},[a]);return R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.memory`)}),I(`p`,{className:`settings-pane-lede`,children:e(`settings.memory.lede`)}),i&&R(`div`,{className:`settings-notice`,role:`status`,children:[I(`p`,{children:e(`settings.memory.fastAgentNotice`)}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>r(`model`),children:e.compose(e=>e(`mem.store.change`,{tab:e(`settings.section.model`)}))})]}),R(`section`,{className:`settings-card`,"aria-label":e(`settings.section.memory`),children:[R(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`settings.memory.remember`)}),R(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,checked:!!a?.memory_enabled,onChange:()=>void d(),disabled:!a||l,"aria-label":e(`settings.memory.remember`)}),I(`span`,{className:`toggle-track`})]})]}),s&&I(`p`,{className:`settings-error`,role:`alert`,children:s}),R(`div`,{className:`settings-row settings-row-between`,children:[I(`span`,{className:`settings-hint`,children:e(`settings.memory.dashboardHint`)}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{n(),t(!0)},children:e(`settings.memory.dashboard`)})]})]}),!i&&I(`section`,{className:`settings-card`,"aria-label":e(`settings.memory.embedder.label`),children:I(qQ,{})})]})}function YQ(e,t,n){if(!/^\d+$/.test(e.trim()))return!1;let r=Number(e);return r>=t&&r<=n}function XQ(e){return e<1048576?`${Math.ceil(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function ZQ(){let e=L(),[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(``),[a,o]=(0,V.useState)(``),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1);(0,V.useEffect)(()=>{yn().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,V.useState)({days:!1,mb:!1}),p=!YQ(r,1,365)||d.days,m=!YQ(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 Xe(Number(r),Number(a));n(t),c({ok:!0,text:e(`settings.undo.saved`)})}catch(t){let n=t instanceof En&&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 R(`div`,{className:`settings-field`,"aria-label":e(`settings.privacy.undo`),children:[I(`span`,{className:`settings-label`,children:e(`settings.privacy.undo`)}),I(`p`,{className:`settings-hint`,children:e(`settings.undo.hint`)}),t&&R(P.Fragment,{children:[R(`div`,{className:`setting-row`,children:[I(`label`,{htmlFor:`undo-days`,children:e(`settings.undo.days`)}),I(`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&&I(`p`,{id:`undo-days-error`,className:`settings-error`,children:e(`settings.undo.daysError`)}),R(`div`,{className:`setting-row`,children:[I(`label`,{htmlFor:`undo-mb`,children:e(`settings.undo.mb`)}),I(`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&&I(`p`,{id:`undo-mb-error`,className:`settings-error`,children:e(`settings.undo.mbError`)}),R(`div`,{className:`setting-row setting-row-path`,children:[I(`span`,{children:e(`settings.undo.inUse`)}),R(`span`,{children:[e.plural(`settings.undo.used`,t.turns,{size:XQ(t.used_bytes)}),` `,I(`bdi`,{dir:`ltr`,children:I(`code`,{className:`setting-path`,children:t.path})})]})]}),I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void g(),disabled:!h||l||p||m,children:e(l?`settings.models.applying`:`settings.advanced.save`)})]}),s&&I(`p`,{className:s.ok?`settings-ok`:`settings-error`,role:s.ok?`status`:`alert`,children:s.text})]})}var QQ={root:`settings-report`,button:`btn-secondary`,hint:`settings-hint`,error:`settings-error`};function $Q(){let e=L(),t=B(e=>e.sessions),n=B(e=>e.removeSession),r=il(),i=B(e=>e.systemStatus?.data_dir),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(null),[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)(!1),[h,g]=(0,V.useState)(null);(0,V.useEffect)(()=>{let e=!0;return ut().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,V.useCallback)(async()=>{if(d===null||p)return;let t=d,n=Xc.getState().active?.model,r=!t;f(r),m(!0),g(null);try{let t=await He({network_policy:r?`local_ai_only`:`cloud_allowed`});f(t.network_policy===`local_ai_only`),Zc(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,V.useCallback)(async t=>{try{await pt(t,!1)}catch(t){u({ok:!1,text:e(`settings.privacy.openFolderFailed`,{reason:t instanceof Error?t.message:String(t)})})}},[e]),y=(0,V.useCallback)(async()=>{c(!0);let r=[];for(let e of t)try{await ar(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 R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.privacy`)}),R(`section`,{className:`settings-card`,"aria-label":e(`settings.privacy.localOnlyTitle`),children:[R(`div`,{children:[R(`label`,{className:`setting-row`,children:[I(`strong`,{children:e(`settings.privacy.localOnlyTitle`)}),R(`span`,{className:`toggle-switch`,children:[I(`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}),I(`span`,{className:`toggle-track`})]})]}),I(`p`,{className:`settings-hint`,id:`privacy-local-only-hint`,children:e(`settings.privacy.localOnlyHint`)})]}),h&&I(`p`,{className:h.ok?`settings-ok`:`settings-error`,role:h.ok?`status`:`alert`,children:h.text})]}),R(`section`,{className:`settings-card`,"aria-labelledby":`privacy-where-title`,children:[I(`h3`,{className:`settings-label`,id:`privacy-where-title`,children:e(`settings.privacy.whereTitle`)}),I(`p`,{className:`settings-note`,children:e(`settings.privacy.stays`)}),I(`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&&R(`div`,{className:`setting-row setting-row-path`,children:[I(`span`,{children:e(`settings.privacy.dataFolder`)}),R(`span`,{className:`setting-path-actions`,children:[I(`bdi`,{dir:`ltr`,className:`setting-path`,children:i}),I(`button`,{type:`button`,className:`link-btn`,onClick:()=>void v(i),children:e(`settings.privacy.openFolder`)})]})]})]}),R(`section`,{className:`settings-card`,"aria-labelledby":`privacy-report-title`,children:[I(`h3`,{className:`settings-label`,id:`privacy-report-title`,children:e(`settings.privacy.reportTitle`)}),I(`p`,{className:`settings-note`,children:e(`settings.privacy.reportNote`)}),I(EF,{classes:QQ})]}),I(KZ,{title:e(`settings.privacy.undo`),children:I(ZQ,{})}),R(`section`,{className:`settings-card`,"aria-labelledby":`privacy-delete-title`,children:[I(`h3`,{className:`settings-label`,id:`privacy-delete-title`,children:e(`settings.privacy.deleteTitle`)}),I(`p`,{className:`danger-warning`,children:t.length===0?e(`settings.privacy.nothingToDelete`):e(`settings.privacy.deleteWarning`)}),I(`button`,{type:`button`,className:`btn-danger`,onClick:()=>{u(null),o(t.length)},disabled:t.length===0,children:e(`settings.privacy.delete`)})]}),a!==null&&R(tX,{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:[I(`p`,{children:e(`settings.privacy.deleteWarning`)}),I(`p`,{children:e(`settings.privacy.deleteFinal`)})]}),l&&I(`p`,{className:l.ok?`settings-ok`:`settings-error`,role:l.ok?`status`:`alert`,children:l.text})]})}var e$=[{id:`needs_approval`,label:`settings.alerts.approval`},{id:`question`,label:`settings.alerts.question`},{id:`finished`,label:`settings.alerts.finished`}],t$=[{value:`banner`,label:`settings.alerts.banner`},{value:`badge`,label:`settings.alerts.badge`},{value:`off`,label:`settings.alerts.off`}],n$=[0,10,20,30,50];function r$(){return typeof Notification>`u`?`unsupported`:Notification.permission}function i$(){let e=L(),t=hu(),n=!!window.gaiaAPI,[r,i]=(0,V.useState)(r$),a=Object.values(t.modes).includes(`banner`);return R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.notifications`)}),I(`p`,{className:`settings-pane-lede`,children:e(`settings.alerts.lede`)}),R(`section`,{className:`settings-card`,"aria-label":e(`settings.alerts.when`),children:[e$.map(n=>R(`div`,{className:`setting-row`,children:[I(`span`,{id:`alert-${n.id}`,children:e(n.label)}),I(VV,{className:`segmented`,"aria-labelledby":`alert-${n.id}`,children:t$.map(r=>I(`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"?I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{Notification.requestPermission().then(i).catch(e=>{console.error(`[alerts] Notification permission request failed`,e),i(r$())})},children:e(`settings.alerts.allow`)}):I(`p`,{className:`settings-error`,role:`alert`,children:e(r===`unsupported`?`settings.alerts.unsupported`:`settings.alerts.blocked`)})),R(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`settings.alerts.sound`)}),R(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,checked:t.sound,onChange:()=>t.update({sound:!t.sound}),"aria-label":e(`settings.alerts.sound`)}),I(`span`,{className:`toggle-track`})]})]}),n&&R(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`settings.alerts.flash`)}),R(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,checked:t.flash,onChange:()=>t.update({flash:!t.flash}),"aria-label":e(`settings.alerts.flash`)}),I(`span`,{className:`toggle-track`})]})]})]}),R(`section`,{className:`settings-card`,"aria-labelledby":`keep-awake-title`,children:[I(`h3`,{className:`settings-label`,id:`keep-awake-title`,children:e(`settings.alerts.keepAwakeTitle`)}),n?R(P.Fragment,{children:[R(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`settings.alerts.keepAwake`)}),R(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,checked:t.keepAwake,onChange:()=>t.update({keepAwake:!t.keepAwake}),"aria-label":e(`settings.alerts.keepAwake`)}),I(`span`,{className:`toggle-track`})]})]}),R(`div`,{className:`setting-row`,children:[I(`label`,{htmlFor:`battery-floor`,children:e(`settings.alerts.battery`)}),I(`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:n$.map(t=>I(`option`,{value:t,children:t===0?e.bare(`settings.alerts.never`):`${t}%`},t))})]}),I(`p`,{className:`settings-hint`,children:e(`settings.alerts.screen`)})]}):I(`p`,{className:`settings-hint`,children:e(`settings.alerts.desktopOnly`)})]})]})}var a$=[50,75,100,125,150,175,200],o$=[{accent:`american`,gender:`female`},{accent:`american`,gender:`male`},{accent:`british`,gender:`female`},{accent:`british`,gender:`male`}],s$=`settings:preview`,c$=`Hello, I'm GAIA. This is how I'll read my replies to you.`;function l$(e){return e instanceof En?e.detail||e.message:String(e)}function u$(){let e=L(),t=aF(e=>e.settings),n=aF(e=>e.setSettings),r=aF(e=>e.read),i=aF(e=>e.stop),a=aF(e=>e.messageId===s$),o=aF(e=>e.messageId===s$&&e.status===`loading`),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(null),[d,f]=(0,V.useState)(!1);(0,V.useEffect)(()=>{KP().then(n).catch(e=>c(l$(e)))},[n]);let p=e=>{f(!0),u(null),aF.getState().messageId===s$&&i(),qP(e).then(n).catch(e=>u(l$(e))).finally(()=>f(!1))};return s?R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.voice`)}),I(`p`,{className:`settings-error`,role:`alert`,children:e(`readAloud.settings.loadFailed`,{reason:s})})]}):t?t.available===!1?R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.voice`)}),I(`p`,{className:`settings-pane-lede`,role:`status`,children:e(`readAloud.settings.unavailable`)})]}):R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.voice`)}),I(`p`,{className:`settings-pane-lede`,children:e(`readAloud.settings.lede`)}),R(`div`,{className:`settings-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`read-aloud-voice`,children:e(`readAloud.settings.voice`)}),R(`div`,{className:`read-aloud-voice-row`,children:[I(`select`,{id:`read-aloud-voice`,className:`settings-input`,value:t.voice,disabled:d,onChange:e=>p({voice:e.target.value}),children:o$.map(n=>I(`optgroup`,{label:e(`readAloud.group.${n.accent}.${n.gender}`),children:t.voices.filter(e=>e.accent===n.accent&&e.gender===n.gender).map(e=>I(`option`,{value:e.id,lang:`en`,children:e.name},e.id))},`${n.accent}-${n.gender}`))}),R(`button`,{type:`button`,className:`btn-secondary`,"aria-pressed":a,disabled:d,onClick:()=>a?i():void r(s$,c$),children:[o?I(so,{size:13,className:`spin`}):I(a?Ks:oc,{size:13}),e(a?`readAloud.stop`:`readAloud.settings.preview`)]})]}),I(`span`,{className:`settings-hint`,children:e(`readAloud.settings.englishOnly`)}),I(cF,{messageId:s$})]}),R(`div`,{className:`settings-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`read-aloud-speed`,children:e(`readAloud.settings.speed`)}),I(`select`,{id:`read-aloud-speed`,className:`settings-input`,value:t.speed,disabled:d,onChange:e=>p({speed:Number(e.target.value)}),children:(a$.includes(t.speed)?a$:[...a$,t.speed].sort((e,t)=>e-t)).map(t=>I(`option`,{value:t,children:t===100?e.bare(`readAloud.settings.normalSpeed`):`${(t/100).toLocaleString(e.locale)}×`},t))})]}),R(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`readAloud.settings.auto`)}),R(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,checked:t.auto,disabled:d,onChange:()=>p({auto:!t.auto}),"aria-label":e(`readAloud.settings.auto`)}),I(`span`,{className:`toggle-track`})]})]}),I(`p`,{className:`settings-hint`,children:e(`readAloud.settings.shared`)}),l&&I(`p`,{className:`settings-error`,role:`alert`,children:e(`readAloud.settings.saveFailed`,{reason:l})})]}):R(`p`,{className:`settings-hint`,children:[I(so,{size:13,className:`spin`}),` `,e(`settings.loading`)]})}function d$(e,{message:t,model:n,reason:r,reasonCode:i}){if(!n||!r||ht(`model.restore.failed`,{model:n,reason:r})!==t)return Ve(t,`ltr`);let a=`model.restore.reason.${i}`;return e(`model.restore.failed`,{model:n,reason:i&&k(a)&&ht(a)===r?M(a):r})}function f$(){let e=L(),t=B(e=>e.jumpToSetting),n=B(e=>e.closeSettings),r=B(e=>e.runSetupAgain),i=Xc(e=>e.active),o=B(e=>e.systemStatus?.lemonade_running===!1),s=i?.restore?.status===`failed`&&!!i.model&&i.restore.model_id===i.model,c=i?.restore,l=s&&c?.message?d$(e,{message:c.message,model:c.model,reason:c.reason,reasonCode:c.reason_code}):null,u=!o&&s,[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(null),[y,b]=(0,V.useState)(null),[x,S]=(0,V.useState)(!1);(0,V.useEffect)(()=>{a().then(f).catch(e=>b(e instanceof Error?e.message:String(e))),ke().then(m).catch(e=>b(e instanceof Error?e.message:String(e))),tt().then(e=>g(e??null)).catch(e=>v(e instanceof Error?e.message:String(e)))},[]);let C=d?.catalog?.find(e=>e.id===d.chat_model.id),w=(i?.model?i.remote?i.label??el(i.model):el(i.model):null)??C?.name??null,T=(d?.catalog??[]).filter(e=>e.downloaded),E=T.reduce((e,t)=>e+(t.full_size_gb??0),0),ee=[p?.gpu_name,p?.npu_detected?e(`setup.checks.npu`):null].filter(Boolean).join(` · `),D=LA(d?.system?.physical_memory,p?.ram_gb),O=D&&VA(e.locale,D),te=d?.capacity_gb==null?null:VA(e.locale,PA(d.capacity_gb)),k=te?O?e(`settings.setup.memoryOf`,{size:te,total:O}):e(`settings.setup.memoryFor`,{size:te}):O,A=[{title:e(`settings.setup.where`),rows:[{label:e(`settings.setup.chatRuns`),value:w,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:[ee,k].filter(Boolean).join(` · `)||null},{label:e(`settings.setup.server`),value:d?.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:!!h?.applies||!!_&&!sQ(_)}]},{title:e(`setup.models.step`),rows:[{label:e(`settings.setup.models`),value:d?.catalog?e(`settings.setup.modelsValue`,{n:String(T.length),size:PA(E)}):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 R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.setup`)}),I(`p`,{className:`settings-hint`,children:e(`settings.setup.lede`)}),R(`div`,{className:`settings-setup-status`,children:[R(`span`,{children:[I(`strong`,{children:e(o?`settings.setup.serverDown`:u?`settings.setup.chatUnusable`:`settings.setup.ready`)}),u&&l&&R(`span`,{className:`settings-hint`,children:[` `,I(`bdi`,{children:l})]}),w&&!o&&!u&&R(`span`,{className:`settings-hint`,children:[` `,I(`bdi`,{children:e(`settings.setup.running`,{name:w})})]})]}),I(`button`,{type:`button`,className:`btn-secondary`,"data-testid":`setup-run-again`,onClick:()=>S(!0),children:e(`settings.setup.runAgain`)})]}),y&&I(`p`,{className:`setup-error`,role:`alert`,children:y}),A.map(e=>R(`section`,{className:`settings-setup-group`,"aria-label":e.title,children:[I(`h3`,{className:`settings-label`,children:e.title}),e.rows.filter(e=>e.shown!==!1).map(e=>{let n=R(`span`,{children:[I(`span`,{className:`settings-setup-row-label`,children:e.label}),e.value&&I(`bdi`,{className:`settings-hint settings-setup-row-value`,children:e.value})]}),r=e.section;return r?R(`button`,{type:`button`,className:`settings-setup-row`,onClick:()=>t({section:r,target:e.target??`.settings-pane-title`,from:`setup`},e.provider),children:[n,I(di,{size:14,className:`settings-setup-chevron`,"aria-hidden":`true`})]},e.label):I(`div`,{className:`settings-setup-row is-fact`,children:n},e.label)})]},e.title)),x&&I(tX,{title:e(`settings.setup.confirmTitle`),confirmLabel:e(`settings.setup.confirmYes`),cancelLabel:e(`setup.again.notNow`),onConfirm:()=>{S(!1),n(),r(!0)},onCancel:()=>S(!1),children:I(`p`,{children:e(`settings.setup.confirmBody`)})})]})}var p$=[{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 m$(){let e=L(),t=B(e=>e.openSettings),n=`GAIA v0.27.0rc21`,[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(null),s=(0,V.useRef)(null);(0,V.useEffect)(()=>()=>{s.current&&clearTimeout(s.current)},[]);let c=(0,V.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 R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.about`)}),R(`section`,{className:`settings-card`,"aria-labelledby":`about-version`,children:[R(`div`,{className:`settings-row settings-row-between`,children:[R(`span`,{children:[I(`strong`,{id:`about-version`,children:I(`bdi`,{dir:`ltr`,children:n})}),` `,I(`span`,{className:`beta-badge`,children:`BETA`})]}),R(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void c(),children:[I(r?ri:Fi,{size:13,"aria-hidden":`true`}),e(r?`settings.about.copied`:`settings.about.copy`)]})]}),I(`p`,{className:`settings-hint`,children:e(`settings.advanced.about`)}),a&&I(`p`,{className:`settings-error`,role:`alert`,children:a})]}),R(`section`,{className:`settings-card`,"aria-label":e(`settings.about.links`),children:[I(`ul`,{className:`settings-about-links`,children:p$.map(t=>I(`li`,{children:R(`a`,{href:t.href,target:`_blank`,rel:`noopener noreferrer`,children:[e(t.label),` `,I(Zi,{size:12,"aria-hidden":`true`})]})},t.href))}),R(`p`,{className:`settings-hint`,children:[e(`settings.about.reportHint`),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>t(`privacy`),children:e(`settings.about.reportWhere`)})]})]})]})}var h$=class extends V.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?I(g$,{variant:this.props.variant??`fill`,onRetry:()=>this.setState({hasError:!1})}):this.props.children}};function g$({onRetry:e,variant:t}){let n=L();return R(`div`,{role:`alert`,className:`error-boundary error-boundary-${t}`,children:[I(`p`,{className:`error-boundary-title`,children:n(`errorBoundary.title`)}),I(`p`,{className:`error-boundary-body`,children:n(t===`window`?`errorBoundary.bodyWindow`:`errorBoundary.body`)}),R(`div`,{className:`error-boundary-actions`,children:[I(`button`,{type:`button`,className:`btn-primary`,onClick:e,children:n(`errorBoundary.retry`)}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>window.location.reload(),children:n(`errorBoundary.reload`)})]})]})}var _$=`modulepreload`,v$=function(e,t){return new URL(e,t).href},y$={},b$=function(e){return e.pathname.endsWith(`.css`)},x$=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},S$=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=v$(t,n);let r=s(t),i=b$(r);return x$(y$,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`:_$,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)})},C$=(0,V.lazy)(()=>S$(()=>import(`./ConnectorsPane-DdYiHRhD.js`).then(e=>({default:e.ConnectorsPane})),__vite__mapDeps([0,1,2,3]),import.meta.url)),w$=(0,V.lazy)(()=>S$(()=>import(`./MessagingSettings-BHd7ftWx.js`).then(e=>({default:e.MessagingSettings})),__vite__mapDeps([4,1,2]),import.meta.url)),T$=(0,V.lazy)(()=>S$(()=>import(`./AutomationsSettings-rLo6mWU6.js`).then(e=>({default:e.AutomationsSettings})),__vite__mapDeps([5,1,2]),import.meta.url)),E$=(0,V.lazy)(()=>S$(()=>import(`./AdvancedSettings-DD-RVnWp.js`).then(e=>({default:e.AdvancedSettings})),__vite__mapDeps([6,1,2]),import.meta.url)),D$=[`general`,`setup`,`model`,`images`,`permissions`,`skills`,`connectors`,`messaging`,`automations`,`memory`,`notifications`,`voice`,`privacy`,`advanced`,`about`];function O$({onUseSkill:e}){let t=L(),n=B(e=>e.settingsSection),r=B(e=>e.openSettings),i=B(e=>e.closeSettings),a=B(e=>e.settingsJump),o=(0,V.useRef)(null),s=(0,V.useRef)(null),c=n!==null;if(Qn(c,i),_n(o,c),FJ(o,c,()=>o.current?.querySelector(`.settings-nav-item.is-active`)),(0,V.useLayoutEffect)(()=>{s.current&&(s.current.scrollTop=0)},[n]),(0,V.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=D$.indexOf(n),i=e.key===`ArrowDown`?(t+1)%D$.length:e.key===`ArrowUp`?(t-1+D$.length)%D$.length:e.key===`Home`?0:e.key===`End`?D$.length-1:null;i!==null&&(e.preventDefault(),r(D$[i]),o.current?.querySelector(`[data-section="${D$[i]}"]`)?.focus())},d=(()=>{switch(n){case`general`:return I(oQ,{});case`setup`:return I(f$,{});case`model`:return I(kQ,{});case`images`:return I(FQ,{});case`permissions`:return I(IQ,{});case`skills`:return I(GQ,{onUseSkill:t=>{i(),e(t)}});case`connectors`:return I(C$,{});case`messaging`:return I(w$,{});case`automations`:return I(T$,{});case`memory`:return I(JQ,{});case`notifications`:return I(i$,{});case`voice`:return I(u$,{});case`privacy`:return I($Q,{});case`advanced`:return I(E$,{});case`about`:return I(m$,{})}})();return I(`div`,{className:`settings-overlay`,onMouseDown:e=>{e.target===e.currentTarget&&i()},children:R(`div`,{ref:o,className:`settings-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`settings.title`),children:[R(`nav`,{className:`settings-nav`,"aria-label":t(`settings.sections`),onKeyDown:u,children:[I(`h1`,{className:`settings-nav-title`,children:t(`settings.title`)}),D$.map(e=>I(`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))]}),R(`div`,{className:`settings-body`,children:[I(`button`,{type:`button`,className:`settings-close`,onClick:i,"aria-label":t(`settings.close`),children:I(fc,{size:18})}),l&&R(`button`,{type:`button`,className:`settings-back`,onClick:()=>{r(l),o.current?.querySelector(`[data-section="${l}"]`)?.focus()},children:[I(li,{size:14,"aria-hidden":`true`}),t.compose(e=>e(`settings.backTo`,{section:e(`settings.section.${l}`)}))]}),I(`div`,{ref:s,className:`settings-scroll`,children:I(h$,{area:`settings.${n}`,children:I(V.Suspense,{fallback:R(`p`,{className:`settings-hint`,children:[I(so,{size:13,className:`spin`}),` `,t(`settings.loading`)]}),children:d})},n)})]})]})})}var k$=`gaia:personalize-connector`,A$=[[`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 j$(e,t){let n=e.toLowerCase().replace(/^mcp-/,``),r=A$.find(([e])=>n.startsWith(e));return r?r[1]:`my recent activity in ${t}`}function M$(e){let t=e.toLowerCase().replace(/^mcp-/,``),n=A$.find(([e])=>t.startsWith(e));return n?n[0]:null}function N$({connectorId:e,displayName:t}){return[`I just connected ${t}. Get to know me from ${j$(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(`
|
|
216
|
+
`)})]})]}),ar&&I(`p`,{className:`setup-error`,role:`alert`,children:n(`setup.summary.short`,{need:PA(ar.needGb),free:PA(ar.freeGb),drive:n(`setup.summary.theDrive`),freeUp:PA(ar.freeUpGb)})}),(xe??O)&&I(NZ,{text:xe??O}),wn!==`cloud`&&R(`details`,{className:`setup-disclosure`,children:[I(`summary`,{children:n(`setup.plan.whatDownloads`)}),I(vX,{plan:j,models:ir})]})]}),dr===`gpu`&&fe&&R(P.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.gpu.title`)}),I(`p`,{className:`setup-lede`,children:n(`setup.gpu.lede`)}),I(uX,{status:fe,onStatus:N,mode:`setup`,headingId:`setup-title`,names:Yn,cloud:o!==`local`,onBack:Pn,onSkip:()=>vn(f),onContinue:()=>vn(f)})]}),dr===`models`&&R(P.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.models.title`)}),j&&se&&I(UX,{plan:j,selection:se,onSelection:ce,disabled:ye||Pr,onRecheck:()=>void Nt()}),Mn&&fe?.total_gb!=null&&fe.gpu_gb!=null&&R(`p`,{className:`setup-hint setup-gpu-option`,children:[n(`setup.models.gpu`,{gpu:PA(fe.gpu_gb),total:PA(fe.total_gb)}),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>Fn(`models`),disabled:ye||Pr,children:n(`setup.found.changeMemory`)})]}),I(JV,{disabled:ye||Pr,pending:Kt?.id??null,onPending:Jt,headingId:LZ}),I(dX,{plan:j,planError:ae,onRetryPlan:()=>void Nt(),onUseRecommended:()=>void Vt(!1,{keepTrying:pe}),selection:se,onSelection:ce,cloud:!1,keepTrying:pe,onKeepTrying:me,onBack:Pn,onContinue:e=>void _n(e),busy:ye||Pr,error:xe??O})]}),dr===`key`&&R(`form`,{id:`setup-key-form`,onSubmit:e=>{e.preventDefault(),Un()},className:`setup-form`,children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.key.title`)}),I(VV,{className:`setup-choices`,"aria-label":n(`setup.key.provider`),children:wZ.filter(e=>e.id!==`local`&&(e.id!==`amd`||vt)).map(e=>R(`button`,{type:`button`,role:`radio`,"aria-checked":o===e.id,className:`setup-choice${o===e.id?` is-active`:``}${xt(e.id)?` is-disabled`:``}`,onClick:()=>Gn(e.id),disabled:ne.busy||xt(e.id),title:_t(e.id)?n(`settings.privacy.localOnlyBlocked`):void 0,children:[I(ki,{size:16,"aria-hidden":`true`}),R(`span`,{children:[I(`span`,{className:`setup-choice-title`,children:I(`bdi`,{children:TZ(e,n)})}),I(`span`,{className:`setup-choice-note`,children:xt(e.id)?St(e.id):n(e.note)})]})]},e.id))}),dt?.reachable===!1&&vt&&I(`button`,{type:`button`,className:`link-btn setup-start`,onClick:pt,children:n(`setup.key.checkAgain`)}),_t(o)&&I(`p`,{className:`setup-a11y-alert`,role:`alert`,children:n(`settings.privacy.localOnlyBlocked`)}),o===`fireworks`&&!Ve&&!_t(o)&&R(`section`,{className:`setup-card`,children:[I(`h3`,{className:`mc-job-title`,children:n(`setup.key.getOne`)}),R(`ol`,{className:`setup-key-steps`,children:[I(`li`,{children:I(`a`,{href:SZ,target:`_blank`,rel:`noreferrer`,children:n(`setup.key.step1`)})}),I(`li`,{children:n(`setup.key.step2`)}),I(`li`,{children:n(`setup.key.step3`)})]})]}),o===`amd`&&!Ve&&!_t(o)&&I(`section`,{className:`setup-card`,children:I(`p`,{className:`setup-hint`,children:I(`a`,{href:CZ,target:`_blank`,rel:`noreferrer`,children:n(`setup.key.gatewayHelp`)})})}),!_t(o)&&I(QJ,{provider:o,limit:3,picked:Oe,onPick:Ae,onDefault:Me,pickDisabled:ne.busy||Pr}),!Ve&&R(P.Fragment,{children:[I(`label`,{className:`setup-key-label`,htmlFor:`setup-key-input`,children:n(`setup.key.labelFor`,{provider:TZ(wZ.find(e=>e.id===o)??wZ[1],n)})}),R(`div`,{className:`setup-row setup-key-row`,children:[I(`input`,{id:`setup-key-input`,className:`settings-input`,type:Ne?`text`:`password`,autoComplete:`off`,spellCheck:!1,value:k,onChange:e=>A(e.target.value),placeholder:yt?n.bare(`setup.key.placeholder`):n.bare(`setup.key.placeholderNew`)}),I(`button`,{type:`button`,className:`btn-secondary setup-key-show`,"aria-label":n(Ne?`setup.key.hide`:`setup.key.show`),title:n(Ne?`setup.key.hide`:`setup.key.show`),onClick:()=>Pe(e=>!e),children:I(Ne?$i:ta,{size:14,"aria-hidden":`true`})})]})]}),I(`p`,{className:`setup-hint`,children:n(Ve?`setup.key.usersServer`:`setup.key.where`)}),gt&&!Ve&&!k&&I(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.key.foundEnv`,{name:gt.name,hint:gt.key_hint??``})}),ne.busy&&!ne.waiting&&I(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.key.testing`)}),ne.busy&&ne.waiting&&I(`p`,{className:`setup-hint`,role:`status`,children:ne.waiting}),ne.error&&I(`p`,{className:`setup-error`,role:`alert`,children:ne.error}),R(eX,{children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:yn,disabled:ne.busy,children:n(`setup.back`)}),R(`button`,{type:`submit`,form:`setup-key-form`,className:`btn-primary`,disabled:ne.busy||xt(o)||Pr,children:[ne.busy&&I(so,{size:13,className:`spin`}),` `,n(`setup.key.connect`)]})]})]}),dr===`download`&&!Et&&R(P.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.download.title`)}),I(`p`,{className:`setup-lede`,children:n(`setup.download.lede`)}),zr,Rr??R(`p`,{className:`setup-hint`,role:`status`,children:[I(so,{size:13,className:`spin`,"aria-hidden":`true`}),` `,n(`setup.download.starting`)]})]}),dr===`download`&&Et&&R(P.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.download.title`)}),I(`p`,{className:`setup-lede`,children:n(`setup.download.lede`)}),zr,j&&I(`section`,{className:`setup-card`,"aria-label":n(`setup.contents.title`),children:I(vX,{plan:j,run:Et,onRetry:Ut,retryDisabled:ye})}),(Et.models?.length??0)>0?I(`div`,{className:ee?`is-stale`:void 0,children:I(AX,{status:{...Et,overall:MY(Et,le??j)},names:Yn,freeGb:j?.disk?.free_gb??null,onCancel:()=>void Ln(),onRetry:(e,t)=>void Rn(e,t),onResume:e=>void Rn(e,null),onResumeAll:Ut,onFinishWithout:nr.length>0&&!rr?()=>void Vn(nr):void 0,onSkip:e=>void zn(e),onRestart:()=>void Hn(),busy:ye||!!ee,retryLater:Dt,labelledBy:`setup-title`})}):Dt?R(P.Fragment,{children:[I(jX,{run:Et,plan:j,idle:n(`setup.download.working`)}),I(eX,{children:I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void Ln(),disabled:ye,children:n(`setup.progress.cancel`)})})]}):null,Ur.length>0&&R(`section`,{className:`setup-card`,"aria-label":n(`setup.optional.title`),children:[I(`h3`,{className:`mc-job-title`,children:n(`setup.optional.title`)}),I(`p`,{className:`setup-hint`,children:n(`setup.optional.lede`)}),I(`ul`,{className:`setup-rows`,children:Ur.map(e=>{let t=Le.includes(e.id)||Br.includes(e.id);return R(`li`,{className:`setup-result is-waiting`,children:[I(`span`,{className:`setup-result-label`,children:n(`setup.purpose.${e.roles[0]}`)}),R(`span`,{className:`setup-result-value`,children:[I(`bdi`,{dir:`ltr`,children:e.size_gb==null?n(`setup.contents.sizeOnDownload`):PA(e.size_gb)}),I(`button`,{type:`button`,className:`btn-secondary`,"aria-pressed":t,disabled:Br.includes(e.id),onClick:()=>Re(n=>t?n.filter(t=>t!==e.id):[...n,e.id]),children:n(t?`setup.optional.added`:`setup.optional.add`)})]})]},e.id)})})]}),ee&&R(P.Fragment,{children:[I(`p`,{className:`setup-error`,role:`alert`,children:n(`setup.lostContact`,{error:ee})}),I(eX,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void zt(),children:n(`setup.reconnect`)})})]}),Xn&&er&&!rr&&Et.state===`failed`&&!Et.model_failed&&(Et.problem?I(MZ,{problem:Et.problem,onRetry:Ut,onUseGaia:()=>void Vt(!0,Ye.current.options)}):R(`div`,{className:`setup-error`,role:`alert`,children:[I(`p`,{children:n(`setup.download.stoppedBeforeCheck`)}),Et.error&&R(`details`,{className:`dl-details`,children:[I(`summary`,{children:n(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:Et.error})]})]})),Xn&&er&&!rr&&R(P.Fragment,{children:[I(`p`,{className:`setup-hint`,children:n(`setup.download.finishNote`)}),I(eX,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:Ut,disabled:ye,children:n(`setup.finish`)})})]}),nr.length>0&&!rr&&I(`p`,{className:`setup-hint`,children:n(`setup.download.extrasLeftNote`,{names:nr.map(e=>Yn[e]??e).join(`, `)})}),Xn&&!er&&!rr&&!(Et.models??[]).some(e=>e.state===`failed`||e.state===`cancelled`)&&R(P.Fragment,{children:[I(PZ,{run:Et}),Et.problem?I(MZ,{problem:Et.problem,onRetry:Ut,onUseGaia:()=>void Vt(!0,Ye.current.options)}):I(eX,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Vt(!!Et.gaia_lemonade,Ye.current.options),children:n(`setup.tryAgain`)})})]}),(xe||O)&&I(NZ,{text:xe??O})]}),dr===`test`&&Et&&R(P.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.test.title`)}),I(`p`,{className:`setup-lede`,children:n(`setup.test.lede`)}),I(xZ,{run:Et,expected:Fr,names:Yn,catalog:z,onRetry:Ut,onChooseAnother:Ct?void 0:bn,onCancel:()=>void Ln(),onDownloadAgain:j?.lemonade.mode===`external`?void 0:e=>void Rn(e,`verify`),busy:ye}),Xn&&Et.error&&!(Et.tests??[]).some(e=>e.error===Et.error)&&R(`details`,{className:`dl-details`,children:[I(`summary`,{children:n(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:Et.error})]}),(xe||O)&&I(NZ,{text:xe??O})]}),dr===`ready`&&R(P.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.ready.heading`)}),R(`div`,{className:`setup-done`,role:`status`,children:[I(`div`,{className:`setup-done-head`,children:qn&&I(`p`,{children:n(Ct?`setup.ready.answersCloud`:`setup.ready.answersLocal`,{model:Ct?el(qn):Yn[qn]??M?.catalog?.find(e=>e.id===qn)?.name??el(qn)})})}),I(eX,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Jn(),autoFocus:!0,children:n(`setup.ready.start`)})}),!Ct&&M&&I(fX,{plan:M,chatModel:qn,gpu:fe}),O&&I(NZ,{text:O}),(Et?.tests??[]).filter(e=>e.state===`failed`).map(e=>I(`p`,{className:`setup-failed-extra`,role:`alert`,children:n(`setup.ready.extraFailed`,{job:n(`setup.test.job.${e.job}`)})},`${e.job}:${e.subject??``}`)),Vr.length>0&&I(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.ready.extraDownloading`,{names:Vr.map(e=>Yn[e]??e).join(`, `)})}),Hr.length>0&&!he&&I(`p`,{className:`setup-failed-extra`,role:`alert`,children:n(`setup.ready.extraNotFetched`,{names:Hr.map(e=>Yn[e]??e).join(`, `)})}),Qn.length>0&&R(P.Fragment,{children:[I(`p`,{className:`setup-hint`,children:n(`setup.ready.tasks`)}),I(fJ,{cards:Qn,onPick:e=>void Jn(e)})]})]})]}),T?.state===`failed`&&I(dZ,{})]},dr),t&&!Dt&&dr!==`plan`&&dr!==`ready`&&I(`div`,{className:`setup-row`,children:I(`button`,{type:`button`,className:`link-btn setup-close`,onClick:t,children:n(`setup.backToGaia`)})}),Pr&&(Nr||dr===`plan`)&&I(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.nav.runGoing`)}),I(IX,{run:T,before:{check:wr},failed:Zn})]})}),I(`div`,{className:`setup-footer`,ref:h})]})}),he?.kind===`no_fit`&&I(tX,{title:kY(he.models)?n(`setup.confirm.tightOne`,{name:he.models[0].name}):he.models.length===1?n(`setup.confirm.noFitOne`,{name:he.models[0].name}):n(`setup.confirm.noFitMany`),confirmLabel:kY(he.models)?n(`setup.confirm.useAnyway`):n(`setup.confirm.downloadAnyway`),cancelLabel:n(`setup.confirm.pickSmaller`),onConfirm:()=>{ge(null),ve(!0),_n(Wt,!0)},onCancel:()=>ge(null),children:he.models.map(e=>R(`p`,{children:[I(`bdi`,{children:e.name}),`: `,zY(e,n)]},e.id))}),he?.kind===`low_disk`&&ar&&I(tX,{title:n(`setup.confirm.lowDiskTitle`),confirmLabel:n(`setup.confirm.downloadAnyway`),cancelLabel:n(`setup.confirm.changeModels`),onConfirm:()=>{ge(null),_n(!0)},onCancel:()=>{ge(null),bn()},children:I(`p`,{children:n(`setup.summary.short`,{need:PA(ar.needGb),free:PA(ar.freeGb),drive:n(`setup.summary.theDrive`),freeUp:PA(ar.freeUpGb)})})}),he?.kind===`server`&&I(tX,{title:he.detail.code===`low_disk`?n(`setup.confirm.lowDiskTitle`):n(`setup.confirm.noFitServerTitle`),confirmLabel:he.detail.code===`low_disk`?n(`setup.confirm.downloadAnyway`):n(`setup.confirm.useAnyway`),cancelLabel:n(`setup.confirm.changeModels`),onConfirm:()=>{let e=he;if(ge(null),e.then===`chat`)ve(!0),_n(Wt,!0);else if(e.then===`retry`)Nn(e.id,{keepTrying:pe,acknowledgeLowDisk:!0}).then(t=>{E(t),Be(t=>t.filter(t=>t!==e.id))}).catch(e=>Se(WZ(e)));else{let{gaiaLemonade:e,options:t}=Ye.current;Vt(e,{...t,acknowledgeLowDisk:!0})}},onCancel:()=>{let e=he;ge(null),e.then!==`retry`&&!Ot&&bn()},children:I(`p`,{children:he.detail.message})})]})}function KZ({title:e,titleId:t,count:n,hint:r,defaultOpen:i=!1,forceOpen:a=!1,targetId:o,children:s}){let[c,l]=(0,V.useState)(i);return R(`details`,{className:`settings-disclosure`,"data-settings-target":o,open:c||a,onToggle:e=>{a||l(e.currentTarget.open)},children:[R(`summary`,{onClick:e=>{a&&e.preventDefault()},children:[I(si,{size:15,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),R(`span`,{className:`settings-disclosure-text`,children:[I(`span`,{className:`settings-disclosure-title`,id:t,tabIndex:t?-1:void 0,children:e}),r&&I(`span`,{className:`settings-disclosure-hint`,children:r})]}),n!=null&&I(`bdi`,{dir:`ltr`,className:`settings-disclosure-count`,children:n})]}),I(`div`,{className:`settings-disclosure-body`,children:s})]})}var qZ=M(Mu()?`settings.desktop.menuBar`:`settings.desktop.tray`),JZ=[{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`}],YZ=new Set([`startMinimized`]),XZ={minimizeToTray:`settings.desktop.keepRunningNoTray`};function ZZ(e){return e?.reason===`no-host`?`settings.desktop.noTray`:e?.reason===`check-failed`?`settings.desktop.noTrayCheckFailed`:null}function QZ(){let e=L(),t=window.gaiaAPI?.tray,[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(null);(0,V.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,V.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=ZZ(i);return I(KZ,{title:e(`settings.desktop.title`),children:R(`div`,{className:`settings-field`,role:`group`,"aria-labelledby":`desktop-app-label`,children:[I(`span`,{className:`settings-label`,id:`desktop-app-label`,children:e(`settings.desktop.title`)}),JZ.map(({key:t,label:r,hint:i})=>{let a=YZ.has(t)?d:null,o=d&&XZ[t]||i;return R(`div`,{children:[R(`label`,{className:`setting-row`,children:[I(`span`,{children:e(r,{tray:qZ})}),R(`span`,{className:`toggle-switch`,children:[I(`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:qZ})}),I(`span`,{className:`toggle-track`})]})]}),I(`p`,{className:`settings-hint`,id:`desktop-${t}-hint`,children:a?e(a):e(o,{tray:qZ})})]},t)}),o&&I(`p`,{className:`settings-error`,role:`alert`,children:o})]})})}function $Z({onClose:e,manualInstall:t=!1}){let n=L(),[r,i]=(0,V.useState)({kind:`loading`}),a=(0,V.useRef)(null);(0,V.useEffect)(()=>{let e=iZ();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.`})},[]),Qn(!0,e),_n(a,!0),(0,V.useEffect)(()=>{let e=a.current;e&&e.querySelector(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)?.focus()},[]),(0,V.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=iZ();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:lZ(e)})})}}function c(e){if(!e)return``;try{return new Date(e).toLocaleDateString(Fn(n),{year:`numeric`,month:`short`,day:`numeric`})}catch{return e}}return I(`div`,{className:`version-picker-overlay`,onClick:t=>{t.target===t.currentTarget&&e()},children:R(`div`,{className:`version-picker-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":n(`update.picker.title`),ref:a,children:[R(`div`,{className:`version-picker-header`,children:[I(`h3`,{children:n(`update.picker.title`)}),I(`button`,{className:`version-picker-close`,onClick:e,"aria-label":n(`update.picker.close`),type:`button`,children:`×`})]}),R(`div`,{className:`version-picker-body`,children:[r.kind===`loading`&&R(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[I(`span`,{className:`version-picker-spinner`}),n(`update.picker.loading`)]}),r.kind===`error`&&R(`div`,{className:`version-picker-error`,children:[I(`p`,{children:r.message}),I(`p`,{children:I(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:n(`update.picker.browse`)})})]}),r.kind===`list`&&I(`ul`,{className:`version-picker-list`,role:`listbox`,"aria-label":n(`update.picker.listAria`),children:r.releases.map(e=>I(`li`,{children:R(`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:[I(`span`,{className:`vp-version`,children:e.version}),I(`span`,{className:`vp-date`,children:c(e.date)}),e.isCurrent&&I(`span`,{className:`vp-badge vp-badge-current`,children:n(`update.picker.installed`)}),e.isPinned&&!e.isCurrent&&I(`span`,{className:`vp-badge vp-badge-pinned`,children:n(`update.picker.pinned`)}),!e.isCurrent&&I(`span`,{className:`vp-arrow`,"aria-hidden":`true`,children:`›`})]})},e.tag))}),r.kind===`list`&&R(`p`,{className:`version-picker-more`,children:[n(`update.picker.recent`,{n:r.releases.length}),` `,I(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:n(`update.picker.browseAll`)})]}),r.kind===`confirm`&&R(`div`,{className:`version-picker-confirm`,children:[t?I(`p`,{children:n(`update.picker.manual`,{version:r.release.version})}):R(P.Fragment,{children:[I(`p`,{children:n(`update.picker.confirm`,{version:r.release.version})}),I(`p`,{className:`vp-confirm-note`,children:n(`update.picker.confirmNote`,{version:r.release.version})})]}),R(`div`,{className:`vp-confirm-actions`,children:[I(`button`,{type:`button`,className:`vp-btn-cancel`,onClick:()=>i({kind:`list`,releases:r.releases}),children:n(`update.picker.back`)}),t?I(`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`)}):I(`button`,{type:`button`,className:`vp-btn-confirm`,onClick:()=>s(r.release),children:n(`update.picker.install`)})]})]}),r.kind===`installing`&&R(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[I(`span`,{className:`version-picker-spinner`}),n(`update.picker.starting`)]})]})]})})}var eQ=`https://github.com/amd/gaia/releases`;function tQ(e){return/^\d+\.\d+\.\d+-/.test(e??``)}function nQ(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 rQ(){let e=oZ(),t=L(),n=iZ(),[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(null),[s,c]=(0,V.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:M(e),reason:lZ(n)}))}finally{i(!1)}}}let u=e.status===`disabled`,d=r||e.status===`checking`||e.status===`downloading`,f=e.readFailed?nQ(e,t):`${t(`update.settings.running`,{version:e.currentVersion??t(`update.settings.unknownVersion`)})} ${nQ(e,t)}`,p=[`available`,`downloaded`,`error`].includes(e.status)||!!e.pinnedVersion||!!e.installFailed||!!e.configError||!!e.readFailed||!!a;return I(KZ,{title:t(`update.settings.title`),titleId:`updates-label`,hint:f,forceOpen:p,children:R(`div`,{className:`settings-field`,role:`group`,"aria-labelledby":`updates-label`,children:[I(`p`,{className:`visually-hidden`,role:`status`,children:f}),!e.manualInstall&&R(P.Fragment,{children:[R(`label`,{className:`setting-row`,children:[I(`span`,{children:t(`update.settings.auto`)}),R(`span`,{className:`toggle-switch`,children:[I(`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))}}),I(`span`,{className:`toggle-track`})]})]}),I(`p`,{className:`settings-hint`,id:`updates-auto-hint`,children:t(`update.settings.autoHint`)})]}),R(`label`,{className:`setting-row`,children:[I(`span`,{children:t(`update.settings.rc`)}),R(`span`,{className:`toggle-switch`,children:[I(`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))}}),I(`span`,{className:`toggle-track`})]})]}),R(`p`,{className:`settings-hint`,id:`updates-rc-hint`,children:[t(`update.settings.rcHint`),tQ(e.currentVersion)&&` ${t(`update.settings.rcHintRunning`)}`]}),e.pinnedVersion&&R(`p`,{className:`settings-hint`,children:[t(`update.settings.pinned`,{version:e.pinnedVersion}),` `,I(`button`,{type:`button`,className:`btn-secondary`,disabled:r,onClick:()=>void l(`update.action.resume`,e=>e.resumeUpdates()),children:t(`update.settings.unpin`)})]}),R(`div`,{className:`setting-actions`,children:[e.status===`available`&&e.manualInstall&&I(`a`,{className:`btn-primary update-download-link`,href:e.downloadUrl??eQ,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&&I(`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`&&I(`button`,{type:`button`,className:`btn-primary`,disabled:r,onClick:()=>void l(`update.action.restart`,e=>e.restart()),children:t(`update.settings.restart`)}),e.readFailed?I(`button`,{type:`button`,className:`btn-secondary`,disabled:r,onClick:async()=>{i(!0);try{await e.reload()}finally{i(!1)}},children:t(`update.settings.retryRead`)}):I(`button`,{type:`button`,className:`btn-secondary`,disabled:d||u,onClick:()=>void l(`update.action.check`,e=>e.check()),children:t(`update.settings.check`)}),I(`button`,{type:`button`,className:`btn-secondary`,disabled:d||u,onClick:()=>c(!0),children:t(`update.settings.pick`)}),e.previousVersion&&I(`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&&I(`p`,{className:`settings-hint`,id:`updates-manual-hint`,children:t(`update.settings.manualHint`)}),e.previousVersion&&I(`p`,{className:`settings-hint`,id:`updates-back-hint`,children:t(`update.settings.goBackHint`)}),e.installFailed&&I(`p`,{className:`settings-error`,role:`alert`,children:t(`update.settings.installFailed`,{...e.installFailed,url:eQ})}),e.lastCheckError&&I(`p`,{className:`settings-hint`,children:t(`update.settings.lastCheckError`,{reason:e.lastCheckError})}),e.configError&&I(`p`,{className:`settings-error`,role:`alert`,children:e.configError}),a&&I(`p`,{className:`settings-error`,role:`alert`,children:a}),s&&I($Z,{onClose:()=>c(!1),manualInstall:e.manualInstall})]})})}var iQ=[{value:`light`,label:`settings.theme.light`},{value:`dark`,label:`settings.theme.dark`},{value:`system`,label:`settings.theme.system`}],aQ={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 oQ(){let e=L(),t=B(e=>e.locale),n=B(e=>e.setLocale),i=B(e=>e.themePreference),a=B(e=>e.setThemePreference),o=B(e=>e.palette),s=B(e=>e.setPalette),c=B(e=>e.customColors),l=B(e=>e.setCustomColors),u=SK(e=>e.visible),d=SK(e=>e.setVisible),f=e=>t=>l({...c,[e]:t.target.value.toUpperCase()});return R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.general`)}),R(`div`,{className:`settings-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`ui-language`,children:e(`settings.language`)}),I(`select`,{id:`ui-language`,className:`settings-input`,value:t,onChange:e=>n(e.target.value),children:je.map(({meta:e})=>I(`option`,{value:e.code,lang:e.code,dir:e.dir,children:Ye(e)},e.code))}),I(`span`,{className:`settings-hint`,children:e(`settings.languageHint`)})]}),R(`div`,{className:`settings-field`,children:[I(`span`,{className:`settings-label`,id:`appearance-label`,children:e(`settings.appearance`)}),I(VV,{className:`segmented`,"aria-labelledby":`appearance-label`,children:iQ.map(t=>I(`button`,{type:`button`,role:`radio`,"aria-checked":i===t.value,className:i===t.value?`is-active`:``,onClick:()=>a(t.value),children:e(t.label)},t.value))})]}),R(`div`,{className:`settings-field`,children:[R(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`resources.settings`)}),R(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked),"aria-label":e(`resources.settings`),"aria-describedby":`resources-hint`}),I(`span`,{className:`toggle-track`})]})]}),I(`span`,{className:`settings-hint`,id:`resources-hint`,children:e(`resources.settingsHint`)})]}),R(KZ,{title:e(`settings.colors`),titleId:`palette-label`,defaultOpen:o===`custom`,children:[R(VV,{className:`palette-grid`,"aria-labelledby":`palette-label`,children:[r.map(t=>R(`button`,{type:`button`,role:`radio`,"aria-checked":o===t.id,className:`palette-tile${o===t.id?` is-active`:``}`,onClick:()=>s(t.id),children:[I(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:t.swatch.map(e=>I(`i`,{style:{background:e}},e))}),e(aQ[t.id])]},t.id)),R(`button`,{type:`button`,role:`radio`,"aria-checked":o===`custom`,className:`palette-tile${o===`custom`?` is-active`:``}`,onClick:()=>s(`custom`),children:[R(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:[I(`i`,{style:{background:c.base}}),I(`i`,{style:{background:c.accent}})]}),e(`settings.colors.custom`)]})]}),o===`custom`&&R(`div`,{className:`palette-custom`,children:[R(`label`,{className:`palette-color`,htmlFor:`custom-accent`,children:[I(`input`,{id:`custom-accent`,type:`color`,value:c.accent,onChange:f(`accent`)}),R(`span`,{children:[e(`settings.colors.accent`),I(`small`,{children:e(`settings.colors.accentHint`)})]})]}),R(`label`,{className:`palette-color`,htmlFor:`custom-base`,children:[I(`input`,{id:`custom-base`,type:`color`,value:c.base,onChange:f(`base`)}),R(`span`,{children:[e(`settings.colors.base`),I(`small`,{children:e(`settings.colors.baseHint`)})]})]}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>l(De),children:e(`settings.colors.reset`)}),I(`p`,{className:`settings-hint`,children:e(`settings.colors.hint`)})]})]}),I(QZ,{}),I(rQ,{}),I(KZ,{title:e(`settings.shortcuts`),children:I(`dl`,{className:`shortcut-list`,children:YJ().map(({label:t,keys:n})=>R(`div`,{className:`shortcut-row`,children:[I(`dt`,{children:I(`kbd`,{children:Iu(n)})}),I(`dd`,{children:e(t)})]},t))})})]})}function sQ(e){return/not reachable|not answering|model server at|ConnectionPool|NewConnectionError|Connection refused|Max retries/i.test(e)}function cQ(e){return/gaia init/i.test(e??``)}var lQ=`GAIA doesn't run this model server, so it can't start it. Start it the way you usually do.`,uQ=/^The model server GAIA uses is at (\S+)\. (.*)$/s;function dQ(e,t){if(!t)return null;if(t===lQ)return e(`server.otherServerStart`);let n=uQ.exec(t);return n&&n[2]===lQ?`${e(`server.chosenServerAt`,{address:n[1]})} ${e(`server.otherServerStart`)}`:t}function fQ(e){return!!e&&!e.lemonade_running&&(cQ(e.start_command)||cQ(e.start_instruction))}function pQ({className:e=`btn-secondary`}){let t=L();return I(`button`,{type:`button`,className:e,onClick:()=>window.dispatchEvent(new CustomEvent(`gaia:set-up-local`)),children:t(`settings.errors.setUpLocal`)})}function mQ({message:e,onRetry:t}){let n=L(),r=B(e=>fQ(e.systemStatus));return sQ(e)?R(`div`,{className:`settings-notice`,role:`alert`,children:[I(`strong`,{children:n(r?`settings.errors.notInstalledTitle`:`settings.errors.serverDownTitle`)}),I(`p`,{children:n(r?`settings.errors.notInstalled`:`settings.errors.serverDown`)}),r&&I(pQ,{className:`btn-primary`}),t&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:t,children:n(`settings.key.checkAgain`)}),R(`details`,{className:`settings-more`,children:[R(`summary`,{children:[I(si,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,n(`settings.errors.details`)]}),I(`bdi`,{dir:`ltr`,className:`settings-notice-raw`,children:e})]})]}):I(`p`,{className:`settings-error`,role:`alert`,children:e})}function hQ({onAdded:e}){let t=L(),[n,r]=(0,V.useState)(``),[i,a]=(0,V.useState)(``),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(null),f=(0,V.useRef)(``),p=(0,V.useCallback)(async e=>{let t=n.trim();f.current=t,l(`check`),d(null);try{let n=await nr(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,V.useCallback)(async()=>{l(`add`),d(null);try{let{report:o}=await Zn(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 R(`form`,{className:`settings-field custom-model-add`,onSubmit:e=>{e.preventDefault(),p(``)},children:[I(`label`,{className:`visually-hidden`,htmlFor:`custom-model-url`,children:t(`settings.custom.title`)}),I(`span`,{className:`settings-hint`,children:t(`settings.custom.hint`)}),R(`div`,{className:`settings-row`,children:[I(`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`}),R(`button`,{type:`submit`,className:`btn-secondary`,disabled:c!==null||!n.trim(),children:[c===`check`?I(so,{size:13,className:`spin`}):null,` `,t(`settings.custom.check`)]})]}),o&&(()=>{let e=I(`ul`,{className:`custom-model-checks`,"aria-label":t(`settings.custom.checks`),children:o.checks.map(e=>R(`li`,{className:e.ok?`is-ok`:`is-failed`,children:[e.ok?I(ri,{size:13,"aria-label":t(`settings.custom.passed`)}):I(fc,{size:13,"aria-label":t(`settings.custom.failed`)}),R(`bdi`,{children:[I(`strong`,{children:e.label}),` — `,e.detail]})]},e.id))});return o.ok?R(`details`,{className:`custom-model-checks-summary`,children:[R(`summary`,{children:[I(ri,{size:13,"aria-hidden":`true`}),` `,t(`settings.custom.allPassed`,{n:o.checks.length})]}),e]}):e})(),o&&o.warnings.length>0&&I(`ul`,{className:`custom-model-checks`,"aria-label":t(`settings.custom.warnings`),children:o.warnings.map(e=>R(`li`,{className:`is-warning`,children:[I(ec,{size:13,"aria-label":t(`settings.custom.warning`)}),` `,I(`bdi`,{children:e})]},e))}),o&&o.variants.length>1&&R(`div`,{className:`settings-row`,children:[I(`label`,{className:`settings-hint`,htmlFor:`custom-model-quant`,children:t(`settings.custom.quantization`)}),I(`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=>R(`option`,{value:e.file,children:[e.quant,` · `,e.size_gb,` GB`,e.fits?``:` · ${t.bare(`settings.custom.tooLarge`)}`]},e.file))})]}),o?.ok&&R(`div`,{className:`settings-row`,children:[R(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void m(),disabled:c!==null,children:[c===`add`?I(so,{size:13,className:`spin`}):null,` `,t(`settings.custom.add`,{name:o.display_name??``})]}),I(`span`,{className:`settings-hint`,children:t(`settings.model.sizeDownload`,{size:`${o.size_gb} GB`})})]}),u&&I(mQ,{message:u})]})}function gQ(e){return e instanceof Error?e.message:String(e)}function _Q(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function vQ({downloadsSlot:e}){let t=L(),[n,r]=(0,V.useState)(null),[i,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(null),[d,f]=(0,V.useState)(!1),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(!1),[_,v]=(0,V.useState)(null),[y,b]=(0,V.useState)(null),x=Fl(e=>e.status),S=Fl(e=>e.started),C=(0,V.useMemo)(()=>Ml(x,S),[x,S]),w=Fl(e=>e.error),T=Fl(e=>e.refresh),E=Fl(e=>e.enqueue),ee=Fl(e=>e.cancel),D=(0,V.useCallback)(async(e=!1)=>{o(null);try{let t=await a();r(t),c(n=>e||!n?bY(t):n)}catch(e){o(gQ(e))}},[]);(0,V.useEffect)(()=>{D(!0),T(),(async()=>{try{v(await tt()??null)}catch(e){b(gQ(e))}})()},[D,T]);let O=(C?.models??[]).filter(e=>e.state===`ready`).map(e=>e.id).join(`,`),te=(0,V.useRef)(O);(0,V.useEffect)(()=>{O!==te.current&&(te.current=O,D(!0))},[O,D]);let k=(0,V.useMemo)(()=>{let e={};for(let t of C?.models??[])e[t.id]=t;return e},[C]),A=(0,V.useMemo)(()=>{let e={};for(let t of n?.catalog??[])e[t.id]=t.name;return e},[n]),ne=(0,V.useMemo)(()=>n?bY(n):null,[n]),re=aY(n),j=n&&s?TY(re,s).filter(e=>k[e.id]?.state!==`downloading`):[],ie=j.reduce((e,t)=>e+(t.size_gb??0),0),ae=!!n&&!!s&&!!ne&&(!_Q(s.ticked,ne.ticked)||s.defaultChat!==ne.defaultChat||j.length>0),oe=(0,V.useCallback)(async(e,i)=>{if(!n||!s)return;if(m(null),!e){let e=OY(re,s).filter(e=>!e.downloaded||e.id===s.defaultChat);if(e.length>0&&e.every(e=>e.need_gb!=null)){u({kind:`no_fit`,models:e});return}}let a=DY(n,s);if(a&&!i)u({kind:`low_disk`,message:a.drop?t(`setup.summary.shortDrop`,{need:PA(a.needGb),free:PA(a.freeGb),drive:UY(n.disk?.path??null)??t(`setup.summary.theDrive`),freeUp:PA(a.freeUpGb),name:a.drop.name,saves:PA(a.drop.size_gb??0)}):t(`setup.summary.short`,{need:PA(a.needGb),free:PA(a.freeGb),drive:UY(n.disk?.path??null)??t(`setup.summary.theDrive`),freeUp:PA(a.freeUpGb)})});else{f(!0);try{let i=n,a=!1;if(s.defaultChat&&s.defaultChat!==i.chat_model.id){a=!0;try{i=await Ue(s.defaultChat,e||h)}catch(e){let t=Cn(e);if(t){u({kind:`server`,detail:t});return}throw e}}for(let e of AY(i,s))i=await Bn(e.id,e.skipped);let o=TY(aY(i),s).map(e=>e.id).filter(e=>k[e]?.state!==`downloading`);r(i),c({...s,defaultChat:i.chat_model.id});let l=null;if(a&&i.chat_model.downloaded)try{await Xc.getState().select(i.chat_model.id)}catch(e){l=gQ(e),Xc.getState().refresh()}else Xc.getState().refresh();o.length&&await E(o,{acknowledgeLowDisk:!0}),m(l===null?{ok:!0,text:t(`settings.models.applied`)}:{ok:!1,text:t(`settings.models.appliedNotSwitched`,{reason:l})})}catch(e){m({ok:!1,text:gQ(e)})}finally{f(!1)}}},[n,s,re,h,k,E,t]),se=(0,V.useCallback)(async e=>{u(null),f(!0),m(null);try{let n=await $t(e.id);jc(),r(n),c(bY(n)),m({ok:!0,text:t(`settings.models.removed`,{name:e.name,size:PA(n.freed_gb)})})}catch(e){m({ok:!1,text:gQ(e)})}finally{f(!1)}},[t]),ce=(0,V.useCallback)((e,t)=>{(async()=>{try{t===`verify`&&await $t(e),await E([e])}catch(e){m({ok:!1,text:gQ(e)})}})()},[E]),le=!!C&&(C.models?.length??0)>0&&(DX(C)||C.models.some(e=>e.state!==`skipped`))&&C&&R(`section`,{className:`settings-field models-pane-section`,"aria-labelledby":`settings-downloads-title`,children:[I(`span`,{className:`settings-label`,id:`settings-downloads-title`,children:t(`settings.models.downloads`)}),I(AX,{status:C,names:A,freeGb:n?.disk?.free_gb??null,onCancel:()=>void ee(),onRetry:ce,onResume:e=>void E([e]),onResumeAll:()=>void E((C.models??[]).filter(e=>e.state===`cancelled`).map(e=>e.id))}),w&&I(`p`,{className:`settings-error`,role:`alert`,children:w})]});return R(P.Fragment,{children:[I(KZ,{title:t(`settings.models.manage`),hint:t(`settings.models.manageHint`),forceOpen:!!i||p?.ok===!1,children:R(`section`,{className:`settings-field models-pane-section`,"aria-labelledby":`settings-models-title`,children:[I(`span`,{className:`visually-hidden`,id:`settings-models-title`,children:t(`settings.models.title`)}),I(`p`,{className:`settings-hint`,children:t(`settings.models.lede`)}),i&&I(mQ,{message:i}),n&&!n.lemonade.reachable&&I(`p`,{className:`settings-hint`,children:t(`settings.models.unavailable`)}),!n&&!i&&R(`p`,{className:`settings-hint`,children:[I(so,{size:13,className:`spin`,"aria-hidden":`true`}),` `,t(`setup.models.loading`)]}),n&&n.lemonade.reachable&&s&&R(P.Fragment,{children:[I(GY,{plan:n,selection:s,onToggle:(e,t)=>c(SY(s,re,e,t)),onDefaultChat:e=>c(CY(s,re,e)),labelledBy:`settings-models-title`,place:`settings`,disabled:d,progress:k,rowActions:e=>e.downloaded&&e.id!==s.defaultChat?I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>u({kind:`remove`,entry:e}),disabled:d||k[e.id]?.state===`downloading`,"aria-label":t(`settings.models.removeAria`,{name:e.name}),children:t(`settings.models.remove`)}):null}),I(HY,{plan:n,selection:s}),I(`div`,{className:`models-apply`,children:R(`button`,{type:`button`,className:`btn-primary`,disabled:!ae||d,onClick:()=>void oe(!1,!1),children:[d&&I(so,{size:13,className:`spin`,"aria-hidden":`true`}),d?t(`settings.models.applying`):j.length>0?t(`settings.models.applyDownload`,{size:PA(Math.round(ie*10)/10)}):t(`settings.models.apply`)]})})]}),p?.ok&&I(`p`,{className:`settings-ok`,role:`status`,children:p.text}),p&&!p.ok&&I(mQ,{message:p.text})]})}),(_?.applies||y&&!sQ(y))&&I(KZ,{title:t(`gpu.settingsTitle`),titleId:`settings-gpu-title`,defaultOpen:!!_?.pending||!!y,children:R(`section`,{className:`settings-field models-pane-section`,"aria-labelledby":`settings-gpu-title`,children:[y&&I(`p`,{className:`settings-error`,role:`alert`,children:y}),_?.applies&&I(uX,{status:_,onStatus:v,mode:`settings`,names:A,headingId:`settings-gpu-title`})]})}),e?(0,dy.createPortal)(le,e):e===void 0&&le,l?.kind===`remove`&&I(tX,{title:t(`settings.models.removeTitle`,{name:l.entry.name}),confirmLabel:t(`settings.models.removeConfirm`),cancelLabel:t(`settings.models.keep`),danger:!0,onConfirm:()=>void se(l.entry),onCancel:()=>u(null),children:I(`p`,{children:oY(l.entry)?t(`settings.models.removeVision`,{size:PA(l.entry.full_size_gb??0)}):t(`settings.models.removeBody`,{size:PA(l.entry.full_size_gb??0)})})}),l?.kind===`no_fit`&&I(tX,{title:kY(l.models)?t(`setup.confirm.tightOne`,{name:l.models[0].name}):l.models.length===1?t(`setup.confirm.noFitOne`,{name:l.models[0].name}):t(`setup.confirm.noFitMany`),confirmLabel:kY(l.models)?t(`setup.confirm.useAnyway`):t(`setup.confirm.downloadAnyway`),cancelLabel:t(`setup.confirm.pickSmaller`),onConfirm:()=>{u(null),g(!0),oe(!0,!1)},onCancel:()=>u(null),children:l.models.map(e=>R(`p`,{children:[I(`bdi`,{children:e.name}),`: `,zY(e,t)]},e.id))}),l?.kind===`low_disk`&&I(tX,{title:t(`setup.confirm.lowDiskTitle`),confirmLabel:t(`setup.confirm.downloadAnyway`),cancelLabel:t(`setup.confirm.changeModels`),onConfirm:()=>{u(null),oe(!0,!0)},onCancel:()=>u(null),children:I(`p`,{children:l.message})}),l?.kind===`server`&&I(tX,{title:t(`setup.confirm.noFitServerTitle`),confirmLabel:t(`setup.confirm.useAnyway`),cancelLabel:t(`setup.confirm.changeModels`),onConfirm:()=>{u(null),g(!0),oe(!0,!1)},onCancel:()=>u(null),children:I(`p`,{children:l.detail.message})})]})}var yQ=`auto`;function bQ({model:e}){let t=L(),[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(null);(0,V.useEffect)(()=>{r(null),a(null),l(null),me(e).then(r).catch(e=>a(e instanceof Error?e.message:String(e)))},[e]);let u=(0,V.useCallback)(async n=>{s(!0),a(null),l(null);try{let i=await ye(e,n===yQ?null:Number(n));r(i);let a={name:i.display_name,size:i.chosen?pl(i.chosen):M(`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 sQ(i)?I(`p`,{className:`settings-hint`,children:t(`settings.ctx.serverDown`)}):I(`p`,{className:`settings-error`,role:`alert`,children:i});if(!n)return R(`p`,{className:`settings-hint`,children:[I(so,{size:13,className:`spin`}),` `,t(`settings.ctx.checking`)]});let d=n.chosen==null?yQ:String(n.chosen),f=n.chosen!=null&&n.loaded_ctx!=null&&n.loaded_ctx!==n.chosen;return R(P.Fragment,{children:[R(`div`,{className:`model-in-use-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`ctx-size`,children:t(`settings.ctx.label`)}),R(`select`,{id:`ctx-size`,className:`settings-input`,value:d,onChange:e=>void u(e.target.value),disabled:o||n.options.length===0,children:[I(`option`,{value:yQ,children:n.automatic?t.bare(`settings.ctx.automaticAt`,{size:pl(n.automatic)}):t.bare(`settings.ctx.automatic`)}),n.options.map(e=>I(`option`,{value:String(e),children:t.bare(`settings.ctx.tokens`,{size:pl(e)})},e))]})]}),n.note&&I(`span`,{className:`settings-hint`,children:I(`bdi`,{children:n.note})}),!n.note&&!!n.max_fit&&R(`details`,{className:`settings-more`,children:[R(`summary`,{children:[I(si,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,t(`settings.ctx.about`)]}),I(`span`,{className:`settings-hint`,children:t(`settings.ctx.explain`,{size:pl(n.max_fit),name:n.display_name,memory:n.memory_source})})]}),f&&I(`span`,{className:`settings-hint`,children:t(`settings.ctx.loadedAt`,{size:pl(n.loaded_ctx)})}),o&&R(`span`,{className:`settings-hint`,children:[I(so,{size:13,className:`spin`}),` `,t(`settings.ctx.applying`)]}),c&&I(`p`,{className:`settings-ok`,role:`status`,children:c}),i&&I(`p`,{className:`settings-error`,role:`alert`,children:i})]})}function xQ({row:e,providerName:t,choices:n,labels:r,disabled:i,onSwitch:a}){let o=L(),s=Xc(e=>e.active),c=Xc(e=>e.error),l=s?.model??null,u=!!s?.remote,d=n.some(e=>$c(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 R(`section`,{className:`settings-card model-in-use`,"aria-label":o(`settings.model.inUseTitle`),children:[I(`span`,{className:`model-in-use-label`,children:o(`settings.model.inUseTitle`)}),l?I(`bdi`,{className:`model-in-use-name`,title:l,children:e?.display_name||s?.display_name||el(l)}):s||c?I(`span`,{className:`settings-hint`,children:o(`settings.model.noneInUse`)}):I(`span`,{className:`settings-hint`,children:o(`settings.loading`)}),s?.config_error&&I(`p`,{className:`settings-error`,role:`alert`,children:I(`bdi`,{children:s.config_error})}),l&&!u&&e?.available===!1&&I(`p`,{className:`settings-error`,role:`alert`,children:o(`settings.model.inUseCantRun`)}),l&&R(`span`,{className:`model-chips`,children:[u&&I(`span`,{className:`model-badge is-device`,children:o(`settings.model.cloud`)}),u&&t&&I(`bdi`,{className:`model-badge is-ready`,children:t}),m&&I(`span`,{className:`model-badge is-device`,children:m.toUpperCase()}),p&&I(`span`,{className:`model-badge ${e?.state===`loaded`?`is-loaded`:`is-ready`}`,children:p}),e?.fits===!0&&I(`span`,{className:`model-badge is-fit`,children:o(`settings.model.fits`)}),!!e?.size_gb&&R(`bdi`,{dir:`ltr`,className:`model-badge is-size`,children:[e.size_gb,` GB`]}),u&&!!e?.context_length&&I(`span`,{className:`model-badge is-ready`,children:o(`settings.model.contextChip`,{size:pl(e.context_length)})})]}),(n.length>1||n.length===1&&!d)&&R(`div`,{className:`model-in-use-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`model-switch`,children:o(`settings.model.switch`)}),R(`select`,{id:`model-switch`,className:`settings-input`,value:d?n.find(e=>$c(l,e.id))?.id:``,onChange:e=>a(e.target.value),disabled:i,children:[!d&&I(`option`,{value:``,disabled:!0,children:o.bare(`settings.model.switchPlaceholder`)}),n.map(e=>I(`option`,{value:e.id,children:r[e.id]},e.id))]})]}),l&&!u&&s?.downloaded!==!1&&I(bQ,{model:l})]})}var SQ=e=>new Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:0}).format(e),CQ=/^(\d+\/\d+) tasks · quality ([\d.]+\/5) · (\$[\d.]+) per (\d+)-task run$/;function wQ(e,t){let n=CQ.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 TQ({model:e,label:t,current:n,remote:r,busy:i,onUse:a,onDownload:o,onAskRemove:s,onNpuRecheck:c}){let l=L(),u=gl(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:SQ(e.context_length)}):null].filter(Boolean).join(` · `)),p=!!(e.display_name||f||e.evidence||e.custom&&e.source_url);return R(`li`,{className:`model-row${n?` is-current`:``}`,children:[R(`div`,{className:`model-row-text`,children:[I(`bdi`,{className:`model-row-name`,title:e.id,children:t}),R(`div`,{className:`model-chips`,children:[e.placement?.device&&I(`span`,{className:`model-badge is-device`,children:e.placement.device.toUpperCase()}),e.rank&&R(`span`,{className:`model-badge is-rank`,children:[R(`bdi`,{dir:`ltr`,children:[`#`,e.rank]}),` `,e.note&&(dl[e.note]?l(dl[e.note]):I(`bdi`,{children:e.note}))]}),e.state===`loaded`&&I(`span`,{className:`model-badge is-loaded`,children:l(`settings.model.loaded`)}),e.fits===!0&&e.available!==!1&&!e.tight&&I(`span`,{className:`model-badge is-fit`,children:l(`settings.model.fits`)}),e.fits===!0&&e.available!==!1&&e.tight&&I(`span`,{className:`model-badge is-tight`,title:l(`setup.models.warn.tight`),children:l(`settings.model.tight`)}),!r&&I(eB,{support:e.support}),e.custom&&I(`span`,{className:`model-badge is-custom`,children:l(`settings.model.custom`)}),!!e.size_gb&&R(`bdi`,{dir:`ltr`,className:`model-badge is-size`,children:[e.size_gb,` GB`]}),p&&R(`details`,{className:`settings-more model-row-facts`,children:[R(`summary`,{children:[I(si,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,l(`settings.model.details`)]}),e.display_name&&I(`span`,{className:`model-row-meta`,children:I(`bdi`,{children:e.id})}),f&&I(`span`,{className:`model-row-meta`,children:f}),e.evidence&&I(`span`,{className:`model-row-meta`,children:wQ(l,e.evidence)}),e.custom&&e.source_url&&I(`span`,{className:`model-row-meta`,children:l(`settings.model.from`,{url:e.source_url})})]})]}),r&&I(`span`,{className:`model-row-meta${e.price?``:` is-unknown-price`}`,children:nB(e.price,l)}),e.placement?.warning&&I(`span`,{className:`model-row-meta is-warning`,role:`alert`,children:I(`bdi`,{children:e.placement.warning})}),e.npu_problems?.length?I(VX,{problems:e.npu_problems,disabled:i!==null,onRecheck:c,id:`npu-problems-${e.id}`}):e.unavailable_reason&&I(`span`,{className:`model-row-meta`,children:l(`settings.model.cantRun`,{reason:e.unavailable_reason})}),u&&I(`progress`,{max:100,value:u.percent,"aria-label":l(`settings.model.downloadingAria`,{name:t})})]}),R(`div`,{className:`model-row-actions`,children:[e.custom&&!n&&!u&&R(`button`,{type:`button`,className:`btn-secondary`,onClick:s,disabled:i!==null,"aria-label":l(`settings.models.removeAria`,{name:t}),children:[i===`rm:${e.id}`?I(so,{size:13,className:`spin`}):null,l(`settings.models.remove`)]}),n&&e.available===!1?I(`span`,{className:`model-row-current is-blocked`,children:l(`settings.model.inUseBlocked`)}):n?R(`span`,{className:`model-row-current`,children:[I(ri,{size:13,"aria-hidden":`true`}),` `,l(`settings.model.inUse`)]}):e.available===!1?null:u?R(`span`,{className:`model-row-current`,children:[I(so,{size:13,className:`spin`}),` `,u.message?I(`bdi`,{children:u.message}):R(`bdi`,{dir:`ltr`,children:[Math.round(u.percent),`%`]})]}):e.downloaded?R(`button`,{type:`button`,className:`btn-secondary`,onClick:a,disabled:i!==null,"aria-label":l(`settings.model.useAria`,{name:t}),children:[i===e.id?I(so,{size:13,className:`spin`}):null,` `,l(`settings.model.use`)]}):R(`button`,{type:`button`,className:`btn-secondary`,onClick:o,disabled:i!==null,"aria-label":l(`settings.model.downloadAria`,{name:t}),children:[i===`dl:${e.id}`?I(so,{size:13,className:`spin`}):null,` `,l(`settings.model.download`)]})]})]})}function EQ(){let e=L(),[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(``),[s,c]=(0,V.useState)(!1),l=(0,V.useCallback)(async e=>{c(!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{c(!1)}},[]);if((0,V.useEffect)(()=>{l(Ae)},[l]),!t)return r?I(`p`,{className:`settings-error`,role:`alert`,children:r}):R(`p`,{className:`settings-hint`,children:[I(so,{size:13,className:`spin`}),` `,e(`settings.spend.loading`)]});let u=t.limit_usd,d=a.trim()===``?null:Number(a),f=d===null||Number.isFinite(d)&&d>0,p=d!==u;return R(`section`,{className:`settings-field spending`,"aria-label":e(`settings.spend.aria`),children:[I(`span`,{className:`settings-label`,children:e(`settings.spend.title`)}),R(`p`,{className:`spending-total`,children:[I(`bdi`,{dir:`ltr`,children:I(`strong`,{children:rB(t.total_usd)})}),u!=null&&R(P.Fragment,{children:[` `,e(`settings.spend.ofLimit`,{limit:rB(u)})]}),R(`span`,{className:`settings-hint`,children:[` · `,e.plural(`settings.spend.turns`,t.turns-t.unpriced_turns-t.unreported_turns)]})]}),t.unpriced_turns>0&&I(`p`,{className:`settings-hint`,children:e.plural(`settings.spend.unpriced`,t.unpriced_turns)}),t.unreported_turns>0&&I(`p`,{className:`settings-hint`,children:e.plural(`settings.spend.unreported`,t.unreported_turns)}),t.state===`near`&&R(`p`,{className:`spending-warning`,role:`status`,children:[I(ec,{size:13,"aria-hidden":`true`}),` `,e(`settings.spend.near`)]}),t.state===`reached`&&R(`div`,{className:`spending-warning`,role:`alert`,children:[R(`p`,{children:[I(ec,{size:13,"aria-hidden":`true`}),` `,e(`settings.spend.reached`)]}),I(`button`,{type:`button`,className:`btn-secondary`,disabled:s,onClick:()=>void l(Ht),children:e(`settings.spend.allow`)})]}),t.state===`allowed_over`&&I(`p`,{className:`settings-hint`,children:e(`settings.spend.allowed`)}),R(`form`,{className:`settings-row`,onSubmit:e=>{e.preventDefault(),f&&p&&l(()=>ie(d))},children:[I(`label`,{className:`spending-limit-label`,htmlFor:`spend-limit`,children:e(`settings.spend.limit`)}),I(`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":!f}),R(`button`,{type:`submit`,className:`btn-secondary`,disabled:s||!f||!p,children:[s?I(so,{size:13,className:`spin`}):null,` `,e(`settings.advanced.save`)]}),u!=null&&I(`button`,{type:`button`,className:`btn-secondary`,disabled:s,onClick:()=>void l(()=>ie(null)),children:e(`settings.spend.removeLimit`)})]}),I(`span`,{className:`settings-hint`,children:e(`settings.spend.how`)}),r&&I(`p`,{className:`settings-error`,role:`alert`,children:r})]})}var DQ=2e3;function OQ(e,t){return e.key_source===`environment`?t(`settings.key.setIn`,{name:e.env_var??``}):`••••••••••••••••••••${e.key_hint?` ${e.key_hint}`:``}`}function kQ(){let e=L(),t=Xc(e=>e.active),n=Xc(e=>e.select),r=Xc(e=>e.refresh),i=Xc(e=>e.rememberNames),a=B(e=>!!e.systemStatus&&SR(e.systemStatus)===`unresponsive`),[o,s]=(0,V.useState)(null),[c,u]=(0,V.useState)(null),d=B(e=>e.settingsProvider),[f,p]=(0,V.useState)(d??t?.provider??`local`),[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)(null),[v,y]=(0,V.useState)(``),[b,x]=(0,V.useState)(!1),[S,C]=(0,V.useState)(``),[w,T]=(0,V.useState)(!1),[E,ee]=(0,V.useState)(!1),[D,O]=(0,V.useState)({base_url:``,auth_header_name:``,auth_header_prefix:``}),[te,k]=(0,V.useState)(null),[A,ne]=(0,V.useState)(null),[re,j]=(0,V.useState)(null),[ie,ae]=(0,V.useState)(null),[oe,se]=(0,V.useState)(!1),[ce,le]=(0,V.useState)(null),[ue,M]=(0,V.useState)(null),de=(0,V.useRef)(f);de.current=f;let fe=(0,V.useRef)(!0);(0,V.useEffect)(()=>(fe.current=!0,()=>{fe.current=!1}),[]);let N=o?.find(e=>e.id===f)??null,pe=e=>e?.network?.reachable===!1,me=e=>!!e?.blocked,he=!!N&&!me(N)&&(!N.remote||!!N.models_discovered),ge=(0,V.useCallback)(async()=>{u(null);try{let e=await Yn();s(e.providers),e.lemonade_error&&u(e.lemonade_error)}catch(e){u(e instanceof Error?e.message:String(e))}},[]),_e=(0,V.useCallback)(async()=>{try{await Se()}catch(e){u(e instanceof Error?e.message:String(e));return}await ge()},[ge]),ve=(0,V.useCallback)(async(t,n=!1)=>{n||(h(null),_(null));try{let n=await ln(t);i(n.models),h(n.models),ne(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,V.useEffect)(()=>{ge()},[ge]);let ye=!!o?.some(e=>e.key_state===`waiting_for_os_permission`);(0,V.useEffect)(()=>{if(ye)return Sl(()=>{ge()},DQ)},[ye,ge]);let be=t?.provider;(0,V.useEffect)(()=>{be&&!d&&p(be)},[be,d]),(0,V.useEffect)(()=>{C(``),T(!1),ee(!1),j(null),y(``),x(!1),se(!1)},[f]),(0,V.useEffect)(()=>{he?ve(f):h(null)},[f,he,ve]);let xe=(0,V.useCallback)(async()=>{if(N){k(`connect`),j(null);try{let t=f===`amd`?{api_key:S||void 0,...Object.fromEntries(Object.entries(D).filter(([,e])=>e!==``))}:{api_key:S||void 0},n=()=>!fe.current||de.current!==f,r=await fr(f,t,e=>{n()||j({ok:!0,text:e})},n);if(n())return;C(``),T(!1),j({ok:!0,text:r.remember_error?e(`settings.key.sessionOnly`,{reason:r.remember_error}):r.known_models?e(`settings.key.knownModels`,{name:N.name}):r.remembered?e(`settings.key.kept`):e(`settings.key.connectedDone`)}),await ge()}catch(e){fe.current&&de.current===f&&j({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{fe.current&&k(null)}}},[D,f,S,ge,N,e]),we=(0,V.useCallback)(async()=>{k(`forget`),ee(!1),j(null);try{await l(f),j({ok:!0,text:e(`settings.key.cleared`)}),await ge(),await r()}catch(e){j({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{k(null)}},[f,ge,r,e]),Te=(0,V.useCallback)(async t=>{k(t),j(null);try{await n(t),j({ok:!0,text:e(`settings.model.switched`,{name:el(t)})}),await ve(f,!0)}catch(e){j({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{k(null)}},[f,ve,n,e]),Ee=(0,V.useCallback)(async e=>{k(`dl:${e}`),j(null),se(!1);try{await Ce(e),await ve(`local`,!0)}catch(e){j({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{k(null)}},[ve]),De=(0,V.useCallback)(async t=>{let n=Xc.getState().active?.model;k(`rm:${t}`),j(null);try{let r=await ir(t);ae(null);let i=r.cleared.includes(`last_model`)?`settings.model.removedLast`:r.cleared.includes(`default_model`)?`settings.model.removedDefault`:`settings.model.removed`;j({ok:!0,text:e(i,{name:r.display_name})}),await ve(`local`,!0),await Zc(n)}catch(e){j({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{k(null)}},[ve,e]),Oe=(0,V.useCallback)(async t=>{j({ok:!0,text:e(`settings.model.added`,{name:t})}),se(!0),await ve(`local`,!0)},[ve,e]),ke=!!m?.some(gl);(0,V.useEffect)(()=>{if(ke)return()=>{r()}},[ke,r]),(0,V.useEffect)(()=>{if(f===`local`&&ke)return Sl(()=>{ve(`local`,!0)},DQ)},[ke,f,ve]);let Ae=t?.model,je=m?.find(e=>$c(Ae,e.id));(0,V.useEffect)(()=>{je&&le(je)},[je]);let Me=(0,V.useMemo)(()=>{let e=v.trim().toLowerCase();return(m??[]).filter(t=>!e||t.id.toLowerCase().includes(e)||(t.display_name??``).toLowerCase().includes(e))},[m,v]),Ne=Me.filter(e=>e.available!==!1),Pe=f===`fireworks`&&!b&&!v.trim()&&Ne.some(e=>e.rank!==null),Fe=e=>e.rank!==null||e.id===t?.model,Ie=Pe?Ne.filter(Fe):Ne,Le=Pe?Ne.filter(e=>!Fe(e)):[],Re=Me.filter(e=>e.available===!1),ze=cl(m??[]),Be=!!v.trim(),Ve=e=>$c(t?.model,e.id),He=N?.id===`local`,Ue=Ie.filter(e=>e.downloaded).sort((e,t)=>Number(Ve(t))-Number(Ve(e))),We=Ie.filter(e=>!e.downloaded),Ge=(m??[]).filter(e=>e.available!==!1&&e.downloaded),Ke=Ge.filter(Fe),qe=ie?(m??[]).find(e=>e.id===ie)??null:null,Je=f===`fireworks`&&Ke.some(e=>e.rank!==null)?Ke:Ge,Ye=e=>I(TQ,{model:e,label:ze[e.id],current:Ve(e),remote:!!N?.remote,busy:te,onUse:()=>void Te(e.id),onDownload:()=>void Ee(e.id),onAskRemove:()=>ae(e.id),onNpuRecheck:()=>void ve(f,!0)},e.id);return R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.model`)}),I(JV,{inSettings:!0}),I(xQ,{row:je??($c(ce?.id,t?.model)?ce:null),providerName:t?.provider_name??null,choices:he?Je:[],labels:ze,disabled:te!==null,onSwitch:e=>void Te(e)}),I(VV,{className:`provider-tabs`,"aria-label":e(`settings.model.whereRuns`),children:(o??[{id:`local`,name:`Local`,remote:!1}]).map(t=>R(`button`,{type:`button`,role:`radio`,"aria-checked":f===t.id,className:`provider-tab${f===t.id?` is-active`:``}${pe(t)||me(t)?` is-disabled`:``}`,onClick:()=>p(t.id),disabled:(pe(t)||me(t))&&f!==t.id,title:me(t)?e(`settings.privacy.localOnlyBlocked`):pe(t)?e(`setup.key.gatewayOff`):void 0,children:[t.remote?I(ki,{size:14,"aria-hidden":`true`}):I(zi,{size:14,"aria-hidden":`true`}),I(`span`,{children:aB(e,t)}),t.remote&&t.models_discovered&&I(`span`,{className:`provider-tab-dot`,"aria-label":e(`settings.key.connectedDot`)})]},t.id))}),!o&&!c&&R(`p`,{className:`settings-hint`,role:`status`,children:[I(so,{size:13,className:`spin`}),` `,e(a?`settings.model.waitingServer`:`settings.loading`)]}),c&&I(mQ,{message:c,onRetry:()=>{ge(),ve(f)}}),N&&R(`section`,{className:`settings-card`,"aria-label":aB(e,N),children:[N.remote&&I(`p`,{className:`settings-note`,children:I(`bdi`,{children:oB(e,N)})}),R(`details`,{className:`settings-more`,children:[R(`summary`,{children:[I(si,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,e(`settings.model.howItWorks`)]}),I(`p`,{className:`settings-hint`,children:e(`settings.model.lede`)}),He&&I(`p`,{className:`settings-hint`,children:I(`bdi`,{children:oB(e,N)})}),He&&I(`p`,{className:`settings-hint`,children:e(`settings.model.devices`)}),He&&A&&I(`p`,{className:`settings-hint`,children:e(`settings.model.memory`,{memory:A})})]}),N.remote&&!he&&R(`div`,{className:`settings-field`,children:[I(`span`,{className:`settings-label`,children:e(`settings.model.prices`)}),I(QJ,{provider:N.id})]}),me(N)&&I(`div`,{className:`settings-field`,children:I(`p`,{className:`settings-error`,role:`alert`,children:e(`settings.privacy.localOnlyBlocked`)})}),pe(N)&&R(`div`,{className:`settings-field`,children:[I(`p`,{className:`settings-error`,role:`alert`,children:N.network?.detail}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void ge(),children:e(`settings.key.checkAgain`)})]}),N.remote&&!pe(N)&&!me(N)&&R(`form`,{className:`settings-field`,"data-settings-target":`cloud-key`,onSubmit:e=>{e.preventDefault(),xe()},children:[R(`div`,{className:`settings-row settings-row-between`,children:[I(`span`,{className:`settings-label`,children:e(`settings.key.title`)}),N.key_source&&I(`span`,{className:`settings-key-status ${he?`settings-ok`:`settings-error`}`,children:e(he?`settings.key.connected`:`settings.key.notConnected`)})]}),!N.key_source&&N.key_state===`store_locked`&&R(`span`,{className:`settings-hint`,role:`status`,children:[e(`settings.key.storeLocked`),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>void _e(),children:e(`settings.key.unlockAgain`)})]}),!N.key_source&&N.key_state!==`store_locked`&&I(`span`,{className:`settings-hint`,children:N.key_state===`waiting_for_os_permission`?N.key_message??e(`settings.key.waitingOs`):e(`settings.key.none`)}),N.id===`amd`&&(!N.key_source||w)&&R(`div`,{className:`settings-grid`,children:[I(`input`,{className:`settings-input`,placeholder:e(`settings.key.gatewayPlaceholder`),value:D.base_url,onChange:e=>O({...D,base_url:e.target.value}),"aria-label":e(`settings.key.gatewayUrl`)}),I(`input`,{className:`settings-input`,placeholder:e(`settings.key.headerPlaceholder`),value:D.auth_header_name,onChange:e=>O({...D,auth_header_name:e.target.value}),"aria-label":e(`settings.key.headerName`)})]}),N.key_source&&!w?R(`div`,{className:`settings-row`,children:[I(`input`,{className:`settings-input settings-key-masked`,readOnly:!0,value:OQ(N,e),"aria-label":e(`settings.key.savedAria`,{name:N.name})}),!he&&R(`button`,{type:`submit`,className:`btn-primary`,disabled:te!==null,children:[te===`connect`?I(so,{size:13,className:`spin`}):null,e(`settings.key.reconnect`)]}),(N.key_source!==`environment`||N.key_from_gaia_env)&&R(P.Fragment,{children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>T(!0),disabled:te!==null,children:e(`settings.key.replace`)}),N.key_source!==`environment`&&I(`button`,{type:`button`,className:`btn-secondary settings-key-remove`,onClick:()=>ee(!0),disabled:te!==null,"aria-label":e(`settings.key.remove`),title:e(`settings.key.remove`),children:I(Qs,{size:14,"aria-hidden":`true`})})]})]}):R(`div`,{className:`settings-row`,children:[I(`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:N.name})}),R(`button`,{type:`submit`,className:`btn-primary`,disabled:te!==null||!S,children:[te===`connect`?I(so,{size:13,className:`spin`}):null,e(w?`settings.key.save`:`settings.key.connect`)]}),w&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{C(``),T(!1)},disabled:te!==null,children:e(`settings.key.cancel`)})]}),N.key_source&&!he&&!N.error&&!w&&I(`p`,{className:`settings-hint`,children:e(`settings.key.notConnectedHint`,{name:N.name})}),N.error&&I(`p`,{className:`settings-error`,role:`alert`,children:N.error})]}),re?.ok&&I(`p`,{className:`settings-ok`,role:`status`,children:re.text}),re&&!re.ok&&I(mQ,{message:re.text}),N.known_models&&I(`p`,{className:`settings-hint`,role:`status`,children:e(`settings.key.knownList`,{name:N.name})}),He&&I(`div`,{className:`models-downloads-slot`,ref:M}),he&&R(`div`,{className:`settings-field`,children:[I(`span`,{className:`settings-label`,children:e(`settings.model.models`)}),(m?.length??0)>6&&I(`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&&sQ(g))&&I(mQ,{message:g}),!m&&!g&&R(`p`,{className:`settings-hint`,children:[I(so,{size:13,className:`spin`}),` `,e(`settings.loading`)]}),m&&Me.length===0&&!g&&I(`p`,{className:`settings-hint`,children:e(Be||!He?`settings.model.noMatch`:`settings.model.noModels`)}),He?R(P.Fragment,{children:[Ue.length>0&&I(KZ,{title:e(`settings.model.groupDownloaded`),count:Ue.length,defaultOpen:!0,forceOpen:Be,targetId:`models-on-pc`,children:I(`ul`,{className:`model-list`,children:Ue.map(Ye)})}),We.length>0&&I(KZ,{title:e(`settings.model.groupAvailable`),count:We.length,defaultOpen:Ue.length===0,forceOpen:Be||oe||We.some(gl),children:I(`ul`,{className:`model-list`,children:We.map(Ye)})})]}):I(`ul`,{className:`model-list`,children:Ie.map(Ye)}),Pe&&Le.length>0&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>x(!0),children:e(`settings.model.showAll`)}),f===`fireworks`&&b&&!Be&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>x(!1),children:e(`settings.model.showRecommended`)}),Re.length>0&&I(KZ,{title:e(`settings.model.groupUnavailable`),count:Re.length,forceOpen:Be,children:I(`ul`,{className:`model-list`,children:Re.map(Ye)})})]}),He&&he&&I(KZ,{title:e(`settings.custom.title`),children:I(hQ,{onAdded:e=>void Oe(e)})}),He&&he&&I(vQ,{downloadsSlot:ue}),N.remote&&I(EQ,{})]}),qe&&I(tX,{title:e(`settings.models.removeTitle`,{name:ze[qe.id]??qe.id}),confirmLabel:qe.downloaded?e(`settings.model.removeDownload`):e(`settings.models.remove`),cancelLabel:e(`settings.models.keep`),danger:!0,onConfirm:()=>{ae(null),De(qe.id)},onCancel:()=>ae(null),children:qe.downloaded&&I(`p`,{children:e(`settings.model.removeDownloadBody`)})}),E&&N&&I(tX,{title:e(`settings.key.removeAsk`),confirmLabel:e(`settings.key.remove`),cancelLabel:e(`settings.models.keep`),danger:!0,onConfirm:()=>void we(),onCancel:()=>ee(!1),children:I(`p`,{children:e(`settings.key.removeBody`,{name:N.name})})})]})}async function AQ(){return jn(`GET`,`/images/settings`)}async function jQ(e){return jn(`PUT`,`/images/settings`,e)}var MQ=[4,8,12,20,30,50],NQ=e=>`${e}`;function PQ(e){return e instanceof En?e.detail||e.message:String(e)}function FQ(){let e=L(),t=B(e=>e.openSettings),n=Oz(e=>e.current)===`gaiacpp`;Qc();let[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1),d=()=>{o(null),AQ().then(i).catch(e=>o({unreachable:e instanceof En&&e.httpStatus===503,detail:PQ(e)}))};(0,V.useEffect)(()=>{n||d()},[n]);let f=e=>{u(!0),c(null),jQ(e).then(i).catch(e=>c(PQ(e))).finally(()=>u(!1))},p=I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.images`)});if(n)return R(`div`,{className:`settings-pane`,children:[p,R(`div`,{className:`settings-notice`,role:`status`,children:[I(`p`,{children:e(`images.settings.fastAgentCannot`)}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>t(`model`),children:e.compose(e=>e(`mem.store.change`,{tab:e(`settings.section.model`)}))})]})]});if(a)return R(`div`,{className:`settings-pane`,children:[p,a.unreachable?R(P.Fragment,{children:[I(`p`,{className:`settings-error`,role:`alert`,children:e(`images.settings.unreachable`)}),I(`p`,{className:`settings-hint`,children:a.detail}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:d,children:e(`images.settings.retry`)})]}):I(`p`,{className:`settings-error`,role:`alert`,children:e(`images.settings.loadFailed`,{reason:a.detail})})]});if(!r)return R(`p`,{className:`settings-hint`,children:[I(so,{size:13,className:`spin`}),` `,e(`settings.loading`)]});let m=r.models.find(e=>e.id===r.model),h=m?[...new Set([...MQ,m.default_steps,...r.steps?[r.steps]:[]])].filter(e=>e<=r.max_steps).sort((e,t)=>e-t):[];return R(`div`,{className:`settings-pane`,children:[p,I(`p`,{className:`settings-pane-lede`,children:e(`images.settings.lede`)}),!r.chat_model_creates_images&&R(`div`,{className:`settings-notice`,role:`status`,children:[I(`p`,{children:e(`images.settings.chatModelCannot`,{model:el(r.chat_model)})}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>t(`model`),children:e(`images.settings.chooseChatModel`)})]}),!r.model_available&&I(`p`,{className:`settings-error`,role:`alert`,children:e(`images.settings.modelGone`,{model:r.model})}),r.models.length===0?I(`p`,{className:`settings-hint`,children:e(`images.settings.noModels`)}):R(P.Fragment,{children:[R(`div`,{className:`settings-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`image-model`,children:e(`images.settings.model`)}),R(`select`,{id:`image-model`,className:`settings-input`,value:r.model_available?r.model:``,disabled:l,onChange:e=>f({model:e.target.value}),children:[!r.model_available&&I(`option`,{value:``,disabled:!0,children:r.model}),r.models.map(t=>I(`option`,{value:t.id,children:t.downloads_on_first_use?e.bare(`images.settings.downloadsOnFirstUse`,{model:t.id,size:NQ(`${t.size_gb??`?`} GB`)}):t.id},t.id))]})]}),m&&R(P.Fragment,{children:[R(`div`,{className:`settings-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`image-size`,children:e(`images.settings.size`)}),R(`select`,{id:`image-size`,className:`settings-input`,value:r.size??``,disabled:l,onChange:e=>f({size:e.target.value||null}),children:[I(`option`,{value:``,children:e.bare(`images.settings.automatic`,{value:NQ(m.default_size)})}),m.sizes.map(e=>I(`option`,{value:e,children:NQ(e)},e))]})]}),R(`div`,{className:`settings-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`image-steps`,children:e(`images.settings.steps`)}),R(`select`,{id:`image-steps`,className:`settings-input`,value:r.steps??``,disabled:l,onChange:e=>f({steps:e.target.value?Number(e.target.value):null}),children:[I(`option`,{value:``,children:e.bare(`images.settings.automatic`,{value:NQ(String(m.default_steps))})}),h.map(e=>I(`option`,{value:e,children:NQ(String(e))},e))]}),I(`span`,{className:`settings-hint`,children:e(`images.settings.stepsHint`)})]})]})]}),I(`p`,{className:`settings-hint`,children:e(`images.settings.shared`)}),s&&I(`p`,{className:`settings-error`,role:`alert`,children:e(`images.settings.saveFailed`,{reason:s})})]})}function IQ(){let e=L(),t=B(e=>e.sessions),[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(null),u=(0,V.useCallback)(async()=>{l(null);try{let e=await Xt();r(e.sessions),a(e.default_mode),B.getState().setDefaultPermissionMode(e.default_mode)}catch(e){l(e instanceof Error?e.message:String(e))}},[]);(0,V.useEffect)(()=>{u()},[u]);let d=(0,V.useCallback)(async e=>{l(null);try{await e(),await u()}catch(e){l(e instanceof Error?e.message:String(e))}},[u]),f=(0,V.useCallback)(async e=>{s(!1),await d(()=>Ct(e))},[d]),p=()=>{i===`full_access`?f(`ask`):s(e=>!e)},m=e=>t.find(t=>t.id===e)?.title??e;return R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.permissions`)}),I(`p`,{className:`settings-pane-lede`,children:e(`settings.permissions.lede`)}),R(`details`,{className:`settings-more`,children:[R(`summary`,{children:[I(si,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,e(`settings.model.howItWorks`)]}),I(`p`,{className:`settings-hint`,children:e(`settings.permissions.perChat`)})]}),R(`section`,{className:`settings-card`,"aria-label":e(`settings.permissions.newChats`),children:[R(`label`,{className:`setting-row`,children:[I(`span`,{className:`settings-label`,children:e(`settings.permissions.fullAccess`)}),R(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,checked:i===`full_access`,onChange:p,disabled:i===null,"aria-label":e(`settings.permissions.fullAccess`)}),I(`span`,{className:`toggle-track`})]})]}),I(`p`,{className:`settings-hint`,children:e(i===`full_access`?`settings.permissions.on`:`settings.permissions.off`)}),o&&R(`div`,{className:`settings-warning`,role:`alert`,children:[I(`p`,{children:e(`settings.permissions.warning`)}),R(`div`,{className:`settings-row`,children:[I(`button`,{type:`button`,className:`btn-danger`,onClick:()=>void f(`full_access`),children:e(`settings.permissions.turnOn`)}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>s(!1),children:e(`settings.key.cancel`)})]})]})]}),c&&I(`p`,{className:`settings-error`,role:`alert`,children:c}),n&&n.length===0&&I(`p`,{className:`settings-hint`,children:e(`settings.permissions.none`)}),!!n?.length&&I(KZ,{title:e(`settings.permissions.chats`),count:n.length,defaultOpen:!0,children:n.map(t=>R(`section`,{className:`settings-field permission-chat`,"aria-label":m(t.session_id),children:[R(`div`,{className:`settings-row settings-row-between`,children:[I(`bdi`,{className:`settings-label`,children:m(t.session_id)}),t.mode===`full_access`&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>d(async()=>{let e=(await sr(t.session_id,`ask`)).mode;AB(t.session_id,e)}),children:e(`settings.permissions.turnOff`)})]}),t.grants.length>0&&I(`ul`,{className:`grant-list`,children:t.grants.map(n=>R(`li`,{className:`grant-row`,children:[I(`code`,{children:n.label}),I(`button`,{type:`button`,className:`link-btn`,onClick:()=>d(()=>tr(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&&I(`button`,{type:`button`,className:`link-btn`,onClick:()=>d(()=>tr(t.session_id)),children:e(`settings.permissions.revokeAll`)})]},t.session_id))})]})}function LQ({text:e}){let t=L(),n=(0,V.useRef)(null),[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(!1);return(0,V.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]),R(P.Fragment,{children:[I(`span`,{ref:n,className:`skill-row-desc${r?` is-open`:``}${a||r?` is-toggle`:``}`,dir:`auto`,onClick:a||r?e=>{e.preventDefault(),i(!r)}:void 0,children:I(`bdi`,{children:e})}),(a||r)&&I(`button`,{type:`button`,className:`skill-row-more`,"aria-expanded":r,onClick:()=>i(!r),children:t(r?`settings.skills.less`:`settings.skills.more`)})]})}function RQ(e,t){if(e instanceof En&&e.reason===`link_not_found`){let n=e.body?.link;if(typeof n==`string`&&ht(`settings.skills.link.notFound`,{link:n})===e.detail)return t(`settings.skills.link.notFound`,{link:n})}return fP(e,t)}var zQ=(e,t)=>!e.error&&(!e.installed||e.update)&&(t||!e.has_code);function BQ(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 VQ({onAdded:e}){let t=L(),[n,r]=(0,V.useState)(``),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(new Set),[f,p]=(0,V.useState)(!1),[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)([]);(0,V.useEffect)(()=>{let e=!1;return Et().then(t=>{e||_(t.libraries)}).catch(n=>{e||s(t(`settings.skills.link.featuredFailed`,{error:fP(n,t)}))}),()=>{e=!0}},[t]);let v=async e=>{if(e.trim()){a(`preview`),s(null),l(null),h(null);try{let t=await Fe(e.trim());l(t),d(new Set(t.skills.filter(e=>zQ(e,!1)).map(e=>e.name)))}catch(e){s(RQ(e,t))}finally{a(null)}}},y=async()=>{if(c&&u.size!==0){a(`add`),s(null);try{let t=await Nt(c.link,[...u],f,c.pin);h(t),l(null),r(``),t.added.length&&e()}catch(e){s(RQ(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=>zQ(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 R(`div`,{className:`settings-card skill-link`,children:[R(`div`,{className:`skill-link-top`,children:[I(`span`,{className:`settings-label`,children:t(`settings.skills.link.title`)}),g.map(e=>{let n=`settings.skills.link.featured.${e.id}`,a=k(n);return I(`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?M(n):e.description}),children:t(`settings.skills.link.get`,{name:e.name})},e.id)})]}),R(`form`,{className:`skill-link-form`,onSubmit:e=>{e.preventDefault(),v(n)},children:[I(`input`,{className:`settings-input`,type:`text`,inputMode:`url`,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Escape`&&i===null&&(c||n)&&(e.preventDefault(),c?l(null):r(``))},...Rt,onPaste:e=>{if(i!==null)return;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`),readOnly:i!==null,"aria-busy":i===`preview`}),I(`button`,{type:`submit`,className:`btn-secondary`,disabled:!n.trim()||i!==null,children:i===`preview`?R(P.Fragment,{children:[I(so,{size:13,className:`spin`}),` `,t(`settings.skills.link.reading`)]}):t(`settings.skills.link.read`)})]}),o&&I(`p`,{className:`settings-error`,role:`alert`,children:o}),c&&R(`div`,{className:`skill-link-preview`,children:[R(`details`,{className:`skill-link-warning`,role:`note`,children:[R(`summary`,{children:[I(ec,{size:14,"aria-hidden":`true`}),t(`settings.skills.link.trust`)]}),I(`p`,{children:I(`bdi`,{children:c.warning})})]}),R(`div`,{className:`skill-link-head`,children:[I(`span`,{children:t(`settings.skills.link.found`,{n:c.skills.length,source:c.source})}),S.length>1&&I(`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`)})]}),I(`ul`,{className:`skill-list skill-link-list`,children:c.skills.map(e=>{let n=zQ(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 I(`li`,{className:`skill-row`,children:R(`label`,{className:`skill-link-pick`,children:[I(`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})}),R(`span`,{className:`skill-row-text`,children:[R(`span`,{className:`skill-row-name`,children:[e.name,r&&I(`span`,{className:`skill-link-tag${e.error?` is-bad`:``}`,children:r}),e.has_code&&I(`span`,{className:`skill-link-tag`,children:t(`settings.skills.link.tagCode`)}),e.verdict===`REVIEW`&&I(`span`,{className:`skill-link-tag`,children:t(`settings.skills.link.tagReview`)})]}),e.description&&I(LQ,{text:e.description}),e.permissions.length>0?R(`span`,{className:`skill-link-perms`,children:[I(`span`,{className:`skill-link-perms-label`,children:t(`settings.skills.link.can`)}),I(`ul`,{"aria-label":t(`settings.skills.link.permsAria`,{name:e.name}),children:e.permissions.map(e=>R(`li`,{children:[I(`bdi`,{children:e.text}),` `,I(`bdi`,{dir:`ltr`,children:I(`code`,{children:e.grant})})]},e.grant))})]}):I(`span`,{className:`skill-link-perms`,children:t(e.permissions_unreadable?`settings.skills.link.permissionsUnreadable`:`settings.skills.link.noPermissions`)}),a&&R(`details`,{className:`skill-link-findings`,children:[I(`summary`,{children:t(`settings.skills.link.details`)}),i&&I(`p`,{children:I(`bdi`,{children:i})}),e.has_code&&!f&&I(`p`,{children:t(`settings.skills.link.shipsCode`)}),e.findings.length>0&&I(`ul`,{children:e.findings.map(e=>I(`li`,{children:I(`bdi`,{children:e})},e))})]})]})]})},e.path)})}),R(`div`,{className:`skill-link-actions`,children:[w&&R(`label`,{className:`skill-link-code`,title:t(`settings.skills.link.codeHint`),children:[I(`input`,{type:`checkbox`,checked:f,onChange:e=>x(e.target.checked)}),I(`span`,{children:t(`settings.skills.link.includeCode`)})]}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>l(null),disabled:i!==null,children:t(`settings.skills.link.cancel`)}),I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void y(),disabled:u.size===0||i!==null,children:i===`add`?R(P.Fragment,{children:[I(so,{size:13,className:`spin`}),` `,t(`settings.skills.link.adding`)]}):t(`settings.skills.link.add`,{n:u.size})})]})]}),m&&R(`div`,{className:`skill-link-result`,role:`status`,children:[m.added.length>0&&I(`p`,{children:BQ(m,t)}),Object.keys(m.failed).length>0&&R(`details`,{children:[I(`summary`,{children:t(`settings.skills.link.notAdded`,{n:Object.keys(m.failed).length})}),I(`ul`,{className:`grant-list`,children:Object.entries(m.failed).map(([e,t])=>R(`li`,{children:[I(`bdi`,{children:I(`strong`,{children:e})}),` — `,I(`bdi`,{children:t})]},e))})]})]})]})}var HQ={path:`~/.gaia/skills`},UQ=[{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:HQ},{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 WQ(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 GQ({onUseSkill:e}){let t=L(),[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)({}),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(``),[u,d]=(0,V.useState)(null),[f,p]=(0,V.useState)(null),m=(0,V.useRef)(null),h=(0,V.useRef)(!0),g=(0,V.useCallback)(()=>{Bt().then(e=>{h.current&&(r(e.skills),a(e.invalid),s(null))}).catch(e=>{h.current&&s(e instanceof Error?e.message:String(e))})},[]);(0,V.useEffect)(()=>(h.current=!0,g(),window.addEventListener(`focus`,g),()=>{h.current=!1,window.removeEventListener(`focus`,g)}),[g]);let _=async e=>{d({name:e,busy:!0}),p(null);try{await ze(e)}catch(n){h.current&&p(t(`settings.skills.removeFailed`,{name:e,error:fP(n,t)}))}finally{h.current&&d(null),g()}},v=c.trim().toLowerCase(),y=(n??[]).filter(e=>!v||e.name.toLowerCase().includes(v)||e.description.toLowerCase().includes(v)),b=n?.every(e=>UQ.some(t=>t.source===e.source))??!1,x=n=>R(`li`,{className:`skill-row`,children:[R(`div`,{className:`skill-row-text`,children:[R(`span`,{className:`skill-row-name`,children:[I(`span`,{title:n.version?`v${n.version}`:void 0,children:n.name}),n.always_on&&R(`span`,{className:`skill-row-meta`,children:[` · `,t(`settings.skills.alwaysOn`)]})]}),I(LQ,{text:n.description})]}),R(`div`,{className:`skill-row-actions`,children:[!n.always_on&&I(`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.source===`user`&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{p(null),d({name:n.name,busy:!1})},"aria-label":t(`settings.skills.removeAria`,{name:n.name}),children:t(`settings.skills.remove`)})]})]},n.name);return R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:t(`settings.section.skills`)}),I(`p`,{className:`settings-pane-lede`,children:t(`settings.skills.lede`)}),R(`details`,{className:`settings-more`,children:[R(`summary`,{children:[I(si,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,t(`settings.model.howItWorks`)]}),I(`p`,{className:`settings-hint`,children:t(`settings.skills.how`,HQ)})]}),I(VQ,{onAdded:g}),o&&I(`p`,{className:`settings-error`,role:`alert`,children:o}),f&&I(`p`,{className:`settings-error`,role:`alert`,children:f}),!n&&!o&&R(`p`,{className:`settings-hint`,children:[I(so,{size:13,className:`spin`}),` `,t(`settings.loading`)]}),n&&n.length>6&&I(`input`,{ref:m,className:`settings-input`,type:`search`,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&c&&(e.preventDefault(),l(``))},...Rt,placeholder:t(`settings.skills.search`),"aria-label":t(`settings.skills.search`)}),n&&n.length===0&&I(`p`,{className:`settings-hint`,children:t(`settings.skills.none`)}),v&&n&&n.length>0&&y.length===0&&R(`p`,{className:`settings-hint`,role:`status`,children:[t(`settings.skills.noMatch`,{query:c.trim()}),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>{l(``),m.current?.focus()},children:t(`settings.skills.clearSearch`)})]}),b?UQ.map(e=>{let n=y.filter(t=>t.source===e.source);return n.length===0&&(v||!e.empty)?null:I(KZ,{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:!!v,children:I(`section`,{"aria-label":t(e.title),children:n.length===0?I(`p`,{className:`settings-hint`,children:e.empty&&t(e.empty,e.params)}):I(`ul`,{className:`skill-list`,children:n.map(x)})})},e.source)}):I(`ul`,{className:`skill-list`,children:y.map(x)}),Object.keys(i).length>0&&R(`div`,{className:`settings-card`,role:`alert`,children:[I(`span`,{className:`settings-label`,children:t(`settings.skills.skipped`)}),I(`ul`,{className:`grant-list`,children:Object.entries(i).map(([e,n])=>I(`li`,{children:t(WQ(n),{name:e.split(/[\\/]/).filter(Boolean).pop()??e})},e))})]}),u&&I(tX,{title:t(`settings.skills.removeTitle`,{name:u.name}),confirmLabel:t(`settings.skills.remove`),cancelLabel:t(`settings.skills.keep`),danger:!0,busy:u.busy,onConfirm:()=>void _(u.name),onCancel:()=>d(null),children:I(`p`,{children:t(`settings.skills.removeBody`,HQ)})})]})}var KQ=`profile`;function qQ(){let e=L(),[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(!1);(0,V.useEffect)(()=>{qq().then(n).catch(e=>i(e instanceof Error?e.message:String(e)))},[]);let l=(0,V.useCallback)(async e=>{o(!0),i(null),c(!1);try{let t=await Jq(e===KQ?null:e);n(t),c(t.changed!==!1)}catch(e){i(e instanceof Error?e.message:String(e)),await qq().then(n).catch(()=>void 0)}finally{o(!1)}},[]);if(!t)return r?I(`p`,{className:`settings-error`,role:`alert`,children:r}):R(`p`,{className:`settings-hint`,children:[I(so,{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 R(P.Fragment,{children:[R(`div`,{className:`model-in-use-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`embedder-device`,children:e(`settings.memory.embedder.label`)}),R(`select`,{id:`embedder-device`,className:`settings-input`,value:t.chosen?t.device:KQ,onChange:e=>void l(e.target.value),disabled:a,children:[I(`option`,{value:KQ,children:e.bare(`settings.memory.embedder.default`,{device:d(t.default_device)})}),t.options.map(t=>I(`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))]})]}),R(`span`,{className:`settings-hint`,children:[e(`settings.memory.embedder.runsOn`,{name:Ve(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)&&I(`span`,{className:`settings-hint`,children:e(`settings.memory.embedder.npuUnproven`)}),u?.downloaded===!1&&I(`span`,{className:`settings-hint`,children:e(`settings.memory.embedder.notDownloaded`)}),a&&R(`span`,{className:`settings-hint`,children:[I(so,{size:13,className:`spin`}),` `,e(`settings.memory.embedder.applying`)]}),s&&I(`p`,{className:`settings-ok`,role:`status`,children:e(`settings.memory.embedder.changed`)}),r&&I(`p`,{className:`settings-error`,role:`alert`,children:r})]})}function JQ(){let e=L(),t=B(e=>e.setShowMemoryDashboard),n=B(e=>e.closeSettings),r=B(e=>e.openSettings),i=Oz(e=>e.current)===`gaiacpp`,[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1);(0,V.useEffect)(()=>{Gq().then(o).catch(e=>c(e instanceof Error?e.message:String(e)))},[]);let d=(0,V.useCallback)(async()=>{if(a){u(!0),c(null);try{o(await Kq({memory_enabled:!a.memory_enabled}))}catch(e){c(e instanceof Error?e.message:String(e))}finally{u(!1)}}},[a]);return R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.memory`)}),I(`p`,{className:`settings-pane-lede`,children:e(`settings.memory.lede`)}),i&&R(`div`,{className:`settings-notice`,role:`status`,children:[I(`p`,{children:e(`settings.memory.fastAgentNotice`)}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>r(`model`),children:e.compose(e=>e(`mem.store.change`,{tab:e(`settings.section.model`)}))})]}),R(`section`,{className:`settings-card`,"aria-label":e(`settings.section.memory`),children:[R(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`settings.memory.remember`)}),R(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,checked:!!a?.memory_enabled,onChange:()=>void d(),disabled:!a||l,"aria-label":e(`settings.memory.remember`)}),I(`span`,{className:`toggle-track`})]})]}),s&&I(`p`,{className:`settings-error`,role:`alert`,children:s}),R(`div`,{className:`settings-row settings-row-between`,children:[I(`span`,{className:`settings-hint`,children:e(`settings.memory.dashboardHint`)}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{n(),t(!0)},children:e(`settings.memory.dashboard`)})]})]}),!i&&I(`section`,{className:`settings-card`,"aria-label":e(`settings.memory.embedder.label`),children:I(qQ,{})})]})}function YQ(e,t,n){if(!/^\d+$/.test(e.trim()))return!1;let r=Number(e);return r>=t&&r<=n}function XQ(e){return e<1048576?`${Math.ceil(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function ZQ(){let e=L(),[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(``),[a,o]=(0,V.useState)(``),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1);(0,V.useEffect)(()=>{yn().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,V.useState)({days:!1,mb:!1}),p=!YQ(r,1,365)||d.days,m=!YQ(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 Xe(Number(r),Number(a));n(t),c({ok:!0,text:e(`settings.undo.saved`)})}catch(t){let n=t instanceof En&&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 R(`div`,{className:`settings-field`,"aria-label":e(`settings.privacy.undo`),children:[I(`span`,{className:`settings-label`,children:e(`settings.privacy.undo`)}),I(`p`,{className:`settings-hint`,children:e(`settings.undo.hint`)}),t&&R(P.Fragment,{children:[R(`div`,{className:`setting-row`,children:[I(`label`,{htmlFor:`undo-days`,children:e(`settings.undo.days`)}),I(`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&&I(`p`,{id:`undo-days-error`,className:`settings-error`,children:e(`settings.undo.daysError`)}),R(`div`,{className:`setting-row`,children:[I(`label`,{htmlFor:`undo-mb`,children:e(`settings.undo.mb`)}),I(`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&&I(`p`,{id:`undo-mb-error`,className:`settings-error`,children:e(`settings.undo.mbError`)}),R(`div`,{className:`setting-row setting-row-path`,children:[I(`span`,{children:e(`settings.undo.inUse`)}),R(`span`,{children:[e.plural(`settings.undo.used`,t.turns,{size:XQ(t.used_bytes)}),` `,I(`bdi`,{dir:`ltr`,children:I(`code`,{className:`setting-path`,children:t.path})})]})]}),I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void g(),disabled:!h||l||p||m,children:e(l?`settings.models.applying`:`settings.advanced.save`)})]}),s&&I(`p`,{className:s.ok?`settings-ok`:`settings-error`,role:s.ok?`status`:`alert`,children:s.text})]})}var QQ={root:`settings-report`,button:`btn-secondary`,hint:`settings-hint`,error:`settings-error`};function $Q(){let e=L(),t=B(e=>e.sessions),n=B(e=>e.removeSession),r=il(),i=B(e=>e.systemStatus?.data_dir),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(null),[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)(!1),[h,g]=(0,V.useState)(null);(0,V.useEffect)(()=>{let e=!0;return ut().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,V.useCallback)(async()=>{if(d===null||p)return;let t=d,n=Xc.getState().active?.model,r=!t;f(r),m(!0),g(null);try{let t=await He({network_policy:r?`local_ai_only`:`cloud_allowed`});f(t.network_policy===`local_ai_only`),Zc(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,V.useCallback)(async t=>{try{await pt(t,!1)}catch(t){u({ok:!1,text:e(`settings.privacy.openFolderFailed`,{reason:t instanceof Error?t.message:String(t)})})}},[e]),y=(0,V.useCallback)(async()=>{c(!0);let r=[];for(let e of t)try{await ar(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 R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.privacy`)}),R(`section`,{className:`settings-card`,"aria-label":e(`settings.privacy.localOnlyTitle`),children:[R(`div`,{children:[R(`label`,{className:`setting-row`,children:[I(`strong`,{children:e(`settings.privacy.localOnlyTitle`)}),R(`span`,{className:`toggle-switch`,children:[I(`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}),I(`span`,{className:`toggle-track`})]})]}),I(`p`,{className:`settings-hint`,id:`privacy-local-only-hint`,children:e(`settings.privacy.localOnlyHint`)})]}),h&&I(`p`,{className:h.ok?`settings-ok`:`settings-error`,role:h.ok?`status`:`alert`,children:h.text})]}),R(`section`,{className:`settings-card`,"aria-labelledby":`privacy-where-title`,children:[I(`h3`,{className:`settings-label`,id:`privacy-where-title`,children:e(`settings.privacy.whereTitle`)}),I(`p`,{className:`settings-note`,children:e(`settings.privacy.stays`)}),I(`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&&R(`div`,{className:`setting-row setting-row-path`,children:[I(`span`,{children:e(`settings.privacy.dataFolder`)}),R(`span`,{className:`setting-path-actions`,children:[I(`bdi`,{dir:`ltr`,className:`setting-path`,children:i}),I(`button`,{type:`button`,className:`link-btn`,onClick:()=>void v(i),children:e(`settings.privacy.openFolder`)})]})]})]}),R(`section`,{className:`settings-card`,"aria-labelledby":`privacy-report-title`,children:[I(`h3`,{className:`settings-label`,id:`privacy-report-title`,children:e(`settings.privacy.reportTitle`)}),I(`p`,{className:`settings-note`,children:e(`settings.privacy.reportNote`)}),I(EF,{classes:QQ})]}),I(KZ,{title:e(`settings.privacy.undo`),children:I(ZQ,{})}),R(`section`,{className:`settings-card`,"aria-labelledby":`privacy-delete-title`,children:[I(`h3`,{className:`settings-label`,id:`privacy-delete-title`,children:e(`settings.privacy.deleteTitle`)}),I(`p`,{className:`danger-warning`,children:t.length===0?e(`settings.privacy.nothingToDelete`):e(`settings.privacy.deleteWarning`)}),I(`button`,{type:`button`,className:`btn-danger`,onClick:()=>{u(null),o(t.length)},disabled:t.length===0,children:e(`settings.privacy.delete`)})]}),a!==null&&R(tX,{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:[I(`p`,{children:e(`settings.privacy.deleteWarning`)}),I(`p`,{children:e(`settings.privacy.deleteFinal`)})]}),l&&I(`p`,{className:l.ok?`settings-ok`:`settings-error`,role:l.ok?`status`:`alert`,children:l.text})]})}var e$=[{id:`needs_approval`,label:`settings.alerts.approval`},{id:`question`,label:`settings.alerts.question`},{id:`finished`,label:`settings.alerts.finished`}],t$=[{value:`banner`,label:`settings.alerts.banner`},{value:`badge`,label:`settings.alerts.badge`},{value:`off`,label:`settings.alerts.off`}],n$=[0,10,20,30,50];function r$(){return typeof Notification>`u`?`unsupported`:Notification.permission}function i$(){let e=L(),t=hu(),n=!!window.gaiaAPI,[r,i]=(0,V.useState)(r$),a=Object.values(t.modes).includes(`banner`);return R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.notifications`)}),I(`p`,{className:`settings-pane-lede`,children:e(`settings.alerts.lede`)}),R(`section`,{className:`settings-card`,"aria-label":e(`settings.alerts.when`),children:[e$.map(n=>R(`div`,{className:`setting-row`,children:[I(`span`,{id:`alert-${n.id}`,children:e(n.label)}),I(VV,{className:`segmented`,"aria-labelledby":`alert-${n.id}`,children:t$.map(r=>I(`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"?I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{Notification.requestPermission().then(i).catch(e=>{console.error(`[alerts] Notification permission request failed`,e),i(r$())})},children:e(`settings.alerts.allow`)}):I(`p`,{className:`settings-error`,role:`alert`,children:e(r===`unsupported`?`settings.alerts.unsupported`:`settings.alerts.blocked`)})),R(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`settings.alerts.sound`)}),R(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,checked:t.sound,onChange:()=>t.update({sound:!t.sound}),"aria-label":e(`settings.alerts.sound`)}),I(`span`,{className:`toggle-track`})]})]}),n&&R(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`settings.alerts.flash`)}),R(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,checked:t.flash,onChange:()=>t.update({flash:!t.flash}),"aria-label":e(`settings.alerts.flash`)}),I(`span`,{className:`toggle-track`})]})]})]}),R(`section`,{className:`settings-card`,"aria-labelledby":`keep-awake-title`,children:[I(`h3`,{className:`settings-label`,id:`keep-awake-title`,children:e(`settings.alerts.keepAwakeTitle`)}),n?R(P.Fragment,{children:[R(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`settings.alerts.keepAwake`)}),R(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,checked:t.keepAwake,onChange:()=>t.update({keepAwake:!t.keepAwake}),"aria-label":e(`settings.alerts.keepAwake`)}),I(`span`,{className:`toggle-track`})]})]}),R(`div`,{className:`setting-row`,children:[I(`label`,{htmlFor:`battery-floor`,children:e(`settings.alerts.battery`)}),I(`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:n$.map(t=>I(`option`,{value:t,children:t===0?e.bare(`settings.alerts.never`):`${t}%`},t))})]}),I(`p`,{className:`settings-hint`,children:e(`settings.alerts.screen`)})]}):I(`p`,{className:`settings-hint`,children:e(`settings.alerts.desktopOnly`)})]})]})}var a$=[50,75,100,125,150,175,200],o$=[{accent:`american`,gender:`female`},{accent:`american`,gender:`male`},{accent:`british`,gender:`female`},{accent:`british`,gender:`male`}],s$=`settings:preview`,c$=`Hello, I'm GAIA. This is how I'll read my replies to you.`;function l$(e){return e instanceof En?e.detail||e.message:String(e)}function u$(){let e=L(),t=aF(e=>e.settings),n=aF(e=>e.setSettings),r=aF(e=>e.read),i=aF(e=>e.stop),a=aF(e=>e.messageId===s$),o=aF(e=>e.messageId===s$&&e.status===`loading`),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(null),[d,f]=(0,V.useState)(!1);(0,V.useEffect)(()=>{KP().then(n).catch(e=>c(l$(e)))},[n]);let p=e=>{f(!0),u(null),aF.getState().messageId===s$&&i(),qP(e).then(n).catch(e=>u(l$(e))).finally(()=>f(!1))};return s?R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.voice`)}),I(`p`,{className:`settings-error`,role:`alert`,children:e(`readAloud.settings.loadFailed`,{reason:s})})]}):t?t.available===!1?R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.voice`)}),I(`p`,{className:`settings-pane-lede`,role:`status`,children:e(`readAloud.settings.unavailable`)})]}):R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.voice`)}),I(`p`,{className:`settings-pane-lede`,children:e(`readAloud.settings.lede`)}),R(`div`,{className:`settings-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`read-aloud-voice`,children:e(`readAloud.settings.voice`)}),R(`div`,{className:`read-aloud-voice-row`,children:[I(`select`,{id:`read-aloud-voice`,className:`settings-input`,value:t.voice,disabled:d,onChange:e=>p({voice:e.target.value}),children:o$.map(n=>I(`optgroup`,{label:e(`readAloud.group.${n.accent}.${n.gender}`),children:t.voices.filter(e=>e.accent===n.accent&&e.gender===n.gender).map(e=>I(`option`,{value:e.id,lang:`en`,children:e.name},e.id))},`${n.accent}-${n.gender}`))}),R(`button`,{type:`button`,className:`btn-secondary`,"aria-pressed":a,disabled:d,onClick:()=>a?i():void r(s$,c$),children:[o?I(so,{size:13,className:`spin`}):I(a?Ks:oc,{size:13}),e(a?`readAloud.stop`:`readAloud.settings.preview`)]})]}),I(`span`,{className:`settings-hint`,children:e(`readAloud.settings.englishOnly`)}),I(cF,{messageId:s$})]}),R(`div`,{className:`settings-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`read-aloud-speed`,children:e(`readAloud.settings.speed`)}),I(`select`,{id:`read-aloud-speed`,className:`settings-input`,value:t.speed,disabled:d,onChange:e=>p({speed:Number(e.target.value)}),children:(a$.includes(t.speed)?a$:[...a$,t.speed].sort((e,t)=>e-t)).map(t=>I(`option`,{value:t,children:t===100?e.bare(`readAloud.settings.normalSpeed`):`${(t/100).toLocaleString(e.locale)}×`},t))})]}),R(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`readAloud.settings.auto`)}),R(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,checked:t.auto,disabled:d,onChange:()=>p({auto:!t.auto}),"aria-label":e(`readAloud.settings.auto`)}),I(`span`,{className:`toggle-track`})]})]}),I(`p`,{className:`settings-hint`,children:e(`readAloud.settings.shared`)}),l&&I(`p`,{className:`settings-error`,role:`alert`,children:e(`readAloud.settings.saveFailed`,{reason:l})})]}):R(`p`,{className:`settings-hint`,children:[I(so,{size:13,className:`spin`}),` `,e(`settings.loading`)]})}function d$(e,{message:t,model:n,reason:r,reasonCode:i}){if(!n||!r||ht(`model.restore.failed`,{model:n,reason:r})!==t)return Ve(t,`ltr`);let a=`model.restore.reason.${i}`;return e(`model.restore.failed`,{model:n,reason:i&&k(a)&&ht(a)===r?M(a):r})}function f$(){let e=L(),t=B(e=>e.jumpToSetting),n=B(e=>e.closeSettings),r=B(e=>e.runSetupAgain),i=Xc(e=>e.active),o=B(e=>e.systemStatus?.lemonade_running===!1),s=i?.restore?.status===`failed`&&!!i.model&&i.restore.model_id===i.model,c=i?.restore,l=s&&c?.message?d$(e,{message:c.message,model:c.model,reason:c.reason,reasonCode:c.reason_code}):null,u=!o&&s,[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(null),[y,b]=(0,V.useState)(null),[x,S]=(0,V.useState)(!1);(0,V.useEffect)(()=>{a().then(f).catch(e=>b(e instanceof Error?e.message:String(e))),ke().then(m).catch(e=>b(e instanceof Error?e.message:String(e))),tt().then(e=>g(e??null)).catch(e=>v(e instanceof Error?e.message:String(e)))},[]);let C=d?.catalog?.find(e=>e.id===d.chat_model.id),w=(i?.model?i.remote?i.label??el(i.model):el(i.model):null)??C?.name??null,T=(d?.catalog??[]).filter(e=>e.downloaded),E=T.reduce((e,t)=>e+(t.full_size_gb??0),0),ee=[p?.gpu_name,p?.npu_detected?e(`setup.checks.npu`):null].filter(Boolean).join(` · `),D=LA(d?.system?.physical_memory,p?.ram_gb),O=D&&VA(e.locale,D),te=d?.capacity_gb==null?null:VA(e.locale,PA(d.capacity_gb)),k=te?O?e(`settings.setup.memoryOf`,{size:te,total:O}):e(`settings.setup.memoryFor`,{size:te}):O,A=[{title:e(`settings.setup.where`),rows:[{label:e(`settings.setup.chatRuns`),value:w,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:[ee,k].filter(Boolean).join(` · `)||null},{label:e(`settings.setup.server`),value:d?.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:!!h?.applies||!!_&&!sQ(_)}]},{title:e(`setup.models.step`),rows:[{label:e(`settings.setup.models`),value:d?.catalog?e(`settings.setup.modelsValue`,{n:String(T.length),size:PA(E)}):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 R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.setup`)}),I(`p`,{className:`settings-hint`,children:e(`settings.setup.lede`)}),R(`div`,{className:`settings-setup-status`,children:[R(`span`,{children:[I(`strong`,{children:e(o?`settings.setup.serverDown`:u?`settings.setup.chatUnusable`:`settings.setup.ready`)}),u&&l&&R(`span`,{className:`settings-hint`,children:[` `,I(`bdi`,{children:l})]}),w&&!o&&!u&&R(`span`,{className:`settings-hint`,children:[` `,I(`bdi`,{children:e(`settings.setup.running`,{name:w})})]})]}),I(`button`,{type:`button`,className:`btn-secondary`,"data-testid":`setup-run-again`,onClick:()=>S(!0),children:e(`settings.setup.runAgain`)})]}),y&&I(`p`,{className:`setup-error`,role:`alert`,children:y}),A.map(e=>R(`section`,{className:`settings-setup-group`,"aria-label":e.title,children:[I(`h3`,{className:`settings-label`,children:e.title}),e.rows.filter(e=>e.shown!==!1).map(e=>{let n=R(`span`,{children:[I(`span`,{className:`settings-setup-row-label`,children:e.label}),e.value&&I(`bdi`,{className:`settings-hint settings-setup-row-value`,children:e.value})]}),r=e.section;return r?R(`button`,{type:`button`,className:`settings-setup-row`,onClick:()=>t({section:r,target:e.target??`.settings-pane-title`,from:`setup`},e.provider),children:[n,I(di,{size:14,className:`settings-setup-chevron`,"aria-hidden":`true`})]},e.label):I(`div`,{className:`settings-setup-row is-fact`,children:n},e.label)})]},e.title)),x&&I(tX,{title:e(`settings.setup.confirmTitle`),confirmLabel:e(`settings.setup.confirmYes`),cancelLabel:e(`setup.again.notNow`),onConfirm:()=>{S(!1),n(),r(!0)},onCancel:()=>S(!1),children:I(`p`,{children:e(`settings.setup.confirmBody`)})})]})}var p$=[{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 m$(){let e=L(),t=B(e=>e.openSettings),n=`GAIA v0.27.0rc22`,[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(null),s=(0,V.useRef)(null);(0,V.useEffect)(()=>()=>{s.current&&clearTimeout(s.current)},[]);let c=(0,V.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 R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.about`)}),R(`section`,{className:`settings-card`,"aria-labelledby":`about-version`,children:[R(`div`,{className:`settings-row settings-row-between`,children:[R(`span`,{children:[I(`strong`,{id:`about-version`,children:I(`bdi`,{dir:`ltr`,children:n})}),` `,I(`span`,{className:`beta-badge`,children:`BETA`})]}),R(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void c(),children:[I(r?ri:Fi,{size:13,"aria-hidden":`true`}),e(r?`settings.about.copied`:`settings.about.copy`)]})]}),I(`p`,{className:`settings-hint`,children:e(`settings.advanced.about`)}),a&&I(`p`,{className:`settings-error`,role:`alert`,children:a})]}),R(`section`,{className:`settings-card`,"aria-label":e(`settings.about.links`),children:[I(`ul`,{className:`settings-about-links`,children:p$.map(t=>I(`li`,{children:R(`a`,{href:t.href,target:`_blank`,rel:`noopener noreferrer`,children:[e(t.label),` `,I(Zi,{size:12,"aria-hidden":`true`})]})},t.href))}),R(`p`,{className:`settings-hint`,children:[e(`settings.about.reportHint`),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>t(`privacy`),children:e(`settings.about.reportWhere`)})]})]})]})}var h$=class extends V.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?I(g$,{variant:this.props.variant??`fill`,onRetry:()=>this.setState({hasError:!1})}):this.props.children}};function g$({onRetry:e,variant:t}){let n=L();return R(`div`,{role:`alert`,className:`error-boundary error-boundary-${t}`,children:[I(`p`,{className:`error-boundary-title`,children:n(`errorBoundary.title`)}),I(`p`,{className:`error-boundary-body`,children:n(t===`window`?`errorBoundary.bodyWindow`:`errorBoundary.body`)}),R(`div`,{className:`error-boundary-actions`,children:[I(`button`,{type:`button`,className:`btn-primary`,onClick:e,children:n(`errorBoundary.retry`)}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>window.location.reload(),children:n(`errorBoundary.reload`)})]})]})}var _$=`modulepreload`,v$=function(e,t){return new URL(e,t).href},y$={},b$=function(e){return e.pathname.endsWith(`.css`)},x$=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},S$=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=v$(t,n);let r=s(t),i=b$(r);return x$(y$,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`:_$,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)})},C$=(0,V.lazy)(()=>S$(()=>import(`./ConnectorsPane-BUyODU0h.js`).then(e=>({default:e.ConnectorsPane})),__vite__mapDeps([0,1,2,3]),import.meta.url)),w$=(0,V.lazy)(()=>S$(()=>import(`./MessagingSettings-DQWJatxm.js`).then(e=>({default:e.MessagingSettings})),__vite__mapDeps([4,1,2]),import.meta.url)),T$=(0,V.lazy)(()=>S$(()=>import(`./AutomationsSettings-D4YxWU3Q.js`).then(e=>({default:e.AutomationsSettings})),__vite__mapDeps([5,1,2]),import.meta.url)),E$=(0,V.lazy)(()=>S$(()=>import(`./AdvancedSettings-CDgnCM7O.js`).then(e=>({default:e.AdvancedSettings})),__vite__mapDeps([6,1,2]),import.meta.url)),D$=[`general`,`setup`,`model`,`images`,`permissions`,`skills`,`connectors`,`messaging`,`automations`,`memory`,`notifications`,`voice`,`privacy`,`advanced`,`about`];function O$({onUseSkill:e}){let t=L(),n=B(e=>e.settingsSection),r=B(e=>e.openSettings),i=B(e=>e.closeSettings),a=B(e=>e.settingsJump),o=(0,V.useRef)(null),s=(0,V.useRef)(null),c=n!==null;if(Qn(c,i),_n(o,c),FJ(o,c,()=>o.current?.querySelector(`.settings-nav-item.is-active`)),(0,V.useLayoutEffect)(()=>{s.current&&(s.current.scrollTop=0)},[n]),(0,V.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=D$.indexOf(n),i=e.key===`ArrowDown`?(t+1)%D$.length:e.key===`ArrowUp`?(t-1+D$.length)%D$.length:e.key===`Home`?0:e.key===`End`?D$.length-1:null;i!==null&&(e.preventDefault(),r(D$[i]),o.current?.querySelector(`[data-section="${D$[i]}"]`)?.focus())},d=(()=>{switch(n){case`general`:return I(oQ,{});case`setup`:return I(f$,{});case`model`:return I(kQ,{});case`images`:return I(FQ,{});case`permissions`:return I(IQ,{});case`skills`:return I(GQ,{onUseSkill:t=>{i(),e(t)}});case`connectors`:return I(C$,{});case`messaging`:return I(w$,{});case`automations`:return I(T$,{});case`memory`:return I(JQ,{});case`notifications`:return I(i$,{});case`voice`:return I(u$,{});case`privacy`:return I($Q,{});case`advanced`:return I(E$,{});case`about`:return I(m$,{})}})();return I(`div`,{className:`settings-overlay`,onMouseDown:e=>{e.target===e.currentTarget&&i()},children:R(`div`,{ref:o,className:`settings-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`settings.title`),children:[R(`nav`,{className:`settings-nav`,"aria-label":t(`settings.sections`),onKeyDown:u,children:[I(`h1`,{className:`settings-nav-title`,children:t(`settings.title`)}),D$.map(e=>I(`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))]}),R(`div`,{className:`settings-body`,children:[I(`button`,{type:`button`,className:`settings-close`,onClick:i,"aria-label":t(`settings.close`),children:I(fc,{size:18})}),l&&R(`button`,{type:`button`,className:`settings-back`,onClick:()=>{r(l),o.current?.querySelector(`[data-section="${l}"]`)?.focus()},children:[I(li,{size:14,"aria-hidden":`true`}),t.compose(e=>e(`settings.backTo`,{section:e(`settings.section.${l}`)}))]}),I(`div`,{ref:s,className:`settings-scroll`,children:I(h$,{area:`settings.${n}`,children:I(V.Suspense,{fallback:R(`p`,{className:`settings-hint`,children:[I(so,{size:13,className:`spin`}),` `,t(`settings.loading`)]}),children:d})},n)})]})]})})}var k$=`gaia:personalize-connector`,A$=[[`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 j$(e,t){let n=e.toLowerCase().replace(/^mcp-/,``),r=A$.find(([e])=>n.startsWith(e));return r?r[1]:`my recent activity in ${t}`}function M$(e){let t=e.toLowerCase().replace(/^mcp-/,``),n=A$.find(([e])=>t.startsWith(e));return n?n[0]:null}function N$({connectorId:e,displayName:t}){return[`I just connected ${t}. Get to know me from ${j$(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(`
|
|
217
217
|
`)}function P$(e){window.dispatchEvent(new CustomEvent(k$,{detail:e}))}function F$(e,t){let[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(!1),[s,c]=(0,V.useState)(null),l=(0,V.useRef)(null),u=(0,V.useRef)(null),d=(0,V.useRef)(null),f=(0,V.useCallback)(()=>{l.current&&=(clearTimeout(l.current),null),u.current&&=(clearTimeout(u.current),null),d.current&&=(clearInterval(d.current),null)},[]);(0,V.useEffect)(()=>f,[f]);let p=(0,V.useCallback)((e,t)=>{d.current&&clearInterval(d.current),d.current=setInterval(async()=>{try{let n=await o();t===`load`?$c(n.model_loaded,e)&&(r(!1),l.current&&=(clearTimeout(l.current),null),d.current&&=(clearInterval(d.current),null)):(n.model_downloaded===!0||$c(n.model_loaded,e))&&(a(!1),u.current&&=(clearTimeout(u.current),null),d.current&&=(clearInterval(d.current),null))}catch{}},Wu)},[]),m=e??`Gemma-4-E4B-it-GGUF`;return(0,V.useEffect)(()=>c(null),[m]),{isLoadingModel:n,isDownloadingModel:i,downloadError:s,loadModel:(0,V.useCallback)(async(e,n)=>{let i=e??m,a=n??t;r(!0);try{if(!await mn(i,a)){r(!1);return}F.system.info(`Load model triggered: ${i} (ctx=${a??`server default`})`),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>r(!1),Hu),p(i,`load`)}catch(e){F.system.error(`Failed to trigger model load`,e),r(!1)}},[m,t,p]),downloadModel:(0,V.useCallback)(async(e=!1,t,n=!1)=>{let r=t??m;a(!0),c(null);try{await Ce(r,e,n),F.system.info(`Download model triggered: ${r} (force=${e})`),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>a(!1),Uu),p(r,`download`)}catch(e){F.system.error(`Failed to trigger model download`,e),c(e instanceof Error?e.message:String(e)),a(!1)}},[m,p])}}function I$({onRetry:e,label:t,busyLabel:n}){let r=L(),[i,a]=(0,V.useState)(!1);return I(`button`,{className:`connection-banner__retry`,onClick:()=>{a(!0),Promise.resolve(e()).finally(()=>a(!1))},disabled:i,children:i?n??r(`banner.checking`):t})}function L$(e){return`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)}`}function R$({lifecycle:e}){let t=L(),n=ZL(e=>e.restart),r=ZL(e=>e.restartError),i=e.status===`restarting`,[a,o]=(0,V.useState)(()=>Date.now());if((0,V.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 R(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(so,{size:16,className:`connection-banner__spinner`})}),R(`div`,{className:`connection-banner__text`,dir:`auto`,children:[t(`banner.restarting`),` `,I(`bdi`,{dir:`ltr`,className:`connection-banner__timer`,children:L$(n)}),` `,I(`span`,{className:`connection-banner__hint`,children:t(`banner.restartingHint`)})]})]})}return R(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[I(`div`,{className:`connection-banner__icon`,children:I(ec,{size:16})}),R(`div`,{className:`connection-banner__text`,dir:`auto`,children:[t(`banner.restartStopped`),` `,I(`span`,{className:`connection-banner__hint`,children:r?t(`banner.restartFailed`,{error:r}):t(`banner.restartStoppedHint`)})]}),I(I$,{onRetry:n,label:t(`banner.restartButton`),busyLabel:t(`banner.restartingShort`)})]})}function z$({onRetry:e,backendSlow:t=!1,backendError:n=null}){let r=L(),{backendConnected:i,systemStatus:a,currentSessionId:o,messages:s}=B(),c=B(e=>e.backendStalled),l=B(e=>e.isStreaming),u=ZL(e=>e.lifecycle),d=ZL(e=>e.restart),f=ZL(e=>e.restartError),p=u!==null,[m,h]=(0,V.useState)(!1),g=!!o&&s.length>0,_=a?.default_model_name??`Gemma-4-E4B-it-GGUF`,{isDownloadingModel:v,downloadError:y,downloadModel:b}=F$(_),x=Xc(e=>e.pickLoad),S=Xc(e=>e.retryPickLoad),C=Xc(e=>e.dismissPickLoad);Qc();let w=(0,V.useRef)(a?.lemonade_running),T=(0,V.useRef)(a?.model_downloaded),E=(0,V.useRef)(a?.context_size_sufficient),ee=(0,V.useRef)(a?.expected_model_loaded);(0,V.useEffect)(()=>{if(g)return;let e=a?.lemonade_running,t=a?.model_downloaded,n=a?.context_size_sufficient,r=a?.expected_model_loaded,i=!1;w.current!==e&&(w.current=e,e===!1&&(i=!0)),T.current!==t&&(T.current=t,t===!1&&(i=!0)),E.current!==n&&(E.current=n,n===!1&&(i=!0)),ee.current!==r&&(ee.current=r,r===!1&&(i=!0)),i&&h(!1)},[a,g]);let D=a?.download_progress??null,O=v||D?.state===`downloading`||D?.state===`starting`,te=B(e=>e.dismissDownloadFailure);if(u&&u.status!==`running`)return I(R$,{lifecycle:u});let A=D?.model_name||_,ne=async()=>{try{await te(D?.model_name??A)}catch{}};if(O||D?.state===`error`){let e=el(A),t=D?.total_bytes?VA(r.locale,`${(D.total_bytes/1e9).toFixed(1)} GB`):r(`banner.download.sizeUnknown`),n=D?.state===`error`;return R(`div`,{className:`connection-banner ${n?`connection-banner--error`:`connection-banner--warning`}`,role:n?`alert`:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(n?ec:Ui,{size:16})}),I(`div`,{className:`connection-banner__text`,dir:`auto`,children:n?R(P.Fragment,{children:[r(`banner.download.failed`,{model:e}),` `,(y??D?.message)&&I(`span`,{className:`connection-banner__hint`,children:y??D?.message})]}):R(P.Fragment,{children:[r(`banner.download.running`,{model:e,size:t}),D?.state===`downloading`&&D.file&&R(P.Fragment,{children:[` `,R(`span`,{className:`connection-banner__hint`,children:[r(`banner.download.file`,{index:D.file_index,total:D.total_files}),` `,I(`code`,{children:D.file})]})]})]})}),n?I(`button`,{className:`connection-banner__retry`,onClick:()=>b(!1,A,!a?.model_loaded),children:r(`banner.download.retry`)}):I(`span`,{className:`connection-banner__loading connection-banner__progress`,children:D&&D.state===`downloading`&&D.total_bytes>0?R(P.Fragment,{children:[I(`span`,{className:`connection-banner__progress-bar`,role:`progressbar`,"aria-valuenow":D.percent,"aria-valuemin":0,"aria-valuemax":100,"aria-label":r(`banner.download.progress`),children:I(`span`,{className:`connection-banner__progress-fill`,style:{width:`${D.percent}%`}})}),R(`bdi`,{className:`connection-banner__progress-label`,dir:`ltr`,children:[D.percent,`% ·`,` `,(D.downloaded_bytes/1e9).toFixed(2),` /`,` `,(D.total_bytes/1e9).toFixed(2),` GB`]})]}):R(P.Fragment,{children:[I(so,{size:13,className:`connection-banner__spinner`}),D?.state===`starting`?D.message??r(`banner.download.starting`):r(`banner.download.downloading`)]})}),n&&I(`button`,{className:`connection-banner__dismiss`,onClick:()=>void ne(),"aria-label":r(`banner.dismiss`),children:I(fc,{size:14})})]})}if(x){let e=el(x.model);return x.error?R(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[I(`div`,{className:`connection-banner__icon`,children:I(ec,{size:16})}),R(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.pickLoad.failed`,{model:e}),` `,I(`span`,{className:`connection-banner__hint`,dir:`auto`,children:x.error.key?r(x.error.key,{reason:x.error.reason}):x.error.reason})]}),I(I$,{onRetry:S,label:r(`banner.pickLoad.retry`)}),I(`button`,{className:`connection-banner__dismiss`,onClick:C,"aria-label":r(`banner.dismiss`),children:I(fc,{size:14})})]}):R(`div`,{className:`connection-banner connection-banner--init`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(so,{size:16,className:`connection-banner__spinner`})}),R(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.pickLoad.loading`,{model:e}),` `,I(`bdi`,{dir:`ltr`,children:r(`banner.pickLoad.seconds`,{s:x.seconds})}),` `,I(`span`,{className:`connection-banner__hint`,children:r(`banner.pickLoad.canType`)})]})]})}let re=a?.init_tasks?.find(e=>e.step===`check_server`),j=a?.lemonade_running===!1&&!!re&&re.status!==`pending`&&re.status!==`running`;if(xR(a)&&!t&&!n&&!j){let e=a?.init_tasks?.find(e=>e.status===`running`)?.step,t=`banner.boot.${e}`,n=e&&k(t)?r(t):r(`banner.boot.generic`);return R(`div`,{className:`connection-banner connection-banner--init`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(so,{size:16,className:`connection-banner__spinner`})}),R(`div`,{className:`connection-banner__text`,dir:`auto`,children:[n,R(`span`,{className:`thinking-dots`,children:[I(`span`,{children:`.`}),I(`span`,{children:`.`}),I(`span`,{children:`.`})]})]})]})}if(!i)return R(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[I(`div`,{className:`connection-banner__icon`,children:I(cc,{size:16})}),R(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.unreachable`),` `,I(`span`,{className:`connection-banner__hint`,children:f?r(`banner.restartFailed`,{error:f}):r(`banner.unreachableHint`)})]}),e&&I(I$,{onRetry:e,label:r(`banner.retry`)}),p&&I(I$,{onRetry:d,label:r(`banner.restartButton`),busyLabel:r(`banner.restartingShort`)})]});if(n)return R(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(ec,{size:16})}),R(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.backendError`,{error:n}),` `,I(`span`,{className:`connection-banner__hint`,children:r(`banner.backendErrorHint`)})]}),e&&I(I$,{onRetry:e,label:r(`settings.key.checkAgain`)})]});if(t||c)return R(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(ec,{size:16})}),R(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.backendSlow`),` `,I(`span`,{className:`connection-banner__hint`,children:f?r(`banner.restartFailed`,{error:f}):r(`banner.backendSlowHint`)})]}),e&&I(I$,{onRetry:e,label:r(`settings.key.checkAgain`)}),p&&(c||!l)&&I(I$,{onRetry:d,label:r(`banner.restartButton`),busyLabel:r(`banner.restartingShort`)})]});if(m||g)return null;if(a?.config_error)return R(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[I(`div`,{className:`connection-banner__icon`,children:I(ec,{size:16})}),R(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.configError`),` `,I(`span`,{className:`connection-banner__hint`,children:a.config_error})]}),e&&I(I$,{onRetry:e,label:r(`settings.key.checkAgain`)})]});if(a&&!a.lemonade_running){let t=SR(a)===`unresponsive`,n=!t&&fQ(a),i=t&&cQ(a.start_command)?null:a.start_command,o=t&&cQ(a.start_instruction)?null:a.start_instruction;return R(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(ec,{size:16})}),R(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(t?`banner.serverHung`:`banner.serverStopped`),` `,n?I(`span`,{className:`connection-banner__hint`,children:r(`banner.finishSetup`)}):i?R(`span`,{className:`connection-banner__hint`,children:[r(t?`banner.restartHint`:`banner.startHint`),` `,I(`code`,{dir:`ltr`,children:i})]}):o&&I(`span`,{className:`connection-banner__hint`,children:dQ(r,o)})]}),n&&I(pQ,{className:`connection-banner__retry`}),e&&I(I$,{onRetry:e,label:r(`settings.key.checkAgain`)}),I(`button`,{className:`connection-banner__dismiss`,onClick:()=>h(!0),"aria-label":r(`banner.dismiss`),children:I(fc,{size:14})})]})}if(a&&a.lemonade_running&&a.model_loaded&&a.context_size_sufficient===!1){let t=a.model_context_size??0;return R(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(Ya,{size:16})}),R(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.contextTooSmall`,{current:VA(r.locale,t.toLocaleString()),required:VA(r.locale,Bu.toLocaleString())}),` `,I(`span`,{className:`connection-banner__hint`,children:r(`banner.contextTooSmallHint`)})]}),e&&I(I$,{onRetry:e,label:r(`settings.key.checkAgain`)}),I(`button`,{className:`connection-banner__dismiss`,onClick:()=>h(!0),"aria-label":r(`banner.dismiss`),children:I(fc,{size:14})})]})}return null}var B$=`https://github.com/amd/gaia/releases`;function V$(){let e=oZ(),t=L(),[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(null),o=(0,V.useCallback)(e=>{let n=iZ();n&&(a(null),n[e]().catch(n=>{F.system.error(`Update ${e} failed`,n),a(uZ(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 R(`div`,{className:`update-chip update-chip--error`,role:`status`,children:[I(ec,{size:13,className:`update-chip__icon`}),I(`span`,{className:`update-chip__label`,title:i??void 0,children:t(i?`update.chip.updateFailed`:`update.chip.startFailed`)}),I(`button`,{type:`button`,className:`update-chip__action`,onClick:()=>o(`revertUpdate`),children:t(`update.chip.goBack`,{version:e.previousVersion})}),I(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>r(!0),"aria-label":t(`update.chip.dismissError`),children:I(fc,{size:11})})]});let l=e.status===`available`||e.status===`downloaded`;if(s&&!l)return R(`div`,{className:`update-chip update-chip--error`,role:`status`,title:s??void 0,children:[I(ec,{size:13,className:`update-chip__icon`}),I(`span`,{className:`update-chip__label`,children:t(`update.chip.installFailed`)}),I(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>r(!0),"aria-label":t(`update.chip.dismissError`),children:I(fc,{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 R(`div`,{className:`update-chip update-chip--downloading`,role:`status`,"aria-live":`polite`,title:t(`update.chip.downloadingTitle`,{version:e.version??``}),children:[I(Ui,{size:13,className:`update-chip__icon`}),I(`span`,{className:`update-chip__label`,children:e.preparing?t(`update.chip.preparing`):t(`update.chip.downloading`,{pct:n})})]})}return e.status===`available`?R(`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:[I(Ui,{size:13,className:`update-chip__icon`}),I(`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?I(`a`,{className:`update-chip__action`,href:e.downloadUrl??B$,target:`_blank`,rel:`noopener noreferrer`,children:t(`update.chip.download`)}):!e.pinnedVersion&&I(`button`,{type:`button`,className:`update-chip__action`,onClick:()=>o(`downloadUpdate`),children:t(`update.chip.updateNow`)}),I(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>r(!0),"aria-label":t(`update.chip.dismiss`),children:I(fc,{size:11})})]}):e.status===`downloaded`?R(`div`,{className:`update-chip update-chip--ready`,role:`status`,"aria-live":`polite`,children:[I(os,{size:13,className:`update-chip__icon`}),I(`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`?R(`div`,{className:`update-chip update-chip--error`,role:`status`,title:e.error||t(`update.chip.checkFailed`),children:[I(ec,{size:13,className:`update-chip__icon`}),I(`span`,{className:`update-chip__label`,children:t(`update.chip.checkFailed`)}),I(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>r(!0),"aria-label":t(`update.chip.dismissError`),children:I(fc,{size:11})})]}):null}var H$={permission_request:{icon:I(As,{size:16}),colorClass:`notif-type-permission`},policy_alert:{icon:I(As,{size:16}),colorClass:`notif-type-policy`},security_alert:{icon:I(ec,{size:16}),colorClass:`notif-type-security`},status_change:{icon:I(hi,{size:16}),colorClass:`notif-type-status`},info:{icon:I(Ua,{size:16}),colorClass:`notif-type-info`},error:{icon:I(yi,{size:16}),colorClass:`notif-type-error`}},U$=/([-])/;function W$(e){return e.split(U$).map((e,t)=>t%2?e:dd(e,!0)).join(``)}function G$(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(Fn(t),{month:`short`,day:`numeric`})}function K$({onClose:e,onOpenChat:t}){let n=L(),r=ru(xc(au)),i=ru(iu),a=ru(e=>e.markRead),o=ru(e=>e.markAllRead),s=ru(e=>e.clearAll),c=ru(e=>e.dismiss),l=ru(e=>e.respondToPermission),u=ru(e=>e.typeFilter),d=ru(xc(ou)),f=ru(e=>e.setTypeFilter),p=(0,V.useCallback)(e=>{a(e.id),e.sessionId&&e.type!==`permission_request`&&t?.(e.sessionId)},[a,t]),m=(0,V.useCallback)(e=>{l(e.id,`allow`).catch(e=>console.error(`[NotificationCenter] allow failed:`,e))},[l]),h=(0,V.useCallback)(e=>{l(e.id,`deny`).catch(e=>console.error(`[NotificationCenter] deny failed:`,e))},[l]);Qn(!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 R(`div`,{className:`notification-center`,role:`dialog`,"aria-label":n(`notifications.dialogAria`),children:[R(`div`,{className:`notification-center-header`,children:[R(`div`,{className:`notification-center-title-row`,children:[I(`h2`,{className:`notification-center-title`,children:n(`notifications.title`)}),i>0&&I(`span`,{className:`notification-center-badge`,children:i})]}),I(`button`,{className:`btn-icon notification-center-close`,onClick:e,"aria-label":n(`notifications.close`),children:I(fc,{size:18})})]}),_&&I(`div`,{className:`notification-filter-bar`,role:`tablist`,"aria-label":n(`notifications.filterAria`),children:g.map(e=>I(`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`))}),I(`div`,{className:`notification-list`,children:r.length===0?R(`div`,{className:`notification-empty`,children:[I(Vr,{size:40,strokeWidth:1.2}),I(`span`,{children:n(`notifications.empty`)})]}):r.map(e=>{let t=H$[e.type],r=e.type===`permission_request`&&e.tool?Gl(e,n,e=>_l(gd(e))):null;return R(`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&&I(`span`,{className:`notification-unread-dot`}),I(`span`,{className:`notification-icon`,children:t.icon}),R(`div`,{className:`notification-content`,children:[R(`div`,{className:`notification-content-header`,children:[I(`span`,{className:`notification-agent`,dir:`auto`,children:e.agentName}),I(`span`,{className:`notification-time`,children:G$(e.timestamp,n)})]}),r?R(P.Fragment,{children:[I(`span`,{className:`notification-title`,children:I(bl,{text:r.heading})}),I(`span`,{className:`notification-message`,dir:`auto`,children:I(bl,{text:r.question})})]}):R(P.Fragment,{children:[e.title&&I(`span`,{className:`notification-title`,children:W$(e.title)}),I(`span`,{className:`notification-message`,dir:`auto`,children:W$(e.message)})]}),e.type===`policy_alert`&&R(`div`,{className:`notification-policy-details`,children:[e.tool&&R(`span`,{className:`notification-tool`,children:[n(`activity.policy.tool`),`: `,I(`code`,{dir:`ltr`,children:e.tool})]}),e.reason&&R(`span`,{className:`notification-policy-reason`,children:[n(`notifications.reason`),`: `,e.reason]}),e.ruleIds&&e.ruleIds.length>0&&R(`span`,{className:`notification-tool`,children:[n(`activity.policy.rules`),`: `,I(`code`,{dir:`ltr`,children:e.ruleIds.join(`, `)})]}),e.policyVersion&&R(`span`,{className:`notification-tool`,children:[n(`activity.policy.policy`),`: `,I(`code`,{dir:`ltr`,children:e.policyVersion})]}),R(`span`,{className:`notification-tool`,children:[n(`activity.policy.receipt`),`:`,` `,e.receiptId?I(`code`,{dir:`ltr`,children:e.receiptId}):I(`em`,{children:n(`activity.policy.receiptUnavailable`)})]})]}),e.type===`permission_request`&&!e.response&&R(`div`,{className:`notification-actions`,children:[R(`button`,{className:`notification-action-btn notification-action-allow`,onClick:t=>{t.stopPropagation(),m(e)},children:[I(ri,{size:14}),n(`notifications.approve`)]}),R(`button`,{className:`notification-action-btn notification-action-deny`,onClick:t=>{t.stopPropagation(),h(e)},children:[I(fc,{size:14}),n(`notifications.deny`)]})]}),e.type===`permission_request`&&e.response&&I(`span`,{className:`notification-response-badge ${e.response===`allow`?`response-allow`:`response-deny`}`,children:e.response===`allow`?n(`notifications.approved`):n(`notifications.denied`)})]}),I(`button`,{className:`notification-dismiss`,onClick:t=>{t.stopPropagation(),c(e.id)},"aria-label":n(`notifications.dismiss`),children:I(fc,{size:14})})]},e.id)})}),r.length>0&&R(`div`,{className:`notification-center-footer`,children:[R(`button`,{className:`notification-footer-btn`,onClick:o,disabled:i===0,children:[I(ri,{size:14}),n(`notifications.markAllRead`)]}),R(`button`,{className:`notification-footer-btn notification-footer-clear`,onClick:s,children:[I(Qs,{size:14}),n(`notifications.clear`)]})]})]})}var q$=1500,J$=e=>new Promise(t=>setTimeout(t,e));async function Y$({onProgress:e,isCancelled:t=()=>!1,pollMs:n=q$}={}){try{await _t(fA)}catch(e){if(e?.httpStatus!==409)throw e;let t=await be(fA).catch(()=>null);if(!t||t.status===`completed`||t.status===`failed`)throw e}for(;!t();){let t=await be(fA);if(e?.(t),t.status===`completed`)return;if(t.status===`failed`)throw Error(t.error||`The GAIA agent could not be installed.`);await J$(n)}}function X$({onInstalled:e,noBuild:t=!1}){let n=L(),[r,i]=(0,V.useState)({kind:`idle`}),a=(0,V.useRef)(!1);(0,V.useEffect)(()=>()=>{a.current=!0},[]);let o=(0,V.useCallback)(async()=>{i({kind:`installing`,percent:0});try{if(await Y$({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?I(`div`,{className:`app-notice is-warning`,role:`status`,children:I(`span`,{children:n(`agentNotice.noBuild`)})}):R(`div`,{className:`app-notice is-warning`,role:`status`,children:[r.kind===`installing`?I(`span`,{children:n(`agentNotice.installing`,{percent:Math.round(r.percent)})}):r.kind===`failed`?I(`span`,{children:n(`agentNotice.failed`,{error:r.error})}):I(`span`,{children:n(`agentNotice.missing`)}),r.kind!==`installing`&&I(`button`,{type:`button`,className:`link-btn`,onClick:()=>void o(),children:r.kind===`failed`?n(`agentNotice.retry`):n(`agentNotice.install`)})]})}var Z$=`goal-store-error-`,Q$=0;function $$(){let e=ru.getState();for(let t of e.notifications)t.id.startsWith(Z$)&&!t.read&&e.markRead(t.id)}var e1=xt((e,t)=>({error:null,damaged:!1,check:async()=>{let n,r;try{({error:n,damaged:r}=await Zq())}catch(e){F.api.error(`Could not check the goal store`,e);return}n&&n!==t().error&&(Q$+=1,ru.getState().addNotification({id:`${Z$}${Q$}`,type:`error`,agentId:`goals`,agentName:`GAIA`,title:Qt()(`mem.goals.storeError`),message:n,timestamp:Date.now(),read:!1,dismissed:!1,priority:`high`})),n||$$(),e({error:n,damaged:!!r})}})),t1=new Set([`loading_model`,`downloading_model`,`model_retry`,`waiting`]),n1=5;function r1(e,t){return{id:e,title:t.get(e)?.title??`Untitled chat`}}function i1(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=>({...r1(e,t),reason:`approval`}));n&&e.awaitingUser&&!a.has(e.currentSessionId)&&o.push({...r1(e.currentSessionId,t),reason:`answer`});for(let[n,r]of Object.entries(e.awaitingBySession))o.some(e=>e.id===n)||o.push({...r1(n,t),reason:r===`question`?`answer`:`approval`});let s=n&&!e.awaitingUser&&e.livePhase&&t1.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,n1).map(e=>r1(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=>r1(e,t)),needsYou:o,recent:u}}function a1(e){let t=(0,V.useRef)(e);t.current=e,(0,V.useEffect)(()=>{let e=window.gaiaAPI?.tray;if(!e)return;let n=``,r=null,i=()=>{let t=B.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:ru.getState().notifications},a=r;if(r=i,a&&Object.keys(i).every(e=>i[e]===a[e]))return;let o=i1(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=B.subscribe(i),o=ru.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`:B.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 o1(){(0,V.useEffect)(()=>{let e=window.gaiaAPI;if(!e)return;let t=ru.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=B.getState();n.currentSessionId!==t&&n.setMessages([]),n.setCurrentSession(t)})];return()=>n.forEach(e=>e())},[])}function s1(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(),B.getState().setCurrentSession(e)}}function c1(){let[e,t]=(0,V.useState)(null);return(0,V.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 l1(){o1();let e=B(e=>e.runningSessionIds),t=B(e=>e.awaitingBySession),n=B(e=>e.sessions),r=B(e=>e.currentSessionId),i=ru(xc(cu)),a=hu(),o=c1(),s=(0,V.useRef)(null),c=Su(e,t,i),l=JSON.stringify(c);(0,V.useEffect)(()=>{let e=JSON.parse(l),t=s.current;if(s.current=e,t===null)return;let{sessions:n,currentSessionId:r}=B.getState(),i=document.hasFocus(),o=!1;for(let{sessionId:s,event:c}of Cu(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`||Eu(s,r,i))&&(o=!0,t===`banner`)){if(c!==`finished`){let{title:t,body:n}=Tu(c,e);s1(s,t,n)}else nt(s).then(e=>{B.getState().updateSessionInList(s,e);let{title:t,body:n}=Tu(c,e);s1(s,t,n)}).catch(t=>{F.system.error(`Could not read how chat ${s} ended`,t);let{title:n,body:r}=Tu(c,{...e,last_run_status:null});s1(s,n,r)})}}if(o){if(a.sound)try{ku()}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=Du(n,c,a.modes,r);(0,V.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&&Ou(o,a.batteryFloor);(0,V.useEffect)(()=>{window.gaiaAPI?.power.setKeepAwake(d).catch(e=>F.system.error(`Could not change keep-awake`,e))},[d])}function u1(e){return e.indexing_status===`failed`&&lz(e.error_kind)}var d1=1e4,f1=6e4;function p1(){let e=B(e=>e.systemStatus?.lemonade_running===!0),t=B(e=>e.documents.some(u1)),n=B(e=>e.setDocuments),r=(0,V.useRef)(!1),i=(0,V.useRef)(0),a=(0,V.useRef)(0),[o,s]=(0,V.useState)(0),c=(0,V.useRef)(()=>{}),l=(0,V.useRef)(!1);c.current=()=>{let e=async()=>{i.current=Date.now();let{documents:e}=await Vn(),t=(e||[]).filter(u1).map(e=>e.id);if(t.length===0){a.current=0,B.getState().documents.some(u1)&&n(e||[]);return}F.doc.info(`Model server is back; retrying ${t.length} document(s) that were waiting for it`);for(let e of t){let t=(await Vn()).documents||[],r=t.find(t=>t.id===e);if(r&&u1(r)){n(t.map(t=>t.id===e?{...t,indexing_status:`indexing`}:t));try{await g(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 Vn()).documents||[];a.current=r.some(u1)?a.current+1:0,i.current=Date.now(),n(r)};r.current=!0,(async()=>{try{do{l.current=!1;try{await e()}catch(e){a.current+=1,i.current=Date.now(),F.doc.warn(`Could not retry the documents waiting for the model server`,e)}}while(l.current&&B.getState().systemStatus?.lemonade_running===!0)}finally{r.current=!1,s(e=>e+1)}})()},(0,V.useEffect)(()=>{e&&(a.current=0,r.current?l.current=!0:c.current())},[e]),(0,V.useEffect)(()=>{if(!e||!t||r.current)return;let n=a.current===0?0:Math.min(d1*2**(a.current-1),f1),o=setTimeout(()=>{r.current||c.current()},Math.max(0,i.current+n-Date.now()));return()=>clearTimeout(o)},[e,t,o])}var m1=`GAIA Agent UI`;function h1(){let e=L(),t=B(e=>e.sessions.find(t=>t.id===e.currentSessionId)),n=t?.title,r=t?.kind;(0,V.useEffect)(()=>{let t=n?.trim()?zd(e,{title:n.trim(),kind:r}):``;document.title=t?`${t} - GAIA`:m1},[n,r,e])}function g1(e,t,n){return!e||t&&(e===t||e===Mz(t))?null:n.some(t=>t.id===e)?e:Nz(n,e)}function _1(e){return new URLSearchParams(e.search).get(`session`)||e.hash.replace(/^#/,``)||null}var v1=`gaia:last-session`;function y1(e){try{e?localStorage.setItem(v1,e):localStorage.removeItem(v1)}catch(e){F.ui.warn(`Could not save the open chat for the next launch`,e)}}function b1(){try{return localStorage.getItem(v1)}catch(e){return F.ui.warn(`Could not read the chat open at last launch`,e),null}}var x1=1e3,S1=3e4;function C1(e,{initialMs:t=x1,maxMs:n=S1,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 w1(e,t,n){return e&&!t&&!n}function T1(){let e=L(),[t]=(0,V.useState)(()=>Date.now()),[n,r]=(0,V.useState)(t);(0,V.useEffect)(()=>{let e=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(e)},[]);let i=n-t;return R(`main`,{className:`startup`,role:`status`,"aria-label":e(`app.startingAria`),children:[I(`div`,{className:`loading-spinner`,"aria-hidden":`true`}),I(`p`,{className:`startup-text`,dir:`auto`,children:e(`app.starting`)}),i>=1e4&&R(`p`,{className:`startup-elapsed`,dir:`auto`,children:[e(`app.stillStarting`),` · `,I(`bdi`,{dir:`ltr`,children:e(`app.startingSeconds`,{s:Math.floor(i/1e3)})})]})]})}function E1({error:e,onCheckAgain:t}){let n=L(),r=ZL(e=>e.lifecycle),i=ZL(e=>e.restart),a=ZL(e=>e.restartError),o=r?.status===`stopped`||r?.status===`restarting`||r?.status===`running`,s=r?.status===`restarting`,c=[...new Set([a,r?.lastError,e].filter(e=>!!e))];return I(`main`,{className:`startup startup--failed`,role:`alert`,children:R(`div`,{className:`startup-failed`,children:[I(`h1`,{className:`startup-failed-title`,dir:`auto`,children:n(`startup.failed.title`)}),I(`p`,{className:`startup-failed-hint`,dir:`auto`,children:n(o?`startup.failed.hintRestart`:`startup.failed.hintReopen`)}),R(`div`,{className:`startup-failed-actions`,children:[o&&I(`button`,{type:`button`,className:`btn-primary`,disabled:s,onClick:()=>void i(),children:n(s?`banner.restartingShort`:`banner.restartButton`)}),I(`button`,{type:`button`,className:o?`btn-secondary`:`btn-primary`,onClick:t,children:n(`setup.unknown.retry`)})]}),R(`details`,{className:`startup-failed-details`,children:[I(`summary`,{children:n(`startup.failed.details`)}),I(`pre`,{className:`startup-failed-log`,dir:`ltr`,children:c.join(`
|
|
218
|
-
`)})]})]})})}var D1=(0,V.lazy)(()=>S$(()=>import(`./MemoryDashboard-
|
|
218
|
+
`)})]})]})})}var D1=(0,V.lazy)(()=>S$(()=>import(`./MemoryDashboard-BX86YZvy.js`).then(e=>({default:e.MemoryDashboard})),__vite__mapDeps([7,1,2,8]),import.meta.url)),O1=(0,V.lazy)(()=>S$(()=>import(`./ScheduleManager-C_dc4t2S.js`).then(e=>({default:e.ScheduleManager})),__vite__mapDeps([9,1,2,10]),import.meta.url)),k1=(0,V.lazy)(()=>S$(()=>import(`./DocumentLibrary-fGmvS5bZ.js`).then(e=>({default:e.DocumentLibrary})),__vite__mapDeps([11,1,2,12,13]),import.meta.url)),A1=(0,V.lazy)(()=>S$(()=>import(`./FileBrowser--eUruCkG.js`).then(e=>({default:e.FileBrowser})),__vite__mapDeps([14,1,2,12,15]),import.meta.url)),j1=(0,V.lazy)(()=>S$(()=>import(`./MobileAccessModal-B3248O8O.js`).then(e=>({default:e.MobileAccessModal})),__vite__mapDeps([16,1,2,17]),import.meta.url)),M1=3,N1=3e5,P1=4e3,F1=6e4,I1=e=>e instanceof TypeError,L1=e=>new Promise(t=>setTimeout(t,e)),R1=3e5,z1=class extends Error{},B1=class extends Error{refusal;constructor(e){super(e.message),this.refusal=e}},V1=class extends Error{constructor(e){super(Qt().bare(`setup.unknown.modelUnread`,{error:e}))}};async function H1(){let e=Date.now()+R1;for(;;){let t=await Pt();if(t.state===`ready`)return;if(t.state===`failed`||t.state===`cancelled`)throw new z1(t.error||Qt().bare(`setup.upgrading.stopped`));if(Date.now()>=e)throw Error(Qt().bare(`setup.upgrading.slow`));await L1(x1)}}function U1(){let e=L();return I(`div`,{className:`loading-spinner`,role:`status`,"aria-label":e(`app.loading`)})}var W1=e=>e===1||e%10==0;function G1(){Xc.getState().active?.remote||iZ()?.markSetupWorked().catch(e=>{F.system.warn(`Couldn't record that setup works on this version`,e)})}function K1(){let e=L(),t=Jt(e=>e.signInRequired);h1();let n=B(e=>e.currentSessionId),r=B(e=>e.setSessions),i=B(e=>e.setCurrentSession),a=B(e=>e.addSession),o=B(e=>e.setMessages),s=B(e=>e.showDocLibrary),c=B(e=>e.showFileBrowser),l=B(e=>e.showMemoryDashboard),u=B(e=>e.showSchedules),d=B(e=>e.sidebarOpen),f=B(e=>e.sidebarCollapsed),p=B(e=>e.setSidebarOpen),m=B(e=>e.setSystemStatus),h=B(e=>e.setBackendConnected),g=B(e=>e.setAgents),_=B(e=>e.agents),v=B(e=>e.setPendingPrompt),y=B(e=>e.setDefaultPermissionMode),b=B(e=>e.openSettings),x=B(e=>e.settingsSection),S=B(e=>e.syncSystemTheme),C=Xc(e=>e.restoreNotice),w=Xc(e=>e.dismissRestoreNotice),T=ru(e=>e.showPanel),E=B(e=>e.systemStatus?.initialized===!0),ee=(0,V.useRef)(!1),D=ru(e=>e.setShowPanel);(0,V.useEffect)(()=>{if(!C?.ok)return;let e=setTimeout(w,P1);return()=>clearTimeout(e)},[C,w]);let[O,te]=(0,V.useState)({state:`checking`}),k=B(e=>e.setupAgain),A=B(e=>e.runSetupAgain),re=(0,V.useRef)(O);re.current=O;let[j,ie]=(0,V.useState)(!1),ae=(0,V.useRef)(j);ae.current=j;let[oe,se]=(0,V.useState)(!1),[ce,le]=(0,V.useState)(!1),ue=oe||j&&!pA(_),M=(0,V.useRef)(ue);M.current=ue;let[de,fe]=(0,V.useState)(null),[N,pe]=(0,V.useState)(!1),[me,he]=(0,V.useState)(``),[ge,_e]=(0,V.useState)(0),[ve,ye]=(0,V.useState)(0),[be,xe]=(0,V.useState)(!1),[Se,Ce]=(0,V.useState)(!1),[we,Te]=(0,V.useState)(null),[Ee,De]=(0,V.useState)(null),Oe=(0,V.useRef)(async()=>{}),ke=(0,V.useRef)(async()=>{}),Ae=(0,V.useCallback)(async(e=!1,t=!1)=>{e||te({state:`checking`});let n=0;try{for(;;){await Xc.getState().refresh();let e=Xc.getState().active,r=!!e?.remote,i;try{if(i=await ne(r),!e&&!i.ready)throw new V1(Xc.getState().error??`no answer`)}catch(e){let r=I1(e)||e instanceof V1,i=ZL.getState().lifecycle?.status===`stopped`;if(!t||!r||i||n>=F1)throw I1(e)&&(t||re.current.state===`backendDown`)?new B1(e):e;await L1(x1),n+=x1;continue}if(!i.ready&&i.stage===`upgrade`){te({state:`upgrading`});let e=await Pt();(!e.upgrade_embedded||e.state!==`running`&&e.state!==`verifying`)&&await Tt(r,!1,{upgradeEmbedded:!0}),await H1(),i=await ne(r)}(n>0||re.current.state===`backendDown`)&&await Promise.all([Oe.current(),ke.current()]),le(!!i.no_agent_build),i.ready&&G1();let a=!i.ready&&i.stage===`server`&&!!i.initialized;te(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 z1){F.system.warn(`Updating the local model server failed`,e),te({state:`unknown`,error:t,upgradeFailed:!0});return}if(e instanceof B1){F.system.error(`GAIA's backend did not start`,e.refusal),te({state:`backendDown`,error:t});return}F.system.warn(`Setup check could not be answered`,e),te({state:`unknown`,error:t})}},[]),je=B(e=>!!e.systemStatus&&SR(e.systemStatus)===`unresponsive`),Ne=B(e=>e.systemStatus?.lemonade_running===!0);(0,V.useEffect)(()=>{O.state===`serverDown`&&Ne&&Ae(!0)},[O.state,Ne,Ae]);let Pe=B(e=>e.systemStatus?.lemonade_running===!1);(0,V.useEffect)(()=>{if(O.state!==`ready`||!Pe)return;let e=!1;return ne(!!Xc.getState().active?.remote).then(t=>{!e&&!t.ready&&t.stage===`server`&&t.initialized&&te({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,Pe]);let Fe=(0,V.useRef)(0),Ie=(0,V.useCallback)(async()=>{let e=++Fe.current,t=(await wn()).agents||[];e===Fe.current&&(g(t),ie(!0),pA(t)&&se(!1))},[g]),Le=(0,V.useCallback)(()=>{let e=ae.current;ie(!1),Ie().catch(t=>{F.api.warn(`Agent list unavailable after setup`,t),e&&ie(!0)})},[Ie]);(0,V.useEffect)(()=>{let e=()=>{M.current&&Ie().catch(e=>F.api.warn(`Agent list unavailable`,e))};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[Ie]);let Re=(0,V.useCallback)(async()=>{y((await Xt()).default_mode)},[y]),ze=(0,V.useRef)([]);(0,V.useEffect)(()=>{ft(`0.27.0rc22`),Ae(!1,!0);let e=[C1(Ie,{onError:(e,t)=>{W1(t)&&F.api.warn(`Agent list unavailable (attempt ${t}); retrying`,e)}}),C1(Re,{onError:(e,t)=>{W1(t)&&F.api.warn(`Default permission mode unavailable (attempt ${t}); retrying`,e)}})];return ze.current=e,()=>e.forEach(e=>e.stop())},[Ae,Ie,Re]);let Be=(0,V.useCallback)(()=>{ze.current.forEach(e=>e.kick()),Xc.getState().retryNow(),ke.current();let e=re.current;(e.state===`unknown`&&!e.upgradeFailed||e.state===`backendDown`)&&Ae(!0)},[Ae]),Ve=(0,V.useRef)(Be);Ve.current=Be;let He=(0,V.useRef)(!1);(0,V.useEffect)(()=>{t?He.current=!0:He.current&&(He.current=!1,Be())},[t,Be]);let Ue=(0,V.useRef)(0),We=(0,V.useRef)(0),Ge=(0,V.useRef)(null),Ke=(0,V.useRef)(!1),[qe,Je]=(0,V.useState)(!1),[Ye,Xe]=(0,V.useState)(null),Ze=(0,V.useCallback)(e=>{if(e.kind===`unreachable`){F.system.warn(`System status check failed`,e.error),QL(),Ke.current=!0,We.current=0,Ge.current=null,Je(!1),Xe(null),B.getState().setBackendStalled(!1),h(!1),m(null);return}if(e.kind===`error`){F.system.warn(`System status answered HTTP ${e.httpStatus}`,e.message),Ke.current&&Ve.current(),Ke.current=!1,We.current=0,Ge.current=null,Je(!1),Xe(`HTTP ${e.httpStatus}: ${e.message}`),B.getState().setBackendStalled(!1),h(!0);return}if(e.kind===`slow`){if(We.current+=1,Ge.current??=Date.now(),Xe(null),F.system.warn(`System status did not answer in time (${We.current} in a row)`),Date.now()-Ge.current>=N1){Je(!1),h(!1),m(null);return}h(!0),(Ke.current||We.current>=M1)&&Je(!0);return}let{status:t}=e;Ke.current&&Ve.current(),Ke.current=!1,We.current=0,Ge.current=null,Je(!1),Xe(null),B.getState().setBackendStalled(!1),h(!0),Ue.current=t.lemonade_running?0:Ue.current+1;let n=B.getState().systemStatus;t.lemonade_running||Ue.current>=M1||!n?.lemonade_running?m(t):m({...n,download_progress:t.download_progress})},[h,m]),Qe=(0,V.useRef)(Ze);Qe.current=Ze;let[$e]=(0,V.useState)(()=>TR(e=>Qe.current(e))),et=$e.check;Oe.current=et,(0,V.useEffect)(()=>Cl($e.start),[$e]),(0,V.useEffect)(()=>$L(()=>{et()}),[et]);let tt=(0,V.useRef)(``);(0,V.useEffect)(()=>{let e=e=>jt().then(t=>{let n=t.sessions||[];if(!e&&n.length===0&&B.getState().sessions.length>0)return;let i=n.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(`
|
|
219
219
|
`);if(i===tt.current)return;tt.current=i,r(n);let a=Xc.getState().active?.model;a&&n.some(e=>e.effective_model&&e.effective_model!==a)&&Xc.getState().refresh()}).catch(t=>{e&&F.system.error(`Could not load chats`,t)});ke.current=()=>e(!1),e(!0);let t=setInterval(()=>void e(!1),5e3);return()=>clearInterval(t)},[r]),(0,V.useEffect)(()=>RR(),[]),(0,V.useEffect)(()=>{let e=()=>{NU.getState().loadSchedules()};e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[]),(0,V.useEffect)(()=>{let e=()=>{e1.getState().check()};e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[]),(0,V.useEffect)(()=>nz(),[]),l1(),p1();let nt=(0,V.useRef)(!1),rt=(0,V.useRef)(!1);(0,V.useEffect)(()=>{let e=()=>{let e=_1(window.location),{currentSessionId:t,sessions:n}=B.getState(),r=g1(e,t,n);return r&&(i(r),o([])),r},t=()=>{if(nt.current||(nt.current=!0,e()||B.getState().currentSessionId))return;if(window.location.hash){window.history.replaceState(null,``,window.location.pathname+window.location.search);return}if(rt.current||zt(`new-chat`))return;let{sessions:t}=B.getState(),n=g1(b1(),null,t);n&&(i(n),o([]))},n=B.subscribe(e=>{e.sessions.length>0&&t()});return B.getState().sessions.length>0&&t(),window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{n(),window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[i,o]),(0,V.useEffect)(()=>{let e=null,t=2e3,n=!1,r=null,a=()=>{n||(e=new EventSource(`${$n()}/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!==B.getState().currentSessionId&&(i(t.session_id),o([]))},e.onerror=()=>{e?.close(),e=null,n||(r=setTimeout(a,t),t=Math.min(t*2,3e4))})};return a(),()=>{n=!0,r&&clearTimeout(r),e?.close()}},[i,o]),(0,V.useEffect)(()=>{if(nt.current&&y1(n),n){let e=Mz(n);window.location.hash!==`#${e}`&&window.history.replaceState(null,``,`#${e}`)}else nt.current&&window.location.hash&&window.history.replaceState(null,``,window.location.pathname+window.location.search)},[n]);let it=(0,V.useCallback)(async e=>{if(fe(null),pe(!1),!await Nc(`chat`))return he(e),!1;let t=B.getState(),n;try{n=await wt({title:`New chat`,agent_type:fA,document_ids:t.draftDocumentIds,private:t.draftPrivate,folders:t.draftFolder?[t.draftFolder]:[]})}catch(e){throw hA(e)?(se(!0),new mA):e}M.current&&(se(!1),Ie().catch(e=>F.api.warn(`Agent list unavailable`,e))),t.defaultPermissionModeKnown||(await Re().catch(e=>F.api.warn(`Default permission mode unavailable; using the chip's mode`,e)),t=B.getState()),t.clearDraftDocuments(),t.setDraftPrivate(!1),t.adoptDraftResearch(n.id,e),t.setDraftFolder(null);let r=null;try{await sr(n.id,t.draftPermissionMode)}catch(e){r=e}return At(cn),r&&!n.private&&On(Jn(n.id),e),a(n),TW.getState().claimDraft(n.id),i(n.id),o([]),he(``),r?(fe(`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`}: ${r instanceof Error?r.message:r}`),!1):(t.resetDraftPermissionMode(),v({sessionId:n.id,text:e}),!0)},[a,i,o,v,Ie,Re]),at=(0,V.useCallback)(async e=>{try{return await it(e)}catch(t){if(!(t instanceof mA))throw t;let n=zt(cn),r=n.trimEnd().endsWith(e)?n:[n,e].filter(Boolean).join(`
|
|
220
220
|
|
|
221
221
|
`);return On(cn,r),he(r),pe(!0),ye(e=>e+1),!1}},[it]),ot=(0,V.useCallback)(()=>{let e=B.getState(),t=e.currentSessionId,n=e.pendingPrompt?.sessionId===t?e.pendingPrompt:null;n&&(e.setPendingPrompt(null),he(n.text)),t&&Ru(t,B.getState())&&zu(t),e.setShowMemoryDashboard(!1),e.setShowSchedules(!1),rt.current=!0,pe(!1),i(null),o([]),_e(e=>e+1)},[i,o]),st=(0,V.useCallback)(e=>{let t=B.getState();t.closeSettings(),e!==t.currentSessionId&&(zu(t.currentSessionId),o([])),i(e)},[i,o]),ct=(0,V.useCallback)(e=>{let t=B.getState();t.setShowMemoryDashboard(!1),t.setShowSchedules(!1),D(!1),st(e)},[st]);a1({openChat:st,newChat:(0,V.useCallback)(()=>{B.getState().closeSettings(),ot()},[ot]),refreshStatus:()=>void et()});let lt=(0,V.useCallback)(t=>{let n=B.getState(),r=n.pendingPrompt?.sessionId===n.currentSessionId?n.pendingPrompt?.text:null;ot();let i=e.bare(`settings.skills.tryPrompt`,{name:t}),a=[zt(cn),r].filter(Boolean).join(`
|