@amd-gaia/agent-ui 0.27.0-rc.1 → 0.27.0-rc.2
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-znkqGWxt.js → AdvancedSettings-DHERtrno.js} +1 -1
- package/dist/assets/{AutomationsSettings-By0Cy-Gu.js → AutomationsSettings-4FWcRau9.js} +1 -1
- package/dist/assets/{ConnectorsPane-6hKjjRWm.js → ConnectorsPane-Dkat1zLC.js} +1 -1
- package/dist/assets/{DocumentLibrary-_PZjdm8h.js → DocumentLibrary-Dll55N7l.js} +1 -1
- package/dist/assets/{FileBrowser-C_cpUmtN.js → FileBrowser-wFHqH6K_.js} +1 -1
- package/dist/assets/MemoryDashboard-BuUBoNq8.js +1 -0
- package/dist/assets/MemoryDashboard-RpfLag-v.css +1 -0
- package/dist/assets/{MessagingSettings-sBXQSmjR.js → MessagingSettings-DomiT2rX.js} +1 -1
- package/dist/assets/{MobileAccessModal-b23-QxSf.js → MobileAccessModal-B2gaE8nk.js} +1 -1
- package/dist/assets/{ScheduleManager-D_U1Igck.js → ScheduleManager-8UE81KlQ.js} +1 -1
- package/dist/assets/{index-BgqO1M5f.js → index-HCZ86cyP.js} +17 -17
- package/dist/assets/useFocusTrap-BFi0chLf.js +6 -0
- package/dist/assets/{zap-DmECnAbs.js → zap-DjkIffnX.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/sw.js +1 -1
- package/package.json +1 -1
- package/dist/assets/MemoryDashboard-BEafsLNv.js +0 -1
- package/dist/assets/MemoryDashboard-TCZiujy9.css +0 -1
- package/dist/assets/useFocusTrap-JsuLBsNA.js +0 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ConnectorsPane-
|
|
2
|
-
import{n as e,r as t,t as n}from"./rolldown-runtime-XKyaHtl9.js";import{$ as r,$n as i,$r as a,$t as o,A as s,An as c,Ar as l,B as u,Bn as d,Br as f,Bt as p,C as m,Cn as h,Ct as g,D as _,Dn as v,Dt as y,E as b,En as x,Er as S,Et as C,F as w,Fn as T,Fr as E,Ft as D,G as O,Gn as k,Gr as ee,Gt as te,H as ne,Hn as A,Hr as re,Ht as ie,I as ae,Ir as j,It as oe,J as se,Jn as ce,Jr as le,Jt as ue,K as de,Kn as fe,Kr as pe,Kt as me,L as he,Ln as M,Lr as N,M as ge,Mn as _e,Mr as ve,Mt as ye,N as be,Nn as xe,Nr as Se,Nt as Ce,O as we,On as Te,Ot as Ee,P as De,Pn as Oe,Pr as ke,Pt as Ae,Q as je,Qn as Me,Qr as Ne,Qt as Pe,R as Fe,Rn as Ie,Rr as Le,Rt as Re,S as ze,Sn as Be,St as Ve,T as He,Tn as Ue,Tt as We,U as Ge,Un as Ke,Ur as qe,Ut as Je,Vn as Ye,Vr as Xe,Vt as Ze,W as Qe,Wn as $e,Wr as et,Wt as tt,X as nt,Xn as rt,Xr as it,Y as at,Yn as ot,Yr as st,Yt as ct,Z as lt,Zn as ut,Zr as dt,Zt as ft,_ as pt,_n as mt,_t as ht,a as gt,ai as _t,an as vt,ar as yt,at as bt,b as xt,bt as St,c as P,ci as Ct,cn as wt,cr as Tt,ct as Et,d as Dt,dn as Ot,dr as kt,ei as At,en as jt,er as Mt,et as Nt,f as Pt,fn as Ft,ft as It,g as Lt,gn as Rt,gt as zt,h as Bt,hn as Vt,i as Ht,ii as F,in as Ut,ir as Wt,it as Gt,j as Kt,jn as qt,jr as Jt,jt as Yt,k as Xt,kn as Zt,kt as Qt,l as I,li as L,ln as $t,lr as en,lt as tn,m as nn,mn as rn,mt as an,n as on,ni as sn,nn as cn,nr as ln,nt as un,oi as dn,on as fn,or as pn,ot as mn,p as hn,pr as gn,pt as _n,q as vn,qn as yn,qr as bn,qt as xn,r as Sn,ri as Cn,rn as wn,rr as Tn,rt as En,s as R,si as Dn,sn as On,sr as kn,st as An,t as jn,ti as Mn,tn as Nn,tr as Pn,u as z,ui as Fn,un as In,ur as Ln,ut as Rn,v as zn,vn as Bn,vt as Vn,w as Hn,wn as Un,wt as Wn,x as Gn,xn as Kn,xt as qn,y as B,yn as Jn,yt as Yn,z as Xn,zn as Zn,zr as Qn,zt as $n}from"./useFocusTrap-JsuLBsNA.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 er=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&te(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&te(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,ee=k.port2;k.port1.onmessage=D,O=function(){ee.postMessage(null)}}else O=function(){_(D,0)};function te(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,te(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),tr=n(((e,t)=>{t.exports=er()})),nr=n((e=>{var t=Fn();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`})),rr=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=nr()})),ir=n((e=>{var t=tr(),n=Fn(),r=rr();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}function f(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&f(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function p(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function m(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function h(e){var t=[null,null],n=p(e);return n===null||g(t,e,n.child,{foundSelf:!1}),t}function g(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&g(e,t,n.child,r))return!0;n=n.sibling}return!1}function _(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var v=null,y=null;function b(e,t,n){return e===n||e===t&&(v=e,!0)}function x(e,t,n){return e===n?(y=e,!1):e===t&&(y!==null&&(v=e),!0)}function S(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function C(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var w=Object.assign,T=Symbol.for(`react.element`),E=Symbol.for(`react.transitional.element`),D=Symbol.for(`react.portal`),O=Symbol.for(`react.fragment`),k=Symbol.for(`react.strict_mode`),ee=Symbol.for(`react.profiler`),te=Symbol.for(`react.consumer`),ne=Symbol.for(`react.context`),A=Symbol.for(`react.forward_ref`),re=Symbol.for(`react.suspense`),ie=Symbol.for(`react.suspense_list`),ae=Symbol.for(`react.memo`),j=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`),de=Symbol.iterator;function fe(e){return typeof e!=`object`||!e?null:(e=de&&e[de]||e[`@@iterator`],typeof e==`function`?e:null)}var pe=Symbol.for(`react.client.reference`);function me(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===pe?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case O:return`Fragment`;case ee:return`Profiler`;case k:return`StrictMode`;case re:return`Suspense`;case ie:return`SuspenseList`;case oe:return`Activity`;case le:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case D:return`Portal`;case ne:return e.displayName||`Context`;case te:return(e._context.displayName||`Context`)+`.Consumer`;case A:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ae:return t=e.displayName||null,t===null?me(e.type)||`Memo`:t;case j:t=e._payload,e=e._init;try{return me(e(t))}catch{}}return null}var he=Array.isArray,M=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,N=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(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ConnectorsPane-Dkat1zLC.js","./rolldown-runtime-XKyaHtl9.js","./useFocusTrap-BFi0chLf.js","./ConnectorsPane-BGI8nBUb.css","./MessagingSettings-DomiT2rX.js","./AutomationsSettings-4FWcRau9.js","./AdvancedSettings-DHERtrno.js","./MemoryDashboard-BuUBoNq8.js","./zap-DjkIffnX.js","./MemoryDashboard-RpfLag-v.css","./ScheduleManager-8UE81KlQ.js","./ScheduleManager-BZzEH2-W.css","./DocumentLibrary-Dll55N7l.js","./DocumentLibrary-fEMoY7lH.css","./FileBrowser-wFHqH6K_.js","./FileBrowser-1goNp4CP.css","./MobileAccessModal-B2gaE8nk.js","./MobileAccessModal-BrZMaERi.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{n as e,r as t,t as n}from"./rolldown-runtime-XKyaHtl9.js";import{$ as r,$n as i,$r as a,$t as o,A as s,An as c,Ar as l,B as u,Bn as d,Br as f,Bt as p,C as m,Cn as h,Ct as g,D as _,Dn as v,Dt as y,E as b,En as x,Er as S,Et as C,F as w,Fn as T,Fr as E,Ft as D,G as O,Gn as k,Gr as ee,Gt as te,H as ne,Hn as A,Hr as re,Ht as ie,I as ae,Ir as j,It as oe,J as se,Jn as ce,Jr as le,Jt as ue,K as de,Kn as fe,Kr as pe,Kt as me,L as he,Ln as M,Lr as N,M as ge,Mn as _e,Mr as ve,Mt as ye,N as be,Nn as xe,Nr as Se,Nt as Ce,O as we,On as Te,Ot as Ee,P as De,Pn as Oe,Pr as ke,Pt as Ae,Q as je,Qn as Me,Qr as Ne,Qt as Pe,R as Fe,Rn as Ie,Rr as Le,Rt as Re,S as ze,Sn as Be,St as Ve,T as He,Tn as Ue,Tt as We,U as Ge,Un as Ke,Ur as qe,Ut as Je,Vn as Ye,Vr as Xe,Vt as Ze,W as Qe,Wn as $e,Wr as et,Wt as tt,X as nt,Xn as rt,Xr as it,Y as at,Yn as ot,Yr as st,Yt as ct,Z as lt,Zn as ut,Zr as dt,Zt as ft,_ as pt,_n as mt,_t as ht,a as gt,ai as _t,an as vt,ar as yt,at as bt,b as xt,bt as St,c as P,ci as Ct,cn as wt,cr as Tt,ct as Et,d as Dt,dn as Ot,dr as kt,ei as At,en as jt,er as Mt,et as Nt,f as Pt,fn as Ft,ft as It,g as Lt,gn as Rt,gt as zt,h as Bt,hn as Vt,i as Ht,ii as F,in as Ut,ir as Wt,it as Gt,j as Kt,jn as qt,jr as Jt,jt as Yt,k as Xt,kn as Zt,kt as Qt,l as I,li as L,ln as $t,lr as en,lt as tn,m as nn,mn as rn,mt as an,n as on,ni as sn,nn as cn,nr as ln,nt as un,oi as dn,on as fn,or as pn,ot as mn,p as hn,pr as gn,pt as _n,q as vn,qn as yn,qr as bn,qt as xn,r as Sn,ri as Cn,rn as wn,rr as Tn,rt as En,s as R,si as Dn,sn as On,sr as kn,st as An,t as jn,ti as Mn,tn as Nn,tr as Pn,u as z,ui as Fn,un as In,ur as Ln,ut as Rn,v as zn,vn as Bn,vt as Vn,w as Hn,wn as Un,wt as Wn,x as Gn,xn as Kn,xt as qn,y as B,yn as Jn,yt as Yn,z as Xn,zn as Zn,zr as Qn,zt as $n}from"./useFocusTrap-BFi0chLf.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 er=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&te(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&te(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,ee=k.port2;k.port1.onmessage=D,O=function(){ee.postMessage(null)}}else O=function(){_(D,0)};function te(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,te(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),tr=n(((e,t)=>{t.exports=er()})),nr=n((e=>{var t=Fn();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`})),rr=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=nr()})),ir=n((e=>{var t=tr(),n=Fn(),r=rr();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}function f(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&f(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function p(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function m(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function h(e){var t=[null,null],n=p(e);return n===null||g(t,e,n.child,{foundSelf:!1}),t}function g(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&g(e,t,n.child,r))return!0;n=n.sibling}return!1}function _(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var v=null,y=null;function b(e,t,n){return e===n||e===t&&(v=e,!0)}function x(e,t,n){return e===n?(y=e,!1):e===t&&(y!==null&&(v=e),!0)}function S(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function C(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var w=Object.assign,T=Symbol.for(`react.element`),E=Symbol.for(`react.transitional.element`),D=Symbol.for(`react.portal`),O=Symbol.for(`react.fragment`),k=Symbol.for(`react.strict_mode`),ee=Symbol.for(`react.profiler`),te=Symbol.for(`react.consumer`),ne=Symbol.for(`react.context`),A=Symbol.for(`react.forward_ref`),re=Symbol.for(`react.suspense`),ie=Symbol.for(`react.suspense_list`),ae=Symbol.for(`react.memo`),j=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`),de=Symbol.iterator;function fe(e){return typeof e!=`object`||!e?null:(e=de&&e[de]||e[`@@iterator`],typeof e==`function`?e:null)}var pe=Symbol.for(`react.client.reference`);function me(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===pe?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case O:return`Fragment`;case ee:return`Profiler`;case k:return`StrictMode`;case re:return`Suspense`;case ie:return`SuspenseList`;case oe:return`Activity`;case le:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case D:return`Portal`;case ne:return e.displayName||`Context`;case te:return(e._context.displayName||`Context`)+`.Consumer`;case A:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ae:return t=e.displayName||null,t===null?me(e.type)||`Memo`:t;case j:t=e._payload,e=e._init;try{return me(e(t))}catch{}}return null}var he=Array.isArray,M=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,N=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(`
|
|
5
5
|
`),l=s.split(`
|
|
@@ -176,14 +176,14 @@ Error generating stack: `+e.message+`
|
|
|
176
176
|
`)){i.trim().startsWith("```")&&(r=!r);let e=r?null:QN.exec(i.trim()),a=e?O_(e[2]):``;e&&a?t.push({src:a,name:e[1]||$N(e[2].split(`/`).pop()||``)}):n.push(i)}return t.length===0?{text:e,images:t}:{text:n.join(`
|
|
177
177
|
`).replace(/\n{3,}/g,`
|
|
178
178
|
|
|
179
|
-
`).trim(),images:t}}function tP({images:e,index:t,onIndex:n,onClose:r}){let i=R(),a=(0,V.useRef)(null),o=(0,V.useRef)(null),s=e.length>1,c=e[t];pt(!0,r),on(a,!0),(0,V.useEffect)(()=>{o.current?.focus()},[]);let l=(0,V.useCallback)(r=>{n((t+r+e.length)%e.length)},[t,e.length,n]);return(0,V.useEffect)(()=>{if(!s)return;let e=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;let t=a.current?getComputedStyle(a.current).direction===`rtl`:!1;e.preventDefault(),l(e.key===`ArrowRight`===t?-1:1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[s,l]),c?(0,Mj.createPortal)(I(`div`,{ref:a,className:`image-viewer`,role:`dialog`,"aria-modal":`true`,"aria-label":i(`imageViewer.dialog`),onClick:e=>{e.target===e.currentTarget&&r()},children:z(`div`,{className:`image-viewer-stage`,onClick:e=>{e.target===e.currentTarget&&r()},children:[I(`button`,{ref:o,type:`button`,className:`image-viewer-btn image-viewer-close`,onClick:r,"aria-label":i(`imageViewer.close`),children:I(Is,{size:18,"aria-hidden":`true`})}),s&&I(`button`,{type:`button`,className:`image-viewer-btn image-viewer-prev`,onClick:()=>l(-1),"aria-label":i(`imageViewer.prev`),children:I(qr,{size:20,"aria-hidden":`true`})}),I(`img`,{className:`image-viewer-img`,src:c.src,alt:c.name}),s&&I(`button`,{type:`button`,className:`image-viewer-btn image-viewer-next`,onClick:()=>l(1),"aria-label":i(`imageViewer.next`),children:I(Yr,{size:20,"aria-hidden":`true`})}),z(`p`,{className:`image-viewer-caption`,dir:`auto`,children:[I(`bdi`,{children:c.name}),s&&z(P.Fragment,{children:[` · `,I(`bdi`,{dir:`ltr`,children:i(`imageViewer.count`,{n:t+1,total:e.length})})]})]})]})}),document.body):null}function nP({images:e}){let t=R(),[n,r]=(0,V.useState)(null),i=(0,V.useRef)([]),a=(0,V.useCallback)(()=>{let e=n;r(null),e!==null&&requestAnimationFrame(()=>i.current[e]?.focus())},[n]);return e.length===0?null:z(P.Fragment,{children:[I(`ul`,{className:`image-thumbs`,"aria-label":t(`msg.images`),children:e.map((e,n)=>I(`li`,{children:I(`button`,{type:`button`,ref:e=>{i.current[n]=e},className:`image-thumb`,onClick:()=>r(n),"aria-label":t(`msg.imageOpen`,{name:e.name}),title:e.name,children:I(`img`,{src:e.src,alt:``,loading:`lazy`})})},`${e.src}-${n}`))}),n!==null&&I(tP,{images:e,index:n,onIndex:r,onClose:a})]})}var rP=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),iP=String.raw`[^\s*?"<>|,;)}\]\\/]+[\\/]`,aP=String.raw`(?:(?:[A-Za-z]:[\\/]|(?<![\p{L}\p{N}_.\-\\/])/)(?:${iP})*)?`,oP=String.raw`(?<![\p{L}\p{N}_.\-])`,sP=String.raw`(?![\p{L}\p{N}_\-]|\.[\p{L}\p{N}])`,cP=e=>e.trim().replace(/\\/g,`/`).toLowerCase(),lP=e=>e.trim().split(/[\\/]/).pop()??``,uP=e=>e.split(/[\\/]/).slice(0,-1).filter(Boolean);function dP(e){let t=new Map;for(let n of e)t.set(n.filename.toLowerCase(),[...t.get(n.filename.toLowerCase())??[],n]);let n=new Map;for(let e of t.values()){let t=Math.max(...e.map(e=>uP(e.filepath??``).length)),r=null;for(let n=1;e.length>1&&n<=t&&!r;n++){let t=e.map(e=>[...uP(e.filepath??``).slice(-n),e.filename].join(`/`));new Set(t.map(e=>e.toLowerCase())).size===e.length&&(r=t)}e.forEach((e,t)=>n.set(e,r?r[t]:e.filename))}return n}function fP(e){let t=e.filter(e=>e.filename),n=dP(t),r=new Map,i=new Map;for(let e of t){let t={id:e.id,filename:e.filename,label:n.get(e)},a=new Set([e.filename.toLowerCase()]);e.filepath&&(a.add(lP(e.filepath).toLowerCase()),i.set(cP(e.filepath),t));for(let n of a){let i=r.get(n);r.set(n,i===void 0||i?.id===e.id?t:null)}}if(r.size===0)return{re:null,byName:r,byPath:i};let a=[...r.keys()].sort((e,t)=>t.length-e.length).map(rP).join(`|`);return{re:RegExp(`${aP}${oP}(${a})${sP}`,`giu`),byName:r,byPath:i}}function pP(e,t){return e.byPath.get(cP(t))??e.byName.get(lP(t).toLowerCase())??null}function mP(e,t){if(!e.re)return[];let n=[];for(let r of t.matchAll(e.re)){let i=r.index+r[0].length,a=
|
|
179
|
+
`).trim(),images:t}}function tP({images:e,index:t,onIndex:n,onClose:r}){let i=R(),a=(0,V.useRef)(null),o=(0,V.useRef)(null),s=e.length>1,c=e[t];pt(!0,r),on(a,!0),(0,V.useEffect)(()=>{o.current?.focus()},[]);let l=(0,V.useCallback)(r=>{n((t+r+e.length)%e.length)},[t,e.length,n]);return(0,V.useEffect)(()=>{if(!s)return;let e=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;let t=a.current?getComputedStyle(a.current).direction===`rtl`:!1;e.preventDefault(),l(e.key===`ArrowRight`===t?-1:1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[s,l]),c?(0,Mj.createPortal)(I(`div`,{ref:a,className:`image-viewer`,role:`dialog`,"aria-modal":`true`,"aria-label":i(`imageViewer.dialog`),onClick:e=>{e.target===e.currentTarget&&r()},children:z(`div`,{className:`image-viewer-stage`,onClick:e=>{e.target===e.currentTarget&&r()},children:[I(`button`,{ref:o,type:`button`,className:`image-viewer-btn image-viewer-close`,onClick:r,"aria-label":i(`imageViewer.close`),children:I(Is,{size:18,"aria-hidden":`true`})}),s&&I(`button`,{type:`button`,className:`image-viewer-btn image-viewer-prev`,onClick:()=>l(-1),"aria-label":i(`imageViewer.prev`),children:I(qr,{size:20,"aria-hidden":`true`})}),I(`img`,{className:`image-viewer-img`,src:c.src,alt:c.name}),s&&I(`button`,{type:`button`,className:`image-viewer-btn image-viewer-next`,onClick:()=>l(1),"aria-label":i(`imageViewer.next`),children:I(Yr,{size:20,"aria-hidden":`true`})}),z(`p`,{className:`image-viewer-caption`,dir:`auto`,children:[I(`bdi`,{children:c.name}),s&&z(P.Fragment,{children:[` · `,I(`bdi`,{dir:`ltr`,children:i(`imageViewer.count`,{n:t+1,total:e.length})})]})]})]})}),document.body):null}function nP({images:e}){let t=R(),[n,r]=(0,V.useState)(null),i=(0,V.useRef)([]),a=(0,V.useCallback)(()=>{let e=n;r(null),e!==null&&requestAnimationFrame(()=>i.current[e]?.focus())},[n]);return e.length===0?null:z(P.Fragment,{children:[I(`ul`,{className:`image-thumbs`,"aria-label":t(`msg.images`),children:e.map((e,n)=>I(`li`,{children:I(`button`,{type:`button`,ref:e=>{i.current[n]=e},className:`image-thumb`,onClick:()=>r(n),"aria-label":t(`msg.imageOpen`,{name:e.name}),title:e.name,children:I(`img`,{src:e.src,alt:``,loading:`lazy`})})},`${e.src}-${n}`))}),n!==null&&I(tP,{images:e,index:n,onIndex:r,onClose:a})]})}var rP=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),iP=String.raw`[^\s*?"<>|,;)}\]\\/]+[\\/]`,aP=String.raw`(?:(?:[A-Za-z]:[\\/]|(?<![\p{L}\p{N}_.\-\\/])/)(?:${iP})*)?`,oP=String.raw`(?<![\p{L}\p{N}_.\-])`,sP=String.raw`(?![\p{L}\p{N}_\-]|\.[\p{L}\p{N}])`,cP=e=>e.trim().replace(/\\/g,`/`).toLowerCase(),lP=e=>e.trim().split(/[\\/]/).pop()??``,uP=e=>e.split(/[\\/]/).slice(0,-1).filter(Boolean);function dP(e){let t=new Map;for(let n of e)t.set(n.filename.toLowerCase(),[...t.get(n.filename.toLowerCase())??[],n]);let n=new Map;for(let e of t.values()){let t=Math.max(...e.map(e=>uP(e.filepath??``).length)),r=null;for(let n=1;e.length>1&&n<=t&&!r;n++){let t=e.map(e=>[...uP(e.filepath??``).slice(-n),e.filename].join(`/`));new Set(t.map(e=>e.toLowerCase())).size===e.length&&(r=t)}e.forEach((e,t)=>n.set(e,r?r[t]:e.filename))}return n}function fP(e){let t=e.filter(e=>e.filename),n=dP(t),r=new Map,i=new Map;for(let e of t){let t={id:e.id,filename:e.filename,label:n.get(e)},a=new Set([e.filename.toLowerCase()]);e.filepath&&(a.add(lP(e.filepath).toLowerCase()),i.set(cP(e.filepath),t));for(let n of a){let i=r.get(n);r.set(n,i===void 0||i?.id===e.id?t:null)}}if(r.size===0)return{re:null,byName:r,byPath:i};let a=[...r.keys()].sort((e,t)=>t.length-e.length).map(rP).join(`|`);return{re:RegExp(`${aP}${oP}(${a})${sP}`,`giu`),byName:r,byPath:i}}function pP(e,t){return e.byPath.get(cP(t))??e.byName.get(lP(t).toLowerCase())??null}function mP(e,t){if(!e.re)return[];let n=[];for(let r of t.matchAll(e.re)){let i=r.index+r[0].length,a=hP(e,t,i,lP(r[0]).toLowerCase()),o=a&&a.start<=r.index?null:pP(e,r[0]);o?n.push({start:r.index,end:i,doc:o}):a&&n.push({start:a.start,end:i,doc:a.doc})}return n}function hP(e,t,n,r){let i=t.slice(0,n).replace(/\\/g,`/`).toLowerCase(),a=null;for(let[t,o]of e.byPath)lP(t)===r&&i.endsWith(t)&&(!a||n-t.length<a.start)&&(a={start:n-t.length,doc:o});return a}var gP=`[0-9\\u0660-\\u0669\\u06F0-\\u06F9]+`,_P=`pages?|pp?\\.|[وبفل]?(?:الصفحات|الصفحتان|الصفحتين|الصفحة|صفحات|صفحتي|صفحة)|ص\\.?`,vP=String.raw`\s*(?:,|،|&|and|to|و|إلى|[-–—])\s*`,yP=new RegExp(String.raw`(?<!\p{L})(?:${_P})(?!\p{L})\s*(${gP}(?:${vP}${gP})*)`,`iu`);function bP(e){return Number(e.replace(/[٠-٩۰-۹]/g,e=>String(e.charCodeAt(0)&15)))}function xP(e){let t=yP.exec(e);if(!t||t.index>40)return[];let n=t.index+t[0].length-t[1].length,r=[];for(let e of t[1].matchAll(new RegExp(gP,`g`))){let t=bP(e[0]);t>0&&r.push({start:n+e.index,end:n+e.index+e[0].length,page:t})}return r}function SP({active:e,label:t,awaitingUser:n=!1}){let r=R(),i=n?r(`activity.waiting`):t?gD(r,t):r(`msg.thinking`),a=wP(e,i),o=e&&!n&&yM(t),s=wP(o),c=Tc();return e?z(`span`,{className:`thinking-indicator${n?``:` is-live`}`,children:[I(`span`,{className:`thinking-indicator-text`,children:i}),!n&&a>=CP&&z(`span`,{className:`thinking-indicator-elapsed`,children:[` · `,z(`bdi`,{dir:`ltr`,children:[a,`s`]})]}),o&&s>=45&&I(`span`,{className:`thinking-indicator-hint`,role:`status`,children:r(c?.remote===!1?`live.localModelWaitHint`:`live.modelWaitHint`)})]}):null}var CP=3;function wP(e,t){let[n,r]=(0,V.useState)(0);return(0,V.useEffect)(()=>{if(r(0),!e)return;let t=Date.now(),n=setInterval(()=>r(Math.floor((Date.now()-t)/1e3)),1e3);return()=>clearInterval(n)},[e,t]),n}var TP=/^The model (?:call failed|stopped responding) at step \d+, so this request is unfinished\./;function EP(e){return TP.test(e.trimStart())}var DP=/[\\/]agents[\\/][^\\/\s]+[\\/]logs\b/;function OP(e){return DP.test(e)}var kP={root:`msg-report`,button:`msg-try-again`,hint:`msg-report-hint`,error:`msg-report-error`};function AP(e){if(!e)return!1;let t=e.toLowerCase();return t.startsWith(`error:`)||t.startsWith(`error -`)||t.includes(`traceback (most recent`)||t.includes(`object has no attribute`)||t.includes(`is lemonade server running`)||t.includes(`connection refused`)||t.includes(`failed to fetch`)}var jP=e=>e.replace(/\s+/g,` `).trim();function MP(e,t){let n=jP(t);if(!n)return{steps:e,echoed:!1,endedBy:null};let r=t.trimEnd(),i=e[e.length-1],a=!1,o=null;return{steps:e.filter(e=>e.type!==`error`||!e.detail?.trim()?!0:jP(e.detail)===n?(a=!0,!1):e!==i||!r.endsWith(`\n\n${e.detail.trim()}`)||(o=e.detail.trim(),!1)),echoed:a,endedBy:o}}var NP=/\s*\{\s*"?tool"?\s*:\s*"[^"]+"\s*,\s*"?tool_args"?\s*:\s*\{[^}]*\}\s*\}/g,PP=new Set([`thought`,`answer`,`tool`,`tool_args`,`goal`]),FP=/^\{\s*"(thought|answer|tool|tool_args|goal)"\s*:/;function IP(e,t){let n=0,r=!1,i=!1;for(let a=t;a<e.length;a++){let t=e[a];if(r)i?i=!1:t===`\\`?i=!0:t===`"`&&(r=!1);else if(t===`"`)r=!0;else if(t===`{`)n++;else if(t===`}`&&(n--,n===0))return a}return-1}function LP(e){let t=e.indexOf(`"answer"`);if(t===-1)return null;let n=e.indexOf(`:`,t+8);if(n===-1)return null;let r=n+1;for(;r<e.length&&/\s/.test(e[r]);)r++;if(r>=e.length||e[r]!==`"`)return null;let i=e.slice(r+1);return i.endsWith(`"}`)?i=i.slice(0,-2):i.endsWith(`"`)&&(i=i.slice(0,-1)),i.replace(/\\"/g,`"`).replace(/\\n/g,`
|
|
180
180
|
`).replace(/\\\\/g,`\\`)}function RP(e){let t;try{t=JSON.parse(e)}catch{let t=LP(e);return t===null?e.includes(`"tool_args"`)?{action:`drop`}:{action:`keep`}:{action:`answer`,text:t}}if(typeof t!=`object`||!t||Array.isArray(t))return{action:`keep`};let n=t,r=Object.keys(n),i=r.length>0&&r.every(e=>PP.has(e));return typeof n.tool==`string`&&n.tool_args!==void 0?{action:`drop`}:typeof n.answer==`string`&&i?{action:`answer`,text:n.answer}:typeof n.thought==`string`&&n.answer===void 0&&i?{action:`drop`}:{action:`keep`}}function zP(e,t){let n=``,r=0;for(;r<e.length;){let i=e.indexOf(`{`,r);if(i===-1){n+=e.slice(r);break}if(!FP.test(e.slice(i,i+40))){n+=e.slice(r,i+1),r=i+1;continue}let a=IP(e,i);if(a===-1){n+=t?e.slice(r,i):e.slice(r);break}n+=e.slice(r,i);let o=e.slice(i,a+1),s=RP(o);s.action===`answer`?n+=s.text:s.action===`keep`&&(n+=o),r=a+1}return n}var BP=new Set(`python.py.javascript.js.typescript.ts.java.c.cpp.csharp.cs.go.rust.ruby.rb.php.swift.kotlin.scala.r.perl.lua.bash.sh.zsh.powershell.ps1.sql.html.css.scss.sass.less.xml.json.yaml.yml.toml.ini.csv.markdown.md.dockerfile.docker.makefile.cmake.nginx.apache.graphql.proto.protobuf.jsx.tsx.vue.svelte.dart.elixir.ex.erlang.haskell.hs.ocaml.ml.fsharp.fs.clojure.clj.lisp.scheme.racket.zig.nim.crystal.julia.matlab.octave.fortran.cobol.pascal.delphi.ada.assembly.asm.nasm.wasm.solidity.sol.verilog.vhdl.text.txt.plaintext.diff.patch.log`.split(`.`));function VP(e){return e.replace(/```(\w*)[ \t]*\n([\s\S]*?)```/g,(e,t,n)=>{let r=t.toLowerCase();return r.length>0&&r.length<=2&&!BP.has(r)?n.trim():e})}var HP=/\n{1,2}Verification: unverified[^\n]*\s*$/;function UP(e){let t=e;for(;;){let e=t.replace(HP,``);if(e===t)return t;t=e}}function WP(e,t=!1){if(!e)return e;e=UP(e);let n=e;n=n.replace(NP,``),n=zP(n,t),n=n.replace(/<think>[\s\S]*?<\/think>/g,``);let r=(n.match(/\\n/g)||[]).length,i=(n.match(/\n/g)||[]).length;return r>2&&r>i*2&&(n=n.replace(/\\n/g,`
|
|
181
181
|
`),n=n.replace(/\\"/g,`"`)),n=VP(n).trim(),GP(n)}function GP(e){let t=!1;return e.split(`
|
|
182
182
|
`).map(e=>(/^\s*(```|~~~)/.test(e)&&(t=!t),t?e:e.replace(/^(\s*\d+)\.(\s*)$/,`$1\\.$2`))).join(`
|
|
183
183
|
`)}function KP(e,t){return e?new Date(e).toLocaleString(Sn(t),{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`,second:`2-digit`,hour12:!0}):``}function qP(e,t,n=new Date){if(!e)return``;let r=new Date(e),i=Sn(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 JP=`Cancelled.`,YP=[[`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`]],XP=/(?:^|\n\n)Before it stopped, it had started these tools: (.+)\.$/;function ZP(e){let t=e.trim(),n=YP.find(([e])=>t.endsWith(e));if(!n)return null;t=t.slice(0,-n[0].length).trimEnd();let r=XP.exec(t);return r&&(t=t.slice(0,r.index).trimEnd()),{body:t,notice:n[1],tools:r?r[1]:null}}function QP(e,t,n=!1){return t?`stopped`:ZP(e)?`interrupted`:n?`failed`:void 0}var $P=320;function eF({original:e,draft:t,onDraft:n,onSend:r,onCancel:i,confirming:a=!1}){let o=R(),{text:s,links:c}=(0,V.useMemo)(()=>E_(e),[e]),[l,u]=(0,V.useState)(()=>t==null?s:E_(t).text),d=(0,V.useRef)(null),f=l.trim()!==``&&l!==s,p=()=>r(D_(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,$P)}px`)},[l]),z(`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`,...Pt}),c.length>0&&I(`ul`,{className:`msg-edit-attachments`,"aria-label":o(`composer.attached`),children:c.map((e,t)=>z(`li`,{className:`msg-edit-attachment`,children:[I(Yi,{size:14,"aria-hidden":`true`}),I(`span`,{className:`msg-edit-attachment-name`,title:e.name,dir:`auto`,children:e.name})]},t))}),!a&&z(`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 tF=/^\[schedule-run\] Run #(\d+) \u00b7 (.+)$/;function nF({message:e,isStreaming:t,agentSteps:n,agentStepsActive:r,cards:i,onDelete:a,onResend:o,extraActions:s,onTryAgain:c,onContinue:l,onRegenerate:u,onEditStart:d,editing:f=!1,editDraft:p=null,onEditDraft:m,onEdit:h,onEditCancel:g,laterCount:_=0,latest:v=!1,latencyMs:y,liveStatus:b,toolStatus:x,awaitingUser:S}){let C=R();yc();let w=(0,V.useMemo)(()=>{if(e.role!==`assistant`||!n)return{steps:n,echoed:!1,endedBy:null};let r=RN(n,e.content);return t?{steps:r,echoed:!1,endedBy:null}:MP(r,e.content)},[n,e.content,e.role,t]),T=e.role===`assistant`&&(w.echoed||e.failed===!0||AP(e.content)),E=Tc(),D=qs(e=>e.show),O=B(e=>e.openSettings),k=B(e=>e.jumpToSetting),ee=(0,V.useMemo)(()=>T&&!t?XN(e.content):null,[T,t,e.content]),te=e.role===`assistant`?e.stopState??(e.content.trim()===JP?`stopped`:void 0):void 0,ne=(0,V.useMemo)(()=>e.role===`assistant`&&!t?ZP(e.content):null,[e.content,e.role,t]),A=ne?null:w.endedBy,re=(0,V.useMemo)(()=>e.role===`user`?eP(e.content):null,[e.content,e.role]),ie=(0,V.useMemo)(()=>re?re.text:WP(ne?ne.body:A?e.content.trimEnd().slice(0,-A.length):e.content,!!t),[e.content,re,t,ne,A]),ae=!!ie.trim()&&!(te&&ie.trim()===JP),j=e.turnSummary?.files,oe=(0,V.useMemo)(()=>j?.map(e=>e.path)??[],[j]),se=`${e.session_id}:${e.id}`,[ce,le]=(0,V.useState)(!1),[ue,de]=(0,V.useState)(!1),fe=e.role===`user`&&iD(e.content),pe=(0,V.useMemo)(()=>fe?oD(e.content):null,[fe,e.content]),[me,he]=(0,V.useState)(!1),M=(0,V.useId)(),N=(0,V.useRef)(null),ge=(0,V.useRef)(!1),_e=(0,V.useCallback)(()=>{me&&(ge.current=!0),he(!me)},[me]);(0,V.useEffect)(()=>{!me&&ge.current&&(ge.current=!1,N.current?.scrollIntoView?.({block:`nearest`}))},[me]);let ve=(0,V.useRef)(null),ye=(0,V.useRef)(null);(0,V.useEffect)(()=>()=>{ve.current&&clearTimeout(ve.current),ye.current&&clearTimeout(ye.current)},[]);let be=(0,V.useCallback)(()=>{let t=e.role===`assistant`?vM(ie):e.content;if(navigator.clipboard?.writeText)navigator.clipboard.writeText(t).catch(()=>{});else{let e=document.createElement(`textarea`);e.value=t,e.style.position=`fixed`,e.style.opacity=`0`,document.body.appendChild(e),e.select(),document.execCommand(`copy`),document.body.removeChild(e)}le(!0),ve.current&&clearTimeout(ve.current),ve.current=setTimeout(()=>le(!1),2e3)},[ie,e.content,e.role]),xe=(0,V.useCallback)(()=>{ue?(de(!1),ye.current&&clearTimeout(ye.current),a?.(e.id)):(de(!0),ye.current&&clearTimeout(ye.current),ye.current=setTimeout(()=>de(!1),3e3))},[ue,e.id,a]),[Se,Ce]=(0,V.useState)(null),we=(0,V.useCallback)(e=>{_>0?Ce(()=>e):e()},[_]),Te=(0,V.useCallback)(()=>{we(()=>o?.(e))},[e,o,we]),Ee=e.created_at?C(e.role===`user`?`msg.sent`:`msg.replied`,{time:KP(e.created_at,C)}):void 0,De=e.role===`system`?tF.exec(e.content):null;return De?I(`div`,{className:`msg-run-divider`,role:`separator`,children:C(`msg.scheduledRun`,{n:De[1],time:De[2]})}):I(`div`,{className:`msg msg-${e.role} ${T?`msg-error`:``}${v?` msg-latest`:``}`,title:Ee,children:z(`div`,{className:`msg-inner`,children:[z(`div`,{className:`msg-header`,children:[I(`div`,{className:`msg-header-left`}),!t&&!f&&z(`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(vo,{size:12})}),e.role===`user`&&o&&I(`button`,{className:`msg-action-btn`,onClick:Te,title:C(`msg.resend`),"aria-label":C(`msg.resend`),children:I(Po,{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(Bo,{size:12})}),s,e.role===`assistant`&&!T&&ae&&I(aN,{messageId:se,content:ie}),ae&&I(`button`,{className:`msg-copy ${ce?`copied`:``}`,onClick:be,title:C(ce?`msg.copied`:`msg.copy`),"aria-label":C(ce?`msg.copiedAria`:`msg.copy`),children:I(ce?Vr:hi,{size:12})}),a&&I(`button`,{className:`msg-action-btn msg-delete ${ue?`confirm`:``}`,onClick:xe,title:C(ue?`msg.confirmDelete`:`msg.delete`),"aria-label":C(ue?`msg.confirmDeleteAria`:`msg.delete`),children:I(Ss,{size:12})})]})]}),z(`div`,{className:`msg-body`,children:[e.role===`assistant`&&(w.steps&&w.steps.length>0||t)&&I(QD,{steps:w.steps??[],isActive:r??!1,running:!!t,awaitingUser:S,toolStatus:t?x:null,answer:t?void 0:ie,liveLine:t&&I(SP,{active:!!r||!ie,label:b,awaitingUser:S})}),T&&z(`div`,{className:`error-banner`,children:[I(ws,{size:14}),I(`span`,{children:C(ee&&ee.kind!==`unknown`?`failedTurn.${ee.kind}.title`:`msg.error`)})]}),(e.cards??i)?.map((e,t)=>I(hM,{render:e.render,data:e.data},t)),e.page_elements&&e.page_elements.length>0&&I(NN,{elements:e.page_elements}),f&&h?I(eF,{original:e.content,draft:p,onDraft:m,onSend:t=>we(()=>h(e,t)),onCancel:()=>{Ce(null),g?.()},confirming:Se!==null&&!t}):fe?z(P.Fragment,{children:[!me&&pe?z(`div`,{ref:N,id:M,className:`msg-excerpt md-content`,children:[I(`div`,{className:`msg-excerpt-lines`,dir:`auto`,children:pe.head}),I(`div`,{className:`msg-excerpt-gap`,children:C.plural(`msg.moreLines`,pe.hidden)}),I(`div`,{className:`msg-excerpt-lines`,dir:`auto`,children:pe.tail})]}):I(`div`,{ref:N,id:M,className:`msg-collapsible${me?``:` is-collapsed`}`,children:I(EF,{content:ie})}),I(cD,{expanded:me,onToggle:_e,controls:M,collapsedLabel:C.hint(C(`msg.showAll`),sD(C,e.content)),expandedLabel:C(`msg.showLess`),className:`msg-expand-toggle`})]}):ee?.raw?z(P.Fragment,{children:[I(`p`,{className:`msg-failed-lead`,children:C(`failedTurn.${ee.kind}.body`)}),z(`details`,{className:`msg-failed-details`,children:[I(`summary`,{children:C(`failedTurn.details`)}),I(EF,{content:ZN(ie)})]})]}):!(te&&ie.trim()===JP)&&I(EF,{content:ie,showCursor:t&&!!ie&&!r,isStreaming:t,writtenFiles:oe}),!f&&re&&I(nP,{images:re.images}),Se&&!t&&z(`div`,{className:`msg-drop-confirm`,role:`alertdialog`,"aria-labelledby":`${M}-drop`,children:[I(`span`,{id:`${M}-drop`,children:C.plural(`msg.dropLater`,_)}),z(`div`,{className:`msg-edit-actions`,children:[I(`button`,{type:`button`,className:`btn-secondary msg-edit-btn`,onClick:()=>Ce(null),autoFocus:!0,children:C(`msg.editCancel`)}),I(`button`,{type:`button`,className:`btn-primary msg-edit-btn`,onClick:()=>{Ce(null),Se()},children:C(`msg.dropLaterGo`)})]})]}),te&&z(`div`,{className:`msg-stopped${te===`unconfirmed`||e.stopError?` is-unconfirmed`:``}`,role:`note`,children:[I(vs,{size:9,fill:`currentColor`,"aria-hidden":`true`}),I(`span`,{children:te===`unconfirmed`?C(`msg.stoppedUnconfirmed`):e.stopError?C(`msg.stoppedError`,{error:e.stopError}):C(`msg.stopped`)})]}),ne&&I(`p`,{className:`msg-cut-off`,role:`note`,children:C.compose(e=>ne.tools?`${e(`msg.cutOff.toolsRan`,{tools:ne.tools})} ${e(ne.notice)}`:e(ne.notice))}),A&&I(`p`,{className:`msg-cut-off`,role:`note`,dir:`auto`,children:A}),l&&te&&!t&&ie.trim()&&ie.trim()!==JP&&z(`button`,{type:`button`,className:`msg-try-again`,onClick:l,children:[I(wo,{size:12,"aria-hidden":`true`}),C(`msg.continue`)]}),c&&!t&&z(`button`,{type:`button`,className:`msg-try-again`,onClick:c,children:[I(Bo,{size:12,"aria-hidden":`true`}),C(`msg.tryAgain`)]}),ee?.sections.map(e=>z(`button`,{type:`button`,className:`msg-try-again`,onClick:()=>{let t=ee?.targets[e];t?k({section:e,target:t}):O(e)},children:[I(Xo,{size:12,"aria-hidden":`true`}),C.compose(t=>t(`failedTurn.openSettings`,{tab:t(`settings.section.${e}`)}))]},e)),(T||A)&&!t&&OP(A??e.content)?z(`button`,{type:`button`,className:`msg-try-again`,onClick:()=>D(`agent`),children:[I(Wo,{size:12,"aria-hidden":`true`}),C(`logs.agentLog`)]}):(T||e.role===`assistant`&&EP(e.content))&&!t&&E?.remote===!1&&z(`button`,{type:`button`,className:`msg-try-again`,onClick:()=>D(`model_server`),children:[I(Wo,{size:12,"aria-hidden":`true`}),C(`logs.serverLog`)]}),e.role===`assistant`&&!t&&(SN(e.content)||SN(e.failureText??``))&&I(wN,{classes:kP,note:C(`msg.reportNote`)}),e.role===`assistant`&&!t&&QO(ie)&&I(ak,{content:ie}),e.role===`assistant`&&!t&&(e.stats||y!=null||e.created_at)&&z(`div`,{className:`msg-stats`,"aria-label":C(`msg.about`),children:[e.created_at&&I(`span`,{className:`msg-stats-ts`,title:KP(e.created_at,C),children:qP(e.created_at,C)}),e.stats?.retried&&e.stats.model&&I(`span`,{title:`This answer was kept from Retry with… (${e.stats.model})`,children:xc(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:xc(e.stats.route.model)}),I(qk,{latencyMs:y,stats:e.stats,ended:QP(e.content,te,T||!!A)})]}),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(WM,{sessionId:e.session_id,messageId:e.id}),e.role===`assistant`&&I(oN,{messageId:se}),e.role===`assistant`&&I(sN,{messageId:se})]})]})})}var rF=(0,V.createContext)(!1);function iF({lang:e,code:t}){let n=R(),[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(!1),s=(0,V.useContext)(rF),c=(0,V.useId)(),l=rD(t),u=l>(s?20:25),d=u&&!a,f=(0,V.useRef)(null);(0,V.useEffect)(()=>()=>{f.current&&clearTimeout(f.current)},[]);let p=(0,V.useCallback)(()=>{if(navigator.clipboard?.writeText)navigator.clipboard.writeText(t).catch(()=>{});else{let e=document.createElement(`textarea`);e.value=t,e.style.position=`fixed`,e.style.opacity=`0`,document.body.appendChild(e),e.select(),document.execCommand(`copy`),document.body.removeChild(e)}i(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>i(!1),2e3)},[t]);return z(`div`,{className:`code-block${d?` is-collapsed`:``}`,dir:`ltr`,children:[z(`div`,{className:`code-header`,children:[I(`span`,{className:`code-lang`,children:e||`code`}),z(`button`,{className:`code-copy ${r?`copied`:``}`,onClick:p,title:n(r?`msg.copied`:`code.copy`),"aria-label":n(r?`msg.copiedAria`:`code.copyAria`),children:[I(r?Vr:hi,{size:13}),I(`span`,{children:n(r?`code.copied`:`code.copy`)})]})]}),I(`pre`,{id:c,children:I(`code`,{children:t})}),u&&I(cD,{expanded:a,onToggle:()=>o(e=>!e),controls:c,collapsedLabel:n(`code.expand`,{size:nD(n,l)}),expandedLabel:n(`code.collapse`),className:`code-expand-toggle`})]})}var aF=/(?<=["\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,oF=/[.:!']+$/,sF=RegExp(`^(?:${aF.source})$`,`i`),cF=(0,V.createContext)([]);function lF(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 uF(e){if(typeof e!=`string`)return null;let t=e.trim();return sF.test(t)?t:null}function dF({path:e,label:t}){let n=t=>{t.preventDefault(),$t(e).catch(e=>{F.ui.error(`Failed to open path`,e)})};return z(`span`,{className:`file-path-link`,dir:`ltr`,onClick:n,title:`Open in file explorer: ${e}`,role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n(e))},children:[I($i,{size:12,className:`file-path-icon`}),t??e]})}function fF(e){return[...e.matchAll(new RegExp(aF.source,`gi`))].map(t=>{let n=t.index+t[0].length,r=`"“`.includes(e[t.index-1]??`
|
|
184
184
|
`)&&`"”`.includes(e[n]??`
|
|
185
185
|
`);return{start:t.index,path:r?t[0]:t[0].replace(oF,``)}})}function pF(e){let t=[],n=0;for(let{start:r,path:i}of fF(e))r>n&&t.push(e.slice(n,r)),t.push(I(dF,{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 mF=(0,V.createContext)(fP([]));function hF({doc:e,page:t,t:n}){return z(`a`,{className:`citation-link`,href:qn(e.id,t),target:`_blank`,rel:`noopener noreferrer`,dir:`ltr`,title:t?n(`citation.openPage`,{page:t}):n(`citation.open`,{name:e.label}),"data-doc-id":e.id,"data-page":t,children:[I(Yi,{size:12,className:`citation-icon`,"aria-hidden":`true`}),e.label]})}function gF({doc:e,page:t,label:n,t:r}){return I(`a`,{className:`citation-page`,href:qn(e.id,t),target:`_blank`,rel:`noopener noreferrer`,title:r(`citation.openPage`,{page:t}),"data-doc-id":e.id,"data-page":t,children:n})}function _F(e,t){let n=mP(e,t)[0];return xP(n?t.slice(0,n.start):t)}function vF(e,t,n,r){let i=fF(e),a=mP(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(gF,{doc:t,page:a.page,label:e.slice(r,s),t:n},`p${r}`)})}};if(r&&s(r,xP(e.slice(0,a[0]?.start??e.length)),0),a.forEach((t,r)=>{let i=xP(e.slice(t.end,a[r+1]?.start??e.length));o.push({start:t.start,end:t.end,node:I(hF,{doc:t.doc,page:i[0]?.page,t:n},`c${t.start}`)}),s(t.doc,i,t.end)}),o.length===0)return pF(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:pF(e.slice(l,t.start))},`t${l}`)),c.push(t.node),l=t.end;return l<e.length&&c.push(I(V.Fragment,{children:pF(e.slice(l))},`t${l}`)),I(P.Fragment,{children:c})}function yF(e,t){return typeof t==`string`?pP(e,t):null}function bF({children:e}){let t=(0,V.useContext)(mF),n=R(),r=V.Children.toArray(e),i=null,a=r.map((e,a)=>{if(typeof e==`string`){let r=vF(e,t,n,i);return i=null,I(V.Fragment,{children:r},`s${a}`)}if(i=null,V.isValidElement(e)&&e.type===SF){let o=yF(t,e.props.children);if(o){let e=r[a+1],s=typeof e==`string`?_F(t,e):[];return i=o,I(hF,{doc:o,page:s[0]?.page,t:n},`k${a}`)}}return e});return I(P.Fragment,{children:a})}function xF({tex:e,display:t}){let n=(0,V.useMemo)(()=>PT.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 SF({className:e,children:t,node:n,...r}){let i=(0,V.useContext)(mF),a=(0,V.useContext)(cF),o=R();if(e?.includes(`math-inline`))return I(xF,{tex:String(t),display:!1});let s=yF(i,t);if(s)return I(hF,{doc:s,t:o});let c=uF(t);if(c)return I(dF,{path:c});let l=lF(a,t);return l?I(dF,{path:l,label:String(t).trim()}):I(`code`,{className:`inline-code`,dir:`ltr`,...r,children:t})}var CF={code:SF,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(xF,{tex:i,display:!0});let a=r?.[1]||``;return I(iF,{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 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(bF,{children:e})})},h1({children:e}){return I(`h2`,{className:`md-h2`,dir:`auto`,children:I(bF,{children:e})})},h2({children:e}){return I(`h3`,{className:`md-h3`,dir:`auto`,children:I(bF,{children:e})})},h3({children:e}){return I(`h4`,{className:`md-h4`,dir:`auto`,children:I(bF,{children:e})})},h4({children:e}){return I(`h5`,{className:`md-h4`,dir:`auto`,children:I(bF,{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(bF,{children:e})})},blockquote({children:e}){return I(`blockquote`,{className:`md-blockquote`,dir:`auto`,children:I(bF,{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(bF,{children:e})})},th({children:e,className:t,style:n}){return I(`th`,{className:t,style:n,children:I(bF,{children:e})})}},wF=[],TF=[Bb,{singleDollarTextMath:!1}];function EF({content:e,showCursor:t,isStreaming:n=!1,writtenFiles:r=wF}){let i=B(e=>e.documents),a=(0,V.useMemo)(()=>fP(i),[i]),o=(0,V.useMemo)(()=>JT(e),[e]);return!e&&!t?null:!e&&t?I(`span`,{className:`cursor`}):I(rF.Provider,{value:n,children:I(mF.Provider,{value:a,children:I(cF.Provider,{value:r,children:z(`div`,{className:`md-content`,children:[I(h_,{remarkPlugins:[Ob,TF,eE,zT,VT],disallowedElements:[...b_],urlTransform:O_,components:CF,children:o}),t&&I(`span`,{className:`cursor`})]})})})})}var DF=()=>[...B.getState().messages].reverse().find(e=>e.role===`assistant`)?.id;function OF({busy:e}){let t=R(),[n,r]=(0,V.useState)({n:0,text:``}),i=(0,V.useRef)(DF());return(0,V.useEffect)(()=>{e&&(i.current=DF())},[e]),ku(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||AP(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 kF(e){return e.type===`status`&&e.status===`working`&&!e.phase&&(e.message??``).startsWith(`Model is processing`)}function AF(e){return e.phase===`loading_tools`?Ht()(`chat.loadingTools`):e.phase===`model_queue`&&e.queue?jF(e.queue):(e.message||``).trim()}function jF(e){let t=Ht(),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 MF(e,t){let n=++t.current,r=Date.now();switch(e.type){case`thinking`:return{id:n,type:`thinking`,label:`Thinking`,detail:e.content,active:!0,timestamp:r};case`commentary`:return{id:n,type:`commentary`,label:`Commentary`,detail:e.content,active:!1,timestamp:r};case`tool_start`:return{id:n,type:`tool`,label:`Using tool`,tool:e.tool,detail:e.detail,narration:e.narration,active:!0,timestamp:r,mcpServer:e.mcp_server,mcpServerLabel:e.mcp_server_label,mcpTool:e.mcp_tool};case`skill_use`:return{id:n,type:`tool`,label:`Using tool`,tool:`use_skill`,detail:e.skill,narration:`Using skill: ${e.skill}`,active:!1,success:!0,timestamp:r};case`plan`:return{id:n,type:`plan`,label:`Created plan`,planSteps:e.steps,planNarrations:e.step_narrations,currentStep:e.current_step,active:!1,success:!0,timestamp:r};case`step`:return{id:n,type:`status`,label:`Step ${e.step}${e.total?` of ${e.total}`:``}`,active:!0,timestamp:r};case`status`:return e.message?.startsWith(`Agent: `)?null:{id:n,type:`status`,label:e.message||e.status||`Working`,active:e.status===`working`,...e.status===`warning`?{success:!1}:{},timestamp:r};case`agent_error`:return{id:n,type:`error`,label:`Error`,detail:e.content,success:!1,active:!1,timestamp:r};case`policy_alert`:{let t=e.tool||`unknown tool`,i=e.reason||e.message||e.content||`Tool execution was blocked by governance policy.`;return{id:n,type:`policy_alert`,label:`Policy blocked ${t}`,detail:i,tool:t,decision:e.decision||`BLOCK`,reason:i,ruleIds:e.rule_ids??[],policyVersion:e.policy_version,receiptId:e.receipt_id,success:!1,active:!1,timestamp:r}}default:return null}}var NF=`speech_model_downloaded`,PF=new Set([`tool`,`waiting`]);function FF(e){return e.livePhase&&!PF.has(e.livePhase)?e.liveStatus:null}function IF(e,t){let n=B.getState(),r=e.status,i=AF(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===NF&&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`||kF(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=MF({...e,message:i},t);o&&n.addAgentStep(o)}var LF=/\s*\{\s*"?(?:tool|thought|goal)"?\s*:\s*"[^"]*"[^}]*(?:"?tool_args"?\s*:\s*\{[^}]*\})?\s*\}/g;function RF(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,`
|
|
186
|
-
`).replace(/\\\\/g,`\\`)}function zF(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 BF(e){let t=(e||[]).filter(e=>typeof e.render==`string`&&e.render.length>0).reduce((e,t)=>Qe(e,{render:t.render,data:t.data}),[]);return t.length>0?t:void 0}function VF(e){return(e||[]).map(e=>{let t=e.agentSteps||e.agent_steps||void 0;return{...e,agentSteps:t,cards:e.cards||BF(t),stats:e.stats||e.inference_stats||void 0,turnSummary:e.turnSummary||e.turn_summary||void 0,libraryNotices:e.libraryNotices||e.library_notices||void 0,stopState:e.stopState??(e.stopped?`stopped`:void 0)}})}function HF(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 UF(e,t){return!!e&&e.role===`assistant`&&!!t.failureText&&e.content.trim()===t.failureText.trim()}function WF(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||UF(r[0],n))}function GF(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 KF(e,t){let n=e[e.length-1],r=t[t.length-1];if(!n?.failed||!UF(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 qF(e){return`policy-receipt-${encodeURIComponent(e)}`}function JF(e){let t=e.content.trim();return!t||e.stopState||e.failed||e.failure||AP(t)||QM(t,1e3).length===0?!1:!MP(e.agentSteps??[],t).echoed}function YF(){(0,V.useEffect)(()=>{let e=!0,t=async()=>{try{let t=await GM();e&&t&&iN.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 XF=[`download`,`decode`,`transcribe`,`voices`,`prepare`,`analyze`],ZF=0,QF=5;function $F(e,t){return e==null?``:e<60?t(`recording.leftUnderMinute`):t(`recording.leftMinutes`,{minutes:Math.ceil(e/60)})}function eI(e){return XF.map((e,t)=>t).filter(t=>t!==ZF&&t!==QF||t in e)}function tI({state:e}){return e===1?I(Vr,{size:14,"aria-hidden":`true`}):e===2?I(Ya,{size:14,"aria-hidden":`true`}):I(`span`,{className:`recording-progress-dot`,"aria-hidden":`true`})}function nI({index:e,stage:t}){let n=R(),r=n(`recording.stage.${XF[e]}`),i=t?.state===0,a=t?.percent,o=i?$F(t?.etaSeconds,n):``,s=t?.state===2?n(`recording.skipped`):o;return z(`li`,{className:`recording-progress-row${i?` is-running`:``}${t?``:` is-waiting`}${t?.state===1?` is-done`:``}`,children:[I(`span`,{className:`recording-progress-mark`,children:I(tI,{state:t?.state})}),I(`span`,{className:`recording-progress-label`,children:r}),i&&a!=null&&z(`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 rI=120;function iI(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)<rI);return r||t.push({title:n,seconds:e.seconds}),!r});return{...e,items:n}})}function aI({sections:e}){let t=R(),n=iI(e),r=n[0]?.sections??0;return z(`section`,{className:`recording-found`,"aria-label":t(`recording.found.title`),children:[z(`h4`,{className:`recording-found-title`,children:[t(`recording.found.title`),I(`span`,{className:`recording-found-count`,children:t(`recording.found.count`,{done:n.length,total:r})})]}),n.map(e=>z(`div`,{className:`recording-found-section`,children:[z(`p`,{className:`recording-found-span`,children:[z(`bdi`,{dir:`ltr`,className:`recording-found-time`,children:[e.start,`–`,e.end]}),e.summary&&I(`span`,{dir:`auto`,children:e.summary})]}),e.items.length>0&&I(`ul`,{className:`recording-found-items`,children:e.items.map(e=>z(`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 oI(){let e=R(),t=B(e=>e.recordingStages),n=B(e=>e.recordingSections);return t?z(`section`,{className:`recording-progress`,"aria-label":e(`recording.title`),children:[I(`ol`,{className:`recording-progress-list`,children:eI(t).map(e=>I(nI,{index:e,stage:t[e]},e))}),n&&I(aI,{sections:n})]}):null}function sI(e,t){let n=e.tool||``,r=e.tool_label||n,{addNotification:i,notifications:a}=_l.getState(),o=e.confirm_id?a.find(t=>t.id===e.confirm_id):void 0;if(o){!o.response&&o.dismissed&&_l.setState(e=>({notifications:e.notifications.map(e=>e.id===o.id?{...e,dismissed:!1}:e)}));return}let s=n===rl,c=s&&ml(a,t,e.args);i({id:e.confirm_id??`perm-${Date.now()}`,type:`permission_request`,agentId:t,sessionId:t,agentName:`GAIA`,title:s?ol(e.args,c):n===`trust_project_folder`?`Trust this folder's instructions and skills?`:`Allow ${r}?`,message:s?al(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 cI(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 lI(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 uI(e){let t={result:e.summary||e.title||`Done`,active:!1,success:e.success!==!1,latencyMs:e.latency_ms},n=lI(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 dI=5e3,fI=2e3,pI=3e4,mI=6e4;function hI(e){return e?.init_state===`initializing`?!e.init_tasks||e.init_tasks.some(e=>e.status===`pending`||e.status===`running`):!1}function gI(e){return e.lemonade_running?`up`:e.lemonade_error?`unresponsive`:`down`}function _I(e){return e.kind===`slow`||e.kind===`error`||e.kind===`ok`&&gI(e.status)===`unresponsive`}function vI(e){let t=e.kind===`ok`?e.status.download_progress?.state:void 0;return t===`downloading`||t===`starting`}function yI(e){let t=null,n=0,r=!1,i=null,a=null,o=!1,s=!1,c=()=>{o||!s||a||(a=setTimeout(()=>{a=null,f()},p()))},l=0,u=null,d=async()=>{let e={controller:new AbortController,cancelled:!1};u=e;let{controller:t}=e,n=setTimeout(()=>t.abort(),mI);try{return{kind:`ok`,status:await te(t.signal)}}catch(n){if(e.cancelled)return null;if(t.signal.aborted)return{kind:`slow`};let r=n?.httpStatus;return r===504?{kind:`slow`}:n?.name===`ApiError`&&typeof r==`number`&&r!==502?{kind:`error`,httpStatus:r,message:n.message}:{kind:`unreachable`,error:n}}finally{clearTimeout(n),u===e&&(u=null)}},f=()=>{if(t)return t;let i=d().then(t=>{if(t!==null){n=_I(t)?n+1:0,r=vI(t),t.kind===`ok`?s=hI(t.status):t.kind===`unreachable`&&(s=!1),c();try{e(t)}catch(e){F.system.error(`Could not apply the system status; the next poll will try again`,e)}}}).finally(()=>{t===i&&(t=null)});return t=i,i},p=()=>Math.min((r?fI:dI)*2**n,pI),m=e=>{f().finally(()=>{e===l&&(i=setTimeout(()=>m(e),p()))})};return{check:f,start:()=>{let e=++l;return o=!0,a&&clearTimeout(a),a=null,m(e),()=>{e===l&&(l++,o=!1,c(),i&&clearTimeout(i),i=null,u&&(u.cancelled=!0,u.controller.abort(),u=null,t=null))}}}}var bI=1e3,xI=15e3,SI=null,CI=null,wI=bI,TI=0,EI=null;function DI(){if(SI)return SI;let e=Date.now();return SI=Mt().then(t=>B.getState().setActiveRuns(t,e)).catch(e=>{F.api.warn(`Could not read which chats are running`,e),xM(e)&&B.getState().loseActiveRuns()}).finally(()=>{SI=null}),SI}function OI(){let e=B.getState();return e.isStreaming||e.runningSessionIds.length>0}function kI(){return OI()?(wI=bI,bI):(wI=Math.min(wI*2,xI),wI)}function AI(e){DI().then(()=>{e===TI&&(CI=setTimeout(()=>AI(e),kI()))})}function jI(){EI&&(CI&&clearTimeout(CI),CI=null,wI=bI,AI(++TI))}function MI(){EI?.();let e=B.subscribe((e,t)=>{e.isStreaming&&!t.isStreaming&&jI()}),t=()=>jI();window.addEventListener(`focus`,t);let n=()=>{TI++,CI&&clearTimeout(CI),CI=null,e(),window.removeEventListener(`focus`,t),EI===n&&(EI=null)};return EI=n,wI=bI,AI(++TI),n}var NI=3e3,PI=new Set,FI=new Map,II=new Set,LI=null;function RI(e,t=Date.now()){FI.set(e,t)}function zI(e){let t=B.getState();return t.activeRunsAt>0&&t.activeRunsAt>=(FI.get(e)??0)&&!t.runningSessionIds.includes(e)&&!t.queuedSessionIds.includes(e)}function BI(e){return II.add(e),()=>{II.delete(e),LI?.()}}function VI(e){return e instanceof Error?pN(e)??(e.message||`Unknown error`):String(e)}function HI(e){let t=e?.httpStatus;return typeof t==`number`?t:void 0}function UI(e){let t=HI(e);return t===409||t===429}function WI(e){F.chat.warn(`Chat ${e} no longer exists; dropping its queued messages`),B.getState().updateQueue(e,()=>[])}function GI(e){B.getState().setQueueHold(e,!0),setTimeout(()=>B.getState().setQueueHold(e,!1),NI)}function KI(e,t,n){return HI(n)===409&&(F.chat.info(`Chat ${e} was busy; queueing the message to try again`),B.getState().updateQueue(e,e=>xt(e,t,`queued`)),GI(e),!0)}async function qI(e,t,n){let r=B.getState;if(PI.has(e)||r().queueHolds[e])return;let i=r().messageQueues[e]??[];if(i.some(e=>e.state===`sending`))return;let a=m(i);if(a||Hn(i)){PI.add(e);try{if(a){let t;try{t=await Tn(e)}catch(t){if(HI(t)===409){F.chat.info(`Chat ${e} is answering again; its queue waits for that turn to end`);return}if(HI(t)===404){WI(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=>Gn(e,`GAIA could not say whether it read this message: ${VI(t)}`));return}r().updateQueue(e,e=>_(e,t))}let i=Hn(r().messageQueues[e]??[]);if(!i||!n())return;r().updateQueue(e,e=>b(e,i.id,`queued`,`starting`));let o;try{o=await t(e,i.text)}catch(e){o={kind:`failed`,error:VI(e)}}if(o.kind===`accepted`){RI(e),r().updateQueue(e,e=>we(e,i.id)),jI();return}if(o.kind===`busy`){F.chat.info(`Queued message found chat ${e} busy; holding it`),r().updateQueue(e,e=>He(e,i.id)),GI(e);return}if(o.kind===`gone`){WI(e);return}F.chat.error(`Queued message for chat ${e} was not sent: ${o.error}`),r().updateQueue(e,e=>He(e,i.id,o.error))}finally{PI.delete(e)}}}function JI(e){return e.type!==`status`||e.phase!==`waiting`}var YI=(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=h(e,t,{onChunk:s,onAgentEvent:e=>{JI(e)&&s()},onDone:s,onError:e=>{uN(e)?s():UI(e)?o({kind:`busy`}):HI(e)===404?o({kind:`gone`}):o({kind:`failed`,error:VI(e)})}}),a&&i.abort()});function XI(e=YI){let t=()=>{let t=B.getState();if(!hI(t.systemStatus))for(let n of Object.keys(t.messageQueues))!II.has(n)&&zI(n)&&qI(n,e,()=>!II.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 LI=t,t(),()=>{n(),LI===t&&(LI=null)}}var ZI=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`]),QI=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 $I(e){let t=e.lastIndexOf(`.`);return t<0?``:e.slice(t).toLowerCase()}function eL(e){return ZI.has($I(e))}function tL(e){let t=$I(e);return ZI.has(t)||QI.has(t)}function nL(e){return e===`model_server_down`||e===`model_server_busy`}function rL(e,t){return e===`model_server_down`?t(`docs.serverDown`):e===`model_server_busy`?t(`docs.serverBusy`):null}function iL(e){return e===`model_server_down`}function aL(e,t,n){return e===`model_server_down`?n(`docs.notAddedServer`,{name:t}):e===`model_server_busy`?n(`docs.notAddedServerBusy`,{name:t}):null}var oL=`https://github.com/amd/gaia/issues/new`,sL=[{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:ZI,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:QI,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 cL(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;for(let e of sL)if(e.extensions.has(t))return e;return null}var lL=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 uL(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;return lL.has(t)}function dL(){let e=navigator.userAgent;return`**Environment:**\n- GAIA Version: 0.27.0rc1\n- Platform: ${navigator.platform||`unknown`}\n- User Agent: ${e}\n- Interface: Agent UI (Web)`}function fL(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?_`,``,`---`,dL(),``,`_Submitted from GAIA Agent UI_`].join(`
|
|
186
|
+
`).replace(/\\\\/g,`\\`)}function zF(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 BF(e){let t=(e||[]).filter(e=>typeof e.render==`string`&&e.render.length>0).reduce((e,t)=>Qe(e,{render:t.render,data:t.data}),[]);return t.length>0?t:void 0}function VF(e){return(e||[]).map(e=>{let t=e.agentSteps||e.agent_steps||void 0;return{...e,agentSteps:t,cards:e.cards||BF(t),stats:e.stats||e.inference_stats||void 0,turnSummary:e.turnSummary||e.turn_summary||void 0,libraryNotices:e.libraryNotices||e.library_notices||void 0,stopState:e.stopState??(e.stopped?`stopped`:void 0)}})}function HF(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 UF(e,t){return!!e&&e.role===`assistant`&&!!t.failureText&&e.content.trim()===t.failureText.trim()}function WF(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||UF(r[0],n))}function GF(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 KF(e,t){let n=e[e.length-1],r=t[t.length-1];if(!n?.failed||!UF(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 qF(e){return`policy-receipt-${encodeURIComponent(e)}`}function JF(e){let t=e.content.trim();return!t||e.stopState||e.failed||e.failure||AP(t)||QM(t,1e3).length===0?!1:!MP(e.agentSteps??[],t).echoed}function YF(){(0,V.useEffect)(()=>{let e=!0,t=async()=>{try{let t=await GM();e&&t&&iN.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 XF=[`download`,`decode`,`transcribe`,`voices`,`prepare`,`analyze`],ZF=0,QF=5;function $F(e,t){return e==null?``:e<60?t(`recording.leftUnderMinute`):t(`recording.leftMinutes`,{minutes:Math.ceil(e/60)})}function eI(e){return XF.map((e,t)=>t).filter(t=>t!==ZF&&t!==QF||t in e)}function tI({state:e}){return e===1?I(Vr,{size:14,"aria-hidden":`true`}):e===2?I(Ya,{size:14,"aria-hidden":`true`}):I(`span`,{className:`recording-progress-dot`,"aria-hidden":`true`})}function nI({index:e,stage:t}){let n=R(),r=n(`recording.stage.${XF[e]}`),i=t?.state===0,a=t?.percent,o=i?$F(t?.etaSeconds,n):``,s=t?.state===2?n(`recording.skipped`):o;return z(`li`,{className:`recording-progress-row${i?` is-running`:``}${t?``:` is-waiting`}${t?.state===1?` is-done`:``}`,children:[I(`span`,{className:`recording-progress-mark`,children:I(tI,{state:t?.state})}),I(`span`,{className:`recording-progress-label`,children:r}),i&&a!=null&&z(`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 rI=120;function iI(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)<rI);return r||t.push({title:n,seconds:e.seconds}),!r});return{...e,items:n}})}function aI({sections:e}){let t=R(),n=iI(e),r=n[0]?.sections??0;return z(`section`,{className:`recording-found`,"aria-label":t(`recording.found.title`),children:[z(`h4`,{className:`recording-found-title`,children:[t(`recording.found.title`),I(`span`,{className:`recording-found-count`,children:t(`recording.found.count`,{done:n.length,total:r})})]}),n.map(e=>z(`div`,{className:`recording-found-section`,children:[z(`p`,{className:`recording-found-span`,children:[z(`bdi`,{dir:`ltr`,className:`recording-found-time`,children:[e.start,`–`,e.end]}),e.summary&&I(`span`,{dir:`auto`,children:e.summary})]}),e.items.length>0&&I(`ul`,{className:`recording-found-items`,children:e.items.map(e=>z(`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 oI(){let e=R(),t=B(e=>e.recordingStages),n=B(e=>e.recordingSections);return t?z(`section`,{className:`recording-progress`,"aria-label":e(`recording.title`),children:[I(`ol`,{className:`recording-progress-list`,children:eI(t).map(e=>I(nI,{index:e,stage:t[e]},e))}),n&&I(aI,{sections:n})]}):null}function sI(e,t){let n=e.tool||``,r=e.tool_label||n,{addNotification:i,notifications:a}=_l.getState(),o=e.confirm_id?a.find(t=>t.id===e.confirm_id):void 0;if(o){!o.response&&o.dismissed&&_l.setState(e=>({notifications:e.notifications.map(e=>e.id===o.id?{...e,dismissed:!1}:e)}));return}let s=n===rl,c=s&&ml(a,t,e.args);i({id:e.confirm_id??`perm-${Date.now()}`,type:`permission_request`,agentId:t,sessionId:t,agentName:`GAIA`,title:s?ol(e.args,c):n===`trust_project_folder`?`Trust this folder's instructions and skills?`:`Allow ${r}?`,message:s?al(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 cI(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 lI(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 uI(e){let t={result:e.summary||e.title||`Done`,active:!1,success:e.success!==!1,latencyMs:e.latency_ms},n=lI(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 dI=5e3,fI=2e3,pI=3e4,mI=6e4;function hI(e){return e?.init_state===`initializing`?!e.init_tasks||e.init_tasks.some(e=>e.status===`pending`||e.status===`running`):!1}function gI(e){return e.lemonade_running?`up`:e.lemonade_error?`unresponsive`:`down`}function _I(e){return e.kind===`slow`||e.kind===`error`||e.kind===`ok`&&gI(e.status)===`unresponsive`}function vI(e){let t=e.kind===`ok`?e.status.download_progress?.state:void 0;return t===`downloading`||t===`starting`}function yI(e){let t=null,n=0,r=!1,i=null,a=null,o=!1,s=!1,c=()=>{o||!s||a||(a=setTimeout(()=>{a=null,f()},p()))},l=0,u=null,d=async()=>{let e={controller:new AbortController,cancelled:!1};u=e;let{controller:t}=e,n=setTimeout(()=>t.abort(),mI);try{return{kind:`ok`,status:await te(t.signal)}}catch(n){if(e.cancelled)return null;if(t.signal.aborted)return{kind:`slow`};let r=n?.httpStatus;return r===504?{kind:`slow`}:n?.name===`ApiError`&&typeof r==`number`&&r!==502?{kind:`error`,httpStatus:r,message:n.message}:{kind:`unreachable`,error:n}}finally{clearTimeout(n),u===e&&(u=null)}},f=()=>{if(t)return t;let i=d().then(t=>{if(t!==null){n=_I(t)?n+1:0,r=vI(t),t.kind===`ok`?s=hI(t.status):t.kind===`unreachable`&&(s=!1),c();try{e(t)}catch(e){F.system.error(`Could not apply the system status; the next poll will try again`,e)}}}).finally(()=>{t===i&&(t=null)});return t=i,i},p=()=>Math.min((r?fI:dI)*2**n,pI),m=e=>{f().finally(()=>{e===l&&(i=setTimeout(()=>m(e),p()))})};return{check:f,start:()=>{let e=++l;return o=!0,a&&clearTimeout(a),a=null,m(e),()=>{e===l&&(l++,o=!1,c(),i&&clearTimeout(i),i=null,u&&(u.cancelled=!0,u.controller.abort(),u=null,t=null))}}}}var bI=1e3,xI=15e3,SI=null,CI=null,wI=bI,TI=0,EI=null;function DI(){if(SI)return SI;let e=Date.now();return SI=Mt().then(t=>B.getState().setActiveRuns(t,e)).catch(e=>{F.api.warn(`Could not read which chats are running`,e),xM(e)&&B.getState().loseActiveRuns()}).finally(()=>{SI=null}),SI}function OI(){let e=B.getState();return e.isStreaming||e.runningSessionIds.length>0}function kI(){return OI()?(wI=bI,bI):(wI=Math.min(wI*2,xI),wI)}function AI(e){DI().then(()=>{e===TI&&(CI=setTimeout(()=>AI(e),kI()))})}function jI(){EI&&(CI&&clearTimeout(CI),CI=null,wI=bI,AI(++TI))}function MI(){EI?.();let e=B.subscribe((e,t)=>{e.isStreaming&&!t.isStreaming&&jI()}),t=()=>jI();window.addEventListener(`focus`,t);let n=()=>{TI++,CI&&clearTimeout(CI),CI=null,e(),window.removeEventListener(`focus`,t),EI===n&&(EI=null)};return EI=n,wI=bI,AI(++TI),n}var NI=3e3,PI=new Set,FI=new Map,II=new Set,LI=null;function RI(e,t=Date.now()){FI.set(e,t)}function zI(e){let t=B.getState();return t.activeRunsAt>0&&t.activeRunsAt>=(FI.get(e)??0)&&!t.runningSessionIds.includes(e)&&!t.queuedSessionIds.includes(e)}function BI(e){return II.add(e),()=>{II.delete(e),LI?.()}}function VI(e){return e instanceof Error?pN(e)??(e.message||`Unknown error`):String(e)}function HI(e){let t=e?.httpStatus;return typeof t==`number`?t:void 0}function UI(e){let t=HI(e);return t===409||t===429}function WI(e){F.chat.warn(`Chat ${e} no longer exists; dropping its queued messages`),B.getState().updateQueue(e,()=>[])}function GI(e){B.getState().setQueueHold(e,!0),setTimeout(()=>B.getState().setQueueHold(e,!1),NI)}function KI(e,t,n){return HI(n)===409&&(F.chat.info(`Chat ${e} was busy; queueing the message to try again`),B.getState().updateQueue(e,e=>xt(e,t,`queued`)),GI(e),!0)}async function qI(e,t,n){let r=B.getState;if(PI.has(e)||r().queueHolds[e])return;let i=r().messageQueues[e]??[];if(i.some(e=>e.state===`sending`))return;let a=m(i);if(a||Hn(i)){PI.add(e);try{if(a){let t;try{t=await Tn(e)}catch(t){if(HI(t)===409){F.chat.info(`Chat ${e} is answering again; its queue waits for that turn to end`);return}if(HI(t)===404){WI(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=>Gn(e,`GAIA could not say whether it read this message: ${VI(t)}`));return}r().updateQueue(e,e=>_(e,t))}let i=Hn(r().messageQueues[e]??[]);if(!i||!n())return;r().updateQueue(e,e=>b(e,i.id,`queued`,`starting`));let o;try{o=await t(e,i.text)}catch(e){o={kind:`failed`,error:VI(e)}}if(o.kind===`accepted`){RI(e),r().updateQueue(e,e=>we(e,i.id)),jI();return}if(o.kind===`busy`){F.chat.info(`Queued message found chat ${e} busy; holding it`),r().updateQueue(e,e=>He(e,i.id)),GI(e);return}if(o.kind===`gone`){WI(e);return}F.chat.error(`Queued message for chat ${e} was not sent: ${o.error}`),r().updateQueue(e,e=>He(e,i.id,o.error))}finally{PI.delete(e)}}}function JI(e){return e.type!==`status`||e.phase!==`waiting`}var YI=(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=h(e,t,{onChunk:s,onAgentEvent:e=>{JI(e)&&s()},onDone:s,onError:e=>{uN(e)?s():UI(e)?o({kind:`busy`}):HI(e)===404?o({kind:`gone`}):o({kind:`failed`,error:VI(e)})}}),a&&i.abort()});function XI(e=YI){let t=()=>{let t=B.getState();if(!hI(t.systemStatus))for(let n of Object.keys(t.messageQueues))!II.has(n)&&zI(n)&&qI(n,e,()=>!II.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 LI=t,t(),()=>{n(),LI===t&&(LI=null)}}var ZI=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`]),QI=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 $I(e){let t=e.lastIndexOf(`.`);return t<0?``:e.slice(t).toLowerCase()}function eL(e){return ZI.has($I(e))}function tL(e){let t=$I(e);return ZI.has(t)||QI.has(t)}function nL(e){return e===`model_server_down`||e===`model_server_busy`}function rL(e,t){return e===`model_server_down`?t(`docs.serverDown`):e===`model_server_busy`?t(`docs.serverBusy`):null}function iL(e){return e===`model_server_down`}function aL(e,t,n){return e===`model_server_down`?n(`docs.notAddedServer`,{name:t}):e===`model_server_busy`?n(`docs.notAddedServerBusy`,{name:t}):null}var oL=`https://github.com/amd/gaia/issues/new`,sL=[{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:ZI,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:QI,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 cL(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;for(let e of sL)if(e.extensions.has(t))return e;return null}var lL=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 uL(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;return lL.has(t)}function dL(){let e=navigator.userAgent;return`**Environment:**\n- GAIA Version: 0.27.0rc2\n- Platform: ${navigator.platform||`unknown`}\n- User Agent: ${e}\n- Interface: Agent UI (Web)`}function fL(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?_`,``,`---`,dL(),``,`_Submitted from GAIA Agent UI_`].join(`
|
|
187
187
|
`);return`${oL}?${new URLSearchParams({title:`[Feature] ${e}`,body:n,labels:`enhancement,agent-ui`}).toString()}`}function pL(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?_`,``,`---`,dL(),``,`_Submitted from GAIA Agent UI_`].join(`
|
|
188
188
|
`);return`${oL}?${new URLSearchParams({title:`[Bug] ${e}`,body:n,labels:`bug,agent-ui`}).toString()}`}var mL={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 hL(e,t){if(!e.startsWith(t))return e;let n=e.slice(t.length).trim();return n.charAt(0).toUpperCase()+n.slice(1)}function gL({filename:e,error:t,status:n,kind:r,onDismiss:i,timeout:a=15e3}){let o=R(),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?cL(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=ri,g=r?mL[r]:void 0;return g?(f=`"${e}" can't be read`,p=g,m=null,h=ws):rL(r,o)?(f=aL(r,e,o)??o(`docs.notAddedServer`,{name:e}),p=rL(r,o)??t,m=null,h=ws):r===`too_large`?(f=o(`docs.tooLarge`,{name:e}),p=t,m=null,h=ws):n===404?(f=o(`docs.notFound`,{name:e}),p=o(`docs.notFoundDetail`),m=null,h=ws):n===403?(f=`GAIA can't read files in that location`,p=`${t} Or drop the file here instead (up to 20 MB) and GAIA keeps its own copy.`,m=null,h=ws):u&&l?(f=`${l.label} files not supported`,p=l.message,m=fL(l.featureTitle),h=ws):u&&!c?(f=`"${e}" has no file extension`,p=hL(t,`File type not allowed:`),m=null,h=ws):u?(f=`File type not supported: ${c}`,p=`This file format cannot be indexed. Supported: PDF, DOCX, PPTX, XLSX, EPUB, images (PNG, JPG, WEBP, ...), TXT, MD, CSV, JSON, HTML, XML, YAML, and 30+ code file formats.`,m=fL(`Support ${c} file indexing`),h=ws):d?(f=`Connection error`,p=`Could not reach the GAIA server. Make sure the backend is running.`,m=pL(`Upload connection error for ${e}`),h=ri):(f=`Failed to index "${e}"`,p=t||`An unexpected error occurred during indexing.`,m=pL(`Indexing error: ${t.slice(0,80)}`),h=jr),z(`div`,{className:`upload-error-toast`,role:`alert`,children:[I(h,{size:16}),z(`div`,{className:`upload-error-content`,children:[I(`div`,{className:`upload-error-title`,children:f}),z(`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(Is,{size:14})})]})}function _L(e,t,n=[],r=[],i={}){let a=vL(t,r,i);if(n.length>0)return n.some(a);let o=$O(e);return o===`google`?a(`google`):o===`microsoft`?a(`microsoft`):a(`google`)||a(`microsoft`)}function vL(e,t,n){return r=>MO(e.find(e=>e.id===r),t.find(e=>e.id===r),n[r])}function yL(e,t,n=[],r=[],i={}){let a=vL(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=$O(e);return s===`google`?`Google`:s===`microsoft`?`Microsoft`:a(`google`)?`Google`:a(`microsoft`)?`Microsoft`:`Google`}function bL({content:e,providers:t=[],accounts:n,onRetry:r}){let i=R(),[a,o]=(0,V.useState)([]),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1),d=(0,V.useCallback)(()=>{S().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&&_L(e,a,t,s,n);if((0,V.useEffect)(()=>{d();let e=()=>d();return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[d]),aA(!f,d),!f||l)return null;let p=yL(e,a,t,s??[],n);return z(`div`,{className:`connector-retry-banner`,role:`status`,children:[I(ti,{size:14,className:`connector-retry-banner__icon`}),I(`span`,{className:`connector-retry-banner__text`,children:i(`retryBanner.connected`,{name:p})}),z(`button`,{type:`button`,className:`connector-retry-banner__btn`,onClick:()=>{u(!0),r()},children:[I(Po,{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:`×`})]})}function xL(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 SL(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 CL(e){return e.replace(/-/g,``).slice(0,7)}function wL(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 TL(e,t){return e.key===`ArrowUp`&&!e.shiftKey&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.nativeEvent?.isComposing&&t===``}function EL(e){for(let t=e.length-1;t>=0;t--)if(e[t].role===`user`)return e[t]}function DL(e,t){for(let n=t+1;n<e.length;n++)if(e[n].role===`user`)return e.length-n;return 0}var OL=/^\/[a-z0-9-]*$/i;function kL(e){let t=OL.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`),Ut().then(t=>{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 AL=`composer-skill-menu`;function jL(e){return`${AL}-${e}`}function ML(e){let t=e.replace(/\s+/g,` `).trim(),n=t.indexOf(`. `);return n>=0?t.slice(0,n+1):t}function NL({menu:e,onPick:t}){let n=R();return e.open?e.status===`ready`?z(`div`,{className:`skill-menu`,children:[I(`p`,{className:`skill-menu-title`,children:n(`composer.skillsTitle`)}),I(`ul`,{id:AL,role:`listbox`,"aria-label":n(`composer.skillsTitle`),children:e.matches.map((n,r)=>z(`li`,{id:jL(r),role:`option`,"aria-selected":r===e.selected,className:`skill-menu-row${r===e.selected?` is-selected`:``}`,onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>e.select(r),onClick:()=>t(n.name),children:[z(`span`,{className:`skill-menu-name`,dir:`ltr`,children:[`/`,n.name]}),I(`span`,{className:`skill-menu-desc`,dir:`auto`,children:ML(n.description)})]},n.name))})]}):I(`div`,{className:`skill-menu`,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`)})}):null}function PL(e){return e.isMedia?eL(e.name)?qi:Vi:Yi}var FL=240,IL=1e5;function LL({value:e,onChange:t,onSubmit:n,onStop:r,streaming:i=!1,stopping:a=!1,queueWhileStreaming:o=!1,answering:s=!1,disabledReason:c,attachments:l,placeholder:u,autoFocus:d,inputRef:f,leftControls:p,rightControls:m,onEditLast:h}){let g=R(),_=(0,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>IL,w=MN(i),T=l.attachments.filter(e=>e.error).map(e=>e.name).join(`, `),E=!b&&(!i||o)&&!l.uploading&&x&&!C&&!T&&!w,D=c||u||g(`composer.placeholder`),O=kL(b?``:e),k=(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,FL)}px`};if(t(),typeof ResizeObserver>`u`)return;let n=e.clientWidth,r=new ResizeObserver(()=>{e.clientWidth!==n&&(n=e.clientWidth,t())});return r.observe(e),()=>r.disconnect()},[e,D,v]);let ee=(0,V.useCallback)(t=>{if(O.open&&!t.nativeEvent.isComposing){let{matches:n,selected:r}=O;if(t.key===`Escape`){t.preventDefault(),O.dismiss();return}if(n.length>0&&(t.key===`ArrowDown`||t.key===`ArrowUp`)){t.preventDefault();let e=t.key===`ArrowDown`?1:-1;O.select((r+e+n.length)%n.length);return}let i=n[r]?.name,a=i!==void 0&&e.toLowerCase()===`/${i}`;if(i&&(t.key===`Tab`||t.key===`Enter`&&!t.shiftKey&&!a)){t.preventDefault(),k(i);return}}h&&TL(t,e)?(t.preventDefault(),h()):t.key===`Enter`&&!t.shiftKey&&!t.nativeEvent.isComposing&&(t.preventDefault(),E&&n())},[E,n,h,e,O,k]),te=(0,V.useCallback)(e=>{e.dataTransfer?.files?.length&&(e.preventDefault(),e.stopPropagation(),l.addFiles(Array.from(e.dataTransfer.files)))},[l]);return z(`div`,{className:`composer${b?` composer-disabled`:``}`,onDrop:te,onDragOver:e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault()},children:[I(jN,{}),l.attachments.length>0&&I(`ul`,{className:`composer-attachments`,"aria-label":g(`composer.attached`),children:l.attachments.map(e=>{let t=PL(e);return z(`li`,{title:e.isImage&&e.url?e.name:void 0,className:`composer-attachment${e.error?` has-error`:``}${e.isMedia?` is-media`:``}${e.isImage&&e.url?` is-image`:``}`,children:[e.isImage&&e.url?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:xL(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(Is,{size:12})})]},e.id)})}),I(NL,{menu:O,onPick:k}),I(`textarea`,{ref:v,className:`composer-input`,value:e,onChange:e=>t(e.target.value),onKeyDown:ee,onPaste:e=>{l.handlePaste(e)},placeholder:D,rows:1,disabled:b,autoFocus:d,"aria-label":g(`composer.message`),"aria-autocomplete":`list`,"aria-expanded":O.open&&O.matches.length>0,"aria-controls":O.open&&O.matches.length>0?AL:void 0,"aria-activedescendant":O.open&&O.matches.length>0?jL(O.selected):void 0,dir:`auto`}),C&&z(`p`,{className:`composer-limit-error`,role:`alert`,children:[g(`composer.tooLong`,{sent:S.toLocaleString(),max:1e5.toLocaleString()}),` `,g(`composer.tooLongHint`)]}),T&&x&&I(`p`,{className:`composer-limit-error`,role:`alert`,children:g(`composer.removeRefused`,{names:T})}),z(`div`,{className:`composer-row`,children:[z(`div`,{className:`composer-row-left`,children:[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(Oo,{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]}),z(`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(yr,{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(vs,{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(yr,{size:16})})]})]})]})}var RL=8,zL=8;function BL({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+RL+t.width<=r-zL?(a=n.right+RL,o=e.top+e.height/2-t.height/2):n.left-RL-t.width>=zL?(a=n.left-RL-t.width,o=e.top+e.height/2-t.height/2):(a=Math.min(Math.max(zL,e.right-t.width),r-zL-t.width),o=e.top-RL-t.height>=zL?e.top-RL-t.height:e.bottom+RL),o=Math.min(Math.max(zL,o),i-zL-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]),z(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(ya,{size:13,"aria-hidden":`true`})}),p&&(0,Mj.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 VL(e){return e<.1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function HL(e,t=gt){return e?t(`settings.price.perMillion`,{input:VL(e.input_per_million),output:VL(e.output_per_million)}):t(`settings.price.unknown`)}function UL(e){return`$${e.toFixed(2)}`}function WL(e,t,n,r=!1){return!ae(t)||gt(t)!==n?n:r?e.bare(t):e(t)}function GL(e,t){return WL(e,`providers.${t.id}.name`,t.name,!0)}function KL(e,t){return WL(e,`providers.${t.id}.notice`,t.privacy_notice)}var qL=2e3,JL=`waiting_for_os_permission`,YL=`store_locked`,XL=5;function ZL(e,t){let n=e.rank?`#${e.rank} ${e.note??``}`.trim():null;return t?[n,HL(e.price)].filter(e=>!!e):[Mc(e.placement),e.size_gb?`${e.size_gb} GB`:null,e.tokens_per_second?`${Math.round(e.tokens_per_second)} tok/s on this PC`:null,n,e.custom?`added by you`:null].filter(e=>!!e)}function QL(e,t){return!bc(t,e.id)&&(Fc(e)||Pc(e)===`not_downloaded`)}function $L(e,t,n){let r=e=>e.provider.id===t?0:1;return[...e].sort((e,t)=>r(e)-r(t)).map(e=>e.provider.remote?e:{...e,models:[...e.models].sort((e,t)=>Number(QL(e,n))-Number(QL(t,n)))})}function eR({m:e,onDownload:t,busy:n}){let r=R();if(Fc(e)){let t=Math.round(e.download_progress?.percent??0);return z(`span`,{className:`model-state is-downloading`,title:`Downloading, ${t}%`,children:[I(La,{size:12,className:`spin`,"aria-hidden":`true`}),` `,t,`%`]})}let i=Pc(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?`${jc.not_downloaded} (${e.size_gb} GB)`:jc.not_downloaded,tabIndex:-1,children:I(Ci,{size:13,"aria-hidden":`true`})}):i===`loaded`?I(`span`,{className:`model-state is-loaded`,role:`img`,"aria-label":jc.loaded,title:jc.loaded}):I(`span`,{className:`model-state is-ready`,title:jc.downloaded,children:r(`modelMenu.ready`)})}function tR(){let e=R(),t=_c(e=>e.active),n=_c(e=>e.select),r=_c(e=>e.queued),i=r??t?.model,a=_c(e=>e.queue),o=_c(e=>e.queueError),s=_c(e=>e.rememberNames);_c(e=>e.names);let c=Tc(),l=B(e=>Ec(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),[D,O]=(0,V.useState)(null),[k,ee]=(0,V.useState)(null),[te,ne]=(0,V.useState)(null),[A,re]=(0,V.useState)(0),[ie,ae]=(0,V.useState)(null),j=(0,V.useRef)(0),oe=(0,V.useRef)(null),se=(0,V.useId)(),ce=(0,V.useRef)(null),le=(0,V.useRef)(null),[ue,de]=(0,V.useState)(null),[fe,pe]=(0,V.useState)(null),me=(0,V.useCallback)(()=>pe(null),[]),he=(0,V.useCallback)(()=>m(!1),[]),M=(0,V.useRef)(!1),N=(0,V.useRef)(null),ge=(0,V.useCallback)(async(t=!1)=>{t||(M.current=!1,S(null),g(null));try{let{providers:n,lemonade_error:r}=await cn();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 Nn(t.id);return{provider:t,models:n.models,error:n.blocked?e(`settings.privacy.localOnlyBlocked`):void 0}}catch(e){return{provider:t,models:[],error:CM(e)}}}));s(a.flatMap(e=>e.models)),b(a.flatMap(e=>e.models).filter(e=>e.available===!1).length),t||(M.current=!0),g(a.map(e=>({...e,models:e.models.filter(e=>e.available!==!1)})))}catch(e){S(CM(e))}},[s,e]),_e=(0,V.useCallback)(async()=>{try{await Jn()}catch(e){S(CM(e));return}await ge(!0)},[ge]);(0,V.useEffect)(()=>{p&&(w(null),E(null),v(!1),de(null),pe(null),ge())},[p,ge]),(0,V.useEffect)(()=>{if(!p||!h||!M.current)return;let e=ce.current?.querySelector(`[role="option"][tabindex="0"]`);e&&(M.current=!1,e.focus(),e.scrollIntoView?.({block:`nearest`}))},[p,h]),(0,V.useEffect)(()=>{let e=N.current;if(!p||!h||!e||!_)return;let t=h.find(t=>t.provider.id===e)?.models.find(e=>e.rank===null&&!bc(i,e.id));if(!t)return;let n=Array.from(ce.current?.querySelectorAll(`[role="option"]`)??[]).find(e=>e.dataset.row===t.id);n&&(N.current=null,de(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(),pe(t=>e.key===`i`&&t===r?null:r);return}case`ArrowLeft`:e.preventDefault(),pe(null);return;default:return}e.preventDefault(),t[r].focus(),t[r].scrollIntoView?.({block:`nearest`})},ye=!!h?.some(e=>e.models.some(Fc)),be=!!h?.some(e=>e.provider.key_state===JL);(0,V.useEffect)(()=>{if(!(p||te)||!(ye||te||be))return;let e=setInterval(()=>{ge(!0)},qL);return()=>clearInterval(e)},[p,ye,te,be,ge]);let xe=(0,V.useCallback)(async e=>{ee(e),re(e=>e+1),S(null);try{await Ve(e),await ge(!0)}catch(t){ne(t=>t?.model===e?null:t),S(CM(t))}finally{ee(null),re(e=>e-1)}},[ge]),Se=(0,V.useCallback)((e,t,n)=>{E(null),n&&(j.current=0,ae(null),ne({model:e,provider:t})),xe(e)},[xe]),Ce=(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;O(e),S(null);try{return await n(e),ae(null),m(!1),null}catch(e){let t=CM(e);return S(t),t}finally{O(null)}},[t?.model,t?.remote,C,a,n,u]);(0,V.useEffect)(()=>{if(!te||!h||A>0)return;let{model:e,provider:t}=te,n=()=>(oe.current!==h&&(oe.current=h,j.current+=1),j.current>=XL),r=h.flatMap(e=>e.models).find(t=>t.id===e);if(!r){if(!n())return;ne(null),ae(`${xc(e)} is no longer in the model list, so it wasn't switched to.`);return}if(Fc(r)){j.current=0;return}let i=r.download_progress;if(i?.state===`error`)ne(null),ae(`Downloading ${xc(e)} failed: ${i.message??`no reason given`}`);else if(i?.state!==`complete`&&Pc(r)===`not_downloaded`){if(!n())return;ne(null),ae(`The download of ${xc(e)} never started. Try the download button again.`)}else ne(null),Ce(e,t).then(t=>{t&&ae(`${xc(e)} downloaded, but switching to it failed: ${t}`)})},[h,te,A,Ce]);let we=(e,t)=>e.id===`fireworks`&&!_&&t.some(e=>e.rank!==null),Te=(e,t)=>we(e,t)?t.filter(e=>e.rank!==null||bc(i,e.id)):t,Ee=(e,t)=>we(e,t)&&t.some(e=>e.rank===null&&!bc(i,e.id)),De=h?.flatMap(({provider:e,models:t})=>[...e.remote&&!e.models_discovered?[`key:${e.id}`]:[],...Te(e,t).filter(e=>D===null&&!Fc(e)).map(e=>e.id),...Ee(e,t)?[`showall:${e.id}`]:[]])??[],Oe=ue&&De.includes(ue)?ue:i&&De.includes(i)?i:De[0],ke=e=>({role:`option`,tabIndex:e===Oe?0:-1,"data-row":e,onFocus:()=>de(e),onBlur:()=>pe(null)}),Ae=c?.remote?pi:c?yi:ai,je=l?xc(l):`Model`,Me=`${je}${c?` · ${c.label}`:``}`,Ne=Object.fromEntries((h??[]).map(e=>[e.provider.id,kc(e.models)])),Pe=h&&$L(h,t?.provider,i),Fe=t?.downloaded===!1&&l===t.model,Ie=ie||o||(r?`${xc(r)} is used from your next message.`:t?.config_error?t.config_error:Fe?`${je} isn't downloaded yet. Open the list to download it.`:c?c.description?.replace(/`/g,``)??(c.remote?e(`modelStatus.runsRemote`,{name:c.label}):e(`modelStatus.runsHere`)):wc);return z(`div`,{className:`composer-chip-wrap`,children:[z(`button`,{ref:f,type:`button`,className:`composer-chip${Fe||o||ie?` is-warning`:``}`,onClick:()=>m(e=>!e),"aria-haspopup":`dialog`,"aria-expanded":p,title:Ie,children:[I(Ae,{size:13,"aria-hidden":`true`}),I(`span`,{className:`composer-chip-label`,dir:`auto`,children:Me}),r&&z(`span`,{className:`composer-chip-next`,children:[`→ `,xc(r),` next`]}),Fe&&I(Ci,{size:12,"aria-label":`Not downloaded`}),ie&&I(ri,{size:12,"aria-label":`Model switch failed`}),I(Gr,{size:12,"aria-hidden":`true`})]}),z(Gs,{open:p,onClose:he,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:xc(l)}):e(`modelMenu.keepsItsModel`)}),ie&&I(`div`,{className:`popover-message is-error`,role:`alert`,children:ie}),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&&z(`div`,{className:`popover-message`,children:[I(La,{size:13,className:`spin`}),` `,e(`modelMenu.loading`)]}),h&&I(`div`,{ref:ce,role:`listbox`,"aria-label":e(`modelMenu.models`),onKeyDown:ve,children:Pe.map(({provider:n,models:a,error:o})=>z(`div`,{role:`group`,"aria-labelledby":`${se}-${n.id}`,children:[I(`div`,{className:`popover-heading`,id:`${se}-${n.id}`,children:GL(e,n)}),o&&I(`div`,{className:`popover-message is-error`,children:o}),n.key_state===JL?z(`div`,{className:`popover-message`,role:`status`,children:[I(La,{size:13,className:`spin`,"aria-hidden":`true`}),` `,n.key_message]}):n.key_state===YL?z(`button`,{type:`button`,className:`popover-item`,...ke(`unlock:${n.id}`),"aria-selected":!1,onClick:()=>void _e(),children:[I(`span`,{className:`popover-item-check`,children:I(xa,{size:13,"aria-hidden":`true`})}),z(`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&&z(`button`,{type:`button`,className:`popover-item`,...ke(`key:${n.id}`),"aria-selected":!1,onClick:()=>{m(!1),d(`model`,n.id)},children:[I(`span`,{className:`popover-item-check`,children:I(xa,{size:13,"aria-hidden":`true`})}),z(`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`)}),Te(n,a).map((a,o,s)=>{let c=!n.remote&&QL(a,i)&&o===s.findIndex(e=>QL(e,i)),l=bc(r??t?.model,a.id),u=!n.remote&&Pc(a)===`not_downloaded`,d=Ne[n.id][a.id],f=ZL(a,n.remote),p=`${se}-info-${n.id}-${a.id}`;return z(V.Fragment,{children:[c&&I(`div`,{className:`popover-subheading`,children:e(`modelMenu.availableToDownload`)}),z(`div`,{className:`popover-row`,children:[z(`button`,{type:`button`,className:`popover-item`,onClick:()=>{u?(w(null),E({model:a.id,provider:n,pick:!0})):(ne(null),E(null),Ce(a.id,n))},disabled:D!==null||Fc(a),...ke(a.id),"aria-selected":l,"aria-describedby":fe===a.id?p:void 0,children:[I(`span`,{className:`popover-item-check`,"aria-hidden":`true`,children:D===a.id?I(La,{size:13,className:`spin`}):l?I(Vr,{size:13}):null}),z(`span`,{className:`popover-item-body is-inline`,children:[I(`span`,{className:`popover-item-title is-model`,children:d}),!n.remote&&a.size_gb?I(`span`,{className:`popover-item-meta`,children:z(`bdi`,{dir:`ltr`,children:[a.size_gb,` GB`]})}):null]})]}),z(BL,{label:`About ${d}`,warning:!!a.placement?.warning,id:p,pinned:fe===a.id,onUnpin:me,tabIndex:-1,children:[I(`div`,{className:`info-bubble-title`,children:d}),f.length>0&&I(`ul`,{className:`info-bubble-lines`,children:f.map(e=>I(`li`,{children:e},e))}),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`,children:a.id})]}),I(`span`,{className:`popover-row-state`,children:!n.remote&&I(eR,{m:a,busy:k!==null,onDownload:()=>{w(null),E({model:a.id,provider:n,pick:!1})}})})]}),T?.model===a.id&&T.provider.id===n.id&&z(`div`,{ref:le,className:`popover-message model-download-confirm`,role:`alert`,children:[z(`span`,{children:[I(zc,{text:a.size_gb?e(`modelMenu.downloadConfirm`,{name:Ic(d),size:Ic(`${a.size_gb} GB`)}):e(`modelMenu.downloadConfirmNoSize`,{name:Ic(d)})}),T.pick&&` ${e(`modelMenu.switchWhenDone`)}`]}),z(`span`,{className:`model-download-confirm-actions`,children:[I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>Se(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&&z(`div`,{ref:le,className:`popover-message`,role:`alert`,children:[KL(e,C.provider),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>Ce(C.model,C.provider),children:e(`modelMenu.useModel`,{name:xc(C.model)})})]})]},a.id)}),Ee(n,a)&&z(`button`,{type:`button`,className:`popover-item`,...ke(`showall:${n.id}`),"aria-selected":!1,onClick:()=>{N.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&&z(`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`}),z(`button`,{type:`button`,className:`popover-item`,onClick:()=>{m(!1),d(`model`)},children:[I(`span`,{className:`popover-item-check`,children:I(Na,{size:13,"aria-hidden":`true`})}),z(`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`)})]})]}),z(`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 nR(e,t,n){if(e==null||!t(e))throw Error(`the server sent no ${n}`);return e}var rR=e=>e.startsWith(`.`);function iR({onPick:e,onClose:t}){let n=R(),[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);pt(!0,t);let p=(0,V.useRef)(null);on(p,!0);let m=(0,V.useCallback)(e=>{u(!0),c(null),Promise.resolve().then(()=>Rn(e)).then(e=>{let t=nR(e,e=>Array.isArray(e.entries),`folder listing`);i(t),o(t.current_path)}).catch(e=>c(e instanceof Nt?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=>!rR(e.name));return I(`div`,{className:`modal-overlay`,onClick:t,children:z(`div`,{ref:p,className:`modal-panel sp-picker`,role:`dialog`,"aria-modal":`true`,"aria-label":n(`pick.label`),onClick:e=>e.stopPropagation(),children:[z(`div`,{className:`modal-header`,children:[I(`h3`,{children:n(`pick.title`)}),I(`button`,{type:`button`,className:`btn-icon`,onClick:t,"aria-label":n(`sp.closeShort`),children:I(Is,{size:18})})]}),z(`div`,{className:`modal-body sp-picker-body`,children:[I(`p`,{className:`sp-meta`,children:n(`pick.note`)}),z(`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&&z(`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)),z(`label`,{className:`sp-picker-hidden`,children:[I(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked)}),n(`pick.showHidden`)]})]}),z(`ul`,{className:`sp-picker-list`,"aria-busy":l,children:[r?.parent_path&&I(`li`,{children:z(`button`,{type:`button`,onClick:()=>m(r.parent_path??void 0),children:[I(yr,{size:13,"aria-hidden":`true`}),` `,n(`pick.up`)]})}),g.map(e=>I(`li`,{children:z(`button`,{type:`button`,onClick:()=>m(e.path),children:[I(aa,{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&&z(`li`,{className:`sp-meta`,children:[I(La,{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})]}),z(`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 aR=e=>e instanceof Nt?e.detail||e.message:e instanceof Error?e.message:String(e);function oR(e){let t=R(),[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 d(n))}catch(e){a(t(`pick.checkFailed`,{error:aR(e)}));return}r?a(r):e(n)},e=>a(t(`pick.openFailed`,{error:aR(e)}))):r(!0)},picker:n?I(iR,{onPick:t=>{r(!1),e(t)},onClose:()=>r(!1)}):null,error:i}}var sR=new Map;function cR(e){let t=sR.get(e);return t||(t={env:null,error:null,inFlight:null,version:0,listeners:new Set},sR.set(e,t)),t}function lR(e,t,n){let r=cR(e);r.env=t??r.env,r.error=n,r.listeners.forEach(e=>e())}function uR(e){let t=cR(e);if(t.inFlight)return t.inFlight;let n=t.version;return t.inFlight=Promise.resolve().then(()=>$e(e)).then(r=>{let i=nR(r,e=>Array.isArray(e.folders),`chat's environment`);t.version===n&&lR(e,i,null)}).catch(t=>lR(e,null,t instanceof Error?t.message:String(t))).finally(()=>{t.inFlight=null}),t.inFlight}function dR(e){let[,t]=(0,V.useState)(0);(0,V.useEffect)(()=>{let n=cR(e),r=()=>t(e=>e+1);return n.listeners.add(r),!n.env&&!n.inFlight&&uR(e),()=>{n.listeners.delete(r)}},[e]);let n=(0,V.useCallback)(()=>uR(e),[e]),r=(0,V.useCallback)(async t=>{let n=await t();return cR(e).version+=1,lR(e,n,null),n},[e]),i=cR(e);return{env:i.env,error:i.error,refresh:n,change:r}}var fR=e=>e.split(/[\\/]/).filter(Boolean).pop()??e;function pR({folder:e,disabled:t}){let n=R(),r=B(e=>e.draftFolder),i=B(e=>e.setDraftFolder),{open:a,picker:o,error:s}=oR(i),c=e.gaia_folder?n(`folderChip.worksInOwn`,{path:e.path}):n(`folderChip.worksIn`,{path:e.path}),l=!e.gaia_folder&&z(`span`,{className:`new-chat-folder`,title:c,children:[I(aa,{size:13,"aria-hidden":`true`}),I(`span`,{className:`new-chat-folder-name`,dir:`auto`,children:e.name})]});return e.choosable?z(P.Fragment,{children:[l,r?z(`span`,{className:`new-chat-folder is-on`,title:n(`folderChip.picked`,{path:r}),children:[I(aa,{size:13,"aria-hidden":`true`}),I(`span`,{className:`new-chat-folder-name`,dir:`auto`,children:fR(r)}),I(`button`,{type:`button`,className:`new-chat-folder-clear`,onClick:()=>i(null),disabled:t,"aria-label":n(`folderChip.remove`,{name:fR(r)}),title:n(`folderChip.remove`,{name:fR(r)}),children:I(Is,{size:12,"aria-hidden":`true`})})]}):z(`button`,{type:`button`,className:`new-chat-folder is-button`,onClick:()=>a(e.path),disabled:t,"aria-haspopup":`dialog`,title:`${c} ${n(`folderChip.addHint`)}`,children:[I(Oo,{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||z(`span`,{className:`new-chat-folder`,title:`${c} ${n(`folderChip.ownFixedHint`)}`,children:[I(aa,{size:13,"aria-hidden":`true`}),I(`span`,{className:`new-chat-folder-name`,children:n(`folderChip.gaiaFolder`)})]})}function mR({sessionId:e,onOpen:t}){let{env:n}=dR(e),r=n?.folders.find(e=>e.source===`working_folder`);if(!r)return null;let i=fR(r.path);return z(`button`,{type:`button`,className:`composer-chip folder-chip`,title:`GAIA works in ${r.path}`,"aria-label":`Working folder ${i}, show the chat's folders`,onClick:t,children:[I(aa,{size:13,"aria-hidden":`true`}),I(`span`,{className:`composer-chip-label`,dir:`auto`,children:i})]})}var hR=`gaia:permission-mode`;function gR(e,t){window.dispatchEvent(new CustomEvent(hR,{detail:{sessionId:e,mode:t}}))}function _R(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(hR,t),()=>window.removeEventListener(hR,t)},[e])}var vR=[{mode:`ask`,label:`perm.ask`,note:`perm.askNote`},{mode:`full_access`,label:`perm.full`,note:`perm.fullNote`}];function yR({sessionId:e,disabled:t}){let n=R(),r=B(e=>e.draftPermissionMode),i=B(e=>e.setDraftPermissionMode),[a,o]=(0,V.useState)(e?`ask`:r),[s,c]=(0,V.useState)(!1),[l,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)(null),m=(0,V.useRef)(null),h=_l(t=>e!==null&&xl(e)(t)!==null);(0,V.useEffect)(()=>{if(!e){o(r);return}let t=!1;return Wt(e).then(e=>{t||o(e.mode)}).catch(e=>{t||p(CM(e))}),()=>{t=!0}},[e,r]),_R(e,o);let g=(0,V.useCallback)(async t=>{if(t===`full_access`&&!l)d(!0);else{p(null);try{if(e){let n=(await kt(e,t)).mode;o(n),gR(e,n),n===`full_access`&&h||c(!1)}else i(t),o(t),c(!1)}catch(t){p(CM(t)),e&&Wt(e).then(e=>o(e.mode)).catch(e=>p(t=>`${t??``} Couldn't re-read the saved mode: ${CM(e)}`.trim()))}finally{d(!1)}}},[l,h,e,i]),_=a===`full_access`,v=_?ns:es;return z(`div`,{className:`composer-chip-wrap`,children:[z(`button`,{ref:m,type:`button`,className:`composer-chip${_?` is-warning`:``}`,onClick:()=>{d(!1),c(e=>!e)},disabled:t,"aria-haspopup":`dialog`,"aria-expanded":s,"aria-label":n(`perm.chipAria`,{mode:u(_?`perm.fullLower`:`perm.askLower`)}),children:[I(v,{size:13,"aria-hidden":`true`}),I(`span`,{className:`composer-chip-label`,dir:`auto`,children:n(_?`perm.full`:`env.ask`)}),I(Gr,{size:12,"aria-hidden":`true`})]}),z(Gs,{open:s,onClose:()=>c(!1),anchor:m,label:n(`env.permission`),children:[vR.map(e=>z(`button`,{type:`button`,className:`popover-item`,onClick:()=>g(e.mode),"aria-pressed":a===e.mode,children:[I(`span`,{className:`popover-item-check`,"aria-hidden":`true`,children:a===e.mode&&I(Vr,{size:13})}),z(`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&&z(`div`,{className:`popover-message`,role:`alert`,children:[n(`env.fullAccessWarn`),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>g(`full_access`),children:n(`env.turnOn`)})]}),_&&h&&!l&&I(`div`,{className:`popover-message`,role:`status`,children:n(`perm.fullPendingNote`)}),f&&I(`div`,{className:`popover-message is-error`,role:`alert`,children:f})]})]})}var bR={sending:`Adding to the running reply…`,delivered:`Added to the running reply. GAIA reads it at its next step.`,queued:`Queued. Sends when this reply ends.`};function xR(e,t){return e?bR.queued:t?`GAIA is still busy in this chat. Trying again in a few seconds.`:`Sending next.`}function SR({items:e,onRemove:t,onSteer:n,onRetry:r,replying:i=!0,busyRetry:a=!1}){let o=e.filter(e=>e.state!==`starting`);return o.length===0?null:I(`ul`,{className:`queued-messages`,"aria-label":`Messages waiting to send`,"aria-live":`polite`,children:o.map(e=>z(`li`,{className:`queued-message is-${e.state}`,children:[e.state===`failed`?I(ri,{size:12,"aria-hidden":`true`}):e.state===`queued`?I(di,{size:12,"aria-hidden":`true`}):I(_i,{size:12,"aria-hidden":`true`}),I(`span`,{className:`queued-message-text`,title:e.text,children:e.text}),I(`span`,{className:`queued-message-state`,title:e.error,children:e.state===`failed`?`Not sent. ${e.error??``}`.trim():e.state===`queued`?i&&e.note||xR(i,a):bR[e.state]}),e.state===`failed`&&z(`button`,{type:`button`,className:`queued-message-steer`,onClick:()=>r(e.id),"aria-label":`Send again: ${e.text}`,children:[I(Bo,{size:11,"aria-hidden":`true`}),` Send again`]}),e.state===`queued`&&n&&I(`button`,{type:`button`,className:`queued-message-steer`,onClick:()=>n(e.id),title:`GAIA reads it at its next step, without starting over. It may not answer it separately.`,children:`Add to this reply`}),(e.state===`queued`||e.state===`failed`)&&I(`button`,{type:`button`,className:`queued-message-remove`,onClick:()=>t(e.id),"aria-label":`Remove queued message: ${e.text}`,title:`Remove`,children:I(Is,{size:12})})]},e.id))})}var CR=e=>e.toLocaleString(`en-US`);function wR({n:e}){let t=R();if(e==null)return I(`span`,{className:`cp-unknown`,children:t(`ctx.unknown`)});let n=e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(+(e<1e4))}K`:`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`;return I(`span`,{title:t(`ctx.tokens`,{n:CR(e)}),dir:`ltr`,children:n})}function TR({s:e}){let t=R();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 ER({r:e}){let t=R();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 DR=(e,t)=>t>0?Math.round(e/t*100):0,OR=(e,t)=>{let n=DR(e,t);return n===0&&e>0?`<1`:String(n)},kR=(e,t)=>t&&e!=null?Math.floor(e/t*100):null,AR=256;function jR(e,t=gt){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:Ac(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 MR({label:e,children:t,hint:n}){return z(`div`,{className:`cp-row`,title:n,children:[I(`dt`,{children:e}),I(`dd`,{children:t})]})}function NR({t:e}){let t=R();if(e.model_seconds==null||e.gaia_seconds==null)return z(MR,{label:t(`ctx.took`),children:[I(TR,{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 z(P.Fragment,{children:[I(MR,{label:t(`ctx.took`),hint:t(`ctx.tookHint`),children:I(TR,{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:`${DR(t.s,e.wall_seconds)}%`}},t.key))}),z(`dl`,{className:`cp-rows cp-indent`,children:[I(MR,{label:t(`ctx.inModel`),children:I(TR,{s:e.model_seconds})}),I(MR,{label:t(`ctx.inGaia`),hint:t(`ctx.inGaiaHint`),children:I(TR,{s:e.gaia_seconds})}),n.slice(1).filter(e=>e.s>0).map(e=>z(MR,{label:`· ${e.label}`,children:[I(`span`,{className:`swatch cp-time-${e.key}`,"aria-hidden":`true`}),` `,I(TR,{s:e.s})]},e.key))]})]})}function PR({why:e}){let t=R();return I(`span`,{className:`cp-unknown`,title:e,children:t(`ctx.unknown`)})}var FR={server:`ctx.src.server`,client:`ctx.src.client`};function IR(e,t){return e?t(FR[e]):void 0}function LR({turn:e}){let t=R(),n=kR(e.tokens_cached,e.tokens_in),r=e.unknown??{},i=e.tools.map(e=>`${e.name??t(`ctx.toolOutside`)}: ${e.seconds??`?`} s`).join(`
|
|
189
189
|
`);return z(P.Fragment,{children:[I(NR,{t:e.time}),z(`dl`,{className:`cp-rows`,children:[I(MR,{label:t(`ctx.firstWord`),hint:IR(e.first_token_source,t),children:e.first_token_seconds==null?I(PR,{why:r.first_token_seconds}):z(P.Fragment,{children:[t.bare(`ctx.in`),` `,I(TR,{s:e.first_token_seconds})]})}),I(MR,{label:t(`ctx.readingPrompt`),hint:t(`ctx.readingHint`),children:e.tokens_new!=null&&e.tokens_new<AR?I(`span`,{title:t(`ctx.tooFewTitle`),children:t(`ctx.onlyNew`,{n:e.tokens_new})}):e.prefill_tokens_per_second==null?I(PR,{why:r.prefill_tokens_per_second}):z(P.Fragment,{children:[I(ER,{r:e.prefill_tokens_per_second}),e.prefill_source===`client`&&I(`span`,{className:`cp-chip`,title:t(`ctx.approxTitle`),children:t(`ctx.approx`)})]})}),I(MR,{label:t(`ctx.writing`),hint:IR(e.generation_source,t)??t(`ctx.writingHint`),children:e.generation_tokens_per_second==null?I(PR,{why:r.generation_tokens_per_second}):I(ER,{r:e.generation_tokens_per_second})}),I(MR,{label:t(`ctx.tokensInOut`),hint:r.tokens,children:z(`span`,{dir:`ltr`,children:[I(wR,{n:e.tokens_in}),` → `,I(wR,{n:e.tokens_out})]})}),I(MR,{label:t(`ctx.cache`),hint:t(`ctx.cacheHint`),children:e.tokens_cached==null?I(PR,{why:r.tokens_cached}):z(P.Fragment,{children:[I(wR,{n:e.tokens_cached}),n!=null&&` (${n}%)`]})}),I(MR,{label:t(`ctx.modelCalls`),children:e.model_calls}),I(MR,{label:t(`ctx.toolCalls`),hint:i||void 0,children:e.tool_calls===0&&!e.tool_seconds_total?t(`ctx.none`):z(P.Fragment,{children:[e.tool_calls,` · `,I(TR,{s:e.tool_seconds_total??0})]})}),I(MR,{label:t(`ctx.loads`),children:e.loads.length===0?t(`ctx.none`):z(`span`,{title:e.loads.map(e=>`${e.model}${e.replaced?.length?` replaced ${e.replaced.join(`, `)}`:``}: ${e.seconds} s`).join(`
|
|
@@ -200,21 +200,21 @@ Error generating stack: `+e.message+`
|
|
|
200
200
|
---
|
|
201
201
|
*Unexpected error?* [Report it on GitHub](${pL((t.message||``).slice(0,80))})`,d={id:Date.now()+2,session_id:e,role:`assistant`,content:u,created_at:new Date().toISOString(),rag_sources:null,failed:!fN(t),failureText:t.message||void 0};a(d),m(!1),_(),w(),D()}},ge=r?tn(e,N):h(e,ee,{...N,pageElements:ne});return se=ge,Je.current=ge,!0},[he,Te,f,e,me,Be,a,l,i,m,jt,_,d,y,x,S,C,w,E,D,re,kt]);ot.current=_n;let vn=B(t=>t.runningSessionIds.includes(e)),yn=B(e=>e.activeRunsAt>Ye.current);(0,V.useEffect)(()=>{DI()},[e]),(0,V.useEffect)(()=>{vn?!yn||f||Xe.current||(F.chat.info(`Resuming live view of background run for session=${e}`),ot.current(void 0,{attach:!0})):Xe.current=!1},[e,vn,yn,f]),(0,V.useEffect)(()=>{let e=e=>{let t=e.detail?.text;typeof t==`string`&&t.trim()&&ot.current(t)};return window.addEventListener(`gaia:send-message`,e),()=>window.removeEventListener(`gaia:send-message`,e)},[]),(0,V.useEffect)(()=>{!f&&qe.current&&qe.current.focus()},[f]);let bn=(0,V.useCallback)(async t=>{f||(F.chat.info(`Deleting message ${t} from session=${e}`),De(t),setTimeout(async()=>{l(t),De(null);try{await zt(e,t)}catch(n){F.chat.error(`Failed to delete message ${t}`,n),$n(e).then(e=>{kt()||i(VF(e.messages))}).catch(t=>F.chat.error(`Could not reload messages for session=${e}`,t))}},250))},[e,f,l,i,kt]),xn=(0,V.useRef)(!1),Sn=(0,V.useCallback)(async(n,r,a)=>{if(f||n.role!==`user`||xn.current)return!1;xn.current=!0;let o=a??n.content;F.chat.info(`Resending message ${n.id} from session=${e}`,{preview:o.slice(0,80)});let s=n=>re({id:`resend-failed-${e}-${Date.now()}`,type:`error`,agentId:e,agentName:`GAIA`,title:t(`chatError.resendFailed`),message:n,timestamp:Date.now(),read:!1,dismissed:!1,priority:`high`,sessionId:e});try{if(hI(B.getState().systemStatus)){let e=await te();if(B.getState().setSystemStatus(e),hI(e))return s(t(`chatError.resendStarting`)),!1}if(!Zs(`chat`)&&!await ec(`chat`))return!1;let a=await $n(e);if(kt())return!1;let c=VF(a.messages),l=HF(c,B.getState().messages,n);if(l&&r&&!WF(c,l,r))return F.chat.info(`Message ${n.id} was answered since it failed; not resending`),i(c),Mt.current=c.length,!1;if(l&&await ht(e,l.id),kt()){let{sessions:t,pendingDeleteIds:n}=B.getState();return t.some(t=>t.id===e)&&!n.includes(e)&<(e=>xt(e,o,`queued`)),!0}}catch(r){F.chat.error(`Could not resend message ${n.id} in session=${e}`,r);let i=r instanceof Error?bN(r):null;return s(i?.kind===`connection`||i?.kind===`timeout`?i.text:t(`chatError.resendStale`)),!1}finally{xn.current=!1}u(n.id);let c=!1;try{c=await ot.current(o)}catch(t){F.chat.error(`Could not resend message ${n.id} in session=${e}; queued it`,t)}return c||lt(e=>xt(e,o,`queued`)),!0},[e,f,u,i,lt,kt,re,t]);(0,V.useEffect)(()=>BI(e),[e]);let Cn=B(()=>zI(e)),wn=(0,V.useCallback)((e,t)=>new Promise(e=>{ot.current(t,{queued:!0,onQueuedOutcome:e})}),[]),Tn=f||Zt;(0,V.useEffect)(()=>{if(!Tn){if(dt.current){dt.current=!1;let e=ct.map(e=>e.text);e.length&&(lt(()=>[]),M(t=>[t.trim(),...e].filter(Boolean).join(`
|
|
202
202
|
|
|
203
|
-
`)))}else ct.length===0||vt||yt||ee||se||Lt.current||Be||It||kt()||!mt.current&&!Cn||qI(e,wn,()=>Ft.current&&!kt()&&!B.getState().isStreaming&&!Qt.current)}},[Tn,ct,vt,yt,Cn,ee,se,Be,It,e,wn,kt]);let En=(0,V.useRef)(!1);(0,V.useEffect)(()=>{En.current&&!Tn&&qt(),En.current=Tn},[Tn,qt]);let Dn=(0,V.useCallback)(t=>{let n=ct.find(e=>e.id===t&&e.state===`queued`);n&&f&&(lt(e=>b(e,t,`queued`,`sending`)),en(e,n.text).then(()=>lt(e=>b(e,t,`sending`,`delivered`))).catch(e=>{F.chat.info(`Follow-up not taken by the running reply; it stays queued: ${e instanceof Error?e.message:e}`),lt(e=>s(e,t))}))},[ct,f,e,lt]),On=(0,V.useCallback)(async()=>{let n=fe?B.getState().liveQuestions[fe]:void 0,r=he.trim();if(!fe||!n||!r||Te.hasUploaded){_n();return}let i=$k(r,n);if(!i)Le(t(`composer.pickAnOption`));else{Le(null),M(``);try{await Qk(e,fe,i.value,i.shown)}catch(e){M(r),e instanceof Xk||Le(t(`composer.answerFailed`,{error:SM(e)}))}}},[fe,he,Te,_n,M,e,t]),kn=(0,V.useCallback)(()=>{for(let e=r.length-1;e>=0;e--)if(r[e].role===`user`){Sn(r[e]);return}},[r,Sn]),An=(0,V.useCallback)(e=>{let t=r.indexOf(e);for(let n=t-1;n>=0;n--)if(r[n].role===`user`){Sn(r[n],e);return}},[r,Sn]),jn=(0,V.useCallback)(e=>{let t=r.indexOf(e);for(let e=t-1;e>=0;e--)if(r[e].role===`user`){Sn(r[e]);return}},[r,Sn]),[Nn,Pn]=(0,V.useState)(null),Fn=(0,V.useRef)(null),In=(0,V.useCallback)(e=>{Fn.current=null,Pn(e)},[]),Ln=(0,V.useCallback)(()=>{let e=EL(r);e&&In(e.id)},[r,In]),Rn=(0,V.useCallback)(()=>{Fn.current=null,Pn(null),qe.current?.focus()},[]),zn=(0,V.useCallback)(async(e,t)=>{Fn.current=t,await Sn(e,void 0,t)&&(Fn.current=null,Pn(t=>t===e.id?null:t))},[Sn]),Bn=(0,V.useCallback)(()=>{ot.current(t(`msg.continuePrompt`))},[t]),Vn=()=>{ye(me?.title||``),ge(!0)},Hn=async()=>{let n=ve.trim().slice(0,200).trim();if(n&&ve!==me?.title&&n!==me?.title){Le(null);try{await _e(e,{title:n,title_is_custom:!0}),d(e,{title:n})}catch(n){F.chat.error(`Could not rename chat ${e}`,n),Le(t(`chat.renameFailed`,{error:SM(n)}))}}ge(!1)},Un=(0,V.useCallback)(async()=>{if(e){Le(null);try{let t=await c(e);d(e,{private:t.private})}catch(e){F.ui.warn(`Failed to toggle private mode`,e),Le(t(`chat.privateFailed`,{error:SM(e)}))}}},[e,d,t]),Wn=(0,V.useCallback)(async n=>{if(n.preventDefault(),n.stopPropagation(),xe(!1),n.dataTransfer.files.length===0)return;let r=Array.from(n.dataTransfer.files),i=r.filter(e=>tL(e.name));i.length>0&&Te.addFiles(i);let a=r.filter(e=>!tL(e.name));if(a.length===0||!await ec(`embedding`))return;Le(null);let o=await xH(e,a);o.length>0&&Le(o.map(({name:e,stage:n,error:r})=>n===`unreadable`||n===`server`?t(n===`server`?`docsBar.serverTitle`:`docsBar.failedTitle`,{name:e}):t(n===`attach`?`chat.dropAttachFailed`:`chat.dropUploadFailed`,{name:e,error:SM(r)})).join(` `))},[e,Te,t]),Gn=e=>{e.dataTransfer?.types?.includes(`Files`)&&(e.preventDefault(),e.stopPropagation(),xe(!0))},Kn=e=>{e.preventDefault(),e.stopPropagation(),xe(!1)},qn=r.length>0?r[r.length-1]:void 0,Jn=(0,V.useMemo)(()=>cA(qn),[qn]),Yn=(0,V.useMemo)(()=>lA(qn),[qn]),Xn=!f&&!ee&&qn?.role===`assistant`&&(uA(qn)?Jn.length>0:QO(qn.content)),Zn=(0,V.useMemo)(()=>{let e=new Map,t;for(let n of r)if(n.role===`user`&&n.created_at)t=new Date(n.created_at).getTime();else if(n.role===`assistant`&&n.created_at&&t!==void 0){let r=new Date(n.created_at).getTime();r>t&&e.set(n.id,r-t),t=void 0}return e},[r]),Qn=Be?`This chat used the retired "${Be}" agent and is read-only. Start a new chat.`:hI(A)?iu:null;return z(`main`,{className:`task-view ${be?`drag-active`:``}`,style:{"--session-panel-w":`${an}px`},onDrop:Wn,onDragOver:Gn,onDragLeave:Kn,"aria-label":me?.title||`Chat`,children:[I(OF,{busy:Tn}),z(`header`,{className:`task-header`,children:[I(`div`,{className:`task-header-left`,children:N?I(`input`,{className:`title-edit`,value:ve,maxLength:200,onChange:e=>ye(e.target.value),onBlur:Hn,onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&Hn(),e.key===`Escape`&&(e.preventDefault(),ge(!1))},...Pt,autoFocus:!0,"aria-label":`Chat title`,dir:`auto`}):z(`button`,{type:`button`,className:`task-title`,onClick:Vn,title:t(`row.rename`),children:[I(`span`,{children:vH(me?.title)?t(`sidebar.newChat`):me?.title}),I(go,{size:12,"aria-hidden":`true`,className:`task-title-edit`})]})}),z(`div`,{className:`task-header-right`,children:[I(`button`,{ref:ln,className:`btn-icon-sm task-header-resources`,onClick:()=>cn(!sn),"aria-pressed":sn,"aria-label":t(`resources.toggle`),title:t(sn?`resources.hide`:`resources.show`),children:I(sr,{size:15,"aria-hidden":`true`})}),I(DV,{isPrivate:!!me?.private,onToggle:Un}),I(`button`,{className:`btn-icon-sm`,onClick:()=>k(!0),title:t(`chat.browseFiles`),"aria-label":t(`chat.browseFiles`),children:I(ra,{size:15})}),I(`button`,{className:`btn-icon-sm`,onClick:Ne,title:t(`chat.exportTitle`),"aria-label":t(`chat.exportLabel`),children:I(Ci,{size:15})}),I(EV,{messages:r,busy:f})]})]}),sn&&I(YV,{onClose:fn}),!sn&&un&&z(`div`,{className:`resource-strip resource-hidden-note`,role:`status`,children:[I(`span`,{children:t(`resources.hiddenNote`)}),I(`button`,{type:`button`,className:`resource-hidden-undo`,onClick:()=>cn(!0),children:t(`resources.show`)})]}),I(kV,{sessionId:e,onDetachFailed:ze}),I(`div`,{className:`messages-scroll`,ref:Ke,...Ot,children:z(`div`,{className:`messages-column`,children:[ee&&!Rt&&I(`div`,{className:`skeleton-messages`,"aria-label":t(`chat.loadingMessages`),children:[0,1,2].map(e=>I(`div`,{className:`skeleton-msg`,children:z(`div`,{className:`skeleton-lines`,children:[I(`div`,{className:`skeleton-line`}),I(`div`,{className:`skeleton-line`}),e!==2&&I(`div`,{className:`skeleton-line`})]})},e))}),Bt.map((e,t)=>{let n=e.role===`assistant`?e.historyNotice??zH.get(e.id):void 0,i=e.role===`assistant`&&QP(e.content,e.stopState)===`interrupted`,a=e.role===`assistant`&&e.stopState===`stopped`&&!e.stopError,o=(e.failed===!0||i||a)&&!Tn&&!Be&&t===r.length-1,s=!o&&!Tn&&!Yt&&!Be&&e.role===`assistant`&&t===r.length-1&&!e.stopState&&!e.failed&&!AP(e.content),c=e.stats?.seconds==null?Zn.get(e.id):e.stats.seconds*1e3,l=Vt(e);return z(`div`,{className:Ee===e.id?`msg-deleting`:We.current.has(Ue.current.get(e.id)??e.id)?`msg-settled`:void 0,"data-message-id":e.id,"data-role":e.role,children:[n&&I(BH,{text:n}),e.libraryNotices&&e.libraryNotices.length>0&&I(VH,{notices:e.libraryNotices}),I(nF,{message:e,agentSteps:e.role===`assistant`?e.agentSteps:void 0,onDelete:!Tn&&!l?bn:void 0,onResend:!Tn&&!l&&e.role===`user`&&!Be?Sn:void 0,onEditStart:!Tn&&!l&&e.role===`user`&&!Be?()=>In(e.id):void 0,editing:Nn===e.id&&!Tn,editDraft:Nn===e.id?Fn.current:null,onEditDraft:e=>{Fn.current=e},onEdit:zn,onEditCancel:Rn,laterCount:e.role===`user`?DL(r,t):0,onRegenerate:s&&!l?()=>jn(e):void 0,extraActions:s?I($R,{answeredBy:e.stats?.model??me?.effective_model,onPick:t=>L(e,t)}):void 0,onTryAgain:o?()=>An(e):void 0,onContinue:o&&a?Bn:void 0,latest:e.role===`assistant`&&t===r.length-1,latencyMs:c}),e.failure===`model_server_down`&&t===r.length-1&&!Tn&&I(EH,{}),Yt?.messageId===e.id&&I(rz,{original:e,originalModel:e.stats?.model??me?.effective_model,originalLatencyMs:c,state:Yt.state,keeping:Yt.keeping,onKeep:e=>{$t(e)},onClose:nn})]},Ut(e)??Ue.current.get(e.id)??e.id)}),f&&Ve&&I(BH,{text:Ve}),f&&I(oI,{}),(f||!!Rt)&&I(`div`,{className:`streaming-bubble stream-active`,children:I(nF,{message:{id:-1,session_id:e,role:`assistant`,content:f&&p||``,created_at:``,rag_sources:null},isStreaming:f||!!Rt,agentSteps:f?v:LH,agentStepsActive:f&&v.some(e=>e.active),cards:f?T:RH,liveStatus:f?ce:null,toolStatus:f?le:null,awaitingUser:f&&(ue||de||pe)})}),I(`div`,{ref:Ge})]})}),I(TV,{sessionId:e,messages:r,busy:Tn,onUsage:Jt,onJumpToMessage:pn}),be&&z(`div`,{className:`drag-overlay`,children:[I(Os,{size:32,strokeWidth:1.5,"aria-hidden":`true`}),I(`span`,{children:t(`chat.dropOverlay`)})]}),Oe&&z(`div`,{className:`toast policy-alert-toast`,role:`alert`,children:[I(`span`,{children:t(`chat.policyBlocked`,{tool:Oe.tool})}),Oe.receiptId?I(`button`,{type:`button`,className:`policy-alert-toast-link`,onClick:()=>{let e=Oe.receiptId;e&&(oe(`policy_alert`),j(!0),Me(e))},children:t(`chat.policyViewReceipt`)}):I(`span`,{className:`policy-alert-toast-missing`,children:t(`activity.policy.receiptUnavailable`)})]}),z(`div`,{className:`input-area`,children:[Se&&I(`button`,{className:`scroll-bottom-btn`,onClick:mn,title:t(`chat.scrollBottom`),"aria-label":t(`chat.scrollBottom`),children:I(dr,{size:16})}),z(`div`,{className:`input-column`,children:[I(ZV,{message:Pe,onDismiss:Fe,dismissLabel:t(`chat.dismissExportError`)}),I(ZV,{message:Ie,onDismiss:()=>Le(null),dismissLabel:t(`chat.dismissError`)}),Xn&&qn&&I(bL,{content:qn.content,providers:Jn,accounts:Yn,onRetry:kn},qn.id),I($E,{sessionId:e}),I(KR,{usage:Wt}),I(XV,{sessionId:e}),se&&It&&I(`ul`,{className:`queued-messages`,"aria-label":t(`composer.heldLabel`),"aria-live":`polite`,children:z(`li`,{className:`queued-message is-queued`,children:[I(di,{size:12,"aria-hidden":`true`}),I(`span`,{className:`queued-message-text`,title:se.text,children:se.text}),I(`span`,{className:`queued-message-state`,children:t(`composer.heldUntilStarted`)})]})}),I(SR,{items:ct,onRemove:e=>lt(t=>we(t,e)),onRetry:e=>lt(t=>b(t,e,`failed`,`queued`)),onSteer:f&&!$e&&!ft?Dn:void 0,replying:f,busyRetry:!!vt}),I(LL,{value:he,onChange:M,onSubmit:fe?On:()=>_n(),answering:!!fe,onStop:gn,streaming:f,stopping:$e,queueWhileStreaming:!0,disabledReason:Qn,attachments:Te,inputRef:qe,onEditLast:!Tn&&!Be?Ln:void 0,placeholder:fe?t(`composer.answerQuestion`):f?t(`composer.queueNext`):r.length===0?t(`composer.placeholder`):t(`composer.reply`),leftControls:I(yR,{sessionId:e,disabled:!!Be}),rightControls:z(P.Fragment,{children:[I(GR,{usage:Wt,unavailable:Gt,sessionId:e,busy:Tn,onUsage:Jt,onDetails:()=>on(`context`)}),I(XR,{sessionId:e,busy:Tn}),I(mR,{sessionId:e,onOpen:()=>on(`environment`)}),I(tR,{})]})})]})]})]})}var WH=1.1,GH=60,KH=110,qH=24,JH=2.4,YH=Math.PI*2,XH=(e,t,n)=>{let r=Math.min(1,Math.max(0,(n-e)/(t-e)));return r*r*(3-2*r)};function ZH(e){let t=e;return()=>{t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}var QH=class{cols=0;rows=0;w=0;h=0;ox=0;oy=0;time=0;energy=new Float32Array;offset=new Float32Array;mask=new Float32Array;phase=new Float32Array;waves=[];ripples=[];waveIn=1.5;dragIn=0;activity=`idle`;progress=0;pointer=null;exit=null;done=!1;settled=!1;rand;constructor(e=7){this.rand=ZH(e)}get cleared(){return this.done}get dissolving(){return this.exit!==null||this.done}resize(e,t,n){this.w=e,this.h=t,this.cols=Math.ceil(e/30),this.rows=Math.ceil(t/30),this.ox=(e-this.cols*30)/2,this.oy=(t-this.rows*30)/2;let r=this.cols*this.rows;this.energy=new Float32Array(r),this.offset=new Float32Array(r*2),this.phase=Float32Array.from({length:r},()=>this.rand()*YH),this.setHole(n)}setHole(e){this.mask.length!==this.cols*this.rows&&(this.mask=new Float32Array(this.cols*this.rows));for(let t=0;t<this.rows;t++)for(let n=0;n<this.cols;n++){let[r,i]=this.center(n,t),a=Math.hypot((r-e.cx)/e.rx,(i-e.cy)/e.ry);this.mask[t*this.cols+n]=(.3+.7*XH(.75,1.5,a))*XH(0,50,i)*XH(0,50,this.h-i)}}setActivity(e){e!==this.activity&&(this.activity=e,this.waveIn=0)}setProgress(e){this.progress=Math.min(1,Math.max(0,e))}setPointer(e,t,n,r=0){this.pointer={x:e,y:t,down:n,speed:r}}clearPointer(){this.pointer=null}ripple(e,t,n){this.ripples.length>24&&this.ripples.shift(),this.ripples.push({x:e,y:t,r:0,t:0,life:1.2+n*.6,strength:n,speed:150+this.rand()*50,phase:this.rand()*YH})}dissolve(e,t){this.ripple(e,t,1);let n=Math.hypot(Math.max(e,this.w-e),Math.max(t,this.h-t))*1.15;this.exit={x:e,y:t,t:0,reach:n,phase:this.rand()*YH},this.done=!1}restore(){this.exit=null,this.done=!1,this.settled=!1,this.energy.fill(0),this.offset.fill(0),this.ripples=[],this.waves=[]}energyAt(e,t){return this.energy[t*this.cols+e]}offsetAt(e,t){let n=t*this.cols+e;return[this.offset[n*2],this.offset[n*2+1]]}center(e,t){return[this.ox+(e+.5)*30,this.oy+(t+.5)*30]}step(e){if(this.done)return!1;if(this.settled&&this.activity===`idle`&&!this.pointer&&!this.ripples.length&&!this.waves.length&&!this.exit&&this.waveIn>e)return this.waveIn-=e,!1;this.time+=e;let t=this.time,n=this.cols+this.rows*.6;if(this.waveIn-=e,this.waveIn<=0){if(this.activity===`loading`)this.waveIn=.9+this.rand()*.5,this.waves.push({front:-3,speed:14+this.rand()*6,dir:1,span:n,strength:.5+this.rand()*.2});else if(this.activity===`idle`){this.waveIn=3+this.rand()*4;let e=this.rand()<.5?1:-1;this.waves.push({front:e>0?-3:n+3,speed:7+this.rand()*4,dir:e,span:n,strength:.45})}else this.waveIn=1}let r=this.pointer;r?.down&&(this.dragIn-=e,this.dragIn<=0&&(this.dragIn=.12,this.ripple(r.x,r.y,.7)));let i=Math.exp(-e*JH),a=Math.min(1,e*14),o=Math.min(1,e*9),s=r?GH+Math.min(80,r.speed*.08):0,c=r?.5+Math.min(.45,r.speed/2e3):0,l=this.activity===`download`?this.progress*this.rows:-1,{cols:u,rows:d,energy:f,offset:p}=this,m=0,h=0;for(let e=0;e<d;e++)for(let n=0;n<u;n++){let g=e*u+n,[_,v]=this.center(n,e),y=f[g]*i,b=0,x=0,S=0,C=.55+.45*Math.sin(n*1.7+e*2.3+t*.6),w=n+e*.6+.9*Math.sin(e*.45+t*.8)+.5*Math.sin(n*.21-t*1.1);for(let e of this.waves){let t=1-Math.abs(w-e.front)/1.5;t>0&&(b=Math.max(b,t*e.strength*C))}for(let e of this.ripples){let t=_-e.x,n=v-e.y,r=Math.hypot(t,n)||1;if(Math.abs(r-e.r)>qH+.11*e.r)continue;let i=Math.atan2(n,t),a=e.r*(1+.07*Math.sin(5*i+e.phase)+.04*Math.sin(9*i-e.phase*2)),o=1-Math.abs(r-a)/qH;if(o<=0)continue;let s=(1-e.t/e.life)**1.3;b=Math.max(b,o*.85*e.strength*s),x+=t/r*o*7*e.strength*s,S+=n/r*o*7*e.strength*s}if(r){let e=_-r.x,t=v-r.y,n=Math.hypot(e,t)||1;if(n<s&&(b=Math.max(b,(1-n/s)**1.4*c)),n<KH){let i=(1-n/KH)**2*(10+Math.min(10,r.speed/120));x+=e/n*i,S+=t/n*i}}let T=0;if(l>=0){let r=l-(d-1-e+.5+.35*Math.sin(n*.55+t*2.1)+.2*Math.sin(n*1.31-t*1.3));r>0&&(T=.16),r>-1&&r<1&&(b=Math.max(b,(1-Math.abs(r))*(.45+.35*Math.sin(t*3+this.phase[g]))))}f[g]=Math.max(T,b>y?y+(b-y)*a:y),p[g*2]+=(x-p[g*2])*o,p[g*2+1]+=(S-p[g*2+1])*o,m=Math.max(m,f[g]),h=Math.max(h,Math.abs(p[g*2]),Math.abs(p[g*2+1]))}return this.settled=m<.04&&h<.05,this.waves=this.waves.filter(t=>(t.front+=t.dir*t.speed*e,t.front>=-4&&t.front<=t.span+4)),this.ripples=this.ripples.filter(t=>(t.t+=e,t.r+=t.speed*e*(1-.35*t.t/t.life),t.t<t.life)),this.exit&&(this.exit.t+=e,this.exit.t>=1.1&&(this.exit=null,this.done=!0)),!0}draw(e,t){if(e.clearRect(0,0,this.w,this.h),this.done)return;let{cols:n,rows:r,energy:i,offset:a,mask:o}=this,s=t.dark?.17:.14;e.lineWidth=1;for(let c=0;c<r;c++)for(let r=0;r<n;r++){let l=c*n+r,[u,d]=this.center(r,c),f=u+a[l*2],p=d+a[l*2+1],m=i[l],h=o[l];if(m<.04){e.fillStyle=t.fg,e.globalAlpha=s*h,e.fillRect(f-1,p-1,2,2);continue}let g=2+m*19,_=Math.max(1,6-m*3);e.beginPath(),e.roundRect(f-g/2,p-g/2,g,g,_),e.fillStyle=t.accent,e.globalAlpha=(.12+m*.22)*h,e.fill(),e.strokeStyle=t.accent,e.globalAlpha=m*.5*h,e.stroke()}this.exit&&this.drawExit(e,t),e.globalAlpha=1}drawExit(e,t){let n=this.exit,r=Math.min(1,n.t/WH),i=(1-(1-r)**3)*n.reach,a=new Path2D;for(let e=0;e<=180;e++){let t=e/180*YH,r=i*(1+.06*Math.sin(3*t+n.phase+n.t*1.5)+.03*Math.sin(5*t-n.phase*1.7-n.t*2.2)),o=n.x+Math.cos(t)*r,s=n.y+Math.sin(t)*r;e?a.lineTo(o,s):a.moveTo(o,s)}a.closePath(),e.globalAlpha=1,e.globalCompositeOperation=`destination-out`,e.fill(a),e.globalCompositeOperation=`source-over`,e.strokeStyle=t.accent,e.lineWidth=1.4,e.globalAlpha=.55*(1-r)**.7,e.stroke(a)}},$H=90;function eU(){let e=getComputedStyle(document.documentElement);return{fg:e.getPropertyValue(`--text-primary`).trim(),accent:e.getPropertyValue(`--accent-solid`).trim(),dark:document.documentElement.getAttribute(`data-theme`)===`dark`}}function tU(e,t,n){let r=e.getBoundingClientRect();return r.width?{cx:r.left-t.left+r.width/2,cy:r.top-t.top+r.height/2,rx:r.width/2+n,ry:r.height/2+n+10}:null}function nU({activity:e,progress:t=0,pulse:n,docked:r,contentRef:i,composerRef:a}){let o=(0,V.useRef)(null),s=(0,V.useRef)(null),c=(0,V.useRef)(null),l=(0,V.useRef)(()=>{}),u=(0,V.useRef)(()=>{}),d=(0,V.useRef)(r),f=(0,V.useRef)({value:n,at:0});d.current=r,(0,V.useEffect)(()=>{let e=o.current,t=e?.parentElement;if(!e||!t)return;let n=e.getContext(`2d`);if(!n){F.ui.warn(`New-chat background is off: the browser gave no 2D canvas context (often low graphics memory).`);return}c.current=t;let r=new QH;s.current=r;let f=typeof window.matchMedia==`function`?window.matchMedia(Oz):null,p=eU(),m=0,h=0,g=!1,_=``,v={x:0,y:0,at:0,speed:0},y=()=>r.draw(n,p),b=(e,t=!1)=>{let n=d.current?a.current:i.current,r=(n&&tU(n,e,d.current?24:40))??{cx:e.width/2,cy:e.height/2,rx:1,ry:1},o=`${Math.round(r.cx)},${Math.round(r.cy)},${Math.round(r.rx)},${Math.round(r.ry)}`;return t||o!==_?(_=o,r):null},x=()=>{let i=t.getBoundingClientRect();if(!i.width||!i.height)return;let a=Math.min(2,window.devicePixelRatio||1);e.width=Math.round(i.width*a),e.height=Math.round(i.height*a),n.setTransform(a,0,0,a,0,0),r.resize(i.width,i.height,b(i,!0)),y()},S=e=>{if(m=requestAnimationFrame(S),e-h<31.833333333333336)return;let n=Math.min(.1,(e-h)/1e3);h=e;let i=b(t.getBoundingClientRect());i&&r.setHole(i),e-v.at>80&&(v.speed*=.8),(r.step(n)||i)&&y(),r.cleared&&w()},C=()=>{g||document.hidden||f?.matches||r.cleared||(g=!0,h=performance.now(),m=requestAnimationFrame(S))},w=()=>{g=!1,cancelAnimationFrame(m)};l.current=C,u.current=()=>{let e=b(t.getBoundingClientRect());e&&r.setHole(e),g||y()};let T=()=>document.hidden?w():C(),E=()=>{w(),y(),C()},D=()=>{p=eU(),y()},O=e=>{let n=t.getBoundingClientRect(),i=e.clientX-n.left,a=e.clientY-n.top,o=performance.now();if(v.at&&o>v.at){let e=Math.hypot(i-v.x,a-v.y)/((o-v.at)/1e3);v.speed+=(Math.min(4e3,e)-v.speed)*.35}Object.assign(v,{x:i,y:a,at:o});let s=e.target instanceof Element&&e.target.closest(`button, a, input, textarea, .composer`);r.setPointer(i,a,(e.buttons&1)==1&&!s,v.speed)},k=()=>{v.at=0,v.speed=0,r.clearPointer()},ee=typeof ResizeObserver>`u`?null:new ResizeObserver(x);ee?.observe(t,{box:`border-box`});let te=new MutationObserver(D);return te.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`,`data-palette`,`style`]}),document.addEventListener(`visibilitychange`,T),f?.addEventListener(`change`,E),t.addEventListener(`pointermove`,O),t.addEventListener(`pointerleave`,k),x(),C(),()=>{w(),ee?.disconnect(),te.disconnect(),document.removeEventListener(`visibilitychange`,T),f?.removeEventListener(`change`,E),t.removeEventListener(`pointermove`,O),t.removeEventListener(`pointerleave`,k),s.current=null,l.current=()=>{},u.current=()=>{}}},[i,a]);let p=(0,V.useCallback)(()=>{let e=c.current,t=a.current;if(!e||!t)return null;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return[r.left-n.left+r.width/2,r.top-n.top+r.height/2]},[a]);return(0,V.useEffect)(()=>{let t=s.current;if(t){if(t.setActivity(e),e===`sending`){let e=p();e&&t.dissolve(...e)}else t.dissolving&&(t.restore(),l.current())}},[e,p]),(0,V.useEffect)(()=>{s.current?.setProgress(t)},[t]),(0,V.useEffect)(()=>{u.current()},[r]),(0,V.useEffect)(()=>{let e=f.current;if(n===e.value)return;let t=performance.now();if(e.value=n,t-e.at<$H)return;e.at=t;let r=p();r&&s.current?.ripple(...r,.45)},[n,p]),I(`canvas`,{ref:o,className:`npu-backdrop`,"aria-hidden":`true`})}async function rU(e,t,n){let r=`${dn()}${t}`,i={};e!==`GET`&&(i[`X-Gaia-UI`]=`1`),n!==void 0&&(i[`Content-Type`]=`application/json`);let a={method:e,headers:Object.keys(i).length>0?i:void 0,body:n===void 0?void 0:JSON.stringify(n)},o=await fetch(r,a);if(!o.ok){let e=await o.text().catch(()=>``),t=e;try{t=JSON.parse(e).detail||e}catch{}throw Error(t||`Memory API error (HTTP ${o.status})`)}if(o.status!==204&&(o.headers.get(`content-type`)||``).includes(`application/json`))return o.json()}function iU(e){let t=[];for(let[n,r]of Object.entries(e))if(r!=null&&r!==``){if(Array.isArray(r))for(let e of r)t.push(`${encodeURIComponent(n)}=${encodeURIComponent(String(e))}`);else t.push(`${encodeURIComponent(n)}=${encodeURIComponent(String(r))}`)}return t.length?`?${t.join(`&`)}`:``}function aU(){return rU(`GET`,`/memory/stats`)}function oU(e=30){return rU(`GET`,`/memory/activity?days=${e}`)}function sU(e={}){return rU(`GET`,`/memory/knowledge${iU(e)}`)}function cU(e){return rU(`POST`,`/memory/knowledge`,e)}function lU(e,t){return rU(`PUT`,`/memory/knowledge/${encodeURIComponent(e)}`,t)}function uU(e){return rU(`DELETE`,`/memory/knowledge/${encodeURIComponent(e)}`)}function dU(){return rU(`GET`,`/memory/entities`)}function fU(){return rU(`GET`,`/memory/tools`)}function pU(e=20){return rU(`GET`,`/memory/conversations?limit=${e}`)}function mU(e,t=20){return rU(`GET`,`/memory/conversations/search?query=${encodeURIComponent(e)}&limit=${t}`)}function hU(e){return rU(`GET`,`/memory/conversations/${encodeURIComponent(e)}`)}function gU(e=7){return rU(`GET`,`/memory/upcoming?days=${e}`)}function _U(){return rU(`GET`,`/memory/embedding-coverage`)}function vU(){return rU(`POST`,`/memory/consolidate`)}function yU(){return rU(`POST`,`/memory/rebuild-embeddings`)}function bU(){return rU(`POST`,`/memory/reconcile`)}function xU(){return rU(`POST`,`/memory/rebuild-fts`)}function SU(){return rU(`POST`,`/memory/refresh-system-context`)}function CU(){return new EventSource(`${dn()}/memory/stream-discovery`)}function wU(e){return new EventSource(`${dn()}/memory/stream-inference?include_browser=${e}`)}function TU(e){return rU(`POST`,`/memory/commit-discovery`,{items:e})}function EU(e){return rU(`POST`,`/memory/commit-inference`,{insights:e})}function DU(){return rU(`GET`,`/memory/settings`)}function OU(e){return rU(`PUT`,`/memory/settings`,e)}function kU(){return rU(`DELETE`,`/memory/all`)}function AU(){return rU(`POST`,`/memory/reinitialize`)}function jU(){return rU(`GET`,`/goals/health`)}function MU(){return rU(`POST`,`/goals/store/reset`)}function NU(){return rU(`GET`,`/goals/stats`)}function PU(e={}){return rU(`GET`,`/goals${iU(e)}`)}function FU(e){return rU(`POST`,`/goals`,e)}function IU(e){return rU(`PUT`,`/goals/${encodeURIComponent(e)}/approve`)}function LU(e){return rU(`PUT`,`/goals/${encodeURIComponent(e)}/reject`)}function RU(e){return rU(`PUT`,`/goals/${encodeURIComponent(e)}/cancel`)}function zU(e){return rU(`DELETE`,`/goals/${encodeURIComponent(e)}`)}function BU({disabled:e}){let t=R(),n=B(e=>e.draftPrivate),r=B(e=>e.setDraftPrivate),i=B(e=>e.settingsSection!==null),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(!1),d=(0,V.useRef)(null),f=(0,V.useCallback)(()=>u(!1),[]);if((0,V.useEffect)(()=>{if(i)return;let e=!1;return DU().then(t=>{e||(o(t.memory_enabled),c(!1))}).catch(t=>{e||(F.ui.error(`Could not read the memory setting for the Private chip`,t),o(null),c(!0))}),()=>{e=!0}},[i]),(0,V.useEffect)(()=>{a===!1&&n&&r(!1)},[a,n,r]),a===!1)return z(`button`,{type:`button`,className:`composer-chip composer-chip-memory is-unavailable`,disabled:!0,"aria-label":t(`composer.memoryOff`),title:t(`composer.memoryOffTitle`),children:[I(Ni,{size:13,"aria-hidden":`true`}),I(`span`,{className:`composer-chip-label`,dir:`auto`,children:t(`composer.memoryOff`)})]});let p=e=>{r(e),u(!1)},m=[{priv:!1,Icon:Fi,label:t(`composer.remember`),note:t(s?`composer.memoryUnknownTitle`:`composer.rememberNote`)},{priv:!0,Icon:Ni,label:t(`composer.privateChat`),note:t(`composer.privateChatNote`)}];return z(`div`,{className:`composer-chip-wrap`,children:[z(`button`,{ref:d,type:`button`,className:`composer-chip composer-chip-memory${n?` is-on`:``}`,onClick:()=>u(e=>!e),disabled:e,"aria-haspopup":`dialog`,"aria-expanded":l,"aria-label":t(`composer.memoryChipAria`,{state:t(n?`composer.private`:s?`composer.memoryUnknown`:`composer.memoryOn`)}),title:t(n?`composer.privateChatNote`:s?`composer.memoryUnknownTitle`:`composer.rememberNote`),children:[I(n?Ni:Fi,{size:13,"aria-hidden":`true`}),I(`span`,{className:`composer-chip-label`,dir:`auto`,children:t(n?`composer.private`:s?`composer.memoryUnknown`:`composer.memoryOn`)}),I(Gr,{size:12,"aria-hidden":`true`})]}),I(Gs,{open:l,onClose:f,anchor:d,label:t(`composer.memoryMenu`),children:m.map(({priv:e,Icon:t,label:r,note:i})=>z(`button`,{type:`button`,className:`popover-item`,onClick:()=>p(e),"aria-pressed":n===e,children:[I(`span`,{className:`popover-item-check`,"aria-hidden":`true`,children:I(n===e?Vr:t,{size:13})}),z(`span`,{className:`popover-item-body`,children:[I(`span`,{className:`popover-item-title`,children:r}),I(`span`,{className:`popover-item-note`,children:i})]})]},String(e)))})]})}var VU=[{icon:Ur,label:`cards.try.recipe`,prompt:`cards.try.recipePrompt`},{icon:Ti,label:`cards.try.workout`,prompt:`cards.try.workoutPrompt`},{icon:Ps,label:`cards.try.howTo`,prompt:`cards.try.howToPrompt`},{icon:Fa,label:`cards.try.checklist`,prompt:`cards.try.checklistPrompt`},{icon:Ua,label:`cards.try.trip`,prompt:`cards.try.tripPrompt`},{icon:Mo,label:`cards.try.bill`,prompt:`cards.try.billPrompt`},{icon:Nr,label:`cards.try.loan`,prompt:`cards.try.loanPrompt`}];function HU({onPick:e,disabled:t}){let n=R();return z(`div`,{className:`try-chips`,role:`group`,"aria-label":n(`cards.tryGroup`),children:[I(`span`,{className:`try-chips-label`,"aria-hidden":`true`,children:n(`cards.try`)}),VU.map(({icon:r,label:i,prompt:a})=>{let o=n(i),s=n.bare(a);return z(`button`,{type:`button`,className:`try-chip`,title:s,"aria-label":`${o}: ${s}`,onClick:()=>e(s),disabled:t,children:[I(r,{size:14,"aria-hidden":`true`}),o]},i)})]})}var UU=1e3;function WU(){let[e,t]=(0,V.useState)(null);return(0,V.useEffect)(()=>{let e=!1,n,r=a=>{e||(a.state===`warming`?(t({seconds:Math.floor(a.elapsed_seconds??0),model:a.model??null,device:a.device??null}),n=setTimeout(()=>{ct().then(r,i)},UU)):t(null))},i=n=>{e||(F.system.warn(`Warm-up status unavailable`,n),t(null))};return mt().then(r,i),()=>{e=!0,n&&clearTimeout(n)}},[]),e}function GU(e){return e===`gpu`?`your GPU`:e===`npu`?`your NPU`:e===`cpu`?`the CPU`:null}function KU(e){return e<1?`under 1 GB`:`${e.toFixed(1)} GB`}var qU=15e3;function JU(e=new Date,t=gt){let n=e.getHours();return t(`newChat.greeting.${n<5?`evening`:n<12?`morning`:n<18?`afternoon`:`evening`}`)}var YU={gpu:`device.gpu`,npu:`device.npu`,cpu:`device.cpu`};function XU({seconds:e,model:t,device:n},r=gt){if(!t)return r(`newChat.warmup.ready`,{s:e});let i=xc(t),a=n?YU[n]:void 0;if(a)return r(`newChat.warmup.loadingOn`,{model:i,where:u(a),s:e});let o=GU(n);return o?r(`newChat.warmup.loadingOn`,{model:i,where:o,s:e}):r(`newChat.warmup.loading`,{model:i,s:e})}function ZU({detail:e,onRetry:t}){let n=R(),[r,i]=(0,V.useState)(!1);return z(`div`,{className:`new-chat-note`,children:[z(`p`,{children:[n(`newChat.assistantUnavailable`),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:t,children:n(`newChat.tryAgain`)})]}),z(`button`,{type:`button`,className:`new-chat-details`,"aria-expanded":r,onClick:()=>i(e=>!e),children:[I(Yr,{size:12,className:r?`is-open`:``,"aria-hidden":`true`}),` `,n(`newChat.details`)]}),r&&I(`pre`,{className:`new-chat-details-text`,children:e})]})}function QU(){let{documents:e,draftDocumentIds:t,addDraftDocuments:n}=B.getState();n(e.filter(e=>e.indexing_status===`complete`&&!t.includes(e.id)).map(e=>e.id))}function $U(){let e=R(),[t,n]=(0,V.useState)(!1),r=B(e=>e.documents),i=B(e=>e.draftDocumentIds),a=B(e=>e.removeDraftDocument),o=B(e=>e.setShowDocLibrary),s=r.filter(e=>i.includes(e.id)),c=r.filter(e=>e.indexing_status===`complete`&&!i.includes(e.id));if(!s.length&&!c.length)return null;let l=c.length,u=s.length-5,d=t||u<=0?s:s.slice(0,5);return z(`div`,{className:`new-chat-docs`,children:[s.length>0&&I(`ul`,{id:`new-chat-doc-list`,className:`new-chat-doc-list${t?` is-expanded`:``}`,"aria-label":e(`newChat.docs.forChat`),children:d.map(t=>z(`li`,{className:`new-chat-doc`,children:[I(Yi,{size:12,"aria-hidden":`true`}),I(`span`,{dir:`ltr`,children:t.filename}),I(`button`,{type:`button`,className:`new-chat-doc-remove`,onClick:()=>a(t.id),"aria-label":e(`newChat.docs.dontAttach`,{name:t.filename}),children:I(Is,{size:12,"aria-hidden":`true`})})]},t.id))}),u>0&&I(`button`,{type:`button`,className:`link-btn new-chat-doc-toggle`,"aria-expanded":t,"aria-controls":`new-chat-doc-list`,onClick:()=>n(e=>!e),children:t?e(`newChat.docs.fewer`):e(`newChat.docs.hidden`,{n:u})}),l>0&&z(`p`,{className:`new-chat-note`,children:[s.length?e.plural(`newChat.docs.more`,l):e.plural(`newChat.docs.library`,l),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:QU,children:l===1?e(`newChat.docs.attachIt`):e(`newChat.docs.attachAll`,{n:l})}),l>1&&z(P.Fragment,{children:[` · `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>o(!0),children:e(`newChat.docs.choose`)})]})]})]})}function eW({error:e}){let t=R(),n=B(e=>e.openSettings);return z(`div`,{className:`new-chat-setup-failed`,role:`alert`,children:[I(`p`,{className:`new-chat-setup-failed-title`,children:t(`newChat.setupFailed.title`)}),I(`p`,{className:`new-chat-setup-failed-error`,children:e}),z(`p`,{children:[t(`newChat.setupFailed.hint`),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>n(`model`),children:t(`newChat.setupFailed.choose`)})]})]})}function tW({onSend:e,initialText:t=``,focusRequest:n=0,agentMissing:r=!1,agentRefused:i=!1}){let s=R(),c=B(e=>hI(e.systemStatus)),l=B(e=>e.systemStatus?.download_progress??null),u=B(e=>e.systemStatus?.model_loaded?null:e.systemStatus?.setup_error??null),d=_c(e=>!!e.active?.remote),[f,p]=DH(a,t),[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)(i),[v,y]=(0,V.useState)(!1),[b,x]=(0,V.useState)(null),[S,C]=(0,V.useState)(null),w=(0,V.useRef)(null),T=(0,V.useRef)(null),E=(0,V.useRef)(null),D=iH(),O=WU();yc();let k=(0,V.useRef)(!0),te=(0,V.useCallback)((e=!1)=>{e||C(null),ee().then(e=>{k.current&&(x(e),C(e.skills_error??null))}).catch(e=>{F.api.warn(`New-chat start screen unavailable`,e),k.current&&C(CM(e))})},[]);(0,V.useEffect)(()=>(k.current=!0,te(),()=>{k.current=!1}),[te]),(0,V.useEffect)(()=>{o().then(e=>B.getState().setDocuments(e.documents||[])).catch(e=>F.api.warn(`Document library unavailable; not offering its documents`,e))},[]),(0,V.useEffect)(()=>{if(S)return SH(()=>te(!0),qU)},[S,te]);let ne=(0,V.useRef)(!1),A=(0,V.useRef)([]),re=(0,V.useCallback)(async(t,n=``)=>{if(t){if(ne.current)A.current.push(n||t),p(``);else{ne.current=!0,y(!0),h(null),_(!1),p(``);try{let n=await e(t);D.clear();let r=A.current.splice(0),i=B.getState().currentSessionId;if(r.length>0&&i){let e=(e,t)=>n===!1?[...e,{...ze(t,`failed`),error:`The first message was not sent.`}]:xt(e,t,`queued`);B.getState().updateQueue(i,t=>r.reduce(e,t))}}catch(e){let r=A.current.splice(0);p([n||t,...r].join(`
|
|
203
|
+
`)))}else ct.length===0||vt||yt||ee||se||Lt.current||Be||It||kt()||!mt.current&&!Cn||qI(e,wn,()=>Ft.current&&!kt()&&!B.getState().isStreaming&&!Qt.current)}},[Tn,ct,vt,yt,Cn,ee,se,Be,It,e,wn,kt]);let En=(0,V.useRef)(!1);(0,V.useEffect)(()=>{En.current&&!Tn&&qt(),En.current=Tn},[Tn,qt]);let Dn=(0,V.useCallback)(t=>{let n=ct.find(e=>e.id===t&&e.state===`queued`);n&&f&&(lt(e=>b(e,t,`queued`,`sending`)),en(e,n.text).then(()=>lt(e=>b(e,t,`sending`,`delivered`))).catch(e=>{F.chat.info(`Follow-up not taken by the running reply; it stays queued: ${e instanceof Error?e.message:e}`),lt(e=>s(e,t))}))},[ct,f,e,lt]),On=(0,V.useCallback)(async()=>{let n=fe?B.getState().liveQuestions[fe]:void 0,r=he.trim();if(!fe||!n||!r||Te.hasUploaded){_n();return}let i=$k(r,n);if(!i)Le(t(`composer.pickAnOption`));else{Le(null),M(``);try{await Qk(e,fe,i.value,i.shown)}catch(e){M(r),e instanceof Xk||Le(t(`composer.answerFailed`,{error:SM(e)}))}}},[fe,he,Te,_n,M,e,t]),kn=(0,V.useCallback)(()=>{for(let e=r.length-1;e>=0;e--)if(r[e].role===`user`){Sn(r[e]);return}},[r,Sn]),An=(0,V.useCallback)(e=>{let t=r.indexOf(e);for(let n=t-1;n>=0;n--)if(r[n].role===`user`){Sn(r[n],e);return}},[r,Sn]),jn=(0,V.useCallback)(e=>{let t=r.indexOf(e);for(let e=t-1;e>=0;e--)if(r[e].role===`user`){Sn(r[e]);return}},[r,Sn]),[Nn,Pn]=(0,V.useState)(null),Fn=(0,V.useRef)(null),In=(0,V.useCallback)(e=>{Fn.current=null,Pn(e)},[]),Ln=(0,V.useCallback)(()=>{let e=EL(r);e&&In(e.id)},[r,In]),Rn=(0,V.useCallback)(()=>{Fn.current=null,Pn(null),qe.current?.focus()},[]),zn=(0,V.useCallback)(async(e,t)=>{Fn.current=t,await Sn(e,void 0,t)&&(Fn.current=null,Pn(t=>t===e.id?null:t))},[Sn]),Bn=(0,V.useCallback)(()=>{ot.current(t(`msg.continuePrompt`))},[t]),Vn=()=>{ye(me?.title||``),ge(!0)},Hn=async()=>{let n=ve.trim().slice(0,200).trim();if(n&&ve!==me?.title&&n!==me?.title){Le(null);try{await _e(e,{title:n,title_is_custom:!0}),d(e,{title:n})}catch(n){F.chat.error(`Could not rename chat ${e}`,n),Le(t(`chat.renameFailed`,{error:SM(n)}))}}ge(!1)},Un=(0,V.useCallback)(async()=>{if(e){Le(null);try{let t=await c(e);d(e,{private:t.private})}catch(e){F.ui.warn(`Failed to toggle private mode`,e),Le(t(`chat.privateFailed`,{error:SM(e)}))}}},[e,d,t]),Wn=(0,V.useCallback)(async n=>{if(n.preventDefault(),n.stopPropagation(),xe(!1),n.dataTransfer.files.length===0)return;let r=Array.from(n.dataTransfer.files),i=r.filter(e=>tL(e.name));i.length>0&&Te.addFiles(i);let a=r.filter(e=>!tL(e.name));if(a.length===0||!await ec(`embedding`))return;Le(null);let o=await xH(e,a);o.length>0&&Le(o.map(({name:e,stage:n,error:r})=>n===`unreadable`||n===`server`?t(n===`server`?`docsBar.serverTitle`:`docsBar.failedTitle`,{name:e}):t(n===`attach`?`chat.dropAttachFailed`:`chat.dropUploadFailed`,{name:e,error:SM(r)})).join(` `))},[e,Te,t]),Gn=e=>{e.dataTransfer?.types?.includes(`Files`)&&(e.preventDefault(),e.stopPropagation(),xe(!0))},Kn=e=>{e.preventDefault(),e.stopPropagation(),xe(!1)},qn=r.length>0?r[r.length-1]:void 0,Jn=(0,V.useMemo)(()=>cA(qn),[qn]),Yn=(0,V.useMemo)(()=>lA(qn),[qn]),Xn=!f&&!ee&&qn?.role===`assistant`&&(uA(qn)?Jn.length>0:QO(qn.content)),Zn=(0,V.useMemo)(()=>{let e=new Map,t;for(let n of r)if(n.role===`user`&&n.created_at)t=new Date(n.created_at).getTime();else if(n.role===`assistant`&&n.created_at&&t!==void 0){let r=new Date(n.created_at).getTime();r>t&&e.set(n.id,r-t),t=void 0}return e},[r]),Qn=Be?`This chat used the retired "${Be}" agent and is read-only. Start a new chat.`:hI(A)?iu:null;return z(`main`,{className:`task-view ${be?`drag-active`:``}`,style:{"--session-panel-w":`${an}px`},onDrop:Wn,onDragOver:Gn,onDragLeave:Kn,"aria-label":me?.title||`Chat`,children:[I(OF,{busy:Tn}),z(`header`,{className:`task-header`,children:[I(`div`,{className:`task-header-left`,children:N?I(`input`,{className:`title-edit`,value:ve,maxLength:200,onChange:e=>ye(e.target.value),onBlur:Hn,onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&Hn(),e.key===`Escape`&&(e.preventDefault(),ge(!1))},...Pt,autoFocus:!0,"aria-label":`Chat title`,dir:`auto`}):z(`button`,{type:`button`,className:`task-title`,onClick:Vn,title:t(`row.rename`),children:[I(`span`,{children:vH(me?.title)?t(`sidebar.newChat`):me?.title}),I(go,{size:12,"aria-hidden":`true`,className:`task-title-edit`})]})}),z(`div`,{className:`task-header-right`,children:[I(`button`,{ref:ln,className:`btn-icon-sm task-header-resources`,onClick:()=>cn(!sn),"aria-pressed":sn,"aria-label":t(`resources.toggle`),title:t(sn?`resources.hide`:`resources.show`),children:I(sr,{size:15,"aria-hidden":`true`})}),I(DV,{isPrivate:!!me?.private,onToggle:Un}),I(`button`,{className:`btn-icon-sm`,onClick:()=>k(!0),title:t(`chat.browseFiles`),"aria-label":t(`chat.browseFiles`),children:I(ra,{size:15})}),I(`button`,{className:`btn-icon-sm`,onClick:Ne,title:t(`chat.exportTitle`),"aria-label":t(`chat.exportLabel`),children:I(Ci,{size:15})}),I(EV,{messages:r,busy:f})]})]}),sn&&I(YV,{onClose:fn}),!sn&&un&&z(`div`,{className:`resource-strip resource-hidden-note`,role:`status`,children:[I(`span`,{children:t(`resources.hiddenNote`)}),I(`button`,{type:`button`,className:`resource-hidden-undo`,onClick:()=>cn(!0),children:t(`resources.show`)})]}),I(kV,{sessionId:e,onDetachFailed:ze}),I(`div`,{className:`messages-scroll`,ref:Ke,...Ot,children:z(`div`,{className:`messages-column`,children:[ee&&!Rt&&I(`div`,{className:`skeleton-messages`,"aria-label":t(`chat.loadingMessages`),children:[0,1,2].map(e=>I(`div`,{className:`skeleton-msg`,children:z(`div`,{className:`skeleton-lines`,children:[I(`div`,{className:`skeleton-line`}),I(`div`,{className:`skeleton-line`}),e!==2&&I(`div`,{className:`skeleton-line`})]})},e))}),Bt.map((e,t)=>{let n=e.role===`assistant`?e.historyNotice??zH.get(e.id):void 0,i=e.role===`assistant`&&QP(e.content,e.stopState)===`interrupted`,a=e.role===`assistant`&&e.stopState===`stopped`&&!e.stopError,o=(e.failed===!0||i||a)&&!Tn&&!Be&&t===r.length-1,s=!o&&!Tn&&!Yt&&!Be&&e.role===`assistant`&&t===r.length-1&&!e.stopState&&!e.failed&&!AP(e.content),c=e.stats?.seconds==null?Zn.get(e.id):e.stats.seconds*1e3,l=Vt(e);return z(`div`,{className:Ee===e.id?`msg-deleting`:We.current.has(Ue.current.get(e.id)??e.id)?`msg-settled`:void 0,"data-message-id":e.id,"data-role":e.role,children:[n&&I(BH,{text:n}),e.libraryNotices&&e.libraryNotices.length>0&&I(VH,{notices:e.libraryNotices}),I(nF,{message:e,agentSteps:e.role===`assistant`?e.agentSteps:void 0,onDelete:!Tn&&!l?bn:void 0,onResend:!Tn&&!l&&e.role===`user`&&!Be?Sn:void 0,onEditStart:!Tn&&!l&&e.role===`user`&&!Be?()=>In(e.id):void 0,editing:Nn===e.id&&!Tn,editDraft:Nn===e.id?Fn.current:null,onEditDraft:e=>{Fn.current=e},onEdit:zn,onEditCancel:Rn,laterCount:e.role===`user`?DL(r,t):0,onRegenerate:s&&!l?()=>jn(e):void 0,extraActions:s?I($R,{answeredBy:e.stats?.model??me?.effective_model,onPick:t=>L(e,t)}):void 0,onTryAgain:o?()=>An(e):void 0,onContinue:o&&a?Bn:void 0,latest:e.role===`assistant`&&t===r.length-1,latencyMs:c}),e.failure===`model_server_down`&&t===r.length-1&&!Tn&&I(EH,{}),Yt?.messageId===e.id&&I(rz,{original:e,originalModel:e.stats?.model??me?.effective_model,originalLatencyMs:c,state:Yt.state,keeping:Yt.keeping,onKeep:e=>{$t(e)},onClose:nn})]},Ut(e)??Ue.current.get(e.id)??e.id)}),f&&Ve&&I(BH,{text:Ve}),f&&I(oI,{}),(f||!!Rt)&&I(`div`,{className:`streaming-bubble stream-active`,children:I(nF,{message:{id:-1,session_id:e,role:`assistant`,content:f&&p||``,created_at:``,rag_sources:null},isStreaming:f||!!Rt,agentSteps:f?v:LH,agentStepsActive:f&&v.some(e=>e.active),cards:f?T:RH,liveStatus:f?ce:null,toolStatus:f?le:null,awaitingUser:f&&(ue||de||pe)})}),I(`div`,{ref:Ge})]})}),I(TV,{sessionId:e,messages:r,busy:Tn,onUsage:Jt,onJumpToMessage:pn}),be&&z(`div`,{className:`drag-overlay`,children:[I(Os,{size:32,strokeWidth:1.5,"aria-hidden":`true`}),I(`span`,{children:t(`chat.dropOverlay`)})]}),Oe&&z(`div`,{className:`toast policy-alert-toast`,role:`alert`,children:[I(`span`,{children:t(`chat.policyBlocked`,{tool:Oe.tool})}),Oe.receiptId?I(`button`,{type:`button`,className:`policy-alert-toast-link`,onClick:()=>{let e=Oe.receiptId;e&&(oe(`policy_alert`),j(!0),Me(e))},children:t(`chat.policyViewReceipt`)}):I(`span`,{className:`policy-alert-toast-missing`,children:t(`activity.policy.receiptUnavailable`)})]}),z(`div`,{className:`input-area`,children:[Se&&I(`button`,{className:`scroll-bottom-btn`,onClick:mn,title:t(`chat.scrollBottom`),"aria-label":t(`chat.scrollBottom`),children:I(dr,{size:16})}),z(`div`,{className:`input-column`,children:[I(ZV,{message:Pe,onDismiss:Fe,dismissLabel:t(`chat.dismissExportError`)}),I(ZV,{message:Ie,onDismiss:()=>Le(null),dismissLabel:t(`chat.dismissError`)}),Xn&&qn&&I(bL,{content:qn.content,providers:Jn,accounts:Yn,onRetry:kn},qn.id),I($E,{sessionId:e}),I(KR,{usage:Wt}),I(XV,{sessionId:e}),se&&It&&I(`ul`,{className:`queued-messages`,"aria-label":t(`composer.heldLabel`),"aria-live":`polite`,children:z(`li`,{className:`queued-message is-queued`,children:[I(di,{size:12,"aria-hidden":`true`}),I(`span`,{className:`queued-message-text`,title:se.text,children:se.text}),I(`span`,{className:`queued-message-state`,children:t(`composer.heldUntilStarted`)})]})}),I(SR,{items:ct,onRemove:e=>lt(t=>we(t,e)),onRetry:e=>lt(t=>b(t,e,`failed`,`queued`)),onSteer:f&&!$e&&!ft?Dn:void 0,replying:f,busyRetry:!!vt}),I(LL,{value:he,onChange:M,onSubmit:fe?On:()=>_n(),answering:!!fe,onStop:gn,streaming:f,stopping:$e,queueWhileStreaming:!0,disabledReason:Qn,attachments:Te,inputRef:qe,onEditLast:!Tn&&!Be?Ln:void 0,placeholder:fe?t(`composer.answerQuestion`):f?t(`composer.queueNext`):r.length===0?t(`composer.placeholder`):t(`composer.reply`),leftControls:I(yR,{sessionId:e,disabled:!!Be}),rightControls:z(P.Fragment,{children:[I(GR,{usage:Wt,unavailable:Gt,sessionId:e,busy:Tn,onUsage:Jt,onDetails:()=>on(`context`)}),I(XR,{sessionId:e,busy:Tn}),I(mR,{sessionId:e,onOpen:()=>on(`environment`)}),I(tR,{})]})})]})]})]})}var WH=1.1,GH=60,KH=110,qH=24,JH=2.4,YH=Math.PI*2,XH=(e,t,n)=>{let r=Math.min(1,Math.max(0,(n-e)/(t-e)));return r*r*(3-2*r)};function ZH(e){let t=e;return()=>{t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}var QH=class{cols=0;rows=0;w=0;h=0;ox=0;oy=0;time=0;energy=new Float32Array;offset=new Float32Array;mask=new Float32Array;phase=new Float32Array;waves=[];ripples=[];waveIn=1.5;dragIn=0;activity=`idle`;progress=0;pointer=null;exit=null;done=!1;settled=!1;rand;constructor(e=7){this.rand=ZH(e)}get cleared(){return this.done}get dissolving(){return this.exit!==null||this.done}resize(e,t,n){this.w=e,this.h=t,this.cols=Math.ceil(e/30),this.rows=Math.ceil(t/30),this.ox=(e-this.cols*30)/2,this.oy=(t-this.rows*30)/2;let r=this.cols*this.rows;this.energy=new Float32Array(r),this.offset=new Float32Array(r*2),this.phase=Float32Array.from({length:r},()=>this.rand()*YH),this.setHole(n)}setHole(e){this.mask.length!==this.cols*this.rows&&(this.mask=new Float32Array(this.cols*this.rows));for(let t=0;t<this.rows;t++)for(let n=0;n<this.cols;n++){let[r,i]=this.center(n,t),a=Math.hypot((r-e.cx)/e.rx,(i-e.cy)/e.ry);this.mask[t*this.cols+n]=(.3+.7*XH(.75,1.5,a))*XH(0,50,i)*XH(0,50,this.h-i)}}setActivity(e){e!==this.activity&&(this.activity=e,this.waveIn=0)}setProgress(e){this.progress=Math.min(1,Math.max(0,e))}setPointer(e,t,n,r=0){this.pointer={x:e,y:t,down:n,speed:r}}clearPointer(){this.pointer=null}ripple(e,t,n){this.ripples.length>24&&this.ripples.shift(),this.ripples.push({x:e,y:t,r:0,t:0,life:1.2+n*.6,strength:n,speed:150+this.rand()*50,phase:this.rand()*YH})}dissolve(e,t){this.ripple(e,t,1);let n=Math.hypot(Math.max(e,this.w-e),Math.max(t,this.h-t))*1.15;this.exit={x:e,y:t,t:0,reach:n,phase:this.rand()*YH},this.done=!1}restore(){this.exit=null,this.done=!1,this.settled=!1,this.energy.fill(0),this.offset.fill(0),this.ripples=[],this.waves=[]}energyAt(e,t){return this.energy[t*this.cols+e]}offsetAt(e,t){let n=t*this.cols+e;return[this.offset[n*2],this.offset[n*2+1]]}center(e,t){return[this.ox+(e+.5)*30,this.oy+(t+.5)*30]}step(e){if(this.done)return!1;if(this.settled&&this.activity===`idle`&&!this.pointer&&!this.ripples.length&&!this.waves.length&&!this.exit&&this.waveIn>e)return this.waveIn-=e,!1;this.time+=e;let t=this.time,n=this.cols+this.rows*.6;if(this.waveIn-=e,this.waveIn<=0){if(this.activity===`loading`)this.waveIn=.9+this.rand()*.5,this.waves.push({front:-3,speed:14+this.rand()*6,dir:1,span:n,strength:.5+this.rand()*.2});else if(this.activity===`idle`){this.waveIn=3+this.rand()*4;let e=this.rand()<.5?1:-1;this.waves.push({front:e>0?-3:n+3,speed:7+this.rand()*4,dir:e,span:n,strength:.45})}else this.waveIn=1}let r=this.pointer;r?.down&&(this.dragIn-=e,this.dragIn<=0&&(this.dragIn=.12,this.ripple(r.x,r.y,.7)));let i=Math.exp(-e*JH),a=Math.min(1,e*14),o=Math.min(1,e*9),s=r?GH+Math.min(80,r.speed*.08):0,c=r?.5+Math.min(.45,r.speed/2e3):0,l=this.activity===`download`?this.progress*this.rows:-1,{cols:u,rows:d,energy:f,offset:p}=this,m=0,h=0;for(let e=0;e<d;e++)for(let n=0;n<u;n++){let g=e*u+n,[_,v]=this.center(n,e),y=f[g]*i,b=0,x=0,S=0,C=.55+.45*Math.sin(n*1.7+e*2.3+t*.6),w=n+e*.6+.9*Math.sin(e*.45+t*.8)+.5*Math.sin(n*.21-t*1.1);for(let e of this.waves){let t=1-Math.abs(w-e.front)/1.5;t>0&&(b=Math.max(b,t*e.strength*C))}for(let e of this.ripples){let t=_-e.x,n=v-e.y,r=Math.hypot(t,n)||1;if(Math.abs(r-e.r)>qH+.11*e.r)continue;let i=Math.atan2(n,t),a=e.r*(1+.07*Math.sin(5*i+e.phase)+.04*Math.sin(9*i-e.phase*2)),o=1-Math.abs(r-a)/qH;if(o<=0)continue;let s=(1-e.t/e.life)**1.3;b=Math.max(b,o*.85*e.strength*s),x+=t/r*o*7*e.strength*s,S+=n/r*o*7*e.strength*s}if(r){let e=_-r.x,t=v-r.y,n=Math.hypot(e,t)||1;if(n<s&&(b=Math.max(b,(1-n/s)**1.4*c)),n<KH){let i=(1-n/KH)**2*(10+Math.min(10,r.speed/120));x+=e/n*i,S+=t/n*i}}let T=0;if(l>=0){let r=l-(d-1-e+.5+.35*Math.sin(n*.55+t*2.1)+.2*Math.sin(n*1.31-t*1.3));r>0&&(T=.16),r>-1&&r<1&&(b=Math.max(b,(1-Math.abs(r))*(.45+.35*Math.sin(t*3+this.phase[g]))))}f[g]=Math.max(T,b>y?y+(b-y)*a:y),p[g*2]+=(x-p[g*2])*o,p[g*2+1]+=(S-p[g*2+1])*o,m=Math.max(m,f[g]),h=Math.max(h,Math.abs(p[g*2]),Math.abs(p[g*2+1]))}return this.settled=m<.04&&h<.05,this.waves=this.waves.filter(t=>(t.front+=t.dir*t.speed*e,t.front>=-4&&t.front<=t.span+4)),this.ripples=this.ripples.filter(t=>(t.t+=e,t.r+=t.speed*e*(1-.35*t.t/t.life),t.t<t.life)),this.exit&&(this.exit.t+=e,this.exit.t>=1.1&&(this.exit=null,this.done=!0)),!0}draw(e,t){if(e.clearRect(0,0,this.w,this.h),this.done)return;let{cols:n,rows:r,energy:i,offset:a,mask:o}=this,s=t.dark?.17:.14;e.lineWidth=1;for(let c=0;c<r;c++)for(let r=0;r<n;r++){let l=c*n+r,[u,d]=this.center(r,c),f=u+a[l*2],p=d+a[l*2+1],m=i[l],h=o[l];if(m<.04){e.fillStyle=t.fg,e.globalAlpha=s*h,e.fillRect(f-1,p-1,2,2);continue}let g=2+m*19,_=Math.max(1,6-m*3);e.beginPath(),e.roundRect(f-g/2,p-g/2,g,g,_),e.fillStyle=t.accent,e.globalAlpha=(.12+m*.22)*h,e.fill(),e.strokeStyle=t.accent,e.globalAlpha=m*.5*h,e.stroke()}this.exit&&this.drawExit(e,t),e.globalAlpha=1}drawExit(e,t){let n=this.exit,r=Math.min(1,n.t/WH),i=(1-(1-r)**3)*n.reach,a=new Path2D;for(let e=0;e<=180;e++){let t=e/180*YH,r=i*(1+.06*Math.sin(3*t+n.phase+n.t*1.5)+.03*Math.sin(5*t-n.phase*1.7-n.t*2.2)),o=n.x+Math.cos(t)*r,s=n.y+Math.sin(t)*r;e?a.lineTo(o,s):a.moveTo(o,s)}a.closePath(),e.globalAlpha=1,e.globalCompositeOperation=`destination-out`,e.fill(a),e.globalCompositeOperation=`source-over`,e.strokeStyle=t.accent,e.lineWidth=1.4,e.globalAlpha=.55*(1-r)**.7,e.stroke(a)}},$H=90;function eU(){let e=getComputedStyle(document.documentElement);return{fg:e.getPropertyValue(`--text-primary`).trim(),accent:e.getPropertyValue(`--accent-solid`).trim(),dark:document.documentElement.getAttribute(`data-theme`)===`dark`}}function tU(e,t,n){let r=e.getBoundingClientRect();return r.width?{cx:r.left-t.left+r.width/2,cy:r.top-t.top+r.height/2,rx:r.width/2+n,ry:r.height/2+n+10}:null}function nU({activity:e,progress:t=0,pulse:n,docked:r,contentRef:i,composerRef:a}){let o=(0,V.useRef)(null),s=(0,V.useRef)(null),c=(0,V.useRef)(null),l=(0,V.useRef)(()=>{}),u=(0,V.useRef)(()=>{}),d=(0,V.useRef)(r),f=(0,V.useRef)({value:n,at:0});d.current=r,(0,V.useEffect)(()=>{let e=o.current,t=e?.parentElement;if(!e||!t)return;let n=e.getContext(`2d`);if(!n){F.ui.warn(`New-chat background is off: the browser gave no 2D canvas context (often low graphics memory).`);return}c.current=t;let r=new QH;s.current=r;let f=typeof window.matchMedia==`function`?window.matchMedia(Oz):null,p=eU(),m=0,h=0,g=!1,_=``,v={x:0,y:0,at:0,speed:0},y=()=>r.draw(n,p),b=(e,t=!1)=>{let n=d.current?a.current:i.current,r=(n&&tU(n,e,d.current?24:40))??{cx:e.width/2,cy:e.height/2,rx:1,ry:1},o=`${Math.round(r.cx)},${Math.round(r.cy)},${Math.round(r.rx)},${Math.round(r.ry)}`;return t||o!==_?(_=o,r):null},x=()=>{let i=t.getBoundingClientRect();if(!i.width||!i.height)return;let a=Math.min(2,window.devicePixelRatio||1);e.width=Math.round(i.width*a),e.height=Math.round(i.height*a),n.setTransform(a,0,0,a,0,0),r.resize(i.width,i.height,b(i,!0)),y()},S=e=>{if(m=requestAnimationFrame(S),e-h<31.833333333333336)return;let n=Math.min(.1,(e-h)/1e3);h=e;let i=b(t.getBoundingClientRect());i&&r.setHole(i),e-v.at>80&&(v.speed*=.8),(r.step(n)||i)&&y(),r.cleared&&w()},C=()=>{g||document.hidden||f?.matches||r.cleared||(g=!0,h=performance.now(),m=requestAnimationFrame(S))},w=()=>{g=!1,cancelAnimationFrame(m)};l.current=C,u.current=()=>{let e=b(t.getBoundingClientRect());e&&r.setHole(e),g||y()};let T=()=>document.hidden?w():C(),E=()=>{w(),y(),C()},D=()=>{p=eU(),y()},O=e=>{let n=t.getBoundingClientRect(),i=e.clientX-n.left,a=e.clientY-n.top,o=performance.now();if(v.at&&o>v.at){let e=Math.hypot(i-v.x,a-v.y)/((o-v.at)/1e3);v.speed+=(Math.min(4e3,e)-v.speed)*.35}Object.assign(v,{x:i,y:a,at:o});let s=e.target instanceof Element&&e.target.closest(`button, a, input, textarea, .composer`);r.setPointer(i,a,(e.buttons&1)==1&&!s,v.speed)},k=()=>{v.at=0,v.speed=0,r.clearPointer()},ee=typeof ResizeObserver>`u`?null:new ResizeObserver(x);ee?.observe(t,{box:`border-box`});let te=new MutationObserver(D);return te.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`,`data-palette`,`style`]}),document.addEventListener(`visibilitychange`,T),f?.addEventListener(`change`,E),t.addEventListener(`pointermove`,O),t.addEventListener(`pointerleave`,k),x(),C(),()=>{w(),ee?.disconnect(),te.disconnect(),document.removeEventListener(`visibilitychange`,T),f?.removeEventListener(`change`,E),t.removeEventListener(`pointermove`,O),t.removeEventListener(`pointerleave`,k),s.current=null,l.current=()=>{},u.current=()=>{}}},[i,a]);let p=(0,V.useCallback)(()=>{let e=c.current,t=a.current;if(!e||!t)return null;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return[r.left-n.left+r.width/2,r.top-n.top+r.height/2]},[a]);return(0,V.useEffect)(()=>{let t=s.current;if(t){if(t.setActivity(e),e===`sending`){let e=p();e&&t.dissolve(...e)}else t.dissolving&&(t.restore(),l.current())}},[e,p]),(0,V.useEffect)(()=>{s.current?.setProgress(t)},[t]),(0,V.useEffect)(()=>{u.current()},[r]),(0,V.useEffect)(()=>{let e=f.current;if(n===e.value)return;let t=performance.now();if(e.value=n,t-e.at<$H)return;e.at=t;let r=p();r&&s.current?.ripple(...r,.45)},[n,p]),I(`canvas`,{ref:o,className:`npu-backdrop`,"aria-hidden":`true`})}async function rU(e,t,n){let r=`${dn()}${t}`,i={};e!==`GET`&&(i[`X-Gaia-UI`]=`1`),n!==void 0&&(i[`Content-Type`]=`application/json`);let a={method:e,headers:Object.keys(i).length>0?i:void 0,body:n===void 0?void 0:JSON.stringify(n)},o=await fetch(r,a);if(!o.ok){let e=await o.text().catch(()=>``),t=e;try{t=JSON.parse(e).detail||e}catch{}throw Error(t||`Memory API error (HTTP ${o.status})`)}if(o.status!==204&&(o.headers.get(`content-type`)||``).includes(`application/json`))return o.json()}function iU(e){let t=[];for(let[n,r]of Object.entries(e))if(r!=null&&r!==``){if(Array.isArray(r))for(let e of r)t.push(`${encodeURIComponent(n)}=${encodeURIComponent(String(e))}`);else t.push(`${encodeURIComponent(n)}=${encodeURIComponent(String(r))}`)}return t.length?`?${t.join(`&`)}`:``}function aU(){return rU(`GET`,`/memory/stats`)}function oU(e=30){return rU(`GET`,`/memory/activity?days=${e}`)}function sU(e={}){return rU(`GET`,`/memory/knowledge${iU(e)}`)}function cU(e){return rU(`POST`,`/memory/knowledge`,e)}function lU(e,t){return rU(`PUT`,`/memory/knowledge/${encodeURIComponent(e)}`,t)}function uU(e){return rU(`DELETE`,`/memory/knowledge/${encodeURIComponent(e)}`)}function dU(){return rU(`GET`,`/memory/entities`)}function fU(){return rU(`GET`,`/memory/tools`)}function pU(e=20){return rU(`GET`,`/memory/conversations?limit=${e}`)}function mU(e,t=20){return rU(`GET`,`/memory/conversations/search?query=${encodeURIComponent(e)}&limit=${t}`)}function hU(e){return rU(`GET`,`/memory/conversations/${encodeURIComponent(e)}`)}function gU(e=7){return rU(`GET`,`/memory/upcoming?days=${e}`)}function _U(){return rU(`GET`,`/memory/embedding-coverage`)}function vU(){return rU(`POST`,`/memory/consolidate`)}function yU(){return rU(`POST`,`/memory/rebuild-embeddings`)}function bU(){return rU(`POST`,`/memory/reconcile`)}function xU(){return rU(`POST`,`/memory/rebuild-fts`)}function SU(){return rU(`POST`,`/memory/refresh-system-context`)}function CU(){return new EventSource(`${dn()}/memory/stream-discovery`)}function wU(e){return new EventSource(`${dn()}/memory/stream-inference?include_browser=${e}`)}function TU(e){return rU(`POST`,`/memory/commit-discovery`,{items:e})}function EU(e){return rU(`POST`,`/memory/commit-inference`,{insights:e})}function DU(){return rU(`GET`,`/memory/settings`)}function OU(e){return rU(`PUT`,`/memory/settings`,e)}function kU(){return rU(`GET`,`/memory/embedder`)}function AU(e){return rU(`PUT`,`/memory/embedder`,{device:e})}function jU(){return rU(`DELETE`,`/memory/all`)}function MU(){return rU(`POST`,`/memory/reinitialize`)}function NU(){return rU(`GET`,`/goals/health`)}function PU(){return rU(`POST`,`/goals/store/reset`)}function FU(){return rU(`GET`,`/goals/stats`)}function IU(e={}){return rU(`GET`,`/goals${iU(e)}`)}function LU(e){return rU(`POST`,`/goals`,e)}function RU(e){return rU(`PUT`,`/goals/${encodeURIComponent(e)}/approve`)}function zU(e){return rU(`PUT`,`/goals/${encodeURIComponent(e)}/reject`)}function BU(e){return rU(`PUT`,`/goals/${encodeURIComponent(e)}/cancel`)}function VU(e){return rU(`DELETE`,`/goals/${encodeURIComponent(e)}`)}function HU({disabled:e}){let t=R(),n=B(e=>e.draftPrivate),r=B(e=>e.setDraftPrivate),i=B(e=>e.settingsSection!==null),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(!1),d=(0,V.useRef)(null),f=(0,V.useCallback)(()=>u(!1),[]);if((0,V.useEffect)(()=>{if(i)return;let e=!1;return DU().then(t=>{e||(o(t.memory_enabled),c(!1))}).catch(t=>{e||(F.ui.error(`Could not read the memory setting for the Private chip`,t),o(null),c(!0))}),()=>{e=!0}},[i]),(0,V.useEffect)(()=>{a===!1&&n&&r(!1)},[a,n,r]),a===!1)return z(`button`,{type:`button`,className:`composer-chip composer-chip-memory is-unavailable`,disabled:!0,"aria-label":t(`composer.memoryOff`),title:t(`composer.memoryOffTitle`),children:[I(Ni,{size:13,"aria-hidden":`true`}),I(`span`,{className:`composer-chip-label`,dir:`auto`,children:t(`composer.memoryOff`)})]});let p=e=>{r(e),u(!1)},m=[{priv:!1,Icon:Fi,label:t(`composer.remember`),note:t(s?`composer.memoryUnknownTitle`:`composer.rememberNote`)},{priv:!0,Icon:Ni,label:t(`composer.privateChat`),note:t(`composer.privateChatNote`)}];return z(`div`,{className:`composer-chip-wrap`,children:[z(`button`,{ref:d,type:`button`,className:`composer-chip composer-chip-memory${n?` is-on`:``}`,onClick:()=>u(e=>!e),disabled:e,"aria-haspopup":`dialog`,"aria-expanded":l,"aria-label":t(`composer.memoryChipAria`,{state:t(n?`composer.private`:s?`composer.memoryUnknown`:`composer.memoryOn`)}),title:t(n?`composer.privateChatNote`:s?`composer.memoryUnknownTitle`:`composer.rememberNote`),children:[I(n?Ni:Fi,{size:13,"aria-hidden":`true`}),I(`span`,{className:`composer-chip-label`,dir:`auto`,children:t(n?`composer.private`:s?`composer.memoryUnknown`:`composer.memoryOn`)}),I(Gr,{size:12,"aria-hidden":`true`})]}),I(Gs,{open:l,onClose:f,anchor:d,label:t(`composer.memoryMenu`),children:m.map(({priv:e,Icon:t,label:r,note:i})=>z(`button`,{type:`button`,className:`popover-item`,onClick:()=>p(e),"aria-pressed":n===e,children:[I(`span`,{className:`popover-item-check`,"aria-hidden":`true`,children:I(n===e?Vr:t,{size:13})}),z(`span`,{className:`popover-item-body`,children:[I(`span`,{className:`popover-item-title`,children:r}),I(`span`,{className:`popover-item-note`,children:i})]})]},String(e)))})]})}var UU=[{icon:Ur,label:`cards.try.recipe`,prompt:`cards.try.recipePrompt`},{icon:Ti,label:`cards.try.workout`,prompt:`cards.try.workoutPrompt`},{icon:Ps,label:`cards.try.howTo`,prompt:`cards.try.howToPrompt`},{icon:Fa,label:`cards.try.checklist`,prompt:`cards.try.checklistPrompt`},{icon:Ua,label:`cards.try.trip`,prompt:`cards.try.tripPrompt`},{icon:Mo,label:`cards.try.bill`,prompt:`cards.try.billPrompt`},{icon:Nr,label:`cards.try.loan`,prompt:`cards.try.loanPrompt`}];function WU({onPick:e,disabled:t}){let n=R();return z(`div`,{className:`try-chips`,role:`group`,"aria-label":n(`cards.tryGroup`),children:[I(`span`,{className:`try-chips-label`,"aria-hidden":`true`,children:n(`cards.try`)}),UU.map(({icon:r,label:i,prompt:a})=>{let o=n(i),s=n.bare(a);return z(`button`,{type:`button`,className:`try-chip`,title:s,"aria-label":`${o}: ${s}`,onClick:()=>e(s),disabled:t,children:[I(r,{size:14,"aria-hidden":`true`}),o]},i)})]})}var GU=1e3;function KU(){let[e,t]=(0,V.useState)(null);return(0,V.useEffect)(()=>{let e=!1,n,r=a=>{e||(a.state===`warming`?(t({seconds:Math.floor(a.elapsed_seconds??0),model:a.model??null,device:a.device??null}),n=setTimeout(()=>{ct().then(r,i)},GU)):t(null))},i=n=>{e||(F.system.warn(`Warm-up status unavailable`,n),t(null))};return mt().then(r,i),()=>{e=!0,n&&clearTimeout(n)}},[]),e}function qU(e){return e===`gpu`?`your GPU`:e===`npu`?`your NPU`:e===`cpu`?`the CPU`:null}function JU(e){return e<1?`under 1 GB`:`${e.toFixed(1)} GB`}var YU=15e3;function XU(e=new Date,t=gt){let n=e.getHours();return t(`newChat.greeting.${n<5?`evening`:n<12?`morning`:n<18?`afternoon`:`evening`}`)}var ZU={gpu:`device.gpu`,npu:`device.npu`,cpu:`device.cpu`};function QU({seconds:e,model:t,device:n},r=gt){if(!t)return r(`newChat.warmup.ready`,{s:e});let i=xc(t),a=n?ZU[n]:void 0;if(a)return r(`newChat.warmup.loadingOn`,{model:i,where:u(a),s:e});let o=qU(n);return o?r(`newChat.warmup.loadingOn`,{model:i,where:o,s:e}):r(`newChat.warmup.loading`,{model:i,s:e})}function $U({detail:e,onRetry:t}){let n=R(),[r,i]=(0,V.useState)(!1);return z(`div`,{className:`new-chat-note`,children:[z(`p`,{children:[n(`newChat.assistantUnavailable`),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:t,children:n(`newChat.tryAgain`)})]}),z(`button`,{type:`button`,className:`new-chat-details`,"aria-expanded":r,onClick:()=>i(e=>!e),children:[I(Yr,{size:12,className:r?`is-open`:``,"aria-hidden":`true`}),` `,n(`newChat.details`)]}),r&&I(`pre`,{className:`new-chat-details-text`,children:e})]})}function eW(){let{documents:e,draftDocumentIds:t,addDraftDocuments:n}=B.getState();n(e.filter(e=>e.indexing_status===`complete`&&!t.includes(e.id)).map(e=>e.id))}function tW(){let e=R(),[t,n]=(0,V.useState)(!1),r=B(e=>e.documents),i=B(e=>e.draftDocumentIds),a=B(e=>e.removeDraftDocument),o=B(e=>e.setShowDocLibrary),s=r.filter(e=>i.includes(e.id)),c=r.filter(e=>e.indexing_status===`complete`&&!i.includes(e.id));if(!s.length&&!c.length)return null;let l=c.length,u=s.length-5,d=t||u<=0?s:s.slice(0,5);return z(`div`,{className:`new-chat-docs`,children:[s.length>0&&I(`ul`,{id:`new-chat-doc-list`,className:`new-chat-doc-list${t?` is-expanded`:``}`,"aria-label":e(`newChat.docs.forChat`),children:d.map(t=>z(`li`,{className:`new-chat-doc`,children:[I(Yi,{size:12,"aria-hidden":`true`}),I(`span`,{dir:`ltr`,children:t.filename}),I(`button`,{type:`button`,className:`new-chat-doc-remove`,onClick:()=>a(t.id),"aria-label":e(`newChat.docs.dontAttach`,{name:t.filename}),children:I(Is,{size:12,"aria-hidden":`true`})})]},t.id))}),u>0&&I(`button`,{type:`button`,className:`link-btn new-chat-doc-toggle`,"aria-expanded":t,"aria-controls":`new-chat-doc-list`,onClick:()=>n(e=>!e),children:t?e(`newChat.docs.fewer`):e(`newChat.docs.hidden`,{n:u})}),l>0&&z(`p`,{className:`new-chat-note`,children:[s.length?e.plural(`newChat.docs.more`,l):e.plural(`newChat.docs.library`,l),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:eW,children:l===1?e(`newChat.docs.attachIt`):e(`newChat.docs.attachAll`,{n:l})}),l>1&&z(P.Fragment,{children:[` · `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>o(!0),children:e(`newChat.docs.choose`)})]})]})]})}function nW({error:e}){let t=R(),n=B(e=>e.openSettings);return z(`div`,{className:`new-chat-setup-failed`,role:`alert`,children:[I(`p`,{className:`new-chat-setup-failed-title`,children:t(`newChat.setupFailed.title`)}),I(`p`,{className:`new-chat-setup-failed-error`,children:e}),z(`p`,{children:[t(`newChat.setupFailed.hint`),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>n(`model`),children:t(`newChat.setupFailed.choose`)})]})]})}function rW({onSend:e,initialText:t=``,focusRequest:n=0,agentMissing:r=!1,agentRefused:i=!1}){let s=R(),c=B(e=>hI(e.systemStatus)),l=B(e=>e.systemStatus?.download_progress??null),u=B(e=>e.systemStatus?.model_loaded?null:e.systemStatus?.setup_error??null),d=_c(e=>!!e.active?.remote),[f,p]=DH(a,t),[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)(i),[v,y]=(0,V.useState)(!1),[b,x]=(0,V.useState)(null),[S,C]=(0,V.useState)(null),w=(0,V.useRef)(null),T=(0,V.useRef)(null),E=(0,V.useRef)(null),D=iH(),O=KU();yc();let k=(0,V.useRef)(!0),te=(0,V.useCallback)((e=!1)=>{e||C(null),ee().then(e=>{k.current&&(x(e),C(e.skills_error??null))}).catch(e=>{F.api.warn(`New-chat start screen unavailable`,e),k.current&&C(CM(e))})},[]);(0,V.useEffect)(()=>(k.current=!0,te(),()=>{k.current=!1}),[te]),(0,V.useEffect)(()=>{o().then(e=>B.getState().setDocuments(e.documents||[])).catch(e=>F.api.warn(`Document library unavailable; not offering its documents`,e))},[]),(0,V.useEffect)(()=>{if(S)return SH(()=>te(!0),YU)},[S,te]);let ne=(0,V.useRef)(!1),A=(0,V.useRef)([]),re=(0,V.useCallback)(async(t,n=``)=>{if(t){if(ne.current)A.current.push(n||t),p(``);else{ne.current=!0,y(!0),h(null),_(!1),p(``);try{let n=await e(t);D.clear();let r=A.current.splice(0),i=B.getState().currentSessionId;if(r.length>0&&i){let e=(e,t)=>n===!1?[...e,{...ze(t,`failed`),error:`The first message was not sent.`}]:xt(e,t,`queued`);B.getState().updateQueue(i,t=>r.reduce(e,t))}}catch(e){let r=A.current.splice(0);p([n||t,...r].join(`
|
|
204
204
|
|
|
205
|
-
`)),e instanceof SO?_(!0):h(CM(e))}finally{ne.current=!1,y(!1)}}}},[D,e]),ie=(0,V.useCallback)(()=>re(D.compose(f.trim()),f.trim()),[D,re,f]);(0,V.useEffect)(()=>{n&&w.current?.focus()},[n]),(0,V.useEffect)(()=>{let e=w.current;t&&e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},[t]);let ae=v,j=(0,V.useRef)(null);(0,V.useLayoutEffect)(()=>{let e=T.current;if(!e)return;typeof e.getAnimations==`function`&&e.getAnimations().forEach(e=>e.cancel());let t=e.getBoundingClientRect().top,n=j.current;if(j.current={top:t,docked:ae},!n||n.docked===ae||Az()||typeof e.animate!=`function`)return;let r=getComputedStyle(document.documentElement).getPropertyValue(`--ease`).trim();if(!r)throw Error(`Motion token --ease is not set; check styles/index.css.`);e.animate([{transform:`translateY(${n.top-t}px)`},{transform:`none`}],{duration:kz(`--duration-spring`),easing:r})});let oe=(0,V.useRef)(``),se=(0,V.useCallback)(e=>{let t=oe.current,n=(t&&f.endsWith(t)?f.slice(0,-t.length):f).trimEnd();oe.current=e,p(n?`${n}\n\n${e}`:e),w.current?.focus()},[f,p]),ce=l?.state===`starting`||l?.state===`downloading`,le=v?`sending`:ce?`download`:c||O!==null?`loading`:`idle`,ue=b?.working_folder;return z(`main`,{className:`new-chat${ae?` is-docked`:``}`,"aria-label":s(`newChat.label`),children:[I(nU,{activity:le,progress:(l?.percent??0)/100,pulse:f.length,docked:ae,contentRef:T,composerRef:E}),I(`div`,{className:`new-chat-actions`,children:I(mV,{})}),z(`div`,{className:`new-chat-inner`,ref:T,children:[I(`h1`,{className:`new-chat-greeting`,"aria-hidden":ae,children:
|
|
206
|
-
`),T=(0,V.useCallback)(()=>{let e=y.current;e&&b.current&&(e.scrollTop=e.scrollHeight,x.current=e.scrollTop)},[]);(0,V.useEffect)(T,[w,T]);let E=C.length>0;(0,V.useEffect)(()=>{let e=y.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(T);return t.observe(e),e.firstElementChild&&t.observe(e.firstElementChild),()=>t.disconnect()},[E,T]);let O=(0,V.useCallback)(async()=>{try{await navigator.clipboard.writeText(w),g({ok:!0,text:n(`logs.copied`)})}catch(e){g({ok:!1,text:n(`logs.copyFailed`,{error:
|
|
207
|
-
`]},t))})}),(r?.dropped??0)>0&&I(`p`,{className:`log-viewer-hint`,children:n(`logs.older`)}),h&&I(`p`,{className:h.ok?`settings-ok`:`log-viewer-warning`,role:h.ok?`status`:`alert`,children:h.text})]})}function vW(){let e=R(),[t,n]=(0,V.useState)(!1),[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(null),s=(0,V.useCallback)(async()=>{n(!0),o(null),i(null);try{let e=await E(),t=await Le(e.name),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=e.name,r.click(),setTimeout(()=>URL.revokeObjectURL(n),6e4),i(e)}catch(t){o(e(`logs.saveAllFailed`,{error:hW(t)}))}finally{n(!1)}},[e]);return z(`div`,{className:`log-viewer-save-all`,children:[z(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void s(),disabled:t,children:[t?I(La,{size:13,className:`spin`,"aria-hidden":`true`}):I(lr,{size:13,"aria-hidden":`true`}),e(`logs.saveAll`)]}),I(`span`,{className:`log-viewer-hint`,children:e(`setup.logs.reportNote`)}),r&&z(`p`,{className:`log-viewer-hint`,role:`status`,children:[e(`logs.savedAll`,{size:WO(r.size_bytes)}),` `,I(`bdi`,{dir:`ltr`,children:r.path})]}),a&&I(`p`,{className:`log-viewer-warning`,role:`alert`,children:a})]})}function yW(){let e=R(),t=qs(e=>e.open),n=qs(e=>e.source),r=qs(e=>e.show),i=qs(e=>e.hide),a=(0,V.useRef)(null),o=(0,V.useRef)(null),[s,c]=(0,V.useState)({}),[l,u]=(0,V.useState)(null);if(pt(t,i),on(a,t),sW(a,t,()=>o.current),(0,V.useEffect)(()=>{t&&oe().then(e=>c(Object.fromEntries(e.sources.map(e=>[e.id,e.files??[]])))).catch(e=>console.warn(`[LogsDialog] could not list log files`,e))},[t]),(0,V.useEffect)(()=>{u(null)},[n]),!t)return null;let d=s[n]??[];return(0,Mj.createPortal)(I(`div`,{className:`log-viewer-overlay`,onMouseDown:e=>{e.target===e.currentTarget&&i()},children:z(`div`,{ref:a,className:`log-viewer`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`log-viewer-title`,children:[z(`div`,{className:`log-viewer-head`,children:[I(`h2`,{id:`log-viewer-title`,className:`log-viewer-title`,children:e(`logs.title`)}),I(`button`,{ref:o,type:`button`,className:`log-viewer-close`,onClick:i,"aria-label":e(`logs.close`),title:e(`logs.close`),children:I(Is,{size:16,"aria-hidden":`true`})})]}),I(`div`,{className:`log-viewer-tabs`,role:`tablist`,"aria-label":e(`logs.title`),children:Ks.map(t=>I(`button`,{type:`button`,role:`tab`,"aria-selected":t===n,className:t===n?`is-active`:``,onClick:()=>r(t),children:t===`gaia`?I(`bdi`,{children:e(dW[t])}):e(dW[t])},t))}),d.length>1&&z(`label`,{className:`log-viewer-file`,children:[e(`logs.file`),I(`select`,{dir:`ltr`,value:l??d[0].name,onChange:e=>u(e.target.value),children:d.map(e=>z(`option`,{value:e.name,children:[e.name,e.size_bytes==null?``:` (${lW}${SL(e.size_bytes)}${uW})`]},e.name))})]}),I(`div`,{role:`tabpanel`,className:`log-viewer-panel`,children:I(_W,{source:n,file:l},`${n}:${l??``}`)}),I(`p`,{className:`log-viewer-hint`,children:e(`logs.privacy`)}),I(vW,{})]})}),document.body)}var bW=[{label:`shortcuts.newChat`,keys:`Mod+Shift+O`},{label:`shortcuts.search`,keys:`Mod+K`},{label:`shortcuts.sidebar`,keys:`Mod+B`},{label:`shortcuts.settings`,keys:`Mod+,`},{label:`shortcuts.sheet`,keys:`Mod+/`},{label:`shortcuts.browserPane`,keys:`Mod+Shift+B`,desktopOnly:!0},{label:`shortcuts.send`,keys:`Enter`},{label:`shortcuts.newLine`,keys:`Shift+Enter`},{label:`shortcuts.editLast`,keys:`↑`},{label:`shortcuts.stop`,keys:`Esc`}];function xW(){let e=!!wB();return bW.filter(t=>e||!t.desktopOnly)}function SW({onClose:e}){let t=R(),n=(0,V.useRef)(null);return pt(!0,e),on(n,!0),sW(n,!0),I(`div`,{ref:n,className:`modal-overlay`,onClick:e,role:`dialog`,"aria-modal":`true`,"aria-label":t(`shortcuts.title`),children:z(`div`,{className:`modal-panel shortcuts-dialog`,onClick:e=>e.stopPropagation(),children:[z(`div`,{className:`modal-header`,children:[I(`h3`,{children:t(`shortcuts.title`)}),I(`button`,{type:`button`,className:`btn-icon`,onClick:e,"aria-label":t(`shortcuts.close`),children:I(Is,{size:18,"aria-hidden":`true`})})]}),I(`dl`,{className:`modal-body shortcuts-list`,children:xW().map(({label:e,keys:n})=>z(`div`,{className:`shortcuts-row`,children:[I(`dt`,{children:t(e)}),I(`dd`,{children:I(`kbd`,{dir:`ltr`,children:Yl(n)})})]},e))})]})})}function CW(e){let t=e?.reason;return t===`needs_key`||t===`bad_key`}function wW({provider:e,limit:t,picked:n=null,onPick:r,pickDisabled:i=!1,onDefault:a}){let o=R(),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(null),d=(0,V.useRef)(a);if(d.current=a,(0,V.useEffect)(()=>{let t=!0;return c(null),u(null),d.current?.(null),Ee(e).then(e=>{t&&(c(e),d.current?.(e.models[0]?.model??null))}).catch(e=>{t&&u(e instanceof Error?e.message:String(e))}),()=>{t=!1}},[e]),l)return I(`p`,{className:`settings-error`,role:`alert`,children:o(`settings.price.loadFailed`,{reason:l})});if(!s)return z(`p`,{className:`settings-hint`,children:[I(La,{size:13,className:`spin`}),` `,o(`settings.price.loading`)]});if(s.models.length===0)return z(`p`,{className:`settings-hint cloud-prices-note`,children:[o(`settings.price.unknownSentence`),` `,I(`bdi`,{children:s.note})]});let f=t?s.models.slice(0,t):s.models,p=n?s.models.find(e=>e.model===n&&!f.includes(e)):void 0,m=p?[...f,p]:f,h=n??m[0]?.model,g=r!==void 0;return z(`div`,{className:`cloud-prices`,"aria-label":o(`settings.model.prices`),children:[g&&I(`p`,{className:`cloud-prices-legend`,id:`cloud-prices-legend`,children:o(`settings.price.pickLegend`)}),I(`ul`,{className:`cloud-prices-list${g?` is-pickable`:``}`,role:g?`radiogroup`:void 0,"aria-labelledby":g?`cloud-prices-legend`:void 0,children:m.map((t,n)=>{let a=z(`span`,{className:`cloud-prices-name`,children:[I(`bdi`,{children:t.name}),n===0&&g&&z(`span`,{className:`cloud-prices-default`,children:[` · `,o(`settings.price.default`)]}),t.note&&z(`span`,{className:`cloud-prices-note`,children:[` · `,I(`bdi`,{children:t.note})]})]});return z(`li`,{className:g&&h===t.model?`is-chosen`:void 0,children:[g?z(`label`,{className:`cloud-prices-pick`,children:[I(`input`,{type:`radio`,name:`cloud-model-${e}`,value:t.model,checked:h===t.model,disabled:i,onChange:()=>r(t.model)}),a]}):a,I(`span`,{className:`cloud-prices-price`,children:HL(t.price,o)})]},t.model)})}),z(`span`,{className:`settings-hint`,children:[I(`bdi`,{children:s.source}),`. `,o(`settings.price.payProvider`)]})]})}function TW(){return au(Oz)}function EW(e,t=150){let n=TW(),[r,i]=(0,V.useState)(e),a=(0,V.useRef)(e);return(0,V.useEffect)(()=>{if(n||typeof requestAnimationFrame!=`function`){a.current=e,i(e);return}let r=a.current,o=performance.now(),s=0,c=n=>{let l=Math.min(1,(n-o)/t),u=1-(1-l)**3,d=r+(e-r)*u;a.current=d,i(d),l<1&&(s=requestAnimationFrame(c))};return s=requestAnimationFrame(c),()=>cancelAnimationFrame(s)},[e,t,n]),r}function DW(e,t){let[n,r]=(0,V.useState)(e);return(0,V.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}function OW(){let[e,t]=(0,V.useState)(()=>typeof document>`u`||document.visibilityState!==`hidden`);return(0,V.useEffect)(()=>{let e=()=>t(document.visibilityState!==`hidden`);return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),e}var kW=180;function AW({open:e,children:t}){let[n,r]=(0,V.useState)(e),[i,a]=(0,V.useState)(e),o=(0,V.useRef)(t);return e&&(o.current=t),(0,V.useEffect)(()=>{if(e){r(!0);let e=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(e)}a(!1);let t=setTimeout(()=>r(!1),kW);return()=>clearTimeout(t)},[e]),n?I(`div`,{className:`reveal${i?` is-open`:``}`,"aria-hidden":!e||void 0,children:I(`div`,{className:`reveal-inner`,children:e?t:o.current})}):null}var jW=e=>e?.catalog??[],MW=e=>e.roles.includes(`vision`),NW=e=>e.roles.includes(`embedding`),PW=e=>e.recipe===`flm`,FW=e=>e.fits===!1&&(e.fit_code===`npu`||e.fit_code===`backend`),IW=e=>e.support===null,LW=e=>e?.feature_tier!==`compact`;function RW(e,t){let n=e.find(e=>e.id===t.defaultChat);return n&&PW(n)||t.vision===`none`?null:t.vision?t.vision:n?.reads_images?n.id:e.find(e=>MW(e)&&e.gaia_model)?.id??null}function zW(e,t){let n=RW(t,e),r=new Set(e.ticked),i=new Set(e.unticked);for(let a of t)MW(a)&&a.id!==e.defaultChat&&(a.id===n?(r.add(a.id),i.delete(a.id)):a.downloaded||(r.delete(a.id),i.add(a.id)));return{...e,ticked:r,unticked:i}}function BW(e,t,n){let r=new Set(e.ticked),i=t.find(t=>t.id===e.defaultChat);i&&!i.downloaded&&r.delete(i.id);let a=t.find(e=>e.id===n);if(a?.downloaded||r.add(n),!LW(a))for(let e of t)e.roles.includes(`image_creation`)&&r.delete(e.id);return zW({...e,ticked:r,defaultChat:n,chatChosen:!0,vision:null},t)}function VW(e,t,n){return zW({...e,vision:n},t)}function HW(e,t){if(t.vision===`none`)return null;let n=RW(e,t),r=e.find(e=>e.id===t.defaultChat);return r&&PW(r)||n===(r?.reads_images?r.id:e.find(e=>MW(e)&&e.gaia_model)?.id)?null:n}function UW(e){return e.filter(e=>e.gaia_model&&(e.planned||e.recommended||e.downloaded||e.partial))}function WW(e){let t=new Set(UW(e).map(e=>e.id));return e.filter(e=>e.gaia_model&&!t.has(e.id))}function GW(e){return e.filter(e=>!e.gaia_model&&e.downloaded)}function KW(e){let t=jW(e),n=new Set(t.filter(e=>e.selected||e.gaia_model&&e.downloaded&&!e.skipped).map(e=>e.id)),r=!t.find(t=>t.id===e.chat_model.id)?.reads_images&&t.some(e=>MW(e)&&e.gaia_model&&e.skipped);return zW({ticked:n,defaultChat:e.chat_model.id,unticked:new Set,chatChosen:e.chat_model.user_set,vision:e.vision_model??(r?`none`:null)},t)}function qW(e,t){return e.filter(e=>e.chat_choice&&(t.has(e.id)||e.downloaded))}function JW(e,t,n,r){let i=new Set(e.ticked),a=new Set(e.unticked);r?(i.add(n),a.delete(n)):(i.delete(n),a.add(n));let o=qW(t,i),s=e.defaultChat;if(!s||!o.some(e=>e.id===s)){let e=t.find(e=>e.id===n);s=r&&e?.chat_choice?n:(o.find(e=>e.recommended)??o[0])?.id??null}return{...e,ticked:i,defaultChat:s,unticked:a}}function YW(e,t,n){let r=t.find(e=>e.id===n)?.downloaded;return{...e,defaultChat:n,chatChosen:!0,ticked:r?e.ticked:new Set([...e.ticked,n])}}function XW(e){let t=jW(e),n=new Set(t.filter(e=>e.recommended||e.gaia_model&&e.downloaded).map(e=>e.id)),r=qW(t,n);return zW({ticked:n,defaultChat:e.recommended_model&&r.some(t=>t.id===e.recommended_model)?e.recommended_model:(r.find(e=>e.recommended)??r[0])?.id??null,unticked:new Set,chatChosen:!1,vision:null},t)}function ZW(e,t){return e.filter(e=>t.ticked.has(e.id)&&!e.downloaded).sort((e,t)=>(t.size_gb??0)-(e.size_gb??0))}function QW(e,t){let n=ZW(jW(e),t).map(e=>e.size_gb),r=n.every(e=>e!=null)?iG(n.reduce((e,t)=>e+t,0)):null,i=e.disk?.free_gb??null;return{downloadGb:r,freeGb:i,afterGb:r!=null&&i!=null?iG(i-r):null}}function $W(e,t){let{downloadGb:n,freeGb:r}=QW(e,t);return n==null||r==null||n<=r?null:{needGb:n,freeGb:r,freeUpGb:iG(n-r),drop:ZW(jW(e),t).find(e=>e.size_gb!=null&&n-e.size_gb<=r)??null}}function eG(e,t){return e.filter(e=>e.fits===!1&&(t.ticked.has(e.id)||e.id===t.defaultChat))}function tG(e,t){let n=[];for(let r of jW(e)){if(!r.planned){r.skipped&&t.ticked.has(r.id)&&n.push({id:r.id,skipped:!1});continue}if(r.id===e.chat_model.id){r.skipped&&n.push({id:r.id,skipped:!1});continue}let i=t.ticked.has(r.id);!i&&!r.skipped&&n.push({id:r.id,skipped:!0}),i&&r.skipped&&n.push({id:r.id,skipped:!1})}return n}function nG(e,t){return jW(e).filter(e=>t.ticked.has(e.id)&&!e.planned&&!e.downloaded).map(e=>e.id)}function rG(e,t){let n=(e.models??[]).filter(e=>e.state!==`skipped`);if(!t?.catalog||n.length===0)return e.overall;let r=0,i=0;for(let e of n){let n=t.catalog.find(t=>t.id===e.id),a=n?.downloaded?0:n?.size_gb==null?e.bytes_total:Math.min(e.bytes_total||1/0,n.size_gb*1e9),o=Math.max(0,e.bytes_total-a);i+=a,r+=e.state===`ready`||e.state===`verifying`?a:Math.min(a,Math.max(0,e.bytes_done-o))}return{bytes_done:r,bytes_total:i,speed_bps:e.overall?.speed_bps??0,eta_s:null,percent:i>0?Math.floor(r*100/i):100,failed:n.filter(e=>e.state===`failed`).length}}function iG(e){return Math.round(e*10)/10}var aG=6;function oG(e,t){let n=[];return e.chat_choice&&!NW(e)&&n.push(t(`setup.models.purpose.chat`)),MW(e)&&n.push(t(`setup.models.purpose.vision`)),NW(e)&&n.push(t(`setup.models.purpose.documents`)),e.roles.includes(`speech`)&&n.push(t(`setup.models.purpose.speech`)),e.roles.includes(`voice`)&&n.push(t(`setup.models.purpose.voice`)),e.roles.includes(`image_creation`)&&n.push(t(`setup.models.purpose.imageCreation`)),n}function sG(e,t){return NW(e)?t(`setup.models.line.documents`):MW(e)?t(`setup.models.line.vision`):e.roles.includes(`speech`)?t(`setup.models.line.speech`):e.roles.includes(`voice`)?t(`setup.models.line.voice`):e.roles.includes(`image_creation`)?t(`setup.models.line.imageCreation`):t(`setup.models.line.chat`)}function cG(e,t){return e.downloaded?t(`setup.models.status.onPc`):e.size_gb==null?t(`setup.models.status.sizeUnknown`):e.partial?t(`setup.models.status.partial`,{size:BO(e.size_gb)}):t(`setup.models.status.download`,{size:BO(e.size_gb)})}function lG(e,t){return e.fits!==!0||e.need_gb==null||e.capacity_gb==null?null:t(`setup.models.fit.ok`,{need:UO(e.need_gb),have:UO(e.capacity_gb)})}function uG(e,t){return e.fit_code===`npu`?t(`setup.models.warn.npu`):e.fit_code===`backend`?t(`setup.models.warn.backend`):e.need_gb!=null&&e.capacity_gb!=null?t(`setup.models.warn.tooBig`,{need:UO(e.need_gb),have:UO(e.capacity_gb)}):t(`setup.models.warn.tooBigNoNumbers`)}function dG(e,t,n,r){return!MW(e)&&!NW(e)||MW(e)&&!e.downloaded&&r?null:n===`settings`?e.downloaded?t(`settings.models.warn.kept`,{name:e.name}):t(MW(e)?`settings.models.warn.vision`:`settings.models.warn.documents`,{name:e.name}):t(MW(e)?`setup.models.warn.vision`:`setup.models.warn.documents`,{name:e.name})}function fG({entry:e,ticked:t,onToggle:n,disabled:r,progress:i,actions:a,place:o,imagesCovered:s}){let c=R(),l=(0,V.useId)(),u=e.fits===!1,d=t?null:dG(e,c,o,s),f=i?.state===`downloading`&&i.bytes_total>0,p=u?uG(e,c):d,m=[`${l}-status`,`${l}-note`,p?`${l}-warn`:null].filter(Boolean).join(` `);return z(`li`,{className:`mc-row${t?` is-ticked`:``}${p?` has-warning`:``}`,children:[z(`div`,{className:`mc-row-top`,children:[z(`label`,{className:`mc-row-main`,children:[I(`input`,{type:`checkbox`,className:`mc-input`,checked:t,disabled:r,onChange:e=>n(e.target.checked),"aria-describedby":m}),I(`span`,{className:`mc-box`,"aria-hidden":`true`,children:I(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,children:I(`path`,{className:`mc-tick`,d:`M3.5 8.5l3 3 6-7`})})}),z(`span`,{className:`mc-text`,children:[z(`span`,{className:`mc-name-line`,children:[I(`bdi`,{className:`mc-name`,title:e.id,children:e.name}),z(`span`,{className:`mc-chips`,children:[oG(e,c).map(e=>I(`span`,{className:`mc-chip`,children:e},e)),PW(e)&&I(`span`,{className:`mc-chip is-npu`,children:c(`setup.models.npu`)})]})]}),z(`span`,{className:`mc-status`,id:`${l}-status`,children:[f?c(`setup.models.status.downloading`,{done:WO(i.bytes_done),total:WO(i.bytes_total)}):cG(e,c),e.recommended&&I(`span`,{className:`mc-pill`,children:c(`setup.models.recommended`)}),e.fits===null&&z(`span`,{className:`mc-chip is-unknown`,children:[I(ai,{size:11,"aria-hidden":`true`}),` `,c(`setup.models.fitUnknown`)]})]}),I(`span`,{className:`mc-note`,id:`${l}-note`,children:c.compose(t=>[sG(e,t),lG(e,t),e.fits===null?t(`setup.models.fit.unknown`):null].filter(Boolean).join(` `))})]})]}),a&&I(`span`,{className:`mc-actions`,children:a})]}),f&&I(`progress`,{className:`mc-mini-progress`,max:i.bytes_total,value:i.bytes_done,"aria-label":c(`setup.progress.rowLabel`,{name:e.name,state:c(`setup.state.downloading`)})}),I(AW,{open:!!p,children:z(`p`,{className:`mc-warn${u?` is-big`:``}`,role:`note`,id:`${l}-warn`,children:[I(ws,{size:13,"aria-hidden":`true`}),I(`span`,{children:p})]})})]})}function pG({plan:e,selection:t}){let n=R(),{downloadGb:r,freeGb:i,afterGb:a}=QW(e,t),o=$W(e,t),s=EW(r??0),c=EW(a??0),l=mG(e.disk?.path??null),u=r!=null&&i?Math.min(1,r/i):0,d=DW(r==null?n(`setup.summary.spokenUnknown`):a==null?n(`setup.summary.spokenNoDisk`,{download:BO(r)}):n(`setup.summary.spoken`,{download:BO(r),after:BO(Math.max(0,a))}),600);return z(`div`,{className:`mc-summary${o?` is-warn`:``}`,role:`group`,"aria-label":n(`setup.summary.label`),children:[z(`div`,{className:`mc-summary-stats`,children:[z(`span`,{className:`mc-stat`,children:[I(`span`,{className:`mc-stat-label`,children:n(`setup.summary.download`)}),I(`bdi`,{className:`mc-stat-value`,children:r==null?n(`setup.summary.sizeUnknown`):BO(hG(s))})]}),z(`span`,{className:`mc-stat`,children:[z(`span`,{className:`mc-stat-label`,children:[I(ha,{size:12,"aria-hidden":`true`}),` `,l?z(P.Fragment,{children:[n(`setup.summary.freeOn`),` `,I(`bdi`,{dir:`ltr`,className:`mc-stat-path`,children:l})]}):n(`setup.summary.free`)]}),I(`bdi`,{className:`mc-stat-value`,children:i==null?n(`setup.summary.freeUnknown`):BO(i)})]}),a!=null&&!o&&z(`span`,{className:`mc-stat`,children:[I(`span`,{className:`mc-stat-label`,children:n(`setup.summary.after`)}),I(`bdi`,{className:`mc-stat-value`,children:BO(Math.max(0,hG(c)))})]})]}),i!=null&&I(`div`,{className:`mc-disk`,"aria-hidden":`true`,children:I(`span`,{className:`mc-disk-fill`,style:{inlineSize:`${(u*100).toFixed(1)}%`}})}),I(AW,{open:!!o,children:o&&z(`p`,{className:`mc-disk-warn`,role:`note`,children:[I(ws,{size:13,"aria-hidden":`true`}),I(`span`,{children:o.drop?n(`setup.summary.shortDrop`,{need:BO(o.needGb),free:BO(o.freeGb),drive:l??n(`setup.summary.theDrive`),freeUp:BO(o.freeUpGb),name:o.drop.name,saves:BO(o.drop.size_gb??0)}):n(`setup.summary.short`,{need:BO(o.needGb),free:BO(o.freeGb),drive:l??n(`setup.summary.theDrive`),freeUp:BO(o.freeUpGb)})})]})}),I(`span`,{className:`visually-hidden`,"aria-live":`polite`,children:d})]})}function mG(e){if(!e)return null;let t=/^([A-Za-z]:)[\\/]/.exec(e);return t?t[1]:e}function hG(e){return Math.round(e*10)/10}function gG({plan:e,selection:t,onToggle:n,onDefaultChat:r,labelledBy:i,cloud:a,disabled:o,progress:s,rowActions:c,place:l=`setup`}){let u=R(),d=jW(e),[f,p]=(0,V.useState)(``),m=(0,V.useId)(),h=a?d.filter(NW):UW(d),g=a?[]:WW(d),_=a?[]:GW(d),v=(0,V.useMemo)(()=>{let e=f.trim().toLowerCase();return e?_.filter(t=>t.id.toLowerCase().includes(e)||t.name.toLowerCase().includes(e)):_},[_,f]),y=qW(d,t.ticked),b=e=>I(fG,{entry:e,ticked:t.ticked.has(e.id),onToggle:t=>n(e.id,t),disabled:o,progress:s?.[e.id],actions:c?.(e),place:l,imagesCovered:d.some(n=>n.id!==e.id&&MW(n)&&(t.ticked.has(n.id)||n.downloaded===!0))},e.id);return z(`div`,{className:`mc`,children:[I(`ul`,{className:`mc-list`,role:`group`,"aria-labelledby":i,children:h.map(b)}),a?I(`p`,{className:`setup-hint`,children:u(`setup.models.cloudNote`)}):I(`p`,{className:`mc-foot`,children:u(`setup.models.neverDeletes`)}),g.length>0&&z(`details`,{className:`mc-more`,children:[I(`summary`,{children:u(`setup.models.more`,{n:String(g.length)})}),I(`ul`,{className:`mc-list`,role:`group`,"aria-label":u(`setup.models.moreLabel`),children:g.map(b)})]}),_.length>0&&z(`details`,{className:`mc-more`,children:[I(`summary`,{children:u(`setup.models.installed`,{n:String(_.length)})}),_.length>aG&&I(`input`,{className:`settings-input mc-search`,type:`search`,value:f,onChange:e=>p(e.target.value),placeholder:u(`setup.models.search`),"aria-label":u(`setup.models.search`)}),I(`ul`,{className:`mc-list`,role:`radiogroup`,"aria-label":u(`setup.models.installedLabel`),children:v.map(e=>I(`li`,{className:`mc-row is-installed${t.defaultChat===e.id?` is-ticked`:``}`,children:z(`label`,{className:`mc-row-main`,children:[I(`input`,{type:`radio`,name:`${m}-installed`,className:`mc-radio`,checked:t.defaultChat===e.id,disabled:o,onChange:()=>r(e.id)}),z(`span`,{className:`mc-text`,children:[z(`span`,{className:`mc-name-line`,children:[I(`bdi`,{className:`mc-name`,title:e.id,children:e.name}),z(`span`,{className:`mc-chips`,children:[I(`span`,{className:`mc-chip`,children:u(`setup.models.purpose.chat`)}),PW(e)&&I(`span`,{className:`mc-chip is-npu`,children:u(`setup.models.npu`)})]})]}),z(`span`,{className:`mc-status`,children:[u(`setup.models.status.onPc`),` · `,u(`setup.models.useAsDefault`)]})]})]})},e.id))})]}),!a&&z(`div`,{className:`mc-default`,children:[I(`label`,{htmlFor:m,className:`mc-default-label`,children:u(`setup.models.defaultChat`)}),z(`select`,{id:m,className:`settings-input mc-select`,value:t.defaultChat??``,disabled:o||y.length===0,onChange:e=>r(e.target.value),children:[y.length===0&&I(`option`,{value:``,children:u.bare(`setup.models.noChat`)}),y.map(e=>z(`option`,{value:e.id,children:[e.name,PW(e)?` (${u(`setup.models.npu`)})`:``]},e.id))]})]})]})}function _G(){let e=R();return z(`div`,{className:`mc`,"aria-busy":`true`,children:[z(`p`,{className:`setup-hint`,role:`status`,children:[I(La,{size:13,className:`spin`,"aria-hidden":`true`}),` `,e(`setup.models.loading`)]}),I(`ul`,{className:`mc-list`,"aria-hidden":`true`,children:[0,1,2].map(e=>I(`li`,{className:`mc-row is-skeleton`,children:I(`span`,{className:`mc-skeleton`})},e))})]})}function vG({entry:e}){let t=R();return e.support===`verified`?I(`span`,{className:`mc-chip is-verified`,children:t(`setup.label.verified`)}):e.support===`untested`?I(`span`,{className:`mc-chip is-untested`,children:t(`setup.label.untested`)}):null}function yG({name:e,entry:t,checked:n,recommended:r,disabled:i,onPick:a,children:o}){let s=R();return I(`li`,{className:`mc-row${n?` is-ticked`:``}`,children:z(`label`,{className:`mc-row-main`,children:[I(`input`,{type:`radio`,className:`mc-radio`,name:e,checked:n,disabled:i||FW(t),onChange:a}),z(`span`,{className:`mc-text`,children:[z(`span`,{className:`mc-name-line`,children:[I(`span`,{className:`mc-name`,title:t.id,children:I(`bdi`,{children:t.name})}),z(`span`,{className:`mc-chips`,children:[r&&I(`span`,{className:`mc-pill`,children:s(`setup.models.recommended`)}),I(vG,{entry:t}),PW(t)&&I(`bdi`,{className:`mc-chip is-npu`,children:s(`setup.models.npu`)})]})]}),I(`span`,{className:`mc-status`,children:cG(t,s)}),t.fits===!1&&z(`span`,{className:`mc-warn is-big`,role:`note`,children:[I(ws,{size:13,"aria-hidden":`true`}),` `,uG(t,s)]}),o]})]})})}function bG({label:e,note:t,size:n,checked:r,disabled:i,warning:a,chips:o,onChange:s}){return I(`li`,{className:`mc-row${r?` is-ticked`:``}${i?` is-off`:``}`,children:z(`label`,{className:`mc-row-main`,children:[I(`input`,{type:`checkbox`,className:`mc-input`,checked:r,disabled:i,onChange:e=>s(e.target.checked)}),I(`span`,{className:`mc-box`,"aria-hidden":`true`,children:I(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,children:I(`path`,{className:`mc-tick`,d:`M3.5 8.5l3 3 6-7`})})}),z(`span`,{className:`mc-text`,children:[z(`span`,{className:`mc-name-line`,children:[I(`span`,{className:`mc-name`,children:I(`bdi`,{children:e})}),I(`span`,{className:`mc-chips`,children:o})]}),I(`span`,{className:`mc-status`,children:I(`bdi`,{dir:`ltr`,children:n})}),I(`span`,{className:`mc-note`,children:t}),a&&z(`span`,{className:`mc-warn`,role:`note`,children:[I(ws,{size:13,"aria-hidden":`true`}),` `,a]})]})]})})}function xG({plan:e,selection:t,onSelection:n,disabled:r}){let i=R(),a=(0,V.useId)(),o=jW(e),[s,c]=(0,V.useState)(!1),l=o.find(e=>e.id===t.defaultChat),u=!!l&&PW(l),d=o.filter(e=>e.chat_choice&&!NW(e)&&(e.gaia_model||e.downloaded)&&PW(e)===u),f=d.filter(e=>e.support===`verified`),p=d.filter(e=>e.support!==`verified`),m=RW(o,t),h=!!l?.reads_images,g=o.filter(e=>MW(e)&&e.id!==l?.id),_=o.find(NW),v=e=>o.find(t=>IW(t)&&t.roles.includes(e)),y=e=>e.downloaded?i(`setup.models.status.onPc`):e.size_gb==null?i(`setup.contents.sizeOnDownload`):BO(e.size_gb),b=(e,r)=>n(JW(t,o,e,r)),x=e=>n(BW(t,o,e)),S=e=>n(VW(t,o,e)),C=v(`speech`),w=v(`voice`),T=v(`image_creation`),E=LW(l),D=l?.support===`untested`;return z(`div`,{className:`mc`,children:[z(`section`,{className:`mc-job`,"aria-labelledby":`${a}-chat`,children:[I(`h3`,{className:`mc-job-title`,id:`${a}-chat`,children:i(`setup.job.chat`)}),I(`p`,{className:`setup-hint`,children:i(`setup.job.verifiedNote`)}),I(`ul`,{className:`mc-list`,role:`radiogroup`,"aria-labelledby":`${a}-chat`,children:f.map(n=>I(yG,{name:`${a}-chat-model`,entry:n,checked:n.id===t.defaultChat,recommended:n.id===e.recommended_model,disabled:r,onPick:()=>x(n.id)},n.id))}),p.length>0&&z(P.Fragment,{children:[I(`p`,{className:`setup-hint`,children:i(`setup.job.untestedNote`)}),I(`ul`,{className:`mc-list`,role:`radiogroup`,"aria-labelledby":`${a}-chat`,children:p.map(e=>I(yG,{name:`${a}-chat-model`,entry:e,checked:e.id===t.defaultChat,recommended:!1,disabled:r,onPick:()=>x(e.id)},e.id))})]}),D&&z(`p`,{className:`mc-warn`,role:`note`,children:[I(ws,{size:13,"aria-hidden":`true`}),` `,i(`setup.job.untestedPicked`)]})]}),z(`section`,{className:`mc-job`,"aria-labelledby":`${a}-vision`,children:[I(`h3`,{className:`mc-job-title`,id:`${a}-vision`,children:i(`setup.job.vision`)}),u?I(`p`,{className:`setup-hint`,role:`note`,children:i(`setup.job.visionOffNpu`,{name:l?.name??``})}):h?z(`div`,{className:`setup-card`,children:[z(`p`,{className:`mc-job-line`,children:[I(`bdi`,{children:i(`setup.job.visionBuiltIn`,{name:l?.name??``})}),I(`span`,{className:`setup-ok`,children:i(`setup.job.nothingMore`)})]}),I(`button`,{type:`button`,className:`link-btn`,"aria-expanded":s,onClick:()=>c(e=>!e),children:i(s?`setup.job.hideVision`:`setup.job.otherVision`)})]}):I(`p`,{className:`setup-hint`,children:i(`setup.job.visionNeeded`,{name:l?.name??``})}),!u&&(!h||s)&&z(`ul`,{className:`mc-list`,role:`radiogroup`,"aria-labelledby":`${a}-vision`,children:[g.map(e=>I(yG,{name:`${a}-vision-model`,entry:e,checked:m===e.id,recommended:!h&&e.gaia_model&&e.support===`verified`,disabled:r,onPick:()=>S(e.id)},e.id)),I(`li`,{className:`mc-row${m===null?` is-ticked`:``}`,children:z(`label`,{className:`mc-row-main`,children:[I(`input`,{type:`radio`,className:`mc-radio`,name:`${a}-vision-model`,checked:h?m===l?.id:m===null,disabled:r,onChange:()=>S(h?null:`none`)}),z(`span`,{className:`mc-text`,children:[I(`span`,{className:`mc-name`,children:i(h?`setup.job.useChatForVision`:`setup.job.skipVision`)}),m===null&&!h&&z(`span`,{className:`mc-warn`,role:`note`,children:[I(ws,{size:13,"aria-hidden":`true`}),` `,i(`setup.job.skipVisionNote`)]})]})]})})]})]}),_&&z(`section`,{className:`mc-job`,"aria-labelledby":`${a}-docs`,children:[I(`h3`,{className:`mc-job-title`,id:`${a}-docs`,children:i(`setup.job.documents`)}),I(`ul`,{className:`mc-list`,children:I(bG,{label:_.name,note:i(`setup.models.line.documents`),size:y(_),checked:t.ticked.has(_.id),disabled:r,warning:t.ticked.has(_.id)?null:i(`setup.job.documentsOff`),chips:z(P.Fragment,{children:[I(`span`,{className:`mc-pill`,children:i(`setup.models.recommended`)}),I(vG,{entry:_})]}),onChange:e=>b(_.id,e)})})]}),z(`section`,{className:`mc-job`,"aria-labelledby":`${a}-extras`,children:[I(`h3`,{className:`mc-job-title`,id:`${a}-extras`,children:i(`setup.job.extras`)}),I(`p`,{className:`setup-hint`,children:i(`setup.job.extrasNote`)}),z(`ul`,{className:`mc-list`,children:[C&&I(bG,{label:i(`setup.job.speech`),note:i(`setup.job.speechNote`),size:y(C),checked:t.ticked.has(C.id),disabled:r,onChange:e=>b(C.id,e)}),w&&I(bG,{label:i(`setup.job.voice`),note:i(`setup.job.voiceNote`),size:y(w),checked:t.ticked.has(w.id),disabled:r,onChange:e=>b(w.id,e)}),T&&I(bG,{label:i(`setup.job.images`),note:i(`setup.job.imagesNote`),size:y(T),checked:t.ticked.has(T.id),disabled:r||!E,warning:E?null:i(`setup.job.imagesBlocked`,{name:l?.name??``}),onChange:e=>b(T.id,e)})]})]}),I(SG,{plan:e,selection:t})]})}function SG({plan:e,selection:t}){let n=R(),r=jW(e),i=e=>r.find(t=>t.id===e)?.name??e??n(`setup.get.off`),a=e=>r.find(n=>IW(n)&&n.roles.includes(e)&&t.ticked.has(n.id)),o=r.find(e=>NW(e)&&t.ticked.has(e.id)),s=r.find(e=>e.id===t.defaultChat),c=RW(r,t),l=[a(`speech`)&&n(`setup.job.speech`),a(`voice`)&&n(`setup.job.voice`)].filter(Boolean).join(`, `);return z(`section`,{className:`setup-card`,"aria-label":n(`setup.get.title`),children:[I(`h3`,{className:`mc-job-title`,children:n(`setup.get.title`)}),z(`dl`,{className:`setup-summary-list`,children:[z(`div`,{children:[I(`dt`,{children:n(`setup.job.chat`)}),I(`dd`,{children:I(`bdi`,{children:i(t.defaultChat)})})]}),z(`div`,{children:[I(`dt`,{children:n(`setup.job.vision`)}),I(`dd`,{children:I(`bdi`,{children:s&&PW(s)?n(`setup.get.offNpu`):c?i(c):n(`setup.get.off`)})})]}),z(`div`,{children:[I(`dt`,{children:n(`setup.job.documents`)}),I(`dd`,{children:I(`bdi`,{children:o?o.name:n(`setup.get.off`)})})]}),z(`div`,{children:[I(`dt`,{children:n(`setup.get.voice`)}),I(`dd`,{children:l||n(`setup.get.off`)})]}),z(`div`,{children:[I(`dt`,{children:n(`setup.job.images`)}),I(`dd`,{children:LW(s)?a(`image_creation`)?n(`setup.get.on`):n(`setup.get.off`):n(`setup.get.notAvailable`)})]})]})]})}var CG=(0,V.createContext)(void 0),wG=CG.Provider;function TG({children:e}){let t=(0,V.useContext)(CG);return t===void 0?I(`div`,{className:`setup-row setup-nav`,children:e}):t===null?null:(0,Mj.createPortal)(I(`div`,{className:`setup-footer-row`,children:e}),t)}function EG({title:e,children:t,confirmLabel:n,cancelLabel:r,onConfirm:i,onCancel:a,danger:o,busy:s}){let c=(0,V.useRef)(null),l=(0,V.useRef)(null),u=(0,V.useId)(),d=(0,V.useId)();return on(c,!0),(0,V.useEffect)(()=>{let e=document.activeElement;return l.current?.focus(),()=>e?.focus?.()},[]),pt(!0,a,!s),(0,Mj.createPortal)(I(`div`,{className:`confirm-overlay`,children:z(`div`,{ref:c,className:`confirm-sheet`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":u,"aria-describedby":t?d:void 0,children:[I(`h2`,{id:u,className:`confirm-title`,children:e}),t&&I(`div`,{id:d,className:`confirm-body`,children:t}),z(`div`,{className:`confirm-actions`,children:[I(`button`,{ref:l,type:`button`,className:`btn-secondary`,onClick:a,disabled:s,children:r}),I(`button`,{type:`button`,className:o?`btn-danger`:`btn-primary`,onClick:i,disabled:s,children:n})]})]})}),document.body)}function DG(e){return e===`windows`?`Windows`:e===`linux`?`Linux`:e}function OG(e){let t=/^Run:\s*(.+)$/.exec(e)??/^(sudo .+)$/.exec(e);return t?t[1].trim():null}function kG(e,t){return e.setting&&Math.abs(e.setting.current_gb-t)<.05&&e.gpu_gb!=null?e.gpu_gb:e.presets?.find(e=>Math.abs(e.setting_gb-t)<.05)?.gpu_gb??null}function AG(e,t,n=!1){return t==null?e(n?`gpu.appliedAny`:`gpu.pending.restartAny`):e(n?`gpu.applied`:`gpu.pending.restart`,{gb:BO(t)})}function jG(e){e.focus({preventScroll:!0});for(let t=e.parentElement;t;t=t.parentElement){let n=getComputedStyle(t).overflowY;if(n!==`auto`&&n!==`scroll`)continue;let r=e.getBoundingClientRect().top-t.getBoundingClientRect().top;(r<0||r>t.clientHeight-40)&&(t.scrollTop+=r-16);return}}function MG(e){return e instanceof Error?e.message:String(e)}function NG({status:e,targetGpuGb:t}){let n=R(),r=e=>Math.round(e*10),i=r(e.total_gb??0),a=r(e.gpu_gb??0),o=t!=null&&r(t)>a?r(t):null,s=o==null?0:o-a,c=Math.max(0,i-a-s),l=e=>BO(e/10),u=e=>i>0?Math.min(100,e/i*100):0,d=e.pending?.state===`took_effect`;return z(`div`,{className:`gpu-split`,children:[z(`div`,{className:`gpu-bar${d?` is-new`:``}`,role:`img`,"aria-label":o==null?n(`gpu.split.aria`,{cpu:l(c),gpu:l(a)}):n(`gpu.split.ariaTarget`,{cpu:l(c),gpu:l(o),now:l(a)}),children:[I(`span`,{className:`gpu-seg is-gpu`,style:{inlineSize:`${u(a)}%`}}),I(`span`,{className:`gpu-seg is-target`,style:{inlineSize:`${u(s)}%`}}),I(`span`,{className:`gpu-seg is-cpu`}),o!=null&&I(`span`,{className:`gpu-marker`,style:{insetInlineStart:`${u(o)}%`}})]}),z(`div`,{className:`gpu-legend`,"aria-hidden":`true`,children:[I(`span`,{className:`gpu-key is-gpu`,children:I(`bdi`,{children:n(`gpu.split.gpu`,{gb:l(a)})})}),o!=null&&I(`span`,{className:`gpu-key is-target`,children:I(`bdi`,{children:n(`gpu.split.added`,{gb:l(s)})})}),I(`span`,{className:`gpu-key is-cpu`,children:I(`bdi`,{children:n(`gpu.split.cpu`,{gb:l(c)})})})]})]})}function PG({presets:e,value:t,onChange:n,recommended:r,max:i,keepGb:a,disabled:o}){let s=R();return z(Fz,{className:`gpu-presets`,"aria-label":s(`gpu.presets.label`),children:[a!=null&&I(`button`,{type:`button`,role:`radio`,"aria-checked":t===null,className:`gpu-preset${t===null?` is-active`:``}`,disabled:o,onClick:()=>n(null),children:I(`bdi`,{children:s(`gpu.presets.keep`,{gb:BO(a)})})}),e.map(e=>z(`button`,{type:`button`,role:`radio`,"aria-checked":e.setting_gb===t,className:`gpu-preset${e.setting_gb===t?` is-active`:``}`,disabled:o,onClick:()=>n(e.setting_gb),children:[I(`bdi`,{children:s(`gpu.presets.gpu`,{gb:BO(e.gpu_gb)})}),e.setting_gb===r&&z(P.Fragment,{children:[` `,I(`span`,{className:`gpu-tag is-recommended`,children:s(`gpu.presets.recommended`)})]}),e.setting_gb===i&&z(P.Fragment,{children:[` `,I(`span`,{className:`gpu-tag is-max`,children:s(`gpu.presets.max`)})]})]},e.setting_gb))]})}function FG({status:e,onStatus:t,mode:n,names:r,onSkip:i,onContinue:a,onBack:o,headingId:s,cloud:c=!1}){let u=R(),d=_c(e=>!!e.active?.remote)||c,p=(0,V.useCallback)(()=>{let e=s?document.getElementById(s):null;e&&jG(e)},[s]);(0,V.useEffect)(()=>{n===`setup`&&p()},[n,p]);let m=(0,V.useId)(),h=e.presets??[],g=d?null:e.recommended_setting_gb??null,[_,v]=(0,V.useState)(g??(e.gpu_gb==null?h[0]?.setting_gb??null:null)),[y,b]=(0,V.useState)(!1),[x,S]=(0,V.useState)(null),[C,w]=(0,V.useState)(void 0),[T,E]=(0,V.useState)(null),[D,O]=(0,V.useState)(null),[k,ee]=(0,V.useState)(null),[te,ne]=(0,V.useState)(null),A=h.find(e=>e.setting_gb===_)??null,re=h.length>0&&h[h.length-1].setting_gb===e.setting?.max_gb?h[h.length-1].setting_gb:null,ie=A&&e.total_gb!=null?Math.max(0,e.total_gb-A.gpu_gb):null,ae=g==null&&!d?(e.models??[]).find(e=>e.default&&e.fits_now):void 0,oe=(A?.unlocks??[]).slice(0,2).map(e=>r[e]??e),se=e.pending??null,ce=e.method===`apply`,le=e.guided_value!==null,ue=(0,V.useCallback)(async()=>{b(!0),S(null),O(`steps`),ee(null);try{let e=await f(_??void 0);w(e.guided_value),S(e.guided_value===null?[]:e.guided_steps??[])}catch(e){w(void 0),S([]),ee({kind:`error`,message:MG(e)})}finally{O(null)}},[_]),de=async()=>{if(_!=null){E(null),O(`apply`),ee(null);try{t(await l(_)),ee({kind:`applied`})}catch(e){let t=e instanceof Nt&&e.httpStatus===403;ee(t?{kind:`denied`}:{kind:`error`,message:MG(e)}),t&&p()}finally{O(null)}}},fe=async()=>{E(null),O(`revert`),ee(null);try{t(await st()),ee({kind:`applied`})}catch(e){ee(e instanceof Nt&&e.httpStatus===403?{kind:`denied`}:{kind:`error`,message:MG(e)})}finally{O(null)}},pe=async()=>{if(_!=null){O(`done`),ee(null);try{t(await bn(_)),b(!1)}catch(e){ee({kind:`error`,message:MG(e)})}finally{O(null)}}},me=async()=>{O(`keep`),ee(null);try{t(await j())}catch(e){ee({kind:`error`,message:MG(e)})}finally{O(null)}},he=async e=>{try{await navigator.clipboard.writeText(e),ne(e)}catch(e){ee({kind:`error`,message:u(`gpu.copyFailed`,{reason:MG(e)})})}},M=se?.state===`restart_required`;return z(`div`,{className:`gpu`,children:[I(`p`,{className:`setup-hint`,children:u(`gpu.body`,{total:BO(e.total_gb??0),gpu:BO(e.gpu_gb??0)})}),I(NG,{status:e,targetGpuGb:!M&&!y?A?.gpu_gb??null:null}),se?.state===`took_effect`&&z(`div`,{className:`gpu-notice is-ok`,role:`status`,children:[I(Vr,{size:14,"aria-hidden":`true`}),I(`span`,{children:u(`gpu.pending.tookEffect`,{gb:BO(e.gpu_gb??0)})}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void me(),disabled:D!==null,children:u(`gpu.ok`)})]}),M&&z(`div`,{className:`gpu-notice`,role:`status`,children:[I(ya,{size:14,"aria-hidden":`true`}),I(`span`,{children:u.compose(t=>[AG(t,kG(e,se.setting_gb),k?.kind===`applied`),t(`gpu.pending.restartHow`),n===`setup`?t(`gpu.pending.downloadsFirst`):null].filter(Boolean).join(` `))}),se.source===`guided`&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void me(),disabled:D!==null,children:u(`gpu.keep`,{gb:BO(e.gpu_gb??0)})})]}),se?.state===`not_applied`&&z(`div`,{className:`gpu-notice is-warn`,role:`status`,children:[I(ws,{size:14,"aria-hidden":`true`}),I(`span`,{children:u(`gpu.pending.notApplied`,{gb:BO(e.gpu_gb??0)})}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void me(),disabled:D!==null,children:u(`gpu.keep`,{gb:BO(e.gpu_gb??0)})})]}),!M&&!y&&h.length>0&&z(P.Fragment,{children:[ae&&z(`p`,{className:`gpu-unlock is-keep`,children:[I(Vr,{size:13,"aria-hidden":`true`}),` `,u(`gpu.keepRecommended`,{model:r[ae.id]??ae.id})]}),I(PG,{presets:h,value:_,onChange:v,recommended:g,max:re,keepGb:e.gpu_gb??null,disabled:D!==null}),A&&I(`p`,{className:`gpu-unlock`,children:oe.length>0?u(oe.length>1?`gpu.unlock.two`:`gpu.unlock.one`,{gb:BO(A.gpu_gb),a:oe[0],b:oe[1]??``}):u(`gpu.unlock.none`,{gb:BO(A.gpu_gb)})}),A&&A.setting_gb===re&&ie!=null&&z(`p`,{className:`gpu-unlock is-warn`,role:`note`,children:[I(ws,{size:13,"aria-hidden":`true`}),` `,u(`gpu.maxWarn`,{cpu:BO(ie),os:DG(e.os)})]}),I(`p`,{className:`setup-hint`,children:u.compose(t=>`${t(`gpu.reserve`,{gb:BO(e.reserve_gb??16),os:DG(e.os)})} ${t(`gpu.needs`)}`)}),!ce&&e.method_reason&&I(`p`,{className:`setup-hint`,children:I(`bdi`,{dir:`ltr`,children:e.method_reason})})]}),!M&&!y&&h.length===0&&I(`p`,{className:`setup-hint`,children:u(`gpu.noPresets`)}),y&&z(`div`,{className:`gpu-guided`,children:[A&&I(`p`,{className:`setup-hint`,id:m,children:u(`gpu.guided.lede`,{gb:BO(A.gpu_gb)})}),x===null?z(`p`,{className:`setup-hint`,role:`status`,children:[I(La,{size:13,className:`spin`,"aria-hidden":`true`}),` `,u(`gpu.guided.loading`)]}):C===null?I(`p`,{className:`setup-hint`,children:u(`gpu.noPresets`)}):I(`ol`,{className:`gpu-steps`,"aria-labelledby":m,children:x.map(e=>{let t=OG(e);return z(`li`,{children:[I(`span`,{children:e}),t&&z(`button`,{type:`button`,className:`btn-secondary gpu-copy`,onClick:()=>void he(t),"aria-label":u(`gpu.copyAria`,{what:t}),children:[I(te===t?Vr:hi,{size:12,"aria-hidden":`true`}),u(te===t?`gpu.copied`:`gpu.copy`)]})]},e)})}),z(TG,{children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>b(!1),disabled:D!==null,children:u(`gpu.guided.back`)}),!ce&&C!==null&&z(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void pe(),disabled:D!==null||_==null,children:[D===`done`&&I(La,{size:13,className:`spin`,"aria-hidden":`true`}),` `,u(`gpu.guided.done`)]})]})]}),D===`apply`||D===`revert`?z(`p`,{className:`setup-hint`,role:`status`,children:[I(La,{size:13,className:`spin`,"aria-hidden":`true`}),` `,u(`gpu.waiting`)]}):null,k?.kind===`denied`&&z(`div`,{className:`gpu-notice is-warn`,role:`alert`,children:[I(ws,{size:14,"aria-hidden":`true`}),I(`span`,{children:u(`gpu.denied`)})]}),k?.kind===`error`&&I(`p`,{className:`setup-error`,role:`alert`,children:k.message}),!y&&(()=>{let t=!M&&ce&&h.length>0&&I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>E(`apply`),disabled:D!==null||_==null,children:k?.kind===`denied`||se?.state===`not_applied`?u(`gpu.tryAgain`):u(`gpu.apply`)}),r=!M&&h.length>0&&le&&I(`button`,{type:`button`,className:ce?`btn-secondary`:`btn-primary`,onClick:()=>void ue(),disabled:D!==null||_==null,children:u(`gpu.showMe`)});return n===`setup`?z(TG,{children:[o&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:o,children:u(`setup.back`)}),M?a&&I(`button`,{type:`button`,className:`btn-primary`,onClick:a,autoFocus:!0,children:u(`setup.continue`)}):_==null&&h.length>0?(i??a)&&I(`button`,{type:`button`,className:`btn-primary`,onClick:i??a,disabled:D!==null,children:u(`gpu.keepAsIs`)}):z(P.Fragment,{children:[i&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:i,disabled:D!==null,children:u(`gpu.skip`)}),ce?z(P.Fragment,{children:[r,t]}):r]})]}):z(`div`,{className:`setup-row gpu-actions`,children:[t,r,e.revert?.available&&z(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>E(`revert`),disabled:D!==null,children:[I(Ro,{size:13,"aria-hidden":`true`}),` `,u(`gpu.undo`)]})]})})(),T===`apply`&&_!=null&&z(EG,{title:A?u(`gpu.consent.title`,{gb:BO(A.gpu_gb)}):u(`gpu.consent.titleAny`),confirmLabel:u(`setup.continue`),cancelLabel:u(`setup.cancel`),onConfirm:()=>void de(),onCancel:()=>E(null),children:[I(`p`,{children:A?u(`gpu.consent.body`,{name:e.setting?.name??``,gb:BO(A.gpu_gb)}):u(`gpu.consent.bodyAny`,{name:e.setting?.name??``})}),I(`p`,{className:`confirm-note`,children:u(`gpu.consent.saved`,{gb:BO(e.gpu_gb??0)})})]}),T===`revert`&&I(EG,{title:u(`gpu.revert.title`),confirmLabel:u(`setup.continue`),cancelLabel:u(`setup.cancel`),onConfirm:()=>void fe(),onCancel:()=>E(null),children:I(`p`,{children:u(`gpu.revert.body`)})})]})}function IG({plan:e,planError:t,onRetryPlan:n,onUseRecommended:r,selection:i,onSelection:a,cloud:o,keepTrying:s,onKeepTrying:c,onBack:l,onContinue:u,busy:d,error:f}){let p=R(),m=(0,V.useRef)(null),[h,g]=(0,V.useState)(!1),_=!!e&&!!i&&!!e.catalog,v=(0,V.useRef)(null);if(_&&v.current===null&&(v.current=!o&&ZW(jW(e),i).length===0&&!!i.defaultChat&&jW(e).some(e=>e.downloaded)),(0,V.useEffect)(()=>{_&&m.current?.querySelector(`input:not([disabled])`)?.focus()},[_,h]),t&&!_)return z(`div`,{className:`setup-models-error`,children:[I(`p`,{className:`setup-error`,role:`alert`,children:p(`setup.models.listFailed`,{reason:t})}),z(`div`,{className:`setup-row`,children:[I(`button`,{type:`button`,className:`btn-primary`,onClick:n,children:p(`setup.tryAgain`)}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:r,children:p(`setup.models.useRecommended`)})]}),I(`p`,{className:`setup-hint`,children:p(`setup.models.useRecommendedNote`)})]});if(!_)return I(_G,{});let y=jW(e),b=ZW(y,i),x=!o&&!i.defaultChat,S=$W(e,i),C=o?[]:y.filter(e=>e.fits===!1&&i.ticked.has(e.id)),w=!h&&!!v.current&&b.length===0,T=p(S?`setup.continueAnyway`:`setup.continue`);return w?z(`div`,{className:`setup-present`,role:`status`,children:[z(`p`,{children:[I(Vr,{size:14,"aria-hidden":`true`}),` `,p(`setup.models.allPresent`)]}),I(`button`,{type:`button`,className:`link-btn`,onClick:()=>g(!0),children:p(`setup.models.change`)}),z(TG,{children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:l,disabled:d,children:p(`setup.back`)}),z(`button`,{type:`button`,className:`btn-primary`,onClick:()=>u(!1),disabled:d,children:[d&&I(La,{size:13,className:`spin`,"aria-hidden":`true`}),` `,p(`setup.finish`)]})]}),f&&I(`p`,{className:`setup-error`,role:`alert`,children:f})]}):z(`div`,{className:`setup-models`,ref:m,children:[I(`p`,{className:`setup-hint`,children:p(`setup.job.lede`)}),I(xG,{plan:e,selection:i,onSelection:a,disabled:d}),!o&&I(`button`,{type:`button`,className:`link-btn setup-reset`,onClick:()=>a(XW(e)),disabled:d,children:p(`setup.models.resetRecommended`)}),z(`div`,{className:`setup-models-footer`,children:[I(pG,{plan:e,selection:i}),z(`label`,{className:`setup-keep-trying`,children:[I(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked),disabled:d}),I(`span`,{children:p(`setup.keepTrying`)})]}),I(AW,{open:x,children:I(`p`,{className:`setup-error`,id:`setup-no-chat`,children:p(`setup.models.noChatReason`)})}),C.length>0&&I(`span`,{className:`visually-hidden`,children:C.map(e=>uG(e,p)).join(` `)}),f&&I(`p`,{className:`setup-error`,role:`alert`,children:f}),z(TG,{children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:l,disabled:d,children:p(`setup.back`)}),z(`button`,{type:`button`,className:`btn-primary`,onClick:()=>u(!!S),disabled:d||x,"aria-describedby":x?`setup-no-chat`:void 0,children:[d&&I(La,{size:13,className:`spin`,"aria-hidden":`true`}),` `,T]})]})]})]})}function LG({plan:e,chatModel:t,gpu:n}){let r=R();if(!e?.catalog)return null;let i=e.catalog,a=e=>e?i.find(t=>t.id===e)?.name??e:null,o=RW(i,{ticked:new Set,unticked:new Set,chatChosen:!1,defaultChat:t,vision:e.vision_model??null}),s=i.find(e=>e.id===o)??i.find(e=>MW(e)&&e.gaia_model),c=i.find(e=>NW(e)&&e.downloaded),l=i.filter(e=>e.gaia_model&&e.planned&&e.skipped),u=n?.pending,d=i.find(e=>e.id===t);return z(`dl`,{className:`setup-summary-list`,children:[t&&z(`div`,{children:[I(`dt`,{children:r(`setup.ready.chat`)}),z(`dd`,{children:[I(`bdi`,{children:a(t)}),d?.recipe===`flm`?` (${r(`setup.models.npu`)})`:``]})]}),z(`div`,{children:[I(`dt`,{children:r(`setup.ready.vision`)}),I(`dd`,{children:s?.downloaded?I(`bdi`,{children:s.name}):r(`setup.ready.visionOff`,{name:s?.name??`Gemma-4-E4B-it`})})]}),c&&z(`div`,{children:[I(`dt`,{children:r(`setup.ready.documents`)}),I(`dd`,{children:I(`bdi`,{children:c.name})})]}),l.length>0&&z(`div`,{children:[I(`dt`,{children:r(`setup.ready.notInstalled`)}),I(`dd`,{children:l.map(e=>e.name).join(`, `)})]}),u?.state===`restart_required`&&z(`div`,{className:`is-warn`,children:[I(`dt`,{children:r(`setup.ready.gpu`)}),z(`dd`,{children:[I(ws,{size:13,"aria-hidden":`true`}),` `,AG(r,n?kG(n,u.setting_gb):null)]})]}),u?.state===`took_effect`&&z(`div`,{children:[I(`dt`,{children:r(`setup.ready.gpu`)}),I(`dd`,{children:n?.gpu_gb==null?r(`setup.ready.gpuChanged`):r(`setup.ready.gpuNow`,{gb:BO(n.gpu_gb)})})]})]})}function RG(e){if(e.skill===`document-brief`){let t=/^(\d+) /.exec(e.note)?.[1];return t?{n:Number(t)}:void 0}if(e.skill===`coding`){let t=/^In (.+)$/.exec(e.note)?.[1];return t?{folder:t}:void 0}}function zG(e,t,n,r){let i=`${n}.one`,a=`${n}.other`,o=ae(i)&&ae(a)&&typeof r?.n==`number`?r.n===1?i:a:n;return!ae(o)||ne[o].includes(`{`)&&!r?t:gt(o,r)===t?e(o,r):t}function BG(e,t){return{title:zG(t,e.title,`card.${e.skill}.title`),note:zG(t,e.note,`card.${e.skill}.note`,RG(e))}}function VG({text:e}){let t=De(e);return t.length===1?I(P.Fragment,{children:e}):I(P.Fragment,{children:t.map((e,t)=>I(`span`,{className:`start-card-part`,children:e},t))})}function HG({cards:e,onPick:t,disabled:n}){let r=R();return e.length===0?null:I(`ul`,{className:`start-cards`,"aria-label":r(`newChat.cardsLabel`),children:e.map(e=>{let{title:i,note:a}=BG(e,r);return I(`li`,{children:z(`button`,{type:`button`,className:`start-card`,onClick:()=>t(e),disabled:n,title:e.needs_input?`${e.prompt}…`:e.prompt,children:[z(`span`,{className:`start-card-title`,children:[i,I(_r,{size:13,"aria-hidden":`true`})]}),I(`span`,{className:`start-card-note`,children:I(VG,{text:a})})]})},e.skill)})})}function UG(){let[e,t]=(0,V.useState)(null),[n,r]=(0,V.useState)([]),i=(0,V.useCallback)(()=>{Promise.resolve(cn()).then(e=>{t(e?.providers?.find(e=>e.id===`amd`)?.network??null),r(e?.providers??[])}).catch(e=>{console.warn(`[useGatewayNetwork] could not check the AMD gateway`,e),t(null)})},[]);return(0,V.useEffect)(i,[i]),{network:e,providers:n,recheck:i}}function WG(e,t,n){return t===`active`?n(`setup.contents.working`):t===`done`?n(`setup.contents.ready`):t===`failed`?n(`setup.contents.failed`):e.installed?n(`setup.contents.alreadyHere`):n(`setup.contents.waiting`)}function GG(e,t){return e==null?t(`setup.contents.sizeOnDownload`):BO(e)}function KG({state:e}){return e===`done`?I(Vr,{size:13,"aria-hidden":`true`}):e===`active`?I(La,{size:13,className:`spin`,"aria-hidden":`true`}):I(e===`failed`?Is:li,{size:13,"aria-hidden":`true`})}function qG({id:e,error:t,transient:n,onRetry:r,disabled:i}){let a=R(),o=a(`setup.component.${e}`);return z(`div`,{className:`setup-content-failure`,role:`alert`,children:[I(`p`,{children:a(n?`setup.contents.failedNetwork`:`setup.contents.failedOther`,{name:o})}),t&&z(`details`,{className:`dl-details`,children:[I(`summary`,{children:a(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:t})]}),r&&I(`button`,{type:`button`,className:`btn-primary`,onClick:r,disabled:i,"aria-label":a(`setup.contents.retryNamed`,{name:o}),children:a(`setup.progress.retry`)})]})}function JG({plan:e,run:t,models:n=[],onRetry:r,retryDisabled:i}){let a=R();return z(`ul`,{className:`setup-contents`,children:[(e.components??[]).map(e=>{let n=t?.components?.[e.id],o=t!=null&&t.state!==`running`&&t.state!==`verifying`,s=n===`active`&&o?void 0:n;return z(`li`,{className:`setup-content is-${s??(e.installed?`done`:`waiting`)}`,children:[I(`span`,{className:`setup-content-icon`,children:I(KG,{state:s??(e.installed?`done`:void 0)})}),z(`span`,{className:`setup-content-main`,children:[I(`span`,{className:`setup-content-name`,children:a(`setup.component.${e.id}`)}),I(`span`,{className:`setup-content-note`,children:a(`setup.component.${e.id}Note`)}),e.bundled?I(`span`,{className:`setup-content-from`,children:a(`setup.contents.bundled`)}):z(`span`,{className:`setup-content-from`,children:[a(`setup.contents.from`),` `,I(`bdi`,{dir:`ltr`,children:e.source})]})]}),z(`span`,{className:`setup-content-side`,children:[I(`bdi`,{dir:`ltr`,children:GG(e.size_gb,a)}),I(`span`,{children:WG(e,s,a)})]}),s===`failed`&&o&&!t?.problem&&I(qG,{id:e.id,error:t?.error,transient:t?.component_kinds?.[e.id]===`transient`,onRetry:r,disabled:i})]},e.id)}),n.map(e=>z(`li`,{className:`setup-content is-waiting`,children:[I(`span`,{className:`setup-content-icon`,children:I(KG,{state:void 0})}),z(`span`,{className:`setup-content-main`,children:[I(`span`,{className:`setup-content-name`,children:I(`bdi`,{children:e.name})}),I(`span`,{className:`setup-content-note`,children:e.roles.map(e=>a(`setup.purpose.${e}`)).join(` · `)}),e.source&&z(`span`,{className:`setup-content-from`,children:[a(`setup.contents.from`),` `,I(`bdi`,{dir:`ltr`,children:e.source})]})]}),I(`span`,{className:`setup-content-side`,children:I(`bdi`,{dir:`ltr`,children:GG(e.size_gb,a)})})]},e.id))]})}function YG({lines:e,className:t,id:n}){let r=(0,V.useRef)(null),i=(0,V.useRef)(!0),a=e.join(`
|
|
208
|
-
`);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
|
|
209
|
-
`):e.error})]}),u?I(`p`,{className:`dl-detail`,children:p(`setup.progress.retryLater`)}):z(`div`,{className:`setup-row`,children:[a&&z(`button`,{type:`button`,className:`btn-primary`,disabled:l,onClick:()=>a(e.id,e.error_kind),"aria-describedby":m,children:[I(Bo,{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:z(`button`,{type:`button`,className:`btn-secondary`,disabled:l,onClick:c,children:[I(Bo,{size:13,"aria-hidden":`true`}),` `,p(`setup.progress.retry`)]})})]})}function oK({status:e,names:t,freeGb:n=null,onCancel:r,onRetry:i,onResume:a,onResumeAll:o,onSkip:s,onRestart:c,busy:l=!1,retryLater:u=!1,labelledBy:d}){let f=R(),p=OW(),m=(0,V.useMemo)(()=>$G(e.models??[]),[e.models]),h=(0,V.useRef)(new Map),g=(0,V.useRef)(new Map),_=(0,V.useRef)(new XO),v=(0,V.useRef)(!1),[y,b]=(0,V.useState)(()=>Date.now()),[x,S]=(0,V.useState)(!1),[C,w]=(0,V.useState)(null),T=i&&((e,t)=>{let n=m.find(t=>t.id===e);t===`verify`&&n?w(n):i(e,t)}),[E,D]=(0,V.useState)(``),[O,k]=(0,V.useState)(``),ee=(0,V.useRef)(null),te=e.state===`verifying`||e.state!==`running`&&m.some(e=>e.state===`verifying`),ne=(0,V.useRef)(new Map);(0,V.useEffect)(()=>{if(!p||!(m.some(e=>e.retrying_until)||te))return;let e=setInterval(()=>b(Date.now()),1e3);return()=>clearInterval(e)},[m,p,te]);let A=e.overall,{estimates:re,overallEstimate:ie}=(0,V.useMemo)(()=>{let e=Date.now(),t={};for(let n of m){if(n.state!==`downloading`){h.current.delete(n.id);continue}let r=h.current.get(n.id),i=n.downloaded_before_gb??null;r&&g.current.get(n.id)===i||(r=new XO,h.current.set(n.id,r),g.current.set(n.id,i)),t[n.id]=r.update(n.bytes_done,n.bytes_total,e)}let n=m.some(e=>e.state===`downloading`);n&&!v.current&&(_.current=new XO),v.current=n;let r=m.filter(e=>e.state===`downloading`||e.state===`queued`).reduce((e,t)=>e+Math.max(0,t.bytes_total-t.bytes_done),0);return{estimates:t,overallEstimate:n&&A?_.current.update(A.bytes_done,A.bytes_done+r,e):void 0}},[m,A]);(0,V.useEffect)(()=>{let e=new Map(m.map(e=>[e.id,e.state])),n=Math.floor((A?.percent??0)/25),r=ee.current;if(ee.current={states:e,quarter:n},!r)return;let i=[];for(let e of m){if(r.states.get(e.id)===e.state)continue;let n=t[e.id]??e.id;e.state===`failed`?k(f(`setup.progress.announceFailed`,{name:n})):i.push(f(`setup.progress.announceState`,{name:n,state:f(nK[e.state])}))}n>r.quarter&&n>0&&n<4&&i.push(f(`setup.progress.announceOverall`,{n:String(n*25)})),i.length&&D(i.join(`. `))},[m,A?.percent,t,f]);let ae=e=>{if(!te)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)},j=rK(e),oe=m.filter(e=>e.state===`cancelled`),se=A?.failed??m.filter(e=>e.state===`failed`).length,ce=A?.percent??0,le=()=>{(A?.bytes_done??0)>XG?S(!0):r?.()},ue=f.compose(e=>[e(`setup.progress.overallPct`,{n:String(ce)}),A&&A.bytes_total>0?e(`setup.progress.of`,{done:WO(A.bytes_done),total:WO(A.bytes_total)}):null,j&&ie?.speed?KO(f.locale,GO(ie.speed)):null,j?ie?.eta==null?e(`setup.progress.estimating`):e(`setup.progress.left`,{eta:qO(ie.eta,e)}):null,se>0?e(`setup.progress.failedCount`,{n:String(se)}):null].filter(Boolean).join(` · `));return z(`section`,{className:`dl${p?``:` is-paused`}`,"aria-labelledby":d,children:[z(`div`,{className:`dl-overall`,children:[I(`p`,{className:`dl-overall-line`,children:I(`bdi`,{children:ue})}),I(`div`,{className:`dl-track is-overall${m.some(e=>e.state===`downloading`)?` is-live`:``}`,role:`progressbar`,"aria-label":f(`setup.progress.overallLabel`),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":ce,"aria-valuetext":f(`setup.progress.percent`,{n:String(ce)}),children:I(`span`,{className:`dl-fill`,style:{inlineSize:`${ce}%`}})})]}),I(`ul`,{className:`dl-list`,children:m.map(e=>I(aK,{model:e,name:t[e.id]??e.id,estimate:re[e.id],now:y,freeGb:n,onRetry:T,onResume:j?void 0:a,onSkip:s,onRestart:c,busy:l,retryLater:u,checking:te,checkingFor:ae(e.id)},e.id))}),j&&I(`p`,{className:`setup-hint dl-controls`,children:f(`setup.progress.keepsGoing`)}),(j&&r||!j&&oe.length>0&&o)&&z(TG,{children:[j&&r&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:le,disabled:l,children:f(`setup.progress.cancel`)}),!j&&oe.length>0&&o&&I(`button`,{type:`button`,className:`btn-primary`,onClick:o,disabled:l,children:f(`setup.progress.resumeAll`)})]}),I(`span`,{className:`visually-hidden`,"aria-live":`polite`,children:E}),I(`span`,{className:`visually-hidden`,role:`alert`,children:O}),x&&I(EG,{title:f(`setup.progress.cancelTitle`),confirmLabel:f(`setup.progress.cancelConfirm`),cancelLabel:f(`setup.progress.cancelKeep`),onConfirm:()=>{S(!1),r?.()},onCancel:()=>S(!1),children:I(`p`,{children:f(`setup.progress.cancelBody`)})}),C&&I(EG,{title:f(`setup.redownload.title`,{name:t[C.id]??C.id}),confirmLabel:f(`setup.redownload.confirm`),cancelLabel:f(`setup.redownload.keep`),onConfirm:()=>{let e=C;w(null),i?.(e.id,`verify`)},onCancel:()=>w(null),children:I(`p`,{children:f(`setup.redownload.body`,{name:t[C.id]??C.id,size:WO(C.bytes_total)})})})]})}function sK({run:e,plan:t,idle:n,bar:r=!0}){let i=R(),a=t?.components??[],o=a.find(t=>e.components?.[t.id]===`active`),s=a.filter(t=>e.components?.[t.id]===`done`||e.components?.[t.id]==null&&t.installed).length,c=e.percent==null?null:Math.max(0,Math.min(100,Math.round(e.percent))),l=o?i(`setup.download.now`,{name:i(`setup.component.${o.id}`)}):n;return z(`div`,{className:`setup-activity`,children:[z(`p`,{className:`setup-hint`,children:[I(La,{size:13,className:`spin`,"aria-hidden":`true`}),` `,I(`span`,{role:`status`,children:l}),c!=null&&z(P.Fragment,{children:[` · `,z(`bdi`,{dir:`ltr`,children:[c,`%`]})]}),a.length>0&&z(P.Fragment,{children:[` · `,i(`setup.download.partsReady`,{done:String(s),total:String(a.length)})]})]}),r&&c!=null&&I(`progress`,{className:`setup-progress`,max:100,value:c,"aria-label":l})]})}var cK=[`check`,`download`,`test`],lK={root:`setup-report`,button:`btn-secondary setup-report-button`,hint:`setup-hint`,error:`setup-error`},uK=/\d+(\.\d+)?\s*%/;function dK(e){let t=[],n=null;for(let r of e){let e=r.search(uK),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 fK({run:e,before:t={},failed:n=!1}){let r=R(),[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=>dK([...t[n]??[],...e?.logs?.[n]??[]]),u=cK.filter(e=>l(e).length>0);return z(`section`,{className:`setup-logs`,"aria-label":r(`setup.logs.title`),children:[z(`button`,{type:`button`,className:`setup-log-toggle setup-help-toggle`,onClick:()=>a(e=>!e),"aria-expanded":i,"aria-controls":`setup-help`,children:[I(Yr,{size:13,className:i?`is-open`:``,"aria-hidden":`true`}),` `,r(`setup.logs.help`)]}),i&&z(`div`,{id:`setup-help`,className:`setup-help`,children:[u.map(e=>{let t=l(e),n=o.has(e);return z(`div`,{className:`setup-log`,children:[z(`button`,{type:`button`,className:`setup-log-toggle`,onClick:()=>c(e),"aria-expanded":n,children:[I(Yr,{size:13,className:n?`is-open`:``,"aria-hidden":`true`}),` `,r(`setup.logs.${e}`)]}),n&&I(YG,{lines:t,className:`setup-log-pre`})]},e)}),I(wN,{classes:lK,note:r(`setup.logs.reportNote`)})]})]})}function pK(){let e=R(),t=B(e=>e.locale),n=B(e=>e.setLocale);return z(`label`,{className:`setup-language`,children:[I(Ca,{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:ge.map(({meta:e})=>I(`option`,{value:e.code,lang:e.code,dir:e.dir,children:Fe(e)},e.code))})]})}var mK={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`]},hK={cancelled:`setup.npu.fixError.cancelled`,timeout:`setup.npu.fixError.timeout`,not_authorized:`setup.npu.fixError.notAuthorized`,no_pkexec:`setup.npu.fixError.noPkexec`};function gK({problem:e}){let t=R(),n=mK[e.code];if(!n)return z(`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`),z(`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 _K({problems:e,disabled:t,onRecheck:n,id:r=`setup-npu-problems`}){let i=R(),[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 Nt?e.body?.code:void 0,r=n&&n in hK?hK[n]:t;c(i(r))}finally{o(!1)}};return z(`div`,{className:`setup-npu-problems`,id:r,role:`note`,children:[I(`p`,{children:i(`setup.npu.notReady`)}),I(`ul`,{children:e.map(e=>I(gK,{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}),z(`div`,{className:`setup-npu-actions`,children:[l&&I(`button`,{type:`button`,className:`btn-primary`,disabled:t||a,onClick:()=>void u(Qn,`setup.npu.fixError.failed`),children:i(`setup.npu.fixMemlock`)}),n&&I(`button`,{type:`button`,className:`btn-secondary`,disabled:t||a,onClick:()=>void u(pe,`setup.npu.recheckFailed`),children:i(`setup.npu.recheck`)})]})]})}async function vK(){let e=await p();e.reachable&&(e.available_backends??[]).some(e=>e.name===`vulkan`)&&(e.preferred_backend??e.default_backend)!==`vulkan`&&await x(`vulkan`)}function yK({plan:e,selection:t,onSelection:n,disabled:r=!1,onRecheck:i}){let a=R(),o=jW(e),s=e.npu?.present&&!e.npu.ready?e.npu.problems:[],c=s.length?void 0:o.find(e=>PW(e)&&e.gaia_model&&e.chat_choice&&e.fits!==!1)??o.find(e=>PW(e)&&e.chat_choice&&e.downloaded&&!FW(e)),l=!s.length&&!c&&o.some(e=>PW(e)&&e.fit_code===`npu`),u=!!o.find(e=>e.id===t.defaultChat&&PW(e)),d=XW(e).defaultChat,f=d&&!o.find(e=>e.id===d&&PW(e))?d:o.find(e=>e.chat_choice&&e.gaia_model&&e.support===`verified`&&!PW(e))?.id,p=e=>{e===`npu`&&c&&!u&&n(BW(t,o,c.id)),e===`gpu`&&u&&f&&n(BW(t,o,f))},m=[{id:`gpu`,label:a(`setup.backend.gpu`)},...c?[{id:`npu`,label:a(`setup.backend.npu`)}]:[],...s.length?[{id:`npu`,label:a(`setup.backend.npu`),unavailable:!0}]:[]],h=u?`npu`:`gpu`;return z(`section`,{className:`setup-backend`,"aria-labelledby":`setup-backend-title`,children:[I(`h3`,{className:`mc-job-title`,id:`setup-backend-title`,children:a(`setup.backend.title`)}),I(Fz,{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(_K,{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 bK=({children:e})=>I(`bdi`,{dir:`ltr`,children:e});function xK({label:e,children:t}){return z(`div`,{className:`found-row`,children:[I(`dt`,{children:e}),I(`dd`,{children:t})]})}function SK(e){return e.family?`${e.name} (${e.family})`:e.name}var CK=[[`llamacpp`,`llama.cpp`],[`flm`,`FastFlowLM`],[`whispercpp`,`whisper.cpp`],[`kokoro`,`Kokoro`],[`sd-cpp`,`stable-diffusion.cpp`]],wK=new Set([`llamacpp`,`flm`]);function TK(e){let t=[];for(let[n,r]of CK){let i=(e.backends??[]).find(e=>e.recipe===n&&e.default);i&&i.state!==`unsupported`&&t.push({name:r,b:i})}return t}function EK(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 DK={release:`release`,release_candidate:`release candidate`,local:`local build`,source:`from source`};function OK(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=TK(e);return{sys:n,cpu:r(e=>e===`cpu`)[0],gpus:i,graphics:i.length?i.map(SK).join(`; `):t?.gpu_name??null,npus:a,runsOn:i[0]?.name??t?.gpu_name??null,npu:a[0]??null,runtimes:o,gaia:EK(n?.gaia_build,n?.gaia_version),build:n?.gaia_build?.kind??null,software:[EK(n?.gaia_build,n?.gaia_version)?`GAIA ${EK(n?.gaia_build,n?.gaia_version)}`:null,n?.lemonade_version?`Lemonade ${n.lemonade_version}`:null,...o.filter(({b:e})=>wK.has(e.recipe)&&AK(e)).map(({name:e,b:t})=>`${e} ${t.version??t.backend}`)].filter(e=>!!e),totalMemory:HO(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 kK={installed:`installed`,update_required:`installed, updates on first use`},AK=e=>e.state===`installed`||e.state===`update_required`,jK={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 MK(e,t){let n=OK(e,t),r=e.lemonade.mode===`external`?`the user's own`:`GAIA's own`;return[`GAIA: ${n.gaia??`unknown`}${n.build?`, ${DK[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}`:``} (${kK[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(SK).join(`; `)||`none found`}`,`Memory: ${n.totalMemory??`unknown`}${e.capacity_gb==null?``:`, ${BO(e.capacity_gb)} for models${e.memory_source?` (${e.memory_source})`:``}`}`,`Models folder: ${n.modelsPath??`unknown`}${n.freeGb==null?``:` (${BO(n.freeGb)} free)`}`,`GAIA data and logs: ${n.gaiaHome??`unknown`}`].join(`
|
|
210
|
-
`)}function NK({plan:e,hardware:t,onChangeMemory:n}){let r=R(),i=OK(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 $t(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 z(`section`,{className:`setup-card found`,"aria-label":r(`setup.found.title`),children:[z(`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(MK(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`?Vr:hi,{size:14,"aria-hidden":`true`})}),s&&I(`span`,{className:`found-copied`,role:`status`,children:r(s===`done`?`setup.found.copied`:`setup.found.copyFailed`)})]}),z(`dl`,{className:`found-glance`,children:[z(xK,{label:r(`setup.found.runsOn`),children:[i.runsOn?I(bK,{children:i.runsOn}):f,i.npu&&I(`span`,{className:`found-chip`,children:I(bK,{children:`NPU`})})]}),z(xK,{label:r(`setup.found.memory`),children:[e.capacity_gb!=null&&i.totalMemory?r(`setup.found.memoryOf`,{size:BO(e.capacity_gb),total:i.totalMemory}):e.capacity_gb==null?i.totalMemory?I(bK,{children:i.totalMemory}):f:I(bK,{children:BO(e.capacity_gb)}),n&&I(`button`,{type:`button`,className:`link-btn found-link`,onClick:n,children:r(`setup.found.changeMemory`)})]}),I(xK,{label:r(`setup.found.space`),children:i.freeGb==null?f:I(bK,{children:BO(i.freeGb)})}),z(xK,{label:r(`setup.found.software`),children:[i.software.length?I(bK,{children:i.software.join(` · `)}):f,i.build&&i.build!==`release`&&I(`span`,{className:`found-chip`,children:r(`setup.found.build.${i.build}`)})]})]}),z(`div`,{className:`found-paths`,children:[[[`setup.found.modelsFolder`,i.modelsPath],[`setup.found.gaiaFolder`,i.gaiaHome]].map(([e,t])=>t&&z(`button`,{type:`button`,className:`link-btn found-open`,onClick:()=>void d(t),title:t,children:[I($i,{size:13,"aria-hidden":`true`}),` `,r(e)]},e)),l&&I(`p`,{className:`setup-error`,role:`alert`,children:l})]}),p.length>0&&z(`details`,{className:`dl-details found-warnings`,children:[z(`summary`,{children:[I(ri,{size:13,"aria-hidden":`true`}),` `,r(`setup.found.noticed`)]}),I(`ul`,{children:p.map(e=>I(`li`,{children:I(bK,{children:e})},e))})]}),z(`button`,{type:`button`,className:`setup-log-toggle found-more`,onClick:()=>o(e=>!e),"aria-expanded":a,children:[I(Yr,{size:13,className:a?`is-open`:``,"aria-hidden":`true`}),` `,r(`setup.found.details`)]}),a&&z(`div`,{className:`found-details`,children:[I(`h4`,{className:`found-group`,children:r(`setup.found.software`)}),z(`dl`,{className:`found-list`,children:[z(xK,{label:I(bK,{children:`GAIA`}),children:[i.gaia?I(bK,{children:i.gaia}):f,i.build&&i.build!==`release`&&I(`span`,{className:`found-chip`,children:r(`setup.found.build.${i.build}`)})]}),I(xK,{label:r(`setup.found.agent`),children:i.sys?.agent_version?I(bK,{children:i.sys.agent_version}):I(`span`,{className:`found-muted`,children:r(`setup.found.agentLater`)})}),z(xK,{label:r(`setup.found.server`),children:[e.lemonade.mode===`external`?r(`setup.found.serverYours`):r(`setup.found.serverOwn`),i.sys?.lemonade_version&&z(P.Fragment,{children:[` `,I(bK,{children:i.sys.lemonade_version})]}),e.lemonade.url&&I(`span`,{className:`found-sub`,children:I(bK,{children:e.lemonade.url})})]})]}),I(`h4`,{className:`found-group`,children:r(`setup.found.runtime`)}),i.runtimes.length?I(`div`,{className:`found-table-wrap`,children:z(`table`,{className:`found-table`,children:[I(`thead`,{className:`visually-hidden`,children:z(`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})=>z(`tr`,{children:[I(`th`,{scope:`row`,children:I(bK,{children:e})}),I(`td`,{children:I(bK,{children:t.backend})}),I(`td`,{children:I(bK,{children:t.version??``})}),I(`td`,{className:AK(t)?`is-installed`:void 0,children:r(AK(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:z(`table`,{className:`found-table`,children:[I(`thead`,{className:`visually-hidden`,children:z(`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=>z(`tr`,{children:[I(`th`,{scope:`row`,title:e.id,children:I(`bdi`,{children:e.name})}),I(`td`,{children:e.roles.map(e=>r(jK[e])).join(` · `)}),z(`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(bK,{children:e.full_size_gb??e.size_gb?BO(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`)}),z(`dl`,{className:`found-list`,children:[I(xK,{label:r(`setup.found.os`),children:i.sys?.os??t?.os?I(bK,{children:i.sys?.os??t?.os}):f}),z(xK,{label:r(`setup.found.cpu`),children:[i.cpu||i.sys?.processor?I(bK,{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(xK,{label:r(`setup.found.gpu`),children:i.graphics?I(bK,{children:i.graphics}):I(`span`,{className:`found-muted`,children:r(`setup.found.none`)})}),I(xK,{label:r(`setup.found.npu`),children:i.npus.length?I(bK,{children:i.npus.map(SK).join(`; `)}):I(`span`,{className:`found-muted`,children:r(`setup.found.none`)})})]})]})]})}function PK({state:e}){return e===`done`?I(Vr,{size:13,"aria-hidden":`true`}):e===`active`?I(La,{size:13,className:`spin`,"aria-hidden":`true`}):I(e===`failed`?Is:e===`question`?ai:li,{size:13,"aria-hidden":`true`})}function FK({hardware:e,hardwareError:t,plan:n,serverRun:r,awaitingChoice:i=!1}){let a=R(),[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?HO(n?.system?.physical_memory,e?.ram_gb):null:BO(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:KO(a.locale,`${Math.round(e.disk_free_gb)} GB`)}),state:f},{id:`server`,label:a(`setup.checks.server`),value:c?d:i?a(`setup.checks.serverChoose`):null,state:c?`done`:l?`failed`:i?`question`:e?`active`:`waiting`},{id:`models`,label:a(`setup.checks.backends`),value:c&&n?.catalog?a(`setup.checks.backendsValue`,{models:String(n.catalog.length),downloaded:String(n.catalog.filter(e=>e.downloaded).length)}):null,state:c&&n?.catalog?`done`:c?`active`:`waiting`}],_=g.filter(e=>e.state===`done`).length,v=Math.round(_/g.length*100),y=I(`ul`,{className:`setup-rows`,id:`setup-check-rows`,children:g.map(e=>z(`li`,{className:`setup-result is-${e.state}`,children:[I(PK,{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?z(`section`,{className:`setup-card setup-checks-done`,"aria-label":a(`setup.check.title`),children:[I(`p`,{className:`setup-result is-done`,role:`status`,children:z(`button`,{type:`button`,className:`setup-checks-toggle`,"aria-expanded":o,"aria-controls":`setup-check-rows`,onClick:()=>s(e=>!e),children:[I(Vr,{size:13,"aria-hidden":`true`}),I(`span`,{className:`setup-result-label`,children:a(`setup.checks.allPassed`,{n:String(g.length)})}),I(Yr,{size:13,className:o?`is-open`:``,"aria-hidden":`true`})]})}),o&&y]}):z(`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`)}):z(P.Fragment,{children:[I(`span`,{children:a(`setup.checks.count`,{done:String(_),total:String(g.length)})}),z(`bdi`,{dir:`ltr`,children:[v,`%`]})]})}),I(`progress`,{className:`setup-progress`,max:100,value:v,"aria-label":a(`setup.check.title`)}),y]})}function IK({steps:e}){let t=R();return z(`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(Vr,{size:13,"aria-hidden":`true`}):e.status===`active`?I(La,{size:13,className:`spin`,"aria-hidden":`true`}):e.status===`failed`?I(ri,{size:13,"aria-hidden":`true`}):t+1,r=z(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 LK={memory:`setup.test.why.memory`,broken:`setup.test.why.broken`,stuck:`setup.test.why.stuck`,missing:`setup.test.why.missing`,agent:`setup.test.why.agent`,answer:`setup.test.why.answer`,window:`setup.test.why.window`};function RK(e,t){return t(`setup.test.job.${e}`)}function zK({state:e}){return e===`passed`?I(Vr,{size:13,"aria-hidden":`true`}):e===`running`?I(La,{size:13,className:`spin`,"aria-hidden":`true`}):I(e===`failed`?Is:e===`skipped`?Ya:li,{size:13,"aria-hidden":`true`})}function BK(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 VK({run:e,expected:t,names:n,catalog:r,onRetry:i,onChooseAnother:a,onCancel:o,onDownloadAgain:s,busy:c}){let l=R(),u=e.tests??[],d=new Set(u.map(e=>e.job)),f=t.filter(e=>!d.has(e)),p=u.filter(e=>e.state!==`running`).length,m=Math.max(u.length+f.length,1),h=Math.round(p/m*100),g=u.filter(e=>e.state===`failed`).filter(e=>!r.find(t=>t.id===e.subject)?.roles.some(e=>[`speech`,`voice`,`image_creation`].includes(e))),_=e.state===`failed`||e.state===`cancelled`,v=s?[...new Set(g.filter(e=>e.kind===`broken`&&e.subject).map(e=>e.subject))]:[],[y,b]=(0,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`),w=e.state===`verifying`&&!u.some(e=>e.state===`running`)?f[0]:void 0;return z(P.Fragment,{children:[z(`section`,{className:`setup-card`,"aria-label":l(`setup.test.title`),children:[z(`div`,{className:`setup-bar-head`,children:[I(`span`,{children:l(`setup.test.count`,{done:String(p),total:String(m)})}),z(`bdi`,{dir:`ltr`,children:[h,`%`]})]}),I(`progress`,{className:`setup-progress`,max:100,value:h,"aria-label":l(`setup.test.title`)}),z(`ul`,{className:`setup-rows`,children:[u.map(e=>z(`li`,{className:`setup-result is-${e.state}`,children:[I(zK,{state:e.state}),z(`span`,{className:`setup-result-label`,children:[RK(e.job,l),e.subject&&z(`bdi`,{className:`setup-result-model`,children:[` `,n[e.subject]??xc(e.subject)]})]}),I(`span`,{className:`setup-result-value`,children:BK(e,l)}),e.error&&z(`div`,{className:`setup-result-error`,children:[I(`p`,{children:l(e.kind===`broken`&&!s?`setup.test.why.brokenYours`:LK[e.kind??``]??`setup.test.why.other`)}),z(`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?z(`li`,{className:`setup-result is-failed`,children:[I(zK,{state:`failed`}),I(`span`,{className:`setup-result-label`,children:RK(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===w?z(`li`,{className:`setup-result is-running`,children:[I(zK,{state:`running`}),I(`span`,{className:`setup-result-label`,children:RK(e,l)}),I(`span`,{className:`setup-result-value`,children:l(`setup.test.starting`)})]},e):z(`li`,{className:`setup-result is-waiting`,children:[I(zK,{state:`waiting`}),I(`span`,{className:`setup-result-label`,children:RK(e,l)}),I(`span`,{className:`setup-result-value`,children:l(`setup.test.waiting`)})]},e))]})]}),e.state===`verifying`&&o&&I(TG,{children:I(`button`,{type:`button`,className:`btn-secondary`,onClick:o,disabled:c,children:l(`setup.progress.cancel`)})}),_&&z(`div`,{className:`setup-failure`,role:`alert`,children:[I(`p`,{children:e.state===`cancelled`?l(`setup.test.cancelled`):g.some(e=>e.kind===`memory`)?l(`setup.test.failedMemory`):l(`setup.test.failedHelp`)}),z(TG,{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?`btn-secondary`:`btn-primary`,onClick:i,disabled:c,children:l(`setup.test.tryAgain`)}),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(EG,{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?``:BO(x)})})})]})}var HK=`https://app.fireworks.ai/settings/users/api-keys`,UK=`https://amd-gaia.ai/docs/guides/llm-gateway`,WK=[{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 GK(e,t){return ae(e.title)?t(e.title):e.title}var KK=1e3,qK=`gaia-setup-choice`;function JK(){try{let e=localStorage.getItem(qK);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 YK(e){try{localStorage.setItem(qK,e)}catch(e){console.warn(`[SetupScreen] could not save the provider choice; a reload will ask again`,e)}}var XK=[`ok`,`needs_key`,`too_old`];function ZK({onChosen:e,onNothingToOffer:t,onFound:n,canInstallOwn:r=!0}){let i=R(),[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,w]=(0,V.useState)(null),[T,E]=(0,V.useState)(`gaia`),D=(0,V.useRef)(!0),O=(0,V.useCallback)(async()=>{c(null);try{let e=await Ce();if(!e.offer){t?.();return}f(!0);let{found:r,unchecked:i=[]}=await St();if(!D.current)return;u(r?[]:i),r&&XK.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 k=(0,V.useCallback)(async t=>{if(a){b(t),S(null);try{await Ue(t===`external`?{mode:t,base_url:a.found.url,api_key:p.trim()||void 0}:{mode:t}),m(``),w(t),e(t)}catch(e){CW(e)&&g(!0),S(e instanceof Error?e.message:String(e))}finally{b(null)}}},[a,p,e]);if(s||l.length>0)return z(P.Fragment,{children:[I(`p`,{className:`setup-hint`,children:s?i(`setup.offer.checkFailed`):i(`setup.offer.noAnswer`,{url:l.join(`, `)})}),s&&z(`details`,{className:`dl-details`,children:[I(`summary`,{children:i(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:s})]}),z(TG,{children:[z(`button`,{type:`button`,className:`btn-secondary`,disabled:d,onClick:()=>void O(),children:[d&&I(La,{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?z(`p`,{className:`setup-hint`,role:`status`,children:[I(La,{size:13,className:`spin`,"aria-hidden":`true`}),` `,i(`setup.offer.looking`)]}):null;let{target:ee,found:te}=a;return C?I(`p`,{className:`setup-hint`,role:`status`,children:C===`external`?i(`setup.offer.usingYours`,{url:te.url}):i(`setup.offer.usingOwn`)}):te.status===`too_old`?z(`p`,{className:`setup-hint`,role:`status`,children:[i(`setup.offer.tooOld`),` `,z(`bdi`,{dir:`ltr`,className:`setup-choice-note`,children:[`Lemonade `,te.version??``,` · `,te.url]})]}):z(`form`,{id:`setup-lemonade-form`,className:`setup-lemonade`,"aria-label":i(`setup.offer.label`),onSubmit:e=>{e.preventDefault(),k(T)},children:[z(`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=>z(`label`,{className:`setup-choice${T===e.mode?` is-active`:``}`,children:[I(`input`,{type:`radio`,name:`setup-server`,value:e.mode,checked:T===e.mode,onChange:()=>{E(e.mode),S(null)}}),z(`span`,{children:[z(`span`,{className:`setup-choice-title`,children:[i(e.title),e.mode===`gaia`&&I(`span`,{className:`setup-choice-tag`,children:i(`setup.offer.recommended`)})]}),I(`span`,{className:`setup-choice-note`,children:i(e.note)})]})]},e.mode))]}),z(`button`,{type:`button`,className:`setup-log-toggle setup-offer-more`,onClick:()=>v(e=>!e),"aria-expanded":_,"aria-controls":`setup-offer-detail`,children:[I(Yr,{size:13,className:_?`is-open`:``,"aria-hidden":`true`}),` `,i(`setup.offer.whatGaiaDoes`)]}),_&&z(`div`,{id:`setup-offer-detail`,children:[I(`p`,{className:`setup-choice-note`,children:z(`bdi`,{dir:`ltr`,children:[`Lemonade`,te.version?` ${te.version}`:``,` · `,te.url]})}),I(`p`,{className:`setup-choice-note`,children:i(`setup.offer.whatGaiaDoesText`)})]}),T===`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&&T===`external`?I(`p`,{className:`setup-error`,role:`alert`,children:i(`setup.offer.keyRejected`)}):I($K,{text:x})),I(TG,{children:z(`button`,{type:`submit`,form:`setup-lemonade-form`,className:`btn-primary`,disabled:!!y||T===`external`&&h&&!p.trim(),children:[y&&I(La,{size:13,className:`spin`}),` `,i(`setup.continue`)]})})]})}function QK({problem:e,onRetry:t,onUseGaia:n}){let r=R(),i=e.kind===`server_too_old`&&e.use_gaia;return z(P.Fragment,{children:[e.start&&z(`details`,{className:`dl-details`,children:[I(`summary`,{children:r(`setup.server.howToStart`)}),I(`pre`,{dir:`ltr`,children:e.start})]}),z(TG,{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 $K({text:e}){let t=R();return z(`div`,{className:`setup-error`,role:`alert`,children:[I(`p`,{children:t(`setup.failedLead`)}),z(`details`,{className:`dl-details`,children:[I(`summary`,{children:t(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:e})]})]})}function eq({run:e}){let t=R();return e.problem?z(`div`,{className:`setup-error`,role:`alert`,children:[I(`p`,{children:t(e.problem.kind===`server_too_old`?`setup.server.tooOld`:`setup.server.unreachable`)}),z(`details`,{className:`dl-details`,children:[I(`summary`,{children:t(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:e.problem.message})]})]}):z(`div`,{className:`setup-error`,role:`alert`,children:[I(`p`,{children:t(e.components?.server===`failed`?`setup.server.ownFailed`:`setup.stopped`)}),e.error&&z(`details`,{className:`dl-details`,children:[I(`summary`,{children:t(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:e.error})]})]})}var tq=[`check`,`plan`,`key`,`models`,`gpu`,`download`,`test`,`ready`];function nq(e){return e instanceof Error?e.message:String(e)}function rq({onReady:e,onClose:t}){let n=R(),r=_c(e=>e.refresh),i=_c(e=>e.select),[a,o]=(0,V.useState)(`local`),[s,c]=(0,V.useState)(`check`),[l,u]=(0,V.useState)(!1),[d,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),[D,O]=(0,V.useState)(null),[k,te]=(0,V.useState)(null),[ne,A]=(0,V.useState)(``),[ie,ae]=(0,V.useState)({busy:!1,error:null,done:!1}),[j,oe]=(0,V.useState)(null),[se,ce]=(0,V.useState)(null),[ue,de]=(0,V.useState)(null),[fe,pe]=(0,V.useState)(null),[me,he]=(0,V.useState)(null),[M,ge]=(0,V.useState)(null),[_e,ve]=(0,V.useState)(!1),[ye,be]=(0,V.useState)(null),[xe,we]=(0,V.useState)(!1),[Te,Ee]=(0,V.useState)(!1),[De,Oe]=(0,V.useState)(null),[Ae,je]=(0,V.useState)(!1),[Me,Pe]=(0,V.useState)(null),[Fe,Ie]=(0,V.useState)(null),[Le,Re]=(0,V.useState)(null),[ze,Be]=(0,V.useState)(!1),[Ve,He]=(0,V.useState)([]),[Ue,We]=(0,V.useState)([]),[Ge,Ke]=(0,V.useState)([]),[Je,Ye]=(0,V.useState)(!1),[Xe,Ze]=(0,V.useState)(!1),Qe=(0,V.useRef)({gaiaLemonade:!1,options:{}}),$e=(0,V.useRef)(null),tt=(0,V.useRef)(!1),nt=(0,V.useRef)(!1),[rt,at]=(0,V.useState)(!1),[ot,st]=(0,V.useState)(!1),ct=(0,V.useCallback)(()=>st(!0),[]),[lt,ut]=(0,V.useState)(null),[ft,pt]=(0,V.useState)(null),mt=(0,V.useRef)(!0);(0,V.useEffect)(()=>(mt.current=!0,()=>{mt.current=!1}),[]);let{network:ht,providers:gt,recheck:_t}=UG(),vt=e=>gt.find(t=>t.id===e),yt=vt(a),bt=yt?.key_source===`environment`&&yt.key_hint?yt:void 0,xt=e=>!!vt(e)?.blocked,St=ht?.reachable!==!1||a===`amd`,Ct=yt?.key_source===`stored`||yt?.key_source===`lemonade`,wt=xt(`fireworks`)&&xt(`amd`),Tt=e=>xt(e)||e===`amd`&&ht?.reachable===!1,Et=e=>xt(e)?n(`settings.privacy.localOnlyBlocked`):n(`setup.key.gatewayOff`),Dt=a!==`local`,Ot=T?.server_only?T:null,kt=T&&!T.server_only?T:null,At=T?.state===`running`||T?.state===`verifying`,jt=kt?.state===`ready`,Mt=rK(T),Pt=!(kt?.models??[]).some(e=>e.state===`downloading`||e.state===`queued`)&&((kt?.tests?.length??0)>0||kt?.state===`verifying`),Ft=(0,V.useCallback)(()=>{w(null),re().then(S).catch(e=>w(nq(e)))},[]),It=(0,V.useRef)(0),Lt=(0,V.useCallback)(async()=>{let e=++It.current;ce(null);try{let t=await qe(!1);return e===It.current?(oe(t),t):null}catch(t){return e===It.current&&ce(nq(t)),null}},[]),Rt=(0,V.useCallback)(async()=>{try{let e=await f();mt.current&&ge(e??null)}catch(e){console.warn(`[SetupScreen] GPU memory could not be read; the step stays hidden`,e)}},[]),zt=t!=null;(0,V.useEffect)(()=>{Ce().then(e=>Ye(e.source===`config`)).catch(e=>console.warn(`[SetupScreen] could not read which Lemonade GAIA uses`,e)),Ft(),Lt(),et().then(e=>{e.state===`idle`&&!e.models?.length||zt&&e.state!==`running`&&e.state!==`verifying`||(E(e),e.server_only||c(`download`),e.skip_chat_model&&o(JK()===`amd`?`amd`:`fireworks`))}).catch(e=>te(nq(e))).finally(()=>at(!0))},[Ft,Lt,zt]),(0,V.useEffect)(()=>{j?.catalog&&j.lemonade.reachable&&(de(e=>e??KW(j)),Rt(),!T&&j.catalog.some(e=>e.partial&&e.selected)&&je(!0))},[j,Rt,T]);let Bt=(0,V.useCallback)(()=>{$e.current&&clearInterval($e.current),$e.current=null},[]),Vt=(T?.models??[]).filter(e=>e.state===`failed`&&e.error_kind===`disk_full`).length;(0,V.useEffect)(()=>{Vt>0&&Lt()},[Vt,Lt]);let Ht=(0,V.useCallback)(async()=>{try{let e=await et();if(O(null),e.state===`idle`&&!e.models?.length){E(null),c(`plan`),Ze(!0),Lt();return}E(e)}catch(e){O(nq(e))}},[Lt,n]);(0,V.useEffect)(()=>(!Mt&&!D||($e.current=setInterval(()=>{Ht()},KK)),Bt),[Mt,D,Ht,Bt]),(0,V.useEffect)(()=>{Ot&&Ot.state===`ready`&&(Ft(),Lt())},[Ot,Ot?.state,Ft,Lt]),(0,V.useEffect)(()=>{jt&&(Ft(),Lt().then(e=>{e&&he(e)}),Rt())},[jt,Ft,Lt,Rt]);let F=(0,V.useRef)(!1),Ut=(0,V.useCallback)(async(e=!1,t={})=>{if(F.current)return!1;F.current=!0,te(null),Oe(null),je(!1),Ze(!1);try{YK(a),Qe.current={gaiaLemonade:e,options:t};let n=await Ne(Dt,e,t);E(n),_(null);let r=t.extraModels??[];return r.length&&Ke(e=>e.filter(e=>!r.includes(e))),t.serverOnly||c(`download`),e&&Ye(!1),!0}catch(e){let t=it(e);if(t)return be({kind:`server`,detail:t,then:`run`}),!1;if(e instanceof Nt&&e.httpStatus===409){let e=await et().catch(()=>null);if(e&&(e.state===`running`||e.state===`verifying`))return E(e),_(null),e.server_only||c(`download`),!0}return te(nq(e)),!1}finally{F.current=!1}},[a,Dt]);(0,V.useEffect)(()=>{s===`check`&&rt&&ot&&j&&!j.lemonade.reachable&&!T&&!tt.current&&(tt.current=!0,Ut(!1,{serverOnly:!0}))},[s,rt,ot,j,T,Ut]);let Wt=!!(ue&&j?.catalog&&j.lemonade.reachable&&(x||C)),Gt=(0,V.useCallback)(()=>{let{gaiaLemonade:e,options:t}=Qe.current;Ut(e,t)},[Ut]),Kt=(0,V.useCallback)((e,t=j)=>{pe(t);let n=t&&ue&&!Dt?nG(t,ue):[];return Ut(!1,{acknowledgeLowDisk:e,keepTrying:_e,extraModels:n})},[j,ue,Dt,_e,Ut]),[qt,Yt]=(0,V.useState)(!1),Xt=(0,V.useRef)(!1),Zt=(0,V.useCallback)(async(e,t=xe)=>{if(!j||!ue||Xt.current)return;Oe(null),Yt(e);let r=jW(j),i=Dt?[]:eG(r,ue).filter(e=>!e.downloaded||e.id===ue.defaultChat),a=i.find(FW);if(a){let e=a.id===ue.defaultChat?`setup.models.cantRun.chat`:`setup.models.cantRun.other`;Oe(n(e,{name:a.name,why:uG(a,n)}))}else if(!Dt&&!t&&i.length>0&&i.every(e=>e.need_gb!=null))be({kind:`no_fit`,models:i});else{Ee(!0),Xt.current=!0;try{let n=j;if(!Dt&&ue.defaultChat&&ue.defaultChat!==n.chat_model.id)try{n=await Se(ue.defaultChat,t,!1)}catch(e){let t=it(e);if(t){be({kind:`server`,detail:t,then:`chat`});return}throw e}if(!Dt){await vK();let e=HW(r,ue);e!==(n.vision_model??null)&&(n=await ke(e,!1));for(let e of tG(n,ue))n=await dt(e.id,e.skipped,!1)}oe(n),await Kt(e,n)}catch(e){Oe(nq(e))}finally{Xt.current=!1,Ee(!1)}}},[j,ue,Dt,xe,Kt,n]),Qt=(0,V.useCallback)(e=>{Oe(null),s===`download`?_(e===b.current?null:e):(_(null),c(e===`test`||e===`ready`?`download`:e))},[s]),L=(0,V.useCallback)(()=>{g??o(`local`),Qt(`plan`)},[Qt,g]),$t=(0,V.useCallback)(()=>{At&&g!=null||(o(`local`),u(!0),Qt(`models`))},[Qt,At,g]),[en,tn]=(0,V.useState)(`local`),nn=_c(e=>e.active?.remote&&e.active.provider!==`local`?e.active.provider:null),rn=_c(e=>e.active?.remote?e.active.model:null),an=(0,V.useCallback)(e=>{At&&g!=null||(u(!1),o(e),tn(`cloud`),Ie(e===nn?rn:null),Qt(`key`))},[Qt,At,g,nn,rn]),on=(0,V.useCallback)(()=>an(JK()===`amd`?`amd`:`fireworks`),[an]),sn=(0,V.useCallback)(()=>{nn?an(nn):Qt(`plan`)},[nn,an,Qt]),cn=!!M?.applies,ln=(0,V.useCallback)(()=>{Qt((g??s)===`gpu`?d:`plan`)},[d,Qt,g,s]),un=(0,V.useCallback)(e=>{p(e),Qt(`gpu`)},[Qt]),dn=(0,V.useRef)({prev:null,next:null});(0,V.useEffect)(()=>{let e=e=>{if(!e.altKey||ye||(e.target instanceof Element?e.target:null)?.closest(`input, textarea, select, [contenteditable="true"]`))return;let t=e.key===`ArrowLeft`?dn.current.prev:e.key===`ArrowRight`?dn.current.next:null;t&&(e.preventDefault(),Qt(t))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[Qt,ye]);let fn=(0,V.useCallback)(async()=>{try{await Jt(),await Ht()}catch(e){Oe(nq(e))}},[Ht]),pn=(0,V.useCallback)(async(e,t)=>{Oe(null),Ee(!0);try{t===`verify`&&await le(e),t===`disk_full`&&Lt();try{E(await N(e,{keepTrying:_e}))}catch(t){let n=it(t);if(!n)throw t;be({kind:`server`,detail:n,then:`retry`,id:e})}}catch(e){Oe(nq(e))}finally{Ee(!1)}},[_e,Lt]),mn=(0,V.useCallback)(async e=>{Oe(null),Ee(!0);try{j?.catalog?.find(t=>t.id===e)?.planned&&oe(await dt(e,!0,!1)),E(t=>t&&{...t,models:t.models?.map(t=>t.id===e?{...t,state:`skipped`}:t)});let{options:t}=Qe.current;Qe.current.options={...t,extraModels:t.extraModels?.filter(t=>t!==e)},de(t=>t&&t.ticked.has(e)?JW(t,jW(j),e,!1):t)}catch(e){Oe(nq(e))}finally{Ee(!1)}},[j]),hn=(0,V.useCallback)(async()=>{await fn(),Gt()},[fn,Gt]),gn=(0,V.useCallback)(async()=>{if(!At){ae({busy:!0,error:null,done:!1});try{await _n(a,{api_key:!Je&&ne||void 0},e=>ae({busy:!0,error:null,done:!1,waiting:e}),()=>!mt.current);let{models:e}=await Nn(a),t=Fe??Le,r=t?e.find(e=>e.id===t):e.find(e=>e.rank===1)??e[0];if(!r)throw Error(t?n(`setup.key.modelNotOffered`,{model:Oc(t)}):n(`setup.key.noModels`));await i(r.id),Pe(r.id),A(``),ae({busy:!1,error:null,done:!0}),Kt(!1)}catch(e){ae({busy:!1,error:nq(e),done:!1})}}},[a,ne,Fe,Le,i,Je,Kt,n,At]),vn=(0,V.useCallback)(e=>{YK(e),o(e),Ie(e===nn?rn:null),Re(null),ae({busy:!1,error:null,done:!1})},[nn,rn]);(0,V.useEffect)(()=>{if(!jt||Ue.length===0||nt.current)return;let e=Ue;nt.current=!0,Ut(!1,{keepTrying:_e,extraModels:e}).then(t=>{nt.current=!1,We(t=>t.filter(t=>!e.includes(t))),t||Ke(t=>[...t,...e.filter(e=>!t.includes(e))])})},[jt,Ue,_e,Ut]);let yn=jt&&Ue.length===0,bn=Dt?Me:kt?.chat_model??(j&&!j.decided_after_server?j.chat_model.id:null),xn=(0,V.useCallback)(async t=>{Oe(null);try{!Dt&&bn&&await i(bn),await r()}catch(e){Oe(nq(e));return}e(t)},[bn,Dt,e,r,i]);(0,V.useEffect)(()=>{yn&&ee().then(e=>He(e.cards)).catch(e=>console.warn(`[SetupScreen] no first tasks to offer`,e))},[yn]);let Sn=(0,V.useMemo)(()=>{let e={};for(let t of j?.catalog??[])e[t.id]=t.name;return e},[j]),Cn=T?.state===`failed`||T?.state===`cancelled`,wn=T?.state===`failed`||!!k||!!se||!!C||!!D||!!De,Tn=zt?Ve:Ve.filter(e=>e.skill!==`check-in`),En=kt&&(kt.state===`failed`||kt.state===`cancelled`)&&(kt.models??[]).length>0&&(kt.models??[]).every(e=>e.state===`ready`||e.state===`skipped`||e.state===`verifying`||e.state===`unchecked`)&&!Mt,Dn=!!kt&&Cn&&!kt.problem&&Object.values(kt.components??{}).includes(`failed`),On=jW(j),kn=ue?ZW(On,ue):[],An=j&&ue?$W(j,ue):null,jn=ue?On.filter(e=>ue.ticked.has(e.id)&&e.downloaded).length:0,Mn=On.some(e=>e.downloaded),Pn=Wt?jn===0?Mn?`setup.check.ledeOthersOnPc`:`setup.check.ledeDone`:kn.length===0?`setup.check.ledeAllOnPc`:`setup.check.ledeSomeOnPc`:`setup.check.lede`,Fn=On.find(e=>e.id===ue?.defaultChat),In=!!x&&!x.compatible&&x.blockers.length>0,Ln=yn?`ready`:s===`download`&&Pt?`test`:s;b.current=Ln;let Rn=g??Ln;(0,V.useEffect)(()=>{y(e=>e.has(Rn)?e:new Set(e).add(Rn))},[Rn]);let zn=(0,V.useRef)(!0);(0,V.useEffect)(()=>{if(zn.current){zn.current=!1;return}let e=document.querySelector(`.setup-scroll`);e&&(e.scrollTop=0),document.getElementById(`setup-title`)?.focus({preventScroll:!0})},[Rn]);let Bn=[{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`}],Vn=e=>e===`models`||e===`key`?`plan`:e===`gpu`?d===`check`?`check`:`plan`:e,Hn=Dt?`key`:l?`models`:`plan`,Un=Bn.findIndex(e=>e.id===Vn(Ln)),Wn=e=>e===`download`||e===`test`||e===`ready`,Gn=[];if(x){let e=[j?.system?.physical_memory?`${HO(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`;Gn.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&&Gn.push(`Couldn't read this PC: ${C}`);lt&&(Gn.push(`Found your Lemonade${lt.version?` ${lt.version}`:``} at ${lt.url}`),Gn.push(ft===`external`?`You chose your own Lemonade`:ft===`gaia`?`You chose GAIA's own Lemonade`:`Waiting for you to choose which Lemonade GAIA uses`)),j&&(!lt||ft)?Gn.push(j.lemonade.reachable?`Model server answering at ${j.lemonade.url??`its address`}`:`No model server answering yet`):se&&Gn.push(`Couldn't read the model list: ${se}`);let Kn=(e,t)=>t<=Un||v.has(e)&&!Wn(e),qn=Bn.map((e,t)=>({id:e.id,label:e.label,status:t<Un?`done`:t>Un?`pending`:Ln===`ready`?`done`:Cn&&(Ln===`download`||Ln===`test`||Ln===`check`)?`failed`:At&&(Ln===`download`||Ln===`test`)?`active`:`current`,shown:e.id===Vn(Rn),onOpen:e.id!==Vn(Rn)&&Kn(e.id,t)?()=>Qt(e.id===`plan`?Hn:e.id):void 0})),B=Bn.findIndex(e=>e.id===Vn(Rn)),Jn=Rn===`gpu`&&d===`check`?.5:tq.indexOf(Rn),Yn=(0,V.useRef)(Jn),Xn=(0,V.useRef)(`forward`);Yn.current!==Jn&&(Xn.current=Jn>Yn.current?`forward`:`back`,Yn.current=Jn);let Zn=Rn===`gpu`?d:Rn===`models`||Rn===`key`?`plan`:B>0?Bn[B-1].id===`plan`?Hn:Bn[B-1].id:null,Qn=(Rn!==`gpu`&&B>=0&&B<Bn.length-1&&Kn(Bn[B+1].id,B+1)?Bn[B+1].id:null)??(g==null?Rn===`check`&&Wt?`plan`:Rn===`gpu`?d:null:null);dn.current={prev:Zn,next:Qn};let $n=Rn===`gpu`||Rn===`models`||Rn===`key`,er=g!=null&&At,tr=[`server`];Dt||tr.push(`chat`),!Dt&&ue&&RW(On,ue)&&tr.push(`vision`),ue&&On.some(e=>NW(e)&&ue.ticked.has(e.id))&&tr.push(`embedding`);for(let e of On)ue&&IW(e)&&ue.ticked.has(e.id)&&!e.downloaded&&tr.push(e.roles[0]);tr.push(`agent`);let nr=Dt&&ie.done&&Me?z(`p`,{className:`setup-ok setup-key-accepted`,role:`status`,children:[I(Vr,{size:14,"aria-hidden":`true`}),` `,n(`setup.key.accepted`,{model:Oc(Me)})]}):null,rr=ue&&!Dt?On.filter(e=>IW(e)&&!ue.ticked.has(e.id)&&!e.downloaded&&(LW(Fn)||!e.roles.includes(`image_creation`))):[],ir=On.find(e=>e.fit_code===`memory`&&e.chat_choice&&e.support===`verified`);return z(`main`,{className:`setup`,"aria-labelledby":`setup-title`,children:[I(IK,{steps:qn}),I(wG,{value:m,children:z(`div`,{className:`setup-pane`,children:[I(`div`,{className:`setup-scroll`,children:z(`div`,{className:`setup-inner`,children:[B>=0&&z(`nav`,{className:`setup-topnav`,"aria-label":n(`setup.nav.label`),children:[I(`button`,{type:`button`,className:`setup-arrow`,onClick:()=>Zn&&Qt(Zn),disabled:!Zn,"aria-label":n(`setup.nav.prev`),children:I(qr,{size:16,"aria-hidden":`true`})}),I(`button`,{type:`button`,className:`setup-arrow`,onClick:()=>Qn&&Qt(Qn),disabled:!Qn,"aria-label":n(`setup.nav.next`),children:I(Yr,{size:16,"aria-hidden":`true`})}),I(`span`,{children:I(`bdi`,{children:n(`setup.nav.stepOf`,{n:String(B+1),total:String(Bn.length)})})}),g!=null&&g!==Ln&&I(`button`,{type:`button`,className:`link-btn`,onClick:()=>_(null),children:n.compose(e=>e(`setup.nav.toLive`,{step:e(Bn.find(e=>e.id===Ln)?.key??`setup.download.step`)}))}),I(pK,{})]}),Ae&&s!==`download`&&z(`div`,{className:`setup-banner`,role:`status`,children:[I(ya,{size:14,"aria-hidden":`true`}),I(`span`,{children:n(`setup.resume.banner`)})]}),Xe&&s!==`download`&&I(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.interrupted`)}),z(`div`,{className:`setup-stage is-${Xn.current}`,children:[Rn===`check`&&z(P.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(Wt?`setup.check.headingDone`:`setup.check.heading`)}),I(`p`,{className:`setup-lede`,children:n(Pn)}),I(FK,{hardware:x,hardwareError:C,plan:j,serverRun:Ot,awaitingChoice:!!lt&&!ot}),Ot?.state===`running`&&z(P.Fragment,{children:[I(sK,{run:Ot,idle:n(`setup.check.serverWorking`),bar:!1}),I(TG,{children:I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void fn(),children:n(`setup.progress.cancel`)})})]}),Wt&&j&&I(NK,{plan:j,hardware:x,onChangeMemory:cn&&g==null?()=>un(`check`):void 0}),Wt&&g==null&&!(lt&&!ot)&&I(TG,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:sn,children:n(`setup.continue`)})}),Ot&&Cn&&z(P.Fragment,{children:[I(eq,{run:Ot}),Ot.problem?I(QK,{problem:Ot.problem,onRetry:()=>void Ut(!1,{serverOnly:!0}),onUseGaia:()=>void Ut(!0,{serverOnly:!0})}):I(TG,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Ut(!!Ot.gaia_lemonade,{serverOnly:!0}),children:n(`setup.tryAgain`)})})]}),se&&!j&&z(P.Fragment,{children:[I($K,{text:se}),z(TG,{children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void Ut(!1,{keepTrying:_e}),children:n(`setup.models.useRecommended`)}),I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Lt(),children:n(`setup.tryAgain`)})]}),I(`p`,{className:`setup-hint`,children:n(`setup.models.useRecommendedNote`)})]}),k&&I($K,{text:k}),k&&!Ot&&j&&!j.lemonade.reachable&&I(TG,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Ut(!1,{serverOnly:!0}),children:n(`setup.tryAgain`)})}),rt&&j&&(!j.lemonade.reachable&&!Ot||Wt&&g==null&&j.lemonade.mode!==`external`)&&I(ZK,{onNothingToOffer:ct,canInstallOwn:!j.lemonade.reachable&&!Ot,onFound:ut,onChosen:e=>{Ye(e===`external`),pt(e),st(!0),Ft(),Lt()}})]}),Rn===`plan`&&j&&ue&&z(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`)}),z(`div`,{className:`setup-where`,children:[z(`section`,{className:`setup-hero setup-where-card${en===`local`?` is-active`:``}`,"aria-label":n(`setup.plan.label`),onClick:()=>!er&&tn(`local`),children:[I(`p`,{className:`setup-eyebrow`,children:ue.chatChosen?n(`setup.plan.yours`):n(`setup.plan.recommended`)}),z(`p`,{className:`setup-hero-title`,children:[I(`input`,{type:`radio`,name:`setup-where`,checked:en===`local`,onChange:()=>tn(`local`),disabled:er,"aria-labelledby":`setup-where-local`}),I(`bdi`,{id:`setup-where-local`,children:n(`setup.plan.run`,{name:Fn?.name??``})})]}),z(`dl`,{className:`setup-facts`,children:[z(`div`,{children:[I(`dt`,{children:n(`setup.summary.download`)}),I(`dd`,{children:I(`bdi`,{dir:`ltr`,children:BO(QW(j,ue).downloadGb??0)})})]}),z(`div`,{children:[I(`dt`,{children:n(`setup.plan.runsOn`)}),I(`dd`,{children:I(`bdi`,{children:Fn&&PW(Fn)?n(`setup.checks.npu`):x?.gpu_name??n(`setup.plan.cpu`)})})]}),z(`div`,{children:[I(`dt`,{children:n(`setup.plan.diskAfter`)}),I(`dd`,{children:I(`bdi`,{dir:`ltr`,children:QW(j,ue).afterGb==null?`—`:BO(Math.max(0,QW(j,ue).afterGb))})})]})]}),z(`ul`,{className:`setup-reasons`,children:[!ue.chatChosen&&I(`li`,{children:n(`setup.plan.why.evaluated`)}),Fn?.need_gb!=null&&Fn.capacity_gb!=null&&Fn.fits&&I(`li`,{children:n(`setup.plan.why.fits`,{need:UO(Fn.need_gb),have:UO(Fn.capacity_gb)})}),I(`li`,{children:n(`setup.plan.why.private`)}),Fn&&PW(Fn)&&I(`li`,{children:n(`setup.plan.why.noImagesNpu`)}),ir&&ir.id!==Fn?.id&&ir.need_gb!=null&&ir.capacity_gb!=null&&I(`li`,{children:n(`setup.plan.why.bigger`,{name:ir.name,need:UO(ir.need_gb),have:UO(ir.capacity_gb)})})]}),kn.length>0&&I(`p`,{className:`setup-hint`,children:n(`setup.plan.cancelAnytime`)})]}),z(`section`,{className:`setup-hero setup-where-card${en===`cloud`?` is-active`:``}${wt?` is-disabled`:``}`,"aria-label":n(`setup.plan.cloudLabel`),onClick:()=>!er&&!wt&&tn(`cloud`),children:[z(`p`,{className:`setup-hero-title`,children:[I(`input`,{type:`radio`,name:`setup-where`,checked:en===`cloud`,onChange:()=>tn(`cloud`),disabled:er||wt,"aria-labelledby":`setup-where-cloud`}),I(`span`,{id:`setup-where-cloud`,children:n(`setup.plan.cloud`)})]}),wt?I(`p`,{className:`setup-hint`,children:n(`settings.privacy.localOnlyBlocked`)}):z(`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`)})]})]})]}),z(TG,{children:[en!==`cloud`&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:$t,disabled:Te||er,children:n(`setup.plan.customize`)}),en===`cloud`?I(`button`,{type:`button`,className:`btn-primary`,onClick:on,disabled:er,children:n(`setup.continue`)}):z(`button`,{type:`button`,className:`btn-primary`,onClick:()=>An?be({kind:`low_disk`}):void Zt(!1),disabled:Te||In||er,children:[Te&&I(La,{size:13,className:`spin`,"aria-hidden":`true`}),` `,kn.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`)})}),In&&z(`div`,{className:`setup-error`,role:`alert`,children:[I(`p`,{children:n(`setup.blocked`)}),z(`details`,{className:`dl-details`,children:[I(`summary`,{children:n(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:x?.blockers.join(`
|
|
211
|
-
`)})]})]}),An&&I(`p`,{className:`setup-error`,role:`alert`,children:n(`setup.summary.short`,{need:BO(An.needGb),free:BO(An.freeGb),drive:n(`setup.summary.theDrive`),freeUp:BO(An.freeUpGb)})}),(De??k)&&I($K,{text:De??k}),en!==`cloud`&&z(`details`,{className:`setup-disclosure`,children:[I(`summary`,{children:n(`setup.plan.whatDownloads`)}),I(JG,{plan:j,models:kn})]})]}),Rn===`gpu`&&M&&z(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(FG,{status:M,onStatus:ge,mode:`setup`,headingId:`setup-title`,names:Sn,cloud:a!==`local`,onBack:ln,onSkip:()=>Qt(d),onContinue:()=>Qt(d)})]}),Rn===`models`&&z(P.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.models.title`)}),j&&ue&&I(yK,{plan:j,selection:ue,onSelection:de,disabled:Te||er,onRecheck:()=>void Lt()}),cn&&M?.total_gb!=null&&M.gpu_gb!=null&&z(`p`,{className:`setup-hint setup-gpu-option`,children:[n(`setup.models.gpu`,{gpu:BO(M.gpu_gb),total:BO(M.total_gb)}),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>un(`models`),disabled:Te||er,children:n(`setup.found.changeMemory`)})]}),I(IG,{plan:j,planError:se,onRetryPlan:()=>void Lt(),onUseRecommended:()=>void Ut(!1,{keepTrying:_e}),selection:ue,onSelection:de,cloud:!1,keepTrying:_e,onKeepTrying:ve,onBack:ln,onContinue:e=>void Zt(e),busy:Te||er,error:De??k})]}),Rn===`key`&&z(`form`,{id:`setup-key-form`,onSubmit:e=>{e.preventDefault(),gn()},className:`setup-form`,children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.key.title`)}),I(Fz,{className:`setup-choices`,"aria-label":n(`setup.key.provider`),children:WK.filter(e=>e.id!==`local`&&(e.id!==`amd`||St)).map(e=>z(`button`,{type:`button`,role:`radio`,"aria-checked":a===e.id,className:`setup-choice${a===e.id?` is-active`:``}${Tt(e.id)?` is-disabled`:``}`,onClick:()=>vn(e.id),disabled:ie.busy||Tt(e.id),title:xt(e.id)?n(`settings.privacy.localOnlyBlocked`):void 0,children:[I(pi,{size:16,"aria-hidden":`true`}),z(`span`,{children:[I(`span`,{className:`setup-choice-title`,children:I(`bdi`,{children:GK(e,n)})}),I(`span`,{className:`setup-choice-note`,children:Tt(e.id)?Et(e.id):n(e.note)})]})]},e.id))}),ht?.reachable===!1&&St&&I(`button`,{type:`button`,className:`link-btn setup-start`,onClick:_t,children:n(`setup.key.checkAgain`)}),xt(a)&&I(`p`,{className:`setup-a11y-alert`,role:`alert`,children:n(`settings.privacy.localOnlyBlocked`)}),a===`fireworks`&&!Je&&!xt(a)&&z(`section`,{className:`setup-card`,children:[I(`h3`,{className:`mc-job-title`,children:n(`setup.key.getOne`)}),z(`ol`,{className:`setup-key-steps`,children:[I(`li`,{children:I(`a`,{href:HK,target:`_blank`,rel:`noreferrer`,children:n(`setup.key.step1`)})}),I(`li`,{children:n(`setup.key.step2`)}),I(`li`,{children:n(`setup.key.step3`)})]})]}),a===`amd`&&!Je&&!xt(a)&&I(`section`,{className:`setup-card`,children:I(`p`,{className:`setup-hint`,children:I(`a`,{href:UK,target:`_blank`,rel:`noreferrer`,children:n(`setup.key.gatewayHelp`)})})}),!xt(a)&&I(wW,{provider:a,limit:3,picked:Fe,onPick:Ie,onDefault:Re,pickDisabled:ie.busy||er}),!Je&&z(P.Fragment,{children:[I(`label`,{className:`setup-key-label`,htmlFor:`setup-key-input`,children:n(`setup.key.labelFor`,{provider:GK(WK.find(e=>e.id===a)??WK[1],n)})}),z(`div`,{className:`setup-row setup-key-row`,children:[I(`input`,{id:`setup-key-input`,className:`settings-input`,type:ze?`text`:`password`,autoComplete:`off`,spellCheck:!1,value:ne,onChange:e=>A(e.target.value),placeholder:Ct?n.bare(`setup.key.placeholder`):n.bare(`setup.key.placeholderNew`)}),I(`button`,{type:`button`,className:`btn-secondary setup-key-show`,"aria-label":n(ze?`setup.key.hide`:`setup.key.show`),title:n(ze?`setup.key.hide`:`setup.key.show`),onClick:()=>Be(e=>!e),children:I(ze?Ni:Fi,{size:14,"aria-hidden":`true`})})]})]}),I(`p`,{className:`setup-hint`,children:n(Je?`setup.key.usersServer`:`setup.key.where`)}),bt&&!Je&&!ne&&I(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.key.foundEnv`,{name:bt.name,hint:bt.key_hint??``})}),ie.busy&&!ie.waiting&&I(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.key.testing`)}),ie.busy&&ie.waiting&&I(`p`,{className:`setup-hint`,role:`status`,children:ie.waiting}),ie.error&&I(`p`,{className:`setup-error`,role:`alert`,children:ie.error}),z(TG,{children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:L,disabled:ie.busy,children:n(`setup.back`)}),z(`button`,{type:`submit`,form:`setup-key-form`,className:`btn-primary`,disabled:ie.busy||Tt(a)||er,children:[ie.busy&&I(La,{size:13,className:`spin`}),` `,n(`setup.key.connect`)]})]})]}),Rn===`download`&&!kt&&z(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`)}),nr,z(`p`,{className:`setup-hint`,role:`status`,children:[I(La,{size:13,className:`spin`,"aria-hidden":`true`}),` `,n(`setup.download.starting`)]})]}),Rn===`download`&&kt&&z(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`)}),nr,j&&I(`section`,{className:`setup-card`,"aria-label":n(`setup.contents.title`),children:I(JG,{plan:j,run:kt,onRetry:Gt,retryDisabled:Te})}),(kt.models?.length??0)>0?I(`div`,{className:D?`is-stale`:void 0,children:I(oK,{status:{...kt,overall:rG(kt,fe??j)},names:Sn,freeGb:j?.disk?.free_gb??null,onCancel:()=>void fn(),onRetry:(e,t)=>void pn(e,t),onResume:e=>void pn(e,null),onResumeAll:Gt,onSkip:e=>void mn(e),onRestart:()=>void hn(),busy:Te||!!D,retryLater:At,labelledBy:`setup-title`})}):At?z(P.Fragment,{children:[I(sK,{run:kt,plan:j,idle:n(`setup.download.working`)}),I(TG,{children:I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void fn(),disabled:Te,children:n(`setup.progress.cancel`)})})]}):null,rr.length>0&&z(`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:rr.map(e=>{let t=Ue.includes(e.id);return z(`li`,{className:`setup-result is-waiting`,children:[I(`span`,{className:`setup-result-label`,children:n(`setup.purpose.${e.roles[0]}`)}),z(`span`,{className:`setup-result-value`,children:[I(`bdi`,{dir:`ltr`,children:e.size_gb==null?n(`setup.contents.sizeOnDownload`):BO(e.size_gb)}),I(`button`,{type:`button`,className:`btn-secondary`,"aria-pressed":t,onClick:()=>We(n=>t?n.filter(t=>t!==e.id):[...n,e.id]),children:n(t?`setup.optional.added`:`setup.optional.add`)})]})]},e.id)})})]}),D&&z(P.Fragment,{children:[I(`p`,{className:`setup-error`,role:`alert`,children:n(`setup.lostContact`,{error:D})}),I(TG,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Ht(),children:n(`setup.reconnect`)})})]}),Cn&&En&&!Dn&&kt.state===`failed`&&!kt.model_failed&&(kt.problem?I(QK,{problem:kt.problem,onRetry:Gt,onUseGaia:()=>void Ut(!0,Qe.current.options)}):z(`div`,{className:`setup-error`,role:`alert`,children:[I(`p`,{children:n(`setup.download.stoppedBeforeCheck`)}),kt.error&&z(`details`,{className:`dl-details`,children:[I(`summary`,{children:n(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:kt.error})]})]})),Cn&&En&&!Dn&&z(P.Fragment,{children:[I(`p`,{className:`setup-hint`,children:n(`setup.download.finishNote`)}),I(TG,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:Gt,disabled:Te,children:n(`setup.finish`)})})]}),Cn&&!En&&!Dn&&!(kt.models??[]).some(e=>e.state===`failed`||e.state===`cancelled`)&&z(P.Fragment,{children:[I(eq,{run:kt}),kt.problem?I(QK,{problem:kt.problem,onRetry:Gt,onUseGaia:()=>void Ut(!0,Qe.current.options)}):I(TG,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Ut(!!kt.gaia_lemonade,Qe.current.options),children:n(`setup.tryAgain`)})})]}),(De||k)&&I($K,{text:De??k})]}),Rn===`test`&&kt&&z(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(VK,{run:kt,expected:tr,names:Sn,catalog:On,onRetry:Gt,onChooseAnother:Dt?void 0:$t,onCancel:()=>void fn(),onDownloadAgain:j?.lemonade.mode===`external`?void 0:e=>void pn(e,`verify`),busy:Te}),Cn&&kt.error&&!(kt.tests??[]).some(e=>e.error===kt.error)&&z(`details`,{className:`dl-details`,children:[I(`summary`,{children:n(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:kt.error})]}),(De||k)&&I($K,{text:De??k})]}),Rn===`ready`&&z(P.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.ready.heading`)}),z(`div`,{className:`setup-done`,role:`status`,children:[I(`div`,{className:`setup-done-head`,children:bn&&I(`p`,{children:n(Dt?`setup.ready.answersCloud`:`setup.ready.answersLocal`,{model:Dt?xc(bn):Sn[bn]??me?.catalog?.find(e=>e.id===bn)?.name??xc(bn)})})}),I(TG,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void xn(),autoFocus:!0,children:n(`setup.ready.start`)})}),!Dt&&me&&I(LG,{plan:me,chatModel:bn,gpu:M}),k&&I($K,{text:k}),(kt?.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??``}`)),Ge.length>0&&!ye&&I(`p`,{className:`setup-failed-extra`,role:`alert`,children:n(`setup.ready.extraNotFetched`,{names:Ge.map(e=>Sn[e]??e).join(`, `)})}),Tn.length>0&&z(P.Fragment,{children:[I(`p`,{className:`setup-hint`,children:n(`setup.ready.tasks`)}),I(HG,{cards:Tn,onPick:e=>void xn(e)})]})]})]})]},Rn),t&&!At&&Rn!==`plan`&&Rn!==`ready`&&I(`div`,{className:`setup-row`,children:I(`button`,{type:`button`,className:`link-btn setup-close`,onClick:t,children:n(`setup.backToGaia`)})}),er&&($n||Rn===`plan`)&&I(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.nav.runGoing`)}),I(fK,{run:T,before:{check:Gn},failed:wn})]})}),I(`div`,{className:`setup-footer`,ref:h})]})}),ye?.kind===`no_fit`&&I(EG,{title:ye.models.length===1?n(`setup.confirm.noFitOne`,{name:ye.models[0].name}):n(`setup.confirm.noFitMany`),confirmLabel:n(`setup.confirm.downloadAnyway`),cancelLabel:n(`setup.confirm.pickSmaller`),onConfirm:()=>{be(null),we(!0),Zt(qt,!0)},onCancel:()=>be(null),children:ye.models.map(e=>z(`p`,{children:[I(`bdi`,{children:e.name}),`: `,uG(e,n)]},e.id))}),ye?.kind===`low_disk`&&An&&I(EG,{title:n(`setup.confirm.lowDiskTitle`),confirmLabel:n(`setup.confirm.downloadAnyway`),cancelLabel:n(`setup.confirm.changeModels`),onConfirm:()=>{be(null),Zt(!0)},onCancel:()=>{be(null),$t()},children:I(`p`,{children:n(`setup.summary.short`,{need:BO(An.needGb),free:BO(An.freeGb),drive:n(`setup.summary.theDrive`),freeUp:BO(An.freeUpGb)})})}),ye?.kind===`server`&&I(EG,{title:ye.detail.code===`low_disk`?n(`setup.confirm.lowDiskTitle`):n(`setup.confirm.noFitServerTitle`),confirmLabel:ye.detail.code===`low_disk`?n(`setup.confirm.downloadAnyway`):n(`setup.confirm.useAnyway`),cancelLabel:n(`setup.confirm.changeModels`),onConfirm:()=>{let e=ye;if(be(null),e.then===`chat`)we(!0),Zt(qt,!0);else if(e.then===`retry`)N(e.id,{keepTrying:_e,acknowledgeLowDisk:!0}).then(E).catch(e=>Oe(nq(e)));else{let{gaiaLemonade:e,options:t}=Qe.current;Ut(e,{...t,acknowledgeLowDisk:!0})}},onCancel:()=>{let e=ye;be(null),e.then!==`retry`&&!jt&&$t()},children:I(`p`,{children:ye.detail.message})})]})}function iq({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 z(`details`,{className:`settings-disclosure`,"data-settings-target":o,open:c||a,onToggle:e=>{a||l(e.currentTarget.open)},children:[z(`summary`,{onClick:e=>{a&&e.preventDefault()},children:[I(Gr,{size:15,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),z(`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 aq=u(Gl()?`settings.desktop.menuBar`:`settings.desktop.tray`),oq=[{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`}],sq=new Set([`startMinimized`]),cq={minimizeToTray:`settings.desktop.keepRunningNoTray`};function lq(e){return e?.reason===`no-host`?`settings.desktop.noTray`:e?.reason===`check-failed`?`settings.desktop.noTrayCheckFailed`:null}function uq(){let e=R(),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=lq(i);return I(iq,{title:e(`settings.desktop.title`),children:z(`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`)}),oq.map(({key:t,label:r,hint:i})=>{let a=sq.has(t)?d:null,o=d&&cq[t]||i;return z(`div`,{children:[z(`label`,{className:`setting-row`,children:[I(`span`,{children:e(r,{tray:aq})}),z(`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:aq})}),I(`span`,{className:`toggle-track`})]})]}),I(`p`,{className:`settings-hint`,id:`desktop-${t}-hint`,children:a?e(a):e(o,{tray:aq})})]},t)}),o&&I(`p`,{className:`settings-error`,role:`alert`,children:o})]})})}function dq(){return window.gaiaUpdater}var fq={status:`idle`,version:null,progress:0,releaseNotes:null,error:null,currentVersion:null,pinnedVersion:null,autoUpdate:!1,includePrereleases:!1};function pq(){let[e,t]=(0,V.useState)({...fq}),n=(0,V.useRef)(!1),r=(0,V.useRef)(0),i=(0,V.useCallback)(async()=>{let e=dq();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=dq();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 mq=`gaia-update-error:`;function hq(e,t){let n=`update.err.${e}`;return ae(n)?u(n,t??{}):null}function gq(e){let t=e instanceof Error?e.message:String(e),n=t.indexOf(mq);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=hq(r.code,r.params)??r.message??r.code,a=r.note&&hq(r.note.code,r.note.params);return a?u(`update.err.withNote`,{error:i,note:a}):i}function _q(e,t){let n=gq(e);return typeof n==`object`?t(n.ref,n.params):String(n)}function vq(){return window.gaiaUpdater}function yq({onClose:e,manualInstall:t=!1}){let n=R(),[r,i]=(0,V.useState)({kind:`loading`}),a=(0,V.useRef)(null);(0,V.useEffect)(()=>{let e=vq();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.`})},[]),pt(!0,e),on(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=vq();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:gq(e)})})}}function c(e){if(!e)return``;try{return new Date(e).toLocaleDateString(Sn(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:z(`div`,{className:`version-picker-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":n(`update.picker.title`),ref:a,children:[z(`div`,{className:`version-picker-header`,children:[I(`h3`,{children:n(`update.picker.title`)}),I(`button`,{className:`version-picker-close`,onClick:e,"aria-label":n(`update.picker.close`),type:`button`,children:`×`})]}),z(`div`,{className:`version-picker-body`,children:[r.kind===`loading`&&z(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[I(`span`,{className:`version-picker-spinner`}),n(`update.picker.loading`)]}),r.kind===`error`&&z(`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:z(`button`,{type:`button`,className:`version-picker-row`,"data-version":e.version,"aria-label":e.isCurrent?n(`update.picker.rowInstalled`,{version:e.version}):e.isPinned?n(`update.picker.rowPinned`,{version:e.version}):e.version,"aria-disabled":e.isCurrent?`true`:`false`,onClick:()=>o(e,r.releases),disabled:e.isCurrent,children:[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`&&z(`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`&&z(`div`,{className:`version-picker-confirm`,children:[t?I(`p`,{children:n(`update.picker.manual`,{version:r.release.version})}):z(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})})]}),z(`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`&&z(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[I(`span`,{className:`version-picker-spinner`}),n(`update.picker.starting`)]})]})]})})}var bq=`https://github.com/amd/gaia/releases`;function xq(e){return/^\d+\.\d+\.\d+-/.test(e??``)}function Sq(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 Cq(){let e=pq(),t=R(),n=dq(),[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:u(e),reason:gq(n)}))}finally{i(!1)}}}let d=e.status===`disabled`,f=r||e.status===`checking`||e.status===`downloading`,p=e.readFailed?Sq(e,t):`${t(`update.settings.running`,{version:e.currentVersion??t(`update.settings.unknownVersion`)})} ${Sq(e,t)}`,m=[`available`,`downloaded`,`error`].includes(e.status)||!!e.pinnedVersion||!!e.installFailed||!!e.configError||!!e.readFailed||!!a;return I(iq,{title:t(`update.settings.title`),titleId:`updates-label`,hint:p,forceOpen:m,children:z(`div`,{className:`settings-field`,role:`group`,"aria-labelledby":`updates-label`,children:[I(`p`,{className:`visually-hidden`,role:`status`,children:p}),!e.manualInstall&&z(P.Fragment,{children:[z(`label`,{className:`setting-row`,children:[I(`span`,{children:t(`update.settings.auto`)}),z(`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:d,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`)})]}),z(`label`,{className:`setting-row`,children:[I(`span`,{children:t(`update.settings.rc`)}),z(`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:d,onChange:()=>{r||l(`update.action.saveRc`,t=>t.setIncludePrereleases(!e.includePrereleases))}}),I(`span`,{className:`toggle-track`})]})]}),z(`p`,{className:`settings-hint`,id:`updates-rc-hint`,children:[t(`update.settings.rcHint`),xq(e.currentVersion)&&` ${t(`update.settings.rcHintRunning`)}`]}),e.pinnedVersion&&z(`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`)})]}),z(`div`,{className:`setting-actions`,children:[e.status===`available`&&e.manualInstall&&I(`a`,{className:`btn-primary update-download-link`,href:e.downloadUrl??bq,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:f||d,onClick:()=>void l(`update.action.check`,e=>e.check()),children:t(`update.settings.check`)}),I(`button`,{type:`button`,className:`btn-secondary`,disabled:f||d,onClick:()=>c(!0),children:t(`update.settings.pick`)}),e.previousVersion&&I(`button`,{type:`button`,className:`btn-secondary`,"aria-describedby":`updates-back-hint`,disabled:f||d,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:bq})}),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(yq,{onClose:()=>c(!1),manualInstall:e.manualInstall})]})})}var wq=[{value:`light`,label:`settings.theme.light`},{value:`dark`,label:`settings.theme.dark`},{value:`system`,label:`settings.theme.system`}],Tq={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 Eq(){let e=R(),t=B(e=>e.locale),n=B(e=>e.setLocale),r=B(e=>e.themePreference),i=B(e=>e.setThemePreference),a=B(e=>e.palette),o=B(e=>e.setPalette),s=B(e=>e.customColors),c=B(e=>e.setCustomColors),l=eH(e=>e.visible),u=eH(e=>e.setVisible),d=e=>t=>c({...s,[e]:t.target.value.toUpperCase()});return z(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.general`)}),z(`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:ge.map(({meta:e})=>I(`option`,{value:e.code,lang:e.code,dir:e.dir,children:Fe(e)},e.code))}),I(`span`,{className:`settings-hint`,children:e(`settings.languageHint`)})]}),z(`div`,{className:`settings-field`,children:[I(`span`,{className:`settings-label`,id:`appearance-label`,children:e(`settings.appearance`)}),I(Fz,{className:`segmented`,"aria-labelledby":`appearance-label`,children:wq.map(t=>I(`button`,{type:`button`,role:`radio`,"aria-checked":r===t.value,className:r===t.value?`is-active`:``,onClick:()=>i(t.value),children:e(t.label)},t.value))})]}),z(`div`,{className:`settings-field`,children:[z(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`resources.settings`)}),z(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,checked:l,onChange:e=>u(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`)})]}),z(iq,{title:e(`settings.colors`),titleId:`palette-label`,defaultOpen:a===`custom`,children:[z(Fz,{className:`palette-grid`,"aria-labelledby":`palette-label`,children:[vn.map(t=>z(`button`,{type:`button`,role:`radio`,"aria-checked":a===t.id,className:`palette-tile${a===t.id?` is-active`:``}`,onClick:()=>o(t.id),children:[I(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:t.swatch.map(e=>I(`i`,{style:{background:e}},e))}),e(Tq[t.id])]},t.id)),z(`button`,{type:`button`,role:`radio`,"aria-checked":a===`custom`,className:`palette-tile${a===`custom`?` is-active`:``}`,onClick:()=>o(`custom`),children:[z(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:[I(`i`,{style:{background:s.base}}),I(`i`,{style:{background:s.accent}})]}),e(`settings.colors.custom`)]})]}),a===`custom`&&z(`div`,{className:`palette-custom`,children:[z(`label`,{className:`palette-color`,htmlFor:`custom-accent`,children:[I(`input`,{id:`custom-accent`,type:`color`,value:s.accent,onChange:d(`accent`)}),z(`span`,{children:[e(`settings.colors.accent`),I(`small`,{children:e(`settings.colors.accentHint`)})]})]}),z(`label`,{className:`palette-color`,htmlFor:`custom-base`,children:[I(`input`,{id:`custom-base`,type:`color`,value:s.base,onChange:d(`base`)}),z(`span`,{children:[e(`settings.colors.base`),I(`small`,{children:e(`settings.colors.baseHint`)})]})]}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>c(de),children:e(`settings.colors.reset`)}),I(`p`,{className:`settings-hint`,children:e(`settings.colors.hint`)})]})]}),I(uq,{}),I(Cq,{}),I(iq,{title:e(`settings.shortcuts`),children:I(`dl`,{className:`shortcut-list`,children:xW().map(({label:t,keys:n})=>z(`div`,{className:`shortcut-row`,children:[I(`dt`,{children:I(`kbd`,{children:Yl(n)})}),I(`dd`,{children:e(t)})]},t))})})]})}function Dq(e){return/not reachable|not answering|model server at|ConnectionPool|NewConnectionError|Connection refused|Max retries/i.test(e)}function Oq(e){return/gaia init/i.test(e??``)}var kq=`GAIA doesn't run this model server, so it can't start it. Start it the way you usually do.`;function Aq(e,t){return t?t===kq?e(`server.otherServerStart`):t:null}function jq(e){return!!e&&!e.lemonade_running&&(Oq(e.start_command)||Oq(e.start_instruction))}function Mq({className:e=`btn-secondary`}){let t=R();return I(`button`,{type:`button`,className:e,onClick:()=>window.dispatchEvent(new CustomEvent(`gaia:set-up-local`)),children:t(`settings.errors.setUpLocal`)})}function Nq({message:e,onRetry:t}){let n=R(),r=B(e=>jq(e.systemStatus));return Dq(e)?z(`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(Mq,{className:`btn-primary`}),t&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:t,children:n(`settings.key.checkAgain`)}),z(`details`,{className:`settings-more`,children:[z(`summary`,{children:[I(Gr,{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 Pq({onAdded:e}){let t=R(),[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 It(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 Gt(n.trim(),i);r(``),a(``),s(null),e(o.display_name??o.model_id??t(`settings.custom.theModel`))}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(null)}},[e,i,n,t]);return z(`form`,{className:`settings-field custom-model-add`,onSubmit:e=>{e.preventDefault(),p(``)},children:[I(`label`,{className:`visually-hidden`,htmlFor:`custom-model-url`,children:t(`settings.custom.title`)}),I(`span`,{className:`settings-hint`,children:t(`settings.custom.hint`)}),z(`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`}),z(`button`,{type:`submit`,className:`btn-secondary`,disabled:c!==null||!n.trim(),children:[c===`check`?I(La,{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=>z(`li`,{className:e.ok?`is-ok`:`is-failed`,children:[e.ok?I(Vr,{size:13,"aria-label":t(`settings.custom.passed`)}):I(Is,{size:13,"aria-label":t(`settings.custom.failed`)}),z(`bdi`,{children:[I(`strong`,{children:e.label}),` — `,e.detail]})]},e.id))});return o.ok?z(`details`,{className:`custom-model-checks-summary`,children:[z(`summary`,{children:[I(Vr,{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=>z(`li`,{className:`is-warning`,children:[I(ws,{size:13,"aria-label":t(`settings.custom.warning`)}),` `,I(`bdi`,{children:e})]},e))}),o&&o.variants.length>1&&z(`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=>z(`option`,{value:e.file,children:[e.quant,` · `,e.size_gb,` GB`,e.fits?``:` · ${t.bare(`settings.custom.tooLarge`)}`]},e.file))})]}),o?.ok&&z(`div`,{className:`settings-row`,children:[z(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void m(),disabled:c!==null,children:[c===`add`?I(La,{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(Nq,{message:u})]})}function Fq(e){return e instanceof Error?e.message:String(e)}function Iq(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function Lq({downloadsSlot:e}){let t=R(),[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(null),[u,d]=(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=Qc(e=>e.status),S=Qc(e=>e.started),C=(0,V.useMemo)(()=>Yc(x,S),[x,S]),w=Qc(e=>e.error),T=Qc(e=>e.refresh),E=Qc(e=>e.enqueue),D=Qc(e=>e.cancel),O=(0,V.useCallback)(async(e=!1)=>{a(null);try{let t=await qe();r(t),s(n=>e||!n?KW(t):n)}catch(e){a(Fq(e))}},[]);(0,V.useEffect)(()=>{O(!0),T(),(async()=>{try{v(await f()??null)}catch(e){b(Fq(e))}})()},[O,T]);let k=(C?.models??[]).filter(e=>e.state===`ready`).map(e=>e.id).join(`,`),ee=(0,V.useRef)(k);(0,V.useEffect)(()=>{k!==ee.current&&(ee.current=k,O(!0))},[k,O]);let te=(0,V.useMemo)(()=>{let e={};for(let t of C?.models??[])e[t.id]=t;return e},[C]),ne=(0,V.useMemo)(()=>{let e={};for(let t of n?.catalog??[])e[t.id]=t.name;return e},[n]),A=(0,V.useMemo)(()=>n?KW(n):null,[n]),re=jW(n),ie=n&&o?ZW(re,o).filter(e=>te[e.id]?.state!==`downloading`):[],ae=ie.reduce((e,t)=>e+(t.size_gb??0),0),j=!!n&&!!o&&!!A&&(!Iq(o.ticked,A.ticked)||o.defaultChat!==A.defaultChat||ie.length>0),oe=(0,V.useCallback)(async(e,i)=>{if(!n||!o)return;if(m(null),!e){let e=eG(re,o).filter(e=>!e.downloaded||e.id===o.defaultChat);if(e.length>0&&e.every(e=>e.need_gb!=null)){l({kind:`no_fit`,models:e});return}}let a=$W(n,o);if(a&&!i)l({kind:`low_disk`,message:a.drop?t(`setup.summary.shortDrop`,{need:BO(a.needGb),free:BO(a.freeGb),drive:mG(n.disk?.path??null)??t(`setup.summary.theDrive`),freeUp:BO(a.freeUpGb),name:a.drop.name,saves:BO(a.drop.size_gb??0)}):t(`setup.summary.short`,{need:BO(a.needGb),free:BO(a.freeGb),drive:mG(n.disk?.path??null)??t(`setup.summary.theDrive`),freeUp:BO(a.freeUpGb)})});else{d(!0);try{let i=n,a=!1;if(o.defaultChat&&o.defaultChat!==i.chat_model.id){a=!0;try{i=await Se(o.defaultChat,e||h)}catch(e){let t=it(e);if(t){l({kind:`server`,detail:t});return}throw e}}for(let e of tG(i,o))i=await dt(e.id,e.skipped);let c=ZW(jW(i),o).map(e=>e.id).filter(e=>te[e]?.state!==`downloading`);r(i),s({...o,defaultChat:i.chat_model.id});let u=null;if(a&&i.chat_model.downloaded)try{await _c.getState().select(i.chat_model.id)}catch(e){u=Fq(e),_c.getState().refresh()}else _c.getState().refresh();c.length&&await E(c,{acknowledgeLowDisk:!0}),m(u===null?{ok:!0,text:t(`settings.models.applied`)}:{ok:!1,text:t(`settings.models.appliedNotSwitched`,{reason:u})})}catch(e){m({ok:!1,text:Fq(e)})}finally{d(!1)}}},[n,o,re,h,te,E,t]),se=(0,V.useCallback)(async e=>{l(null),d(!0),m(null);try{let n=await le(e.id);Qs(),r(n),s(KW(n)),m({ok:!0,text:t(`settings.models.removed`,{name:e.name,size:BO(n.freed_gb)})})}catch(e){m({ok:!1,text:Fq(e)})}finally{d(!1)}},[t]),ce=(0,V.useCallback)((e,t)=>{(async()=>{try{t===`verify`&&await le(e),await E([e])}catch(e){m({ok:!1,text:Fq(e)})}})()},[E]),ue=!!C&&(C.models?.length??0)>0&&(rK(C)||C.models.some(e=>e.state!==`skipped`))&&C&&z(`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(oK,{status:C,names:ne,freeGb:n?.disk?.free_gb??null,onCancel:()=>void D(),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 z(P.Fragment,{children:[I(iq,{title:t(`settings.models.manage`),hint:t(`settings.models.manageHint`),forceOpen:!!i||p?.ok===!1,children:z(`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(Nq,{message:i}),n&&!n.lemonade.reachable&&I(`p`,{className:`settings-hint`,children:t(`settings.models.unavailable`)}),!n&&!i&&z(`p`,{className:`settings-hint`,children:[I(La,{size:13,className:`spin`,"aria-hidden":`true`}),` `,t(`setup.models.loading`)]}),n&&n.lemonade.reachable&&o&&z(P.Fragment,{children:[I(gG,{plan:n,selection:o,onToggle:(e,t)=>s(JW(o,re,e,t)),onDefaultChat:e=>s(YW(o,re,e)),labelledBy:`settings-models-title`,place:`settings`,disabled:u,progress:te,rowActions:e=>e.downloaded&&e.id!==o.defaultChat?I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>l({kind:`remove`,entry:e}),disabled:u||te[e.id]?.state===`downloading`,"aria-label":t(`settings.models.removeAria`,{name:e.name}),children:t(`settings.models.remove`)}):null}),I(pG,{plan:n,selection:o}),I(`div`,{className:`models-apply`,children:z(`button`,{type:`button`,className:`btn-primary`,disabled:!j||u,onClick:()=>void oe(!1,!1),children:[u&&I(La,{size:13,className:`spin`,"aria-hidden":`true`}),u?t(`settings.models.applying`):ie.length>0?t(`settings.models.applyDownload`,{size:BO(Math.round(ae*10)/10)}):t(`settings.models.apply`)]})})]}),p?.ok&&I(`p`,{className:`settings-ok`,role:`status`,children:p.text}),p&&!p.ok&&I(Nq,{message:p.text})]})}),(_?.applies||y&&!Dq(y))&&I(iq,{title:t(`gpu.settingsTitle`),titleId:`settings-gpu-title`,defaultOpen:!!_?.pending||!!y,children:z(`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(FG,{status:_,onStatus:v,mode:`settings`,names:ne,headingId:`settings-gpu-title`})]})}),e?(0,Mj.createPortal)(ue,e):e===void 0&&ue,c?.kind===`remove`&&I(EG,{title:t(`settings.models.removeTitle`,{name:c.entry.name}),confirmLabel:t(`settings.models.removeConfirm`),cancelLabel:t(`settings.models.keep`),danger:!0,onConfirm:()=>void se(c.entry),onCancel:()=>l(null),children:I(`p`,{children:MW(c.entry)?t(`settings.models.removeVision`,{size:BO(c.entry.full_size_gb??0)}):t(`settings.models.removeBody`,{size:BO(c.entry.full_size_gb??0)})})}),c?.kind===`no_fit`&&I(EG,{title:c.models.length===1?t(`setup.confirm.noFitOne`,{name:c.models[0].name}):t(`setup.confirm.noFitMany`),confirmLabel:t(`setup.confirm.downloadAnyway`),cancelLabel:t(`setup.confirm.pickSmaller`),onConfirm:()=>{l(null),g(!0),oe(!0,!1)},onCancel:()=>l(null),children:c.models.map(e=>z(`p`,{children:[I(`bdi`,{children:e.name}),`: `,uG(e,t)]},e.id))}),c?.kind===`low_disk`&&I(EG,{title:t(`setup.confirm.lowDiskTitle`),confirmLabel:t(`setup.confirm.downloadAnyway`),cancelLabel:t(`setup.confirm.changeModels`),onConfirm:()=>{l(null),oe(!0,!0)},onCancel:()=>l(null),children:I(`p`,{children:c.message})}),c?.kind===`server`&&I(EG,{title:t(`setup.confirm.noFitServerTitle`),confirmLabel:t(`setup.confirm.useAnyway`),cancelLabel:t(`setup.confirm.changeModels`),onConfirm:()=>{l(null),g(!0),oe(!0,!1)},onCancel:()=>l(null),children:I(`p`,{children:c.detail.message})})]})}var Rq=`auto`;function zq({model:e}){let t=R(),[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),Qt(e).then(r).catch(e=>a(e instanceof Error?e.message:String(e)))},[e]);let d=(0,V.useCallback)(async n=>{s(!0),a(null),l(null);try{let i=await Un(e,n===Rq?null:Number(n));r(i);let a={name:i.display_name,size:i.chosen?Nc(i.chosen):u(`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 Dq(i)?I(`p`,{className:`settings-hint`,children:t(`settings.ctx.serverDown`)}):I(`p`,{className:`settings-error`,role:`alert`,children:i});if(!n)return z(`p`,{className:`settings-hint`,children:[I(La,{size:13,className:`spin`}),` `,t(`settings.ctx.checking`)]});let f=n.chosen==null?Rq:String(n.chosen),p=n.chosen!=null&&n.loaded_ctx!=null&&n.loaded_ctx!==n.chosen;return z(P.Fragment,{children:[z(`div`,{className:`model-in-use-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`ctx-size`,children:t(`settings.ctx.label`)}),z(`select`,{id:`ctx-size`,className:`settings-input`,value:f,onChange:e=>void d(e.target.value),disabled:o||n.options.length===0,children:[I(`option`,{value:Rq,children:n.automatic?t.bare(`settings.ctx.automaticAt`,{size:Nc(n.automatic)}):t.bare(`settings.ctx.automatic`)}),n.options.map(e=>I(`option`,{value:String(e),children:t.bare(`settings.ctx.tokens`,{size:Nc(e)})},e))]})]}),n.note&&I(`span`,{className:`settings-hint`,children:I(`bdi`,{children:n.note})}),!n.note&&!!n.max_fit&&z(`details`,{className:`settings-more`,children:[z(`summary`,{children:[I(Gr,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,t(`settings.ctx.about`)]}),I(`span`,{className:`settings-hint`,children:t(`settings.ctx.explain`,{size:Nc(n.max_fit),name:n.display_name,memory:n.memory_source})})]}),p&&I(`span`,{className:`settings-hint`,children:t(`settings.ctx.loadedAt`,{size:Nc(n.loaded_ctx)})}),o&&z(`span`,{className:`settings-hint`,children:[I(La,{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 Bq({row:e,providerName:t,choices:n,labels:r,disabled:i,onSwitch:a}){let o=R(),s=_c(e=>e.active),c=_c(e=>e.error),l=s?.model??null,u=!!s?.remote,d=n.some(e=>bc(l,e.id)),f=s?.downloaded??e?.downloaded,p=u?null:e?.state===`loaded`?o(`settings.model.loaded`):f===!0?o(`settings.model.downloaded`):f===!1?o(`settings.model.notDownloaded`):null,m=e?.placement?.device;return z(`section`,{className:`settings-card model-in-use`,"aria-label":o(`settings.model.inUseTitle`),children:[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||xc(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&&z(`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&&z(`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:Nc(e.context_length)})})]}),(n.length>1||n.length===1&&!d)&&z(`div`,{className:`model-in-use-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`model-switch`,children:o(`settings.model.switch`)}),z(`select`,{id:`model-switch`,className:`settings-input`,value:d?n.find(e=>bc(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(zq,{model:l})]})}var Vq=e=>new Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:0}).format(e),Hq={"best overall, fastest":`settings.model.note.bestFastest`,cheapest:`settings.model.note.cheapest`,"most truthful":`settings.model.note.mostTruthful`},Uq=/^(\d+\/\d+) tasks · quality ([\d.]+\/5) · (\$[\d.]+) per (\d+)-task run$/;function Wq(e,t){let n=Uq.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 Gq({model:e,label:t,current:n,remote:r,busy:i,onUse:a,onDownload:o,onAskRemove:s,onNpuRecheck:c}){let l=R(),u=Fc(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:Vq(e.context_length)}):null].filter(Boolean).join(` · `)),p=!!(e.display_name||f||e.evidence||e.custom&&e.source_url);return z(`li`,{className:`model-row${n?` is-current`:``}`,children:[z(`div`,{className:`model-row-text`,children:[I(`bdi`,{className:`model-row-name`,title:e.id,children:t}),z(`div`,{className:`model-chips`,children:[e.placement?.device&&I(`span`,{className:`model-badge is-device`,children:e.placement.device.toUpperCase()}),e.rank&&z(`span`,{className:`model-badge is-rank`,children:[z(`bdi`,{dir:`ltr`,children:[`#`,e.rank]}),` `,e.note&&(Hq[e.note]?l(Hq[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&&I(`span`,{className:`model-badge is-fit`,children:l(`settings.model.fits`)}),e.custom&&I(`span`,{className:`model-badge is-custom`,children:l(`settings.model.custom`)}),!!e.size_gb&&z(`bdi`,{dir:`ltr`,className:`model-badge is-size`,children:[e.size_gb,` GB`]}),p&&z(`details`,{className:`settings-more model-row-facts`,children:[z(`summary`,{children:[I(Gr,{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:HL(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(_K,{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})})]}),z(`div`,{className:`model-row-actions`,children:[e.custom&&!n&&!u&&z(`button`,{type:`button`,className:`btn-secondary`,onClick:s,disabled:i!==null,"aria-label":l(`settings.models.removeAria`,{name:t}),children:[i===`rm:${e.id}`?I(La,{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?z(`span`,{className:`model-row-current`,children:[I(Vr,{size:13,"aria-hidden":`true`}),` `,l(`settings.model.inUse`)]}):e.available===!1?null:u?z(`span`,{className:`model-row-current`,children:[I(La,{size:13,className:`spin`}),` `,u.message?I(`bdi`,{children:u.message}):z(`bdi`,{dir:`ltr`,children:[Math.round(u.percent),`%`]})]}):e.downloaded?z(`button`,{type:`button`,className:`btn-secondary`,onClick:a,disabled:i!==null,"aria-label":l(`settings.model.useAria`,{name:t}),children:[i===e.id?I(La,{size:13,className:`spin`}):null,` `,l(`settings.model.use`)]}):z(`button`,{type:`button`,className:`btn-secondary`,onClick:o,disabled:i!==null,"aria-label":l(`settings.model.downloadAria`,{name:t}),children:[i===`dl:${e.id}`?I(La,{size:13,className:`spin`}):null,` `,l(`settings.model.download`)]})]})]})}function Kq(){let e=R(),[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(tt)},[l]),!t)return r?I(`p`,{className:`settings-error`,role:`alert`,children:r}):z(`p`,{className:`settings-hint`,children:[I(La,{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 z(`section`,{className:`settings-field spending`,"aria-label":e(`settings.spend.aria`),children:[I(`span`,{className:`settings-label`,children:e(`settings.spend.title`)}),z(`p`,{className:`spending-total`,children:[I(`bdi`,{dir:`ltr`,children:I(`strong`,{children:UL(t.total_usd)})}),u!=null&&z(P.Fragment,{children:[` `,e(`settings.spend.ofLimit`,{limit:UL(u)})]}),z(`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`&&z(`p`,{className:`spending-warning`,role:`status`,children:[I(ws,{size:13,"aria-hidden":`true`}),` `,e(`settings.spend.near`)]}),t.state===`reached`&&z(`div`,{className:`spending-warning`,role:`alert`,children:[z(`p`,{children:[I(ws,{size:13,"aria-hidden":`true`}),` `,e(`settings.spend.reached`)]}),I(`button`,{type:`button`,className:`btn-secondary`,disabled:s,onClick:()=>void l(mn),children:e(`settings.spend.allow`)})]}),t.state===`allowed_over`&&I(`p`,{className:`settings-hint`,children:e(`settings.spend.allowed`)}),z(`form`,{className:`settings-row`,onSubmit:e=>{e.preventDefault(),f&&p&&l(()=>v(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}),z(`button`,{type:`submit`,className:`btn-secondary`,disabled:s||!f||!p,children:[s?I(La,{size:13,className:`spin`}):null,` `,e(`settings.advanced.save`)]}),u!=null&&I(`button`,{type:`button`,className:`btn-secondary`,disabled:s,onClick:()=>void l(()=>v(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 qq=2e3;function Jq(e,t){return e.key_source===`environment`?t(`settings.key.setIn`,{name:e.env_var??``}):`••••••••••••••••••••${e.key_hint?` ${e.key_hint}`:``}`}function Yq(){let e=R(),t=_c(e=>e.active),n=_c(e=>e.select),r=_c(e=>e.refresh),i=_c(e=>e.rememberNames),a=B(e=>!!e.systemStatus&&gI(e.systemStatus)===`unresponsive`),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(null),u=B(e=>e.settingsProvider),[d,f]=(0,V.useState)(u??t?.provider??`local`),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(``),[y,b]=(0,V.useState)(!1),[x,S]=(0,V.useState)(``),[C,w]=(0,V.useState)(!1),[T,E]=(0,V.useState)(!1),[D,O]=(0,V.useState)({base_url:``,auth_header_name:``,auth_header_prefix:``}),[k,ee]=(0,V.useState)(null),[te,ne]=(0,V.useState)(null),[A,re]=(0,V.useState)(null),[ie,ae]=(0,V.useState)(null),[j,oe]=(0,V.useState)(!1),[se,ce]=(0,V.useState)(null),[le,ue]=(0,V.useState)(null),de=(0,V.useRef)(d);de.current=d;let fe=(0,V.useRef)(!0);(0,V.useEffect)(()=>(fe.current=!0,()=>{fe.current=!1}),[]);let pe=o?.find(e=>e.id===d)??null,me=e=>e?.network?.reachable===!1,he=e=>!!e?.blocked,M=!!pe&&!he(pe)&&(!pe.remote||!!pe.models_discovered),N=(0,V.useCallback)(async()=>{l(null);try{let e=await cn();s(e.providers),e.lemonade_error&&l(e.lemonade_error)}catch(e){l(e instanceof Error?e.message:String(e))}},[]),ge=(0,V.useCallback)(async()=>{try{await Jn()}catch(e){l(e instanceof Error?e.message:String(e));return}await N()},[N]),_e=(0,V.useCallback)(async(t,n=!1)=>{n||(m(null),g(null));try{let n=await Nn(t);i(n.models),m(n.models),ne(n.memory_gb?`${n.memory_gb} GB (${n.memory_source})`:n.capacity_error??null),n.blocked&&g(e(`settings.privacy.localOnlyBlocked`))}catch(e){g(e instanceof Error?e.message:String(e))}},[i,e]);(0,V.useEffect)(()=>{N()},[N]);let ve=!!o?.some(e=>e.key_state===`waiting_for_os_permission`);(0,V.useEffect)(()=>{if(!ve)return;let e=setInterval(()=>{N()},qq);return()=>clearInterval(e)},[ve,N]);let ye=t?.provider;(0,V.useEffect)(()=>{ye&&!u&&f(ye)},[ye,u]),(0,V.useEffect)(()=>{S(``),w(!1),E(!1),re(null),v(``),b(!1),oe(!1)},[d]),(0,V.useEffect)(()=>{M?_e(d):m(null)},[d,M,_e]);let be=(0,V.useCallback)(async()=>{if(pe){ee(`connect`),re(null);try{let t=d===`amd`?{api_key:x||void 0,...Object.fromEntries(Object.entries(D).filter(([,e])=>e!==``))}:{api_key:x||void 0},n=()=>!fe.current||de.current!==d,r=await _n(d,t,e=>{n()||re({ok:!0,text:e})},n);if(n())return;S(``),w(!1),re({ok:!0,text:r.remember_error?e(`settings.key.sessionOnly`,{reason:r.remember_error}):r.known_models?e(`settings.key.knownModels`,{name:pe.name}):r.remembered?e(`settings.key.kept`):e(`settings.key.connectedDone`)}),await N()}catch(e){fe.current&&de.current===d&&re({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{fe.current&&ee(null)}}},[D,d,x,N,pe,e]),xe=(0,V.useCallback)(async()=>{ee(`forget`),E(!1),re(null);try{await Wn(d),re({ok:!0,text:e(`settings.key.cleared`)}),await N(),await r()}catch(e){re({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{ee(null)}},[d,N,r,e]),Se=(0,V.useCallback)(async t=>{ee(t),re(null);try{await n(t),re({ok:!0,text:e(`settings.model.switched`,{name:xc(t)})}),await _e(d,!0)}catch(e){re({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{ee(null)}},[d,_e,n,e]),Ce=(0,V.useCallback)(async e=>{ee(`dl:${e}`),re(null),oe(!1);try{await Ve(e),await _e(`local`,!0)}catch(e){re({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{ee(null)}},[_e]),we=(0,V.useCallback)(async t=>{let n=_c.getState().active?.model;ee(`rm:${t}`),re(null);try{let r=await Rt(t);ae(null);let i=r.cleared.includes(`last_model`)?`settings.model.removedLast`:r.cleared.includes(`default_model`)?`settings.model.removedDefault`:`settings.model.removed`;re({ok:!0,text:e(i,{name:r.display_name})}),await _e(`local`,!0),await vc(n)}catch(e){re({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{ee(null)}},[_e,e]),Te=(0,V.useCallback)(async t=>{re({ok:!0,text:e(`settings.model.added`,{name:t})}),oe(!0),await _e(`local`,!0)},[_e,e]),Ee=!!p?.some(Fc);(0,V.useEffect)(()=>{if(Ee)return()=>{r()}},[Ee,r]),(0,V.useEffect)(()=>{if(d!==`local`||!Ee)return;let e=setInterval(()=>{_e(`local`,!0)},qq);return()=>clearInterval(e)},[Ee,d,_e]);let De=t?.model,Oe=p?.find(e=>bc(De,e.id));(0,V.useEffect)(()=>{Oe&&ce(Oe)},[Oe]);let ke=(0,V.useMemo)(()=>{let e=_.trim().toLowerCase();return(p??[]).filter(t=>!e||t.id.toLowerCase().includes(e)||(t.display_name??``).toLowerCase().includes(e))},[p,_]),Ae=ke.filter(e=>e.available!==!1),je=d===`fireworks`&&!y&&!_.trim()&&Ae.some(e=>e.rank!==null),Me=e=>e.rank!==null||e.id===t?.model,Ne=je?Ae.filter(Me):Ae,Pe=je?Ae.filter(e=>!Me(e)):[],Fe=ke.filter(e=>e.available===!1),Ie=kc(p??[]),Le=!!_.trim(),Re=e=>bc(t?.model,e.id),ze=pe?.id===`local`,Be=Ne.filter(e=>e.downloaded).sort((e,t)=>Number(Re(t))-Number(Re(e))),He=Ne.filter(e=>!e.downloaded),Ue=(p??[]).filter(e=>e.available!==!1&&e.downloaded),We=Ue.filter(Me),Ge=ie?(p??[]).find(e=>e.id===ie)??null:null,Ke=d===`fireworks`&&We.some(e=>e.rank!==null)?We:Ue,qe=e=>I(Gq,{model:e,label:Ie[e.id],current:Re(e),remote:!!pe?.remote,busy:k,onUse:()=>void Se(e.id),onDownload:()=>void Ce(e.id),onAskRemove:()=>ae(e.id),onNpuRecheck:()=>void _e(d,!0)},e.id);return z(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.model`)}),I(Bq,{row:Oe??(bc(se?.id,t?.model)?se:null),providerName:t?.provider_name??null,choices:M?Ke:[],labels:Ie,disabled:k!==null,onSwitch:e=>void Se(e)}),I(Fz,{className:`provider-tabs`,"aria-label":e(`settings.model.whereRuns`),children:(o??[{id:`local`,name:`Local`,remote:!1}]).map(t=>z(`button`,{type:`button`,role:`radio`,"aria-checked":d===t.id,className:`provider-tab${d===t.id?` is-active`:``}${me(t)||he(t)?` is-disabled`:``}`,onClick:()=>f(t.id),disabled:(me(t)||he(t))&&d!==t.id,title:he(t)?e(`settings.privacy.localOnlyBlocked`):me(t)?e(`setup.key.gatewayOff`):void 0,children:[t.remote?I(pi,{size:14,"aria-hidden":`true`}):I(yi,{size:14,"aria-hidden":`true`}),I(`span`,{children:GL(e,t)}),t.remote&&t.models_discovered&&I(`span`,{className:`provider-tab-dot`,"aria-label":e(`settings.key.connectedDot`)})]},t.id))}),!o&&!c&&z(`p`,{className:`settings-hint`,role:`status`,children:[I(La,{size:13,className:`spin`}),` `,e(a?`settings.model.waitingServer`:`settings.loading`)]}),c&&I(Nq,{message:c,onRetry:()=>{N(),_e(d)}}),pe&&z(`section`,{className:`settings-card`,"aria-label":GL(e,pe),children:[pe.remote&&I(`p`,{className:`settings-note`,children:I(`bdi`,{children:KL(e,pe)})}),z(`details`,{className:`settings-more`,children:[z(`summary`,{children:[I(Gr,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,e(`settings.model.howItWorks`)]}),I(`p`,{className:`settings-hint`,children:e(`settings.model.lede`)}),ze&&I(`p`,{className:`settings-hint`,children:I(`bdi`,{children:KL(e,pe)})}),ze&&I(`p`,{className:`settings-hint`,children:e(`settings.model.devices`)}),ze&&te&&I(`p`,{className:`settings-hint`,children:e(`settings.model.memory`,{memory:te})})]}),pe.remote&&!M&&z(`div`,{className:`settings-field`,children:[I(`span`,{className:`settings-label`,children:e(`settings.model.prices`)}),I(wW,{provider:pe.id})]}),he(pe)&&I(`div`,{className:`settings-field`,children:I(`p`,{className:`settings-error`,role:`alert`,children:e(`settings.privacy.localOnlyBlocked`)})}),me(pe)&&z(`div`,{className:`settings-field`,children:[I(`p`,{className:`settings-error`,role:`alert`,children:pe.network?.detail}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void N(),children:e(`settings.key.checkAgain`)})]}),pe.remote&&!me(pe)&&!he(pe)&&z(`form`,{className:`settings-field`,"data-settings-target":`cloud-key`,onSubmit:e=>{e.preventDefault(),be()},children:[z(`div`,{className:`settings-row settings-row-between`,children:[I(`span`,{className:`settings-label`,children:e(`settings.key.title`)}),pe.key_source&&I(`span`,{className:`settings-key-status ${M?`settings-ok`:`settings-error`}`,children:e(M?`settings.key.connected`:`settings.key.notConnected`)})]}),!pe.key_source&&pe.key_state===`store_locked`&&z(`span`,{className:`settings-hint`,role:`status`,children:[e(`settings.key.storeLocked`),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>void ge(),children:e(`settings.key.unlockAgain`)})]}),!pe.key_source&&pe.key_state!==`store_locked`&&I(`span`,{className:`settings-hint`,children:pe.key_state===`waiting_for_os_permission`?pe.key_message??e(`settings.key.waitingOs`):e(`settings.key.none`)}),pe.id===`amd`&&(!pe.key_source||C)&&z(`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`)})]}),pe.key_source&&!C?z(`div`,{className:`settings-row`,children:[I(`input`,{className:`settings-input settings-key-masked`,readOnly:!0,value:Jq(pe,e),"aria-label":e(`settings.key.savedAria`,{name:pe.name})}),!M&&z(`button`,{type:`submit`,className:`btn-primary`,disabled:k!==null,children:[k===`connect`?I(La,{size:13,className:`spin`}):null,e(`settings.key.reconnect`)]}),(pe.key_source!==`environment`||pe.key_from_gaia_env)&&z(P.Fragment,{children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>w(!0),disabled:k!==null,children:e(`settings.key.replace`)}),pe.key_source!==`environment`&&I(`button`,{type:`button`,className:`btn-secondary settings-key-remove`,onClick:()=>E(!0),disabled:k!==null,"aria-label":e(`settings.key.remove`),title:e(`settings.key.remove`),children:I(Ss,{size:14,"aria-hidden":`true`})})]})]}):z(`div`,{className:`settings-row`,children:[I(`input`,{className:`settings-input`,type:`password`,autoComplete:`off`,spellCheck:!1,autoFocus:C,value:x,onChange:e=>S(e.target.value),placeholder:e(C?`settings.key.pasteNew`:`settings.key.paste`),"aria-label":e(`settings.key.fieldAria`,{name:pe.name})}),z(`button`,{type:`submit`,className:`btn-primary`,disabled:k!==null||!x,children:[k===`connect`?I(La,{size:13,className:`spin`}):null,e(C?`settings.key.save`:`settings.key.connect`)]}),C&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{S(``),w(!1)},disabled:k!==null,children:e(`settings.key.cancel`)})]}),pe.key_source&&!M&&!pe.error&&!C&&I(`p`,{className:`settings-hint`,children:e(`settings.key.notConnectedHint`,{name:pe.name})}),pe.error&&I(`p`,{className:`settings-error`,role:`alert`,children:pe.error})]}),A?.ok&&I(`p`,{className:`settings-ok`,role:`status`,children:A.text}),A&&!A.ok&&I(Nq,{message:A.text}),pe.known_models&&I(`p`,{className:`settings-hint`,role:`status`,children:e(`settings.key.knownList`,{name:pe.name})}),ze&&I(`div`,{className:`models-downloads-slot`,ref:ue}),M&&z(`div`,{className:`settings-field`,children:[I(`span`,{className:`settings-label`,children:e(`settings.model.models`)}),(p?.length??0)>6&&I(`input`,{className:`settings-input`,type:`search`,value:_,onChange:e=>v(e.target.value),placeholder:e(`settings.model.search`),"aria-label":e(`settings.model.search`)}),h&&!(c&&Dq(h))&&I(Nq,{message:h}),!p&&!h&&z(`p`,{className:`settings-hint`,children:[I(La,{size:13,className:`spin`}),` `,e(`settings.loading`)]}),p&&ke.length===0&&!h&&I(`p`,{className:`settings-hint`,children:e(Le||!ze?`settings.model.noMatch`:`settings.model.noModels`)}),ze?z(P.Fragment,{children:[Be.length>0&&I(iq,{title:e(`settings.model.groupDownloaded`),count:Be.length,defaultOpen:!0,forceOpen:Le,targetId:`models-on-pc`,children:I(`ul`,{className:`model-list`,children:Be.map(qe)})}),He.length>0&&I(iq,{title:e(`settings.model.groupAvailable`),count:He.length,defaultOpen:Be.length===0,forceOpen:Le||j||He.some(Fc),children:I(`ul`,{className:`model-list`,children:He.map(qe)})})]}):I(`ul`,{className:`model-list`,children:Ne.map(qe)}),je&&Pe.length>0&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>b(!0),children:e(`settings.model.showAll`)}),d===`fireworks`&&y&&!Le&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>b(!1),children:e(`settings.model.showRecommended`)}),Fe.length>0&&I(iq,{title:e(`settings.model.groupUnavailable`),count:Fe.length,forceOpen:Le,children:I(`ul`,{className:`model-list`,children:Fe.map(qe)})})]}),ze&&M&&I(iq,{title:e(`settings.custom.title`),children:I(Pq,{onAdded:e=>void Te(e)})}),ze&&M&&I(Lq,{downloadsSlot:le}),pe.remote&&I(Kq,{})]}),Ge&&I(EG,{title:e(`settings.models.removeTitle`,{name:Ie[Ge.id]??Ge.id}),confirmLabel:Ge.downloaded?e(`settings.model.removeDownload`):e(`settings.models.remove`),cancelLabel:e(`settings.models.keep`),danger:!0,onConfirm:()=>{ae(null),we(Ge.id)},onCancel:()=>ae(null),children:Ge.downloaded&&I(`p`,{children:e(`settings.model.removeDownloadBody`)})}),T&&pe&&I(EG,{title:e(`settings.key.removeAsk`),confirmLabel:e(`settings.key.remove`),cancelLabel:e(`settings.models.keep`),danger:!0,onConfirm:()=>void xe(),onCancel:()=>E(!1),children:I(`p`,{children:e(`settings.key.removeBody`,{name:pe.name})})})]})}function Xq(){let e=R(),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 yt();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(()=>Ln(e))},[d]),p=()=>{i===`full_access`?f(`ask`):s(e=>!e)},m=e=>t.find(t=>t.id===e)?.title??e;return z(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.permissions`)}),I(`p`,{className:`settings-pane-lede`,children:e(`settings.permissions.lede`)}),z(`details`,{className:`settings-more`,children:[z(`summary`,{children:[I(Gr,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,e(`settings.model.howItWorks`)]}),I(`p`,{className:`settings-hint`,children:e(`settings.permissions.perChat`)})]}),z(`section`,{className:`settings-card`,"aria-label":e(`settings.permissions.newChats`),children:[z(`label`,{className:`setting-row`,children:[I(`span`,{className:`settings-label`,children:e(`settings.permissions.fullAccess`)}),z(`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&&z(`div`,{className:`settings-warning`,role:`alert`,children:[I(`p`,{children:e(`settings.permissions.warning`)}),z(`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(iq,{title:e(`settings.permissions.chats`),count:n.length,defaultOpen:!0,children:n.map(t=>z(`section`,{className:`settings-field permission-chat`,"aria-label":m(t.session_id),children:[z(`div`,{className:`settings-row settings-row-between`,children:[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 kt(t.session_id,`ask`)).mode;gR(t.session_id,e)}),children:e(`settings.permissions.turnOff`)})]}),t.grants.length>0&&I(`ul`,{className:`grant-list`,children:t.grants.map(n=>z(`li`,{className:`grant-row`,children:[I(`code`,{children:n.label}),I(`button`,{type:`button`,className:`link-btn`,onClick:()=>d(()=>Tt(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(()=>Tt(t.session_id)),children:e(`settings.permissions.revokeAll`)})]},t.session_id))})]})}var Zq=(e,t)=>!e.error&&(!e.installed||e.update)&&(t||!e.has_code);function Qq(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 $q({onAdded:e}){let t=R(),[n,r]=(0,V.useState)(``),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(null),[d,f]=(0,V.useState)(new Set),[p,m]=(0,V.useState)(!1),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)([]);(0,V.useEffect)(()=>{let e=!1;return jt().then(t=>{e||v(t.libraries)}).catch(n=>{e||s(t(`settings.skills.link.featuredFailed`,{error:CM(n,t)}))}),()=>{e=!0}},[t]);let y=async e=>{if(e.trim()){a(`preview`),s(null),l(null),g(null);try{let t=await rn(e.trim());l(t),f(new Set(t.skills.filter(e=>Zq(e,!1)).map(e=>e.name)))}catch(e){s(CM(e,t))}finally{a(null)}}},b=async()=>{if(c&&d.size!==0){a(`add`),s(null);try{let t=await bt(c.link,[...d],p,c.pin);g(t),l(null),r(``),t.added.length&&e()}catch(e){s(CM(e,t))}finally{a(null)}}},x=e=>f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),S=e=>{if(m(e),!e&&c){let e=new Set(c.skills.filter(e=>e.has_code).map(e=>e.name));f(t=>new Set([...t].filter(t=>!e.has(t))))}},C=c?.skills.filter(e=>Zq(e,p))??[],w=C.length>0&&C.every(e=>d.has(e.name)),T=c?.skills.some(e=>e.has_code&&!e.error)??!1;return z(`div`,{className:`settings-card skill-link`,children:[z(`div`,{className:`skill-link-top`,children:[I(`span`,{className:`settings-label`,children:t(`settings.skills.link.title`)}),_.map(e=>{let n=`settings.skills.link.featured.${e.id}`,a=ae(n);return I(`button`,{type:`button`,className:`btn-secondary skill-link-chip`,onClick:()=>{r(e.url),y(e.url)},disabled:i!==null,title:a?t(n):e.description,"aria-label":t(`settings.skills.link.getAria`,{name:e.name,description:a?u(n):e.description}),children:t(`settings.skills.link.get`,{name:e.name})},e.id)})]}),z(`form`,{className:`skill-link-form`,onSubmit:e=>{e.preventDefault(),y(n)},children:[I(`input`,{className:`settings-input`,type:`text`,inputMode:`url`,value:n,onChange:e=>r(e.target.value),onPaste:e=>{let t=e.clipboardData.getData(`text`).trim();t&&(e.preventDefault(),r(t),y(t))},placeholder:t.bare(`settings.skills.link.placeholder`),title:t(`settings.skills.link.hint`),"aria-label":t(`settings.skills.link.aria`),disabled:i!==null}),I(`button`,{type:`submit`,className:`btn-secondary`,disabled:!n.trim()||i!==null,children:i===`preview`?z(P.Fragment,{children:[I(La,{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&&z(`div`,{className:`skill-link-preview`,children:[z(`details`,{className:`skill-link-warning`,role:`note`,children:[z(`summary`,{children:[I(ws,{size:14,"aria-hidden":`true`}),t(`settings.skills.link.trust`)]}),I(`p`,{children:I(`bdi`,{children:c.warning})})]}),z(`div`,{className:`skill-link-head`,children:[I(`span`,{children:t(`settings.skills.link.found`,{n:c.skills.length,source:c.source})}),C.length>1&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>f(w?new Set:new Set(C.map(e=>e.name))),children:t(w?`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,p),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&&!p;return I(`li`,{className:`skill-row`,children:z(`label`,{className:`skill-link-pick`,children:[I(`input`,{type:`checkbox`,checked:n&&d.has(e.name),disabled:!n,onChange:()=>x(e.name),"aria-label":t(`settings.skills.link.addAria`,{name:e.name})}),z(`span`,{className:`skill-row-text`,children:[z(`span`,{className:`skill-row-name`,children:[e.name,r&&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(`span`,{className:`skill-row-desc skill-link-desc`,dir:`auto`,title:e.description,children:I(`bdi`,{children:e.description})}),e.permissions.length>0?z(`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=>z(`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&&z(`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&&!p&&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)})}),z(`div`,{className:`skill-link-actions`,children:[T&&z(`label`,{className:`skill-link-code`,title:t(`settings.skills.link.codeHint`),children:[I(`input`,{type:`checkbox`,checked:p,onChange:e=>S(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 b(),disabled:d.size===0||i!==null,children:i===`add`?z(P.Fragment,{children:[I(La,{size:13,className:`spin`}),` `,t(`settings.skills.link.adding`)]}):t(`settings.skills.link.add`,{n:d.size})})]})]}),h&&z(`div`,{className:`skill-link-result`,role:`status`,children:[h.added.length>0&&I(`p`,{children:Qq(h,t)}),Object.keys(h.failed).length>0&&z(`details`,{children:[I(`summary`,{children:t(`settings.skills.link.notAdded`,{n:Object.keys(h.failed).length})}),I(`ul`,{className:`grant-list`,children:Object.entries(h.failed).map(([e,t])=>z(`li`,{children:[I(`bdi`,{children:I(`strong`,{children:e})}),` — `,I(`bdi`,{children:t})]},e))})]})]})]})}var eJ={path:`~/.gaia/skills`},tJ=[{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:eJ},{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 nJ(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 rJ({text:e}){let t=R(),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]),z(P.Fragment,{children:[I(`span`,{ref:n,className:`skill-row-desc${r?` is-open`:``}${a||r?` is-toggle`:``}`,dir:`auto`,onClick:a||r?()=>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 iJ({onUseSkill:e}){let t=R(),[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)({}),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(``),u=(0,V.useRef)(null),d=(0,V.useRef)(!0),f=(0,V.useCallback)(()=>{Ut().then(e=>{d.current&&(r(e.skills),a(e.invalid),s(null))}).catch(e=>{d.current&&s(e instanceof Error?e.message:String(e))})},[]);(0,V.useEffect)(()=>(d.current=!0,f(),window.addEventListener(`focus`,f),()=>{d.current=!1,window.removeEventListener(`focus`,f)}),[f]);let p=c.trim().toLowerCase(),m=(n??[]).filter(e=>!p||e.name.toLowerCase().includes(p)||e.description.toLowerCase().includes(p)),h=n?.every(e=>tJ.some(t=>t.source===e.source))??!1,g=n=>z(`li`,{className:`skill-row`,children:[z(`div`,{className:`skill-row-text`,children:[z(`span`,{className:`skill-row-name`,children:[I(`span`,{title:n.version?`v${n.version}`:void 0,children:n.name}),n.always_on&&z(`span`,{className:`skill-row-meta`,children:[` · `,t(`settings.skills.alwaysOn`)]})]}),I(rJ,{text:n.description})]}),!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.name);return z(`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`)}),z(`details`,{className:`settings-more`,children:[z(`summary`,{children:[I(Gr,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,t(`settings.model.howItWorks`)]}),I(`p`,{className:`settings-hint`,children:t(`settings.skills.how`,eJ)})]}),I($q,{onAdded:f}),o&&I(`p`,{className:`settings-error`,role:`alert`,children:o}),!n&&!o&&z(`p`,{className:`settings-hint`,children:[I(La,{size:13,className:`spin`}),` `,t(`settings.loading`)]}),n&&n.length>6&&I(`input`,{ref:u,className:`settings-input`,type:`search`,value:c,onChange:e=>l(e.target.value),placeholder:t(`settings.skills.search`),"aria-label":t(`settings.skills.search`)}),n&&n.length===0&&I(`p`,{className:`settings-hint`,children:t(`settings.skills.none`)}),p&&n&&n.length>0&&m.length===0&&z(`p`,{className:`settings-hint`,role:`status`,children:[t(`settings.skills.noMatch`,{query:c.trim()}),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>{l(``),u.current?.focus()},children:t(`settings.skills.clearSearch`)})]}),h?tJ.map(e=>{let n=m.filter(t=>t.source===e.source);return n.length===0&&(p||!e.empty)?null:I(iq,{title:t(e.title),count:n.length,hint:t(e.note,e.params),defaultOpen:e.source===`agent-bundled`||e.source===`user`&&n.length>0,forceOpen:!!p,children: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(g)})})},e.source)}):I(`ul`,{className:`skill-list`,children:m.map(g)}),Object.keys(i).length>0&&z(`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(nJ(n),{name:e.split(/[\\/]/).filter(Boolean).pop()??e})},e))})]})]})}function aJ(){let e=R(),t=B(e=>e.setShowMemoryDashboard),n=B(e=>e.closeSettings),[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(!1);(0,V.useEffect)(()=>{DU().then(i).catch(e=>o(e instanceof Error?e.message:String(e)))},[]);let l=(0,V.useCallback)(async()=>{if(r){c(!0),o(null);try{i(await OU({memory_enabled:!r.memory_enabled}))}catch(e){o(e instanceof Error?e.message:String(e))}finally{c(!1)}}},[r]);return z(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.memory`)}),I(`p`,{className:`settings-pane-lede`,children:e(`settings.memory.lede`)}),z(`section`,{className:`settings-card`,"aria-label":e(`settings.section.memory`),children:[z(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`settings.memory.remember`)}),z(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,checked:!!r?.memory_enabled,onChange:()=>void l(),disabled:!r||s,"aria-label":e(`settings.memory.remember`)}),I(`span`,{className:`toggle-track`})]})]}),a&&I(`p`,{className:`settings-error`,role:`alert`,children:a}),z(`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`)})]})]})]})}function oJ(e,t,n){if(!/^\d+$/.test(e.trim()))return!1;let r=Number(e);return r>=t&&r<=n}function sJ(e){return e<1048576?`${Math.ceil(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function cJ(){let e=R(),[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)(()=>{ue().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=!oJ(r,1,365)||d.days,m=!oJ(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 Oe(Number(r),Number(a));n(t),c({ok:!0,text:e(`settings.undo.saved`)})}catch(t){let n=t instanceof Nt&&t.httpStatus===422?t.fields:[],r=n.includes(`retention_days`),i=n.includes(`max_mb`);r||i?(f({days:r,mb:i}),c({ok:!1,text:e(`settings.undo.fix`)})):c({ok:!1,text:t instanceof Error?t.message:String(t)})}finally{u(!1)}}};return z(`div`,{className:`settings-field`,"aria-label":e(`settings.privacy.undo`),children:[I(`span`,{className:`settings-label`,children:e(`settings.privacy.undo`)}),I(`p`,{className:`settings-hint`,children:e(`settings.undo.hint`)}),t&&z(P.Fragment,{children:[z(`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`)}),z(`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`)}),z(`div`,{className:`setting-row setting-row-path`,children:[I(`span`,{children:e(`settings.undo.inUse`)}),z(`span`,{children:[e.plural(`settings.undo.used`,t.turns,{size:sJ(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 lJ={root:`settings-report`,button:`btn-secondary`,hint:`settings-hint`,error:`settings-error`};function uJ(){let e=R(),t=B(e=>e.sessions),n=B(e=>e.removeSession),r=Tc(),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 Je().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=_c.getState().active?.model,r=!t;f(r),m(!0),g(null);try{let t=await xe({network_policy:r?`local_ai_only`:`cloud_allowed`});f(t.network_policy===`local_ai_only`),vc(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 $t(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 Vn(e.id),n(e.id)}catch(t){r.push(`${e.title}: ${t instanceof Error?t.message:t}`)}c(!1),o(null),u(r.length?{ok:!1,text:e(`settings.privacy.deleteFailed`,{n:r.length,reason:r.join(`; `)})}:{ok:!0,text:e(`settings.privacy.deleted`)})},[n,t,e]);return z(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.privacy`)}),z(`section`,{className:`settings-card`,"aria-label":e(`settings.privacy.localOnlyTitle`),children:[z(`div`,{children:[z(`label`,{className:`setting-row`,children:[I(`strong`,{children:e(`settings.privacy.localOnlyTitle`)}),z(`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})]}),z(`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&&z(`div`,{className:`setting-row setting-row-path`,children:[I(`span`,{children:e(`settings.privacy.dataFolder`)}),z(`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`)})]})]})]}),z(`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(wN,{classes:lJ})]}),I(iq,{title:e(`settings.privacy.undo`),children:I(cJ,{})}),z(`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&&z(EG,{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 dJ=[{id:`needs_approval`,label:`settings.alerts.approval`},{id:`question`,label:`settings.alerts.question`},{id:`finished`,label:`settings.alerts.finished`}],fJ=[{value:`banner`,label:`settings.alerts.banner`},{value:`badge`,label:`settings.alerts.badge`},{value:`off`,label:`settings.alerts.off`}],pJ=[0,10,20,30,50];function mJ(){return typeof Notification>`u`?`unsupported`:Notification.permission}function hJ(){let e=R(),t=kl(),n=!!window.gaiaAPI,[r,i]=(0,V.useState)(mJ),a=Object.values(t.modes).includes(`banner`);return z(`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`)}),z(`section`,{className:`settings-card`,"aria-label":e(`settings.alerts.when`),children:[dJ.map(n=>z(`div`,{className:`setting-row`,children:[I(`span`,{id:`alert-${n.id}`,children:e(n.label)}),I(Fz,{className:`segmented`,"aria-labelledby":`alert-${n.id}`,children:fJ.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(mJ())})},children:e(`settings.alerts.allow`)}):I(`p`,{className:`settings-error`,role:`alert`,children:e(r===`unsupported`?`settings.alerts.unsupported`:`settings.alerts.blocked`)})),z(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`settings.alerts.sound`)}),z(`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&&z(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`settings.alerts.flash`)}),z(`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`})]})]})]}),z(`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?z(P.Fragment,{children:[z(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`settings.alerts.keepAwake`)}),z(`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`})]})]}),z(`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:pJ.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 gJ=[50,75,100,125,150,175,200],_J=[{accent:`american`,gender:`female`},{accent:`american`,gender:`male`},{accent:`british`,gender:`female`},{accent:`british`,gender:`male`}],vJ=`settings:preview`,yJ=`Hello, I'm GAIA. This is how I'll read my replies to you.`;function bJ(e){return e instanceof Nt?e.detail||e.message:String(e)}function xJ(){let e=R(),t=iN(e=>e.settings),n=iN(e=>e.setSettings),r=iN(e=>e.read),i=iN(e=>e.stop),a=iN(e=>e.messageId===vJ),o=iN(e=>e.messageId===vJ&&e.status===`loading`),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(null),[d,f]=(0,V.useState)(!1);(0,V.useEffect)(()=>{GM().then(n).catch(e=>c(bJ(e)))},[n]);let p=e=>{f(!0),u(null),iN.getState().messageId===vJ&&i(),KM(e).then(n).catch(e=>u(bJ(e))).finally(()=>f(!1))};return s?z(`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?z(`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`)}),z(`div`,{className:`settings-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`read-aloud-voice`,children:e(`readAloud.settings.voice`)}),z(`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:_J.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}`))}),z(`button`,{type:`button`,className:`btn-secondary`,"aria-pressed":a,disabled:d,onClick:()=>a?i():void r(vJ,yJ),children:[o?I(La,{size:13,className:`spin`}):I(a?vs:As,{size:13}),e(a?`readAloud.stop`:`readAloud.settings.preview`)]})]}),I(`span`,{className:`settings-hint`,children:e(`readAloud.settings.englishOnly`)}),I(sN,{messageId:vJ})]}),z(`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:(gJ.includes(t.speed)?gJ:[...gJ,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))})]}),z(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`readAloud.settings.auto`)}),z(`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})})]}):z(`p`,{className:`settings-hint`,children:[I(La,{size:13,className:`spin`}),` `,e(`settings.loading`)]})}function SJ(){let e=R(),t=B(e=>e.jumpToSetting),n=B(e=>e.closeSettings),r=B(e=>e.runSetupAgain),i=_c(e=>e.active),a=B(e=>e.systemStatus?.lemonade_running===!1),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(null),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(!1);(0,V.useEffect)(()=>{qe().then(s).catch(e=>g(e instanceof Error?e.message:String(e))),re().then(l).catch(e=>g(e instanceof Error?e.message:String(e))),f().then(e=>d(e??null)).catch(e=>m(e instanceof Error?e.message:String(e)))},[]);let y=o?.catalog?.find(e=>e.id===o.chat_model.id),b=(i?.model?i.remote?i.label??xc(i.model):xc(i.model):null)??y?.name??null,x=(o?.catalog??[]).filter(e=>e.downloaded),S=x.reduce((e,t)=>e+(t.full_size_gb??0),0),C=[c?.gpu_name,c?.npu_detected?e(`setup.checks.npu`):null].filter(Boolean).join(` · `),w=HO(o?.system?.physical_memory,c?.ram_gb),T=w&&KO(e.locale,w),E=o?.capacity_gb==null?null:KO(e.locale,BO(o.capacity_gb)),D=E?T?e(`settings.setup.memoryOf`,{size:E,total:T}):e(`settings.setup.memoryFor`,{size:E}):T,O=[{title:e(`settings.setup.where`),rows:[{label:e(`settings.setup.chatRuns`),value:b,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:[C,D].filter(Boolean).join(` · `)||null},{label:e(`settings.setup.server`),value:o?.lemonade.mode===`external`?e(`settings.setup.serverYours`):e(`settings.setup.serverOwn`),section:`advanced`,target:`[data-settings-target="model-server"]`},{label:e(`setup.gpu.title`),value:null,section:`model`,target:`#settings-gpu-title`,provider:`local`,shown:!!u?.applies||!!p&&!Dq(p)}]},{title:e(`setup.models.step`),rows:[{label:e(`settings.setup.models`),value:o?.catalog?e(`settings.setup.modelsValue`,{n:String(x.length),size:BO(S)}):null,section:`model`,target:`[data-settings-target="models-on-pc"]`,provider:`local`},{label:e(`settings.setup.context`),value:null,section:`model`,target:`#ctx-size`,shown:!!i?.model&&!i.remote&&i.downloaded!==!1}]},{title:e(`settings.setup.after`),rows:[{label:e(`settings.section.connectors`),value:null,section:`connectors`},{label:e(`settings.section.memory`),value:null,section:`memory`},{label:e(`settings.language`),value:null,section:`general`,target:`#ui-language`},{label:e(`settings.setup.signIn`),value:null,section:`general`,target:`#desktop-startOnLogin`,shown:!!window.gaiaAPI?.tray}]}];return z(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.setup`)}),I(`p`,{className:`settings-hint`,children:e(`settings.setup.lede`)}),z(`div`,{className:`settings-setup-status`,children:[z(`span`,{children:[I(`strong`,{children:e(a?`settings.setup.serverDown`:`settings.setup.ready`)}),b&&!a&&z(`span`,{className:`settings-hint`,children:[` `,I(`bdi`,{children:e(`settings.setup.running`,{name:b})})]})]}),I(`button`,{type:`button`,className:`btn-secondary`,"data-testid":`setup-run-again`,onClick:()=>v(!0),children:e(`settings.setup.runAgain`)})]}),h&&I(`p`,{className:`setup-error`,role:`alert`,children:h}),O.map(e=>z(`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=z(`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?z(`button`,{type:`button`,className:`settings-setup-row`,onClick:()=>t({section:r,target:e.target??`.settings-pane-title`,from:`setup`},e.provider),children:[n,I(Yr,{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)),_&&I(EG,{title:e(`settings.setup.confirmTitle`),confirmLabel:e(`settings.setup.confirmYes`),cancelLabel:e(`setup.again.notNow`),onConfirm:()=>{v(!1),n(),r(!0)},onCancel:()=>v(!1),children:I(`p`,{children:e(`settings.setup.confirmBody`)})})]})}var CJ=[{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 wJ(){let e=R(),t=B(e=>e.openSettings),n=`GAIA v0.27.0rc1`,[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 z(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.about`)}),z(`section`,{className:`settings-card`,"aria-labelledby":`about-version`,children:[z(`div`,{className:`settings-row settings-row-between`,children:[z(`span`,{children:[I(`strong`,{id:`about-version`,children:I(`bdi`,{dir:`ltr`,children:n})}),` `,I(`span`,{className:`beta-badge`,children:`BETA`})]}),z(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void c(),children:[I(r?Vr:hi,{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})]}),z(`section`,{className:`settings-card`,"aria-label":e(`settings.about.links`),children:[I(`ul`,{className:`settings-about-links`,children:CJ.map(t=>I(`li`,{children:z(`a`,{href:t.href,target:`_blank`,rel:`noopener noreferrer`,children:[e(t.label),` `,I(ji,{size:12,"aria-hidden":`true`})]})},t.href))}),z(`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 TJ=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(EJ,{variant:this.props.variant??`fill`,onRetry:()=>this.setState({hasError:!1})}):this.props.children}};function EJ({onRetry:e,variant:t}){let n=R();return z(`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`)}),z(`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 DJ=`modulepreload`,OJ=function(e,t){return new URL(e,t).href},kJ={},AJ=function(e){return e.pathname.endsWith(`.css`)},jJ=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},MJ=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=OJ(t,n);let r=s(t),i=AJ(r);return jJ(kJ,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`:DJ,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)})},NJ=(0,V.lazy)(()=>MJ(()=>import(`./ConnectorsPane-6hKjjRWm.js`).then(e=>({default:e.ConnectorsPane})),__vite__mapDeps([0,1,2,3]),import.meta.url)),PJ=(0,V.lazy)(()=>MJ(()=>import(`./MessagingSettings-sBXQSmjR.js`).then(e=>({default:e.MessagingSettings})),__vite__mapDeps([4,1,2]),import.meta.url)),FJ=(0,V.lazy)(()=>MJ(()=>import(`./AutomationsSettings-By0Cy-Gu.js`).then(e=>({default:e.AutomationsSettings})),__vite__mapDeps([5,1,2]),import.meta.url)),IJ=(0,V.lazy)(()=>MJ(()=>import(`./AdvancedSettings-znkqGWxt.js`).then(e=>({default:e.AdvancedSettings})),__vite__mapDeps([6,1,2]),import.meta.url)),LJ=[`general`,`setup`,`model`,`permissions`,`skills`,`connectors`,`messaging`,`automations`,`memory`,`notifications`,`voice`,`privacy`,`advanced`,`about`];function RJ({onUseSkill:e}){let t=R(),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(pt(c,i),on(o,c),sW(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=LJ.indexOf(n),i=e.key===`ArrowDown`?(t+1)%LJ.length:e.key===`ArrowUp`?(t-1+LJ.length)%LJ.length:e.key===`Home`?0:e.key===`End`?LJ.length-1:null;i!==null&&(e.preventDefault(),r(LJ[i]),o.current?.querySelector(`[data-section="${LJ[i]}"]`)?.focus())},d=(()=>{switch(n){case`general`:return I(Eq,{});case`setup`:return I(SJ,{});case`model`:return I(Yq,{});case`permissions`:return I(Xq,{});case`skills`:return I(iJ,{onUseSkill:t=>{i(),e(t)}});case`connectors`:return I(NJ,{});case`messaging`:return I(PJ,{});case`automations`:return I(FJ,{});case`memory`:return I(aJ,{});case`notifications`:return I(hJ,{});case`voice`:return I(xJ,{});case`privacy`:return I(uJ,{});case`advanced`:return I(IJ,{});case`about`:return I(wJ,{})}})();return I(`div`,{className:`settings-overlay`,onMouseDown:e=>{e.target===e.currentTarget&&i()},children:z(`div`,{ref:o,className:`settings-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`settings.title`),children:[z(`nav`,{className:`settings-nav`,"aria-label":t(`settings.sections`),onKeyDown:u,children:[I(`h1`,{className:`settings-nav-title`,children:t(`settings.title`)}),LJ.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))]}),z(`div`,{className:`settings-body`,children:[I(`button`,{type:`button`,className:`settings-close`,onClick:i,"aria-label":t(`settings.close`),children:I(Is,{size:18})}),l&&z(`button`,{type:`button`,className:`settings-back`,onClick:()=>{r(l),o.current?.querySelector(`[data-section="${l}"]`)?.focus()},children:[I(qr,{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(TJ,{area:`settings.${n}`,children:I(V.Suspense,{fallback:z(`p`,{className:`settings-hint`,children:[I(La,{size:13,className:`spin`}),` `,t(`settings.loading`)]}),children:d})},n)})]})]})})}var zJ=`gaia:personalize-connector`,BJ=[[`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 VJ(e,t){let n=e.toLowerCase().replace(/^mcp-/,``),r=BJ.find(([e])=>n.startsWith(e));return r?r[1]:`my recent activity in ${t}`}function HJ(e){let t=e.toLowerCase().replace(/^mcp-/,``),n=BJ.find(([e])=>t.startsWith(e));return n?n[0]:null}function UJ({connectorId:e,displayName:t}){return[`I just connected ${t}. Get to know me from ${VJ(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(`
|
|
212
|
-
`)}function WJ(e){window.dispatchEvent(new CustomEvent(zJ,{detail:e}))}var GJ=Ct((e,t)=>({lifecycle:null,restartError:null,apply:n=>{n.apiBase&&Dn(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 KJ(){let e=window.gaiaAPI?.backend;e&&e.getState().then(e=>GJ.getState().apply(e)).catch(e=>F.system.error(`Could not read the backend state from the desktop app`,e))}function qJ(e){let t=window.gaiaAPI?.backend;if(!t)return()=>{};let n=t=>{let n=GJ.getState().lifecycle?.status;GJ.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 JJ(e,t){let[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(!1),[o,s]=(0,V.useState)(null),c=(0,V.useRef)(null),l=(0,V.useRef)(null),u=(0,V.useRef)(null),d=(0,V.useCallback)(()=>{c.current&&=(clearTimeout(c.current),null),l.current&&=(clearTimeout(l.current),null),u.current&&=(clearInterval(u.current),null)},[]);(0,V.useEffect)(()=>d,[d]);let f=(0,V.useCallback)((e,t)=>{u.current&&clearInterval(u.current),u.current=setInterval(async()=>{try{let n=await te();t===`load`?bc(n.model_loaded,e)&&(r(!1),c.current&&=(clearTimeout(c.current),null),u.current&&=(clearInterval(u.current),null)):(n.model_downloaded===!0||bc(n.model_loaded,e))&&(a(!1),l.current&&=(clearTimeout(l.current),null),u.current&&=(clearInterval(u.current),null))}catch{}},ru)},[]),p=e??`Gemma-4-E4B-it-GGUF`;return(0,V.useEffect)(()=>s(null),[p]),{isLoadingModel:n,isDownloadingModel:i,downloadError:o,loadModel:(0,V.useCallback)(async(e,n)=>{let i=e??p,a=n??t;r(!0);try{if(!await fn(i,a)){r(!1);return}F.system.info(`Load model triggered: ${i} (ctx=${a??`server default`})`),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>r(!1),tu),f(i,`load`)}catch(e){F.system.error(`Failed to trigger model load`,e),r(!1)}},[p,t,f]),downloadModel:(0,V.useCallback)(async(e=!1,t,n=!1)=>{let r=t??p;a(!0),s(null);try{await Ve(r,e,n),F.system.info(`Download model triggered: ${r} (force=${e})`),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>a(!1),nu),f(r,`download`)}catch(e){F.system.error(`Failed to trigger model download`,e),s(e instanceof Error?e.message:String(e)),a(!1)}},[p,f])}}function YJ({onRetry:e,label:t,busyLabel:n=`Checking…`}){let[r,i]=(0,V.useState)(!1);return I(`button`,{className:`connection-banner__retry`,onClick:()=>{i(!0),Promise.resolve(e()).finally(()=>i(!1))},disabled:r,children:r?n:t})}function XJ(e){return`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)}`}function ZJ({lifecycle:e}){let t=R(),n=GJ(e=>e.restart),r=GJ(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 z(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(La,{size:16,className:`connection-banner__spinner`})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[t(`banner.restarting`),` `,I(`bdi`,{dir:`ltr`,className:`connection-banner__timer`,children:XJ(n)}),` `,I(`span`,{className:`connection-banner__hint`,children:t(`banner.restartingHint`)})]})]})}return z(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[I(`div`,{className:`connection-banner__icon`,children:I(ws,{size:16})}),z(`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(YJ,{onRetry:n,label:t(`banner.restartButton`),busyLabel:t(`banner.restartingShort`)})]})}function QJ({onRetry:e,backendSlow:t=!1,backendError:n=null}){let r=R(),{backendConnected:i,systemStatus:a,currentSessionId:o,messages:s}=B(),c=GJ(e=>e.lifecycle),[l,u]=(0,V.useState)(!1),d=!!o&&s.length>0,f=a?.default_model_name??`Gemma-4-E4B-it-GGUF`,{isDownloadingModel:p,downloadError:m,downloadModel:h}=JJ(f),g=_c(e=>e.pickLoad),_=_c(e=>e.retryPickLoad),v=_c(e=>e.dismissPickLoad);yc();let y=(0,V.useRef)(a?.lemonade_running),b=(0,V.useRef)(a?.model_downloaded),x=(0,V.useRef)(a?.context_size_sufficient),S=(0,V.useRef)(a?.expected_model_loaded);(0,V.useEffect)(()=>{if(d)return;let e=a?.lemonade_running,t=a?.model_downloaded,n=a?.context_size_sufficient,r=a?.expected_model_loaded,i=!1;y.current!==e&&(y.current=e,e===!1&&(i=!0)),b.current!==t&&(b.current=t,t===!1&&(i=!0)),x.current!==n&&(x.current=n,n===!1&&(i=!0)),S.current!==r&&(S.current=r,r===!1&&(i=!0)),i&&u(!1)},[a,d]);let C=a?.download_progress??null,w=p||C?.state===`downloading`||C?.state===`starting`,T=B(e=>e.dismissDownloadFailure);if(c&&c.status!==`running`)return I(ZJ,{lifecycle:c});let E=C?.model_name||f,D=async()=>{try{await T(C?.model_name??E)}catch{}};if(w||C?.state===`error`){let e=C?.total_bytes?`${(C.total_bytes/1e9).toFixed(1)} GB`:`large download`,t=C?.state===`error`;return z(`div`,{className:`connection-banner ${t?`connection-banner--error`:`connection-banner--warning`}`,role:t?`alert`:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(t?ws:Ci,{size:16})}),I(`div`,{className:`connection-banner__text`,dir:`auto`,children:t?z(P.Fragment,{children:[`Download of `,I(`strong`,{children:E}),` failed.`,` `,(m??C?.message)&&I(`span`,{className:`connection-banner__hint`,children:m??C?.message})]}):z(P.Fragment,{children:[`Downloading `,I(`strong`,{children:E}),` (`,e,`).`,C?.state===`downloading`&&C.file&&z(P.Fragment,{children:[` `,z(`span`,{className:`connection-banner__hint`,children:[`File `,C.file_index,` / `,C.total_files,`: `,I(`code`,{children:C.file})]})]})]})}),t?I(`button`,{className:`connection-banner__retry`,onClick:()=>h(!1,E,!a?.model_loaded),children:`Retry`}):I(`span`,{className:`connection-banner__loading connection-banner__progress`,children:C&&C.state===`downloading`&&C.total_bytes>0?z(P.Fragment,{children:[I(`span`,{className:`connection-banner__progress-bar`,role:`progressbar`,"aria-valuenow":C.percent,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`Download progress`,children:I(`span`,{className:`connection-banner__progress-fill`,style:{width:`${C.percent}%`}})}),z(`span`,{className:`connection-banner__progress-label`,children:[C.percent,`% ·`,` `,(C.downloaded_bytes/1e9).toFixed(2),` /`,` `,(C.total_bytes/1e9).toFixed(2),` GB`]})]}):z(P.Fragment,{children:[I(La,{size:13,className:`connection-banner__spinner`}),C?.state===`starting`?C.message??`Starting download…`:`Downloading…`]})}),t&&I(`button`,{className:`connection-banner__dismiss`,onClick:()=>void D(),"aria-label":`Dismiss`,children:I(Is,{size:14})})]})}if(g){let e=xc(g.model);return g.error?z(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[I(`div`,{className:`connection-banner__icon`,children:I(ws,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.pickLoad.failed`,{model:e}),` `,I(`span`,{className:`connection-banner__hint`,dir:`auto`,children:g.error.key?r(g.error.key,{reason:g.error.reason}):g.error.reason})]}),I(YJ,{onRetry:_,label:r(`banner.pickLoad.retry`)}),I(`button`,{className:`connection-banner__dismiss`,onClick:v,"aria-label":r(`banner.dismiss`),children:I(Is,{size:14})})]}):z(`div`,{className:`connection-banner connection-banner--init`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(La,{size:16,className:`connection-banner__spinner`})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.pickLoad.loading`,{model:e}),` `,I(`bdi`,{dir:`ltr`,children:r(`banner.pickLoad.seconds`,{s:g.seconds})}),` `,I(`span`,{className:`connection-banner__hint`,children:r(`banner.pickLoad.canType`)})]})]})}if(hI(a)&&!t&&!n){let e=a?.init_tasks?.find(e=>e.status===`running`)?.step,t=`banner.boot.${e}`,n=e&&ae(t)?r(t):r(`banner.boot.generic`);return z(`div`,{className:`connection-banner connection-banner--init`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(La,{size:16,className:`connection-banner__spinner`})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[n,z(`span`,{className:`thinking-dots`,children:[I(`span`,{children:`.`}),I(`span`,{children:`.`}),I(`span`,{children:`.`})]})]})]})}if(l||d)return null;if(!i)return z(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[I(`div`,{className:`connection-banner__icon`,children:I(Ms,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.unreachable`),` `,I(`span`,{className:`connection-banner__hint`,children:r(`banner.unreachableHint`)})]}),e&&I(YJ,{onRetry:e,label:`Retry`})]});if(n)return z(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(ws,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[`GAIA's backend answered with an error (`,n,`).`,` `,I(`span`,{className:`connection-banner__hint`,children:`It may be overloaded. GAIA keeps checking; if it lasts, restart GAIA.`})]}),e&&I(YJ,{onRetry:e,label:`Check again`})]});if(t)return z(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(ws,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[`GAIA is slow to answer.`,` `,I(`span`,{className:`connection-banner__hint`,children:`It may be busy with another chat or app. GAIA keeps checking.`})]}),e&&I(YJ,{onRetry:e,label:`Check again`})]});if(a?.config_error)return z(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[I(`div`,{className:`connection-banner__icon`,children:I(ws,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[`GAIA settings could not be loaded.`,` `,I(`span`,{className:`connection-banner__hint`,children:a.config_error})]}),e&&I(YJ,{onRetry:e,label:`Check again`})]});if(a&&!a.lemonade_running){let t=gI(a)===`unresponsive`,n=!t&&jq(a),i=t&&Oq(a.start_command)?null:a.start_command,o=t&&Oq(a.start_instruction)?null:a.start_instruction;return z(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(ws,{size:16})}),z(`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?z(`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:Aq(r,o)})]}),n&&I(Mq,{className:`connection-banner__retry`}),e&&I(YJ,{onRetry:e,label:r(`settings.key.checkAgain`)}),I(`button`,{className:`connection-banner__dismiss`,onClick:()=>u(!0),"aria-label":`Dismiss`,children:I(Is,{size:14})})]})}if(a&&a.lemonade_running&&a.model_loaded&&a.context_size_sufficient===!1){let t=a.model_context_size??0;return z(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(Ta,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[`LLM context window is too small (`,t.toLocaleString(),` tokens;`,` `,$l.toLocaleString(),` required).`,` `,I(`span`,{className:`connection-banner__hint`,children:`Reload it with a larger context in Settings → Advanced.`})]}),e&&I(YJ,{onRetry:e,label:`Check again`}),I(`button`,{className:`connection-banner__dismiss`,onClick:()=>u(!0),"aria-label":`Dismiss`,children:I(Is,{size:14})})]})}return null}var $J=`https://github.com/amd/gaia/releases`;function eY(){let e=pq(),t=R(),[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(null),o=(0,V.useCallback)(e=>{let n=dq();n&&(a(null),n[e]().catch(n=>{F.system.error(`Update ${e} failed`,n),a(_q(n,t))}))},[t]);if(n)return null;let s=e.installFailed?t(`update.chip.installFailedDetail`,e.installFailed):null,c=e.status===`downloading`||e.status===`downloaded`;if(e.startFailed&&e.previousVersion&&!c)return z(`div`,{className:`update-chip update-chip--error`,role:`status`,children:[I(ws,{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(Is,{size:11})})]});let l=e.status===`available`||e.status===`downloaded`;if(s&&!l)return z(`div`,{className:`update-chip update-chip--error`,role:`status`,title:s??void 0,children:[I(ws,{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(Is,{size:11})})]});if(e.status===`idle`||e.status===`checking`||e.status===`disabled`||e.status===`no-channel`)return null;if(e.status===`downloading`){let n=Math.max(0,Math.min(100,e.progress));return z(`div`,{className:`update-chip update-chip--downloading`,role:`status`,"aria-live":`polite`,title:t(`update.chip.downloadingTitle`,{version:e.version??``}),children:[I(Ci,{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`?z(`div`,{className:`update-chip update-chip--available`,role:`status`,title:e.manualInstall?t(`update.chip.manualTitle`,{version:e.version??``}):i||s||e.releaseNotes||t(`update.chip.availableTitle`),children:[I(Ci,{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??$J,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(Is,{size:11})})]}):e.status===`downloaded`?z(`div`,{className:`update-chip update-chip--ready`,role:`status`,"aria-live":`polite`,children:[I(Po,{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`?z(`div`,{className:`update-chip update-chip--error`,role:`status`,title:e.error||t(`update.chip.checkFailed`),children:[I(ws,{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(Is,{size:11})})]}):null}var tY={permission_request:{icon:I(ns,{size:16}),colorClass:`notif-type-permission`},policy_alert:{icon:I(ns,{size:16}),colorClass:`notif-type-policy`},security_alert:{icon:I(ws,{size:16}),colorClass:`notif-type-security`},status_change:{icon:I($r,{size:16}),colorClass:`notif-type-status`},info:{icon:I(ya,{size:16}),colorClass:`notif-type-info`},error:{icon:I(ri,{size:16}),colorClass:`notif-type-error`}};function nY(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(Sn(t),{month:`short`,day:`numeric`})}function rY({onClose:e,onOpenChat:t}){let n=R(),r=_l(Us(yl)),i=_l(vl),a=_l(e=>e.markRead),o=_l(e=>e.markAllRead),s=_l(e=>e.clearAll),c=_l(e=>e.dismiss),l=_l(e=>e.respondToPermission),u=_l(e=>e.typeFilter),d=_l(Us(bl)),f=_l(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]);pt(!0,e);let g=[{key:null,label:n(`notifications.filter.all`)},{key:`permission_request`,label:n(`notifications.filter.permissions`)},{key:`policy_alert`,label:n(`notifications.filter.policy`)},{key:`error`,label:n(`notifications.filter.errors`)},{key:`security_alert`,label:n(`notifications.filter.security`)},{key:`status_change`,label:n(`notifications.filter.status`)},{key:`info`,label:n(`notifications.filter.info`)}].filter(e=>e.key===null||e.key===u||d.includes(e.key)),_=g.length>2||u!==null;return z(`div`,{className:`notification-center`,role:`dialog`,"aria-label":n(`notifications.dialogAria`),children:[z(`div`,{className:`notification-center-header`,children:[z(`div`,{className:`notification-center-title-row`,children:[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(Is,{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?z(`div`,{className:`notification-empty`,children:[I(Tr,{size:40,strokeWidth:1.2}),I(`span`,{children:n(`notifications.empty`)})]}):r.map(e=>{let t=tY[e.type],r=e.type===`permission_request`&&e.tool?cl(e,n,Ic):null;return z(`div`,{className:`notification-item ${e.read?``:`unread`} ${t.colorClass}`,id:e.type===`policy_alert`&&e.receiptId?`policy-receipt-${encodeURIComponent(e.receiptId)}`:void 0,onClick:()=>p(e),role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&p(e)},children:[!e.read&&I(`span`,{className:`notification-unread-dot`}),I(`span`,{className:`notification-icon`,children:t.icon}),z(`div`,{className:`notification-content`,children:[z(`div`,{className:`notification-content-header`,children:[I(`span`,{className:`notification-agent`,dir:`auto`,children:e.agentName}),I(`span`,{className:`notification-time`,children:nY(e.timestamp,n)})]}),r?z(P.Fragment,{children:[I(`span`,{className:`notification-title`,children:I(zc,{text:r.heading})}),I(`span`,{className:`notification-message`,dir:`auto`,children:I(zc,{text:r.question})})]}):z(P.Fragment,{children:[e.title&&I(`span`,{className:`notification-title`,children:e.title}),I(`span`,{className:`notification-message`,dir:`auto`,children:e.message})]}),e.type===`policy_alert`&&z(`div`,{className:`notification-policy-details`,children:[e.tool&&z(`span`,{className:`notification-tool`,children:[n(`activity.policy.tool`),`: `,I(`code`,{dir:`ltr`,children:e.tool})]}),e.reason&&z(`span`,{className:`notification-policy-reason`,children:[n(`notifications.reason`),`: `,e.reason]}),e.ruleIds&&e.ruleIds.length>0&&z(`span`,{className:`notification-tool`,children:[n(`activity.policy.rules`),`: `,I(`code`,{dir:`ltr`,children:e.ruleIds.join(`, `)})]}),e.policyVersion&&z(`span`,{className:`notification-tool`,children:[n(`activity.policy.policy`),`: `,I(`code`,{dir:`ltr`,children:e.policyVersion})]}),z(`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&&z(`div`,{className:`notification-actions`,children:[z(`button`,{className:`notification-action-btn notification-action-allow`,onClick:t=>{t.stopPropagation(),m(e)},children:[I(Vr,{size:14}),n(`notifications.approve`)]}),z(`button`,{className:`notification-action-btn notification-action-deny`,onClick:t=>{t.stopPropagation(),h(e)},children:[I(Is,{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(Is,{size:14})})]},e.id)})}),r.length>0&&z(`div`,{className:`notification-center-footer`,children:[z(`button`,{className:`notification-footer-btn`,onClick:o,disabled:i===0,children:[I(Vr,{size:14}),n(`notifications.markAllRead`)]}),z(`button`,{className:`notification-footer-btn notification-footer-clear`,onClick:s,children:[I(Ss,{size:14}),n(`notifications.clear`)]})]})]})}var iY=1500,aY=e=>new Promise(t=>setTimeout(t,e));async function oY({onProgress:e,isCancelled:t=()=>!1,pollMs:n=iY}={}){try{await ft(bO)}catch(e){if(e?.httpStatus!==409)throw e;let t=await C(bO).catch(()=>null);if(!t||t.status===`completed`||t.status===`failed`)throw e}for(;!t();){let t=await C(bO);if(e?.(t),t.status===`completed`)return;if(t.status===`failed`)throw Error(t.error||`The GAIA agent could not be installed.`);await aY(n)}}function sY({onInstalled:e,noBuild:t=!1}){let n=R(),[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 oY({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`)})}):z(`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`)})]})}async function cY(){return An(`GET`,`/schedules`)}function lY(){return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}async function uY(e,t,n){return An(`POST`,`/schedules`,{name:e,interval:t,prompt:n,timezone:lY()})}async function dY(e,t,n){return An(`PATCH`,`/schedules/${encodeURIComponent(e)}`,{interval:t,prompt:n,timezone:lY()})}async function fY(e,t){return An(`PUT`,`/schedules/${encodeURIComponent(e)}`,{status:t})}async function pY(e){return An(`POST`,`/schedules/${encodeURIComponent(e)}/run`)}async function mY(e){return An(`DELETE`,`/schedules/${encodeURIComponent(e)}`)}async function hY(e,t=20){return An(`GET`,`/schedules/${encodeURIComponent(e)}/results?limit=${t}`)}async function gY(e){return An(`POST`,`/schedules/parse`,{input:e,timezone:lY()})}function _Y(e){return e.replace(/^\s*(```|~~~).*$/gm,``).replace(/!?\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/`([^`]+)`/g,`$1`).replace(/\*\*(.+?)\*\*/g,`$1`).replace(/(^|[^\w])__(?=\S)(.+?\S)__(?![\w.])/g,`$1$2`).replace(/(^|[^\w*])\*(?!\s)(.*?\S)\*(?!\w)/g,`$1$2`).replace(/(^|[^\w])_(?![\s_])(.+?)_(?!\w)/g,`$1$2`).replace(/^\s{0,3}(#{1,6}\s+|>\s?|[-*+]\s+)/gm,``).replace(/\s+/g,` `).trim()}function vY(e,t){if(!(e instanceof Error))return t;let n=e.message,r=n.match(/API \d+: (.+)/);if(r)try{let e=JSON.parse(r[1]);if(e.detail)return e.detail}catch{}return n}var yY=`gaia-schedule-announced-errors`;function bY(){let e;try{e=localStorage.getItem(yY)}catch(e){return F.system.warn(`Announced schedule failures unreadable; failures from before launch may be announced again. localStorage is blocked -- check private-browsing or site-data settings.`,e),{}}if(!e)return{};try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return Object.fromEntries(Object.entries(t).filter(([,e])=>typeof e==`number`));F.system.warn(`Ignored malformed "${yY}"; failures from before launch may be announced again.`)}catch(e){F.system.warn(`"${yY}" is corrupt; failures from before launch may be announced again.`,e)}return{}}function xY(e){try{localStorage.setItem(yY,JSON.stringify(e))}catch(e){F.system.warn(`Announced schedule failures not saved; they may be announced again on the next launch. localStorage is blocked -- check private-browsing or site-data settings.`,e)}}function SY(e,t){let{addNotification:n}=_l.getState();for(let r of t)r.error_count<=(e[r.id]??0)||!r.last_error||n({id:`schedule-error-${r.id}-${r.error_count}`,type:`error`,agentId:`scheduler`,agentName:`GAIA`,title:Ht()(`schedules.failed`,{name:r.name}),message:r.last_error,timestamp:Date.now(),read:!1,dismissed:!1,priority:`high`,...r.session_id?{sessionId:r.session_id}:{}})}function CY(e){return e.run_count-+!!e.running}function wY(e,t,n){let{addNotification:r}=_l.getState();for(let i of n){let n=CY(i);n<=(t[i.id]??0)||i.error_count>(e[i.id]??0)||r({id:`schedule-done-${i.id}-${n}`,type:`info`,agentId:`scheduler`,agentName:`GAIA`,title:Ht()(`schedules.finished`,{name:i.name}),message:_Y(i.last_result??``),timestamp:Date.now(),read:!1,dismissed:!1,priority:`medium`,...i.session_id?{sessionId:i.session_id}:{}})}}var TY=Ct((e,t)=>({schedules:[],loading:!1,error:null,actionError:null,selectedSchedule:null,results:[],resultsLoading:!1,errorCounts:null,finishedCounts:{},draft:null,setDraft:t=>e({draft:t}),loadSchedules:async()=>{t().schedules.length===0&&!t().error&&e({loading:!0}),e({error:null});try{let n=(await cY()).schedules||[],r=t().errorCounts,i=t().finishedCounts,a=r??bY();SY(a,n),r&&wY(a,i,n);let o=Object.fromEntries(n.map(e=>[e.id,e.error_count]));xY(o),e({schedules:n,loading:!1,errorCounts:o,finishedCounts:Object.fromEntries(n.map(e=>[e.id,Math.max(CY(e),i[e.id]??0)]))})}catch(t){F.api.error(`Failed to load schedules`,t),e({error:`Failed to load schedules`,loading:!1})}},createSchedule:async(t,n,r)=>{try{let i=await uY(t,n,r);e(e=>({schedules:[...e.schedules,i],actionError:null}))}catch(e){throw F.api.error(`Failed to create schedule`,e),e}},editSchedule:async(t,n,r)=>{try{let i=await dY(t,n,r);e(e=>({schedules:e.schedules.map(e=>e.name===t?i:e),actionError:null}))}catch(e){throw F.api.error(`Failed to edit schedule "${t}"`,e),e}},updateScheduleStatus:async(t,n)=>{try{let r=await fY(t,n);e(e=>({schedules:e.schedules.map(e=>e.name===t?r:e),actionError:null}))}catch(n){F.api.error(`Failed to update schedule "${t}"`,n),e({actionError:vY(n,`Failed to update schedule`)})}},runScheduleNow:async t=>{try{let n=await pY(t);e(e=>({schedules:e.schedules.map(e=>e.name===t?n:e),actionError:null}))}catch(n){F.api.error(`Failed to run schedule "${t}" now`,n),e({actionError:vY(n,`Could not run the schedule now`)})}},deleteSchedule:async t=>{try{await mY(t),e(e=>({schedules:e.schedules.filter(e=>e.name!==t),selectedSchedule:e.selectedSchedule===t?null:e.selectedSchedule,actionError:null}))}catch(n){F.api.error(`Failed to delete schedule "${t}"`,n),e({actionError:vY(n,`Failed to delete schedule`)})}},selectSchedule:n=>{e({selectedSchedule:n,results:[],resultsLoading:!1}),n&&t().loadResults(n)},loadResults:async n=>{e({resultsLoading:!0});try{let r=await hY(n);if(t().selectedSchedule!==n)return;e({results:r.results||[],resultsLoading:!1})}catch(r){if(F.api.error(`Failed to load results for "${n}"`,r),t().selectedSchedule!==n)return;e({results:[],resultsLoading:!1})}},dismissActionError:()=>e({actionError:null})})),EY=`goal-store-error-`,DY=0;function OY(){let e=_l.getState();for(let t of e.notifications)t.id.startsWith(EY)&&!t.read&&e.markRead(t.id)}var kY=Ct((e,t)=>({error:null,damaged:!1,check:async()=>{let n,r;try{({error:n,damaged:r}=await jU())}catch(e){F.api.error(`Could not check the goal store`,e);return}n&&n!==t().error&&(DY+=1,_l.getState().addNotification({id:`${EY}${DY}`,type:`error`,agentId:`goals`,agentName:`GAIA`,title:Ht()(`mem.goals.storeError`),message:n,timestamp:Date.now(),read:!1,dismissed:!1,priority:`high`})),n||OY(),e({error:n,damaged:!!r})}})),AY=new Set([`loading_model`,`downloading_model`,`model_retry`,`waiting`]),jY=5;function MY(e,t){return{id:e,title:t.get(e)?.title??`Untitled chat`}}function NY(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=>({...MY(e,t),reason:`approval`}));n&&e.awaitingUser&&!a.has(e.currentSessionId)&&o.push({...MY(e.currentSessionId,t),reason:`answer`});for(let[n,r]of Object.entries(e.awaitingBySession))o.some(e=>e.id===n)||o.push({...MY(n,t),reason:r===`question`?`answer`:`approval`});let s=n&&!e.awaitingUser&&e.livePhase&&AY.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,jY).map(e=>MY(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=>MY(e,t)),needsYou:o,recent:u}}function PY(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:_l.getState().notifications},a=r;if(r=i,a&&Object.keys(i).every(e=>i[e]===a[e]))return;let o=NY(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=_l.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 FY(){(0,V.useEffect)(()=>{let e=window.gaiaAPI;if(!e)return;let t=_l.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 IY(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 LY(){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 RY(){FY();let e=B(e=>e.runningSessionIds),t=B(e=>e.awaitingBySession),n=B(e=>e.sessions),r=B(e=>e.currentSessionId),i=_l(Us(Sl)),a=kl(),o=LY(),s=(0,V.useRef)(null),c=Il(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 Ll(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`||Bl(s,r,i))&&(o=!0,t===`banner`)){if(c!==`finished`){let{title:t,body:n}=zl(c,e);IY(s,t,n)}else ie(s).then(e=>{B.getState().updateSessionInList(s,e);let{title:t,body:n}=zl(c,e);IY(s,t,n)}).catch(t=>{F.system.error(`Could not read how chat ${s} ended`,t);let{title:n,body:r}=zl(c,{...e,last_run_status:null});IY(s,n,r)})}}if(o){if(a.sound)try{Ul()}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=Vl(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&&Hl(o,a.batteryFloor);(0,V.useEffect)(()=>{window.gaiaAPI?.power.setKeepAwake(d).catch(e=>F.system.error(`Could not change keep-awake`,e))},[d])}function zY(e){return e.indexing_status===`failed`&&nL(e.error_kind)}function BY(){let e=B(e=>e.systemStatus?.lemonade_running===!0),t=B(e=>e.setDocuments),n=(0,V.useRef)(!1),r=(0,V.useRef)(!1);(0,V.useEffect)(()=>{if(!e)return;if(n.current){r.current=!0;return}let i=async()=>{let{documents:e}=await o(),n=(e||[]).filter(zY).map(e=>e.id);if(n.length===0)return;F.doc.info(`Model server is back; retrying ${n.length} document(s) that were waiting for it`);for(let e of n){let n=(await o()).documents||[],r=n.find(t=>t.id===e);if(r&&zY(r)){t(n.map(t=>t.id===e?{...t,indexing_status:`indexing`}:t));try{await Vt(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 o();t(r.documents||[])};n.current=!0,(async()=>{try{do{r.current=!1;try{await i()}catch(e){F.doc.warn(`Could not retry the documents waiting for the model server`,e)}}while(r.current&&B.getState().systemStatus?.lemonade_running===!0)}finally{n.current=!1}})()},[e,t])}var VY=`GAIA Agent UI`;function HY(){let e=B(e=>e.sessions.find(t=>t.id===e.currentSessionId)?.title);(0,V.useEffect)(()=>{document.title=e?.trim()?`${e.trim()} - GAIA`:VY},[e])}function UY(e,t,n){return!e||t&&(e===t||e===CL(t))?null:n.some(t=>t.id===e)?e:wL(n,e)}function WY(e){return new URLSearchParams(e.search).get(`session`)||e.hash.replace(/^#/,``)||null}var GY=`gaia:last-session`;function KY(e){try{e?localStorage.setItem(GY,e):localStorage.removeItem(GY)}catch(e){F.ui.warn(`Could not save the open chat for the next launch`,e)}}function qY(){try{return localStorage.getItem(GY)}catch(e){return F.ui.warn(`Could not read the chat open at last launch`,e),null}}var JY=1e3,YY=3e4;function XY(e,{initialMs:t=JY,maxMs:n=YY,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 ZY(e,t,n){return e&&!t&&!n}var QY=(0,V.lazy)(()=>MJ(()=>import(`./MemoryDashboard-BEafsLNv.js`).then(e=>({default:e.MemoryDashboard})),__vite__mapDeps([7,1,2,8,9]),import.meta.url)),$Y=(0,V.lazy)(()=>MJ(()=>import(`./ScheduleManager-D_U1Igck.js`).then(e=>({default:e.ScheduleManager})),__vite__mapDeps([10,1,2,8,11]),import.meta.url)),eX=(0,V.lazy)(()=>MJ(()=>import(`./DocumentLibrary-_PZjdm8h.js`).then(e=>({default:e.DocumentLibrary})),__vite__mapDeps([12,1,2,13]),import.meta.url)),tX=(0,V.lazy)(()=>MJ(()=>import(`./FileBrowser-C_cpUmtN.js`).then(e=>({default:e.FileBrowser})),__vite__mapDeps([14,1,2,15]),import.meta.url)),nX=(0,V.lazy)(()=>MJ(()=>import(`./MobileAccessModal-b23-QxSf.js`).then(e=>({default:e.MobileAccessModal})),__vite__mapDeps([16,1,2,17]),import.meta.url)),rX=3,iX=3e5,aX=6e3,oX=6e4,sX=e=>e instanceof TypeError,cX=e=>new Promise(t=>setTimeout(t,e)),lX=3e5,uX=class extends Error{},dX=class extends Error{constructor(e){super(Ht().bare(`setup.unknown.modelUnread`,{error:e}))}};async function fX(){let e=Date.now()+lX;for(;;){let t=await et();if(t.state===`ready`)return;if(t.state===`failed`||t.state===`cancelled`)throw new uX(t.error||Ht().bare(`setup.upgrading.stopped`));if(Date.now()>=e)throw Error(Ht().bare(`setup.upgrading.slow`));await cX(JY)}}function pX(){return I(`div`,{className:`loading-spinner`,role:`status`,"aria-label":`Loading`})}var mX=e=>e===1||e%10==0;function hX(){let e=R();HY();let t=B(e=>e.currentSessionId),n=B(e=>e.setSessions),r=B(e=>e.setCurrentSession),i=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=_c(e=>e.restoreNotice),w=_c(e=>e.dismissRestoreNotice),T=_l(e=>e.showPanel),E=B(e=>e.systemStatus?.initialized===!0),D=(0,V.useRef)(!1),O=_l(e=>e.setShowPanel);(0,V.useEffect)(()=>{if(!C?.ok)return;let e=setTimeout(w,aX);return()=>clearTimeout(e)},[C,w]);let[k,ee]=(0,V.useState)({state:`checking`}),te=B(e=>e.setupAgain),ne=B(e=>e.runSetupAgain),A=(0,V.useRef)(k);A.current=k;let[re,ie]=(0,V.useState)(!1),ae=(0,V.useRef)(re);ae.current=re;let[j,oe]=(0,V.useState)(!1),[se,ce]=(0,V.useState)(!1),le=j||re&&!xO(_),ue=(0,V.useRef)(le);ue.current=le;let[de,fe]=(0,V.useState)(null),[pe,he]=(0,V.useState)(!1),[M,N]=(0,V.useState)(``),[ge,_e]=(0,V.useState)(0),[ye,be]=(0,V.useState)(0),[xe,Se]=(0,V.useState)(!1),[Ce,we]=(0,V.useState)(!1),[Ee,De]=(0,V.useState)(null),[Oe,ke]=(0,V.useState)(null),Ae=(0,V.useRef)(async()=>{}),je=(0,V.useRef)(async()=>{}),Me=(0,V.useCallback)(async(e=!1,t=!1)=>{e||ee({state:`checking`});let n=0;try{for(;;){await _c.getState().refresh();let e=_c.getState().active,r=!!e?.remote,i;try{if(i=await ve(r),!e&&!i.ready)throw new dX(_c.getState().error??`no answer`)}catch(e){let r=sX(e)||e instanceof dX;if(!t||!r||n>=oX)throw e;await cX(JY),n+=JY;continue}if(!i.ready&&i.stage===`upgrade`){ee({state:`upgrading`});let e=await et();(!e.upgrade_embedded||e.state!==`running`&&e.state!==`verifying`)&&await Ne(r,!1,{upgradeEmbedded:!0}),await fX(),i=await ve(r)}n>0&&await Promise.all([Ae.current(),je.current()]),ce(!!i.no_agent_build);let a=!i.ready&&i.stage===`server`&&!!i.initialized;ee(i.ready?{state:`ready`}:a?{state:`serverDown`,modelListUnread:!!i.model_list_unread}:{state:`needed`,check:i});return}}catch(e){let t=e instanceof Error?e.message:String(e);if(e instanceof uX){F.system.warn(`Updating the local model server failed`,e),ee({state:`unknown`,error:t,upgradeFailed:!0});return}F.system.warn(`Setup check could not be answered`,e),ee({state:`unknown`,error:t})}},[]),Fe=B(e=>!!e.systemStatus&&gI(e.systemStatus)===`unresponsive`),Ie=B(e=>e.systemStatus?.lemonade_running===!0);(0,V.useEffect)(()=>{k.state===`serverDown`&&Ie&&Me(!0)},[k.state,Ie,Me]);let Le=B(e=>e.systemStatus?.lemonade_running===!1);(0,V.useEffect)(()=>{if(k.state!==`ready`||!Le)return;let e=!1;return ve(!!_c.getState().active?.remote).then(t=>{!e&&!t.ready&&t.stage===`server`&&t.initialized&&ee({state:`serverDown`,modelListUnread:!!t.model_list_unread})}).catch(e=>F.system.warn(`Could not confirm the model server is down`,e)),()=>{e=!0}},[k.state,Le]);let Re=(0,V.useRef)(0),ze=(0,V.useCallback)(async()=>{let e=++Re.current,t=(await Pe()).agents||[];e===Re.current&&(g(t),ie(!0),xO(t)&&oe(!1))},[g]),Be=(0,V.useCallback)(()=>{let e=ae.current;ie(!1),ze().catch(t=>{F.api.warn(`Agent list unavailable after setup`,t),e&&ie(!0)})},[ze]);(0,V.useEffect)(()=>{let e=()=>{ue.current&&ze().catch(e=>F.api.warn(`Agent list unavailable`,e))};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[ze]);let Ve=(0,V.useCallback)(async()=>{y((await yt()).default_mode)},[y]),He=(0,V.useRef)([]);(0,V.useEffect)(()=>{_t(`0.27.0rc1`),Me(!1,!0);let e=[XY(ze,{onError:(e,t)=>{mX(t)&&F.api.warn(`Agent list unavailable (attempt ${t}); retrying`,e)}}),XY(Ve,{onError:(e,t)=>{mX(t)&&F.api.warn(`Default permission mode unavailable (attempt ${t}); retrying`,e)}})];return He.current=e,()=>e.forEach(e=>e.stop())},[Me,ze,Ve]);let Ue=(0,V.useCallback)(()=>{He.current.forEach(e=>e.kick()),_c.getState().retryNow(),je.current();let e=A.current;e.state===`unknown`&&!e.upgradeFailed&&Me(!0)},[Me]),We=(0,V.useRef)(Ue);We.current=Ue;let Ge=(0,V.useRef)(0),Ke=(0,V.useRef)(0),qe=(0,V.useRef)(null),Je=(0,V.useRef)(!1),[Ye,Xe]=(0,V.useState)(!1),[Ze,Qe]=(0,V.useState)(null),$e=(0,V.useCallback)(e=>{if(e.kind===`unreachable`){F.system.warn(`System status check failed`,e.error),KJ(),Je.current=!0,Ke.current=0,qe.current=null,Xe(!1),Qe(null),h(!1),m(null);return}if(e.kind===`error`){F.system.warn(`System status answered HTTP ${e.httpStatus}`,e.message),Je.current&&We.current(),Je.current=!1,Ke.current=0,qe.current=null,Xe(!1),Qe(`HTTP ${e.httpStatus}: ${e.message}`),h(!0);return}if(e.kind===`slow`){if(Ke.current+=1,qe.current??=Date.now(),Qe(null),F.system.warn(`System status did not answer in time (${Ke.current} in a row)`),Date.now()-qe.current>=iX){Xe(!1),h(!1),m(null);return}h(!0),(Je.current||Ke.current>=rX)&&Xe(!0);return}let{status:t}=e;Je.current&&We.current(),Je.current=!1,Ke.current=0,qe.current=null,Xe(!1),Qe(null),h(!0),Ge.current=t.lemonade_running?0:Ge.current+1;let n=B.getState().systemStatus;t.lemonade_running||Ge.current>=rX||!n?.lemonade_running?m(t):m({...n,download_progress:t.download_progress})},[h,m]),tt=(0,V.useRef)($e);tt.current=$e;let[nt]=(0,V.useState)(()=>yI(e=>tt.current(e))),rt=nt.check;Ae.current=rt,(0,V.useEffect)(()=>CH(nt.start),[nt]),(0,V.useEffect)(()=>qJ(()=>{rt()}),[rt]);let it=(0,V.useRef)(``);(0,V.useEffect)(()=>{let e=e=>wn().then(t=>{let r=t.sessions||[];if(!e&&r.length===0&&B.getState().sessions.length>0)return;let i=r.map(e=>`${e.id}|${e.updated_at}|${e.title}|${e.inference_remote}|${e.inference_provider}|${e.inference_description}|${e.effective_model}|${e.unread}|${e.pinned}|${e.last_run_status}|${e.kind}`).join(`
|
|
213
|
-
`);if(i===it.current)return;it.current=i,n(r);let a=_c.getState().active?.model;a&&r.some(e=>e.effective_model&&e.effective_model!==a)&&_c.getState().refresh()}).catch(t=>{e&&F.system.error(`Could not load chats`,t)});je.current=()=>e(!1),e(!0);let t=setInterval(()=>void e(!1),5e3);return()=>clearInterval(t)},[n]),(0,V.useEffect)(()=>MI(),[]),(0,V.useEffect)(()=>{let e=()=>{
|
|
205
|
+
`)),e instanceof SO?_(!0):h(CM(e))}finally{ne.current=!1,y(!1)}}}},[D,e]),ie=(0,V.useCallback)(()=>re(D.compose(f.trim()),f.trim()),[D,re,f]);(0,V.useEffect)(()=>{n&&w.current?.focus()},[n]),(0,V.useEffect)(()=>{let e=w.current;t&&e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},[t]);let ae=v,j=(0,V.useRef)(null);(0,V.useLayoutEffect)(()=>{let e=T.current;if(!e)return;typeof e.getAnimations==`function`&&e.getAnimations().forEach(e=>e.cancel());let t=e.getBoundingClientRect().top,n=j.current;if(j.current={top:t,docked:ae},!n||n.docked===ae||Az()||typeof e.animate!=`function`)return;let r=getComputedStyle(document.documentElement).getPropertyValue(`--ease`).trim();if(!r)throw Error(`Motion token --ease is not set; check styles/index.css.`);e.animate([{transform:`translateY(${n.top-t}px)`},{transform:`none`}],{duration:kz(`--duration-spring`),easing:r})});let oe=(0,V.useRef)(``),se=(0,V.useCallback)(e=>{let t=oe.current,n=(t&&f.endsWith(t)?f.slice(0,-t.length):f).trimEnd();oe.current=e,p(n?`${n}\n\n${e}`:e),w.current?.focus()},[f,p]),ce=l?.state===`starting`||l?.state===`downloading`,le=v?`sending`:ce?`download`:c||O!==null?`loading`:`idle`,ue=b?.working_folder;return z(`main`,{className:`new-chat${ae?` is-docked`:``}`,"aria-label":s(`newChat.label`),children:[I(nU,{activity:le,progress:(l?.percent??0)/100,pulse:f.length,docked:ae,contentRef:T,composerRef:E}),I(`div`,{className:`new-chat-actions`,children:I(mV,{})}),z(`div`,{className:`new-chat-inner`,ref:T,children:[I(`h1`,{className:`new-chat-greeting`,"aria-hidden":ae,children:XU(new Date,s)}),u&&!d&&I(nW,{error:u}),I(`div`,{ref:E,children:I(LL,{value:f,onChange:p,onSubmit:ie,attachments:D,disabledReason:c?s(`composer.starting`):null,autoFocus:!0,inputRef:w,leftControls:z(P.Fragment,{children:[I(yR,{sessionId:null}),I(HU,{disabled:v})]}),rightControls:I(tR,{})})}),I(`div`,{className:`new-chat-meta`,children:ue&&I(pR,{folder:ue,disabled:c||v})}),I(tW,{}),O!==null&&!c&&I(`p`,{className:`new-chat-warmup`,role:`status`,children:QU(O,s)}),m&&I(`p`,{className:`new-chat-error`,role:`alert`,children:m}),g&&r&&I(`p`,{className:`new-chat-error`,role:`alert`,children:s(`agentNotice.sendRefused`)}),I(WU,{onPick:se,disabled:c||v}),S&&I($U,{detail:S,onRetry:()=>te()})]})]})}var iW=1e3,aW=15,oW=5,sW=new Map;function cW(){let e=R(),t=$s(e=>e.need),n=$s(e=>e.settle),r=(0,V.useRef)(null),i=(0,V.useRef)(null),a=(0,V.useRef)(0),o=(0,V.useRef)(0),s=(0,V.useRef)(null);s.current=t;let[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)(null),[m,h]=(0,V.useState)(!1),g=(0,V.useCallback)(()=>{i.current&&clearInterval(i.current),i.current=null},[]);(0,V.useEffect)(()=>(l(null),d(!1),p(null),h(!1),g),[t,g]);let _=(0,V.useCallback)(()=>{g(),u&&t?.model&&Jt(t.model.id).catch(e=>console.warn(`[ModelNeededDialog] could not cancel the download`,e)),n(!1)},[u,t,n,g]);pt(!!t,_),on(r,!!t);let v=(0,V.useCallback)(async r=>{if(!t?.model)return;let c=t,u=t.model.id,f=(sW.get(u)??0)+1;sW.set(u,f),p(null),d(!0),a.current=0,o.current=0;try{await N(u,{acknowledgeLowDisk:r})}catch(e){if(s.current!==c)return;d(!1),p(e instanceof Error?e.message:String(e)),e instanceof Nt&&e.body?.code===`low_disk`&&h(!0);return}s.current===c?(g(),i.current=setInterval(()=>{et().then(t=>{if(s.current!==c){g();return}o.current=0;let r=t.models?.find(e=>e.id===u);if(r)r.bytes_total>0&&l(Math.floor(r.bytes_done*100/r.bytes_total)),r.state===`ready`||r.state===`verifying`?(g(),n(!0)):(r.state===`failed`||r.state===`cancelled`)&&(g(),d(!1),p(r.error??e(`modelNeeded.failed`)));else{if(++a.current<aW)return;g(),d(!1),p(e(`modelNeeded.failed`))}}).catch(e=>{s.current===c?++o.current<oW||(g(),d(!1),p(e instanceof Error?e.message:String(e))):g()})},iW)):sW.get(u)===f&&Jt(u).catch(e=>console.warn(`[ModelNeededDialog] could not cancel the download`,e))},[t,n,g,e]);if(t?.off)return(0,Mj.createPortal)(I(`div`,{className:`model-needed-overlay`,children:z(`div`,{ref:r,className:`model-needed`,role:`dialog`,"aria-modal":`true`,"aria-label":e(`modelNeeded.off.${t.off}.title`),children:[I(`h2`,{className:`model-needed-title`,children:e(`modelNeeded.off.${t.off}.title`)}),I(`p`,{className:`model-needed-from`,children:e(`modelNeeded.off.${t.off}.body`)}),z(`div`,{className:`model-needed-actions`,children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:_,children:e(`modelNeeded.notNow`)}),I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>n(!0),children:e(`modelNeeded.off.send`)})]})]})}),document.body);if(!t?.model)return null;let{model:y,job:b,disk_free_gb:x}=t,S=y.size_gb!=null&&x!=null&&y.size_gb>x,C=S||m;return(0,Mj.createPortal)(I(`div`,{className:`model-needed-overlay`,children:z(`div`,{ref:r,className:`model-needed`,role:`dialog`,"aria-modal":`true`,"aria-label":e(`modelNeeded.dialog`),children:[I(`h2`,{className:`model-needed-title`,children:e(`modelNeeded.title.${b}`)}),z(`p`,{className:`model-needed-line`,children:[I(`bdi`,{children:y.name}),y.size_gb!=null&&z(P.Fragment,{children:[`, `,I(`bdi`,{dir:`ltr`,children:BO(y.size_gb)})]}),x!=null&&z(P.Fragment,{children:[` · `,e(`modelNeeded.free`),` `,I(`bdi`,{dir:`ltr`,children:BO(x)})]})]}),y.source&&z(`p`,{className:`model-needed-from`,children:[e(`setup.contents.from`),` `,I(`bdi`,{dir:`ltr`,children:y.source})]}),I(`p`,{className:`model-needed-from`,children:e(`modelNeeded.waits`)}),u&&(c==null?z(`p`,{role:`status`,children:[I(La,{size:13,className:`spin`,"aria-hidden":`true`}),` `,e(`modelNeeded.starting`)]}):I(`progress`,{className:`setup-progress`,max:100,value:c,"aria-label":e(`modelNeeded.dialog`)})),S&&!u&&I(`p`,{className:`setup-error`,role:`alert`,children:e(`modelNeeded.lowDisk`,{need:BO(y.size_gb??0),free:BO(x??0),freeUp:BO((y.size_gb??0)-(x??0))})}),f&&I(`p`,{className:`setup-error`,role:`alert`,children:f}),z(`div`,{className:`model-needed-actions`,children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:_,children:e(`modelNeeded.notNow`)}),I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void v(C),disabled:u,children:e(C?`setup.confirm.downloadAnyway`:f?`setup.tryAgain`:`modelNeeded.download`)})]})]})}),document.body)}function lW(e,t,n){let r=(0,V.useRef)(n);(0,V.useEffect)(()=>{r.current=n});let i=(0,V.useRef)(!1),a=(0,V.useRef)(null);if(t&&!i.current){let e=document.activeElement;a.current=e instanceof HTMLElement?e:null}(0,V.useEffect)(()=>{if(!t)return;i.current=!0;let n=a.current,o=e.current;if(o&&!o.contains(document.activeElement)){let e=r.current?.()??jn(o)[0];e?e.focus():(o.hasAttribute(`tabindex`)||o.setAttribute(`tabindex`,`-1`),o.focus())}return()=>{i.current=!1;let e=document.activeElement;(!e||e===document.body||o?.contains(e))&&n?.isConnected&&n.focus()}},[e,t])}var uW=2e3,dW=``,fW=``,pW={model_server:`logs.source.modelServer`,gaia:`logs.source.gaia`,service:`logs.source.service`,agent:`logs.source.agent`,desktop:`logs.source.desktop`,other:`logs.source.other`},mW={model_server:`logs.hint.modelServer`,gaia:`logs.hint.gaia`,service:`logs.hint.service`,agent:`logs.hint.agent`,desktop:`logs.hint.desktop`,other:`logs.hint.other`},hW={no_file:`logs.reason.noFile`,unreadable:`logs.reason.unreadable`,not_running:`logs.reason.notRunning`,remote:`logs.reason.remote`,no_stream:`logs.reason.noStream`,stream_failed:`logs.reason.streamFailed`},gW=e=>e.severity===`warning`||e.severity===`error`;function _W(e){return e instanceof Error?e.message:String(e)}function vW(e){let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}${t(e.getMonth()+1)}${t(e.getDate())}-${t(e.getHours())}${t(e.getMinutes())}${t(e.getSeconds())}`}function yW({source:e,file:t}){let n=R(),[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)([]),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!0),[d,f]=(0,V.useState)(!0),[p,m]=(0,V.useState)(!1),[h,g]=(0,V.useState)(null),_=(0,V.useRef)(null),v=(0,V.useRef)(!1),y=(0,V.useRef)(null),b=(0,V.useRef)(!0),x=(0,V.useRef)(null),S=(0,V.useCallback)(async n=>{if(!v.current){v.current=!0,n&&u(!0);try{let r=await D(e,{file:t,after:n?null:_.current});r.cursor&&(_.current=r.cursor);let a=r.lines??[],s=n||!!r.reset;o(e=>(s?a:[...e,...a]).slice(-5e3)),i(e=>s||!e?r:{...r,server_answering:r.server_answering??e.server_answering,dropped:e.dropped}),c(null)}catch(e){c(_W(e))}finally{v.current=!1,u(!1)}}},[e,t]);(0,V.useEffect)(()=>{_.current=null,b.current=!0,i(null),o([]),g(null),S(!0)},[S]),(0,V.useEffect)(()=>{if(!d)return;let e=setInterval(()=>{S(!1)},uW);return()=>clearInterval(e)},[d,S]);let C=p?a.filter(gW):a,w=C.map(e=>e.text).join(`
|
|
206
|
+
`),T=(0,V.useCallback)(()=>{let e=y.current;e&&b.current&&(e.scrollTop=e.scrollHeight,x.current=e.scrollTop)},[]);(0,V.useEffect)(T,[w,T]);let E=C.length>0;(0,V.useEffect)(()=>{let e=y.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(T);return t.observe(e),e.firstElementChild&&t.observe(e.firstElementChild),()=>t.disconnect()},[E,T]);let O=(0,V.useCallback)(async()=>{try{await navigator.clipboard.writeText(w),g({ok:!0,text:n(`logs.copied`)})}catch(e){g({ok:!1,text:n(`logs.copyFailed`,{error:_W(e)})})}},[n,w]),k=(0,V.useCallback)(()=>{let t=URL.createObjectURL(new Blob([`${w}\n`],{type:`text/plain;charset=utf-8`})),n=document.createElement(`a`);n.href=t,n.download=`gaia-${e.replace(`_`,`-`)}-log-${vW(new Date)}.txt`,n.click(),setTimeout(()=>URL.revokeObjectURL(t),6e4),g(null)},[e,w]),ee=e===`model_server`,te=r&&!r.available&&r.reason?!ee&&r.reason===`no_file`?`logs.reason.notWritten`:hW[r.reason]:void 0;return z(`div`,{className:`log-viewer-view`,children:[I(`p`,{className:`log-viewer-hint`,children:n(mW[e])}),r?.source===`file`&&r.log_path&&z(`p`,{className:`log-viewer-source`,children:[n(`logs.fromFile`),` `,I(`bdi`,{dir:`ltr`,children:r.log_path})]}),r?.source===`stream`&&z(`p`,{className:`log-viewer-source`,children:[n(`logs.fromStream`),` `,I(`bdi`,{dir:`ltr`,children:r.base_url})]}),ee&&r?.source===`file`&&r.server_answering===!1&&I(`p`,{className:`log-viewer-warning`,role:`alert`,children:n(`logs.notAnswering`)}),te&&z(`div`,{className:`log-viewer-warning`,role:`alert`,children:[I(`p`,{children:n(te)}),r?.detail&&I(`p`,{className:`log-viewer-detail`,children:I(`bdi`,{dir:`ltr`,children:r.detail})})]}),r?.available&&r.detail&&I(`p`,{className:`log-viewer-hint`,role:`note`,children:I(`bdi`,{dir:`ltr`,children:r.detail})}),s&&I(`p`,{className:`log-viewer-warning`,role:`alert`,children:n(`logs.readFailed`,{error:s})}),z(`div`,{className:`log-viewer-toolbar`,children:[z(`label`,{className:`log-viewer-check`,children:[I(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked)}),n(`logs.follow`)]}),z(`label`,{className:`log-viewer-check`,children:[I(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked)}),n(`logs.problemsOnly`)]}),z(`div`,{className:`log-viewer-actions`,children:[z(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void S(!0),disabled:l,children:[l?I(La,{size:13,className:`spin`,"aria-hidden":`true`}):I(Bo,{size:13,"aria-hidden":`true`}),n(`logs.refresh`)]}),z(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void O(),disabled:!w,children:[h?.ok?I(Vr,{size:13,"aria-hidden":`true`}):I(hi,{size:13,"aria-hidden":`true`}),n(`logs.copy`)]}),z(`button`,{type:`button`,className:`btn-secondary`,onClick:k,disabled:!w,children:[I(zi,{size:13,"aria-hidden":`true`}),n(`logs.save`)]})]})]}),l&&!r?z(`p`,{className:`log-viewer-empty`,role:`status`,children:[I(La,{size:13,className:`spin`,"aria-hidden":`true`}),` `,n(`logs.loading`)]}):r?.available&&C.length===0?I(`p`,{className:`log-viewer-empty`,role:`status`,children:p&&a.length>0?n(`logs.noProblems`):n(`logs.empty`)}):C.length>0&&I(`pre`,{ref:y,className:`log-viewer-lines`,dir:`ltr`,tabIndex:0,"aria-label":n(pW[e]),onScroll:e=>{let t=e.currentTarget;t.scrollTop!==x.current&&(x.current=null,b.current=t.scrollHeight-t.scrollTop-t.clientHeight<8)},children:I(`span`,{className:`log-viewer-body`,children:C.map((e,t)=>z(`span`,{className:e.severity?`is-${e.severity}`:void 0,children:[e.text,`
|
|
207
|
+
`]},t))})}),(r?.dropped??0)>0&&I(`p`,{className:`log-viewer-hint`,children:n(`logs.older`)}),h&&I(`p`,{className:h.ok?`settings-ok`:`log-viewer-warning`,role:h.ok?`status`:`alert`,children:h.text})]})}function bW(){let e=R(),[t,n]=(0,V.useState)(!1),[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(null),s=(0,V.useCallback)(async()=>{n(!0),o(null),i(null);try{let e=await E(),t=await Le(e.name),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=e.name,r.click(),setTimeout(()=>URL.revokeObjectURL(n),6e4),i(e)}catch(t){o(e(`logs.saveAllFailed`,{error:_W(t)}))}finally{n(!1)}},[e]);return z(`div`,{className:`log-viewer-save-all`,children:[z(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void s(),disabled:t,children:[t?I(La,{size:13,className:`spin`,"aria-hidden":`true`}):I(lr,{size:13,"aria-hidden":`true`}),e(`logs.saveAll`)]}),I(`span`,{className:`log-viewer-hint`,children:e(`setup.logs.reportNote`)}),r&&z(`p`,{className:`log-viewer-hint`,role:`status`,children:[e(`logs.savedAll`,{size:WO(r.size_bytes)}),` `,I(`bdi`,{dir:`ltr`,children:r.path})]}),a&&I(`p`,{className:`log-viewer-warning`,role:`alert`,children:a})]})}function xW(){let e=R(),t=qs(e=>e.open),n=qs(e=>e.source),r=qs(e=>e.show),i=qs(e=>e.hide),a=(0,V.useRef)(null),o=(0,V.useRef)(null),[s,c]=(0,V.useState)({}),[l,u]=(0,V.useState)(null);if(pt(t,i),on(a,t),lW(a,t,()=>o.current),(0,V.useEffect)(()=>{t&&oe().then(e=>c(Object.fromEntries(e.sources.map(e=>[e.id,e.files??[]])))).catch(e=>console.warn(`[LogsDialog] could not list log files`,e))},[t]),(0,V.useEffect)(()=>{u(null)},[n]),!t)return null;let d=s[n]??[];return(0,Mj.createPortal)(I(`div`,{className:`log-viewer-overlay`,onMouseDown:e=>{e.target===e.currentTarget&&i()},children:z(`div`,{ref:a,className:`log-viewer`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`log-viewer-title`,children:[z(`div`,{className:`log-viewer-head`,children:[I(`h2`,{id:`log-viewer-title`,className:`log-viewer-title`,children:e(`logs.title`)}),I(`button`,{ref:o,type:`button`,className:`log-viewer-close`,onClick:i,"aria-label":e(`logs.close`),title:e(`logs.close`),children:I(Is,{size:16,"aria-hidden":`true`})})]}),I(`div`,{className:`log-viewer-tabs`,role:`tablist`,"aria-label":e(`logs.title`),children:Ks.map(t=>I(`button`,{type:`button`,role:`tab`,"aria-selected":t===n,className:t===n?`is-active`:``,onClick:()=>r(t),children:t===`gaia`?I(`bdi`,{children:e(pW[t])}):e(pW[t])},t))}),d.length>1&&z(`label`,{className:`log-viewer-file`,children:[e(`logs.file`),I(`select`,{dir:`ltr`,value:l??d[0].name,onChange:e=>u(e.target.value),children:d.map(e=>z(`option`,{value:e.name,children:[e.name,e.size_bytes==null?``:` (${dW}${SL(e.size_bytes)}${fW})`]},e.name))})]}),I(`div`,{role:`tabpanel`,className:`log-viewer-panel`,children:I(yW,{source:n,file:l},`${n}:${l??``}`)}),I(`p`,{className:`log-viewer-hint`,children:e(`logs.privacy`)}),I(bW,{})]})}),document.body)}var SW=[{label:`shortcuts.newChat`,keys:`Mod+Shift+O`},{label:`shortcuts.search`,keys:`Mod+K`},{label:`shortcuts.sidebar`,keys:`Mod+B`},{label:`shortcuts.settings`,keys:`Mod+,`},{label:`shortcuts.sheet`,keys:`Mod+/`},{label:`shortcuts.browserPane`,keys:`Mod+Shift+B`,desktopOnly:!0},{label:`shortcuts.send`,keys:`Enter`},{label:`shortcuts.newLine`,keys:`Shift+Enter`},{label:`shortcuts.editLast`,keys:`↑`},{label:`shortcuts.stop`,keys:`Esc`}];function CW(){let e=!!wB();return SW.filter(t=>e||!t.desktopOnly)}function wW({onClose:e}){let t=R(),n=(0,V.useRef)(null);return pt(!0,e),on(n,!0),lW(n,!0),I(`div`,{ref:n,className:`modal-overlay`,onClick:e,role:`dialog`,"aria-modal":`true`,"aria-label":t(`shortcuts.title`),children:z(`div`,{className:`modal-panel shortcuts-dialog`,onClick:e=>e.stopPropagation(),children:[z(`div`,{className:`modal-header`,children:[I(`h3`,{children:t(`shortcuts.title`)}),I(`button`,{type:`button`,className:`btn-icon`,onClick:e,"aria-label":t(`shortcuts.close`),children:I(Is,{size:18,"aria-hidden":`true`})})]}),I(`dl`,{className:`modal-body shortcuts-list`,children:CW().map(({label:e,keys:n})=>z(`div`,{className:`shortcuts-row`,children:[I(`dt`,{children:t(e)}),I(`dd`,{children:I(`kbd`,{dir:`ltr`,children:Yl(n)})})]},e))})]})})}function TW(e){let t=e?.reason;return t===`needs_key`||t===`bad_key`}function EW({provider:e,limit:t,picked:n=null,onPick:r,pickDisabled:i=!1,onDefault:a}){let o=R(),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(null),d=(0,V.useRef)(a);if(d.current=a,(0,V.useEffect)(()=>{let t=!0;return c(null),u(null),d.current?.(null),Ee(e).then(e=>{t&&(c(e),d.current?.(e.models[0]?.model??null))}).catch(e=>{t&&u(e instanceof Error?e.message:String(e))}),()=>{t=!1}},[e]),l)return I(`p`,{className:`settings-error`,role:`alert`,children:o(`settings.price.loadFailed`,{reason:l})});if(!s)return z(`p`,{className:`settings-hint`,children:[I(La,{size:13,className:`spin`}),` `,o(`settings.price.loading`)]});if(s.models.length===0)return z(`p`,{className:`settings-hint cloud-prices-note`,children:[o(`settings.price.unknownSentence`),` `,I(`bdi`,{children:s.note})]});let f=t?s.models.slice(0,t):s.models,p=n?s.models.find(e=>e.model===n&&!f.includes(e)):void 0,m=p?[...f,p]:f,h=n??m[0]?.model,g=r!==void 0;return z(`div`,{className:`cloud-prices`,"aria-label":o(`settings.model.prices`),children:[g&&I(`p`,{className:`cloud-prices-legend`,id:`cloud-prices-legend`,children:o(`settings.price.pickLegend`)}),I(`ul`,{className:`cloud-prices-list${g?` is-pickable`:``}`,role:g?`radiogroup`:void 0,"aria-labelledby":g?`cloud-prices-legend`:void 0,children:m.map((t,n)=>{let a=z(`span`,{className:`cloud-prices-name`,children:[I(`bdi`,{children:t.name}),n===0&&g&&z(`span`,{className:`cloud-prices-default`,children:[` · `,o(`settings.price.default`)]}),t.note&&z(`span`,{className:`cloud-prices-note`,children:[` · `,I(`bdi`,{children:t.note})]})]});return z(`li`,{className:g&&h===t.model?`is-chosen`:void 0,children:[g?z(`label`,{className:`cloud-prices-pick`,children:[I(`input`,{type:`radio`,name:`cloud-model-${e}`,value:t.model,checked:h===t.model,disabled:i,onChange:()=>r(t.model)}),a]}):a,I(`span`,{className:`cloud-prices-price`,children:HL(t.price,o)})]},t.model)})}),z(`span`,{className:`settings-hint`,children:[I(`bdi`,{children:s.source}),`. `,o(`settings.price.payProvider`)]})]})}function DW(){return au(Oz)}function OW(e,t=150){let n=DW(),[r,i]=(0,V.useState)(e),a=(0,V.useRef)(e);return(0,V.useEffect)(()=>{if(n||typeof requestAnimationFrame!=`function`){a.current=e,i(e);return}let r=a.current,o=performance.now(),s=0,c=n=>{let l=Math.min(1,(n-o)/t),u=1-(1-l)**3,d=r+(e-r)*u;a.current=d,i(d),l<1&&(s=requestAnimationFrame(c))};return s=requestAnimationFrame(c),()=>cancelAnimationFrame(s)},[e,t,n]),r}function kW(e,t){let[n,r]=(0,V.useState)(e);return(0,V.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}function AW(){let[e,t]=(0,V.useState)(()=>typeof document>`u`||document.visibilityState!==`hidden`);return(0,V.useEffect)(()=>{let e=()=>t(document.visibilityState!==`hidden`);return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),e}var jW=180;function MW({open:e,children:t}){let[n,r]=(0,V.useState)(e),[i,a]=(0,V.useState)(e),o=(0,V.useRef)(t);return e&&(o.current=t),(0,V.useEffect)(()=>{if(e){r(!0);let e=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(e)}a(!1);let t=setTimeout(()=>r(!1),jW);return()=>clearTimeout(t)},[e]),n?I(`div`,{className:`reveal${i?` is-open`:``}`,"aria-hidden":!e||void 0,children:I(`div`,{className:`reveal-inner`,children:e?t:o.current})}):null}var NW=e=>e?.catalog??[],PW=e=>e.roles.includes(`vision`),FW=e=>e.roles.includes(`embedding`),IW=e=>e.recipe===`flm`,LW=e=>e.fits===!1&&(e.fit_code===`npu`||e.fit_code===`backend`),RW=e=>e.support===null,zW=e=>e?.feature_tier!==`compact`;function BW(e,t){let n=e.find(e=>e.id===t.defaultChat);return n&&IW(n)||t.vision===`none`?null:t.vision?t.vision:n?.reads_images?n.id:e.find(e=>PW(e)&&e.gaia_model)?.id??null}function VW(e,t){let n=BW(t,e),r=new Set(e.ticked),i=new Set(e.unticked);for(let a of t)PW(a)&&a.id!==e.defaultChat&&(a.id===n?(r.add(a.id),i.delete(a.id)):a.downloaded||(r.delete(a.id),i.add(a.id)));return{...e,ticked:r,unticked:i}}function HW(e,t,n){let r=new Set(e.ticked),i=t.find(t=>t.id===e.defaultChat);i&&!i.downloaded&&r.delete(i.id);let a=t.find(e=>e.id===n);if(a?.downloaded||r.add(n),!zW(a))for(let e of t)e.roles.includes(`image_creation`)&&r.delete(e.id);return VW({...e,ticked:r,defaultChat:n,chatChosen:!0,vision:null},t)}function UW(e,t,n){return VW({...e,vision:n},t)}function WW(e,t){if(t.vision===`none`)return null;let n=BW(e,t),r=e.find(e=>e.id===t.defaultChat);return r&&IW(r)||n===(r?.reads_images?r.id:e.find(e=>PW(e)&&e.gaia_model)?.id)?null:n}function GW(e){return e.filter(e=>e.gaia_model&&(e.planned||e.recommended||e.downloaded||e.partial))}function KW(e){let t=new Set(GW(e).map(e=>e.id));return e.filter(e=>e.gaia_model&&!t.has(e.id))}function qW(e){return e.filter(e=>!e.gaia_model&&e.downloaded)}function JW(e){let t=NW(e),n=new Set(t.filter(e=>e.selected||e.gaia_model&&e.downloaded&&!e.skipped).map(e=>e.id)),r=!t.find(t=>t.id===e.chat_model.id)?.reads_images&&t.some(e=>PW(e)&&e.gaia_model&&e.skipped);return VW({ticked:n,defaultChat:e.chat_model.id,unticked:new Set,chatChosen:e.chat_model.user_set,vision:e.vision_model??(r?`none`:null)},t)}function YW(e,t){return e.filter(e=>e.chat_choice&&(t.has(e.id)||e.downloaded))}function XW(e,t,n,r){let i=new Set(e.ticked),a=new Set(e.unticked);r?(i.add(n),a.delete(n)):(i.delete(n),a.add(n));let o=YW(t,i),s=e.defaultChat;if(!s||!o.some(e=>e.id===s)){let e=t.find(e=>e.id===n);s=r&&e?.chat_choice?n:(o.find(e=>e.recommended)??o[0])?.id??null}return{...e,ticked:i,defaultChat:s,unticked:a}}function ZW(e,t,n){let r=t.find(e=>e.id===n)?.downloaded;return{...e,defaultChat:n,chatChosen:!0,ticked:r?e.ticked:new Set([...e.ticked,n])}}function QW(e){let t=NW(e),n=new Set(t.filter(e=>e.recommended||e.gaia_model&&e.downloaded).map(e=>e.id)),r=YW(t,n);return VW({ticked:n,defaultChat:e.recommended_model&&r.some(t=>t.id===e.recommended_model)?e.recommended_model:(r.find(e=>e.recommended)??r[0])?.id??null,unticked:new Set,chatChosen:!1,vision:null},t)}function $W(e,t){return e.filter(e=>t.ticked.has(e.id)&&!e.downloaded).sort((e,t)=>(t.size_gb??0)-(e.size_gb??0))}function eG(e,t){let n=$W(NW(e),t).map(e=>e.size_gb),r=n.every(e=>e!=null)?oG(n.reduce((e,t)=>e+t,0)):null,i=e.disk?.free_gb??null;return{downloadGb:r,freeGb:i,afterGb:r!=null&&i!=null?oG(i-r):null}}function tG(e,t){let{downloadGb:n,freeGb:r}=eG(e,t);return n==null||r==null||n<=r?null:{needGb:n,freeGb:r,freeUpGb:oG(n-r),drop:$W(NW(e),t).find(e=>e.size_gb!=null&&n-e.size_gb<=r)??null}}function nG(e,t){return e.filter(e=>e.fits===!1&&(t.ticked.has(e.id)||e.id===t.defaultChat))}function rG(e,t){let n=[];for(let r of NW(e)){if(!r.planned){r.skipped&&t.ticked.has(r.id)&&n.push({id:r.id,skipped:!1});continue}if(r.id===e.chat_model.id){r.skipped&&n.push({id:r.id,skipped:!1});continue}let i=t.ticked.has(r.id);!i&&!r.skipped&&n.push({id:r.id,skipped:!0}),i&&r.skipped&&n.push({id:r.id,skipped:!1})}return n}function iG(e,t){return NW(e).filter(e=>t.ticked.has(e.id)&&!e.planned&&!e.downloaded).map(e=>e.id)}function aG(e,t){let n=(e.models??[]).filter(e=>e.state!==`skipped`);if(!t?.catalog||n.length===0)return e.overall;let r=0,i=0;for(let e of n){let n=t.catalog.find(t=>t.id===e.id),a=n?.downloaded?0:n?.size_gb==null?e.bytes_total:Math.min(e.bytes_total||1/0,n.size_gb*1e9),o=Math.max(0,e.bytes_total-a);i+=a,r+=e.state===`ready`||e.state===`verifying`?a:Math.min(a,Math.max(0,e.bytes_done-o))}return{bytes_done:r,bytes_total:i,speed_bps:e.overall?.speed_bps??0,eta_s:null,percent:i>0?Math.floor(r*100/i):100,failed:n.filter(e=>e.state===`failed`).length}}function oG(e){return Math.round(e*10)/10}var sG=6;function cG(e,t){let n=[];return e.chat_choice&&!FW(e)&&n.push(t(`setup.models.purpose.chat`)),PW(e)&&n.push(t(`setup.models.purpose.vision`)),FW(e)&&n.push(t(`setup.models.purpose.documents`)),e.roles.includes(`speech`)&&n.push(t(`setup.models.purpose.speech`)),e.roles.includes(`voice`)&&n.push(t(`setup.models.purpose.voice`)),e.roles.includes(`image_creation`)&&n.push(t(`setup.models.purpose.imageCreation`)),n}function lG(e,t){return FW(e)?t(`setup.models.line.documents`):PW(e)?t(`setup.models.line.vision`):e.roles.includes(`speech`)?t(`setup.models.line.speech`):e.roles.includes(`voice`)?t(`setup.models.line.voice`):e.roles.includes(`image_creation`)?t(`setup.models.line.imageCreation`):t(`setup.models.line.chat`)}function uG(e,t){return e.downloaded?t(`setup.models.status.onPc`):e.size_gb==null?t(`setup.models.status.sizeUnknown`):e.partial?t(`setup.models.status.partial`,{size:BO(e.size_gb)}):t(`setup.models.status.download`,{size:BO(e.size_gb)})}function dG(e,t){return e.fits!==!0||e.need_gb==null||e.capacity_gb==null?null:t(`setup.models.fit.ok`,{need:UO(e.need_gb),have:UO(e.capacity_gb)})}function fG(e,t){return e.fit_code===`npu`?t(`setup.models.warn.npu`):e.fit_code===`backend`?t(`setup.models.warn.backend`):e.need_gb!=null&&e.capacity_gb!=null?t(`setup.models.warn.tooBig`,{need:UO(e.need_gb),have:UO(e.capacity_gb)}):t(`setup.models.warn.tooBigNoNumbers`)}function pG(e,t,n,r){return!PW(e)&&!FW(e)||PW(e)&&!e.downloaded&&r?null:n===`settings`?e.downloaded?t(`settings.models.warn.kept`,{name:e.name}):t(PW(e)?`settings.models.warn.vision`:`settings.models.warn.documents`,{name:e.name}):t(PW(e)?`setup.models.warn.vision`:`setup.models.warn.documents`,{name:e.name})}function mG({entry:e,ticked:t,onToggle:n,disabled:r,progress:i,actions:a,place:o,imagesCovered:s}){let c=R(),l=(0,V.useId)(),u=e.fits===!1,d=t?null:pG(e,c,o,s),f=i?.state===`downloading`&&i.bytes_total>0,p=u?fG(e,c):d,m=[`${l}-status`,`${l}-note`,p?`${l}-warn`:null].filter(Boolean).join(` `);return z(`li`,{className:`mc-row${t?` is-ticked`:``}${p?` has-warning`:``}`,children:[z(`div`,{className:`mc-row-top`,children:[z(`label`,{className:`mc-row-main`,children:[I(`input`,{type:`checkbox`,className:`mc-input`,checked:t,disabled:r,onChange:e=>n(e.target.checked),"aria-describedby":m}),I(`span`,{className:`mc-box`,"aria-hidden":`true`,children:I(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,children:I(`path`,{className:`mc-tick`,d:`M3.5 8.5l3 3 6-7`})})}),z(`span`,{className:`mc-text`,children:[z(`span`,{className:`mc-name-line`,children:[I(`bdi`,{className:`mc-name`,title:e.id,children:e.name}),z(`span`,{className:`mc-chips`,children:[cG(e,c).map(e=>I(`span`,{className:`mc-chip`,children:e},e)),IW(e)&&I(`span`,{className:`mc-chip is-npu`,children:c(`setup.models.npu`)})]})]}),z(`span`,{className:`mc-status`,id:`${l}-status`,children:[f?c(`setup.models.status.downloading`,{done:WO(i.bytes_done),total:WO(i.bytes_total)}):uG(e,c),e.recommended&&I(`span`,{className:`mc-pill`,children:c(`setup.models.recommended`)}),e.fits===null&&z(`span`,{className:`mc-chip is-unknown`,children:[I(ai,{size:11,"aria-hidden":`true`}),` `,c(`setup.models.fitUnknown`)]})]}),I(`span`,{className:`mc-note`,id:`${l}-note`,children:c.compose(t=>[lG(e,t),dG(e,t),e.fits===null?t(`setup.models.fit.unknown`):null].filter(Boolean).join(` `))})]})]}),a&&I(`span`,{className:`mc-actions`,children:a})]}),f&&I(`progress`,{className:`mc-mini-progress`,max:i.bytes_total,value:i.bytes_done,"aria-label":c(`setup.progress.rowLabel`,{name:e.name,state:c(`setup.state.downloading`)})}),I(MW,{open:!!p,children:z(`p`,{className:`mc-warn${u?` is-big`:``}`,role:`note`,id:`${l}-warn`,children:[I(ws,{size:13,"aria-hidden":`true`}),I(`span`,{children:p})]})})]})}function hG({plan:e,selection:t}){let n=R(),{downloadGb:r,freeGb:i,afterGb:a}=eG(e,t),o=tG(e,t),s=OW(r??0),c=OW(a??0),l=gG(e.disk?.path??null),u=r!=null&&i?Math.min(1,r/i):0,d=kW(r==null?n(`setup.summary.spokenUnknown`):a==null?n(`setup.summary.spokenNoDisk`,{download:BO(r)}):n(`setup.summary.spoken`,{download:BO(r),after:BO(Math.max(0,a))}),600);return z(`div`,{className:`mc-summary${o?` is-warn`:``}`,role:`group`,"aria-label":n(`setup.summary.label`),children:[z(`div`,{className:`mc-summary-stats`,children:[z(`span`,{className:`mc-stat`,children:[I(`span`,{className:`mc-stat-label`,children:n(`setup.summary.download`)}),I(`bdi`,{className:`mc-stat-value`,children:r==null?n(`setup.summary.sizeUnknown`):BO(_G(s))})]}),z(`span`,{className:`mc-stat`,children:[z(`span`,{className:`mc-stat-label`,children:[I(ha,{size:12,"aria-hidden":`true`}),` `,l?z(P.Fragment,{children:[n(`setup.summary.freeOn`),` `,I(`bdi`,{dir:`ltr`,className:`mc-stat-path`,children:l})]}):n(`setup.summary.free`)]}),I(`bdi`,{className:`mc-stat-value`,children:i==null?n(`setup.summary.freeUnknown`):BO(i)})]}),a!=null&&!o&&z(`span`,{className:`mc-stat`,children:[I(`span`,{className:`mc-stat-label`,children:n(`setup.summary.after`)}),I(`bdi`,{className:`mc-stat-value`,children:BO(Math.max(0,_G(c)))})]})]}),i!=null&&I(`div`,{className:`mc-disk`,"aria-hidden":`true`,children:I(`span`,{className:`mc-disk-fill`,style:{inlineSize:`${(u*100).toFixed(1)}%`}})}),I(MW,{open:!!o,children:o&&z(`p`,{className:`mc-disk-warn`,role:`note`,children:[I(ws,{size:13,"aria-hidden":`true`}),I(`span`,{children:o.drop?n(`setup.summary.shortDrop`,{need:BO(o.needGb),free:BO(o.freeGb),drive:l??n(`setup.summary.theDrive`),freeUp:BO(o.freeUpGb),name:o.drop.name,saves:BO(o.drop.size_gb??0)}):n(`setup.summary.short`,{need:BO(o.needGb),free:BO(o.freeGb),drive:l??n(`setup.summary.theDrive`),freeUp:BO(o.freeUpGb)})})]})}),I(`span`,{className:`visually-hidden`,"aria-live":`polite`,children:d})]})}function gG(e){if(!e)return null;let t=/^([A-Za-z]:)[\\/]/.exec(e);return t?t[1]:e}function _G(e){return Math.round(e*10)/10}function vG({plan:e,selection:t,onToggle:n,onDefaultChat:r,labelledBy:i,cloud:a,disabled:o,progress:s,rowActions:c,place:l=`setup`}){let u=R(),d=NW(e),[f,p]=(0,V.useState)(``),m=(0,V.useId)(),h=a?d.filter(FW):GW(d),g=a?[]:KW(d),_=a?[]:qW(d),v=(0,V.useMemo)(()=>{let e=f.trim().toLowerCase();return e?_.filter(t=>t.id.toLowerCase().includes(e)||t.name.toLowerCase().includes(e)):_},[_,f]),y=YW(d,t.ticked),b=e=>I(mG,{entry:e,ticked:t.ticked.has(e.id),onToggle:t=>n(e.id,t),disabled:o,progress:s?.[e.id],actions:c?.(e),place:l,imagesCovered:d.some(n=>n.id!==e.id&&PW(n)&&(t.ticked.has(n.id)||n.downloaded===!0))},e.id);return z(`div`,{className:`mc`,children:[I(`ul`,{className:`mc-list`,role:`group`,"aria-labelledby":i,children:h.map(b)}),a?I(`p`,{className:`setup-hint`,children:u(`setup.models.cloudNote`)}):I(`p`,{className:`mc-foot`,children:u(`setup.models.neverDeletes`)}),g.length>0&&z(`details`,{className:`mc-more`,children:[I(`summary`,{children:u(`setup.models.more`,{n:String(g.length)})}),I(`ul`,{className:`mc-list`,role:`group`,"aria-label":u(`setup.models.moreLabel`),children:g.map(b)})]}),_.length>0&&z(`details`,{className:`mc-more`,children:[I(`summary`,{children:u(`setup.models.installed`,{n:String(_.length)})}),_.length>sG&&I(`input`,{className:`settings-input mc-search`,type:`search`,value:f,onChange:e=>p(e.target.value),placeholder:u(`setup.models.search`),"aria-label":u(`setup.models.search`)}),I(`ul`,{className:`mc-list`,role:`radiogroup`,"aria-label":u(`setup.models.installedLabel`),children:v.map(e=>I(`li`,{className:`mc-row is-installed${t.defaultChat===e.id?` is-ticked`:``}`,children:z(`label`,{className:`mc-row-main`,children:[I(`input`,{type:`radio`,name:`${m}-installed`,className:`mc-radio`,checked:t.defaultChat===e.id,disabled:o,onChange:()=>r(e.id)}),z(`span`,{className:`mc-text`,children:[z(`span`,{className:`mc-name-line`,children:[I(`bdi`,{className:`mc-name`,title:e.id,children:e.name}),z(`span`,{className:`mc-chips`,children:[I(`span`,{className:`mc-chip`,children:u(`setup.models.purpose.chat`)}),IW(e)&&I(`span`,{className:`mc-chip is-npu`,children:u(`setup.models.npu`)})]})]}),z(`span`,{className:`mc-status`,children:[u(`setup.models.status.onPc`),` · `,u(`setup.models.useAsDefault`)]})]})]})},e.id))})]}),!a&&z(`div`,{className:`mc-default`,children:[I(`label`,{htmlFor:m,className:`mc-default-label`,children:u(`setup.models.defaultChat`)}),z(`select`,{id:m,className:`settings-input mc-select`,value:t.defaultChat??``,disabled:o||y.length===0,onChange:e=>r(e.target.value),children:[y.length===0&&I(`option`,{value:``,children:u.bare(`setup.models.noChat`)}),y.map(e=>z(`option`,{value:e.id,children:[e.name,IW(e)?` (${u(`setup.models.npu`)})`:``]},e.id))]})]})]})}function yG(){let e=R();return z(`div`,{className:`mc`,"aria-busy":`true`,children:[z(`p`,{className:`setup-hint`,role:`status`,children:[I(La,{size:13,className:`spin`,"aria-hidden":`true`}),` `,e(`setup.models.loading`)]}),I(`ul`,{className:`mc-list`,"aria-hidden":`true`,children:[0,1,2].map(e=>I(`li`,{className:`mc-row is-skeleton`,children:I(`span`,{className:`mc-skeleton`})},e))})]})}function bG({entry:e}){let t=R();return e.support===`verified`?I(`span`,{className:`mc-chip is-verified`,children:t(`setup.label.verified`)}):e.support===`untested`?I(`span`,{className:`mc-chip is-untested`,children:t(`setup.label.untested`)}):null}function xG({name:e,entry:t,checked:n,recommended:r,disabled:i,onPick:a,children:o}){let s=R();return I(`li`,{className:`mc-row${n?` is-ticked`:``}`,children:z(`label`,{className:`mc-row-main`,children:[I(`input`,{type:`radio`,className:`mc-radio`,name:e,checked:n,disabled:i||LW(t),onChange:a}),z(`span`,{className:`mc-text`,children:[z(`span`,{className:`mc-name-line`,children:[I(`span`,{className:`mc-name`,title:t.id,children:I(`bdi`,{children:t.name})}),z(`span`,{className:`mc-chips`,children:[r&&I(`span`,{className:`mc-pill`,children:s(`setup.models.recommended`)}),I(bG,{entry:t}),IW(t)&&I(`bdi`,{className:`mc-chip is-npu`,children:s(`setup.models.npu`)})]})]}),I(`span`,{className:`mc-status`,children:uG(t,s)}),t.fits===!1&&z(`span`,{className:`mc-warn is-big`,role:`note`,children:[I(ws,{size:13,"aria-hidden":`true`}),` `,fG(t,s)]}),o]})]})})}function SG({label:e,note:t,size:n,checked:r,disabled:i,warning:a,chips:o,onChange:s}){return I(`li`,{className:`mc-row${r?` is-ticked`:``}${i?` is-off`:``}`,children:z(`label`,{className:`mc-row-main`,children:[I(`input`,{type:`checkbox`,className:`mc-input`,checked:r,disabled:i,onChange:e=>s(e.target.checked)}),I(`span`,{className:`mc-box`,"aria-hidden":`true`,children:I(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,children:I(`path`,{className:`mc-tick`,d:`M3.5 8.5l3 3 6-7`})})}),z(`span`,{className:`mc-text`,children:[z(`span`,{className:`mc-name-line`,children:[I(`span`,{className:`mc-name`,children:I(`bdi`,{children:e})}),I(`span`,{className:`mc-chips`,children:o})]}),I(`span`,{className:`mc-status`,children:I(`bdi`,{dir:`ltr`,children:n})}),I(`span`,{className:`mc-note`,children:t}),a&&z(`span`,{className:`mc-warn`,role:`note`,children:[I(ws,{size:13,"aria-hidden":`true`}),` `,a]})]})]})})}function CG({plan:e,selection:t,onSelection:n,disabled:r}){let i=R(),a=(0,V.useId)(),o=NW(e),[s,c]=(0,V.useState)(!1),l=o.find(e=>e.id===t.defaultChat),u=!!l&&IW(l),d=o.filter(e=>e.chat_choice&&!FW(e)&&(e.gaia_model||e.downloaded)&&IW(e)===u),f=d.filter(e=>e.support===`verified`),p=d.filter(e=>e.support!==`verified`),m=BW(o,t),h=!!l?.reads_images,g=o.filter(e=>PW(e)&&e.id!==l?.id),_=o.find(FW),v=e=>o.find(t=>RW(t)&&t.roles.includes(e)),y=e=>e.downloaded?i(`setup.models.status.onPc`):e.size_gb==null?i(`setup.contents.sizeOnDownload`):BO(e.size_gb),b=(e,r)=>n(XW(t,o,e,r)),x=e=>n(HW(t,o,e)),S=e=>n(UW(t,o,e)),C=v(`speech`),w=v(`voice`),T=v(`image_creation`),E=zW(l),D=l?.support===`untested`;return z(`div`,{className:`mc`,children:[z(`section`,{className:`mc-job`,"aria-labelledby":`${a}-chat`,children:[I(`h3`,{className:`mc-job-title`,id:`${a}-chat`,children:i(`setup.job.chat`)}),I(`p`,{className:`setup-hint`,children:i(`setup.job.verifiedNote`)}),I(`ul`,{className:`mc-list`,role:`radiogroup`,"aria-labelledby":`${a}-chat`,children:f.map(n=>I(xG,{name:`${a}-chat-model`,entry:n,checked:n.id===t.defaultChat,recommended:n.id===e.recommended_model,disabled:r,onPick:()=>x(n.id)},n.id))}),p.length>0&&z(P.Fragment,{children:[I(`p`,{className:`setup-hint`,children:i(`setup.job.untestedNote`)}),I(`ul`,{className:`mc-list`,role:`radiogroup`,"aria-labelledby":`${a}-chat`,children:p.map(e=>I(xG,{name:`${a}-chat-model`,entry:e,checked:e.id===t.defaultChat,recommended:!1,disabled:r,onPick:()=>x(e.id)},e.id))})]}),D&&z(`p`,{className:`mc-warn`,role:`note`,children:[I(ws,{size:13,"aria-hidden":`true`}),` `,i(`setup.job.untestedPicked`)]})]}),z(`section`,{className:`mc-job`,"aria-labelledby":`${a}-vision`,children:[I(`h3`,{className:`mc-job-title`,id:`${a}-vision`,children:i(`setup.job.vision`)}),u?I(`p`,{className:`setup-hint`,role:`note`,children:i(`setup.job.visionOffNpu`,{name:l?.name??``})}):h?z(`div`,{className:`setup-card`,children:[z(`p`,{className:`mc-job-line`,children:[I(`bdi`,{children:i(`setup.job.visionBuiltIn`,{name:l?.name??``})}),I(`span`,{className:`setup-ok`,children:i(`setup.job.nothingMore`)})]}),I(`button`,{type:`button`,className:`link-btn`,"aria-expanded":s,onClick:()=>c(e=>!e),children:i(s?`setup.job.hideVision`:`setup.job.otherVision`)})]}):I(`p`,{className:`setup-hint`,children:i(`setup.job.visionNeeded`,{name:l?.name??``})}),!u&&(!h||s)&&z(`ul`,{className:`mc-list`,role:`radiogroup`,"aria-labelledby":`${a}-vision`,children:[g.map(e=>I(xG,{name:`${a}-vision-model`,entry:e,checked:m===e.id,recommended:!h&&e.gaia_model&&e.support===`verified`,disabled:r,onPick:()=>S(e.id)},e.id)),I(`li`,{className:`mc-row${m===null?` is-ticked`:``}`,children:z(`label`,{className:`mc-row-main`,children:[I(`input`,{type:`radio`,className:`mc-radio`,name:`${a}-vision-model`,checked:h?m===l?.id:m===null,disabled:r,onChange:()=>S(h?null:`none`)}),z(`span`,{className:`mc-text`,children:[I(`span`,{className:`mc-name`,children:i(h?`setup.job.useChatForVision`:`setup.job.skipVision`)}),m===null&&!h&&z(`span`,{className:`mc-warn`,role:`note`,children:[I(ws,{size:13,"aria-hidden":`true`}),` `,i(`setup.job.skipVisionNote`)]})]})]})})]})]}),_&&z(`section`,{className:`mc-job`,"aria-labelledby":`${a}-docs`,children:[I(`h3`,{className:`mc-job-title`,id:`${a}-docs`,children:i(`setup.job.documents`)}),I(`ul`,{className:`mc-list`,children:I(SG,{label:_.name,note:i(`setup.models.line.documents`),size:y(_),checked:t.ticked.has(_.id),disabled:r,warning:t.ticked.has(_.id)?null:i(`setup.job.documentsOff`),chips:z(P.Fragment,{children:[I(`span`,{className:`mc-pill`,children:i(`setup.models.recommended`)}),I(bG,{entry:_})]}),onChange:e=>b(_.id,e)})})]}),z(`section`,{className:`mc-job`,"aria-labelledby":`${a}-extras`,children:[I(`h3`,{className:`mc-job-title`,id:`${a}-extras`,children:i(`setup.job.extras`)}),I(`p`,{className:`setup-hint`,children:i(`setup.job.extrasNote`)}),z(`ul`,{className:`mc-list`,children:[C&&I(SG,{label:i(`setup.job.speech`),note:i(`setup.job.speechNote`),size:y(C),checked:t.ticked.has(C.id),disabled:r,onChange:e=>b(C.id,e)}),w&&I(SG,{label:i(`setup.job.voice`),note:i(`setup.job.voiceNote`),size:y(w),checked:t.ticked.has(w.id),disabled:r,onChange:e=>b(w.id,e)}),T&&I(SG,{label:i(`setup.job.images`),note:i(`setup.job.imagesNote`),size:y(T),checked:t.ticked.has(T.id),disabled:r||!E,warning:E?null:i(`setup.job.imagesBlocked`,{name:l?.name??``}),onChange:e=>b(T.id,e)})]})]}),I(wG,{plan:e,selection:t})]})}function wG({plan:e,selection:t}){let n=R(),r=NW(e),i=e=>r.find(t=>t.id===e)?.name??e??n(`setup.get.off`),a=e=>r.find(n=>RW(n)&&n.roles.includes(e)&&t.ticked.has(n.id)),o=r.find(e=>FW(e)&&t.ticked.has(e.id)),s=r.find(e=>e.id===t.defaultChat),c=BW(r,t),l=[a(`speech`)&&n(`setup.job.speech`),a(`voice`)&&n(`setup.job.voice`)].filter(Boolean).join(`, `);return z(`section`,{className:`setup-card`,"aria-label":n(`setup.get.title`),children:[I(`h3`,{className:`mc-job-title`,children:n(`setup.get.title`)}),z(`dl`,{className:`setup-summary-list`,children:[z(`div`,{children:[I(`dt`,{children:n(`setup.job.chat`)}),I(`dd`,{children:I(`bdi`,{children:i(t.defaultChat)})})]}),z(`div`,{children:[I(`dt`,{children:n(`setup.job.vision`)}),I(`dd`,{children:I(`bdi`,{children:s&&IW(s)?n(`setup.get.offNpu`):c?i(c):n(`setup.get.off`)})})]}),z(`div`,{children:[I(`dt`,{children:n(`setup.job.documents`)}),I(`dd`,{children:I(`bdi`,{children:o?o.name:n(`setup.get.off`)})})]}),z(`div`,{children:[I(`dt`,{children:n(`setup.get.voice`)}),I(`dd`,{children:l||n(`setup.get.off`)})]}),z(`div`,{children:[I(`dt`,{children:n(`setup.job.images`)}),I(`dd`,{children:zW(s)?a(`image_creation`)?n(`setup.get.on`):n(`setup.get.off`):n(`setup.get.notAvailable`)})]})]})]})}var TG=(0,V.createContext)(void 0),EG=TG.Provider;function DG({children:e}){let t=(0,V.useContext)(TG);return t===void 0?I(`div`,{className:`setup-row setup-nav`,children:e}):t===null?null:(0,Mj.createPortal)(I(`div`,{className:`setup-footer-row`,children:e}),t)}function OG({title:e,children:t,confirmLabel:n,cancelLabel:r,onConfirm:i,onCancel:a,danger:o,busy:s}){let c=(0,V.useRef)(null),l=(0,V.useRef)(null),u=(0,V.useId)(),d=(0,V.useId)();return on(c,!0),(0,V.useEffect)(()=>{let e=document.activeElement;return l.current?.focus(),()=>e?.focus?.()},[]),pt(!0,a,!s),(0,Mj.createPortal)(I(`div`,{className:`confirm-overlay`,children:z(`div`,{ref:c,className:`confirm-sheet`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":u,"aria-describedby":t?d:void 0,children:[I(`h2`,{id:u,className:`confirm-title`,children:e}),t&&I(`div`,{id:d,className:`confirm-body`,children:t}),z(`div`,{className:`confirm-actions`,children:[I(`button`,{ref:l,type:`button`,className:`btn-secondary`,onClick:a,disabled:s,children:r}),I(`button`,{type:`button`,className:o?`btn-danger`:`btn-primary`,onClick:i,disabled:s,children:n})]})]})}),document.body)}function kG(e){return e===`windows`?`Windows`:e===`linux`?`Linux`:e}function AG(e){let t=/^Run:\s*(.+)$/.exec(e)??/^(sudo .+)$/.exec(e);return t?t[1].trim():null}function jG(e,t){return e.setting&&Math.abs(e.setting.current_gb-t)<.05&&e.gpu_gb!=null?e.gpu_gb:e.presets?.find(e=>Math.abs(e.setting_gb-t)<.05)?.gpu_gb??null}function MG(e,t,n=!1){return t==null?e(n?`gpu.appliedAny`:`gpu.pending.restartAny`):e(n?`gpu.applied`:`gpu.pending.restart`,{gb:BO(t)})}function NG(e){e.focus({preventScroll:!0});for(let t=e.parentElement;t;t=t.parentElement){let n=getComputedStyle(t).overflowY;if(n!==`auto`&&n!==`scroll`)continue;let r=e.getBoundingClientRect().top-t.getBoundingClientRect().top;(r<0||r>t.clientHeight-40)&&(t.scrollTop+=r-16);return}}function PG(e){return e instanceof Error?e.message:String(e)}function FG({status:e,targetGpuGb:t}){let n=R(),r=e=>Math.round(e*10),i=r(e.total_gb??0),a=r(e.gpu_gb??0),o=t!=null&&r(t)>a?r(t):null,s=o==null?0:o-a,c=Math.max(0,i-a-s),l=e=>BO(e/10),u=e=>i>0?Math.min(100,e/i*100):0,d=e.pending?.state===`took_effect`;return z(`div`,{className:`gpu-split`,children:[z(`div`,{className:`gpu-bar${d?` is-new`:``}`,role:`img`,"aria-label":o==null?n(`gpu.split.aria`,{cpu:l(c),gpu:l(a)}):n(`gpu.split.ariaTarget`,{cpu:l(c),gpu:l(o),now:l(a)}),children:[I(`span`,{className:`gpu-seg is-gpu`,style:{inlineSize:`${u(a)}%`}}),I(`span`,{className:`gpu-seg is-target`,style:{inlineSize:`${u(s)}%`}}),I(`span`,{className:`gpu-seg is-cpu`}),o!=null&&I(`span`,{className:`gpu-marker`,style:{insetInlineStart:`${u(o)}%`}})]}),z(`div`,{className:`gpu-legend`,"aria-hidden":`true`,children:[I(`span`,{className:`gpu-key is-gpu`,children:I(`bdi`,{children:n(`gpu.split.gpu`,{gb:l(a)})})}),o!=null&&I(`span`,{className:`gpu-key is-target`,children:I(`bdi`,{children:n(`gpu.split.added`,{gb:l(s)})})}),I(`span`,{className:`gpu-key is-cpu`,children:I(`bdi`,{children:n(`gpu.split.cpu`,{gb:l(c)})})})]})]})}function IG({presets:e,value:t,onChange:n,recommended:r,max:i,keepGb:a,disabled:o}){let s=R();return z(Fz,{className:`gpu-presets`,"aria-label":s(`gpu.presets.label`),children:[a!=null&&I(`button`,{type:`button`,role:`radio`,"aria-checked":t===null,className:`gpu-preset${t===null?` is-active`:``}`,disabled:o,onClick:()=>n(null),children:I(`bdi`,{children:s(`gpu.presets.keep`,{gb:BO(a)})})}),e.map(e=>z(`button`,{type:`button`,role:`radio`,"aria-checked":e.setting_gb===t,className:`gpu-preset${e.setting_gb===t?` is-active`:``}`,disabled:o,onClick:()=>n(e.setting_gb),children:[I(`bdi`,{children:s(`gpu.presets.gpu`,{gb:BO(e.gpu_gb)})}),e.setting_gb===r&&z(P.Fragment,{children:[` `,I(`span`,{className:`gpu-tag is-recommended`,children:s(`gpu.presets.recommended`)})]}),e.setting_gb===i&&z(P.Fragment,{children:[` `,I(`span`,{className:`gpu-tag is-max`,children:s(`gpu.presets.max`)})]})]},e.setting_gb))]})}function LG({status:e,onStatus:t,mode:n,names:r,onSkip:i,onContinue:a,onBack:o,headingId:s,cloud:c=!1}){let u=R(),d=_c(e=>!!e.active?.remote)||c,p=(0,V.useCallback)(()=>{let e=s?document.getElementById(s):null;e&&NG(e)},[s]);(0,V.useEffect)(()=>{n===`setup`&&p()},[n,p]);let m=(0,V.useId)(),h=e.presets??[],g=d?null:e.recommended_setting_gb??null,[_,v]=(0,V.useState)(g??(e.gpu_gb==null?h[0]?.setting_gb??null:null)),[y,b]=(0,V.useState)(!1),[x,S]=(0,V.useState)(null),[C,w]=(0,V.useState)(void 0),[T,E]=(0,V.useState)(null),[D,O]=(0,V.useState)(null),[k,ee]=(0,V.useState)(null),[te,ne]=(0,V.useState)(null),A=h.find(e=>e.setting_gb===_)??null,re=h.length>0&&h[h.length-1].setting_gb===e.setting?.max_gb?h[h.length-1].setting_gb:null,ie=A&&e.total_gb!=null?Math.max(0,e.total_gb-A.gpu_gb):null,ae=g==null&&!d?(e.models??[]).find(e=>e.default&&e.fits_now):void 0,oe=(A?.unlocks??[]).slice(0,2).map(e=>r[e]??e),se=e.pending??null,ce=e.method===`apply`,le=e.guided_value!==null,ue=(0,V.useCallback)(async()=>{b(!0),S(null),O(`steps`),ee(null);try{let e=await f(_??void 0);w(e.guided_value),S(e.guided_value===null?[]:e.guided_steps??[])}catch(e){w(void 0),S([]),ee({kind:`error`,message:PG(e)})}finally{O(null)}},[_]),de=async()=>{if(_!=null){E(null),O(`apply`),ee(null);try{t(await l(_)),ee({kind:`applied`})}catch(e){let t=e instanceof Nt&&e.httpStatus===403;ee(t?{kind:`denied`}:{kind:`error`,message:PG(e)}),t&&p()}finally{O(null)}}},fe=async()=>{E(null),O(`revert`),ee(null);try{t(await st()),ee({kind:`applied`})}catch(e){ee(e instanceof Nt&&e.httpStatus===403?{kind:`denied`}:{kind:`error`,message:PG(e)})}finally{O(null)}},pe=async()=>{if(_!=null){O(`done`),ee(null);try{t(await bn(_)),b(!1)}catch(e){ee({kind:`error`,message:PG(e)})}finally{O(null)}}},me=async()=>{O(`keep`),ee(null);try{t(await j())}catch(e){ee({kind:`error`,message:PG(e)})}finally{O(null)}},he=async e=>{try{await navigator.clipboard.writeText(e),ne(e)}catch(e){ee({kind:`error`,message:u(`gpu.copyFailed`,{reason:PG(e)})})}},M=se?.state===`restart_required`;return z(`div`,{className:`gpu`,children:[I(`p`,{className:`setup-hint`,children:u(`gpu.body`,{total:BO(e.total_gb??0),gpu:BO(e.gpu_gb??0)})}),I(FG,{status:e,targetGpuGb:!M&&!y?A?.gpu_gb??null:null}),se?.state===`took_effect`&&z(`div`,{className:`gpu-notice is-ok`,role:`status`,children:[I(Vr,{size:14,"aria-hidden":`true`}),I(`span`,{children:u(`gpu.pending.tookEffect`,{gb:BO(e.gpu_gb??0)})}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void me(),disabled:D!==null,children:u(`gpu.ok`)})]}),M&&z(`div`,{className:`gpu-notice`,role:`status`,children:[I(ya,{size:14,"aria-hidden":`true`}),I(`span`,{children:u.compose(t=>[MG(t,jG(e,se.setting_gb),k?.kind===`applied`),t(`gpu.pending.restartHow`),n===`setup`?t(`gpu.pending.downloadsFirst`):null].filter(Boolean).join(` `))}),se.source===`guided`&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void me(),disabled:D!==null,children:u(`gpu.keep`,{gb:BO(e.gpu_gb??0)})})]}),se?.state===`not_applied`&&z(`div`,{className:`gpu-notice is-warn`,role:`status`,children:[I(ws,{size:14,"aria-hidden":`true`}),I(`span`,{children:u(`gpu.pending.notApplied`,{gb:BO(e.gpu_gb??0)})}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void me(),disabled:D!==null,children:u(`gpu.keep`,{gb:BO(e.gpu_gb??0)})})]}),!M&&!y&&h.length>0&&z(P.Fragment,{children:[ae&&z(`p`,{className:`gpu-unlock is-keep`,children:[I(Vr,{size:13,"aria-hidden":`true`}),` `,u(`gpu.keepRecommended`,{model:r[ae.id]??ae.id})]}),I(IG,{presets:h,value:_,onChange:v,recommended:g,max:re,keepGb:e.gpu_gb??null,disabled:D!==null}),A&&I(`p`,{className:`gpu-unlock`,children:oe.length>0?u(oe.length>1?`gpu.unlock.two`:`gpu.unlock.one`,{gb:BO(A.gpu_gb),a:oe[0],b:oe[1]??``}):u(`gpu.unlock.none`,{gb:BO(A.gpu_gb)})}),A&&A.setting_gb===re&&ie!=null&&z(`p`,{className:`gpu-unlock is-warn`,role:`note`,children:[I(ws,{size:13,"aria-hidden":`true`}),` `,u(`gpu.maxWarn`,{cpu:BO(ie),os:kG(e.os)})]}),I(`p`,{className:`setup-hint`,children:u.compose(t=>`${t(`gpu.reserve`,{gb:BO(e.reserve_gb??16),os:kG(e.os)})} ${t(`gpu.needs`)}`)}),!ce&&e.method_reason&&I(`p`,{className:`setup-hint`,children:I(`bdi`,{dir:`ltr`,children:e.method_reason})})]}),!M&&!y&&h.length===0&&I(`p`,{className:`setup-hint`,children:u(`gpu.noPresets`)}),y&&z(`div`,{className:`gpu-guided`,children:[A&&I(`p`,{className:`setup-hint`,id:m,children:u(`gpu.guided.lede`,{gb:BO(A.gpu_gb)})}),x===null?z(`p`,{className:`setup-hint`,role:`status`,children:[I(La,{size:13,className:`spin`,"aria-hidden":`true`}),` `,u(`gpu.guided.loading`)]}):C===null?I(`p`,{className:`setup-hint`,children:u(`gpu.noPresets`)}):I(`ol`,{className:`gpu-steps`,"aria-labelledby":m,children:x.map(e=>{let t=AG(e);return z(`li`,{children:[I(`span`,{children:e}),t&&z(`button`,{type:`button`,className:`btn-secondary gpu-copy`,onClick:()=>void he(t),"aria-label":u(`gpu.copyAria`,{what:t}),children:[I(te===t?Vr:hi,{size:12,"aria-hidden":`true`}),u(te===t?`gpu.copied`:`gpu.copy`)]})]},e)})}),z(DG,{children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>b(!1),disabled:D!==null,children:u(`gpu.guided.back`)}),!ce&&C!==null&&z(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void pe(),disabled:D!==null||_==null,children:[D===`done`&&I(La,{size:13,className:`spin`,"aria-hidden":`true`}),` `,u(`gpu.guided.done`)]})]})]}),D===`apply`||D===`revert`?z(`p`,{className:`setup-hint`,role:`status`,children:[I(La,{size:13,className:`spin`,"aria-hidden":`true`}),` `,u(`gpu.waiting`)]}):null,k?.kind===`denied`&&z(`div`,{className:`gpu-notice is-warn`,role:`alert`,children:[I(ws,{size:14,"aria-hidden":`true`}),I(`span`,{children:u(`gpu.denied`)})]}),k?.kind===`error`&&I(`p`,{className:`setup-error`,role:`alert`,children:k.message}),!y&&(()=>{let t=!M&&ce&&h.length>0&&I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>E(`apply`),disabled:D!==null||_==null,children:k?.kind===`denied`||se?.state===`not_applied`?u(`gpu.tryAgain`):u(`gpu.apply`)}),r=!M&&h.length>0&&le&&I(`button`,{type:`button`,className:ce?`btn-secondary`:`btn-primary`,onClick:()=>void ue(),disabled:D!==null||_==null,children:u(`gpu.showMe`)});return n===`setup`?z(DG,{children:[o&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:o,children:u(`setup.back`)}),M?a&&I(`button`,{type:`button`,className:`btn-primary`,onClick:a,autoFocus:!0,children:u(`setup.continue`)}):_==null&&h.length>0?(i??a)&&I(`button`,{type:`button`,className:`btn-primary`,onClick:i??a,disabled:D!==null,children:u(`gpu.keepAsIs`)}):z(P.Fragment,{children:[i&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:i,disabled:D!==null,children:u(`gpu.skip`)}),ce?z(P.Fragment,{children:[r,t]}):r]})]}):z(`div`,{className:`setup-row gpu-actions`,children:[t,r,e.revert?.available&&z(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>E(`revert`),disabled:D!==null,children:[I(Ro,{size:13,"aria-hidden":`true`}),` `,u(`gpu.undo`)]})]})})(),T===`apply`&&_!=null&&z(OG,{title:A?u(`gpu.consent.title`,{gb:BO(A.gpu_gb)}):u(`gpu.consent.titleAny`),confirmLabel:u(`setup.continue`),cancelLabel:u(`setup.cancel`),onConfirm:()=>void de(),onCancel:()=>E(null),children:[I(`p`,{children:A?u(`gpu.consent.body`,{name:e.setting?.name??``,gb:BO(A.gpu_gb)}):u(`gpu.consent.bodyAny`,{name:e.setting?.name??``})}),I(`p`,{className:`confirm-note`,children:u(`gpu.consent.saved`,{gb:BO(e.gpu_gb??0)})})]}),T===`revert`&&I(OG,{title:u(`gpu.revert.title`),confirmLabel:u(`setup.continue`),cancelLabel:u(`setup.cancel`),onConfirm:()=>void fe(),onCancel:()=>E(null),children:I(`p`,{children:u(`gpu.revert.body`)})})]})}function RG({plan:e,planError:t,onRetryPlan:n,onUseRecommended:r,selection:i,onSelection:a,cloud:o,keepTrying:s,onKeepTrying:c,onBack:l,onContinue:u,busy:d,error:f}){let p=R(),m=(0,V.useRef)(null),[h,g]=(0,V.useState)(!1),_=!!e&&!!i&&!!e.catalog,v=(0,V.useRef)(null);if(_&&v.current===null&&(v.current=!o&&$W(NW(e),i).length===0&&!!i.defaultChat&&NW(e).some(e=>e.downloaded)),(0,V.useEffect)(()=>{_&&m.current?.querySelector(`input:not([disabled])`)?.focus()},[_,h]),t&&!_)return z(`div`,{className:`setup-models-error`,children:[I(`p`,{className:`setup-error`,role:`alert`,children:p(`setup.models.listFailed`,{reason:t})}),z(`div`,{className:`setup-row`,children:[I(`button`,{type:`button`,className:`btn-primary`,onClick:n,children:p(`setup.tryAgain`)}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:r,children:p(`setup.models.useRecommended`)})]}),I(`p`,{className:`setup-hint`,children:p(`setup.models.useRecommendedNote`)})]});if(!_)return I(yG,{});let y=NW(e),b=$W(y,i),x=!o&&!i.defaultChat,S=tG(e,i),C=o?[]:y.filter(e=>e.fits===!1&&i.ticked.has(e.id)),w=!h&&!!v.current&&b.length===0,T=p(S?`setup.continueAnyway`:`setup.continue`);return w?z(`div`,{className:`setup-present`,role:`status`,children:[z(`p`,{children:[I(Vr,{size:14,"aria-hidden":`true`}),` `,p(`setup.models.allPresent`)]}),I(`button`,{type:`button`,className:`link-btn`,onClick:()=>g(!0),children:p(`setup.models.change`)}),z(DG,{children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:l,disabled:d,children:p(`setup.back`)}),z(`button`,{type:`button`,className:`btn-primary`,onClick:()=>u(!1),disabled:d,children:[d&&I(La,{size:13,className:`spin`,"aria-hidden":`true`}),` `,p(`setup.finish`)]})]}),f&&I(`p`,{className:`setup-error`,role:`alert`,children:f})]}):z(`div`,{className:`setup-models`,ref:m,children:[I(`p`,{className:`setup-hint`,children:p(`setup.job.lede`)}),I(CG,{plan:e,selection:i,onSelection:a,disabled:d}),!o&&I(`button`,{type:`button`,className:`link-btn setup-reset`,onClick:()=>a(QW(e)),disabled:d,children:p(`setup.models.resetRecommended`)}),z(`div`,{className:`setup-models-footer`,children:[I(hG,{plan:e,selection:i}),z(`label`,{className:`setup-keep-trying`,children:[I(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked),disabled:d}),I(`span`,{children:p(`setup.keepTrying`)})]}),I(MW,{open:x,children:I(`p`,{className:`setup-error`,id:`setup-no-chat`,children:p(`setup.models.noChatReason`)})}),C.length>0&&I(`span`,{className:`visually-hidden`,children:C.map(e=>fG(e,p)).join(` `)}),f&&I(`p`,{className:`setup-error`,role:`alert`,children:f}),z(DG,{children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:l,disabled:d,children:p(`setup.back`)}),z(`button`,{type:`button`,className:`btn-primary`,onClick:()=>u(!!S),disabled:d||x,"aria-describedby":x?`setup-no-chat`:void 0,children:[d&&I(La,{size:13,className:`spin`,"aria-hidden":`true`}),` `,T]})]})]})]})}function zG({plan:e,chatModel:t,gpu:n}){let r=R();if(!e?.catalog)return null;let i=e.catalog,a=e=>e?i.find(t=>t.id===e)?.name??e:null,o=BW(i,{ticked:new Set,unticked:new Set,chatChosen:!1,defaultChat:t,vision:e.vision_model??null}),s=i.find(e=>e.id===o)??i.find(e=>PW(e)&&e.gaia_model),c=i.find(e=>FW(e)&&e.downloaded),l=i.filter(e=>e.gaia_model&&e.planned&&e.skipped),u=n?.pending,d=i.find(e=>e.id===t);return z(`dl`,{className:`setup-summary-list`,children:[t&&z(`div`,{children:[I(`dt`,{children:r(`setup.ready.chat`)}),z(`dd`,{children:[I(`bdi`,{children:a(t)}),d?.recipe===`flm`?` (${r(`setup.models.npu`)})`:``]})]}),z(`div`,{children:[I(`dt`,{children:r(`setup.ready.vision`)}),I(`dd`,{children:s?.downloaded?I(`bdi`,{children:s.name}):r(`setup.ready.visionOff`,{name:s?.name??`Gemma-4-E4B-it`})})]}),c&&z(`div`,{children:[I(`dt`,{children:r(`setup.ready.documents`)}),I(`dd`,{children:I(`bdi`,{children:c.name})})]}),l.length>0&&z(`div`,{children:[I(`dt`,{children:r(`setup.ready.notInstalled`)}),I(`dd`,{children:l.map(e=>e.name).join(`, `)})]}),u?.state===`restart_required`&&z(`div`,{className:`is-warn`,children:[I(`dt`,{children:r(`setup.ready.gpu`)}),z(`dd`,{children:[I(ws,{size:13,"aria-hidden":`true`}),` `,MG(r,n?jG(n,u.setting_gb):null)]})]}),u?.state===`took_effect`&&z(`div`,{children:[I(`dt`,{children:r(`setup.ready.gpu`)}),I(`dd`,{children:n?.gpu_gb==null?r(`setup.ready.gpuChanged`):r(`setup.ready.gpuNow`,{gb:BO(n.gpu_gb)})})]})]})}function BG(e){if(e.skill===`document-brief`){let t=/^(\d+) /.exec(e.note)?.[1];return t?{n:Number(t)}:void 0}if(e.skill===`coding`){let t=/^In (.+)$/.exec(e.note)?.[1];return t?{folder:t}:void 0}}function VG(e,t,n,r){let i=`${n}.one`,a=`${n}.other`,o=ae(i)&&ae(a)&&typeof r?.n==`number`?r.n===1?i:a:n;return!ae(o)||ne[o].includes(`{`)&&!r?t:gt(o,r)===t?e(o,r):t}function HG(e,t){return{title:VG(t,e.title,`card.${e.skill}.title`),note:VG(t,e.note,`card.${e.skill}.note`,BG(e))}}function UG({text:e}){let t=De(e);return t.length===1?I(P.Fragment,{children:e}):I(P.Fragment,{children:t.map((e,t)=>I(`span`,{className:`start-card-part`,children:e},t))})}function WG({cards:e,onPick:t,disabled:n}){let r=R();return e.length===0?null:I(`ul`,{className:`start-cards`,"aria-label":r(`newChat.cardsLabel`),children:e.map(e=>{let{title:i,note:a}=HG(e,r);return I(`li`,{children:z(`button`,{type:`button`,className:`start-card`,onClick:()=>t(e),disabled:n,title:e.needs_input?`${e.prompt}…`:e.prompt,children:[z(`span`,{className:`start-card-title`,children:[i,I(_r,{size:13,"aria-hidden":`true`})]}),I(`span`,{className:`start-card-note`,children:I(UG,{text:a})})]})},e.skill)})})}function GG(){let[e,t]=(0,V.useState)(null),[n,r]=(0,V.useState)([]),i=(0,V.useCallback)(()=>{Promise.resolve(cn()).then(e=>{t(e?.providers?.find(e=>e.id===`amd`)?.network??null),r(e?.providers??[])}).catch(e=>{console.warn(`[useGatewayNetwork] could not check the AMD gateway`,e),t(null)})},[]);return(0,V.useEffect)(i,[i]),{network:e,providers:n,recheck:i}}function KG(e,t,n){return t===`active`?n(`setup.contents.working`):t===`done`?n(`setup.contents.ready`):t===`failed`?n(`setup.contents.failed`):e.installed?n(`setup.contents.alreadyHere`):n(`setup.contents.waiting`)}function qG(e,t){return e==null?t(`setup.contents.sizeOnDownload`):BO(e)}function JG({state:e}){return e===`done`?I(Vr,{size:13,"aria-hidden":`true`}):e===`active`?I(La,{size:13,className:`spin`,"aria-hidden":`true`}):I(e===`failed`?Is:li,{size:13,"aria-hidden":`true`})}function YG({id:e,error:t,transient:n,onRetry:r,disabled:i}){let a=R(),o=a(`setup.component.${e}`);return z(`div`,{className:`setup-content-failure`,role:`alert`,children:[I(`p`,{children:a(n?`setup.contents.failedNetwork`:`setup.contents.failedOther`,{name:o})}),t&&z(`details`,{className:`dl-details`,children:[I(`summary`,{children:a(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:t})]}),r&&I(`button`,{type:`button`,className:`btn-primary`,onClick:r,disabled:i,"aria-label":a(`setup.contents.retryNamed`,{name:o}),children:a(`setup.progress.retry`)})]})}function XG({plan:e,run:t,models:n=[],onRetry:r,retryDisabled:i}){let a=R();return z(`ul`,{className:`setup-contents`,children:[(e.components??[]).map(e=>{let n=t?.components?.[e.id],o=t!=null&&t.state!==`running`&&t.state!==`verifying`,s=n===`active`&&o?void 0:n;return z(`li`,{className:`setup-content is-${s??(e.installed?`done`:`waiting`)}`,children:[I(`span`,{className:`setup-content-icon`,children:I(JG,{state:s??(e.installed?`done`:void 0)})}),z(`span`,{className:`setup-content-main`,children:[I(`span`,{className:`setup-content-name`,children:a(`setup.component.${e.id}`)}),I(`span`,{className:`setup-content-note`,children:a(`setup.component.${e.id}Note`)}),e.bundled?I(`span`,{className:`setup-content-from`,children:a(`setup.contents.bundled`)}):z(`span`,{className:`setup-content-from`,children:[a(`setup.contents.from`),` `,I(`bdi`,{dir:`ltr`,children:e.source})]})]}),z(`span`,{className:`setup-content-side`,children:[I(`bdi`,{dir:`ltr`,children:qG(e.size_gb,a)}),I(`span`,{children:KG(e,s,a)})]}),s===`failed`&&o&&!t?.problem&&I(YG,{id:e.id,error:t?.error,transient:t?.component_kinds?.[e.id]===`transient`,onRetry:r,disabled:i})]},e.id)}),n.map(e=>z(`li`,{className:`setup-content is-waiting`,children:[I(`span`,{className:`setup-content-icon`,children:I(JG,{state:void 0})}),z(`span`,{className:`setup-content-main`,children:[I(`span`,{className:`setup-content-name`,children:I(`bdi`,{children:e.name})}),I(`span`,{className:`setup-content-note`,children:e.roles.map(e=>a(`setup.purpose.${e}`)).join(` · `)}),e.source&&z(`span`,{className:`setup-content-from`,children:[a(`setup.contents.from`),` `,I(`bdi`,{dir:`ltr`,children:e.source})]})]}),I(`span`,{className:`setup-content-side`,children:I(`bdi`,{dir:`ltr`,children:qG(e.size_gb,a)})})]},e.id))]})}function ZG({lines:e,className:t,id:n}){let r=(0,V.useRef)(null),i=(0,V.useRef)(!0),a=e.join(`
|
|
208
|
+
`);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 QG=1e9,$G={downloading:0,verifying:1,failed:2,ready:3,unchecked:3,cancelled:4,queued:5,skipped:6};function eK(e){return e.roles.includes(`embedding`)?0:e.roles.includes(`chat`)?1:2}function tK(e){return[...e].filter(e=>e.state!==`skipped`).sort((e,t)=>$G[e.state]-$G[t.state]||eK(e)-eK(t))}var nK=/^\s*(Downloading:|Downloaded\b|\[[=\-\s>#]*\])/;function rK(e){return e.some(e=>e.trim()&&!nK.test(e))}var iK={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 aK(e){return e?e.state===`running`||e.state===`verifying`||!!e.models?.some(e=>e.state===`downloading`||e.state===`queued`||e.state===`verifying`):!1}function oK(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:WO(e.bytes_done),need:BO(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 sK({model:e,name:t,estimate:n,now:r,freeGb:i,onRetry:a,onResume:o,onSkip:s,onRestart:c,busy:l,retryLater:u,checking:d,checkingFor:f}){let p=R(),m=(0,V.useId)(),h=(0,V.useId)(),[g,_]=(0,V.useState)(!1),v=e.log??[],y=e.bytes_total>0?Math.min(100,e.bytes_done/e.bytes_total*100):e.state===`ready`?100:0,b=p(iK[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=KO(p.locale,e.bytes_total>0?`${WO(e.bytes_done)} / ${WO(e.bytes_total)}`:WO(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} · ${KO(p.locale,GO(e))} · ${qO(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?WO(e.bytes_total):``:e.state===`unchecked`?p(`setup.progress.unchecked`):e.state===`cancelled`?e.bytes_done>0?p(`setup.progress.keptPartial`,{done:WO(e.bytes_done)}):``:e.state===`queued`&&e.bytes_total?WO(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:WO(e.bytes_done),total:WO(e.bytes_total)}):null,n?.eta==null?null:JO(n.eta,t)].filter(Boolean).join(`, `)):b;return z(`li`,{className:`dl-row is-${e.state}${C?` is-live`:``}${S>=15?` is-stalled`:``}`,children:[z(`div`,{className:`dl-row-head`,children:[I(`span`,{className:`dl-icon`,"aria-hidden":`true`,children:e.state===`ready`||e.state===`unchecked`?I(Vr,{size:14}):e.state===`failed`?I(ri,{size:14}):e.state===`cancelled`?I(mo,{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`&&z(`bdi`,{className:`dl-pct`,children:[Math.floor(y),`%`]}),e.state!==`failed`&&rK(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(Yr,{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`&&rK(v)&&I(ZG,{lines:v,id:h,className:`dl-log`}),e.state===`failed`&&z(`div`,{className:`dl-fail`,children:[I(`p`,{className:`dl-error`,id:m,children:oK(e,t,i,p)}),(v.length>0||e.error)&&z(`details`,{className:`dl-details`,children:[I(`summary`,{children:p(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:v.length>0?v.join(`
|
|
209
|
+
`):e.error})]}),u?I(`p`,{className:`dl-detail`,children:p(`setup.progress.retryLater`)}):z(`div`,{className:`setup-row`,children:[a&&z(`button`,{type:`button`,className:`btn-primary`,disabled:l,onClick:()=>a(e.id,e.error_kind),"aria-describedby":m,children:[I(Bo,{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:z(`button`,{type:`button`,className:`btn-secondary`,disabled:l,onClick:c,children:[I(Bo,{size:13,"aria-hidden":`true`}),` `,p(`setup.progress.retry`)]})})]})}function cK({status:e,names:t,freeGb:n=null,onCancel:r,onRetry:i,onResume:a,onResumeAll:o,onSkip:s,onRestart:c,busy:l=!1,retryLater:u=!1,labelledBy:d}){let f=R(),p=AW(),m=(0,V.useMemo)(()=>tK(e.models??[]),[e.models]),h=(0,V.useRef)(new Map),g=(0,V.useRef)(new Map),_=(0,V.useRef)(new XO),v=(0,V.useRef)(!1),[y,b]=(0,V.useState)(()=>Date.now()),[x,S]=(0,V.useState)(!1),[C,w]=(0,V.useState)(null),T=i&&((e,t)=>{let n=m.find(t=>t.id===e);t===`verify`&&n?w(n):i(e,t)}),[E,D]=(0,V.useState)(``),[O,k]=(0,V.useState)(``),ee=(0,V.useRef)(null),te=e.state===`verifying`||e.state!==`running`&&m.some(e=>e.state===`verifying`),ne=(0,V.useRef)(new Map);(0,V.useEffect)(()=>{if(!p||!(m.some(e=>e.retrying_until)||te))return;let e=setInterval(()=>b(Date.now()),1e3);return()=>clearInterval(e)},[m,p,te]);let A=e.overall,{estimates:re,overallEstimate:ie}=(0,V.useMemo)(()=>{let e=Date.now(),t={};for(let n of m){if(n.state!==`downloading`){h.current.delete(n.id);continue}let r=h.current.get(n.id),i=n.downloaded_before_gb??null;r&&g.current.get(n.id)===i||(r=new XO,h.current.set(n.id,r),g.current.set(n.id,i)),t[n.id]=r.update(n.bytes_done,n.bytes_total,e)}let n=m.some(e=>e.state===`downloading`);n&&!v.current&&(_.current=new XO),v.current=n;let r=m.filter(e=>e.state===`downloading`||e.state===`queued`).reduce((e,t)=>e+Math.max(0,t.bytes_total-t.bytes_done),0);return{estimates:t,overallEstimate:n&&A?_.current.update(A.bytes_done,A.bytes_done+r,e):void 0}},[m,A]);(0,V.useEffect)(()=>{let e=new Map(m.map(e=>[e.id,e.state])),n=Math.floor((A?.percent??0)/25),r=ee.current;if(ee.current={states:e,quarter:n},!r)return;let i=[];for(let e of m){if(r.states.get(e.id)===e.state)continue;let n=t[e.id]??e.id;e.state===`failed`?k(f(`setup.progress.announceFailed`,{name:n})):i.push(f(`setup.progress.announceState`,{name:n,state:f(iK[e.state])}))}n>r.quarter&&n>0&&n<4&&i.push(f(`setup.progress.announceOverall`,{n:String(n*25)})),i.length&&D(i.join(`. `))},[m,A?.percent,t,f]);let ae=e=>{if(!te)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)},j=aK(e),oe=m.filter(e=>e.state===`cancelled`),se=A?.failed??m.filter(e=>e.state===`failed`).length,ce=A?.percent??0,le=()=>{(A?.bytes_done??0)>QG?S(!0):r?.()},ue=f.compose(e=>[e(`setup.progress.overallPct`,{n:String(ce)}),A&&A.bytes_total>0?e(`setup.progress.of`,{done:WO(A.bytes_done),total:WO(A.bytes_total)}):null,j&&ie?.speed?KO(f.locale,GO(ie.speed)):null,j?ie?.eta==null?e(`setup.progress.estimating`):e(`setup.progress.left`,{eta:qO(ie.eta,e)}):null,se>0?e(`setup.progress.failedCount`,{n:String(se)}):null].filter(Boolean).join(` · `));return z(`section`,{className:`dl${p?``:` is-paused`}`,"aria-labelledby":d,children:[z(`div`,{className:`dl-overall`,children:[I(`p`,{className:`dl-overall-line`,children:I(`bdi`,{children:ue})}),I(`div`,{className:`dl-track is-overall${m.some(e=>e.state===`downloading`)?` is-live`:``}`,role:`progressbar`,"aria-label":f(`setup.progress.overallLabel`),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":ce,"aria-valuetext":f(`setup.progress.percent`,{n:String(ce)}),children:I(`span`,{className:`dl-fill`,style:{inlineSize:`${ce}%`}})})]}),I(`ul`,{className:`dl-list`,children:m.map(e=>I(sK,{model:e,name:t[e.id]??e.id,estimate:re[e.id],now:y,freeGb:n,onRetry:T,onResume:j?void 0:a,onSkip:s,onRestart:c,busy:l,retryLater:u,checking:te,checkingFor:ae(e.id)},e.id))}),j&&I(`p`,{className:`setup-hint dl-controls`,children:f(`setup.progress.keepsGoing`)}),(j&&r||!j&&oe.length>0&&o)&&z(DG,{children:[j&&r&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:le,disabled:l,children:f(`setup.progress.cancel`)}),!j&&oe.length>0&&o&&I(`button`,{type:`button`,className:`btn-primary`,onClick:o,disabled:l,children:f(`setup.progress.resumeAll`)})]}),I(`span`,{className:`visually-hidden`,"aria-live":`polite`,children:E}),I(`span`,{className:`visually-hidden`,role:`alert`,children:O}),x&&I(OG,{title:f(`setup.progress.cancelTitle`),confirmLabel:f(`setup.progress.cancelConfirm`),cancelLabel:f(`setup.progress.cancelKeep`),onConfirm:()=>{S(!1),r?.()},onCancel:()=>S(!1),children:I(`p`,{children:f(`setup.progress.cancelBody`)})}),C&&I(OG,{title:f(`setup.redownload.title`,{name:t[C.id]??C.id}),confirmLabel:f(`setup.redownload.confirm`),cancelLabel:f(`setup.redownload.keep`),onConfirm:()=>{let e=C;w(null),i?.(e.id,`verify`)},onCancel:()=>w(null),children:I(`p`,{children:f(`setup.redownload.body`,{name:t[C.id]??C.id,size:WO(C.bytes_total)})})})]})}function lK({run:e,plan:t,idle:n,bar:r=!0}){let i=R(),a=t?.components??[],o=a.find(t=>e.components?.[t.id]===`active`),s=a.filter(t=>e.components?.[t.id]===`done`||e.components?.[t.id]==null&&t.installed).length,c=e.percent==null?null:Math.max(0,Math.min(100,Math.round(e.percent))),l=o?i(`setup.download.now`,{name:i(`setup.component.${o.id}`)}):n;return z(`div`,{className:`setup-activity`,children:[z(`p`,{className:`setup-hint`,children:[I(La,{size:13,className:`spin`,"aria-hidden":`true`}),` `,I(`span`,{role:`status`,children:l}),c!=null&&z(P.Fragment,{children:[` · `,z(`bdi`,{dir:`ltr`,children:[c,`%`]})]}),a.length>0&&z(P.Fragment,{children:[` · `,i(`setup.download.partsReady`,{done:String(s),total:String(a.length)})]})]}),r&&c!=null&&I(`progress`,{className:`setup-progress`,max:100,value:c,"aria-label":l})]})}var uK=[`check`,`download`,`test`],dK={root:`setup-report`,button:`btn-secondary setup-report-button`,hint:`setup-hint`,error:`setup-error`},fK=/\d+(\.\d+)?\s*%/;function pK(e){let t=[],n=null;for(let r of e){let e=r.search(fK),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 mK({run:e,before:t={},failed:n=!1}){let r=R(),[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=>pK([...t[n]??[],...e?.logs?.[n]??[]]),u=uK.filter(e=>l(e).length>0);return z(`section`,{className:`setup-logs`,"aria-label":r(`setup.logs.title`),children:[z(`button`,{type:`button`,className:`setup-log-toggle setup-help-toggle`,onClick:()=>a(e=>!e),"aria-expanded":i,"aria-controls":`setup-help`,children:[I(Yr,{size:13,className:i?`is-open`:``,"aria-hidden":`true`}),` `,r(`setup.logs.help`)]}),i&&z(`div`,{id:`setup-help`,className:`setup-help`,children:[u.map(e=>{let t=l(e),n=o.has(e);return z(`div`,{className:`setup-log`,children:[z(`button`,{type:`button`,className:`setup-log-toggle`,onClick:()=>c(e),"aria-expanded":n,children:[I(Yr,{size:13,className:n?`is-open`:``,"aria-hidden":`true`}),` `,r(`setup.logs.${e}`)]}),n&&I(ZG,{lines:t,className:`setup-log-pre`})]},e)}),I(wN,{classes:dK,note:r(`setup.logs.reportNote`)})]})]})}function hK(){let e=R(),t=B(e=>e.locale),n=B(e=>e.setLocale);return z(`label`,{className:`setup-language`,children:[I(Ca,{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:ge.map(({meta:e})=>I(`option`,{value:e.code,lang:e.code,dir:e.dir,children:Fe(e)},e.code))})]})}var gK={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`]},_K={cancelled:`setup.npu.fixError.cancelled`,timeout:`setup.npu.fixError.timeout`,not_authorized:`setup.npu.fixError.notAuthorized`,no_pkexec:`setup.npu.fixError.noPkexec`};function vK({problem:e}){let t=R(),n=gK[e.code];if(!n)return z(`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`),z(`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 yK({problems:e,disabled:t,onRecheck:n,id:r=`setup-npu-problems`}){let i=R(),[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 Nt?e.body?.code:void 0,r=n&&n in _K?_K[n]:t;c(i(r))}finally{o(!1)}};return z(`div`,{className:`setup-npu-problems`,id:r,role:`note`,children:[I(`p`,{children:i(`setup.npu.notReady`)}),I(`ul`,{children:e.map(e=>I(vK,{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}),z(`div`,{className:`setup-npu-actions`,children:[l&&I(`button`,{type:`button`,className:`btn-primary`,disabled:t||a,onClick:()=>void u(Qn,`setup.npu.fixError.failed`),children:i(`setup.npu.fixMemlock`)}),n&&I(`button`,{type:`button`,className:`btn-secondary`,disabled:t||a,onClick:()=>void u(pe,`setup.npu.recheckFailed`),children:i(`setup.npu.recheck`)})]})]})}async function bK(){let e=await p();e.reachable&&(e.available_backends??[]).some(e=>e.name===`vulkan`)&&(e.preferred_backend??e.default_backend)!==`vulkan`&&await x(`vulkan`)}function xK({plan:e,selection:t,onSelection:n,disabled:r=!1,onRecheck:i}){let a=R(),o=NW(e),s=e.npu?.present&&!e.npu.ready?e.npu.problems:[],c=s.length?void 0:o.find(e=>IW(e)&&e.gaia_model&&e.chat_choice&&e.fits!==!1)??o.find(e=>IW(e)&&e.chat_choice&&e.downloaded&&!LW(e)),l=!s.length&&!c&&o.some(e=>IW(e)&&e.fit_code===`npu`),u=!!o.find(e=>e.id===t.defaultChat&&IW(e)),d=QW(e).defaultChat,f=d&&!o.find(e=>e.id===d&&IW(e))?d:o.find(e=>e.chat_choice&&e.gaia_model&&e.support===`verified`&&!IW(e))?.id,p=e=>{e===`npu`&&c&&!u&&n(HW(t,o,c.id)),e===`gpu`&&u&&f&&n(HW(t,o,f))},m=[{id:`gpu`,label:a(`setup.backend.gpu`)},...c?[{id:`npu`,label:a(`setup.backend.npu`)}]:[],...s.length?[{id:`npu`,label:a(`setup.backend.npu`),unavailable:!0}]:[]],h=u?`npu`:`gpu`;return z(`section`,{className:`setup-backend`,"aria-labelledby":`setup-backend-title`,children:[I(`h3`,{className:`mc-job-title`,id:`setup-backend-title`,children:a(`setup.backend.title`)}),I(Fz,{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(yK,{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 SK=({children:e})=>I(`bdi`,{dir:`ltr`,children:e});function CK({label:e,children:t}){return z(`div`,{className:`found-row`,children:[I(`dt`,{children:e}),I(`dd`,{children:t})]})}function wK(e){return e.family?`${e.name} (${e.family})`:e.name}var TK=[[`llamacpp`,`llama.cpp`],[`flm`,`FastFlowLM`],[`whispercpp`,`whisper.cpp`],[`kokoro`,`Kokoro`],[`sd-cpp`,`stable-diffusion.cpp`]],EK=new Set([`llamacpp`,`flm`]);function DK(e){let t=[];for(let[n,r]of TK){let i=(e.backends??[]).find(e=>e.recipe===n&&e.default);i&&i.state!==`unsupported`&&t.push({name:r,b:i})}return t}function OK(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 kK={release:`release`,release_candidate:`release candidate`,local:`local build`,source:`from source`};function AK(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=DK(e);return{sys:n,cpu:r(e=>e===`cpu`)[0],gpus:i,graphics:i.length?i.map(wK).join(`; `):t?.gpu_name??null,npus:a,runsOn:i[0]?.name??t?.gpu_name??null,npu:a[0]??null,runtimes:o,gaia:OK(n?.gaia_build,n?.gaia_version),build:n?.gaia_build?.kind??null,software:[OK(n?.gaia_build,n?.gaia_version)?`GAIA ${OK(n?.gaia_build,n?.gaia_version)}`:null,n?.lemonade_version?`Lemonade ${n.lemonade_version}`:null,...o.filter(({b:e})=>EK.has(e.recipe)&&MK(e)).map(({name:e,b:t})=>`${e} ${t.version??t.backend}`)].filter(e=>!!e),totalMemory:HO(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 jK={installed:`installed`,update_required:`installed, updates on first use`},MK=e=>e.state===`installed`||e.state===`update_required`,NK={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 PK(e,t){let n=AK(e,t),r=e.lemonade.mode===`external`?`the user's own`:`GAIA's own`;return[`GAIA: ${n.gaia??`unknown`}${n.build?`, ${kK[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}`:``} (${jK[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(wK).join(`; `)||`none found`}`,`Memory: ${n.totalMemory??`unknown`}${e.capacity_gb==null?``:`, ${BO(e.capacity_gb)} for models${e.memory_source?` (${e.memory_source})`:``}`}`,`Models folder: ${n.modelsPath??`unknown`}${n.freeGb==null?``:` (${BO(n.freeGb)} free)`}`,`GAIA data and logs: ${n.gaiaHome??`unknown`}`].join(`
|
|
210
|
+
`)}function FK({plan:e,hardware:t,onChangeMemory:n}){let r=R(),i=AK(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 $t(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 z(`section`,{className:`setup-card found`,"aria-label":r(`setup.found.title`),children:[z(`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(PK(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`?Vr:hi,{size:14,"aria-hidden":`true`})}),s&&I(`span`,{className:`found-copied`,role:`status`,children:r(s===`done`?`setup.found.copied`:`setup.found.copyFailed`)})]}),z(`dl`,{className:`found-glance`,children:[z(CK,{label:r(`setup.found.runsOn`),children:[i.runsOn?I(SK,{children:i.runsOn}):f,i.npu&&I(`span`,{className:`found-chip`,children:I(SK,{children:`NPU`})})]}),z(CK,{label:r(`setup.found.memory`),children:[e.capacity_gb!=null&&i.totalMemory?r(`setup.found.memoryOf`,{size:BO(e.capacity_gb),total:i.totalMemory}):e.capacity_gb==null?i.totalMemory?I(SK,{children:i.totalMemory}):f:I(SK,{children:BO(e.capacity_gb)}),n&&I(`button`,{type:`button`,className:`link-btn found-link`,onClick:n,children:r(`setup.found.changeMemory`)})]}),I(CK,{label:r(`setup.found.space`),children:i.freeGb==null?f:I(SK,{children:BO(i.freeGb)})}),z(CK,{label:r(`setup.found.software`),children:[i.software.length?I(SK,{children:i.software.join(` · `)}):f,i.build&&i.build!==`release`&&I(`span`,{className:`found-chip`,children:r(`setup.found.build.${i.build}`)})]})]}),z(`div`,{className:`found-paths`,children:[[[`setup.found.modelsFolder`,i.modelsPath],[`setup.found.gaiaFolder`,i.gaiaHome]].map(([e,t])=>t&&z(`button`,{type:`button`,className:`link-btn found-open`,onClick:()=>void d(t),title:t,children:[I($i,{size:13,"aria-hidden":`true`}),` `,r(e)]},e)),l&&I(`p`,{className:`setup-error`,role:`alert`,children:l})]}),p.length>0&&z(`details`,{className:`dl-details found-warnings`,children:[z(`summary`,{children:[I(ri,{size:13,"aria-hidden":`true`}),` `,r(`setup.found.noticed`)]}),I(`ul`,{children:p.map(e=>I(`li`,{children:I(SK,{children:e})},e))})]}),z(`button`,{type:`button`,className:`setup-log-toggle found-more`,onClick:()=>o(e=>!e),"aria-expanded":a,children:[I(Yr,{size:13,className:a?`is-open`:``,"aria-hidden":`true`}),` `,r(`setup.found.details`)]}),a&&z(`div`,{className:`found-details`,children:[I(`h4`,{className:`found-group`,children:r(`setup.found.software`)}),z(`dl`,{className:`found-list`,children:[z(CK,{label:I(SK,{children:`GAIA`}),children:[i.gaia?I(SK,{children:i.gaia}):f,i.build&&i.build!==`release`&&I(`span`,{className:`found-chip`,children:r(`setup.found.build.${i.build}`)})]}),I(CK,{label:r(`setup.found.agent`),children:i.sys?.agent_version?I(SK,{children:i.sys.agent_version}):I(`span`,{className:`found-muted`,children:r(`setup.found.agentLater`)})}),z(CK,{label:r(`setup.found.server`),children:[e.lemonade.mode===`external`?r(`setup.found.serverYours`):r(`setup.found.serverOwn`),i.sys?.lemonade_version&&z(P.Fragment,{children:[` `,I(SK,{children:i.sys.lemonade_version})]}),e.lemonade.url&&I(`span`,{className:`found-sub`,children:I(SK,{children:e.lemonade.url})})]})]}),I(`h4`,{className:`found-group`,children:r(`setup.found.runtime`)}),i.runtimes.length?I(`div`,{className:`found-table-wrap`,children:z(`table`,{className:`found-table`,children:[I(`thead`,{className:`visually-hidden`,children:z(`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})=>z(`tr`,{children:[I(`th`,{scope:`row`,children:I(SK,{children:e})}),I(`td`,{children:I(SK,{children:t.backend})}),I(`td`,{children:I(SK,{children:t.version??``})}),I(`td`,{className:MK(t)?`is-installed`:void 0,children:r(MK(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:z(`table`,{className:`found-table`,children:[I(`thead`,{className:`visually-hidden`,children:z(`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=>z(`tr`,{children:[I(`th`,{scope:`row`,title:e.id,children:I(`bdi`,{children:e.name})}),I(`td`,{children:e.roles.map(e=>r(NK[e])).join(` · `)}),z(`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(SK,{children:e.full_size_gb??e.size_gb?BO(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`)}),z(`dl`,{className:`found-list`,children:[I(CK,{label:r(`setup.found.os`),children:i.sys?.os??t?.os?I(SK,{children:i.sys?.os??t?.os}):f}),z(CK,{label:r(`setup.found.cpu`),children:[i.cpu||i.sys?.processor?I(SK,{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(CK,{label:r(`setup.found.gpu`),children:i.graphics?I(SK,{children:i.graphics}):I(`span`,{className:`found-muted`,children:r(`setup.found.none`)})}),I(CK,{label:r(`setup.found.npu`),children:i.npus.length?I(SK,{children:i.npus.map(wK).join(`; `)}):I(`span`,{className:`found-muted`,children:r(`setup.found.none`)})})]})]})]})}function IK({state:e}){return e===`done`?I(Vr,{size:13,"aria-hidden":`true`}):e===`active`?I(La,{size:13,className:`spin`,"aria-hidden":`true`}):I(e===`failed`?Is:e===`question`?ai:li,{size:13,"aria-hidden":`true`})}function LK({hardware:e,hardwareError:t,plan:n,serverRun:r,awaitingChoice:i=!1}){let a=R(),[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?HO(n?.system?.physical_memory,e?.ram_gb):null:BO(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:KO(a.locale,`${Math.round(e.disk_free_gb)} GB`)}),state:f},{id:`server`,label:a(`setup.checks.server`),value:c?d:i?a(`setup.checks.serverChoose`):null,state:c?`done`:l?`failed`:i?`question`:e?`active`:`waiting`},{id:`models`,label:a(`setup.checks.backends`),value:c&&n?.catalog?a(`setup.checks.backendsValue`,{models:String(n.catalog.length),downloaded:String(n.catalog.filter(e=>e.downloaded).length)}):null,state:c&&n?.catalog?`done`:c?`active`:`waiting`}],_=g.filter(e=>e.state===`done`).length,v=Math.round(_/g.length*100),y=I(`ul`,{className:`setup-rows`,id:`setup-check-rows`,children:g.map(e=>z(`li`,{className:`setup-result is-${e.state}`,children:[I(IK,{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?z(`section`,{className:`setup-card setup-checks-done`,"aria-label":a(`setup.check.title`),children:[I(`p`,{className:`setup-result is-done`,role:`status`,children:z(`button`,{type:`button`,className:`setup-checks-toggle`,"aria-expanded":o,"aria-controls":`setup-check-rows`,onClick:()=>s(e=>!e),children:[I(Vr,{size:13,"aria-hidden":`true`}),I(`span`,{className:`setup-result-label`,children:a(`setup.checks.allPassed`,{n:String(g.length)})}),I(Yr,{size:13,className:o?`is-open`:``,"aria-hidden":`true`})]})}),o&&y]}):z(`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`)}):z(P.Fragment,{children:[I(`span`,{children:a(`setup.checks.count`,{done:String(_),total:String(g.length)})}),z(`bdi`,{dir:`ltr`,children:[v,`%`]})]})}),I(`progress`,{className:`setup-progress`,max:100,value:v,"aria-label":a(`setup.check.title`)}),y]})}function RK({steps:e}){let t=R();return z(`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(Vr,{size:13,"aria-hidden":`true`}):e.status===`active`?I(La,{size:13,className:`spin`,"aria-hidden":`true`}):e.status===`failed`?I(ri,{size:13,"aria-hidden":`true`}):t+1,r=z(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 zK={memory:`setup.test.why.memory`,broken:`setup.test.why.broken`,stuck:`setup.test.why.stuck`,missing:`setup.test.why.missing`,agent:`setup.test.why.agent`,answer:`setup.test.why.answer`,window:`setup.test.why.window`};function BK(e,t){return t(`setup.test.job.${e}`)}function VK({state:e}){return e===`passed`?I(Vr,{size:13,"aria-hidden":`true`}):e===`running`?I(La,{size:13,className:`spin`,"aria-hidden":`true`}):I(e===`failed`?Is:e===`skipped`?Ya:li,{size:13,"aria-hidden":`true`})}function HK(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 UK({run:e,expected:t,names:n,catalog:r,onRetry:i,onChooseAnother:a,onCancel:o,onDownloadAgain:s,busy:c}){let l=R(),u=e.tests??[],d=new Set(u.map(e=>e.job)),f=t.filter(e=>!d.has(e)),p=u.filter(e=>e.state!==`running`).length,m=Math.max(u.length+f.length,1),h=Math.round(p/m*100),g=u.filter(e=>e.state===`failed`).filter(e=>!r.find(t=>t.id===e.subject)?.roles.some(e=>[`speech`,`voice`,`image_creation`].includes(e))),_=e.state===`failed`||e.state===`cancelled`,v=s?[...new Set(g.filter(e=>e.kind===`broken`&&e.subject).map(e=>e.subject))]:[],[y,b]=(0,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`),w=e.state===`verifying`&&!u.some(e=>e.state===`running`)?f[0]:void 0;return z(P.Fragment,{children:[z(`section`,{className:`setup-card`,"aria-label":l(`setup.test.title`),children:[z(`div`,{className:`setup-bar-head`,children:[I(`span`,{children:l(`setup.test.count`,{done:String(p),total:String(m)})}),z(`bdi`,{dir:`ltr`,children:[h,`%`]})]}),I(`progress`,{className:`setup-progress`,max:100,value:h,"aria-label":l(`setup.test.title`)}),z(`ul`,{className:`setup-rows`,children:[u.map(e=>z(`li`,{className:`setup-result is-${e.state}`,children:[I(VK,{state:e.state}),z(`span`,{className:`setup-result-label`,children:[BK(e.job,l),e.subject&&z(`bdi`,{className:`setup-result-model`,children:[` `,n[e.subject]??xc(e.subject)]})]}),I(`span`,{className:`setup-result-value`,children:HK(e,l)}),e.error&&z(`div`,{className:`setup-result-error`,children:[I(`p`,{children:l(e.kind===`broken`&&!s?`setup.test.why.brokenYours`:zK[e.kind??``]??`setup.test.why.other`)}),z(`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?z(`li`,{className:`setup-result is-failed`,children:[I(VK,{state:`failed`}),I(`span`,{className:`setup-result-label`,children:BK(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===w?z(`li`,{className:`setup-result is-running`,children:[I(VK,{state:`running`}),I(`span`,{className:`setup-result-label`,children:BK(e,l)}),I(`span`,{className:`setup-result-value`,children:l(`setup.test.starting`)})]},e):z(`li`,{className:`setup-result is-waiting`,children:[I(VK,{state:`waiting`}),I(`span`,{className:`setup-result-label`,children:BK(e,l)}),I(`span`,{className:`setup-result-value`,children:l(`setup.test.waiting`)})]},e))]})]}),e.state===`verifying`&&o&&I(DG,{children:I(`button`,{type:`button`,className:`btn-secondary`,onClick:o,disabled:c,children:l(`setup.progress.cancel`)})}),_&&z(`div`,{className:`setup-failure`,role:`alert`,children:[I(`p`,{children:e.state===`cancelled`?l(`setup.test.cancelled`):g.some(e=>e.kind===`memory`)?l(`setup.test.failedMemory`):l(`setup.test.failedHelp`)}),z(DG,{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?`btn-secondary`:`btn-primary`,onClick:i,disabled:c,children:l(`setup.test.tryAgain`)}),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(OG,{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?``:BO(x)})})})]})}var WK=`https://app.fireworks.ai/settings/users/api-keys`,GK=`https://amd-gaia.ai/docs/guides/llm-gateway`,KK=[{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 qK(e,t){return ae(e.title)?t(e.title):e.title}var JK=1e3,YK=`gaia-setup-choice`;function XK(){try{let e=localStorage.getItem(YK);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 ZK(e){try{localStorage.setItem(YK,e)}catch(e){console.warn(`[SetupScreen] could not save the provider choice; a reload will ask again`,e)}}var QK=[`ok`,`needs_key`,`too_old`];function $K({onChosen:e,onNothingToOffer:t,onFound:n,canInstallOwn:r=!0}){let i=R(),[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,w]=(0,V.useState)(null),[T,E]=(0,V.useState)(`gaia`),D=(0,V.useRef)(!0),O=(0,V.useCallback)(async()=>{c(null);try{let e=await Ce();if(!e.offer){t?.();return}f(!0);let{found:r,unchecked:i=[]}=await St();if(!D.current)return;u(r?[]:i),r&&QK.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 k=(0,V.useCallback)(async t=>{if(a){b(t),S(null);try{await Ue(t===`external`?{mode:t,base_url:a.found.url,api_key:p.trim()||void 0}:{mode:t}),m(``),w(t),e(t)}catch(e){TW(e)&&g(!0),S(e instanceof Error?e.message:String(e))}finally{b(null)}}},[a,p,e]);if(s||l.length>0)return z(P.Fragment,{children:[I(`p`,{className:`setup-hint`,children:s?i(`setup.offer.checkFailed`):i(`setup.offer.noAnswer`,{url:l.join(`, `)})}),s&&z(`details`,{className:`dl-details`,children:[I(`summary`,{children:i(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:s})]}),z(DG,{children:[z(`button`,{type:`button`,className:`btn-secondary`,disabled:d,onClick:()=>void O(),children:[d&&I(La,{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?z(`p`,{className:`setup-hint`,role:`status`,children:[I(La,{size:13,className:`spin`,"aria-hidden":`true`}),` `,i(`setup.offer.looking`)]}):null;let{target:ee,found:te}=a;return C?I(`p`,{className:`setup-hint`,role:`status`,children:C===`external`?i(`setup.offer.usingYours`,{url:te.url}):i(`setup.offer.usingOwn`)}):te.status===`too_old`?z(`p`,{className:`setup-hint`,role:`status`,children:[i(`setup.offer.tooOld`),` `,z(`bdi`,{dir:`ltr`,className:`setup-choice-note`,children:[`Lemonade `,te.version??``,` · `,te.url]})]}):z(`form`,{id:`setup-lemonade-form`,className:`setup-lemonade`,"aria-label":i(`setup.offer.label`),onSubmit:e=>{e.preventDefault(),k(T)},children:[z(`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=>z(`label`,{className:`setup-choice${T===e.mode?` is-active`:``}`,children:[I(`input`,{type:`radio`,name:`setup-server`,value:e.mode,checked:T===e.mode,onChange:()=>{E(e.mode),S(null)}}),z(`span`,{children:[z(`span`,{className:`setup-choice-title`,children:[i(e.title),e.mode===`gaia`&&I(`span`,{className:`setup-choice-tag`,children:i(`setup.offer.recommended`)})]}),I(`span`,{className:`setup-choice-note`,children:i(e.note)})]})]},e.mode))]}),z(`button`,{type:`button`,className:`setup-log-toggle setup-offer-more`,onClick:()=>v(e=>!e),"aria-expanded":_,"aria-controls":`setup-offer-detail`,children:[I(Yr,{size:13,className:_?`is-open`:``,"aria-hidden":`true`}),` `,i(`setup.offer.whatGaiaDoes`)]}),_&&z(`div`,{id:`setup-offer-detail`,children:[I(`p`,{className:`setup-choice-note`,children:z(`bdi`,{dir:`ltr`,children:[`Lemonade`,te.version?` ${te.version}`:``,` · `,te.url]})}),I(`p`,{className:`setup-choice-note`,children:i(`setup.offer.whatGaiaDoesText`)})]}),T===`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&&T===`external`?I(`p`,{className:`setup-error`,role:`alert`,children:i(`setup.offer.keyRejected`)}):I(tq,{text:x})),I(DG,{children:z(`button`,{type:`submit`,form:`setup-lemonade-form`,className:`btn-primary`,disabled:!!y||T===`external`&&h&&!p.trim(),children:[y&&I(La,{size:13,className:`spin`}),` `,i(`setup.continue`)]})})]})}function eq({problem:e,onRetry:t,onUseGaia:n}){let r=R(),i=e.kind===`server_too_old`&&e.use_gaia;return z(P.Fragment,{children:[e.start&&z(`details`,{className:`dl-details`,children:[I(`summary`,{children:r(`setup.server.howToStart`)}),I(`pre`,{dir:`ltr`,children:e.start})]}),z(DG,{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 tq({text:e}){let t=R();return z(`div`,{className:`setup-error`,role:`alert`,children:[I(`p`,{children:t(`setup.failedLead`)}),z(`details`,{className:`dl-details`,children:[I(`summary`,{children:t(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:e})]})]})}function nq({run:e}){let t=R();return e.problem?z(`div`,{className:`setup-error`,role:`alert`,children:[I(`p`,{children:t(e.problem.kind===`server_too_old`?`setup.server.tooOld`:`setup.server.unreachable`)}),z(`details`,{className:`dl-details`,children:[I(`summary`,{children:t(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:e.problem.message})]})]}):z(`div`,{className:`setup-error`,role:`alert`,children:[I(`p`,{children:t(e.components?.server===`failed`?`setup.server.ownFailed`:`setup.stopped`)}),e.error&&z(`details`,{className:`dl-details`,children:[I(`summary`,{children:t(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:e.error})]})]})}var rq=[`check`,`plan`,`key`,`models`,`gpu`,`download`,`test`,`ready`];function iq(e){return e instanceof Error?e.message:String(e)}function aq({onReady:e,onClose:t}){let n=R(),r=_c(e=>e.refresh),i=_c(e=>e.select),[a,o]=(0,V.useState)(`local`),[s,c]=(0,V.useState)(`check`),[l,u]=(0,V.useState)(!1),[d,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),[D,O]=(0,V.useState)(null),[k,te]=(0,V.useState)(null),[ne,A]=(0,V.useState)(``),[ie,ae]=(0,V.useState)({busy:!1,error:null,done:!1}),[j,oe]=(0,V.useState)(null),[se,ce]=(0,V.useState)(null),[ue,de]=(0,V.useState)(null),[fe,pe]=(0,V.useState)(null),[me,he]=(0,V.useState)(null),[M,ge]=(0,V.useState)(null),[_e,ve]=(0,V.useState)(!1),[ye,be]=(0,V.useState)(null),[xe,we]=(0,V.useState)(!1),[Te,Ee]=(0,V.useState)(!1),[De,Oe]=(0,V.useState)(null),[Ae,je]=(0,V.useState)(!1),[Me,Pe]=(0,V.useState)(null),[Fe,Ie]=(0,V.useState)(null),[Le,Re]=(0,V.useState)(null),[ze,Be]=(0,V.useState)(!1),[Ve,He]=(0,V.useState)([]),[Ue,We]=(0,V.useState)([]),[Ge,Ke]=(0,V.useState)([]),[Je,Ye]=(0,V.useState)(!1),[Xe,Ze]=(0,V.useState)(!1),Qe=(0,V.useRef)({gaiaLemonade:!1,options:{}}),$e=(0,V.useRef)(null),tt=(0,V.useRef)(!1),nt=(0,V.useRef)(!1),[rt,at]=(0,V.useState)(!1),[ot,st]=(0,V.useState)(!1),ct=(0,V.useCallback)(()=>st(!0),[]),[lt,ut]=(0,V.useState)(null),[ft,pt]=(0,V.useState)(null),mt=(0,V.useRef)(!0);(0,V.useEffect)(()=>(mt.current=!0,()=>{mt.current=!1}),[]);let{network:ht,providers:gt,recheck:_t}=GG(),vt=e=>gt.find(t=>t.id===e),yt=vt(a),bt=yt?.key_source===`environment`&&yt.key_hint?yt:void 0,xt=e=>!!vt(e)?.blocked,St=ht?.reachable!==!1||a===`amd`,Ct=yt?.key_source===`stored`||yt?.key_source===`lemonade`,wt=xt(`fireworks`)&&xt(`amd`),Tt=e=>xt(e)||e===`amd`&&ht?.reachable===!1,Et=e=>xt(e)?n(`settings.privacy.localOnlyBlocked`):n(`setup.key.gatewayOff`),Dt=a!==`local`,Ot=T?.server_only?T:null,kt=T&&!T.server_only?T:null,At=T?.state===`running`||T?.state===`verifying`,jt=kt?.state===`ready`,Mt=aK(T),Pt=!(kt?.models??[]).some(e=>e.state===`downloading`||e.state===`queued`)&&((kt?.tests?.length??0)>0||kt?.state===`verifying`),Ft=(0,V.useCallback)(()=>{w(null),re().then(S).catch(e=>w(iq(e)))},[]),It=(0,V.useRef)(0),Lt=(0,V.useCallback)(async()=>{let e=++It.current;ce(null);try{let t=await qe(!1);return e===It.current?(oe(t),t):null}catch(t){return e===It.current&&ce(iq(t)),null}},[]),Rt=(0,V.useCallback)(async()=>{try{let e=await f();mt.current&&ge(e??null)}catch(e){console.warn(`[SetupScreen] GPU memory could not be read; the step stays hidden`,e)}},[]),zt=t!=null;(0,V.useEffect)(()=>{Ce().then(e=>Ye(e.source===`config`)).catch(e=>console.warn(`[SetupScreen] could not read which Lemonade GAIA uses`,e)),Ft(),Lt(),et().then(e=>{e.state===`idle`&&!e.models?.length||zt&&e.state!==`running`&&e.state!==`verifying`||(E(e),e.server_only||c(`download`),e.skip_chat_model&&o(XK()===`amd`?`amd`:`fireworks`))}).catch(e=>te(iq(e))).finally(()=>at(!0))},[Ft,Lt,zt]),(0,V.useEffect)(()=>{j?.catalog&&j.lemonade.reachable&&(de(e=>e??JW(j)),Rt(),!T&&j.catalog.some(e=>e.partial&&e.selected)&&je(!0))},[j,Rt,T]);let Bt=(0,V.useCallback)(()=>{$e.current&&clearInterval($e.current),$e.current=null},[]),Vt=(T?.models??[]).filter(e=>e.state===`failed`&&e.error_kind===`disk_full`).length;(0,V.useEffect)(()=>{Vt>0&&Lt()},[Vt,Lt]);let Ht=(0,V.useCallback)(async()=>{try{let e=await et();if(O(null),e.state===`idle`&&!e.models?.length){E(null),c(`plan`),Ze(!0),Lt();return}E(e)}catch(e){O(iq(e))}},[Lt,n]);(0,V.useEffect)(()=>(!Mt&&!D||($e.current=setInterval(()=>{Ht()},JK)),Bt),[Mt,D,Ht,Bt]),(0,V.useEffect)(()=>{Ot&&Ot.state===`ready`&&(Ft(),Lt())},[Ot,Ot?.state,Ft,Lt]),(0,V.useEffect)(()=>{jt&&(Ft(),Lt().then(e=>{e&&he(e)}),Rt())},[jt,Ft,Lt,Rt]);let F=(0,V.useRef)(!1),Ut=(0,V.useCallback)(async(e=!1,t={})=>{if(F.current)return!1;F.current=!0,te(null),Oe(null),je(!1),Ze(!1);try{ZK(a),Qe.current={gaiaLemonade:e,options:t};let n=await Ne(Dt,e,t);E(n),_(null);let r=t.extraModels??[];return r.length&&Ke(e=>e.filter(e=>!r.includes(e))),t.serverOnly||c(`download`),e&&Ye(!1),!0}catch(e){let t=it(e);if(t)return be({kind:`server`,detail:t,then:`run`}),!1;if(e instanceof Nt&&e.httpStatus===409){let e=await et().catch(()=>null);if(e&&(e.state===`running`||e.state===`verifying`))return E(e),_(null),e.server_only||c(`download`),!0}return te(iq(e)),!1}finally{F.current=!1}},[a,Dt]);(0,V.useEffect)(()=>{s===`check`&&rt&&ot&&j&&!j.lemonade.reachable&&!T&&!tt.current&&(tt.current=!0,Ut(!1,{serverOnly:!0}))},[s,rt,ot,j,T,Ut]);let Wt=!!(ue&&j?.catalog&&j.lemonade.reachable&&(x||C)),Gt=(0,V.useCallback)(()=>{let{gaiaLemonade:e,options:t}=Qe.current;Ut(e,t)},[Ut]),Kt=(0,V.useCallback)((e,t=j)=>{pe(t);let n=t&&ue&&!Dt?iG(t,ue):[];return Ut(!1,{acknowledgeLowDisk:e,keepTrying:_e,extraModels:n})},[j,ue,Dt,_e,Ut]),[qt,Yt]=(0,V.useState)(!1),Xt=(0,V.useRef)(!1),Zt=(0,V.useCallback)(async(e,t=xe)=>{if(!j||!ue||Xt.current)return;Oe(null),Yt(e);let r=NW(j),i=Dt?[]:nG(r,ue).filter(e=>!e.downloaded||e.id===ue.defaultChat),a=i.find(LW);if(a){let e=a.id===ue.defaultChat?`setup.models.cantRun.chat`:`setup.models.cantRun.other`;Oe(n(e,{name:a.name,why:fG(a,n)}))}else if(!Dt&&!t&&i.length>0&&i.every(e=>e.need_gb!=null))be({kind:`no_fit`,models:i});else{Ee(!0),Xt.current=!0;try{let n=j;if(!Dt&&ue.defaultChat&&ue.defaultChat!==n.chat_model.id)try{n=await Se(ue.defaultChat,t,!1)}catch(e){let t=it(e);if(t){be({kind:`server`,detail:t,then:`chat`});return}throw e}if(!Dt){await bK();let e=WW(r,ue);e!==(n.vision_model??null)&&(n=await ke(e,!1));for(let e of rG(n,ue))n=await dt(e.id,e.skipped,!1)}oe(n),await Kt(e,n)}catch(e){Oe(iq(e))}finally{Xt.current=!1,Ee(!1)}}},[j,ue,Dt,xe,Kt,n]),Qt=(0,V.useCallback)(e=>{Oe(null),s===`download`?_(e===b.current?null:e):(_(null),c(e===`test`||e===`ready`?`download`:e))},[s]),L=(0,V.useCallback)(()=>{g??o(`local`),Qt(`plan`)},[Qt,g]),$t=(0,V.useCallback)(()=>{At&&g!=null||(o(`local`),u(!0),Qt(`models`))},[Qt,At,g]),[en,tn]=(0,V.useState)(`local`),nn=_c(e=>e.active?.remote&&e.active.provider!==`local`?e.active.provider:null),rn=_c(e=>e.active?.remote?e.active.model:null),an=(0,V.useCallback)(e=>{At&&g!=null||(u(!1),o(e),tn(`cloud`),Ie(e===nn?rn:null),Qt(`key`))},[Qt,At,g,nn,rn]),on=(0,V.useCallback)(()=>an(XK()===`amd`?`amd`:`fireworks`),[an]),sn=(0,V.useCallback)(()=>{nn?an(nn):Qt(`plan`)},[nn,an,Qt]),cn=!!M?.applies,ln=(0,V.useCallback)(()=>{Qt((g??s)===`gpu`?d:`plan`)},[d,Qt,g,s]),un=(0,V.useCallback)(e=>{p(e),Qt(`gpu`)},[Qt]),dn=(0,V.useRef)({prev:null,next:null});(0,V.useEffect)(()=>{let e=e=>{if(!e.altKey||ye||(e.target instanceof Element?e.target:null)?.closest(`input, textarea, select, [contenteditable="true"]`))return;let t=e.key===`ArrowLeft`?dn.current.prev:e.key===`ArrowRight`?dn.current.next:null;t&&(e.preventDefault(),Qt(t))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[Qt,ye]);let fn=(0,V.useCallback)(async()=>{try{await Jt(),await Ht()}catch(e){Oe(iq(e))}},[Ht]),pn=(0,V.useCallback)(async(e,t)=>{Oe(null),Ee(!0);try{t===`verify`&&await le(e),t===`disk_full`&&Lt();try{E(await N(e,{keepTrying:_e}))}catch(t){let n=it(t);if(!n)throw t;be({kind:`server`,detail:n,then:`retry`,id:e})}}catch(e){Oe(iq(e))}finally{Ee(!1)}},[_e,Lt]),mn=(0,V.useCallback)(async e=>{Oe(null),Ee(!0);try{j?.catalog?.find(t=>t.id===e)?.planned&&oe(await dt(e,!0,!1)),E(t=>t&&{...t,models:t.models?.map(t=>t.id===e?{...t,state:`skipped`}:t)});let{options:t}=Qe.current;Qe.current.options={...t,extraModels:t.extraModels?.filter(t=>t!==e)},de(t=>t&&t.ticked.has(e)?XW(t,NW(j),e,!1):t)}catch(e){Oe(iq(e))}finally{Ee(!1)}},[j]),hn=(0,V.useCallback)(async()=>{await fn(),Gt()},[fn,Gt]),gn=(0,V.useCallback)(async()=>{if(!At){ae({busy:!0,error:null,done:!1});try{await _n(a,{api_key:!Je&&ne||void 0},e=>ae({busy:!0,error:null,done:!1,waiting:e}),()=>!mt.current);let{models:e}=await Nn(a),t=Fe??Le,r=t?e.find(e=>e.id===t):e.find(e=>e.rank===1)??e[0];if(!r)throw Error(t?n(`setup.key.modelNotOffered`,{model:Oc(t)}):n(`setup.key.noModels`));await i(r.id),Pe(r.id),A(``),ae({busy:!1,error:null,done:!0}),Kt(!1)}catch(e){ae({busy:!1,error:iq(e),done:!1})}}},[a,ne,Fe,Le,i,Je,Kt,n,At]),vn=(0,V.useCallback)(e=>{ZK(e),o(e),Ie(e===nn?rn:null),Re(null),ae({busy:!1,error:null,done:!1})},[nn,rn]);(0,V.useEffect)(()=>{if(!jt||Ue.length===0||nt.current)return;let e=Ue;nt.current=!0,Ut(!1,{keepTrying:_e,extraModels:e}).then(t=>{nt.current=!1,We(t=>t.filter(t=>!e.includes(t))),t||Ke(t=>[...t,...e.filter(e=>!t.includes(e))])})},[jt,Ue,_e,Ut]);let yn=jt&&Ue.length===0,bn=Dt?Me:kt?.chat_model??(j&&!j.decided_after_server?j.chat_model.id:null),xn=(0,V.useCallback)(async t=>{Oe(null);try{!Dt&&bn&&await i(bn),await r()}catch(e){Oe(iq(e));return}e(t)},[bn,Dt,e,r,i]);(0,V.useEffect)(()=>{yn&&ee().then(e=>He(e.cards)).catch(e=>console.warn(`[SetupScreen] no first tasks to offer`,e))},[yn]);let Sn=(0,V.useMemo)(()=>{let e={};for(let t of j?.catalog??[])e[t.id]=t.name;return e},[j]),Cn=T?.state===`failed`||T?.state===`cancelled`,wn=T?.state===`failed`||!!k||!!se||!!C||!!D||!!De,Tn=zt?Ve:Ve.filter(e=>e.skill!==`check-in`),En=kt&&(kt.state===`failed`||kt.state===`cancelled`)&&(kt.models??[]).length>0&&(kt.models??[]).every(e=>e.state===`ready`||e.state===`skipped`||e.state===`verifying`||e.state===`unchecked`)&&!Mt,Dn=!!kt&&Cn&&!kt.problem&&Object.values(kt.components??{}).includes(`failed`),On=NW(j),kn=ue?$W(On,ue):[],An=j&&ue?tG(j,ue):null,jn=ue?On.filter(e=>ue.ticked.has(e.id)&&e.downloaded).length:0,Mn=On.some(e=>e.downloaded),Pn=Wt?jn===0?Mn?`setup.check.ledeOthersOnPc`:`setup.check.ledeDone`:kn.length===0?`setup.check.ledeAllOnPc`:`setup.check.ledeSomeOnPc`:`setup.check.lede`,Fn=On.find(e=>e.id===ue?.defaultChat),In=!!x&&!x.compatible&&x.blockers.length>0,Ln=yn?`ready`:s===`download`&&Pt?`test`:s;b.current=Ln;let Rn=g??Ln;(0,V.useEffect)(()=>{y(e=>e.has(Rn)?e:new Set(e).add(Rn))},[Rn]);let zn=(0,V.useRef)(!0);(0,V.useEffect)(()=>{if(zn.current){zn.current=!1;return}let e=document.querySelector(`.setup-scroll`);e&&(e.scrollTop=0),document.getElementById(`setup-title`)?.focus({preventScroll:!0})},[Rn]);let Bn=[{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`}],Vn=e=>e===`models`||e===`key`?`plan`:e===`gpu`?d===`check`?`check`:`plan`:e,Hn=Dt?`key`:l?`models`:`plan`,Un=Bn.findIndex(e=>e.id===Vn(Ln)),Wn=e=>e===`download`||e===`test`||e===`ready`,Gn=[];if(x){let e=[j?.system?.physical_memory?`${HO(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`;Gn.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&&Gn.push(`Couldn't read this PC: ${C}`);lt&&(Gn.push(`Found your Lemonade${lt.version?` ${lt.version}`:``} at ${lt.url}`),Gn.push(ft===`external`?`You chose your own Lemonade`:ft===`gaia`?`You chose GAIA's own Lemonade`:`Waiting for you to choose which Lemonade GAIA uses`)),j&&(!lt||ft)?Gn.push(j.lemonade.reachable?`Model server answering at ${j.lemonade.url??`its address`}`:`No model server answering yet`):se&&Gn.push(`Couldn't read the model list: ${se}`);let Kn=(e,t)=>t<=Un||v.has(e)&&!Wn(e),qn=Bn.map((e,t)=>({id:e.id,label:e.label,status:t<Un?`done`:t>Un?`pending`:Ln===`ready`?`done`:Cn&&(Ln===`download`||Ln===`test`||Ln===`check`)?`failed`:At&&(Ln===`download`||Ln===`test`)?`active`:`current`,shown:e.id===Vn(Rn),onOpen:e.id!==Vn(Rn)&&Kn(e.id,t)?()=>Qt(e.id===`plan`?Hn:e.id):void 0})),B=Bn.findIndex(e=>e.id===Vn(Rn)),Jn=Rn===`gpu`&&d===`check`?.5:rq.indexOf(Rn),Yn=(0,V.useRef)(Jn),Xn=(0,V.useRef)(`forward`);Yn.current!==Jn&&(Xn.current=Jn>Yn.current?`forward`:`back`,Yn.current=Jn);let Zn=Rn===`gpu`?d:Rn===`models`||Rn===`key`?`plan`:B>0?Bn[B-1].id===`plan`?Hn:Bn[B-1].id:null,Qn=(Rn!==`gpu`&&B>=0&&B<Bn.length-1&&Kn(Bn[B+1].id,B+1)?Bn[B+1].id:null)??(g==null?Rn===`check`&&Wt?`plan`:Rn===`gpu`?d:null:null);dn.current={prev:Zn,next:Qn};let $n=Rn===`gpu`||Rn===`models`||Rn===`key`,er=g!=null&&At,tr=[`server`];Dt||tr.push(`chat`),!Dt&&ue&&BW(On,ue)&&tr.push(`vision`),ue&&On.some(e=>FW(e)&&ue.ticked.has(e.id))&&tr.push(`embedding`);for(let e of On)ue&&RW(e)&&ue.ticked.has(e.id)&&!e.downloaded&&tr.push(e.roles[0]);tr.push(`agent`);let nr=Dt&&ie.done&&Me?z(`p`,{className:`setup-ok setup-key-accepted`,role:`status`,children:[I(Vr,{size:14,"aria-hidden":`true`}),` `,n(`setup.key.accepted`,{model:Oc(Me)})]}):null,rr=ue&&!Dt?On.filter(e=>RW(e)&&!ue.ticked.has(e.id)&&!e.downloaded&&(zW(Fn)||!e.roles.includes(`image_creation`))):[],ir=On.find(e=>e.fit_code===`memory`&&e.chat_choice&&e.support===`verified`);return z(`main`,{className:`setup`,"aria-labelledby":`setup-title`,children:[I(RK,{steps:qn}),I(EG,{value:m,children:z(`div`,{className:`setup-pane`,children:[I(`div`,{className:`setup-scroll`,children:z(`div`,{className:`setup-inner`,children:[B>=0&&z(`nav`,{className:`setup-topnav`,"aria-label":n(`setup.nav.label`),children:[I(`button`,{type:`button`,className:`setup-arrow`,onClick:()=>Zn&&Qt(Zn),disabled:!Zn,"aria-label":n(`setup.nav.prev`),children:I(qr,{size:16,"aria-hidden":`true`})}),I(`button`,{type:`button`,className:`setup-arrow`,onClick:()=>Qn&&Qt(Qn),disabled:!Qn,"aria-label":n(`setup.nav.next`),children:I(Yr,{size:16,"aria-hidden":`true`})}),I(`span`,{children:I(`bdi`,{children:n(`setup.nav.stepOf`,{n:String(B+1),total:String(Bn.length)})})}),g!=null&&g!==Ln&&I(`button`,{type:`button`,className:`link-btn`,onClick:()=>_(null),children:n.compose(e=>e(`setup.nav.toLive`,{step:e(Bn.find(e=>e.id===Ln)?.key??`setup.download.step`)}))}),I(hK,{})]}),Ae&&s!==`download`&&z(`div`,{className:`setup-banner`,role:`status`,children:[I(ya,{size:14,"aria-hidden":`true`}),I(`span`,{children:n(`setup.resume.banner`)})]}),Xe&&s!==`download`&&I(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.interrupted`)}),z(`div`,{className:`setup-stage is-${Xn.current}`,children:[Rn===`check`&&z(P.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(Wt?`setup.check.headingDone`:`setup.check.heading`)}),I(`p`,{className:`setup-lede`,children:n(Pn)}),I(LK,{hardware:x,hardwareError:C,plan:j,serverRun:Ot,awaitingChoice:!!lt&&!ot}),Ot?.state===`running`&&z(P.Fragment,{children:[I(lK,{run:Ot,idle:n(`setup.check.serverWorking`),bar:!1}),I(DG,{children:I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void fn(),children:n(`setup.progress.cancel`)})})]}),Wt&&j&&I(FK,{plan:j,hardware:x,onChangeMemory:cn&&g==null?()=>un(`check`):void 0}),Wt&&g==null&&!(lt&&!ot)&&I(DG,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:sn,children:n(`setup.continue`)})}),Ot&&Cn&&z(P.Fragment,{children:[I(nq,{run:Ot}),Ot.problem?I(eq,{problem:Ot.problem,onRetry:()=>void Ut(!1,{serverOnly:!0}),onUseGaia:()=>void Ut(!0,{serverOnly:!0})}):I(DG,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Ut(!!Ot.gaia_lemonade,{serverOnly:!0}),children:n(`setup.tryAgain`)})})]}),se&&!j&&z(P.Fragment,{children:[I(tq,{text:se}),z(DG,{children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void Ut(!1,{keepTrying:_e}),children:n(`setup.models.useRecommended`)}),I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Lt(),children:n(`setup.tryAgain`)})]}),I(`p`,{className:`setup-hint`,children:n(`setup.models.useRecommendedNote`)})]}),k&&I(tq,{text:k}),k&&!Ot&&j&&!j.lemonade.reachable&&I(DG,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Ut(!1,{serverOnly:!0}),children:n(`setup.tryAgain`)})}),rt&&j&&(!j.lemonade.reachable&&!Ot||Wt&&g==null&&j.lemonade.mode!==`external`)&&I($K,{onNothingToOffer:ct,canInstallOwn:!j.lemonade.reachable&&!Ot,onFound:ut,onChosen:e=>{Ye(e===`external`),pt(e),st(!0),Ft(),Lt()}})]}),Rn===`plan`&&j&&ue&&z(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`)}),z(`div`,{className:`setup-where`,children:[z(`section`,{className:`setup-hero setup-where-card${en===`local`?` is-active`:``}`,"aria-label":n(`setup.plan.label`),onClick:()=>!er&&tn(`local`),children:[I(`p`,{className:`setup-eyebrow`,children:ue.chatChosen?n(`setup.plan.yours`):n(`setup.plan.recommended`)}),z(`p`,{className:`setup-hero-title`,children:[I(`input`,{type:`radio`,name:`setup-where`,checked:en===`local`,onChange:()=>tn(`local`),disabled:er,"aria-labelledby":`setup-where-local`}),I(`bdi`,{id:`setup-where-local`,children:n(`setup.plan.run`,{name:Fn?.name??``})})]}),z(`dl`,{className:`setup-facts`,children:[z(`div`,{children:[I(`dt`,{children:n(`setup.summary.download`)}),I(`dd`,{children:I(`bdi`,{dir:`ltr`,children:BO(eG(j,ue).downloadGb??0)})})]}),z(`div`,{children:[I(`dt`,{children:n(`setup.plan.runsOn`)}),I(`dd`,{children:I(`bdi`,{children:Fn&&IW(Fn)?n(`setup.checks.npu`):x?.gpu_name??n(`setup.plan.cpu`)})})]}),z(`div`,{children:[I(`dt`,{children:n(`setup.plan.diskAfter`)}),I(`dd`,{children:I(`bdi`,{dir:`ltr`,children:eG(j,ue).afterGb==null?`—`:BO(Math.max(0,eG(j,ue).afterGb))})})]})]}),z(`ul`,{className:`setup-reasons`,children:[!ue.chatChosen&&I(`li`,{children:n(`setup.plan.why.evaluated`)}),Fn?.need_gb!=null&&Fn.capacity_gb!=null&&Fn.fits&&I(`li`,{children:n(`setup.plan.why.fits`,{need:UO(Fn.need_gb),have:UO(Fn.capacity_gb)})}),I(`li`,{children:n(`setup.plan.why.private`)}),Fn&&IW(Fn)&&I(`li`,{children:n(`setup.plan.why.noImagesNpu`)}),ir&&ir.id!==Fn?.id&&ir.need_gb!=null&&ir.capacity_gb!=null&&I(`li`,{children:n(`setup.plan.why.bigger`,{name:ir.name,need:UO(ir.need_gb),have:UO(ir.capacity_gb)})})]}),kn.length>0&&I(`p`,{className:`setup-hint`,children:n(`setup.plan.cancelAnytime`)})]}),z(`section`,{className:`setup-hero setup-where-card${en===`cloud`?` is-active`:``}${wt?` is-disabled`:``}`,"aria-label":n(`setup.plan.cloudLabel`),onClick:()=>!er&&!wt&&tn(`cloud`),children:[z(`p`,{className:`setup-hero-title`,children:[I(`input`,{type:`radio`,name:`setup-where`,checked:en===`cloud`,onChange:()=>tn(`cloud`),disabled:er||wt,"aria-labelledby":`setup-where-cloud`}),I(`span`,{id:`setup-where-cloud`,children:n(`setup.plan.cloud`)})]}),wt?I(`p`,{className:`setup-hint`,children:n(`settings.privacy.localOnlyBlocked`)}):z(`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`)})]})]})]}),z(DG,{children:[en!==`cloud`&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:$t,disabled:Te||er,children:n(`setup.plan.customize`)}),en===`cloud`?I(`button`,{type:`button`,className:`btn-primary`,onClick:on,disabled:er,children:n(`setup.continue`)}):z(`button`,{type:`button`,className:`btn-primary`,onClick:()=>An?be({kind:`low_disk`}):void Zt(!1),disabled:Te||In||er,children:[Te&&I(La,{size:13,className:`spin`,"aria-hidden":`true`}),` `,kn.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`)})}),In&&z(`div`,{className:`setup-error`,role:`alert`,children:[I(`p`,{children:n(`setup.blocked`)}),z(`details`,{className:`dl-details`,children:[I(`summary`,{children:n(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:x?.blockers.join(`
|
|
211
|
+
`)})]})]}),An&&I(`p`,{className:`setup-error`,role:`alert`,children:n(`setup.summary.short`,{need:BO(An.needGb),free:BO(An.freeGb),drive:n(`setup.summary.theDrive`),freeUp:BO(An.freeUpGb)})}),(De??k)&&I(tq,{text:De??k}),en!==`cloud`&&z(`details`,{className:`setup-disclosure`,children:[I(`summary`,{children:n(`setup.plan.whatDownloads`)}),I(XG,{plan:j,models:kn})]})]}),Rn===`gpu`&&M&&z(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(LG,{status:M,onStatus:ge,mode:`setup`,headingId:`setup-title`,names:Sn,cloud:a!==`local`,onBack:ln,onSkip:()=>Qt(d),onContinue:()=>Qt(d)})]}),Rn===`models`&&z(P.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.models.title`)}),j&&ue&&I(xK,{plan:j,selection:ue,onSelection:de,disabled:Te||er,onRecheck:()=>void Lt()}),cn&&M?.total_gb!=null&&M.gpu_gb!=null&&z(`p`,{className:`setup-hint setup-gpu-option`,children:[n(`setup.models.gpu`,{gpu:BO(M.gpu_gb),total:BO(M.total_gb)}),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>un(`models`),disabled:Te||er,children:n(`setup.found.changeMemory`)})]}),I(RG,{plan:j,planError:se,onRetryPlan:()=>void Lt(),onUseRecommended:()=>void Ut(!1,{keepTrying:_e}),selection:ue,onSelection:de,cloud:!1,keepTrying:_e,onKeepTrying:ve,onBack:ln,onContinue:e=>void Zt(e),busy:Te||er,error:De??k})]}),Rn===`key`&&z(`form`,{id:`setup-key-form`,onSubmit:e=>{e.preventDefault(),gn()},className:`setup-form`,children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.key.title`)}),I(Fz,{className:`setup-choices`,"aria-label":n(`setup.key.provider`),children:KK.filter(e=>e.id!==`local`&&(e.id!==`amd`||St)).map(e=>z(`button`,{type:`button`,role:`radio`,"aria-checked":a===e.id,className:`setup-choice${a===e.id?` is-active`:``}${Tt(e.id)?` is-disabled`:``}`,onClick:()=>vn(e.id),disabled:ie.busy||Tt(e.id),title:xt(e.id)?n(`settings.privacy.localOnlyBlocked`):void 0,children:[I(pi,{size:16,"aria-hidden":`true`}),z(`span`,{children:[I(`span`,{className:`setup-choice-title`,children:I(`bdi`,{children:qK(e,n)})}),I(`span`,{className:`setup-choice-note`,children:Tt(e.id)?Et(e.id):n(e.note)})]})]},e.id))}),ht?.reachable===!1&&St&&I(`button`,{type:`button`,className:`link-btn setup-start`,onClick:_t,children:n(`setup.key.checkAgain`)}),xt(a)&&I(`p`,{className:`setup-a11y-alert`,role:`alert`,children:n(`settings.privacy.localOnlyBlocked`)}),a===`fireworks`&&!Je&&!xt(a)&&z(`section`,{className:`setup-card`,children:[I(`h3`,{className:`mc-job-title`,children:n(`setup.key.getOne`)}),z(`ol`,{className:`setup-key-steps`,children:[I(`li`,{children:I(`a`,{href:WK,target:`_blank`,rel:`noreferrer`,children:n(`setup.key.step1`)})}),I(`li`,{children:n(`setup.key.step2`)}),I(`li`,{children:n(`setup.key.step3`)})]})]}),a===`amd`&&!Je&&!xt(a)&&I(`section`,{className:`setup-card`,children:I(`p`,{className:`setup-hint`,children:I(`a`,{href:GK,target:`_blank`,rel:`noreferrer`,children:n(`setup.key.gatewayHelp`)})})}),!xt(a)&&I(EW,{provider:a,limit:3,picked:Fe,onPick:Ie,onDefault:Re,pickDisabled:ie.busy||er}),!Je&&z(P.Fragment,{children:[I(`label`,{className:`setup-key-label`,htmlFor:`setup-key-input`,children:n(`setup.key.labelFor`,{provider:qK(KK.find(e=>e.id===a)??KK[1],n)})}),z(`div`,{className:`setup-row setup-key-row`,children:[I(`input`,{id:`setup-key-input`,className:`settings-input`,type:ze?`text`:`password`,autoComplete:`off`,spellCheck:!1,value:ne,onChange:e=>A(e.target.value),placeholder:Ct?n.bare(`setup.key.placeholder`):n.bare(`setup.key.placeholderNew`)}),I(`button`,{type:`button`,className:`btn-secondary setup-key-show`,"aria-label":n(ze?`setup.key.hide`:`setup.key.show`),title:n(ze?`setup.key.hide`:`setup.key.show`),onClick:()=>Be(e=>!e),children:I(ze?Ni:Fi,{size:14,"aria-hidden":`true`})})]})]}),I(`p`,{className:`setup-hint`,children:n(Je?`setup.key.usersServer`:`setup.key.where`)}),bt&&!Je&&!ne&&I(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.key.foundEnv`,{name:bt.name,hint:bt.key_hint??``})}),ie.busy&&!ie.waiting&&I(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.key.testing`)}),ie.busy&&ie.waiting&&I(`p`,{className:`setup-hint`,role:`status`,children:ie.waiting}),ie.error&&I(`p`,{className:`setup-error`,role:`alert`,children:ie.error}),z(DG,{children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:L,disabled:ie.busy,children:n(`setup.back`)}),z(`button`,{type:`submit`,form:`setup-key-form`,className:`btn-primary`,disabled:ie.busy||Tt(a)||er,children:[ie.busy&&I(La,{size:13,className:`spin`}),` `,n(`setup.key.connect`)]})]})]}),Rn===`download`&&!kt&&z(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`)}),nr,z(`p`,{className:`setup-hint`,role:`status`,children:[I(La,{size:13,className:`spin`,"aria-hidden":`true`}),` `,n(`setup.download.starting`)]})]}),Rn===`download`&&kt&&z(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`)}),nr,j&&I(`section`,{className:`setup-card`,"aria-label":n(`setup.contents.title`),children:I(XG,{plan:j,run:kt,onRetry:Gt,retryDisabled:Te})}),(kt.models?.length??0)>0?I(`div`,{className:D?`is-stale`:void 0,children:I(cK,{status:{...kt,overall:aG(kt,fe??j)},names:Sn,freeGb:j?.disk?.free_gb??null,onCancel:()=>void fn(),onRetry:(e,t)=>void pn(e,t),onResume:e=>void pn(e,null),onResumeAll:Gt,onSkip:e=>void mn(e),onRestart:()=>void hn(),busy:Te||!!D,retryLater:At,labelledBy:`setup-title`})}):At?z(P.Fragment,{children:[I(lK,{run:kt,plan:j,idle:n(`setup.download.working`)}),I(DG,{children:I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void fn(),disabled:Te,children:n(`setup.progress.cancel`)})})]}):null,rr.length>0&&z(`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:rr.map(e=>{let t=Ue.includes(e.id);return z(`li`,{className:`setup-result is-waiting`,children:[I(`span`,{className:`setup-result-label`,children:n(`setup.purpose.${e.roles[0]}`)}),z(`span`,{className:`setup-result-value`,children:[I(`bdi`,{dir:`ltr`,children:e.size_gb==null?n(`setup.contents.sizeOnDownload`):BO(e.size_gb)}),I(`button`,{type:`button`,className:`btn-secondary`,"aria-pressed":t,onClick:()=>We(n=>t?n.filter(t=>t!==e.id):[...n,e.id]),children:n(t?`setup.optional.added`:`setup.optional.add`)})]})]},e.id)})})]}),D&&z(P.Fragment,{children:[I(`p`,{className:`setup-error`,role:`alert`,children:n(`setup.lostContact`,{error:D})}),I(DG,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Ht(),children:n(`setup.reconnect`)})})]}),Cn&&En&&!Dn&&kt.state===`failed`&&!kt.model_failed&&(kt.problem?I(eq,{problem:kt.problem,onRetry:Gt,onUseGaia:()=>void Ut(!0,Qe.current.options)}):z(`div`,{className:`setup-error`,role:`alert`,children:[I(`p`,{children:n(`setup.download.stoppedBeforeCheck`)}),kt.error&&z(`details`,{className:`dl-details`,children:[I(`summary`,{children:n(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:kt.error})]})]})),Cn&&En&&!Dn&&z(P.Fragment,{children:[I(`p`,{className:`setup-hint`,children:n(`setup.download.finishNote`)}),I(DG,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:Gt,disabled:Te,children:n(`setup.finish`)})})]}),Cn&&!En&&!Dn&&!(kt.models??[]).some(e=>e.state===`failed`||e.state===`cancelled`)&&z(P.Fragment,{children:[I(nq,{run:kt}),kt.problem?I(eq,{problem:kt.problem,onRetry:Gt,onUseGaia:()=>void Ut(!0,Qe.current.options)}):I(DG,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Ut(!!kt.gaia_lemonade,Qe.current.options),children:n(`setup.tryAgain`)})})]}),(De||k)&&I(tq,{text:De??k})]}),Rn===`test`&&kt&&z(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(UK,{run:kt,expected:tr,names:Sn,catalog:On,onRetry:Gt,onChooseAnother:Dt?void 0:$t,onCancel:()=>void fn(),onDownloadAgain:j?.lemonade.mode===`external`?void 0:e=>void pn(e,`verify`),busy:Te}),Cn&&kt.error&&!(kt.tests??[]).some(e=>e.error===kt.error)&&z(`details`,{className:`dl-details`,children:[I(`summary`,{children:n(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:kt.error})]}),(De||k)&&I(tq,{text:De??k})]}),Rn===`ready`&&z(P.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.ready.heading`)}),z(`div`,{className:`setup-done`,role:`status`,children:[I(`div`,{className:`setup-done-head`,children:bn&&I(`p`,{children:n(Dt?`setup.ready.answersCloud`:`setup.ready.answersLocal`,{model:Dt?xc(bn):Sn[bn]??me?.catalog?.find(e=>e.id===bn)?.name??xc(bn)})})}),I(DG,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void xn(),autoFocus:!0,children:n(`setup.ready.start`)})}),!Dt&&me&&I(zG,{plan:me,chatModel:bn,gpu:M}),k&&I(tq,{text:k}),(kt?.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??``}`)),Ge.length>0&&!ye&&I(`p`,{className:`setup-failed-extra`,role:`alert`,children:n(`setup.ready.extraNotFetched`,{names:Ge.map(e=>Sn[e]??e).join(`, `)})}),Tn.length>0&&z(P.Fragment,{children:[I(`p`,{className:`setup-hint`,children:n(`setup.ready.tasks`)}),I(WG,{cards:Tn,onPick:e=>void xn(e)})]})]})]})]},Rn),t&&!At&&Rn!==`plan`&&Rn!==`ready`&&I(`div`,{className:`setup-row`,children:I(`button`,{type:`button`,className:`link-btn setup-close`,onClick:t,children:n(`setup.backToGaia`)})}),er&&($n||Rn===`plan`)&&I(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.nav.runGoing`)}),I(mK,{run:T,before:{check:Gn},failed:wn})]})}),I(`div`,{className:`setup-footer`,ref:h})]})}),ye?.kind===`no_fit`&&I(OG,{title:ye.models.length===1?n(`setup.confirm.noFitOne`,{name:ye.models[0].name}):n(`setup.confirm.noFitMany`),confirmLabel:n(`setup.confirm.downloadAnyway`),cancelLabel:n(`setup.confirm.pickSmaller`),onConfirm:()=>{be(null),we(!0),Zt(qt,!0)},onCancel:()=>be(null),children:ye.models.map(e=>z(`p`,{children:[I(`bdi`,{children:e.name}),`: `,fG(e,n)]},e.id))}),ye?.kind===`low_disk`&&An&&I(OG,{title:n(`setup.confirm.lowDiskTitle`),confirmLabel:n(`setup.confirm.downloadAnyway`),cancelLabel:n(`setup.confirm.changeModels`),onConfirm:()=>{be(null),Zt(!0)},onCancel:()=>{be(null),$t()},children:I(`p`,{children:n(`setup.summary.short`,{need:BO(An.needGb),free:BO(An.freeGb),drive:n(`setup.summary.theDrive`),freeUp:BO(An.freeUpGb)})})}),ye?.kind===`server`&&I(OG,{title:ye.detail.code===`low_disk`?n(`setup.confirm.lowDiskTitle`):n(`setup.confirm.noFitServerTitle`),confirmLabel:ye.detail.code===`low_disk`?n(`setup.confirm.downloadAnyway`):n(`setup.confirm.useAnyway`),cancelLabel:n(`setup.confirm.changeModels`),onConfirm:()=>{let e=ye;if(be(null),e.then===`chat`)we(!0),Zt(qt,!0);else if(e.then===`retry`)N(e.id,{keepTrying:_e,acknowledgeLowDisk:!0}).then(E).catch(e=>Oe(iq(e)));else{let{gaiaLemonade:e,options:t}=Qe.current;Ut(e,{...t,acknowledgeLowDisk:!0})}},onCancel:()=>{let e=ye;be(null),e.then!==`retry`&&!jt&&$t()},children:I(`p`,{children:ye.detail.message})})]})}function oq({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 z(`details`,{className:`settings-disclosure`,"data-settings-target":o,open:c||a,onToggle:e=>{a||l(e.currentTarget.open)},children:[z(`summary`,{onClick:e=>{a&&e.preventDefault()},children:[I(Gr,{size:15,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),z(`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 sq=u(Gl()?`settings.desktop.menuBar`:`settings.desktop.tray`),cq=[{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`}],lq=new Set([`startMinimized`]),uq={minimizeToTray:`settings.desktop.keepRunningNoTray`};function dq(e){return e?.reason===`no-host`?`settings.desktop.noTray`:e?.reason===`check-failed`?`settings.desktop.noTrayCheckFailed`:null}function fq(){let e=R(),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=dq(i);return I(oq,{title:e(`settings.desktop.title`),children:z(`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`)}),cq.map(({key:t,label:r,hint:i})=>{let a=lq.has(t)?d:null,o=d&&uq[t]||i;return z(`div`,{children:[z(`label`,{className:`setting-row`,children:[I(`span`,{children:e(r,{tray:sq})}),z(`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:sq})}),I(`span`,{className:`toggle-track`})]})]}),I(`p`,{className:`settings-hint`,id:`desktop-${t}-hint`,children:a?e(a):e(o,{tray:sq})})]},t)}),o&&I(`p`,{className:`settings-error`,role:`alert`,children:o})]})})}function pq(){return window.gaiaUpdater}var mq={status:`idle`,version:null,progress:0,releaseNotes:null,error:null,currentVersion:null,pinnedVersion:null,autoUpdate:!1,includePrereleases:!1};function hq(){let[e,t]=(0,V.useState)({...mq}),n=(0,V.useRef)(!1),r=(0,V.useRef)(0),i=(0,V.useCallback)(async()=>{let e=pq();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=pq();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 gq=`gaia-update-error:`;function _q(e,t){let n=`update.err.${e}`;return ae(n)?u(n,t??{}):null}function vq(e){let t=e instanceof Error?e.message:String(e),n=t.indexOf(gq);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=_q(r.code,r.params)??r.message??r.code,a=r.note&&_q(r.note.code,r.note.params);return a?u(`update.err.withNote`,{error:i,note:a}):i}function yq(e,t){let n=vq(e);return typeof n==`object`?t(n.ref,n.params):String(n)}function bq(){return window.gaiaUpdater}function xq({onClose:e,manualInstall:t=!1}){let n=R(),[r,i]=(0,V.useState)({kind:`loading`}),a=(0,V.useRef)(null);(0,V.useEffect)(()=>{let e=bq();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.`})},[]),pt(!0,e),on(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=bq();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:vq(e)})})}}function c(e){if(!e)return``;try{return new Date(e).toLocaleDateString(Sn(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:z(`div`,{className:`version-picker-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":n(`update.picker.title`),ref:a,children:[z(`div`,{className:`version-picker-header`,children:[I(`h3`,{children:n(`update.picker.title`)}),I(`button`,{className:`version-picker-close`,onClick:e,"aria-label":n(`update.picker.close`),type:`button`,children:`×`})]}),z(`div`,{className:`version-picker-body`,children:[r.kind===`loading`&&z(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[I(`span`,{className:`version-picker-spinner`}),n(`update.picker.loading`)]}),r.kind===`error`&&z(`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:z(`button`,{type:`button`,className:`version-picker-row`,"data-version":e.version,"aria-label":e.isCurrent?n(`update.picker.rowInstalled`,{version:e.version}):e.isPinned?n(`update.picker.rowPinned`,{version:e.version}):e.version,"aria-disabled":e.isCurrent?`true`:`false`,onClick:()=>o(e,r.releases),disabled:e.isCurrent,children:[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`&&z(`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`&&z(`div`,{className:`version-picker-confirm`,children:[t?I(`p`,{children:n(`update.picker.manual`,{version:r.release.version})}):z(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})})]}),z(`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`&&z(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[I(`span`,{className:`version-picker-spinner`}),n(`update.picker.starting`)]})]})]})})}var Sq=`https://github.com/amd/gaia/releases`;function Cq(e){return/^\d+\.\d+\.\d+-/.test(e??``)}function wq(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 Tq(){let e=hq(),t=R(),n=pq(),[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:u(e),reason:vq(n)}))}finally{i(!1)}}}let d=e.status===`disabled`,f=r||e.status===`checking`||e.status===`downloading`,p=e.readFailed?wq(e,t):`${t(`update.settings.running`,{version:e.currentVersion??t(`update.settings.unknownVersion`)})} ${wq(e,t)}`,m=[`available`,`downloaded`,`error`].includes(e.status)||!!e.pinnedVersion||!!e.installFailed||!!e.configError||!!e.readFailed||!!a;return I(oq,{title:t(`update.settings.title`),titleId:`updates-label`,hint:p,forceOpen:m,children:z(`div`,{className:`settings-field`,role:`group`,"aria-labelledby":`updates-label`,children:[I(`p`,{className:`visually-hidden`,role:`status`,children:p}),!e.manualInstall&&z(P.Fragment,{children:[z(`label`,{className:`setting-row`,children:[I(`span`,{children:t(`update.settings.auto`)}),z(`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:d,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`)})]}),z(`label`,{className:`setting-row`,children:[I(`span`,{children:t(`update.settings.rc`)}),z(`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:d,onChange:()=>{r||l(`update.action.saveRc`,t=>t.setIncludePrereleases(!e.includePrereleases))}}),I(`span`,{className:`toggle-track`})]})]}),z(`p`,{className:`settings-hint`,id:`updates-rc-hint`,children:[t(`update.settings.rcHint`),Cq(e.currentVersion)&&` ${t(`update.settings.rcHintRunning`)}`]}),e.pinnedVersion&&z(`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`)})]}),z(`div`,{className:`setting-actions`,children:[e.status===`available`&&e.manualInstall&&I(`a`,{className:`btn-primary update-download-link`,href:e.downloadUrl??Sq,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:f||d,onClick:()=>void l(`update.action.check`,e=>e.check()),children:t(`update.settings.check`)}),I(`button`,{type:`button`,className:`btn-secondary`,disabled:f||d,onClick:()=>c(!0),children:t(`update.settings.pick`)}),e.previousVersion&&I(`button`,{type:`button`,className:`btn-secondary`,"aria-describedby":`updates-back-hint`,disabled:f||d,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:Sq})}),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(xq,{onClose:()=>c(!1),manualInstall:e.manualInstall})]})})}var Eq=[{value:`light`,label:`settings.theme.light`},{value:`dark`,label:`settings.theme.dark`},{value:`system`,label:`settings.theme.system`}],Dq={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=R(),t=B(e=>e.locale),n=B(e=>e.setLocale),r=B(e=>e.themePreference),i=B(e=>e.setThemePreference),a=B(e=>e.palette),o=B(e=>e.setPalette),s=B(e=>e.customColors),c=B(e=>e.setCustomColors),l=eH(e=>e.visible),u=eH(e=>e.setVisible),d=e=>t=>c({...s,[e]:t.target.value.toUpperCase()});return z(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.general`)}),z(`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:ge.map(({meta:e})=>I(`option`,{value:e.code,lang:e.code,dir:e.dir,children:Fe(e)},e.code))}),I(`span`,{className:`settings-hint`,children:e(`settings.languageHint`)})]}),z(`div`,{className:`settings-field`,children:[I(`span`,{className:`settings-label`,id:`appearance-label`,children:e(`settings.appearance`)}),I(Fz,{className:`segmented`,"aria-labelledby":`appearance-label`,children:Eq.map(t=>I(`button`,{type:`button`,role:`radio`,"aria-checked":r===t.value,className:r===t.value?`is-active`:``,onClick:()=>i(t.value),children:e(t.label)},t.value))})]}),z(`div`,{className:`settings-field`,children:[z(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`resources.settings`)}),z(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,checked:l,onChange:e=>u(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`)})]}),z(oq,{title:e(`settings.colors`),titleId:`palette-label`,defaultOpen:a===`custom`,children:[z(Fz,{className:`palette-grid`,"aria-labelledby":`palette-label`,children:[vn.map(t=>z(`button`,{type:`button`,role:`radio`,"aria-checked":a===t.id,className:`palette-tile${a===t.id?` is-active`:``}`,onClick:()=>o(t.id),children:[I(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:t.swatch.map(e=>I(`i`,{style:{background:e}},e))}),e(Dq[t.id])]},t.id)),z(`button`,{type:`button`,role:`radio`,"aria-checked":a===`custom`,className:`palette-tile${a===`custom`?` is-active`:``}`,onClick:()=>o(`custom`),children:[z(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:[I(`i`,{style:{background:s.base}}),I(`i`,{style:{background:s.accent}})]}),e(`settings.colors.custom`)]})]}),a===`custom`&&z(`div`,{className:`palette-custom`,children:[z(`label`,{className:`palette-color`,htmlFor:`custom-accent`,children:[I(`input`,{id:`custom-accent`,type:`color`,value:s.accent,onChange:d(`accent`)}),z(`span`,{children:[e(`settings.colors.accent`),I(`small`,{children:e(`settings.colors.accentHint`)})]})]}),z(`label`,{className:`palette-color`,htmlFor:`custom-base`,children:[I(`input`,{id:`custom-base`,type:`color`,value:s.base,onChange:d(`base`)}),z(`span`,{children:[e(`settings.colors.base`),I(`small`,{children:e(`settings.colors.baseHint`)})]})]}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>c(de),children:e(`settings.colors.reset`)}),I(`p`,{className:`settings-hint`,children:e(`settings.colors.hint`)})]})]}),I(fq,{}),I(Tq,{}),I(oq,{title:e(`settings.shortcuts`),children:I(`dl`,{className:`shortcut-list`,children:CW().map(({label:t,keys:n})=>z(`div`,{className:`shortcut-row`,children:[I(`dt`,{children:I(`kbd`,{children:Yl(n)})}),I(`dd`,{children:e(t)})]},t))})})]})}function kq(e){return/not reachable|not answering|model server at|ConnectionPool|NewConnectionError|Connection refused|Max retries/i.test(e)}function Aq(e){return/gaia init/i.test(e??``)}var jq=`GAIA doesn't run this model server, so it can't start it. Start it the way you usually do.`;function Mq(e,t){return t?t===jq?e(`server.otherServerStart`):t:null}function Nq(e){return!!e&&!e.lemonade_running&&(Aq(e.start_command)||Aq(e.start_instruction))}function Pq({className:e=`btn-secondary`}){let t=R();return I(`button`,{type:`button`,className:e,onClick:()=>window.dispatchEvent(new CustomEvent(`gaia:set-up-local`)),children:t(`settings.errors.setUpLocal`)})}function Fq({message:e,onRetry:t}){let n=R(),r=B(e=>Nq(e.systemStatus));return kq(e)?z(`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`)}),z(`details`,{className:`settings-more`,children:[z(`summary`,{children:[I(Gr,{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 Iq({onAdded:e}){let t=R(),[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 It(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 Gt(n.trim(),i);r(``),a(``),s(null),e(o.display_name??o.model_id??t(`settings.custom.theModel`))}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(null)}},[e,i,n,t]);return z(`form`,{className:`settings-field custom-model-add`,onSubmit:e=>{e.preventDefault(),p(``)},children:[I(`label`,{className:`visually-hidden`,htmlFor:`custom-model-url`,children:t(`settings.custom.title`)}),I(`span`,{className:`settings-hint`,children:t(`settings.custom.hint`)}),z(`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`}),z(`button`,{type:`submit`,className:`btn-secondary`,disabled:c!==null||!n.trim(),children:[c===`check`?I(La,{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=>z(`li`,{className:e.ok?`is-ok`:`is-failed`,children:[e.ok?I(Vr,{size:13,"aria-label":t(`settings.custom.passed`)}):I(Is,{size:13,"aria-label":t(`settings.custom.failed`)}),z(`bdi`,{children:[I(`strong`,{children:e.label}),` — `,e.detail]})]},e.id))});return o.ok?z(`details`,{className:`custom-model-checks-summary`,children:[z(`summary`,{children:[I(Vr,{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=>z(`li`,{className:`is-warning`,children:[I(ws,{size:13,"aria-label":t(`settings.custom.warning`)}),` `,I(`bdi`,{children:e})]},e))}),o&&o.variants.length>1&&z(`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=>z(`option`,{value:e.file,children:[e.quant,` · `,e.size_gb,` GB`,e.fits?``:` · ${t.bare(`settings.custom.tooLarge`)}`]},e.file))})]}),o?.ok&&z(`div`,{className:`settings-row`,children:[z(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void m(),disabled:c!==null,children:[c===`add`?I(La,{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(Fq,{message:u})]})}function Lq(e){return e instanceof Error?e.message:String(e)}function Rq(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function zq({downloadsSlot:e}){let t=R(),[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(null),[u,d]=(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=Qc(e=>e.status),S=Qc(e=>e.started),C=(0,V.useMemo)(()=>Yc(x,S),[x,S]),w=Qc(e=>e.error),T=Qc(e=>e.refresh),E=Qc(e=>e.enqueue),D=Qc(e=>e.cancel),O=(0,V.useCallback)(async(e=!1)=>{a(null);try{let t=await qe();r(t),s(n=>e||!n?JW(t):n)}catch(e){a(Lq(e))}},[]);(0,V.useEffect)(()=>{O(!0),T(),(async()=>{try{v(await f()??null)}catch(e){b(Lq(e))}})()},[O,T]);let k=(C?.models??[]).filter(e=>e.state===`ready`).map(e=>e.id).join(`,`),ee=(0,V.useRef)(k);(0,V.useEffect)(()=>{k!==ee.current&&(ee.current=k,O(!0))},[k,O]);let te=(0,V.useMemo)(()=>{let e={};for(let t of C?.models??[])e[t.id]=t;return e},[C]),ne=(0,V.useMemo)(()=>{let e={};for(let t of n?.catalog??[])e[t.id]=t.name;return e},[n]),A=(0,V.useMemo)(()=>n?JW(n):null,[n]),re=NW(n),ie=n&&o?$W(re,o).filter(e=>te[e.id]?.state!==`downloading`):[],ae=ie.reduce((e,t)=>e+(t.size_gb??0),0),j=!!n&&!!o&&!!A&&(!Rq(o.ticked,A.ticked)||o.defaultChat!==A.defaultChat||ie.length>0),oe=(0,V.useCallback)(async(e,i)=>{if(!n||!o)return;if(m(null),!e){let e=nG(re,o).filter(e=>!e.downloaded||e.id===o.defaultChat);if(e.length>0&&e.every(e=>e.need_gb!=null)){l({kind:`no_fit`,models:e});return}}let a=tG(n,o);if(a&&!i)l({kind:`low_disk`,message:a.drop?t(`setup.summary.shortDrop`,{need:BO(a.needGb),free:BO(a.freeGb),drive:gG(n.disk?.path??null)??t(`setup.summary.theDrive`),freeUp:BO(a.freeUpGb),name:a.drop.name,saves:BO(a.drop.size_gb??0)}):t(`setup.summary.short`,{need:BO(a.needGb),free:BO(a.freeGb),drive:gG(n.disk?.path??null)??t(`setup.summary.theDrive`),freeUp:BO(a.freeUpGb)})});else{d(!0);try{let i=n,a=!1;if(o.defaultChat&&o.defaultChat!==i.chat_model.id){a=!0;try{i=await Se(o.defaultChat,e||h)}catch(e){let t=it(e);if(t){l({kind:`server`,detail:t});return}throw e}}for(let e of rG(i,o))i=await dt(e.id,e.skipped);let c=$W(NW(i),o).map(e=>e.id).filter(e=>te[e]?.state!==`downloading`);r(i),s({...o,defaultChat:i.chat_model.id});let u=null;if(a&&i.chat_model.downloaded)try{await _c.getState().select(i.chat_model.id)}catch(e){u=Lq(e),_c.getState().refresh()}else _c.getState().refresh();c.length&&await E(c,{acknowledgeLowDisk:!0}),m(u===null?{ok:!0,text:t(`settings.models.applied`)}:{ok:!1,text:t(`settings.models.appliedNotSwitched`,{reason:u})})}catch(e){m({ok:!1,text:Lq(e)})}finally{d(!1)}}},[n,o,re,h,te,E,t]),se=(0,V.useCallback)(async e=>{l(null),d(!0),m(null);try{let n=await le(e.id);Qs(),r(n),s(JW(n)),m({ok:!0,text:t(`settings.models.removed`,{name:e.name,size:BO(n.freed_gb)})})}catch(e){m({ok:!1,text:Lq(e)})}finally{d(!1)}},[t]),ce=(0,V.useCallback)((e,t)=>{(async()=>{try{t===`verify`&&await le(e),await E([e])}catch(e){m({ok:!1,text:Lq(e)})}})()},[E]),ue=!!C&&(C.models?.length??0)>0&&(aK(C)||C.models.some(e=>e.state!==`skipped`))&&C&&z(`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(cK,{status:C,names:ne,freeGb:n?.disk?.free_gb??null,onCancel:()=>void D(),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 z(P.Fragment,{children:[I(oq,{title:t(`settings.models.manage`),hint:t(`settings.models.manageHint`),forceOpen:!!i||p?.ok===!1,children:z(`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(Fq,{message:i}),n&&!n.lemonade.reachable&&I(`p`,{className:`settings-hint`,children:t(`settings.models.unavailable`)}),!n&&!i&&z(`p`,{className:`settings-hint`,children:[I(La,{size:13,className:`spin`,"aria-hidden":`true`}),` `,t(`setup.models.loading`)]}),n&&n.lemonade.reachable&&o&&z(P.Fragment,{children:[I(vG,{plan:n,selection:o,onToggle:(e,t)=>s(XW(o,re,e,t)),onDefaultChat:e=>s(ZW(o,re,e)),labelledBy:`settings-models-title`,place:`settings`,disabled:u,progress:te,rowActions:e=>e.downloaded&&e.id!==o.defaultChat?I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>l({kind:`remove`,entry:e}),disabled:u||te[e.id]?.state===`downloading`,"aria-label":t(`settings.models.removeAria`,{name:e.name}),children:t(`settings.models.remove`)}):null}),I(hG,{plan:n,selection:o}),I(`div`,{className:`models-apply`,children:z(`button`,{type:`button`,className:`btn-primary`,disabled:!j||u,onClick:()=>void oe(!1,!1),children:[u&&I(La,{size:13,className:`spin`,"aria-hidden":`true`}),u?t(`settings.models.applying`):ie.length>0?t(`settings.models.applyDownload`,{size:BO(Math.round(ae*10)/10)}):t(`settings.models.apply`)]})})]}),p?.ok&&I(`p`,{className:`settings-ok`,role:`status`,children:p.text}),p&&!p.ok&&I(Fq,{message:p.text})]})}),(_?.applies||y&&!kq(y))&&I(oq,{title:t(`gpu.settingsTitle`),titleId:`settings-gpu-title`,defaultOpen:!!_?.pending||!!y,children:z(`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(LG,{status:_,onStatus:v,mode:`settings`,names:ne,headingId:`settings-gpu-title`})]})}),e?(0,Mj.createPortal)(ue,e):e===void 0&&ue,c?.kind===`remove`&&I(OG,{title:t(`settings.models.removeTitle`,{name:c.entry.name}),confirmLabel:t(`settings.models.removeConfirm`),cancelLabel:t(`settings.models.keep`),danger:!0,onConfirm:()=>void se(c.entry),onCancel:()=>l(null),children:I(`p`,{children:PW(c.entry)?t(`settings.models.removeVision`,{size:BO(c.entry.full_size_gb??0)}):t(`settings.models.removeBody`,{size:BO(c.entry.full_size_gb??0)})})}),c?.kind===`no_fit`&&I(OG,{title:c.models.length===1?t(`setup.confirm.noFitOne`,{name:c.models[0].name}):t(`setup.confirm.noFitMany`),confirmLabel:t(`setup.confirm.downloadAnyway`),cancelLabel:t(`setup.confirm.pickSmaller`),onConfirm:()=>{l(null),g(!0),oe(!0,!1)},onCancel:()=>l(null),children:c.models.map(e=>z(`p`,{children:[I(`bdi`,{children:e.name}),`: `,fG(e,t)]},e.id))}),c?.kind===`low_disk`&&I(OG,{title:t(`setup.confirm.lowDiskTitle`),confirmLabel:t(`setup.confirm.downloadAnyway`),cancelLabel:t(`setup.confirm.changeModels`),onConfirm:()=>{l(null),oe(!0,!0)},onCancel:()=>l(null),children:I(`p`,{children:c.message})}),c?.kind===`server`&&I(OG,{title:t(`setup.confirm.noFitServerTitle`),confirmLabel:t(`setup.confirm.useAnyway`),cancelLabel:t(`setup.confirm.changeModels`),onConfirm:()=>{l(null),g(!0),oe(!0,!1)},onCancel:()=>l(null),children:I(`p`,{children:c.detail.message})})]})}var Bq=`auto`;function Vq({model:e}){let t=R(),[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),Qt(e).then(r).catch(e=>a(e instanceof Error?e.message:String(e)))},[e]);let d=(0,V.useCallback)(async n=>{s(!0),a(null),l(null);try{let i=await Un(e,n===Bq?null:Number(n));r(i);let a={name:i.display_name,size:i.chosen?Nc(i.chosen):u(`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 kq(i)?I(`p`,{className:`settings-hint`,children:t(`settings.ctx.serverDown`)}):I(`p`,{className:`settings-error`,role:`alert`,children:i});if(!n)return z(`p`,{className:`settings-hint`,children:[I(La,{size:13,className:`spin`}),` `,t(`settings.ctx.checking`)]});let f=n.chosen==null?Bq:String(n.chosen),p=n.chosen!=null&&n.loaded_ctx!=null&&n.loaded_ctx!==n.chosen;return z(P.Fragment,{children:[z(`div`,{className:`model-in-use-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`ctx-size`,children:t(`settings.ctx.label`)}),z(`select`,{id:`ctx-size`,className:`settings-input`,value:f,onChange:e=>void d(e.target.value),disabled:o||n.options.length===0,children:[I(`option`,{value:Bq,children:n.automatic?t.bare(`settings.ctx.automaticAt`,{size:Nc(n.automatic)}):t.bare(`settings.ctx.automatic`)}),n.options.map(e=>I(`option`,{value:String(e),children:t.bare(`settings.ctx.tokens`,{size:Nc(e)})},e))]})]}),n.note&&I(`span`,{className:`settings-hint`,children:I(`bdi`,{children:n.note})}),!n.note&&!!n.max_fit&&z(`details`,{className:`settings-more`,children:[z(`summary`,{children:[I(Gr,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,t(`settings.ctx.about`)]}),I(`span`,{className:`settings-hint`,children:t(`settings.ctx.explain`,{size:Nc(n.max_fit),name:n.display_name,memory:n.memory_source})})]}),p&&I(`span`,{className:`settings-hint`,children:t(`settings.ctx.loadedAt`,{size:Nc(n.loaded_ctx)})}),o&&z(`span`,{className:`settings-hint`,children:[I(La,{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 Hq({row:e,providerName:t,choices:n,labels:r,disabled:i,onSwitch:a}){let o=R(),s=_c(e=>e.active),c=_c(e=>e.error),l=s?.model??null,u=!!s?.remote,d=n.some(e=>bc(l,e.id)),f=s?.downloaded??e?.downloaded,p=u?null:e?.state===`loaded`?o(`settings.model.loaded`):f===!0?o(`settings.model.downloaded`):f===!1?o(`settings.model.notDownloaded`):null,m=e?.placement?.device;return z(`section`,{className:`settings-card model-in-use`,"aria-label":o(`settings.model.inUseTitle`),children:[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||xc(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&&z(`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&&z(`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:Nc(e.context_length)})})]}),(n.length>1||n.length===1&&!d)&&z(`div`,{className:`model-in-use-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`model-switch`,children:o(`settings.model.switch`)}),z(`select`,{id:`model-switch`,className:`settings-input`,value:d?n.find(e=>bc(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(Vq,{model:l})]})}var Uq=e=>new Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:0}).format(e),Wq={"best overall, fastest":`settings.model.note.bestFastest`,cheapest:`settings.model.note.cheapest`,"most truthful":`settings.model.note.mostTruthful`},Gq=/^(\d+\/\d+) tasks · quality ([\d.]+\/5) · (\$[\d.]+) per (\d+)-task run$/;function Kq(e,t){let n=Gq.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 qq({model:e,label:t,current:n,remote:r,busy:i,onUse:a,onDownload:o,onAskRemove:s,onNpuRecheck:c}){let l=R(),u=Fc(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:Uq(e.context_length)}):null].filter(Boolean).join(` · `)),p=!!(e.display_name||f||e.evidence||e.custom&&e.source_url);return z(`li`,{className:`model-row${n?` is-current`:``}`,children:[z(`div`,{className:`model-row-text`,children:[I(`bdi`,{className:`model-row-name`,title:e.id,children:t}),z(`div`,{className:`model-chips`,children:[e.placement?.device&&I(`span`,{className:`model-badge is-device`,children:e.placement.device.toUpperCase()}),e.rank&&z(`span`,{className:`model-badge is-rank`,children:[z(`bdi`,{dir:`ltr`,children:[`#`,e.rank]}),` `,e.note&&(Wq[e.note]?l(Wq[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&&I(`span`,{className:`model-badge is-fit`,children:l(`settings.model.fits`)}),e.custom&&I(`span`,{className:`model-badge is-custom`,children:l(`settings.model.custom`)}),!!e.size_gb&&z(`bdi`,{dir:`ltr`,className:`model-badge is-size`,children:[e.size_gb,` GB`]}),p&&z(`details`,{className:`settings-more model-row-facts`,children:[z(`summary`,{children:[I(Gr,{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:Kq(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:HL(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(yK,{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})})]}),z(`div`,{className:`model-row-actions`,children:[e.custom&&!n&&!u&&z(`button`,{type:`button`,className:`btn-secondary`,onClick:s,disabled:i!==null,"aria-label":l(`settings.models.removeAria`,{name:t}),children:[i===`rm:${e.id}`?I(La,{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?z(`span`,{className:`model-row-current`,children:[I(Vr,{size:13,"aria-hidden":`true`}),` `,l(`settings.model.inUse`)]}):e.available===!1?null:u?z(`span`,{className:`model-row-current`,children:[I(La,{size:13,className:`spin`}),` `,u.message?I(`bdi`,{children:u.message}):z(`bdi`,{dir:`ltr`,children:[Math.round(u.percent),`%`]})]}):e.downloaded?z(`button`,{type:`button`,className:`btn-secondary`,onClick:a,disabled:i!==null,"aria-label":l(`settings.model.useAria`,{name:t}),children:[i===e.id?I(La,{size:13,className:`spin`}):null,` `,l(`settings.model.use`)]}):z(`button`,{type:`button`,className:`btn-secondary`,onClick:o,disabled:i!==null,"aria-label":l(`settings.model.downloadAria`,{name:t}),children:[i===`dl:${e.id}`?I(La,{size:13,className:`spin`}):null,` `,l(`settings.model.download`)]})]})]})}function Jq(){let e=R(),[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(tt)},[l]),!t)return r?I(`p`,{className:`settings-error`,role:`alert`,children:r}):z(`p`,{className:`settings-hint`,children:[I(La,{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 z(`section`,{className:`settings-field spending`,"aria-label":e(`settings.spend.aria`),children:[I(`span`,{className:`settings-label`,children:e(`settings.spend.title`)}),z(`p`,{className:`spending-total`,children:[I(`bdi`,{dir:`ltr`,children:I(`strong`,{children:UL(t.total_usd)})}),u!=null&&z(P.Fragment,{children:[` `,e(`settings.spend.ofLimit`,{limit:UL(u)})]}),z(`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`&&z(`p`,{className:`spending-warning`,role:`status`,children:[I(ws,{size:13,"aria-hidden":`true`}),` `,e(`settings.spend.near`)]}),t.state===`reached`&&z(`div`,{className:`spending-warning`,role:`alert`,children:[z(`p`,{children:[I(ws,{size:13,"aria-hidden":`true`}),` `,e(`settings.spend.reached`)]}),I(`button`,{type:`button`,className:`btn-secondary`,disabled:s,onClick:()=>void l(mn),children:e(`settings.spend.allow`)})]}),t.state===`allowed_over`&&I(`p`,{className:`settings-hint`,children:e(`settings.spend.allowed`)}),z(`form`,{className:`settings-row`,onSubmit:e=>{e.preventDefault(),f&&p&&l(()=>v(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}),z(`button`,{type:`submit`,className:`btn-secondary`,disabled:s||!f||!p,children:[s?I(La,{size:13,className:`spin`}):null,` `,e(`settings.advanced.save`)]}),u!=null&&I(`button`,{type:`button`,className:`btn-secondary`,disabled:s,onClick:()=>void l(()=>v(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 Yq=2e3;function Xq(e,t){return e.key_source===`environment`?t(`settings.key.setIn`,{name:e.env_var??``}):`••••••••••••••••••••${e.key_hint?` ${e.key_hint}`:``}`}function Zq(){let e=R(),t=_c(e=>e.active),n=_c(e=>e.select),r=_c(e=>e.refresh),i=_c(e=>e.rememberNames),a=B(e=>!!e.systemStatus&&gI(e.systemStatus)===`unresponsive`),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(null),u=B(e=>e.settingsProvider),[d,f]=(0,V.useState)(u??t?.provider??`local`),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(``),[y,b]=(0,V.useState)(!1),[x,S]=(0,V.useState)(``),[C,w]=(0,V.useState)(!1),[T,E]=(0,V.useState)(!1),[D,O]=(0,V.useState)({base_url:``,auth_header_name:``,auth_header_prefix:``}),[k,ee]=(0,V.useState)(null),[te,ne]=(0,V.useState)(null),[A,re]=(0,V.useState)(null),[ie,ae]=(0,V.useState)(null),[j,oe]=(0,V.useState)(!1),[se,ce]=(0,V.useState)(null),[le,ue]=(0,V.useState)(null),de=(0,V.useRef)(d);de.current=d;let fe=(0,V.useRef)(!0);(0,V.useEffect)(()=>(fe.current=!0,()=>{fe.current=!1}),[]);let pe=o?.find(e=>e.id===d)??null,me=e=>e?.network?.reachable===!1,he=e=>!!e?.blocked,M=!!pe&&!he(pe)&&(!pe.remote||!!pe.models_discovered),N=(0,V.useCallback)(async()=>{l(null);try{let e=await cn();s(e.providers),e.lemonade_error&&l(e.lemonade_error)}catch(e){l(e instanceof Error?e.message:String(e))}},[]),ge=(0,V.useCallback)(async()=>{try{await Jn()}catch(e){l(e instanceof Error?e.message:String(e));return}await N()},[N]),_e=(0,V.useCallback)(async(t,n=!1)=>{n||(m(null),g(null));try{let n=await Nn(t);i(n.models),m(n.models),ne(n.memory_gb?`${n.memory_gb} GB (${n.memory_source})`:n.capacity_error??null),n.blocked&&g(e(`settings.privacy.localOnlyBlocked`))}catch(e){g(e instanceof Error?e.message:String(e))}},[i,e]);(0,V.useEffect)(()=>{N()},[N]);let ve=!!o?.some(e=>e.key_state===`waiting_for_os_permission`);(0,V.useEffect)(()=>{if(!ve)return;let e=setInterval(()=>{N()},Yq);return()=>clearInterval(e)},[ve,N]);let ye=t?.provider;(0,V.useEffect)(()=>{ye&&!u&&f(ye)},[ye,u]),(0,V.useEffect)(()=>{S(``),w(!1),E(!1),re(null),v(``),b(!1),oe(!1)},[d]),(0,V.useEffect)(()=>{M?_e(d):m(null)},[d,M,_e]);let be=(0,V.useCallback)(async()=>{if(pe){ee(`connect`),re(null);try{let t=d===`amd`?{api_key:x||void 0,...Object.fromEntries(Object.entries(D).filter(([,e])=>e!==``))}:{api_key:x||void 0},n=()=>!fe.current||de.current!==d,r=await _n(d,t,e=>{n()||re({ok:!0,text:e})},n);if(n())return;S(``),w(!1),re({ok:!0,text:r.remember_error?e(`settings.key.sessionOnly`,{reason:r.remember_error}):r.known_models?e(`settings.key.knownModels`,{name:pe.name}):r.remembered?e(`settings.key.kept`):e(`settings.key.connectedDone`)}),await N()}catch(e){fe.current&&de.current===d&&re({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{fe.current&&ee(null)}}},[D,d,x,N,pe,e]),xe=(0,V.useCallback)(async()=>{ee(`forget`),E(!1),re(null);try{await Wn(d),re({ok:!0,text:e(`settings.key.cleared`)}),await N(),await r()}catch(e){re({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{ee(null)}},[d,N,r,e]),Se=(0,V.useCallback)(async t=>{ee(t),re(null);try{await n(t),re({ok:!0,text:e(`settings.model.switched`,{name:xc(t)})}),await _e(d,!0)}catch(e){re({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{ee(null)}},[d,_e,n,e]),Ce=(0,V.useCallback)(async e=>{ee(`dl:${e}`),re(null),oe(!1);try{await Ve(e),await _e(`local`,!0)}catch(e){re({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{ee(null)}},[_e]),we=(0,V.useCallback)(async t=>{let n=_c.getState().active?.model;ee(`rm:${t}`),re(null);try{let r=await Rt(t);ae(null);let i=r.cleared.includes(`last_model`)?`settings.model.removedLast`:r.cleared.includes(`default_model`)?`settings.model.removedDefault`:`settings.model.removed`;re({ok:!0,text:e(i,{name:r.display_name})}),await _e(`local`,!0),await vc(n)}catch(e){re({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{ee(null)}},[_e,e]),Te=(0,V.useCallback)(async t=>{re({ok:!0,text:e(`settings.model.added`,{name:t})}),oe(!0),await _e(`local`,!0)},[_e,e]),Ee=!!p?.some(Fc);(0,V.useEffect)(()=>{if(Ee)return()=>{r()}},[Ee,r]),(0,V.useEffect)(()=>{if(d!==`local`||!Ee)return;let e=setInterval(()=>{_e(`local`,!0)},Yq);return()=>clearInterval(e)},[Ee,d,_e]);let De=t?.model,Oe=p?.find(e=>bc(De,e.id));(0,V.useEffect)(()=>{Oe&&ce(Oe)},[Oe]);let ke=(0,V.useMemo)(()=>{let e=_.trim().toLowerCase();return(p??[]).filter(t=>!e||t.id.toLowerCase().includes(e)||(t.display_name??``).toLowerCase().includes(e))},[p,_]),Ae=ke.filter(e=>e.available!==!1),je=d===`fireworks`&&!y&&!_.trim()&&Ae.some(e=>e.rank!==null),Me=e=>e.rank!==null||e.id===t?.model,Ne=je?Ae.filter(Me):Ae,Pe=je?Ae.filter(e=>!Me(e)):[],Fe=ke.filter(e=>e.available===!1),Ie=kc(p??[]),Le=!!_.trim(),Re=e=>bc(t?.model,e.id),ze=pe?.id===`local`,Be=Ne.filter(e=>e.downloaded).sort((e,t)=>Number(Re(t))-Number(Re(e))),He=Ne.filter(e=>!e.downloaded),Ue=(p??[]).filter(e=>e.available!==!1&&e.downloaded),We=Ue.filter(Me),Ge=ie?(p??[]).find(e=>e.id===ie)??null:null,Ke=d===`fireworks`&&We.some(e=>e.rank!==null)?We:Ue,qe=e=>I(qq,{model:e,label:Ie[e.id],current:Re(e),remote:!!pe?.remote,busy:k,onUse:()=>void Se(e.id),onDownload:()=>void Ce(e.id),onAskRemove:()=>ae(e.id),onNpuRecheck:()=>void _e(d,!0)},e.id);return z(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.model`)}),I(Hq,{row:Oe??(bc(se?.id,t?.model)?se:null),providerName:t?.provider_name??null,choices:M?Ke:[],labels:Ie,disabled:k!==null,onSwitch:e=>void Se(e)}),I(Fz,{className:`provider-tabs`,"aria-label":e(`settings.model.whereRuns`),children:(o??[{id:`local`,name:`Local`,remote:!1}]).map(t=>z(`button`,{type:`button`,role:`radio`,"aria-checked":d===t.id,className:`provider-tab${d===t.id?` is-active`:``}${me(t)||he(t)?` is-disabled`:``}`,onClick:()=>f(t.id),disabled:(me(t)||he(t))&&d!==t.id,title:he(t)?e(`settings.privacy.localOnlyBlocked`):me(t)?e(`setup.key.gatewayOff`):void 0,children:[t.remote?I(pi,{size:14,"aria-hidden":`true`}):I(yi,{size:14,"aria-hidden":`true`}),I(`span`,{children:GL(e,t)}),t.remote&&t.models_discovered&&I(`span`,{className:`provider-tab-dot`,"aria-label":e(`settings.key.connectedDot`)})]},t.id))}),!o&&!c&&z(`p`,{className:`settings-hint`,role:`status`,children:[I(La,{size:13,className:`spin`}),` `,e(a?`settings.model.waitingServer`:`settings.loading`)]}),c&&I(Fq,{message:c,onRetry:()=>{N(),_e(d)}}),pe&&z(`section`,{className:`settings-card`,"aria-label":GL(e,pe),children:[pe.remote&&I(`p`,{className:`settings-note`,children:I(`bdi`,{children:KL(e,pe)})}),z(`details`,{className:`settings-more`,children:[z(`summary`,{children:[I(Gr,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,e(`settings.model.howItWorks`)]}),I(`p`,{className:`settings-hint`,children:e(`settings.model.lede`)}),ze&&I(`p`,{className:`settings-hint`,children:I(`bdi`,{children:KL(e,pe)})}),ze&&I(`p`,{className:`settings-hint`,children:e(`settings.model.devices`)}),ze&&te&&I(`p`,{className:`settings-hint`,children:e(`settings.model.memory`,{memory:te})})]}),pe.remote&&!M&&z(`div`,{className:`settings-field`,children:[I(`span`,{className:`settings-label`,children:e(`settings.model.prices`)}),I(EW,{provider:pe.id})]}),he(pe)&&I(`div`,{className:`settings-field`,children:I(`p`,{className:`settings-error`,role:`alert`,children:e(`settings.privacy.localOnlyBlocked`)})}),me(pe)&&z(`div`,{className:`settings-field`,children:[I(`p`,{className:`settings-error`,role:`alert`,children:pe.network?.detail}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void N(),children:e(`settings.key.checkAgain`)})]}),pe.remote&&!me(pe)&&!he(pe)&&z(`form`,{className:`settings-field`,"data-settings-target":`cloud-key`,onSubmit:e=>{e.preventDefault(),be()},children:[z(`div`,{className:`settings-row settings-row-between`,children:[I(`span`,{className:`settings-label`,children:e(`settings.key.title`)}),pe.key_source&&I(`span`,{className:`settings-key-status ${M?`settings-ok`:`settings-error`}`,children:e(M?`settings.key.connected`:`settings.key.notConnected`)})]}),!pe.key_source&&pe.key_state===`store_locked`&&z(`span`,{className:`settings-hint`,role:`status`,children:[e(`settings.key.storeLocked`),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>void ge(),children:e(`settings.key.unlockAgain`)})]}),!pe.key_source&&pe.key_state!==`store_locked`&&I(`span`,{className:`settings-hint`,children:pe.key_state===`waiting_for_os_permission`?pe.key_message??e(`settings.key.waitingOs`):e(`settings.key.none`)}),pe.id===`amd`&&(!pe.key_source||C)&&z(`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`)})]}),pe.key_source&&!C?z(`div`,{className:`settings-row`,children:[I(`input`,{className:`settings-input settings-key-masked`,readOnly:!0,value:Xq(pe,e),"aria-label":e(`settings.key.savedAria`,{name:pe.name})}),!M&&z(`button`,{type:`submit`,className:`btn-primary`,disabled:k!==null,children:[k===`connect`?I(La,{size:13,className:`spin`}):null,e(`settings.key.reconnect`)]}),(pe.key_source!==`environment`||pe.key_from_gaia_env)&&z(P.Fragment,{children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>w(!0),disabled:k!==null,children:e(`settings.key.replace`)}),pe.key_source!==`environment`&&I(`button`,{type:`button`,className:`btn-secondary settings-key-remove`,onClick:()=>E(!0),disabled:k!==null,"aria-label":e(`settings.key.remove`),title:e(`settings.key.remove`),children:I(Ss,{size:14,"aria-hidden":`true`})})]})]}):z(`div`,{className:`settings-row`,children:[I(`input`,{className:`settings-input`,type:`password`,autoComplete:`off`,spellCheck:!1,autoFocus:C,value:x,onChange:e=>S(e.target.value),placeholder:e(C?`settings.key.pasteNew`:`settings.key.paste`),"aria-label":e(`settings.key.fieldAria`,{name:pe.name})}),z(`button`,{type:`submit`,className:`btn-primary`,disabled:k!==null||!x,children:[k===`connect`?I(La,{size:13,className:`spin`}):null,e(C?`settings.key.save`:`settings.key.connect`)]}),C&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{S(``),w(!1)},disabled:k!==null,children:e(`settings.key.cancel`)})]}),pe.key_source&&!M&&!pe.error&&!C&&I(`p`,{className:`settings-hint`,children:e(`settings.key.notConnectedHint`,{name:pe.name})}),pe.error&&I(`p`,{className:`settings-error`,role:`alert`,children:pe.error})]}),A?.ok&&I(`p`,{className:`settings-ok`,role:`status`,children:A.text}),A&&!A.ok&&I(Fq,{message:A.text}),pe.known_models&&I(`p`,{className:`settings-hint`,role:`status`,children:e(`settings.key.knownList`,{name:pe.name})}),ze&&I(`div`,{className:`models-downloads-slot`,ref:ue}),M&&z(`div`,{className:`settings-field`,children:[I(`span`,{className:`settings-label`,children:e(`settings.model.models`)}),(p?.length??0)>6&&I(`input`,{className:`settings-input`,type:`search`,value:_,onChange:e=>v(e.target.value),placeholder:e(`settings.model.search`),"aria-label":e(`settings.model.search`)}),h&&!(c&&kq(h))&&I(Fq,{message:h}),!p&&!h&&z(`p`,{className:`settings-hint`,children:[I(La,{size:13,className:`spin`}),` `,e(`settings.loading`)]}),p&&ke.length===0&&!h&&I(`p`,{className:`settings-hint`,children:e(Le||!ze?`settings.model.noMatch`:`settings.model.noModels`)}),ze?z(P.Fragment,{children:[Be.length>0&&I(oq,{title:e(`settings.model.groupDownloaded`),count:Be.length,defaultOpen:!0,forceOpen:Le,targetId:`models-on-pc`,children:I(`ul`,{className:`model-list`,children:Be.map(qe)})}),He.length>0&&I(oq,{title:e(`settings.model.groupAvailable`),count:He.length,defaultOpen:Be.length===0,forceOpen:Le||j||He.some(Fc),children:I(`ul`,{className:`model-list`,children:He.map(qe)})})]}):I(`ul`,{className:`model-list`,children:Ne.map(qe)}),je&&Pe.length>0&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>b(!0),children:e(`settings.model.showAll`)}),d===`fireworks`&&y&&!Le&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>b(!1),children:e(`settings.model.showRecommended`)}),Fe.length>0&&I(oq,{title:e(`settings.model.groupUnavailable`),count:Fe.length,forceOpen:Le,children:I(`ul`,{className:`model-list`,children:Fe.map(qe)})})]}),ze&&M&&I(oq,{title:e(`settings.custom.title`),children:I(Iq,{onAdded:e=>void Te(e)})}),ze&&M&&I(zq,{downloadsSlot:le}),pe.remote&&I(Jq,{})]}),Ge&&I(OG,{title:e(`settings.models.removeTitle`,{name:Ie[Ge.id]??Ge.id}),confirmLabel:Ge.downloaded?e(`settings.model.removeDownload`):e(`settings.models.remove`),cancelLabel:e(`settings.models.keep`),danger:!0,onConfirm:()=>{ae(null),we(Ge.id)},onCancel:()=>ae(null),children:Ge.downloaded&&I(`p`,{children:e(`settings.model.removeDownloadBody`)})}),T&&pe&&I(OG,{title:e(`settings.key.removeAsk`),confirmLabel:e(`settings.key.remove`),cancelLabel:e(`settings.models.keep`),danger:!0,onConfirm:()=>void xe(),onCancel:()=>E(!1),children:I(`p`,{children:e(`settings.key.removeBody`,{name:pe.name})})})]})}function Qq(){let e=R(),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 yt();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(()=>Ln(e))},[d]),p=()=>{i===`full_access`?f(`ask`):s(e=>!e)},m=e=>t.find(t=>t.id===e)?.title??e;return z(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.permissions`)}),I(`p`,{className:`settings-pane-lede`,children:e(`settings.permissions.lede`)}),z(`details`,{className:`settings-more`,children:[z(`summary`,{children:[I(Gr,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,e(`settings.model.howItWorks`)]}),I(`p`,{className:`settings-hint`,children:e(`settings.permissions.perChat`)})]}),z(`section`,{className:`settings-card`,"aria-label":e(`settings.permissions.newChats`),children:[z(`label`,{className:`setting-row`,children:[I(`span`,{className:`settings-label`,children:e(`settings.permissions.fullAccess`)}),z(`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&&z(`div`,{className:`settings-warning`,role:`alert`,children:[I(`p`,{children:e(`settings.permissions.warning`)}),z(`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(oq,{title:e(`settings.permissions.chats`),count:n.length,defaultOpen:!0,children:n.map(t=>z(`section`,{className:`settings-field permission-chat`,"aria-label":m(t.session_id),children:[z(`div`,{className:`settings-row settings-row-between`,children:[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 kt(t.session_id,`ask`)).mode;gR(t.session_id,e)}),children:e(`settings.permissions.turnOff`)})]}),t.grants.length>0&&I(`ul`,{className:`grant-list`,children:t.grants.map(n=>z(`li`,{className:`grant-row`,children:[I(`code`,{children:n.label}),I(`button`,{type:`button`,className:`link-btn`,onClick:()=>d(()=>Tt(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(()=>Tt(t.session_id)),children:e(`settings.permissions.revokeAll`)})]},t.session_id))})]})}var $q=(e,t)=>!e.error&&(!e.installed||e.update)&&(t||!e.has_code);function eJ(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 tJ({onAdded:e}){let t=R(),[n,r]=(0,V.useState)(``),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(null),[d,f]=(0,V.useState)(new Set),[p,m]=(0,V.useState)(!1),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)([]);(0,V.useEffect)(()=>{let e=!1;return jt().then(t=>{e||v(t.libraries)}).catch(n=>{e||s(t(`settings.skills.link.featuredFailed`,{error:CM(n,t)}))}),()=>{e=!0}},[t]);let y=async e=>{if(e.trim()){a(`preview`),s(null),l(null),g(null);try{let t=await rn(e.trim());l(t),f(new Set(t.skills.filter(e=>$q(e,!1)).map(e=>e.name)))}catch(e){s(CM(e,t))}finally{a(null)}}},b=async()=>{if(c&&d.size!==0){a(`add`),s(null);try{let t=await bt(c.link,[...d],p,c.pin);g(t),l(null),r(``),t.added.length&&e()}catch(e){s(CM(e,t))}finally{a(null)}}},x=e=>f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),S=e=>{if(m(e),!e&&c){let e=new Set(c.skills.filter(e=>e.has_code).map(e=>e.name));f(t=>new Set([...t].filter(t=>!e.has(t))))}},C=c?.skills.filter(e=>$q(e,p))??[],w=C.length>0&&C.every(e=>d.has(e.name)),T=c?.skills.some(e=>e.has_code&&!e.error)??!1;return z(`div`,{className:`settings-card skill-link`,children:[z(`div`,{className:`skill-link-top`,children:[I(`span`,{className:`settings-label`,children:t(`settings.skills.link.title`)}),_.map(e=>{let n=`settings.skills.link.featured.${e.id}`,a=ae(n);return I(`button`,{type:`button`,className:`btn-secondary skill-link-chip`,onClick:()=>{r(e.url),y(e.url)},disabled:i!==null,title:a?t(n):e.description,"aria-label":t(`settings.skills.link.getAria`,{name:e.name,description:a?u(n):e.description}),children:t(`settings.skills.link.get`,{name:e.name})},e.id)})]}),z(`form`,{className:`skill-link-form`,onSubmit:e=>{e.preventDefault(),y(n)},children:[I(`input`,{className:`settings-input`,type:`text`,inputMode:`url`,value:n,onChange:e=>r(e.target.value),onPaste:e=>{let t=e.clipboardData.getData(`text`).trim();t&&(e.preventDefault(),r(t),y(t))},placeholder:t.bare(`settings.skills.link.placeholder`),title:t(`settings.skills.link.hint`),"aria-label":t(`settings.skills.link.aria`),disabled:i!==null}),I(`button`,{type:`submit`,className:`btn-secondary`,disabled:!n.trim()||i!==null,children:i===`preview`?z(P.Fragment,{children:[I(La,{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&&z(`div`,{className:`skill-link-preview`,children:[z(`details`,{className:`skill-link-warning`,role:`note`,children:[z(`summary`,{children:[I(ws,{size:14,"aria-hidden":`true`}),t(`settings.skills.link.trust`)]}),I(`p`,{children:I(`bdi`,{children:c.warning})})]}),z(`div`,{className:`skill-link-head`,children:[I(`span`,{children:t(`settings.skills.link.found`,{n:c.skills.length,source:c.source})}),C.length>1&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>f(w?new Set:new Set(C.map(e=>e.name))),children:t(w?`settings.skills.link.none`:`settings.skills.link.all`)})]}),I(`ul`,{className:`skill-list skill-link-list`,children:c.skills.map(e=>{let n=$q(e,p),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&&!p;return I(`li`,{className:`skill-row`,children:z(`label`,{className:`skill-link-pick`,children:[I(`input`,{type:`checkbox`,checked:n&&d.has(e.name),disabled:!n,onChange:()=>x(e.name),"aria-label":t(`settings.skills.link.addAria`,{name:e.name})}),z(`span`,{className:`skill-row-text`,children:[z(`span`,{className:`skill-row-name`,children:[e.name,r&&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(`span`,{className:`skill-row-desc skill-link-desc`,dir:`auto`,title:e.description,children:I(`bdi`,{children:e.description})}),e.permissions.length>0?z(`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=>z(`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&&z(`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&&!p&&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)})}),z(`div`,{className:`skill-link-actions`,children:[T&&z(`label`,{className:`skill-link-code`,title:t(`settings.skills.link.codeHint`),children:[I(`input`,{type:`checkbox`,checked:p,onChange:e=>S(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 b(),disabled:d.size===0||i!==null,children:i===`add`?z(P.Fragment,{children:[I(La,{size:13,className:`spin`}),` `,t(`settings.skills.link.adding`)]}):t(`settings.skills.link.add`,{n:d.size})})]})]}),h&&z(`div`,{className:`skill-link-result`,role:`status`,children:[h.added.length>0&&I(`p`,{children:eJ(h,t)}),Object.keys(h.failed).length>0&&z(`details`,{children:[I(`summary`,{children:t(`settings.skills.link.notAdded`,{n:Object.keys(h.failed).length})}),I(`ul`,{className:`grant-list`,children:Object.entries(h.failed).map(([e,t])=>z(`li`,{children:[I(`bdi`,{children:I(`strong`,{children:e})}),` — `,I(`bdi`,{children:t})]},e))})]})]})]})}var nJ={path:`~/.gaia/skills`},rJ=[{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:nJ},{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 iJ(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 aJ({text:e}){let t=R(),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]),z(P.Fragment,{children:[I(`span`,{ref:n,className:`skill-row-desc${r?` is-open`:``}${a||r?` is-toggle`:``}`,dir:`auto`,onClick:a||r?()=>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 oJ({onUseSkill:e}){let t=R(),[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)({}),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(``),u=(0,V.useRef)(null),d=(0,V.useRef)(!0),f=(0,V.useCallback)(()=>{Ut().then(e=>{d.current&&(r(e.skills),a(e.invalid),s(null))}).catch(e=>{d.current&&s(e instanceof Error?e.message:String(e))})},[]);(0,V.useEffect)(()=>(d.current=!0,f(),window.addEventListener(`focus`,f),()=>{d.current=!1,window.removeEventListener(`focus`,f)}),[f]);let p=c.trim().toLowerCase(),m=(n??[]).filter(e=>!p||e.name.toLowerCase().includes(p)||e.description.toLowerCase().includes(p)),h=n?.every(e=>rJ.some(t=>t.source===e.source))??!1,g=n=>z(`li`,{className:`skill-row`,children:[z(`div`,{className:`skill-row-text`,children:[z(`span`,{className:`skill-row-name`,children:[I(`span`,{title:n.version?`v${n.version}`:void 0,children:n.name}),n.always_on&&z(`span`,{className:`skill-row-meta`,children:[` · `,t(`settings.skills.alwaysOn`)]})]}),I(aJ,{text:n.description})]}),!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.name);return z(`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`)}),z(`details`,{className:`settings-more`,children:[z(`summary`,{children:[I(Gr,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,t(`settings.model.howItWorks`)]}),I(`p`,{className:`settings-hint`,children:t(`settings.skills.how`,nJ)})]}),I(tJ,{onAdded:f}),o&&I(`p`,{className:`settings-error`,role:`alert`,children:o}),!n&&!o&&z(`p`,{className:`settings-hint`,children:[I(La,{size:13,className:`spin`}),` `,t(`settings.loading`)]}),n&&n.length>6&&I(`input`,{ref:u,className:`settings-input`,type:`search`,value:c,onChange:e=>l(e.target.value),placeholder:t(`settings.skills.search`),"aria-label":t(`settings.skills.search`)}),n&&n.length===0&&I(`p`,{className:`settings-hint`,children:t(`settings.skills.none`)}),p&&n&&n.length>0&&m.length===0&&z(`p`,{className:`settings-hint`,role:`status`,children:[t(`settings.skills.noMatch`,{query:c.trim()}),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>{l(``),u.current?.focus()},children:t(`settings.skills.clearSearch`)})]}),h?rJ.map(e=>{let n=m.filter(t=>t.source===e.source);return n.length===0&&(p||!e.empty)?null:I(oq,{title:t(e.title),count:n.length,hint:t(e.note,e.params),defaultOpen:e.source===`agent-bundled`||e.source===`user`&&n.length>0,forceOpen:!!p,children: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(g)})})},e.source)}):I(`ul`,{className:`skill-list`,children:m.map(g)}),Object.keys(i).length>0&&z(`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(iJ(n),{name:e.split(/[\\/]/).filter(Boolean).pop()??e})},e))})]})]})}var sJ=`profile`;function cJ(){let e=R(),[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)(()=>{kU().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 AU(e===sJ?null:e);n(t),c(t.changed!==!1)}catch(e){i(e instanceof Error?e.message:String(e)),await kU().then(n).catch(()=>void 0)}finally{o(!1)}},[]);if(!t)return r?I(`p`,{className:`settings-error`,role:`alert`,children:r}):z(`p`,{className:`settings-hint`,children:[I(La,{size:13,className:`spin`}),` `,e(`settings.memory.embedder.checking`)]});let u=t.options.find(e=>e.device===t.device),d=t=>e.bare(t===`npu`?`settings.memory.embedder.npu`:`settings.memory.embedder.gpu`);return z(P.Fragment,{children:[z(`div`,{className:`model-in-use-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`embedder-device`,children:e(`settings.memory.embedder.label`)}),z(`select`,{id:`embedder-device`,className:`settings-input`,value:t.chosen?t.device:sJ,onChange:e=>void l(e.target.value),disabled:a,children:[I(`option`,{value:sJ,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))]})]}),z(`span`,{className:`settings-hint`,children:[e(`settings.memory.embedder.runsOn`,{name:he(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&&z(`span`,{className:`settings-hint`,children:[I(La,{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 lJ(){let e=R(),t=B(e=>e.setShowMemoryDashboard),n=B(e=>e.closeSettings),[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(!1);(0,V.useEffect)(()=>{DU().then(i).catch(e=>o(e instanceof Error?e.message:String(e)))},[]);let l=(0,V.useCallback)(async()=>{if(r){c(!0),o(null);try{i(await OU({memory_enabled:!r.memory_enabled}))}catch(e){o(e instanceof Error?e.message:String(e))}finally{c(!1)}}},[r]);return z(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.memory`)}),I(`p`,{className:`settings-pane-lede`,children:e(`settings.memory.lede`)}),z(`section`,{className:`settings-card`,"aria-label":e(`settings.section.memory`),children:[z(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`settings.memory.remember`)}),z(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,checked:!!r?.memory_enabled,onChange:()=>void l(),disabled:!r||s,"aria-label":e(`settings.memory.remember`)}),I(`span`,{className:`toggle-track`})]})]}),a&&I(`p`,{className:`settings-error`,role:`alert`,children:a}),z(`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(`section`,{className:`settings-card`,"aria-label":e(`settings.memory.embedder.label`),children:I(cJ,{})})]})}function uJ(e,t,n){if(!/^\d+$/.test(e.trim()))return!1;let r=Number(e);return r>=t&&r<=n}function dJ(e){return e<1048576?`${Math.ceil(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function fJ(){let e=R(),[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)(()=>{ue().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=!uJ(r,1,365)||d.days,m=!uJ(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 Oe(Number(r),Number(a));n(t),c({ok:!0,text:e(`settings.undo.saved`)})}catch(t){let n=t instanceof Nt&&t.httpStatus===422?t.fields:[],r=n.includes(`retention_days`),i=n.includes(`max_mb`);r||i?(f({days:r,mb:i}),c({ok:!1,text:e(`settings.undo.fix`)})):c({ok:!1,text:t instanceof Error?t.message:String(t)})}finally{u(!1)}}};return z(`div`,{className:`settings-field`,"aria-label":e(`settings.privacy.undo`),children:[I(`span`,{className:`settings-label`,children:e(`settings.privacy.undo`)}),I(`p`,{className:`settings-hint`,children:e(`settings.undo.hint`)}),t&&z(P.Fragment,{children:[z(`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`)}),z(`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`)}),z(`div`,{className:`setting-row setting-row-path`,children:[I(`span`,{children:e(`settings.undo.inUse`)}),z(`span`,{children:[e.plural(`settings.undo.used`,t.turns,{size:dJ(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 pJ={root:`settings-report`,button:`btn-secondary`,hint:`settings-hint`,error:`settings-error`};function mJ(){let e=R(),t=B(e=>e.sessions),n=B(e=>e.removeSession),r=Tc(),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 Je().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=_c.getState().active?.model,r=!t;f(r),m(!0),g(null);try{let t=await xe({network_policy:r?`local_ai_only`:`cloud_allowed`});f(t.network_policy===`local_ai_only`),vc(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 $t(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 Vn(e.id),n(e.id)}catch(t){r.push(`${e.title}: ${t instanceof Error?t.message:t}`)}c(!1),o(null),u(r.length?{ok:!1,text:e(`settings.privacy.deleteFailed`,{n:r.length,reason:r.join(`; `)})}:{ok:!0,text:e(`settings.privacy.deleted`)})},[n,t,e]);return z(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.privacy`)}),z(`section`,{className:`settings-card`,"aria-label":e(`settings.privacy.localOnlyTitle`),children:[z(`div`,{children:[z(`label`,{className:`setting-row`,children:[I(`strong`,{children:e(`settings.privacy.localOnlyTitle`)}),z(`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})]}),z(`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&&z(`div`,{className:`setting-row setting-row-path`,children:[I(`span`,{children:e(`settings.privacy.dataFolder`)}),z(`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`)})]})]})]}),z(`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(wN,{classes:pJ})]}),I(oq,{title:e(`settings.privacy.undo`),children:I(fJ,{})}),z(`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&&z(OG,{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 hJ=[{id:`needs_approval`,label:`settings.alerts.approval`},{id:`question`,label:`settings.alerts.question`},{id:`finished`,label:`settings.alerts.finished`}],gJ=[{value:`banner`,label:`settings.alerts.banner`},{value:`badge`,label:`settings.alerts.badge`},{value:`off`,label:`settings.alerts.off`}],_J=[0,10,20,30,50];function vJ(){return typeof Notification>`u`?`unsupported`:Notification.permission}function yJ(){let e=R(),t=kl(),n=!!window.gaiaAPI,[r,i]=(0,V.useState)(vJ),a=Object.values(t.modes).includes(`banner`);return z(`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`)}),z(`section`,{className:`settings-card`,"aria-label":e(`settings.alerts.when`),children:[hJ.map(n=>z(`div`,{className:`setting-row`,children:[I(`span`,{id:`alert-${n.id}`,children:e(n.label)}),I(Fz,{className:`segmented`,"aria-labelledby":`alert-${n.id}`,children:gJ.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(vJ())})},children:e(`settings.alerts.allow`)}):I(`p`,{className:`settings-error`,role:`alert`,children:e(r===`unsupported`?`settings.alerts.unsupported`:`settings.alerts.blocked`)})),z(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`settings.alerts.sound`)}),z(`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&&z(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`settings.alerts.flash`)}),z(`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`})]})]})]}),z(`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?z(P.Fragment,{children:[z(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`settings.alerts.keepAwake`)}),z(`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`})]})]}),z(`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:_J.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 bJ=[50,75,100,125,150,175,200],xJ=[{accent:`american`,gender:`female`},{accent:`american`,gender:`male`},{accent:`british`,gender:`female`},{accent:`british`,gender:`male`}],SJ=`settings:preview`,CJ=`Hello, I'm GAIA. This is how I'll read my replies to you.`;function wJ(e){return e instanceof Nt?e.detail||e.message:String(e)}function TJ(){let e=R(),t=iN(e=>e.settings),n=iN(e=>e.setSettings),r=iN(e=>e.read),i=iN(e=>e.stop),a=iN(e=>e.messageId===SJ),o=iN(e=>e.messageId===SJ&&e.status===`loading`),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(null),[d,f]=(0,V.useState)(!1);(0,V.useEffect)(()=>{GM().then(n).catch(e=>c(wJ(e)))},[n]);let p=e=>{f(!0),u(null),iN.getState().messageId===SJ&&i(),KM(e).then(n).catch(e=>u(wJ(e))).finally(()=>f(!1))};return s?z(`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?z(`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`)}),z(`div`,{className:`settings-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`read-aloud-voice`,children:e(`readAloud.settings.voice`)}),z(`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:xJ.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}`))}),z(`button`,{type:`button`,className:`btn-secondary`,"aria-pressed":a,disabled:d,onClick:()=>a?i():void r(SJ,CJ),children:[o?I(La,{size:13,className:`spin`}):I(a?vs:As,{size:13}),e(a?`readAloud.stop`:`readAloud.settings.preview`)]})]}),I(`span`,{className:`settings-hint`,children:e(`readAloud.settings.englishOnly`)}),I(sN,{messageId:SJ})]}),z(`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:(bJ.includes(t.speed)?bJ:[...bJ,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))})]}),z(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`readAloud.settings.auto`)}),z(`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})})]}):z(`p`,{className:`settings-hint`,children:[I(La,{size:13,className:`spin`}),` `,e(`settings.loading`)]})}function EJ(){let e=R(),t=B(e=>e.jumpToSetting),n=B(e=>e.closeSettings),r=B(e=>e.runSetupAgain),i=_c(e=>e.active),a=B(e=>e.systemStatus?.lemonade_running===!1),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(null),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(!1);(0,V.useEffect)(()=>{qe().then(s).catch(e=>g(e instanceof Error?e.message:String(e))),re().then(l).catch(e=>g(e instanceof Error?e.message:String(e))),f().then(e=>d(e??null)).catch(e=>m(e instanceof Error?e.message:String(e)))},[]);let y=o?.catalog?.find(e=>e.id===o.chat_model.id),b=(i?.model?i.remote?i.label??xc(i.model):xc(i.model):null)??y?.name??null,x=(o?.catalog??[]).filter(e=>e.downloaded),S=x.reduce((e,t)=>e+(t.full_size_gb??0),0),C=[c?.gpu_name,c?.npu_detected?e(`setup.checks.npu`):null].filter(Boolean).join(` · `),w=HO(o?.system?.physical_memory,c?.ram_gb),T=w&&KO(e.locale,w),E=o?.capacity_gb==null?null:KO(e.locale,BO(o.capacity_gb)),D=E?T?e(`settings.setup.memoryOf`,{size:E,total:T}):e(`settings.setup.memoryFor`,{size:E}):T,O=[{title:e(`settings.setup.where`),rows:[{label:e(`settings.setup.chatRuns`),value:b,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:[C,D].filter(Boolean).join(` · `)||null},{label:e(`settings.setup.server`),value:o?.lemonade.mode===`external`?e(`settings.setup.serverYours`):e(`settings.setup.serverOwn`),section:`advanced`,target:`[data-settings-target="model-server"]`},{label:e(`setup.gpu.title`),value:null,section:`model`,target:`#settings-gpu-title`,provider:`local`,shown:!!u?.applies||!!p&&!kq(p)}]},{title:e(`setup.models.step`),rows:[{label:e(`settings.setup.models`),value:o?.catalog?e(`settings.setup.modelsValue`,{n:String(x.length),size:BO(S)}):null,section:`model`,target:`[data-settings-target="models-on-pc"]`,provider:`local`},{label:e(`settings.setup.context`),value:null,section:`model`,target:`#ctx-size`,shown:!!i?.model&&!i.remote&&i.downloaded!==!1}]},{title:e(`settings.setup.after`),rows:[{label:e(`settings.section.connectors`),value:null,section:`connectors`},{label:e(`settings.section.memory`),value:null,section:`memory`},{label:e(`settings.language`),value:null,section:`general`,target:`#ui-language`},{label:e(`settings.setup.signIn`),value:null,section:`general`,target:`#desktop-startOnLogin`,shown:!!window.gaiaAPI?.tray}]}];return z(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.setup`)}),I(`p`,{className:`settings-hint`,children:e(`settings.setup.lede`)}),z(`div`,{className:`settings-setup-status`,children:[z(`span`,{children:[I(`strong`,{children:e(a?`settings.setup.serverDown`:`settings.setup.ready`)}),b&&!a&&z(`span`,{className:`settings-hint`,children:[` `,I(`bdi`,{children:e(`settings.setup.running`,{name:b})})]})]}),I(`button`,{type:`button`,className:`btn-secondary`,"data-testid":`setup-run-again`,onClick:()=>v(!0),children:e(`settings.setup.runAgain`)})]}),h&&I(`p`,{className:`setup-error`,role:`alert`,children:h}),O.map(e=>z(`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=z(`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?z(`button`,{type:`button`,className:`settings-setup-row`,onClick:()=>t({section:r,target:e.target??`.settings-pane-title`,from:`setup`},e.provider),children:[n,I(Yr,{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)),_&&I(OG,{title:e(`settings.setup.confirmTitle`),confirmLabel:e(`settings.setup.confirmYes`),cancelLabel:e(`setup.again.notNow`),onConfirm:()=>{v(!1),n(),r(!0)},onCancel:()=>v(!1),children:I(`p`,{children:e(`settings.setup.confirmBody`)})})]})}var DJ=[{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 OJ(){let e=R(),t=B(e=>e.openSettings),n=`GAIA v0.27.0rc2`,[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 z(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.about`)}),z(`section`,{className:`settings-card`,"aria-labelledby":`about-version`,children:[z(`div`,{className:`settings-row settings-row-between`,children:[z(`span`,{children:[I(`strong`,{id:`about-version`,children:I(`bdi`,{dir:`ltr`,children:n})}),` `,I(`span`,{className:`beta-badge`,children:`BETA`})]}),z(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void c(),children:[I(r?Vr:hi,{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})]}),z(`section`,{className:`settings-card`,"aria-label":e(`settings.about.links`),children:[I(`ul`,{className:`settings-about-links`,children:DJ.map(t=>I(`li`,{children:z(`a`,{href:t.href,target:`_blank`,rel:`noopener noreferrer`,children:[e(t.label),` `,I(ji,{size:12,"aria-hidden":`true`})]})},t.href))}),z(`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 kJ=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(AJ,{variant:this.props.variant??`fill`,onRetry:()=>this.setState({hasError:!1})}):this.props.children}};function AJ({onRetry:e,variant:t}){let n=R();return z(`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`)}),z(`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 jJ=`modulepreload`,MJ=function(e,t){return new URL(e,t).href},NJ={},PJ=function(e){return e.pathname.endsWith(`.css`)},FJ=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},IJ=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=MJ(t,n);let r=s(t),i=PJ(r);return FJ(NJ,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`:jJ,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)})},LJ=(0,V.lazy)(()=>IJ(()=>import(`./ConnectorsPane-Dkat1zLC.js`).then(e=>({default:e.ConnectorsPane})),__vite__mapDeps([0,1,2,3]),import.meta.url)),RJ=(0,V.lazy)(()=>IJ(()=>import(`./MessagingSettings-DomiT2rX.js`).then(e=>({default:e.MessagingSettings})),__vite__mapDeps([4,1,2]),import.meta.url)),zJ=(0,V.lazy)(()=>IJ(()=>import(`./AutomationsSettings-4FWcRau9.js`).then(e=>({default:e.AutomationsSettings})),__vite__mapDeps([5,1,2]),import.meta.url)),BJ=(0,V.lazy)(()=>IJ(()=>import(`./AdvancedSettings-DHERtrno.js`).then(e=>({default:e.AdvancedSettings})),__vite__mapDeps([6,1,2]),import.meta.url)),VJ=[`general`,`setup`,`model`,`permissions`,`skills`,`connectors`,`messaging`,`automations`,`memory`,`notifications`,`voice`,`privacy`,`advanced`,`about`];function HJ({onUseSkill:e}){let t=R(),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(pt(c,i),on(o,c),lW(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=VJ.indexOf(n),i=e.key===`ArrowDown`?(t+1)%VJ.length:e.key===`ArrowUp`?(t-1+VJ.length)%VJ.length:e.key===`Home`?0:e.key===`End`?VJ.length-1:null;i!==null&&(e.preventDefault(),r(VJ[i]),o.current?.querySelector(`[data-section="${VJ[i]}"]`)?.focus())},d=(()=>{switch(n){case`general`:return I(Oq,{});case`setup`:return I(EJ,{});case`model`:return I(Zq,{});case`permissions`:return I(Qq,{});case`skills`:return I(oJ,{onUseSkill:t=>{i(),e(t)}});case`connectors`:return I(LJ,{});case`messaging`:return I(RJ,{});case`automations`:return I(zJ,{});case`memory`:return I(lJ,{});case`notifications`:return I(yJ,{});case`voice`:return I(TJ,{});case`privacy`:return I(mJ,{});case`advanced`:return I(BJ,{});case`about`:return I(OJ,{})}})();return I(`div`,{className:`settings-overlay`,onMouseDown:e=>{e.target===e.currentTarget&&i()},children:z(`div`,{ref:o,className:`settings-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`settings.title`),children:[z(`nav`,{className:`settings-nav`,"aria-label":t(`settings.sections`),onKeyDown:u,children:[I(`h1`,{className:`settings-nav-title`,children:t(`settings.title`)}),VJ.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))]}),z(`div`,{className:`settings-body`,children:[I(`button`,{type:`button`,className:`settings-close`,onClick:i,"aria-label":t(`settings.close`),children:I(Is,{size:18})}),l&&z(`button`,{type:`button`,className:`settings-back`,onClick:()=>{r(l),o.current?.querySelector(`[data-section="${l}"]`)?.focus()},children:[I(qr,{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(kJ,{area:`settings.${n}`,children:I(V.Suspense,{fallback:z(`p`,{className:`settings-hint`,children:[I(La,{size:13,className:`spin`}),` `,t(`settings.loading`)]}),children:d})},n)})]})]})})}var UJ=`gaia:personalize-connector`,WJ=[[`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 GJ(e,t){let n=e.toLowerCase().replace(/^mcp-/,``),r=WJ.find(([e])=>n.startsWith(e));return r?r[1]:`my recent activity in ${t}`}function KJ(e){let t=e.toLowerCase().replace(/^mcp-/,``),n=WJ.find(([e])=>t.startsWith(e));return n?n[0]:null}function qJ({connectorId:e,displayName:t}){return[`I just connected ${t}. Get to know me from ${GJ(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(`
|
|
212
|
+
`)}function JJ(e){window.dispatchEvent(new CustomEvent(UJ,{detail:e}))}var YJ=Ct((e,t)=>({lifecycle:null,restartError:null,apply:n=>{n.apiBase&&Dn(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 XJ(){let e=window.gaiaAPI?.backend;e&&e.getState().then(e=>YJ.getState().apply(e)).catch(e=>F.system.error(`Could not read the backend state from the desktop app`,e))}function ZJ(e){let t=window.gaiaAPI?.backend;if(!t)return()=>{};let n=t=>{let n=YJ.getState().lifecycle?.status;YJ.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 QJ(e,t){let[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(!1),[o,s]=(0,V.useState)(null),c=(0,V.useRef)(null),l=(0,V.useRef)(null),u=(0,V.useRef)(null),d=(0,V.useCallback)(()=>{c.current&&=(clearTimeout(c.current),null),l.current&&=(clearTimeout(l.current),null),u.current&&=(clearInterval(u.current),null)},[]);(0,V.useEffect)(()=>d,[d]);let f=(0,V.useCallback)((e,t)=>{u.current&&clearInterval(u.current),u.current=setInterval(async()=>{try{let n=await te();t===`load`?bc(n.model_loaded,e)&&(r(!1),c.current&&=(clearTimeout(c.current),null),u.current&&=(clearInterval(u.current),null)):(n.model_downloaded===!0||bc(n.model_loaded,e))&&(a(!1),l.current&&=(clearTimeout(l.current),null),u.current&&=(clearInterval(u.current),null))}catch{}},ru)},[]),p=e??`Gemma-4-E4B-it-GGUF`;return(0,V.useEffect)(()=>s(null),[p]),{isLoadingModel:n,isDownloadingModel:i,downloadError:o,loadModel:(0,V.useCallback)(async(e,n)=>{let i=e??p,a=n??t;r(!0);try{if(!await fn(i,a)){r(!1);return}F.system.info(`Load model triggered: ${i} (ctx=${a??`server default`})`),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>r(!1),tu),f(i,`load`)}catch(e){F.system.error(`Failed to trigger model load`,e),r(!1)}},[p,t,f]),downloadModel:(0,V.useCallback)(async(e=!1,t,n=!1)=>{let r=t??p;a(!0),s(null);try{await Ve(r,e,n),F.system.info(`Download model triggered: ${r} (force=${e})`),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>a(!1),nu),f(r,`download`)}catch(e){F.system.error(`Failed to trigger model download`,e),s(e instanceof Error?e.message:String(e)),a(!1)}},[p,f])}}function $J({onRetry:e,label:t,busyLabel:n=`Checking…`}){let[r,i]=(0,V.useState)(!1);return I(`button`,{className:`connection-banner__retry`,onClick:()=>{i(!0),Promise.resolve(e()).finally(()=>i(!1))},disabled:r,children:r?n:t})}function eY(e){return`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)}`}function tY({lifecycle:e}){let t=R(),n=YJ(e=>e.restart),r=YJ(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 z(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(La,{size:16,className:`connection-banner__spinner`})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[t(`banner.restarting`),` `,I(`bdi`,{dir:`ltr`,className:`connection-banner__timer`,children:eY(n)}),` `,I(`span`,{className:`connection-banner__hint`,children:t(`banner.restartingHint`)})]})]})}return z(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[I(`div`,{className:`connection-banner__icon`,children:I(ws,{size:16})}),z(`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($J,{onRetry:n,label:t(`banner.restartButton`),busyLabel:t(`banner.restartingShort`)})]})}function nY({onRetry:e,backendSlow:t=!1,backendError:n=null}){let r=R(),{backendConnected:i,systemStatus:a,currentSessionId:o,messages:s}=B(),c=YJ(e=>e.lifecycle),[l,u]=(0,V.useState)(!1),d=!!o&&s.length>0,f=a?.default_model_name??`Gemma-4-E4B-it-GGUF`,{isDownloadingModel:p,downloadError:m,downloadModel:h}=QJ(f),g=_c(e=>e.pickLoad),_=_c(e=>e.retryPickLoad),v=_c(e=>e.dismissPickLoad);yc();let y=(0,V.useRef)(a?.lemonade_running),b=(0,V.useRef)(a?.model_downloaded),x=(0,V.useRef)(a?.context_size_sufficient),S=(0,V.useRef)(a?.expected_model_loaded);(0,V.useEffect)(()=>{if(d)return;let e=a?.lemonade_running,t=a?.model_downloaded,n=a?.context_size_sufficient,r=a?.expected_model_loaded,i=!1;y.current!==e&&(y.current=e,e===!1&&(i=!0)),b.current!==t&&(b.current=t,t===!1&&(i=!0)),x.current!==n&&(x.current=n,n===!1&&(i=!0)),S.current!==r&&(S.current=r,r===!1&&(i=!0)),i&&u(!1)},[a,d]);let C=a?.download_progress??null,w=p||C?.state===`downloading`||C?.state===`starting`,T=B(e=>e.dismissDownloadFailure);if(c&&c.status!==`running`)return I(tY,{lifecycle:c});let E=C?.model_name||f,D=async()=>{try{await T(C?.model_name??E)}catch{}};if(w||C?.state===`error`){let e=C?.total_bytes?`${(C.total_bytes/1e9).toFixed(1)} GB`:`large download`,t=C?.state===`error`;return z(`div`,{className:`connection-banner ${t?`connection-banner--error`:`connection-banner--warning`}`,role:t?`alert`:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(t?ws:Ci,{size:16})}),I(`div`,{className:`connection-banner__text`,dir:`auto`,children:t?z(P.Fragment,{children:[`Download of `,I(`strong`,{children:E}),` failed.`,` `,(m??C?.message)&&I(`span`,{className:`connection-banner__hint`,children:m??C?.message})]}):z(P.Fragment,{children:[`Downloading `,I(`strong`,{children:E}),` (`,e,`).`,C?.state===`downloading`&&C.file&&z(P.Fragment,{children:[` `,z(`span`,{className:`connection-banner__hint`,children:[`File `,C.file_index,` / `,C.total_files,`: `,I(`code`,{children:C.file})]})]})]})}),t?I(`button`,{className:`connection-banner__retry`,onClick:()=>h(!1,E,!a?.model_loaded),children:`Retry`}):I(`span`,{className:`connection-banner__loading connection-banner__progress`,children:C&&C.state===`downloading`&&C.total_bytes>0?z(P.Fragment,{children:[I(`span`,{className:`connection-banner__progress-bar`,role:`progressbar`,"aria-valuenow":C.percent,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`Download progress`,children:I(`span`,{className:`connection-banner__progress-fill`,style:{width:`${C.percent}%`}})}),z(`span`,{className:`connection-banner__progress-label`,children:[C.percent,`% ·`,` `,(C.downloaded_bytes/1e9).toFixed(2),` /`,` `,(C.total_bytes/1e9).toFixed(2),` GB`]})]}):z(P.Fragment,{children:[I(La,{size:13,className:`connection-banner__spinner`}),C?.state===`starting`?C.message??`Starting download…`:`Downloading…`]})}),t&&I(`button`,{className:`connection-banner__dismiss`,onClick:()=>void D(),"aria-label":`Dismiss`,children:I(Is,{size:14})})]})}if(g){let e=xc(g.model);return g.error?z(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[I(`div`,{className:`connection-banner__icon`,children:I(ws,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.pickLoad.failed`,{model:e}),` `,I(`span`,{className:`connection-banner__hint`,dir:`auto`,children:g.error.key?r(g.error.key,{reason:g.error.reason}):g.error.reason})]}),I($J,{onRetry:_,label:r(`banner.pickLoad.retry`)}),I(`button`,{className:`connection-banner__dismiss`,onClick:v,"aria-label":r(`banner.dismiss`),children:I(Is,{size:14})})]}):z(`div`,{className:`connection-banner connection-banner--init`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(La,{size:16,className:`connection-banner__spinner`})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.pickLoad.loading`,{model:e}),` `,I(`bdi`,{dir:`ltr`,children:r(`banner.pickLoad.seconds`,{s:g.seconds})}),` `,I(`span`,{className:`connection-banner__hint`,children:r(`banner.pickLoad.canType`)})]})]})}if(hI(a)&&!t&&!n){let e=a?.init_tasks?.find(e=>e.status===`running`)?.step,t=`banner.boot.${e}`,n=e&&ae(t)?r(t):r(`banner.boot.generic`);return z(`div`,{className:`connection-banner connection-banner--init`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(La,{size:16,className:`connection-banner__spinner`})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[n,z(`span`,{className:`thinking-dots`,children:[I(`span`,{children:`.`}),I(`span`,{children:`.`}),I(`span`,{children:`.`})]})]})]})}if(l||d)return null;if(!i)return z(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[I(`div`,{className:`connection-banner__icon`,children:I(Ms,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.unreachable`),` `,I(`span`,{className:`connection-banner__hint`,children:r(`banner.unreachableHint`)})]}),e&&I($J,{onRetry:e,label:`Retry`})]});if(n)return z(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(ws,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[`GAIA's backend answered with an error (`,n,`).`,` `,I(`span`,{className:`connection-banner__hint`,children:`It may be overloaded. GAIA keeps checking; if it lasts, restart GAIA.`})]}),e&&I($J,{onRetry:e,label:`Check again`})]});if(t)return z(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(ws,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[`GAIA is slow to answer.`,` `,I(`span`,{className:`connection-banner__hint`,children:`It may be busy with another chat or app. GAIA keeps checking.`})]}),e&&I($J,{onRetry:e,label:`Check again`})]});if(a?.config_error)return z(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[I(`div`,{className:`connection-banner__icon`,children:I(ws,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[`GAIA settings could not be loaded.`,` `,I(`span`,{className:`connection-banner__hint`,children:a.config_error})]}),e&&I($J,{onRetry:e,label:`Check again`})]});if(a&&!a.lemonade_running){let t=gI(a)===`unresponsive`,n=!t&&Nq(a),i=t&&Aq(a.start_command)?null:a.start_command,o=t&&Aq(a.start_instruction)?null:a.start_instruction;return z(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(ws,{size:16})}),z(`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?z(`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:Mq(r,o)})]}),n&&I(Pq,{className:`connection-banner__retry`}),e&&I($J,{onRetry:e,label:r(`settings.key.checkAgain`)}),I(`button`,{className:`connection-banner__dismiss`,onClick:()=>u(!0),"aria-label":`Dismiss`,children:I(Is,{size:14})})]})}if(a&&a.lemonade_running&&a.model_loaded&&a.context_size_sufficient===!1){let t=a.model_context_size??0;return z(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(Ta,{size:16})}),z(`div`,{className:`connection-banner__text`,dir:`auto`,children:[`LLM context window is too small (`,t.toLocaleString(),` tokens;`,` `,$l.toLocaleString(),` required).`,` `,I(`span`,{className:`connection-banner__hint`,children:`Reload it with a larger context in Settings → Advanced.`})]}),e&&I($J,{onRetry:e,label:`Check again`}),I(`button`,{className:`connection-banner__dismiss`,onClick:()=>u(!0),"aria-label":`Dismiss`,children:I(Is,{size:14})})]})}return null}var rY=`https://github.com/amd/gaia/releases`;function iY(){let e=hq(),t=R(),[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(null),o=(0,V.useCallback)(e=>{let n=pq();n&&(a(null),n[e]().catch(n=>{F.system.error(`Update ${e} failed`,n),a(yq(n,t))}))},[t]);if(n)return null;let s=e.installFailed?t(`update.chip.installFailedDetail`,e.installFailed):null,c=e.status===`downloading`||e.status===`downloaded`;if(e.startFailed&&e.previousVersion&&!c)return z(`div`,{className:`update-chip update-chip--error`,role:`status`,children:[I(ws,{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(Is,{size:11})})]});let l=e.status===`available`||e.status===`downloaded`;if(s&&!l)return z(`div`,{className:`update-chip update-chip--error`,role:`status`,title:s??void 0,children:[I(ws,{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(Is,{size:11})})]});if(e.status===`idle`||e.status===`checking`||e.status===`disabled`||e.status===`no-channel`)return null;if(e.status===`downloading`){let n=Math.max(0,Math.min(100,e.progress));return z(`div`,{className:`update-chip update-chip--downloading`,role:`status`,"aria-live":`polite`,title:t(`update.chip.downloadingTitle`,{version:e.version??``}),children:[I(Ci,{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`?z(`div`,{className:`update-chip update-chip--available`,role:`status`,title:e.manualInstall?t(`update.chip.manualTitle`,{version:e.version??``}):i||s||e.releaseNotes||t(`update.chip.availableTitle`),children:[I(Ci,{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??rY,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(Is,{size:11})})]}):e.status===`downloaded`?z(`div`,{className:`update-chip update-chip--ready`,role:`status`,"aria-live":`polite`,children:[I(Po,{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`?z(`div`,{className:`update-chip update-chip--error`,role:`status`,title:e.error||t(`update.chip.checkFailed`),children:[I(ws,{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(Is,{size:11})})]}):null}var aY={permission_request:{icon:I(ns,{size:16}),colorClass:`notif-type-permission`},policy_alert:{icon:I(ns,{size:16}),colorClass:`notif-type-policy`},security_alert:{icon:I(ws,{size:16}),colorClass:`notif-type-security`},status_change:{icon:I($r,{size:16}),colorClass:`notif-type-status`},info:{icon:I(ya,{size:16}),colorClass:`notif-type-info`},error:{icon:I(ri,{size:16}),colorClass:`notif-type-error`}};function oY(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(Sn(t),{month:`short`,day:`numeric`})}function sY({onClose:e,onOpenChat:t}){let n=R(),r=_l(Us(yl)),i=_l(vl),a=_l(e=>e.markRead),o=_l(e=>e.markAllRead),s=_l(e=>e.clearAll),c=_l(e=>e.dismiss),l=_l(e=>e.respondToPermission),u=_l(e=>e.typeFilter),d=_l(Us(bl)),f=_l(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]);pt(!0,e);let g=[{key:null,label:n(`notifications.filter.all`)},{key:`permission_request`,label:n(`notifications.filter.permissions`)},{key:`policy_alert`,label:n(`notifications.filter.policy`)},{key:`error`,label:n(`notifications.filter.errors`)},{key:`security_alert`,label:n(`notifications.filter.security`)},{key:`status_change`,label:n(`notifications.filter.status`)},{key:`info`,label:n(`notifications.filter.info`)}].filter(e=>e.key===null||e.key===u||d.includes(e.key)),_=g.length>2||u!==null;return z(`div`,{className:`notification-center`,role:`dialog`,"aria-label":n(`notifications.dialogAria`),children:[z(`div`,{className:`notification-center-header`,children:[z(`div`,{className:`notification-center-title-row`,children:[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(Is,{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?z(`div`,{className:`notification-empty`,children:[I(Tr,{size:40,strokeWidth:1.2}),I(`span`,{children:n(`notifications.empty`)})]}):r.map(e=>{let t=aY[e.type],r=e.type===`permission_request`&&e.tool?cl(e,n,Ic):null;return z(`div`,{className:`notification-item ${e.read?``:`unread`} ${t.colorClass}`,id:e.type===`policy_alert`&&e.receiptId?`policy-receipt-${encodeURIComponent(e.receiptId)}`:void 0,onClick:()=>p(e),role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&p(e)},children:[!e.read&&I(`span`,{className:`notification-unread-dot`}),I(`span`,{className:`notification-icon`,children:t.icon}),z(`div`,{className:`notification-content`,children:[z(`div`,{className:`notification-content-header`,children:[I(`span`,{className:`notification-agent`,dir:`auto`,children:e.agentName}),I(`span`,{className:`notification-time`,children:oY(e.timestamp,n)})]}),r?z(P.Fragment,{children:[I(`span`,{className:`notification-title`,children:I(zc,{text:r.heading})}),I(`span`,{className:`notification-message`,dir:`auto`,children:I(zc,{text:r.question})})]}):z(P.Fragment,{children:[e.title&&I(`span`,{className:`notification-title`,children:e.title}),I(`span`,{className:`notification-message`,dir:`auto`,children:e.message})]}),e.type===`policy_alert`&&z(`div`,{className:`notification-policy-details`,children:[e.tool&&z(`span`,{className:`notification-tool`,children:[n(`activity.policy.tool`),`: `,I(`code`,{dir:`ltr`,children:e.tool})]}),e.reason&&z(`span`,{className:`notification-policy-reason`,children:[n(`notifications.reason`),`: `,e.reason]}),e.ruleIds&&e.ruleIds.length>0&&z(`span`,{className:`notification-tool`,children:[n(`activity.policy.rules`),`: `,I(`code`,{dir:`ltr`,children:e.ruleIds.join(`, `)})]}),e.policyVersion&&z(`span`,{className:`notification-tool`,children:[n(`activity.policy.policy`),`: `,I(`code`,{dir:`ltr`,children:e.policyVersion})]}),z(`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&&z(`div`,{className:`notification-actions`,children:[z(`button`,{className:`notification-action-btn notification-action-allow`,onClick:t=>{t.stopPropagation(),m(e)},children:[I(Vr,{size:14}),n(`notifications.approve`)]}),z(`button`,{className:`notification-action-btn notification-action-deny`,onClick:t=>{t.stopPropagation(),h(e)},children:[I(Is,{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(Is,{size:14})})]},e.id)})}),r.length>0&&z(`div`,{className:`notification-center-footer`,children:[z(`button`,{className:`notification-footer-btn`,onClick:o,disabled:i===0,children:[I(Vr,{size:14}),n(`notifications.markAllRead`)]}),z(`button`,{className:`notification-footer-btn notification-footer-clear`,onClick:s,children:[I(Ss,{size:14}),n(`notifications.clear`)]})]})]})}var cY=1500,lY=e=>new Promise(t=>setTimeout(t,e));async function uY({onProgress:e,isCancelled:t=()=>!1,pollMs:n=cY}={}){try{await ft(bO)}catch(e){if(e?.httpStatus!==409)throw e;let t=await C(bO).catch(()=>null);if(!t||t.status===`completed`||t.status===`failed`)throw e}for(;!t();){let t=await C(bO);if(e?.(t),t.status===`completed`)return;if(t.status===`failed`)throw Error(t.error||`The GAIA agent could not be installed.`);await lY(n)}}function dY({onInstalled:e,noBuild:t=!1}){let n=R(),[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 uY({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`)})}):z(`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`)})]})}async function fY(){return An(`GET`,`/schedules`)}function pY(){return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}async function mY(e,t,n){return An(`POST`,`/schedules`,{name:e,interval:t,prompt:n,timezone:pY()})}async function hY(e,t,n){return An(`PATCH`,`/schedules/${encodeURIComponent(e)}`,{interval:t,prompt:n,timezone:pY()})}async function gY(e,t){return An(`PUT`,`/schedules/${encodeURIComponent(e)}`,{status:t})}async function _Y(e){return An(`POST`,`/schedules/${encodeURIComponent(e)}/run`)}async function vY(e){return An(`DELETE`,`/schedules/${encodeURIComponent(e)}`)}async function yY(e,t=20){return An(`GET`,`/schedules/${encodeURIComponent(e)}/results?limit=${t}`)}async function bY(e){return An(`POST`,`/schedules/parse`,{input:e,timezone:pY()})}function xY(e){return e.replace(/^\s*(```|~~~).*$/gm,``).replace(/!?\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/`([^`]+)`/g,`$1`).replace(/\*\*(.+?)\*\*/g,`$1`).replace(/(^|[^\w])__(?=\S)(.+?\S)__(?![\w.])/g,`$1$2`).replace(/(^|[^\w*])\*(?!\s)(.*?\S)\*(?!\w)/g,`$1$2`).replace(/(^|[^\w])_(?![\s_])(.+?)_(?!\w)/g,`$1$2`).replace(/^\s{0,3}(#{1,6}\s+|>\s?|[-*+]\s+)/gm,``).replace(/\s+/g,` `).trim()}function SY(e,t){if(!(e instanceof Error))return t;let n=e.message,r=n.match(/API \d+: (.+)/);if(r)try{let e=JSON.parse(r[1]);if(e.detail)return e.detail}catch{}return n}var CY=`gaia-schedule-announced-errors`;function wY(){let e;try{e=localStorage.getItem(CY)}catch(e){return F.system.warn(`Announced schedule failures unreadable; failures from before launch may be announced again. localStorage is blocked -- check private-browsing or site-data settings.`,e),{}}if(!e)return{};try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return Object.fromEntries(Object.entries(t).filter(([,e])=>typeof e==`number`));F.system.warn(`Ignored malformed "${CY}"; failures from before launch may be announced again.`)}catch(e){F.system.warn(`"${CY}" is corrupt; failures from before launch may be announced again.`,e)}return{}}function TY(e){try{localStorage.setItem(CY,JSON.stringify(e))}catch(e){F.system.warn(`Announced schedule failures not saved; they may be announced again on the next launch. localStorage is blocked -- check private-browsing or site-data settings.`,e)}}function EY(e,t){let{addNotification:n}=_l.getState();for(let r of t)r.error_count<=(e[r.id]??0)||!r.last_error||n({id:`schedule-error-${r.id}-${r.error_count}`,type:`error`,agentId:`scheduler`,agentName:`GAIA`,title:Ht()(`schedules.failed`,{name:r.name}),message:r.last_error,timestamp:Date.now(),read:!1,dismissed:!1,priority:`high`,...r.session_id?{sessionId:r.session_id}:{}})}function DY(e){return e.run_count-+!!e.running}function OY(e,t,n){let{addNotification:r}=_l.getState();for(let i of n){let n=DY(i);n<=(t[i.id]??0)||i.error_count>(e[i.id]??0)||r({id:`schedule-done-${i.id}-${n}`,type:`info`,agentId:`scheduler`,agentName:`GAIA`,title:Ht()(`schedules.finished`,{name:i.name}),message:xY(i.last_result??``),timestamp:Date.now(),read:!1,dismissed:!1,priority:`medium`,...i.session_id?{sessionId:i.session_id}:{}})}}var kY=Ct((e,t)=>({schedules:[],loading:!1,error:null,actionError:null,selectedSchedule:null,results:[],resultsLoading:!1,errorCounts:null,finishedCounts:{},draft:null,setDraft:t=>e({draft:t}),loadSchedules:async()=>{t().schedules.length===0&&!t().error&&e({loading:!0}),e({error:null});try{let n=(await fY()).schedules||[],r=t().errorCounts,i=t().finishedCounts,a=r??wY();EY(a,n),r&&OY(a,i,n);let o=Object.fromEntries(n.map(e=>[e.id,e.error_count]));TY(o),e({schedules:n,loading:!1,errorCounts:o,finishedCounts:Object.fromEntries(n.map(e=>[e.id,Math.max(DY(e),i[e.id]??0)]))})}catch(t){F.api.error(`Failed to load schedules`,t),e({error:`Failed to load schedules`,loading:!1})}},createSchedule:async(t,n,r)=>{try{let i=await mY(t,n,r);e(e=>({schedules:[...e.schedules,i],actionError:null}))}catch(e){throw F.api.error(`Failed to create schedule`,e),e}},editSchedule:async(t,n,r)=>{try{let i=await hY(t,n,r);e(e=>({schedules:e.schedules.map(e=>e.name===t?i:e),actionError:null}))}catch(e){throw F.api.error(`Failed to edit schedule "${t}"`,e),e}},updateScheduleStatus:async(t,n)=>{try{let r=await gY(t,n);e(e=>({schedules:e.schedules.map(e=>e.name===t?r:e),actionError:null}))}catch(n){F.api.error(`Failed to update schedule "${t}"`,n),e({actionError:SY(n,`Failed to update schedule`)})}},runScheduleNow:async t=>{try{let n=await _Y(t);e(e=>({schedules:e.schedules.map(e=>e.name===t?n:e),actionError:null}))}catch(n){F.api.error(`Failed to run schedule "${t}" now`,n),e({actionError:SY(n,`Could not run the schedule now`)})}},deleteSchedule:async t=>{try{await vY(t),e(e=>({schedules:e.schedules.filter(e=>e.name!==t),selectedSchedule:e.selectedSchedule===t?null:e.selectedSchedule,actionError:null}))}catch(n){F.api.error(`Failed to delete schedule "${t}"`,n),e({actionError:SY(n,`Failed to delete schedule`)})}},selectSchedule:n=>{e({selectedSchedule:n,results:[],resultsLoading:!1}),n&&t().loadResults(n)},loadResults:async n=>{e({resultsLoading:!0});try{let r=await yY(n);if(t().selectedSchedule!==n)return;e({results:r.results||[],resultsLoading:!1})}catch(r){if(F.api.error(`Failed to load results for "${n}"`,r),t().selectedSchedule!==n)return;e({results:[],resultsLoading:!1})}},dismissActionError:()=>e({actionError:null})})),AY=`goal-store-error-`,jY=0;function MY(){let e=_l.getState();for(let t of e.notifications)t.id.startsWith(AY)&&!t.read&&e.markRead(t.id)}var NY=Ct((e,t)=>({error:null,damaged:!1,check:async()=>{let n,r;try{({error:n,damaged:r}=await NU())}catch(e){F.api.error(`Could not check the goal store`,e);return}n&&n!==t().error&&(jY+=1,_l.getState().addNotification({id:`${AY}${jY}`,type:`error`,agentId:`goals`,agentName:`GAIA`,title:Ht()(`mem.goals.storeError`),message:n,timestamp:Date.now(),read:!1,dismissed:!1,priority:`high`})),n||MY(),e({error:n,damaged:!!r})}})),PY=new Set([`loading_model`,`downloading_model`,`model_retry`,`waiting`]),FY=5;function IY(e,t){return{id:e,title:t.get(e)?.title??`Untitled chat`}}function LY(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=>({...IY(e,t),reason:`approval`}));n&&e.awaitingUser&&!a.has(e.currentSessionId)&&o.push({...IY(e.currentSessionId,t),reason:`answer`});for(let[n,r]of Object.entries(e.awaitingBySession))o.some(e=>e.id===n)||o.push({...IY(n,t),reason:r===`question`?`answer`:`approval`});let s=n&&!e.awaitingUser&&e.livePhase&&PY.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,FY).map(e=>IY(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=>IY(e,t)),needsYou:o,recent:u}}function RY(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:_l.getState().notifications},a=r;if(r=i,a&&Object.keys(i).every(e=>i[e]===a[e]))return;let o=LY(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=_l.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 zY(){(0,V.useEffect)(()=>{let e=window.gaiaAPI;if(!e)return;let t=_l.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 BY(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 VY(){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 HY(){zY();let e=B(e=>e.runningSessionIds),t=B(e=>e.awaitingBySession),n=B(e=>e.sessions),r=B(e=>e.currentSessionId),i=_l(Us(Sl)),a=kl(),o=VY(),s=(0,V.useRef)(null),c=Il(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 Ll(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`||Bl(s,r,i))&&(o=!0,t===`banner`)){if(c!==`finished`){let{title:t,body:n}=zl(c,e);BY(s,t,n)}else ie(s).then(e=>{B.getState().updateSessionInList(s,e);let{title:t,body:n}=zl(c,e);BY(s,t,n)}).catch(t=>{F.system.error(`Could not read how chat ${s} ended`,t);let{title:n,body:r}=zl(c,{...e,last_run_status:null});BY(s,n,r)})}}if(o){if(a.sound)try{Ul()}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=Vl(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&&Hl(o,a.batteryFloor);(0,V.useEffect)(()=>{window.gaiaAPI?.power.setKeepAwake(d).catch(e=>F.system.error(`Could not change keep-awake`,e))},[d])}function UY(e){return e.indexing_status===`failed`&&nL(e.error_kind)}function WY(){let e=B(e=>e.systemStatus?.lemonade_running===!0),t=B(e=>e.setDocuments),n=(0,V.useRef)(!1),r=(0,V.useRef)(!1);(0,V.useEffect)(()=>{if(!e)return;if(n.current){r.current=!0;return}let i=async()=>{let{documents:e}=await o(),n=(e||[]).filter(UY).map(e=>e.id);if(n.length===0)return;F.doc.info(`Model server is back; retrying ${n.length} document(s) that were waiting for it`);for(let e of n){let n=(await o()).documents||[],r=n.find(t=>t.id===e);if(r&&UY(r)){t(n.map(t=>t.id===e?{...t,indexing_status:`indexing`}:t));try{await Vt(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 o();t(r.documents||[])};n.current=!0,(async()=>{try{do{r.current=!1;try{await i()}catch(e){F.doc.warn(`Could not retry the documents waiting for the model server`,e)}}while(r.current&&B.getState().systemStatus?.lemonade_running===!0)}finally{n.current=!1}})()},[e,t])}var GY=`GAIA Agent UI`;function KY(){let e=B(e=>e.sessions.find(t=>t.id===e.currentSessionId)?.title);(0,V.useEffect)(()=>{document.title=e?.trim()?`${e.trim()} - GAIA`:GY},[e])}function qY(e,t,n){return!e||t&&(e===t||e===CL(t))?null:n.some(t=>t.id===e)?e:wL(n,e)}function JY(e){return new URLSearchParams(e.search).get(`session`)||e.hash.replace(/^#/,``)||null}var YY=`gaia:last-session`;function XY(e){try{e?localStorage.setItem(YY,e):localStorage.removeItem(YY)}catch(e){F.ui.warn(`Could not save the open chat for the next launch`,e)}}function ZY(){try{return localStorage.getItem(YY)}catch(e){return F.ui.warn(`Could not read the chat open at last launch`,e),null}}var QY=1e3,$Y=3e4;function eX(e,{initialMs:t=QY,maxMs:n=$Y,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 tX(e,t,n){return e&&!t&&!n}var nX=(0,V.lazy)(()=>IJ(()=>import(`./MemoryDashboard-BuUBoNq8.js`).then(e=>({default:e.MemoryDashboard})),__vite__mapDeps([7,1,2,8,9]),import.meta.url)),rX=(0,V.lazy)(()=>IJ(()=>import(`./ScheduleManager-8UE81KlQ.js`).then(e=>({default:e.ScheduleManager})),__vite__mapDeps([10,1,2,8,11]),import.meta.url)),iX=(0,V.lazy)(()=>IJ(()=>import(`./DocumentLibrary-Dll55N7l.js`).then(e=>({default:e.DocumentLibrary})),__vite__mapDeps([12,1,2,13]),import.meta.url)),aX=(0,V.lazy)(()=>IJ(()=>import(`./FileBrowser-wFHqH6K_.js`).then(e=>({default:e.FileBrowser})),__vite__mapDeps([14,1,2,15]),import.meta.url)),oX=(0,V.lazy)(()=>IJ(()=>import(`./MobileAccessModal-B2gaE8nk.js`).then(e=>({default:e.MobileAccessModal})),__vite__mapDeps([16,1,2,17]),import.meta.url)),sX=3,cX=3e5,lX=6e3,uX=6e4,dX=e=>e instanceof TypeError,fX=e=>new Promise(t=>setTimeout(t,e)),pX=3e5,mX=class extends Error{},hX=class extends Error{constructor(e){super(Ht().bare(`setup.unknown.modelUnread`,{error:e}))}};async function gX(){let e=Date.now()+pX;for(;;){let t=await et();if(t.state===`ready`)return;if(t.state===`failed`||t.state===`cancelled`)throw new mX(t.error||Ht().bare(`setup.upgrading.stopped`));if(Date.now()>=e)throw Error(Ht().bare(`setup.upgrading.slow`));await fX(QY)}}function _X(){return I(`div`,{className:`loading-spinner`,role:`status`,"aria-label":`Loading`})}var vX=e=>e===1||e%10==0;function yX(){let e=R();KY();let t=B(e=>e.currentSessionId),n=B(e=>e.setSessions),r=B(e=>e.setCurrentSession),i=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=_c(e=>e.restoreNotice),w=_c(e=>e.dismissRestoreNotice),T=_l(e=>e.showPanel),E=B(e=>e.systemStatus?.initialized===!0),D=(0,V.useRef)(!1),O=_l(e=>e.setShowPanel);(0,V.useEffect)(()=>{if(!C?.ok)return;let e=setTimeout(w,lX);return()=>clearTimeout(e)},[C,w]);let[k,ee]=(0,V.useState)({state:`checking`}),te=B(e=>e.setupAgain),ne=B(e=>e.runSetupAgain),A=(0,V.useRef)(k);A.current=k;let[re,ie]=(0,V.useState)(!1),ae=(0,V.useRef)(re);ae.current=re;let[j,oe]=(0,V.useState)(!1),[se,ce]=(0,V.useState)(!1),le=j||re&&!xO(_),ue=(0,V.useRef)(le);ue.current=le;let[de,fe]=(0,V.useState)(null),[pe,he]=(0,V.useState)(!1),[M,N]=(0,V.useState)(``),[ge,_e]=(0,V.useState)(0),[ye,be]=(0,V.useState)(0),[xe,Se]=(0,V.useState)(!1),[Ce,we]=(0,V.useState)(!1),[Ee,De]=(0,V.useState)(null),[Oe,ke]=(0,V.useState)(null),Ae=(0,V.useRef)(async()=>{}),je=(0,V.useRef)(async()=>{}),Me=(0,V.useCallback)(async(e=!1,t=!1)=>{e||ee({state:`checking`});let n=0;try{for(;;){await _c.getState().refresh();let e=_c.getState().active,r=!!e?.remote,i;try{if(i=await ve(r),!e&&!i.ready)throw new hX(_c.getState().error??`no answer`)}catch(e){let r=dX(e)||e instanceof hX;if(!t||!r||n>=uX)throw e;await fX(QY),n+=QY;continue}if(!i.ready&&i.stage===`upgrade`){ee({state:`upgrading`});let e=await et();(!e.upgrade_embedded||e.state!==`running`&&e.state!==`verifying`)&&await Ne(r,!1,{upgradeEmbedded:!0}),await gX(),i=await ve(r)}n>0&&await Promise.all([Ae.current(),je.current()]),ce(!!i.no_agent_build);let a=!i.ready&&i.stage===`server`&&!!i.initialized;ee(i.ready?{state:`ready`}:a?{state:`serverDown`,modelListUnread:!!i.model_list_unread}:{state:`needed`,check:i});return}}catch(e){let t=e instanceof Error?e.message:String(e);if(e instanceof mX){F.system.warn(`Updating the local model server failed`,e),ee({state:`unknown`,error:t,upgradeFailed:!0});return}F.system.warn(`Setup check could not be answered`,e),ee({state:`unknown`,error:t})}},[]),Fe=B(e=>!!e.systemStatus&&gI(e.systemStatus)===`unresponsive`),Ie=B(e=>e.systemStatus?.lemonade_running===!0);(0,V.useEffect)(()=>{k.state===`serverDown`&&Ie&&Me(!0)},[k.state,Ie,Me]);let Le=B(e=>e.systemStatus?.lemonade_running===!1);(0,V.useEffect)(()=>{if(k.state!==`ready`||!Le)return;let e=!1;return ve(!!_c.getState().active?.remote).then(t=>{!e&&!t.ready&&t.stage===`server`&&t.initialized&&ee({state:`serverDown`,modelListUnread:!!t.model_list_unread})}).catch(e=>F.system.warn(`Could not confirm the model server is down`,e)),()=>{e=!0}},[k.state,Le]);let Re=(0,V.useRef)(0),ze=(0,V.useCallback)(async()=>{let e=++Re.current,t=(await Pe()).agents||[];e===Re.current&&(g(t),ie(!0),xO(t)&&oe(!1))},[g]),Be=(0,V.useCallback)(()=>{let e=ae.current;ie(!1),ze().catch(t=>{F.api.warn(`Agent list unavailable after setup`,t),e&&ie(!0)})},[ze]);(0,V.useEffect)(()=>{let e=()=>{ue.current&&ze().catch(e=>F.api.warn(`Agent list unavailable`,e))};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[ze]);let Ve=(0,V.useCallback)(async()=>{y((await yt()).default_mode)},[y]),He=(0,V.useRef)([]);(0,V.useEffect)(()=>{_t(`0.27.0rc2`),Me(!1,!0);let e=[eX(ze,{onError:(e,t)=>{vX(t)&&F.api.warn(`Agent list unavailable (attempt ${t}); retrying`,e)}}),eX(Ve,{onError:(e,t)=>{vX(t)&&F.api.warn(`Default permission mode unavailable (attempt ${t}); retrying`,e)}})];return He.current=e,()=>e.forEach(e=>e.stop())},[Me,ze,Ve]);let Ue=(0,V.useCallback)(()=>{He.current.forEach(e=>e.kick()),_c.getState().retryNow(),je.current();let e=A.current;e.state===`unknown`&&!e.upgradeFailed&&Me(!0)},[Me]),We=(0,V.useRef)(Ue);We.current=Ue;let Ge=(0,V.useRef)(0),Ke=(0,V.useRef)(0),qe=(0,V.useRef)(null),Je=(0,V.useRef)(!1),[Ye,Xe]=(0,V.useState)(!1),[Ze,Qe]=(0,V.useState)(null),$e=(0,V.useCallback)(e=>{if(e.kind===`unreachable`){F.system.warn(`System status check failed`,e.error),XJ(),Je.current=!0,Ke.current=0,qe.current=null,Xe(!1),Qe(null),h(!1),m(null);return}if(e.kind===`error`){F.system.warn(`System status answered HTTP ${e.httpStatus}`,e.message),Je.current&&We.current(),Je.current=!1,Ke.current=0,qe.current=null,Xe(!1),Qe(`HTTP ${e.httpStatus}: ${e.message}`),h(!0);return}if(e.kind===`slow`){if(Ke.current+=1,qe.current??=Date.now(),Qe(null),F.system.warn(`System status did not answer in time (${Ke.current} in a row)`),Date.now()-qe.current>=cX){Xe(!1),h(!1),m(null);return}h(!0),(Je.current||Ke.current>=sX)&&Xe(!0);return}let{status:t}=e;Je.current&&We.current(),Je.current=!1,Ke.current=0,qe.current=null,Xe(!1),Qe(null),h(!0),Ge.current=t.lemonade_running?0:Ge.current+1;let n=B.getState().systemStatus;t.lemonade_running||Ge.current>=sX||!n?.lemonade_running?m(t):m({...n,download_progress:t.download_progress})},[h,m]),tt=(0,V.useRef)($e);tt.current=$e;let[nt]=(0,V.useState)(()=>yI(e=>tt.current(e))),rt=nt.check;Ae.current=rt,(0,V.useEffect)(()=>CH(nt.start),[nt]),(0,V.useEffect)(()=>ZJ(()=>{rt()}),[rt]);let it=(0,V.useRef)(``);(0,V.useEffect)(()=>{let e=e=>wn().then(t=>{let r=t.sessions||[];if(!e&&r.length===0&&B.getState().sessions.length>0)return;let i=r.map(e=>`${e.id}|${e.updated_at}|${e.title}|${e.inference_remote}|${e.inference_provider}|${e.inference_description}|${e.effective_model}|${e.unread}|${e.pinned}|${e.last_run_status}|${e.kind}`).join(`
|
|
213
|
+
`);if(i===it.current)return;it.current=i,n(r);let a=_c.getState().active?.model;a&&r.some(e=>e.effective_model&&e.effective_model!==a)&&_c.getState().refresh()}).catch(t=>{e&&F.system.error(`Could not load chats`,t)});je.current=()=>e(!1),e(!0);let t=setInterval(()=>void e(!1),5e3);return()=>clearInterval(t)},[n]),(0,V.useEffect)(()=>MI(),[]),(0,V.useEffect)(()=>{let e=()=>{kY.getState().loadSchedules()};e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[]),(0,V.useEffect)(()=>{let e=()=>{NY.getState().check()};e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[]),(0,V.useEffect)(()=>XI(),[]),HY(),WY();let at=(0,V.useRef)(!1),ot=(0,V.useRef)(!1);(0,V.useEffect)(()=>{let e=()=>{let e=JY(window.location),{currentSessionId:t,sessions:n}=B.getState(),i=qY(e,t,n);return i&&(r(i),o([])),i},t=()=>{if(at.current||(at.current=!0,e()||B.getState().currentSessionId))return;if(window.location.hash){window.history.replaceState(null,``,window.location.pathname+window.location.search);return}if(ot.current||sn(`new-chat`))return;let{sessions:t}=B.getState(),n=qY(ZY(),null,t);n&&(r(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)}},[r,o]),(0,V.useEffect)(()=>{let e=null,t=2e3,n=!1,i=null,a=()=>{n||(e=new EventSource(`${dn()}/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&&(r(t.session_id),o([]))},e.onerror=()=>{e?.close(),e=null,n||(i=setTimeout(a,t),t=Math.min(t*2,3e4))})};return a(),()=>{n=!0,i&&clearTimeout(i),e?.close()}},[r,o]),(0,V.useEffect)(()=>{if(at.current&&XY(t),t){let e=CL(t);window.location.hash!==`#${e}`&&window.history.replaceState(null,``,`#${e}`)}else at.current&&window.location.hash&&window.history.replaceState(null,``,window.location.pathname+window.location.search)},[t]);let st=(0,V.useCallback)(async e=>{if(fe(null),he(!1),!await ec(`chat`))return N(e),!1;let t=B.getState(),n;try{n=await an({title:`New chat`,agent_type:bO,document_ids:t.draftDocumentIds,private:t.draftPrivate,folders:t.draftFolder?[t.draftFolder]:[]})}catch(e){throw CO(e)?(oe(!0),new SO):e}ue.current&&(oe(!1),ze().catch(e=>F.api.warn(`Agent list unavailable`,e))),t.defaultPermissionModeKnown||(await Ve().catch(e=>F.api.warn(`Default permission mode unavailable; using the chip's mode`,e)),t=B.getState()),t.clearDraftDocuments(),t.setDraftPrivate(!1),t.setDraftFolder(null);let s=null;try{await kt(n.id,t.draftPermissionMode)}catch(e){s=e}return Mn(a),s&&!n.private&&Cn(At(n.id),e),i(n),MB.getState().claimDraft(n.id),r(n.id),o([]),N(``),s?(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`}: ${s instanceof Error?s.message:s}`),!1):(t.resetDraftPermissionMode(),v({sessionId:n.id,text:e}),!0)},[i,r,o,v,ze,Ve]),ct=(0,V.useCallback)(async e=>{try{return await st(e)}catch(t){if(!(t instanceof SO))throw t;let n=sn(a),r=n.trimEnd().endsWith(e)?n:[n,e].filter(Boolean).join(`
|
|
214
214
|
|
|
215
|
-
`);return Cn(a,r),N(r),he(!0),be(e=>e+1),!1}},[st]),lt=(0,V.useCallback)(()=>{let e=B.getState(),t=e.currentSessionId,n=e.pendingPrompt?.sessionId===t?e.pendingPrompt:null;n&&(e.setPendingPrompt(null),N(n.text)),t&&Zl(t,B.getState())&&Ql(t),e.setShowMemoryDashboard(!1),e.setShowSchedules(!1),ot.current=!0,he(!1),r(null),o([]),_e(e=>e+1)},[r,o]),ut=(0,V.useCallback)(e=>{let t=B.getState();t.closeSettings(),e!==t.currentSessionId&&(Ql(t.currentSessionId),o([])),r(e)},[r,o]),dt=(0,V.useCallback)(e=>{let t=B.getState();t.setShowMemoryDashboard(!1),t.setShowSchedules(!1),O(!1),ut(e)},[ut]);
|
|
215
|
+
`);return Cn(a,r),N(r),he(!0),be(e=>e+1),!1}},[st]),lt=(0,V.useCallback)(()=>{let e=B.getState(),t=e.currentSessionId,n=e.pendingPrompt?.sessionId===t?e.pendingPrompt:null;n&&(e.setPendingPrompt(null),N(n.text)),t&&Zl(t,B.getState())&&Ql(t),e.setShowMemoryDashboard(!1),e.setShowSchedules(!1),ot.current=!0,he(!1),r(null),o([]),_e(e=>e+1)},[r,o]),ut=(0,V.useCallback)(e=>{let t=B.getState();t.closeSettings(),e!==t.currentSessionId&&(Ql(t.currentSessionId),o([])),r(e)},[r,o]),dt=(0,V.useCallback)(e=>{let t=B.getState();t.setShowMemoryDashboard(!1),t.setShowSchedules(!1),O(!1),ut(e)},[ut]);RY({openChat:ut,newChat:(0,V.useCallback)(()=>{B.getState().closeSettings(),lt()},[lt]),refreshStatus:()=>void rt()});let ft=(0,V.useCallback)(t=>{let n=B.getState(),r=n.pendingPrompt?.sessionId===n.currentSessionId?n.pendingPrompt?.text:null;lt();let i=e.bare(`settings.skills.tryPrompt`,{name:t}),o=[sn(a),r].filter(Boolean).join(`
|
|
216
216
|
|
|
217
217
|
`),s=o.trimEnd().endsWith(i)?o:[o,i].filter(Boolean).join(`
|
|
218
218
|
|
|
219
|
-
`);Cn(a,s),N(s),be(e=>e+1)},[lt,e]);(0,V.useEffect)(()=>{let e=e=>{let t=e.detail;B.getState().closeSettings(),lt(),ct(
|
|
220
|
-
`)}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:s,children:c(`engine.openLog`)})]})]})}function
|
|
219
|
+
`);Cn(a,s),N(s),be(e=>e+1)},[lt,e]);(0,V.useEffect)(()=>{let e=e=>{let t=e.detail;B.getState().closeSettings(),lt(),ct(qJ(t)).catch(e=>fe(e instanceof Error?e.message:String(e)))};return window.addEventListener(UJ,e),()=>window.removeEventListener(UJ,e)},[lt,ct]);let pt=(0,V.useCallback)(e=>{ee({state:`ready`}),Be(),rt(),e&&(e.needs_input?N(e.prompt):ct(e.prompt).catch(e=>fe(e instanceof Error?e.message:String(e))))},[rt,ct,Be]),mt=(0,V.useCallback)(()=>{ee({state:`ready`}),rt()},[rt]);(0,V.useEffect)(()=>{let e=()=>{B.getState().closeSettings(),ee({state:`addingLocal`})};return window.addEventListener(`gaia:set-up-local`,e),()=>window.removeEventListener(`gaia:set-up-local`,e)},[]);let[ht,gt]=(0,V.useState)(!1);(0,V.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&(e.shiftKey&&e.key.toLowerCase()===`o`?(e.preventDefault(),lt()):!e.shiftKey&&e.key.toLowerCase()===`k`?(e.preventDefault(),window.dispatchEvent(new CustomEvent(`gaia:focus-search`))):!e.shiftKey&&e.key.toLowerCase()===`b`?(e.preventDefault(),B.getState().toggleSidebarCollapsed()):!e.shiftKey&&e.key===`,`?(e.preventDefault(),b()):e.key===`/`&&(e.preventDefault(),gt(e=>!e)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[lt,b]),(0,V.useEffect)(()=>{let e=window.matchMedia?.(`(max-width: 768px)`);if(!e)return;let t=()=>p(!e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[p]),(0,V.useEffect)(()=>{if(typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(prefers-color-scheme: light)`);return e.addEventListener(`change`,S),()=>e.removeEventListener(`change`,S)},[S]),(0,V.useEffect)(()=>{me().then(e=>we(e.active===!0)).catch(e=>F.system.debug(`Mobile access unavailable`,e))},[]);let vt=(0,V.useCallback)(async()=>{if(Se(!0),De(null),Ce)ke(null);else try{let e=await Te(),t=e.reason===`ngrok_not_installed`;if(ke(t?e.installCommands??[]:null),t)return;e.error?De(e.error):we(!0)}catch(e){ke(null),De(e instanceof Error?e.message:`Could not start mobile access`)}},[Ce]),bt=(0,V.useCallback)(async()=>{try{await Zt(),we(!1),Se(!1)}catch(e){De(e instanceof Error?e.message:`Could not stop mobile access`)}},[]);Vz(e=>{e?vt():bt()}),(0,V.useEffect)(()=>{zz(Ce)},[Ce]);let xt=au(`(max-width: 768px)`),St=tX(k.state===`checking`,E,D.current);if(!St&&k.state!==`needed`&&(D.current=!0),St)return I(`div`,{className:`app`,children:z(`main`,{className:`startup`,role:`status`,"aria-label":`Starting GAIA`,children:[I(`div`,{className:`loading-spinner`,"aria-hidden":`true`}),I(`p`,{className:`startup-text`,children:`Starting GAIA…`})]})});if(k.state===`upgrading`)return I(`div`,{className:`app`,children:z(`main`,{className:`startup`,role:`status`,"aria-live":`polite`,"aria-label":e(`setup.upgrading.notice`),children:[I(`div`,{className:`loading-spinner`,"aria-hidden":`true`}),I(`p`,{className:`startup-text`,children:e(`setup.upgrading.notice`)})]})});if(k.state===`needed`||k.state===`addingLocal`||te){let e=te?()=>ne(!1):k.state===`addingLocal`?mt:void 0;return z(`div`,{className:`app`,children:[I(aq,{onReady:e=>{ne(!1),pt(e)},onClose:e}),I(cW,{}),I(iY,{})]})}let P=!l&&!u?wB():void 0,Ct=l?I(V.Suspense,{fallback:I(_X,{}),children:I(nX,{})}):t?I(UH,{sessionId:t},t):I(rW,{onSend:st,initialText:M,focusRequest:ge,agentMissing:le,agentRefused:pe},`${ye}:${M}`);return z(`div`,{className:`app`,children:[!d&&I(`button`,{className:`sidebar-toggle`,onClick:()=>p(!0),"aria-label":e(`sidebar.open`),children:I(Ga,{size:18})}),I(`div`,{className:`sidebar-overlay ${d?`visible`:``}`,onClick:()=>p(!1),"aria-hidden":`true`}),I(kJ,{area:`sidebar`,variant:`compact`,children:I(Ou,{onNewChat:lt,onMobileAccess:xt?void 0:()=>void vt(),tunnelActive:Ce})}),z(`div`,{className:`main-content`,children:[(k.state===`ready`||k.state===`checking`||k.state===`serverDown`&&Fe)&&I(nY,{onRetry:rt,backendSlow:Ye,backendError:Ze}),k.state===`serverDown`&&!Fe&&z(`div`,{className:`app-notice is-warning`,role:`status`,children:[I(`span`,{children:e(k.modelListUnread?`setup.modelListUnread.notice`:`setup.serverDown.notice`)}),I(`button`,{type:`button`,className:`link-btn`,onClick:()=>void Me(!0),children:e(`setup.unknown.retry`)}),!k.modelListUnread&&I(`button`,{type:`button`,className:`link-btn`,onClick:()=>ne(!0),children:e(`setup.serverDown.setup`)})]}),k.state===`unknown`&&(k.upgradeFailed?z(`div`,{className:`app-notice is-warning`,role:`status`,children:[I(`span`,{children:e(`setup.upgrading.failed`,{error:k.error})}),I(`button`,{type:`button`,className:`link-btn`,onClick:()=>void Me(),children:e(`setup.upgrading.retry`)})]}):z(`div`,{className:`app-notice is-warning`,role:`status`,children:[I(`span`,{children:e(`setup.unknown.failed`,{error:k.error})}),I(`button`,{type:`button`,className:`link-btn`,onClick:()=>void Me(),children:e(`setup.unknown.retry`)})]})),(!d||f)&&I($c,{placement:`main`}),le&&I(dY,{onInstalled:ze,noBuild:se}),C&&z(`div`,{className:`app-notice${C.ok?``:` is-warning`}`,role:`status`,children:[I(`span`,{children:C.message}),!C.ok&&I(`button`,{type:`button`,className:`link-btn`,onClick:()=>{w(),b(`model`)},children:`Pick a model`}),I(`button`,{type:`button`,className:`app-notice-close`,onClick:w,"aria-label":`Dismiss`,children:I(Is,{size:14})})]}),I(kJ,{resetKey:l?`memory`:t??`new-${ge}`,area:`main`,children:Ct})]}),P&&I(cV,{api:P}),u&&I(V.Suspense,{fallback:null,children:I(rX,{})}),s&&I(V.Suspense,{fallback:null,children:I(iX,{})}),c&&I(V.Suspense,{fallback:null,children:I(aX,{onStartChat:ct})}),T&&I(`div`,{className:`notification-center-popover`,children:I(sY,{onClose:()=>O(!1),onOpenChat:dt})}),xe&&I(V.Suspense,{fallback:null,children:I(oX,{isOpen:xe,onClose:()=>Se(!1),onStop:()=>void bt(),error:Ee,setupCommands:Oe,onRetry:()=>void vt()})}),x&&I(HJ,{onUseSkill:ft}),I(cW,{}),I(xW,{}),ht&&I(wW,{onClose:()=>gt(!1)}),I(iY,{}),de&&z(`div`,{className:`toast toast-dismissible`,role:`alert`,children:[I(`span`,{children:de}),I(`button`,{type:`button`,className:`toast-dismiss`,onClick:()=>fe(null),"aria-label":e(`banner.dismiss`),children:I(Is,{size:14,"aria-hidden":`true`})})]})]})}var bX=`agent-refresh`,xX={"pre-checks":`engine.stage.preChecks`,"ensure-uv":`engine.stage.ensureUv`,"create-venv":`engine.stage.createVenv`,"install-package":`engine.stage.installPackage`,verify:`engine.stage.verify`,[bX]:`engine.stage.agentRefresh`,start:`engine.stage.start`},SX={disk:`engine.hint.disk`,network:`engine.hint.network`,tls:`engine.hint.tls`,locked:`engine.hint.locked`,daemon:`engine.hint.daemon`};function CX(e,t){if(!e)return t(`engine.stage.neutral`);let n=xX[e];return n?t(n):(console.warn(`[EngineInstallScreen] install stage "${e}" has no label`),t(`engine.stage.neutral`))}function wX(e,t){return e.reason?t(SX[e.reason]):t(e.stage===bX?`engine.hint.agent`:`engine.hint.other`)}function TX(e){return e.reason===`locked`&&e.lockedBy?.length?e.lockedBy:null}function EX(e,t){let n=e.name??String(e.pid),r=e.folder;return e.isGaia?r?t(`engine.locked.gaia`,{name:n,folder:r}):t(`engine.locked.gaiaNoFolder`,{name:n}):r?t(`engine.locked.other`,{name:n,folder:r}):t(`engine.locked.otherNoFolder`,{name:n})}function DX({status:e}){let t=R(),n=CX(e.stage,t);return z(`div`,{className:`engine-progress`,role:`status`,children:[z(`div`,{className:`engine-progress-head`,children:[I(`span`,{children:n}),e.percent!==null&&z(`bdi`,{dir:`ltr`,children:[e.percent,`%`]})]}),I(`progress`,{className:`engine-bar`,"aria-label":n,max:100,value:e.percent??void 0})]})}function OX({error:e,busy:t,notice:n,onRetry:r,onCloseLockers:i,onContinue:a,onRevert:o,onOpenLog:s}){let c=R(),l=TX(e),u=l!==null&&l.every(e=>e.isGaia),d=(l?.length??0)>1;return z(`div`,{className:`engine-failure`,children:[z(`div`,{role:`alert`,children:[l?z(P.Fragment,{children:[l.map(e=>I(`p`,{className:`engine-hint`,children:EX(e,c)},e.pid)),!u&&I(`p`,{className:`engine-hint`,children:c(d?`engine.locked.closeThenMany`:`engine.locked.closeThen`)})]}):I(`p`,{className:`engine-hint`,children:wX(e,c)}),I(`p`,{className:`engine-error`,children:I(`bdi`,{dir:`ltr`,children:e.message})})]}),u&&I(`button`,{type:`button`,className:`btn-primary engine-retry`,disabled:t,onClick:i,autoFocus:!0,children:c(d?`engine.locked.closeMany`:`engine.locked.close`)}),I(`button`,{type:`button`,className:`${u?`btn-secondary`:`btn-primary`} engine-retry`,disabled:t,onClick:r,autoFocus:!u,children:c(`engine.tryAgain`)}),e.stage===bX&&I(`button`,{type:`button`,className:`btn-secondary engine-retry`,disabled:t,onClick:a,children:c(`engine.continueWithout`)}),e.previousVersion&&I(`button`,{type:`button`,className:`btn-secondary engine-retry`,disabled:t,onClick:o,children:c(`update.chip.goBack`,{version:e.previousVersion})}),n&&I(`p`,{className:`engine-error`,role:`alert`,children:I(`bdi`,{dir:`ltr`,children:n})}),z(`details`,{className:`engine-details`,children:[I(`summary`,{children:c(`engine.details`)}),I(`pre`,{className:`engine-log`,dir:`ltr`,children:e.logTail.join(`
|
|
220
|
+
`)}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:s,children:c(`engine.openLog`)})]})]})}function kX(){let e=R(),[t,n]=(0,V.useState)({phase:`running`,stage:null,percent:null,message:``,error:null}),[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(null),s=(0,V.useCallback)(e=>{console.error(`[EngineInstallScreen] the desktop app did not answer`,e),o(e instanceof Error?e.message:String(e))},[]);(0,V.useEffect)(()=>{let e=window.gaiaInstall,t=e.onProgress(n);return e.status().then(n).catch(s),t},[s]);let c=(0,V.useCallback)(()=>{i(!0),o(null),window.gaiaInstall.retry().catch(s).finally(()=>i(!1))},[s]),l=(0,V.useCallback)(()=>{i(!0),o(null),window.gaiaInstall.closeLockingPrograms().catch(s).finally(()=>i(!1))},[s]),u=(0,V.useCallback)(()=>{i(!0),o(null),window.gaiaInstall.continueWithoutAgentUpdate().catch(s).finally(()=>i(!1))},[s]),d=(0,V.useCallback)(()=>{i(!0),o(null),window.gaiaInstall.revert().then(e=>{e||i(!1)}).catch(e=>{s(e),i(!1)})},[s]),f=(0,V.useCallback)(()=>{o(null),window.gaiaInstall.openLogFile().then(e=>{e.ok||o(e.message)}).catch(s)},[s]),{error:p}=t,m=t.phase===`failed`&&p,h=e(m?p.stage===bX?`engine.failed.agentTitle`:`engine.failed.title`:`engine.title`);return I(`div`,{className:`app`,children:I(`main`,{className:`engine`,children:z(`div`,{className:`engine-inner`,children:[I(`h1`,{className:`engine-title`,children:h}),m?I(OX,{error:p,busy:r,notice:a,onRetry:c,onCloseLockers:l,onContinue:u,onRevert:d,onOpenLog:f}):z(P.Fragment,{children:[I(`p`,{className:`engine-lede`,children:e(`engine.lede`)}),I(DX,{status:t}),a&&I(`p`,{className:`engine-error`,role:`alert`,children:I(`bdi`,{dir:`ltr`,children:a})})]})]})})})}function AX(){return!!window.gaiaInstall&&new URLSearchParams(window.location.search).get(`engine`)===`install`}async function jX(e){if(!e.isProduction||e.protocol!==`https:`&&e.protocol!==`http:`||!e.serviceWorker)return!1;try{return await e.serviceWorker.register(`./sw.js`,{scope:`./`}),!0}catch(e){return console.error(`[pwa] Service worker registration failed, so the UI is not cached for an installed app:`,e),!1}}nl(),nt();var MX=localStorage.getItem(`gaia-chat-theme`);at(lt(MX===`light`||MX===`dark`?MX:`system`));var NX=B.getState();se(NX.palette,NX.customColors,NX.theme),be(NX.locale),je(),r(),Ls.createRoot(document.getElementById(`root`)).render(I(V.StrictMode,{children:I(kJ,{area:`app`,variant:`window`,children:AX()?I(kX,{}):I(yX,{})})})),window.addEventListener(`load`,()=>{jX({isProduction:!0,protocol:window.location.protocol,serviceWorker:`serviceWorker`in navigator?navigator.serviceWorker:void 0})});export{SH as $,Yi as $t,hU as A,Ps as At,gU as B,Po as Bt,EU as C,Gl as Ct,VU as D,ec as Dt,cU as E,_c as Et,oU as F,us as Ft,xU as G,$a as Gt,CU as H,wo as Ht,pU as I,cs as It,MU as J,Na as Jt,bU as K,La as Kt,DU as L,Ko as Lt,dU as M,Es as Mt,FU as N,ws as Nt,uU as O,qs as Ot,sU as P,Ss as Pt,OU as Q,Zi as Qt,aU as R,Wo as Rt,TU as S,Kl as St,LU as T,vc as Tt,wU as U,vo as Ut,IU as V,Oo as Vt,yU as W,mo as Wt,PU as X,aa as Xt,zU as Y,ha as Yt,mU as Z,$i as Zt,lW as _,Vr as _n,EO as _t,KJ as a,yi as an,uL as at,BU as b,pr as bn,h_ as bt,Fq as c,li as cn,aL as ct,Nq as d,ti as dn,KO as dt,Fi as en,Fz as et,Mq as f,$r as fn,RO as ft,bW as g,Gr as gn,TO as gt,TW as h,qr as hn,NO as ht,QJ as i,xi as in,cL as it,_U as j,Os as jt,lU as k,Is as kt,Pq as l,si as ln,iL as lt,OG as m,Yr as mn,OO as mt,kY as n,Di as nn,mL as nt,JJ as o,hi as on,nL as ot,oq as p,Zr as pn,PO as pt,SU as q,Fa as qt,bY as r,Ci as rn,gL as rt,IJ as s,di as sn,rL as st,NY as t,ji as tn,SL as tt,Aq as u,ri as un,SM as ut,JU as v,kr as vn,b_ as vt,vU as w,xc as wt,jU as x,eu as xt,RU as y,yr as yn,O_ as yt,fU as z,Bo as zt};
|