@amd-gaia/agent-ui 0.25.2-rc.1 → 0.25.2-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.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ConnectorsPane-DrjImgCN.js","./rolldown-runtime-XKyaHtl9.js","./apiBase-BmPG2Rib.js","./ConnectorsPane-Dzu2DRTc.css","./AdvancedSettings-C67TQFIS.js","./AdvancedSettings-D5VKpkPY.css","./MemoryDashboard-BSvuQ0Gw.js","./eye-CwjwlxR5.js","./message-square-DuVoNniw.js","./MemoryDashboard-Mo721-BI.css","./ScheduleManager-CtKyLXmp.js","./ScheduleManager-DotJl5JW.css","./DocumentLibrary-Blc3og5s.js","./DocumentLibrary-CIKp6qld.css","./FileBrowser-BEHm0tfL.js","./FileBrowser-D04I8Pvv.css","./MobileAccessModal-CesEiNm2.js","./MobileAccessModal-DuVy9F1u.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ConnectorsPane-BMuJwbQS.js","./rolldown-runtime-XKyaHtl9.js","./apiBase-BmPG2Rib.js","./ConnectorsPane-Dzu2DRTc.css","./AdvancedSettings-DlNYuBwr.js","./AdvancedSettings-D5VKpkPY.css","./MemoryDashboard-CI0XsMok.js","./eye-CwjwlxR5.js","./message-square-DuVoNniw.js","./MemoryDashboard-Mo721-BI.css","./ScheduleManager-ia8OmdHV.js","./ScheduleManager-DotJl5JW.css","./DocumentLibrary-BBkaVGFa.js","./DocumentLibrary-CIKp6qld.css","./FileBrowser-B3rdG7Th.js","./FileBrowser-D04I8Pvv.css","./MobileAccessModal-Bt5XREFP.js","./MobileAccessModal-DuVy9F1u.css"])))=>i.map(i=>d[i]);
2
2
  import{n as e,r as t,t as n}from"./rolldown-runtime-XKyaHtl9.js";import{a as r,c as i,i as a,l as o,n as s,o as c,r as l,s as u,t as d,u as f}from"./apiBase-BmPG2Rib.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 p=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&&j(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&&j(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,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(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,j(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}}}})),m=n(((e,t)=>{t.exports=p()})),h=n((e=>{var t=f();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`})),g=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=h()})),_=n((e=>{var t=m(),n=f(),r=g();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 p(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)&&p(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function h(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 _(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 v(e){var t=[null,null],n=h(e);return n===null||y(t,e,n.child,{foundSelf:!1}),t}function y(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)&&y(e,t,n.child,r))return!0;n=n.sibling}return!1}function b(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 x=null,S=null;function C(e,t,n){return e===n||e===t&&(x=e,!0)}function w(e,t,n){return e===n?(S=e,!1):e===t&&(S!==null&&(x=e),!0)}function T(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 E(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 D=Object.assign,O=Symbol.for(`react.element`),k=Symbol.for(`react.transitional.element`),A=Symbol.for(`react.portal`),j=Symbol.for(`react.fragment`),M=Symbol.for(`react.strict_mode`),N=Symbol.for(`react.profiler`),ee=Symbol.for(`react.consumer`),P=Symbol.for(`react.context`),te=Symbol.for(`react.forward_ref`),ne=Symbol.for(`react.suspense`),re=Symbol.for(`react.suspense_list`),ie=Symbol.for(`react.memo`),ae=Symbol.for(`react.lazy`),oe=Symbol.for(`react.activity`),se=Symbol.for(`react.legacy_hidden`),ce=Symbol.for(`react.memo_cache_sentinel`),le=Symbol.for(`react.view_transition`),ue=Symbol.for(`react.recoverable`),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 j:return`Fragment`;case N:return`Profiler`;case M:return`StrictMode`;case ne:return`Suspense`;case re:return`SuspenseList`;case oe:return`Activity`;case le:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case A:return`Portal`;case P:return e.displayName||`Context`;case ee:return(e._context.displayName||`Context`)+`.Consumer`;case te:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ie:return t=e.displayName||null,t===null?me(e.type)||`Memo`:t;case ae:t=e._payload,e=e._init;try{return me(e(t))}catch{}}return null}var he=Array.isArray,F=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L={pending:!1,data:null,method:null,action:null},ge=[],_e=-1;function ve(e){return{current:e}}function ye(e){0>_e||(e.current=ge[_e],ge[_e]=null,_e--)}function R(e,t){_e++,ge[_e]=e.current,e.current=t}var be=ve(null),xe=ve(null),Se=ve(null),Ce=ve(null);function we(e,t){switch(R(Se,t),R(xe,e),R(be,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ye(be),R(be,e)}function Te(){ye(be),ye(xe),ye(Se)}function Ee(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,R(Ce,e)),t=be.current;var n=dp(t,e.type);t!==n&&(R(xe,e),R(be,n))}function De(e){xe.current===e&&(ye(be),ye(xe)),Ce.current===e&&(ye(Ce),sh._currentValue=L)}var Oe,ke;function Ae(e){if(Oe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Oe=t&&t[1]||``,ke=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+Oe+e+ke}var je=!1;function Me(e,t){if(!e||je)return``;je=!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(`
@@ -55,7 +55,7 @@ Load ${e} anyway?`)?(await Li(e,t,!0),!0):!1}}async function zi(e,t=!1){return U
55
55
  `).replace(/\\\\/g,`\\`)}function Kb(e){let t;try{t=JSON.parse(e)}catch{let t=Gb(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=>Hb.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 qb(e,t){let n=``,r=0;for(;r<e.length;){let i=e.indexOf(`{`,r);if(i===-1){n+=e.slice(r);break}if(!Ub.test(e.slice(i,i+40))){n+=e.slice(r,i+1),r=i+1;continue}let a=Wb(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=Kb(o);s.action===`answer`?n+=s.text:s.action===`keep`&&(n+=o),r=a+1}return n}var Jb=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.email_pre_scan.email-pre-scan`.split(`.`));function Yb(e){return e.replace(/```(\w*)[ \t]*\n([\s\S]*?)```/g,(e,t,n)=>{let r=t.toLowerCase();return r.length>0&&r.length<=2&&!Jb.has(r)?n.trim():e})}var Xb=/\n{1,2}Verification: unverified[^\n]*\s*$/;function Zb(e){let t=e;for(;;){let e=t.replace(Xb,``);if(e===t)return t;t=e}}function Qb(e,t=!1){if(!e)return e;e=Zb(e);let n=e;n=n.replace(Vb,``),n=qb(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,`
56
56
  `),n=n.replace(/\\"/g,`"`)),n=Yb(n).trim(),$b(n)}function $b(e){let t=!1;return e.split(`
57
57
  `).map(e=>(/^\s*(```|~~~)/.test(e)&&(t=!t),t?e:e.replace(/^(\s*\d+)\.(\s*)$/,`$1\\.$2`))).join(`
58
- `)}function ex(e){return e?new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`,second:`2-digit`,hour12:!0}):``}var tx=`Cancelled.`,nx=[`This answer was interrupted when GAIA closed. Send again to retry.`,`This answer was interrupted before it finished. Send again to retry.`,`This answer ended before GAIA could save a reply. Send again to retry.`];function rx(e,t){if(t)return`stopped`;let n=e.trim();return nx.some(e=>n.endsWith(e))?`interrupted`:void 0}function ix({message:e,isStreaming:t,agentSteps:n,agentStepsActive:r,agentStepCount:i,cards:a,onDelete:o,onResend:s,extraActions:c,latencyMs:l,liveStatus:u,awaitingUser:d}){Wo();let f=(0,B.useMemo)(()=>e.role===`assistant`&&!t&&n?Bb(n,e.content):{steps:n,echoed:!1},[n,e.content,e.role,t]),p=e.role===`assistant`&&(f.echoed||Rb(e.content)),m=e.role===`assistant`?e.stopState??(e.content.trim()===tx?`stopped`:void 0):void 0,h=(0,B.useMemo)(()=>e.role===`user`?e.content:Qb(e.content,!!t),[e.content,e.role,t]),[g,_]=(0,B.useState)(!1),[v,y]=(0,B.useState)(!1),b=e.role===`user`&&fv(e.content),[x,S]=(0,B.useState)(!1),C=(0,B.useId)(),w=(0,B.useRef)(null),T=(0,B.useRef)(!1),E=(0,B.useCallback)(()=>{x&&(T.current=!0),S(!x)},[x]);(0,B.useEffect)(()=>{!x&&T.current&&(T.current=!1,w.current?.scrollIntoView?.({block:`nearest`}))},[x]);let D=(0,B.useRef)(null),O=(0,B.useRef)(null);(0,B.useEffect)(()=>()=>{D.current&&clearTimeout(D.current),O.current&&clearTimeout(O.current)},[]);let k=(0,B.useCallback)(()=>{if(navigator.clipboard?.writeText)navigator.clipboard.writeText(e.content).catch(()=>{});else{let t=document.createElement(`textarea`);t.value=e.content,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),document.execCommand(`copy`),document.body.removeChild(t)}_(!0),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>_(!1),2e3)},[e.content]),A=(0,B.useCallback)(()=>{v?(y(!1),O.current&&clearTimeout(O.current),o?.(e.id)):(y(!0),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>y(!1),3e3))},[v,e.id,o]),j=(0,B.useCallback)(()=>{s?.(e)},[e,s]),M=e.created_at?`${e.role===`user`?`Sent`:`Replied`} ${ex(e.created_at)}`:void 0;return(0,H.jsx)(`div`,{className:`msg msg-${e.role} ${p?`msg-error`:``}`,title:M,children:(0,H.jsxs)(`div`,{className:`msg-inner`,children:[(0,H.jsxs)(`div`,{className:`msg-header`,children:[(0,H.jsx)(`div`,{className:`msg-header-left`,children:e.role===`assistant`&&t&&(0,H.jsx)(Fb,{active:!!r||!h,label:u,awaitingUser:d})}),!t&&(0,H.jsxs)(`div`,{className:`msg-actions`,children:[e.role===`user`&&s&&(0,H.jsx)(`button`,{className:`msg-action-btn`,onClick:j,title:`Resend message`,"aria-label":`Resend message`,children:(0,H.jsx)(Xt,{size:12})}),c,(0,H.jsx)(`button`,{className:`msg-copy ${g?`copied`:``}`,onClick:k,title:g?`Copied!`:`Copy message`,"aria-label":g?`Copied to clipboard`:`Copy message`,children:g?(0,H.jsx)(ae,{size:12}):(0,H.jsx)(Te,{size:12})}),o&&(0,H.jsx)(`button`,{className:`msg-action-btn msg-delete ${v?`confirm`:``}`,onClick:A,title:v?`Click again to confirm`:`Delete message`,"aria-label":v?`Confirm delete message`:`Delete message`,children:(0,H.jsx)(xn,{size:12})})]})]}),(0,H.jsxs)(`div`,{className:`msg-body`,children:[f.steps&&f.steps.length>0&&(0,H.jsx)(Vv,{steps:f.steps,isActive:r??!1,variant:r?`inline`:`summary`,agentStepCount:i??e.stats?.steps??void 0,awaitingUser:d}),p&&(0,H.jsxs)(`div`,{className:`error-banner`,children:[(0,H.jsx)(Cn,{size:14}),(0,H.jsx)(`span`,{children:`Something went wrong`})]}),(e.cards??a)?.map((e,t)=>(0,H.jsx)(Yy,{render:e.render,data:e.data},t)),b?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{ref:w,id:C,className:`msg-collapsible${x?``:` is-collapsed`}`,children:(0,H.jsx)(hx,{content:h})}),(0,H.jsx)(mv,{expanded:x,onToggle:E,controls:C,collapsedLabel:`Show all (${pv(e.content)})`,expandedLabel:`Show less`,className:`msg-expand-toggle`})]}):!(m&&h.trim()===tx)&&(0,H.jsx)(hx,{content:h,showCursor:t&&!!h&&!r,isStreaming:t}),m&&(0,H.jsxs)(`div`,{className:`msg-stopped${m===`unconfirmed`||e.stopError?` is-unconfirmed`:``}`,role:`note`,children:[(0,H.jsx)(_n,{size:9,fill:`currentColor`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{children:m===`unconfirmed`?`Stopped. GAIA did not confirm the stop, so some steps may be missing here. Reload the chat to see what it saved.`:e.stopError?`Stopped. GAIA reported an error while stopping: ${e.stopError}`:`Stopped`})]}),e.role===`assistant`&&!t&&oy(h)&&(0,H.jsx)(uy,{content:h}),e.role===`assistant`&&!t&&(e.stats||l!=null||e.created_at)&&(0,H.jsxs)(`div`,{className:`msg-stats`,"aria-label":`About this answer`,children:[e.created_at&&(0,H.jsx)(`span`,{className:`msg-stats-ts`,title:`Message timestamp`,children:ex(e.created_at)}),e.stats?.retried&&e.stats.model&&(0,H.jsx)(`span`,{title:`This answer was kept from Retry with… (${e.stats.model})`,children:Go(e.stats.model)}),(0,H.jsx)(eb,{latencyMs:l,stats:e.stats,ended:rx(e.content,m)})]}),e.role===`assistant`&&!t&&e.id>0&&e.session_id&&(0,H.jsx)(Pb,{sessionId:e.session_id,messageId:e.id})]})]})})}var ax=(0,B.createContext)(!1);function ox({lang:e,code:t}){let[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(!1),o=(0,B.useContext)(ax),s=(0,B.useId)(),c=dv(t),l=c>(o?20:25),u=l&&!i,d=(0,B.useRef)(null);(0,B.useEffect)(()=>()=>{d.current&&clearTimeout(d.current)},[]);let f=(0,B.useCallback)(()=>{if(navigator.clipboard?.writeText)navigator.clipboard.writeText(t).catch(()=>{});else{let e=document.createElement(`textarea`);e.value=t,e.style.position=`fixed`,e.style.opacity=`0`,document.body.appendChild(e),e.select(),document.execCommand(`copy`),document.body.removeChild(e)}r(!0),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>r(!1),2e3)},[t]);return(0,H.jsxs)(`div`,{className:`code-block${u?` is-collapsed`:``}`,children:[(0,H.jsxs)(`div`,{className:`code-header`,children:[(0,H.jsx)(`span`,{className:`code-lang`,children:e||`code`}),(0,H.jsxs)(`button`,{className:`code-copy ${n?`copied`:``}`,onClick:f,title:n?`Copied!`:`Copy`,"aria-label":n?`Copied to clipboard`:`Copy code`,children:[n?(0,H.jsx)(ae,{size:13}):(0,H.jsx)(Te,{size:13}),(0,H.jsx)(`span`,{children:n?`Copied`:`Copy`})]})]}),(0,H.jsx)(`pre`,{id:s,children:(0,H.jsx)(`code`,{children:t})}),l&&(0,H.jsx)(mv,{expanded:i,onToggle:()=>a(e=>!e),controls:s,collapsedLabel:`Expand (${c.toLocaleString(`en-US`)} lines)`,expandedLabel:`Collapse`,className:`code-expand-toggle`})]})}var sx=/\b[A-Z]:[\\/][^\s*?"<>|,;)}\]\\/]+(?:[\\/][^\s*?"<>|,;)}\]\\/]+)*[\\/]?/gi,cx=/[.:!']+$/,lx=RegExp(`^(?:${sx.source})$`,`i`);function ux(e){if(typeof e!=`string`)return null;let t=e.trim();return lx.test(t)?t:null}function dx({path:e}){let t=t=>{t.preventDefault(),eo(e).catch(e=>{u.ui.error(`Failed to open path`,e)})};return(0,H.jsxs)(`span`,{className:`file-path-link`,onClick:t,title:`Open in file explorer: ${e}`,role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t(e))},children:[(0,H.jsx)(Ye,{size:12,className:`file-path-icon`}),e]})}function fx(e){let t=new RegExp(sx.source,`gi`),n=[],r=0,i;for(;(i=t.exec(e))!==null;){i.index>r&&n.push(e.slice(r,i.index));let t=i[0].replace(cx,``);n.push((0,H.jsx)(dx,{path:t},i.index)),r=i.index+t.length}return n.length===0?e:(r<e.length&&n.push(e.slice(r)),(0,H.jsx)(H.Fragment,{children:n}))}function px(e){return B.Children.map(e,e=>typeof e==`string`?fx(e):e)}var mx={code({className:e,children:t,node:n,...r}){let i=ux(t);return i?(0,H.jsx)(dx,{path:i}):(0,H.jsx)(`code`,{className:`inline-code`,...r,children:t})},pre({children:e}){let t=B.Children.toArray(e)[0];if(B.isValidElement(t)&&(t.type===`code`||t.props?.className!==void 0||typeof t.props?.children==`string`)){let e=t.props,n=e?.className||``,r=/language-([\w-]+)/.exec(n),i=String(e?.children||``).replace(/\n$/,``),a=r?.[1]||``;return(0,H.jsx)(ox,{lang:a,code:i})}return(0,H.jsx)(`pre`,{children:e})},table({children:e}){return(0,H.jsx)(`div`,{className:`md-table-wrap`,children:(0,H.jsx)(`table`,{className:`md-table`,children:e})})},a({href:e,children:t}){return(0,H.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`md-link`,children:t})},p({children:e}){return(0,H.jsx)(`p`,{className:`md-p`,children:px(e)})},h1({children:e}){return(0,H.jsx)(`h2`,{className:`md-h2`,children:px(e)})},h2({children:e}){return(0,H.jsx)(`h3`,{className:`md-h3`,children:px(e)})},h3({children:e}){return(0,H.jsx)(`h4`,{className:`md-h4`,children:px(e)})},ul({children:e}){return(0,H.jsx)(`ul`,{className:`md-ul`,children:e})},ol({children:e,start:t}){return(0,H.jsx)(`ol`,{className:`md-ol`,start:t,children:e})},li({children:e}){return(0,H.jsx)(`li`,{className:`md-li`,children:px(e)})},blockquote({children:e}){return(0,H.jsx)(`blockquote`,{className:`md-blockquote`,children:px(e)})},hr(){return(0,H.jsx)(`hr`,{className:`md-hr`})},td({children:e}){return(0,H.jsx)(`td`,{children:px(e)})},th({children:e}){return(0,H.jsx)(`th`,{children:px(e)})}};function hx({content:e,showCursor:t,isStreaming:n=!1}){return!e&&!t?null:!e&&t?(0,H.jsx)(`span`,{className:`cursor`}):(0,H.jsx)(ax.Provider,{value:n,children:(0,H.jsxs)(`div`,{className:`md-content`,children:[(0,H.jsx)(Wm,{remarkPlugins:[X_,tv,rv],disallowedElements:[...Ym],urlTransform:Xm,components:mx,children:e}),t&&(0,H.jsx)(`span`,{className:`cursor`})]})})}var gx=1e3,_x=15e3,vx=null,yx=null,bx=gx,xx=0,Sx=null;function Cx(){if(vx)return vx;let e=Date.now();return vx=fi().then(t=>V.getState().setActiveRuns(t,e)).catch(e=>u.api.warn(`Could not read which chats are running`,e)).finally(()=>{vx=null}),vx}function wx(){let e=V.getState();return e.isStreaming||e.runningSessionIds.length>0}function Tx(){return wx()?(bx=gx,gx):(bx=Math.min(bx*2,_x),bx)}function Ex(e){Cx().then(()=>{e===xx&&(yx=setTimeout(()=>Ex(e),Tx()))})}function Dx(){Sx&&(yx&&clearTimeout(yx),yx=null,bx=gx,Ex(++xx))}function Ox(){Sx?.();let e=V.subscribe((e,t)=>{e.isStreaming&&!t.isStreaming&&Dx()}),t=()=>Dx();window.addEventListener(`focus`,t);let n=()=>{xx++,yx&&clearTimeout(yx),yx=null,e(),window.removeEventListener(`focus`,t),Sx===n&&(Sx=null)};return Sx=n,bx=gx,Ex(++xx),n}var kx=[0,3e3,1e4],Ax=`The answer to your last message was lost: its run stopped before it finished, most often because GAIA restarted. Send the message again.`;function jx(e){return e.name===`StreamStalledError`||e.name===`StreamDroppedError`}function Mx(e){if(jx(e))return`Lost the live view of this answer: the connection to GAIA dropped 4 times. The answer may still finish. Reopen this chat in a minute to see it.`;if(e instanceof Ra)return e.endpoint===`send`?`GAIA did not start this answer within ${Math.round(e.timeoutMs/1e3)} seconds; it may be busy or stuck. If the chat list shows this chat running, reopen it later to see the answer. Otherwise, send the message again.`:`GAIA did not respond when this chat reconnected to its running answer. The answer may still finish: check that GAIA is still running, then reopen this chat.`;if(e instanceof Ci){let t=e.detail?bi(e.detail):``;return e.httpStatus===429?`GAIA is busy with another chat, so this message was not sent. Send it again when that chat finishes.`:e.httpStatus===409?t||`This chat is already answering a message. Wait for it to finish, or press Stop.`:`GAIA could not take this message (HTTP ${e.httpStatus})${t?`: ${t}`:`.`}`}return null}var Nx=3e3,Px=new Set,Fx=new Map,Ix=new Set,Lx=null;function Rx(e,t=Date.now()){Fx.set(e,t)}function zx(e){let t=V.getState();return t.activeRunsAt>0&&t.activeRunsAt>=(Fx.get(e)??0)&&!t.runningSessionIds.includes(e)&&!t.queuedSessionIds.includes(e)}function Bx(e){return Ix.add(e),()=>{Ix.delete(e),Lx?.()}}function Vx(e){return e instanceof Error?Mx(e)??(e.message||`Unknown error`):String(e)}function Hx(e){let t=e?.httpStatus;return typeof t==`number`?t:void 0}function Ux(e){let t=Hx(e);return t===409||t===429}function Wx(e){V.getState().setQueueHold(e,!0),setTimeout(()=>V.getState().setQueueHold(e,!1),Nx)}function Gx(e,t,n){return Hx(n)===409&&(u.chat.info(`Chat ${e} was busy; queueing the message to try again`),V.getState().updateQueue(e,e=>br(e,t,`queued`)),Wx(e),!0)}async function Kx(e,t,n){let r=V.getState;if(Px.has(e)||r().queueHolds[e])return;let i=r().messageQueues[e]??[];if(i.some(e=>e.state===`sending`))return;let a=Dr(i);if(a||jr(i)){Px.add(e);try{if(a){let t;try{t=await si(e)}catch(t){if(Hx(t)===409){u.chat.info(`Chat ${e} is answering again; its queue waits for that turn to end`);return}u.chat.error(`Could not learn what chat ${e}'s last reply did with the messages added to it`,t),r().updateQueue(e,e=>Ar(e,`GAIA could not say whether it read this message: ${Vx(t)}`));return}r().updateQueue(e,e=>kr(e,t))}let i=jr(r().messageQueues[e]??[]);if(!i||!n())return;r().updateQueue(e,e=>xr(e,i.id,`queued`,`starting`));let o;try{o=await t(e,i.text)}catch(e){o={kind:`failed`,error:Vx(e)}}if(o.kind===`accepted`){Rx(e),r().updateQueue(e,e=>Sr(e,i.id)),Dx();return}if(o.kind===`busy`){u.chat.info(`Queued message found chat ${e} busy; holding it`),r().updateQueue(e,e=>Cr(e,i.id)),Wx(e);return}u.chat.error(`Queued message for chat ${e} was not sent: ${o.error}`),r().updateQueue(e,e=>Cr(e,i.id,o.error))}finally{Px.delete(e)}}}function qx(e){return e.type!==`status`||e.phase!==`waiting`}var Jx=(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`});u.chat.info(`Sending queued message for chat ${e} in the background`),i=ka(e,t,{onChunk:s,onAgentEvent:e=>{qx(e)&&s()},onDone:s,onError:e=>{jx(e)?s():Ux(e)?o({kind:`busy`}):o({kind:`failed`,error:Vx(e)})}}),a&&i.abort()});function Yx(e=Jx){let t=()=>{let t=V.getState();if(t.systemStatus?.init_state!==`initializing`)for(let n of Object.keys(t.messageQueues))!Ix.has(n)&&zx(n)&&Kx(n,e,()=>!Ix.has(n))},n=V.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 Lx=t,t(),()=>{n(),Lx===t&&(Lx=null)}}var Xx=`https://github.com/amd/gaia/issues/new`,Zx=[{label:`Image`,extensions:new Set([`.jpg`,`.jpeg`,`.png`,`.gif`,`.bmp`,`.tiff`,`.webp`,`.ico`,`.heic`,`.heif`]),message:`Image files cannot be indexed for text search.`,alternatives:[`Index PDFs that contain images — text is extracted automatically`,`Paste image descriptions or OCR text directly into the chat`,`Use GAIA's VLM agent for image analysis: gaia vlm`],featureTitle:`Support image file indexing and OCR`},{label:`Video`,extensions:new Set([`.mp4`,`.avi`,`.mkv`,`.mov`,`.wmv`,`.flv`,`.webm`,`.m4v`]),message:`Video files are not supported for indexing.`,alternatives:[`Extract subtitles or transcripts from videos and index those`,`Use GAIA's voice/talk mode for audio: gaia talk`],featureTitle:`Support video file indexing`},{label:`Audio`,extensions:new Set([`.mp3`,`.wav`,`.flac`,`.aac`,`.ogg`,`.wma`,`.m4a`,`.opus`]),message:`Audio files are not supported for indexing.`,alternatives:[`Use GAIA's voice mode for speech interaction: gaia talk`,`Transcribe audio to text first, then index the transcript`],featureTitle:`Support audio file transcription and indexing`},{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 Qx(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;for(let e of Zx)if(e.extensions.has(t))return e;return null}var $x=new Set(`.pdf,.pptx,.docx,.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 eS(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;return $x.has(t)}function tS(){let e=navigator.userAgent;return`**Environment:**\n- GAIA Version: 0.25.2rc1\n- Platform: ${navigator.platform||`unknown`}\n- User Agent: ${e}\n- Interface: Agent UI (Web)`}function nS(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?_`,``,`---`,tS(),``,`_Submitted from GAIA Agent UI_`].join(`
58
+ `)}function ex(e){return e?new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`,second:`2-digit`,hour12:!0}):``}var tx=`Cancelled.`,nx=[`This answer was interrupted when GAIA closed. Send again to retry.`,`This answer was interrupted before it finished. Send again to retry.`,`This answer ended before GAIA could save a reply. Send again to retry.`];function rx(e,t){if(t)return`stopped`;let n=e.trim();return nx.some(e=>n.endsWith(e))?`interrupted`:void 0}function ix({message:e,isStreaming:t,agentSteps:n,agentStepsActive:r,agentStepCount:i,cards:a,onDelete:o,onResend:s,extraActions:c,latencyMs:l,liveStatus:u,awaitingUser:d}){Wo();let f=(0,B.useMemo)(()=>e.role===`assistant`&&!t&&n?Bb(n,e.content):{steps:n,echoed:!1},[n,e.content,e.role,t]),p=e.role===`assistant`&&(f.echoed||Rb(e.content)),m=e.role===`assistant`?e.stopState??(e.content.trim()===tx?`stopped`:void 0):void 0,h=(0,B.useMemo)(()=>e.role===`user`?e.content:Qb(e.content,!!t),[e.content,e.role,t]),[g,_]=(0,B.useState)(!1),[v,y]=(0,B.useState)(!1),b=e.role===`user`&&fv(e.content),[x,S]=(0,B.useState)(!1),C=(0,B.useId)(),w=(0,B.useRef)(null),T=(0,B.useRef)(!1),E=(0,B.useCallback)(()=>{x&&(T.current=!0),S(!x)},[x]);(0,B.useEffect)(()=>{!x&&T.current&&(T.current=!1,w.current?.scrollIntoView?.({block:`nearest`}))},[x]);let D=(0,B.useRef)(null),O=(0,B.useRef)(null);(0,B.useEffect)(()=>()=>{D.current&&clearTimeout(D.current),O.current&&clearTimeout(O.current)},[]);let k=(0,B.useCallback)(()=>{if(navigator.clipboard?.writeText)navigator.clipboard.writeText(e.content).catch(()=>{});else{let t=document.createElement(`textarea`);t.value=e.content,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),document.execCommand(`copy`),document.body.removeChild(t)}_(!0),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>_(!1),2e3)},[e.content]),A=(0,B.useCallback)(()=>{v?(y(!1),O.current&&clearTimeout(O.current),o?.(e.id)):(y(!0),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>y(!1),3e3))},[v,e.id,o]),j=(0,B.useCallback)(()=>{s?.(e)},[e,s]),M=e.created_at?`${e.role===`user`?`Sent`:`Replied`} ${ex(e.created_at)}`:void 0;return(0,H.jsx)(`div`,{className:`msg msg-${e.role} ${p?`msg-error`:``}`,title:M,children:(0,H.jsxs)(`div`,{className:`msg-inner`,children:[(0,H.jsxs)(`div`,{className:`msg-header`,children:[(0,H.jsx)(`div`,{className:`msg-header-left`,children:e.role===`assistant`&&t&&(0,H.jsx)(Fb,{active:!!r||!h,label:u,awaitingUser:d})}),!t&&(0,H.jsxs)(`div`,{className:`msg-actions`,children:[e.role===`user`&&s&&(0,H.jsx)(`button`,{className:`msg-action-btn`,onClick:j,title:`Resend message`,"aria-label":`Resend message`,children:(0,H.jsx)(Xt,{size:12})}),c,(0,H.jsx)(`button`,{className:`msg-copy ${g?`copied`:``}`,onClick:k,title:g?`Copied!`:`Copy message`,"aria-label":g?`Copied to clipboard`:`Copy message`,children:g?(0,H.jsx)(ae,{size:12}):(0,H.jsx)(Te,{size:12})}),o&&(0,H.jsx)(`button`,{className:`msg-action-btn msg-delete ${v?`confirm`:``}`,onClick:A,title:v?`Click again to confirm`:`Delete message`,"aria-label":v?`Confirm delete message`:`Delete message`,children:(0,H.jsx)(xn,{size:12})})]})]}),(0,H.jsxs)(`div`,{className:`msg-body`,children:[f.steps&&f.steps.length>0&&(0,H.jsx)(Vv,{steps:f.steps,isActive:r??!1,variant:r?`inline`:`summary`,agentStepCount:i??e.stats?.steps??void 0,awaitingUser:d}),p&&(0,H.jsxs)(`div`,{className:`error-banner`,children:[(0,H.jsx)(Cn,{size:14}),(0,H.jsx)(`span`,{children:`Something went wrong`})]}),(e.cards??a)?.map((e,t)=>(0,H.jsx)(Yy,{render:e.render,data:e.data},t)),b?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{ref:w,id:C,className:`msg-collapsible${x?``:` is-collapsed`}`,children:(0,H.jsx)(hx,{content:h})}),(0,H.jsx)(mv,{expanded:x,onToggle:E,controls:C,collapsedLabel:`Show all (${pv(e.content)})`,expandedLabel:`Show less`,className:`msg-expand-toggle`})]}):!(m&&h.trim()===tx)&&(0,H.jsx)(hx,{content:h,showCursor:t&&!!h&&!r,isStreaming:t}),m&&(0,H.jsxs)(`div`,{className:`msg-stopped${m===`unconfirmed`||e.stopError?` is-unconfirmed`:``}`,role:`note`,children:[(0,H.jsx)(_n,{size:9,fill:`currentColor`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{children:m===`unconfirmed`?`Stopped. GAIA did not confirm the stop, so some steps may be missing here. Reload the chat to see what it saved.`:e.stopError?`Stopped. GAIA reported an error while stopping: ${e.stopError}`:`Stopped`})]}),e.role===`assistant`&&!t&&oy(h)&&(0,H.jsx)(uy,{content:h}),e.role===`assistant`&&!t&&(e.stats||l!=null||e.created_at)&&(0,H.jsxs)(`div`,{className:`msg-stats`,"aria-label":`About this answer`,children:[e.created_at&&(0,H.jsx)(`span`,{className:`msg-stats-ts`,title:`Message timestamp`,children:ex(e.created_at)}),e.stats?.retried&&e.stats.model&&(0,H.jsx)(`span`,{title:`This answer was kept from Retry with… (${e.stats.model})`,children:Go(e.stats.model)}),(0,H.jsx)(eb,{latencyMs:l,stats:e.stats,ended:rx(e.content,m)})]}),e.role===`assistant`&&!t&&e.id>0&&e.session_id&&(0,H.jsx)(Pb,{sessionId:e.session_id,messageId:e.id})]})]})})}var ax=(0,B.createContext)(!1);function ox({lang:e,code:t}){let[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(!1),o=(0,B.useContext)(ax),s=(0,B.useId)(),c=dv(t),l=c>(o?20:25),u=l&&!i,d=(0,B.useRef)(null);(0,B.useEffect)(()=>()=>{d.current&&clearTimeout(d.current)},[]);let f=(0,B.useCallback)(()=>{if(navigator.clipboard?.writeText)navigator.clipboard.writeText(t).catch(()=>{});else{let e=document.createElement(`textarea`);e.value=t,e.style.position=`fixed`,e.style.opacity=`0`,document.body.appendChild(e),e.select(),document.execCommand(`copy`),document.body.removeChild(e)}r(!0),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>r(!1),2e3)},[t]);return(0,H.jsxs)(`div`,{className:`code-block${u?` is-collapsed`:``}`,children:[(0,H.jsxs)(`div`,{className:`code-header`,children:[(0,H.jsx)(`span`,{className:`code-lang`,children:e||`code`}),(0,H.jsxs)(`button`,{className:`code-copy ${n?`copied`:``}`,onClick:f,title:n?`Copied!`:`Copy`,"aria-label":n?`Copied to clipboard`:`Copy code`,children:[n?(0,H.jsx)(ae,{size:13}):(0,H.jsx)(Te,{size:13}),(0,H.jsx)(`span`,{children:n?`Copied`:`Copy`})]})]}),(0,H.jsx)(`pre`,{id:s,children:(0,H.jsx)(`code`,{children:t})}),l&&(0,H.jsx)(mv,{expanded:i,onToggle:()=>a(e=>!e),controls:s,collapsedLabel:`Expand (${c.toLocaleString(`en-US`)} lines)`,expandedLabel:`Collapse`,className:`code-expand-toggle`})]})}var sx=/\b[A-Z]:[\\/][^\s*?"<>|,;)}\]\\/]+(?:[\\/][^\s*?"<>|,;)}\]\\/]+)*[\\/]?/gi,cx=/[.:!']+$/,lx=RegExp(`^(?:${sx.source})$`,`i`);function ux(e){if(typeof e!=`string`)return null;let t=e.trim();return lx.test(t)?t:null}function dx({path:e}){let t=t=>{t.preventDefault(),eo(e).catch(e=>{u.ui.error(`Failed to open path`,e)})};return(0,H.jsxs)(`span`,{className:`file-path-link`,onClick:t,title:`Open in file explorer: ${e}`,role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t(e))},children:[(0,H.jsx)(Ye,{size:12,className:`file-path-icon`}),e]})}function fx(e){let t=new RegExp(sx.source,`gi`),n=[],r=0,i;for(;(i=t.exec(e))!==null;){i.index>r&&n.push(e.slice(r,i.index));let t=i[0].replace(cx,``);n.push((0,H.jsx)(dx,{path:t},i.index)),r=i.index+t.length}return n.length===0?e:(r<e.length&&n.push(e.slice(r)),(0,H.jsx)(H.Fragment,{children:n}))}function px(e){return B.Children.map(e,e=>typeof e==`string`?fx(e):e)}var mx={code({className:e,children:t,node:n,...r}){let i=ux(t);return i?(0,H.jsx)(dx,{path:i}):(0,H.jsx)(`code`,{className:`inline-code`,...r,children:t})},pre({children:e}){let t=B.Children.toArray(e)[0];if(B.isValidElement(t)&&(t.type===`code`||t.props?.className!==void 0||typeof t.props?.children==`string`)){let e=t.props,n=e?.className||``,r=/language-([\w-]+)/.exec(n),i=String(e?.children||``).replace(/\n$/,``),a=r?.[1]||``;return(0,H.jsx)(ox,{lang:a,code:i})}return(0,H.jsx)(`pre`,{children:e})},table({children:e}){return(0,H.jsx)(`div`,{className:`md-table-wrap`,children:(0,H.jsx)(`table`,{className:`md-table`,children:e})})},a({href:e,children:t}){return(0,H.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`md-link`,children:t})},p({children:e}){return(0,H.jsx)(`p`,{className:`md-p`,children:px(e)})},h1({children:e}){return(0,H.jsx)(`h2`,{className:`md-h2`,children:px(e)})},h2({children:e}){return(0,H.jsx)(`h3`,{className:`md-h3`,children:px(e)})},h3({children:e}){return(0,H.jsx)(`h4`,{className:`md-h4`,children:px(e)})},ul({children:e}){return(0,H.jsx)(`ul`,{className:`md-ul`,children:e})},ol({children:e,start:t}){return(0,H.jsx)(`ol`,{className:`md-ol`,start:t,children:e})},li({children:e}){return(0,H.jsx)(`li`,{className:`md-li`,children:px(e)})},blockquote({children:e}){return(0,H.jsx)(`blockquote`,{className:`md-blockquote`,children:px(e)})},hr(){return(0,H.jsx)(`hr`,{className:`md-hr`})},td({children:e}){return(0,H.jsx)(`td`,{children:px(e)})},th({children:e}){return(0,H.jsx)(`th`,{children:px(e)})}};function hx({content:e,showCursor:t,isStreaming:n=!1}){return!e&&!t?null:!e&&t?(0,H.jsx)(`span`,{className:`cursor`}):(0,H.jsx)(ax.Provider,{value:n,children:(0,H.jsxs)(`div`,{className:`md-content`,children:[(0,H.jsx)(Wm,{remarkPlugins:[X_,tv,rv],disallowedElements:[...Ym],urlTransform:Xm,components:mx,children:e}),t&&(0,H.jsx)(`span`,{className:`cursor`})]})})}var gx=1e3,_x=15e3,vx=null,yx=null,bx=gx,xx=0,Sx=null;function Cx(){if(vx)return vx;let e=Date.now();return vx=fi().then(t=>V.getState().setActiveRuns(t,e)).catch(e=>u.api.warn(`Could not read which chats are running`,e)).finally(()=>{vx=null}),vx}function wx(){let e=V.getState();return e.isStreaming||e.runningSessionIds.length>0}function Tx(){return wx()?(bx=gx,gx):(bx=Math.min(bx*2,_x),bx)}function Ex(e){Cx().then(()=>{e===xx&&(yx=setTimeout(()=>Ex(e),Tx()))})}function Dx(){Sx&&(yx&&clearTimeout(yx),yx=null,bx=gx,Ex(++xx))}function Ox(){Sx?.();let e=V.subscribe((e,t)=>{e.isStreaming&&!t.isStreaming&&Dx()}),t=()=>Dx();window.addEventListener(`focus`,t);let n=()=>{xx++,yx&&clearTimeout(yx),yx=null,e(),window.removeEventListener(`focus`,t),Sx===n&&(Sx=null)};return Sx=n,bx=gx,Ex(++xx),n}var kx=[0,3e3,1e4],Ax=`The answer to your last message was lost: its run stopped before it finished, most often because GAIA restarted. Send the message again.`;function jx(e){return e.name===`StreamStalledError`||e.name===`StreamDroppedError`}function Mx(e){if(jx(e))return`Lost the live view of this answer: the connection to GAIA dropped 4 times. The answer may still finish. Reopen this chat in a minute to see it.`;if(e instanceof Ra)return e.endpoint===`send`?`GAIA did not start this answer within ${Math.round(e.timeoutMs/1e3)} seconds; it may be busy or stuck. If the chat list shows this chat running, reopen it later to see the answer. Otherwise, send the message again.`:`GAIA did not respond when this chat reconnected to its running answer. The answer may still finish: check that GAIA is still running, then reopen this chat.`;if(e instanceof Ci){let t=e.detail?bi(e.detail):``;return e.httpStatus===429?`GAIA is busy with another chat, so this message was not sent. Send it again when that chat finishes.`:e.httpStatus===409?t||`This chat is already answering a message. Wait for it to finish, or press Stop.`:`GAIA could not take this message (HTTP ${e.httpStatus})${t?`: ${t}`:`.`}`}return null}var Nx=3e3,Px=new Set,Fx=new Map,Ix=new Set,Lx=null;function Rx(e,t=Date.now()){Fx.set(e,t)}function zx(e){let t=V.getState();return t.activeRunsAt>0&&t.activeRunsAt>=(Fx.get(e)??0)&&!t.runningSessionIds.includes(e)&&!t.queuedSessionIds.includes(e)}function Bx(e){return Ix.add(e),()=>{Ix.delete(e),Lx?.()}}function Vx(e){return e instanceof Error?Mx(e)??(e.message||`Unknown error`):String(e)}function Hx(e){let t=e?.httpStatus;return typeof t==`number`?t:void 0}function Ux(e){let t=Hx(e);return t===409||t===429}function Wx(e){V.getState().setQueueHold(e,!0),setTimeout(()=>V.getState().setQueueHold(e,!1),Nx)}function Gx(e,t,n){return Hx(n)===409&&(u.chat.info(`Chat ${e} was busy; queueing the message to try again`),V.getState().updateQueue(e,e=>br(e,t,`queued`)),Wx(e),!0)}async function Kx(e,t,n){let r=V.getState;if(Px.has(e)||r().queueHolds[e])return;let i=r().messageQueues[e]??[];if(i.some(e=>e.state===`sending`))return;let a=Dr(i);if(a||jr(i)){Px.add(e);try{if(a){let t;try{t=await si(e)}catch(t){if(Hx(t)===409){u.chat.info(`Chat ${e} is answering again; its queue waits for that turn to end`);return}u.chat.error(`Could not learn what chat ${e}'s last reply did with the messages added to it`,t),r().updateQueue(e,e=>Ar(e,`GAIA could not say whether it read this message: ${Vx(t)}`));return}r().updateQueue(e,e=>kr(e,t))}let i=jr(r().messageQueues[e]??[]);if(!i||!n())return;r().updateQueue(e,e=>xr(e,i.id,`queued`,`starting`));let o;try{o=await t(e,i.text)}catch(e){o={kind:`failed`,error:Vx(e)}}if(o.kind===`accepted`){Rx(e),r().updateQueue(e,e=>Sr(e,i.id)),Dx();return}if(o.kind===`busy`){u.chat.info(`Queued message found chat ${e} busy; holding it`),r().updateQueue(e,e=>Cr(e,i.id)),Wx(e);return}u.chat.error(`Queued message for chat ${e} was not sent: ${o.error}`),r().updateQueue(e,e=>Cr(e,i.id,o.error))}finally{Px.delete(e)}}}function qx(e){return e.type!==`status`||e.phase!==`waiting`}var Jx=(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`});u.chat.info(`Sending queued message for chat ${e} in the background`),i=ka(e,t,{onChunk:s,onAgentEvent:e=>{qx(e)&&s()},onDone:s,onError:e=>{jx(e)?s():Ux(e)?o({kind:`busy`}):o({kind:`failed`,error:Vx(e)})}}),a&&i.abort()});function Yx(e=Jx){let t=()=>{let t=V.getState();if(t.systemStatus?.init_state!==`initializing`)for(let n of Object.keys(t.messageQueues))!Ix.has(n)&&zx(n)&&Kx(n,e,()=>!Ix.has(n))},n=V.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 Lx=t,t(),()=>{n(),Lx===t&&(Lx=null)}}var Xx=`https://github.com/amd/gaia/issues/new`,Zx=[{label:`Image`,extensions:new Set([`.jpg`,`.jpeg`,`.png`,`.gif`,`.bmp`,`.tiff`,`.webp`,`.ico`,`.heic`,`.heif`]),message:`Image files cannot be indexed for text search.`,alternatives:[`Index PDFs that contain images — text is extracted automatically`,`Paste image descriptions or OCR text directly into the chat`,`Use GAIA's VLM agent for image analysis: gaia vlm`],featureTitle:`Support image file indexing and OCR`},{label:`Video`,extensions:new Set([`.mp4`,`.avi`,`.mkv`,`.mov`,`.wmv`,`.flv`,`.webm`,`.m4v`]),message:`Video files are not supported for indexing.`,alternatives:[`Extract subtitles or transcripts from videos and index those`,`Use GAIA's voice/talk mode for audio: gaia talk`],featureTitle:`Support video file indexing`},{label:`Audio`,extensions:new Set([`.mp3`,`.wav`,`.flac`,`.aac`,`.ogg`,`.wma`,`.m4a`,`.opus`]),message:`Audio files are not supported for indexing.`,alternatives:[`Use GAIA's voice mode for speech interaction: gaia talk`,`Transcribe audio to text first, then index the transcript`],featureTitle:`Support audio file transcription and indexing`},{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 Qx(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;for(let e of Zx)if(e.extensions.has(t))return e;return null}var $x=new Set(`.pdf,.pptx,.docx,.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 eS(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;return $x.has(t)}function tS(){let e=navigator.userAgent;return`**Environment:**\n- GAIA Version: 0.25.2rc2\n- Platform: ${navigator.platform||`unknown`}\n- User Agent: ${e}\n- Interface: Agent UI (Web)`}function nS(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?_`,``,`---`,tS(),``,`_Submitted from GAIA Agent UI_`].join(`
59
59
  `);return`${Xx}?${new URLSearchParams({title:`[Feature] ${e}`,body:n,labels:`enhancement,agent-ui`}).toString()}`}function rS(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?_`,``,`---`,tS(),``,`_Submitted from GAIA Agent UI_`].join(`
60
60
  `);return`${Xx}?${new URLSearchParams({title:`[Bug] ${e}`,body:n,labels:`bug,agent-ui`}).toString()}`}var iS={corrupted:`The file looks damaged. Re-download or re-export it, then index the new copy.`,encrypted:`The PDF needs a password to open. Save a copy without the password, then index that.`,empty:`The PDF has no readable text, which usually means it is a scan. Run OCR on it, then index it again.`,empty_file:`This file is empty. Add content to it, then index 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 index that.`};function aS(e,t){return e.startsWith(t)?e.slice(t.length).trim():e}function oS({filename:e,error:t,status:n,kind:r,onDismiss:i,timeout:a=15e3}){let o=(0,B.useRef)(null);(0,B.useEffect)(()=>(a>0&&(o.current=setTimeout(i,a)),()=>{o.current&&clearTimeout(o.current)}),[i,a]);let s=e.includes(`.`)?`.`+e.split(`.`).pop()?.toLowerCase():``,c=s?Qx(s):null,l=t.toLowerCase().includes(`unsupported file type`)||t.toLowerCase().includes(`not supported for indexing`)||t.toLowerCase().includes(`file type not allowed`)||c!==null,u=t.toLowerCase().includes(`fetch`)||t.toLowerCase().includes(`network`)||t.toLowerCase().includes(`connect`),d,f,p,m=pe,h=r?iS[r]:void 0;return h?(d=`"${e}" can't be read`,f=h,p=null,m=Cn):n===404?(d=`"${e}" doesn't exist`,f=aS(t,`File not found:`),p=null,m=Cn):n===403?(d=`GAIA can't read files in that location`,f=`${t} Or drop the file here instead (up to 20 MB) and GAIA keeps its own copy.`,p=null,m=Cn):l&&c?(d=`${c.label} files not supported`,f=c.message,p=nS(c.featureTitle),m=Cn):l&&!s?(d=`"${e}" has no file extension`,f=aS(t,`File type not allowed:`),p=null,m=Cn):l?(d=`File type not supported: ${s}`,f=`This file format cannot be indexed. Supported: PDF, PPTX, TXT, MD, CSV, JSON, XLSX, HTML, XML, YAML, and 30+ code file formats.`,p=nS(`Support ${s} file indexing`),m=Cn):u?(d=`Connection error`,f=`Could not reach the GAIA server. Make sure the backend is running.`,p=rS(`Upload connection error for ${e}`),m=pe):(d=`Failed to index "${e}"`,f=t||`An unexpected error occurred during indexing.`,p=rS(`Indexing error: ${t.slice(0,80)}`),m=ee),(0,H.jsxs)(`div`,{className:`upload-error-toast`,role:`alert`,children:[(0,H.jsx)(m,{size:16}),(0,H.jsxs)(`div`,{className:`upload-error-content`,children:[(0,H.jsx)(`div`,{className:`upload-error-title`,children:d}),(0,H.jsxs)(`div`,{className:`upload-error-detail`,children:[f,p&&` `,p===null?null:l?(0,H.jsx)(`a`,{href:p,target:`_blank`,rel:`noopener noreferrer`,children:`Request this feature →`}):(0,H.jsx)(`a`,{href:p,target:`_blank`,rel:`noopener noreferrer`,children:`Report this issue →`})]})]}),(0,H.jsx)(`button`,{className:`upload-error-dismiss`,onClick:i,"aria-label":`Dismiss`,children:(0,H.jsx)(Nn,{size:14})})]})}function sS(e,t){let n=e=>t.some(t=>t.id===e&&t.configured),r=sy(e);return r===`google`?n(`google`):r===`microsoft`?n(`microsoft`):r===`microsoft_work`?n(`microsoft_work`):n(`google`)||n(`microsoft`)||n(`microsoft_work`)}function cS(e,t){let n=e=>t.some(t=>t.id===e&&t.configured),r=sy(e);return r===`google`?`Google`:r===`microsoft`?`Microsoft`:r===`microsoft_work`?`Microsoft 365`:n(`google`)?`Google`:n(`microsoft`)?`Microsoft`:n(`microsoft_work`)?`Microsoft 365`:`Google`}var lS=4e3;function uS({content:e,onRetry:t}){let[n,r]=(0,B.useState)([]),[i,a]=(0,B.useState)(!1),o=(0,B.useCallback)(()=>{Wr().then(e=>r(e.connectors||[])).catch(e=>u.ui.warn(`ConnectorRetryBanner: connector fetch failed`,e))},[]),s=sS(e,n);if((0,B.useEffect)(()=>{o();let e=()=>o();return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[o]),(0,B.useEffect)(()=>{if(s)return;let e=setInterval(o,lS);return()=>clearInterval(e)},[s,o]),!s||i)return null;let c=cS(e,n);return(0,H.jsxs)(`div`,{className:`connector-retry-banner`,role:`status`,children:[(0,H.jsx)(I,{size:14,className:`connector-retry-banner__icon`}),(0,H.jsxs)(`span`,{className:`connector-retry-banner__text`,children:[c,` connected since this reply — ask again to run it now.`]}),(0,H.jsxs)(`button`,{type:`button`,className:`connector-retry-banner__btn`,onClick:()=>{a(!0),t()},children:[(0,H.jsx)(Xt,{size:12}),(0,H.jsx)(`span`,{children:`Ask again`})]}),(0,H.jsx)(`button`,{type:`button`,className:`connector-retry-banner__dismiss`,onClick:()=>a(!0),"aria-label":`Dismiss`,children:`×`})]})}var dS=240,fS=1e5;function pS({value:e,onChange:t,onSubmit:n,onStop:r,streaming:i=!1,stopping:a=!1,queueWhileStreaming:o=!1,disabledReason:s,attachments:c,placeholder:l=`Ask GAIA anything`,autoFocus:u,inputRef:d,leftControls:f,rightControls:p}){let m=(0,B.useRef)(null),h=d??m,g=(0,B.useRef)(null),_=!!s,v=e.trim().length>0||c.hasUploaded,y=c.compose(e.trim()).length,b=y>fS,x=!_&&(!i||o)&&!c.uploading&&v&&!b,S=s||l;(0,B.useLayoutEffect)(()=>{let e=h.current;if(!e)return;let t=()=>{e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,dS)}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,S,h]);let C=(0,B.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),x&&n())},[x,n]),w=(0,B.useCallback)(e=>{e.dataTransfer?.files?.length&&(e.preventDefault(),e.stopPropagation(),c.addFiles(Array.from(e.dataTransfer.files)))},[c]);return(0,H.jsxs)(`div`,{className:`composer${_?` composer-disabled`:``}`,onDrop:w,onDragOver:e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault()},children:[c.attachments.length>0&&(0,H.jsx)(`ul`,{className:`composer-attachments`,"aria-label":`Attached files`,children:c.attachments.map(e=>(0,H.jsxs)(`li`,{className:`composer-attachment${e.error?` has-error`:``}`,children:[e.isImage&&e.url?(0,H.jsx)(`img`,{src:e.url,alt:``,className:`composer-attachment-thumb`}):(0,H.jsx)(Ge,{size:14,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`composer-attachment-name`,title:e.name,children:e.name}),e.uploading&&(0,H.jsx)(`span`,{className:`composer-attachment-state`,children:`Uploading…`}),e.error&&(0,H.jsx)(`span`,{className:`composer-attachment-state`,role:`alert`,children:e.error}),(0,H.jsx)(`button`,{type:`button`,className:`composer-icon-btn`,onClick:()=>c.remove(e.id),"aria-label":`Remove ${e.name}`,children:(0,H.jsx)(Nn,{size:12})})]},e.id))}),(0,H.jsx)(`textarea`,{ref:h,className:`composer-input`,value:e,onChange:e=>t(e.target.value),onKeyDown:C,onPaste:e=>{c.handlePaste(e)},placeholder:S,rows:1,disabled:_,autoFocus:u,"aria-label":`Message`}),b&&(0,H.jsxs)(`p`,{className:`composer-limit-error`,role:`alert`,children:[`Too long to send: `,y.toLocaleString(),` of `,1e5.toLocaleString(),` characters.`,` `,`Save it as a file and attach it with +, and GAIA can read all of it.`]}),(0,H.jsxs)(`div`,{className:`composer-row`,children:[(0,H.jsxs)(`div`,{className:`composer-row-left`,children:[(0,H.jsx)(`button`,{type:`button`,className:`composer-icon-btn`,onClick:()=>g.current?.click(),disabled:_,"aria-label":`Attach files`,title:`Attach files`,children:(0,H.jsx)(Jt,{size:16})}),(0,H.jsx)(`input`,{ref:g,type:`file`,multiple:!0,hidden:!0,onChange:e=>{e.target.files&&c.addFiles(Array.from(e.target.files)),e.target.value=``}}),f]}),(0,H.jsxs)(`div`,{className:`composer-row-right`,children:[p,i&&o&&v&&(0,H.jsx)(`button`,{type:`button`,className:`composer-send`,onClick:n,disabled:!x,"aria-label":`Queue message`,title:`Queue it to send when this reply ends (Enter)`,children:(0,H.jsx)(E,{size:16})}),i?(0,H.jsx)(`button`,{type:`button`,className:`composer-send is-stop`,onClick:r,disabled:a,"aria-label":`Stop`,title:a?`Stopping…`:`Stop (Esc)`,children:(0,H.jsx)(_n,{size:12,fill:`currentColor`})}):(0,H.jsx)(`button`,{type:`button`,className:`composer-send`,onClick:n,disabled:!x,"aria-label":`Send`,title:`Send (Enter)`,children:(0,H.jsx)(E,{size:16})})]})]})]})}var mS=8,hS=8;function gS({label:e,warning:t,children:n,id:r,pinned:i=!1,onUnpin:a,tabIndex:o}){let s=(0,B.useId)(),c=r??s,l=(0,B.useRef)(null),u=(0,B.useRef)(null),[d,f]=(0,B.useState)(!1),p=d||i,[m,h]=(0,B.useState)(null);return(0,B.useLayoutEffect)(()=>{if(!p){h(null);return}let e=l.current?.getBoundingClientRect(),t=u.current?.getBoundingClientRect(),n=l.current?.closest(`[role="dialog"]`)?.getBoundingClientRect()??e;if(!e||!t||!n)return;let r=window.innerWidth,i=window.innerHeight,a,o;n.right+mS+t.width<=r-hS?(a=n.right+mS,o=e.top+e.height/2-t.height/2):n.left-mS-t.width>=hS?(a=n.left-mS-t.width,o=e.top+e.height/2-t.height/2):(a=Math.min(Math.max(hS,e.right-t.width),r-hS-t.width),o=e.top-mS-t.height>=hS?e.top-mS-t.height:e.bottom+mS),o=Math.min(Math.max(hS,o),i-hS-t.height),h({left:a,top:o})},[p]),(0,B.useEffect)(()=>{if(!p)return;let e=()=>{f(!1),a?.()};return window.addEventListener(`scroll`,e,!0),()=>window.removeEventListener(`scroll`,e,!0)},[p,a]),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`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:(0,H.jsx)(ht,{size:13,"aria-hidden":`true`})}),p&&(0,Sb.createPortal)((0,H.jsx)(`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 _S(e){return e<.1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function vS(e){return e?`${_S(e.input_per_million)} in · ${_S(e.output_per_million)} out per 1M tokens`:`price unknown`}function yS(e){return`$${e.toFixed(2)}`}var bS=2e3,xS=`waiting_for_os_permission`,SS=5;function CS(e,t){let n=e.rank?`#${e.rank} ${e.note??``}`.trim():null;return t?[n,vS(e.price)].filter(e=>!!e):[ns(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].filter(e=>!!e)}function wS({m:e,onDownload:t,busy:n}){if(as(e)){let t=Math.round(e.download_progress?.percent??0);return(0,H.jsxs)(`span`,{className:`model-state is-downloading`,title:`Downloading, ${t}%`,children:[(0,H.jsx)(z,{size:12,className:`spin`,"aria-hidden":`true`}),` `,t,`%`]})}let r=is(e);return r===`not_downloaded`?(0,H.jsx)(`button`,{type:`button`,className:`model-state-btn`,onClick:e=>{e.stopPropagation(),t()},disabled:n,"aria-label":`Download ${e.display_name??e.id}`,title:ts.not_downloaded,tabIndex:-1,children:(0,H.jsx)(Ne,{size:13,"aria-hidden":`true`})}):r===`loaded`?(0,H.jsx)(`span`,{className:`model-state is-loaded`,role:`img`,"aria-label":ts.loaded,title:ts.loaded}):(0,H.jsx)(`span`,{className:`model-state is-ready`,title:ts.downloaded,children:`Ready`})}function TS(){let e=Uo(e=>e.active),t=Uo(e=>e.select),n=Uo(e=>e.queued),r=Uo(e=>e.queue),i=Uo(e=>e.queueError),a=Uo(e=>e.rememberNames);Uo(e=>e.names);let o=Yo(),s=V(t=>Xo(e,t.sessions,t.currentSessionId)),c=V(e=>e.isStreaming),l=V(e=>e.openSettings),u=(0,B.useRef)(null),[d,f]=(0,B.useState)(!1),[p,m]=(0,B.useState)(null),[h,g]=(0,B.useState)(0),[_,v]=(0,B.useState)(null),[y,b]=(0,B.useState)(null),[x,S]=(0,B.useState)(null),[C,w]=(0,B.useState)(null),[T,E]=(0,B.useState)(null),[D,O]=(0,B.useState)(0),[k,A]=(0,B.useState)(null),j=(0,B.useRef)(0),M=(0,B.useRef)(null),N=(0,B.useId)(),ee=(0,B.useRef)(null),[P,te]=(0,B.useState)(null),[ne,re]=(0,B.useState)(null),ie=(0,B.useCallback)(()=>re(null),[]),oe=(0,B.useCallback)(()=>f(!1),[]),ce=(0,B.useRef)(!1),le=(0,B.useCallback)(async(e=!1)=>{e||(ce.current=!1,v(null),m(null));try{let{providers:t,lemonade_error:n}=await $i();if(n)throw Error(n);let r=t.filter(e=>!e.remote||e.models_discovered||e.id===`fireworks`||e.registered),i=await Promise.all(r.map(async e=>{if(e.remote&&!e.models_discovered)return{provider:e,models:[]};try{return{provider:e,models:(await ia(e.id)).models}}catch(t){return{provider:e,models:[],error:t instanceof Error?t.message:String(t)}}}));a(i.flatMap(e=>e.models)),g(i.flatMap(e=>e.models).filter(e=>e.available===!1).length),e||(ce.current=!0),m(i.map(e=>({...e,models:e.models.filter(e=>e.available!==!1)})))}catch(e){v(e instanceof Error?e.message:String(e))}},[a]);(0,B.useEffect)(()=>{d&&(b(null),te(null),re(null),le())},[d,le]),(0,B.useEffect)(()=>{if(!d||!p||!ce.current)return;let e=ee.current?.querySelector(`[role="option"][tabindex="0"]`);e&&(ce.current=!1,e.focus(),e.scrollIntoView?.({block:`nearest`}))},[d,p]);let ue=e=>{if(e.altKey||e.ctrlKey||e.metaKey)return;let t=Array.from(ee.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(),re(t=>e.key===`i`&&t===r?null:r);return}case`ArrowLeft`:e.preventDefault(),re(null);return;default:return}e.preventDefault(),t[r].focus(),t[r].scrollIntoView?.({block:`nearest`})},de=!!p?.some(e=>e.models.some(as)),fe=!!p?.some(e=>e.provider.key_state===xS);(0,B.useEffect)(()=>{if(!(d||T)||!(de||T||fe))return;let e=setInterval(()=>{le(!0)},bS);return()=>clearInterval(e)},[d,de,T,fe,le]);let me=(0,B.useCallback)(async e=>{w(e),O(e=>e+1),v(null);try{await zi(e),await le(!0)}catch(t){E(t=>t?.model===e?null:t),v(t instanceof Error?t.message:String(t))}finally{w(null),O(e=>e-1)}},[le]),he=(0,B.useCallback)(async(n,i)=>{if(i.remote&&!e?.remote&&y?.model!==n)return b({model:n,provider:i}),null;if(b(null),c)return r(n===e?.model?null:n),f(!1),null;S(n),v(null);try{return await t(n),A(null),f(!1),null}catch(e){let t=e instanceof Error?e.message:String(e);return v(t),t}finally{S(null)}},[e?.model,e?.remote,y,r,t,c]);(0,B.useEffect)(()=>{if(!T||!p||D>0)return;let{model:e,provider:t}=T,n=()=>(M.current!==p&&(M.current=p,j.current+=1),j.current>=SS),r=p.flatMap(e=>e.models).find(t=>t.id===e);if(!r){if(!n())return;E(null),A(`${Go(e)} is no longer in the model list, so it wasn't switched to.`);return}if(as(r)){j.current=0;return}let i=r.download_progress;if(i?.state===`error`)E(null),A(`Downloading ${Go(e)} failed: ${i.message??`no reason given`}`);else if(i?.state!==`complete`&&is(r)===`not_downloaded`){if(!n())return;E(null),A(`The download of ${Go(e)} never started. Try the download button again.`)}else E(null),he(e,t).then(t=>{t&&A(`${Go(e)} downloaded, but switching to it failed: ${t}`)})},[p,T,D,he]);let F=p?.flatMap(({provider:e,models:t})=>[...e.remote&&!e.models_discovered?[`key:${e.id}`]:[],...t.filter(e=>x===null&&!as(e)).map(e=>e.id)])??[],I=n??e?.model,L=P&&F.includes(P)?P:I&&F.includes(I)?I:F[0],_e=e=>({role:`option`,tabIndex:e===L?0:-1,"data-row":e,onFocus:()=>te(e),onBlur:()=>re(null)}),ve=o?.remote?xe:o?ke:ge,ye=s?Go(s):`Model`,R=`${ye}${o?` · ${o.label}`:``}`,be=Object.fromEntries((p??[]).map(e=>[e.provider.id,$o(e.models)])),Se=e?.downloaded===!1&&s===e.model,Ce=k||i||(n?`${Go(n)} is used from your next message.`:e?.config_error?e.config_error:Se?`${ye} isn't downloaded yet. Open the list to download it.`:o?o.description?.replace(/`/g,``)??(o.remote?`Runs on ${o.label} — chat history leaves this PC`:`Runs on this PC`):Jo);return(0,H.jsxs)(`div`,{className:`composer-chip-wrap`,children:[(0,H.jsxs)(`button`,{ref:u,type:`button`,className:`composer-chip${Se||i||k?` is-warning`:``}`,onClick:()=>f(e=>!e),"aria-haspopup":`dialog`,"aria-expanded":d,title:Ce,children:[(0,H.jsx)(ve,{size:13,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`composer-chip-label`,children:R}),n&&(0,H.jsxs)(`span`,{className:`composer-chip-next`,children:[`→ `,Go(n),` next`]}),Se&&(0,H.jsx)(Ne,{size:12,"aria-label":`Not downloaded`}),k&&(0,H.jsx)(pe,{size:12,"aria-label":`Model switch failed`}),(0,H.jsx)(se,{size:12,"aria-hidden":`true`})]}),(0,H.jsxs)(Ur,{open:d,onClose:oe,anchor:u,label:`Choose a model`,align:`end`,children:[c&&(0,H.jsxs)(`div`,{className:`popover-message`,role:`status`,children:[`This reply keeps `,s?Go(s):`its model`,`. A model you pick here is used from your next message.`]}),k&&(0,H.jsx)(`div`,{className:`popover-message is-error`,role:`alert`,children:k}),i&&(0,H.jsx)(`div`,{className:`popover-message is-error`,role:`alert`,children:i}),_&&(0,H.jsx)(`div`,{className:`popover-message is-error`,role:`alert`,children:_}),!p&&!_&&(0,H.jsxs)(`div`,{className:`popover-message`,children:[(0,H.jsx)(z,{size:13,className:`spin`}),` Loading models…`]}),p&&(0,H.jsx)(`div`,{ref:ee,role:`listbox`,"aria-label":`Models`,onKeyDown:ue,children:p.map(({provider:t,models:r,error:i})=>(0,H.jsxs)(`div`,{role:`group`,"aria-labelledby":`${N}-${t.id}`,children:[(0,H.jsx)(`div`,{className:`popover-heading`,id:`${N}-${t.id}`,children:t.name}),i&&(0,H.jsx)(`div`,{className:`popover-message is-error`,children:i}),t.key_state===xS?(0,H.jsxs)(`div`,{className:`popover-message`,role:`status`,children:[(0,H.jsx)(z,{size:13,className:`spin`,"aria-hidden":`true`}),` `,t.key_message]}):t.remote&&!t.models_discovered&&(0,H.jsxs)(`button`,{type:`button`,className:`popover-item`,..._e(`key:${t.id}`),"aria-selected":!1,onClick:()=>{f(!1),l(`model`)},children:[(0,H.jsx)(`span`,{className:`popover-item-check`,children:(0,H.jsx)(_t,{size:13,"aria-hidden":`true`})}),(0,H.jsxs)(`span`,{className:`popover-item-body`,children:[(0,H.jsx)(`span`,{className:`popover-item-title`,children:`Add your key`}),(0,H.jsxs)(`span`,{className:`popover-item-note`,children:[`Connect `,t.name,` in Settings`]})]})]}),!i&&r.length===0&&t.models_discovered!==!1&&(0,H.jsx)(`div`,{className:`popover-message`,children:`No models yet.`}),r.map(r=>{let i=(n??e?.model)===r.id,a=!t.remote&&is(r)===`not_downloaded`,o=be[t.id][r.id],s=CS(r,t.remote),c=`${N}-info-${t.id}-${r.id}`;return(0,H.jsxs)(`div`,{className:`popover-row`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`popover-item`,onClick:()=>{a?(j.current=0,A(null),E({model:r.id,provider:t}),me(r.id)):(E(null),he(r.id,t))},disabled:x!==null||as(r),..._e(r.id),"aria-selected":i,"aria-describedby":ne===r.id?c:void 0,children:[(0,H.jsx)(`span`,{className:`popover-item-check`,"aria-hidden":`true`,children:x===r.id?(0,H.jsx)(z,{size:13,className:`spin`}):i?(0,H.jsx)(ae,{size:13}):null}),(0,H.jsx)(`span`,{className:`popover-item-body`,children:(0,H.jsx)(`span`,{className:`popover-item-title`,children:o})})]}),(0,H.jsxs)(gS,{label:`About ${o}`,warning:!!r.placement?.warning,id:c,pinned:ne===r.id,onUnpin:ie,tabIndex:-1,children:[(0,H.jsx)(`div`,{className:`info-bubble-title`,children:o}),s.length>0&&(0,H.jsx)(`ul`,{className:`info-bubble-lines`,children:s.map(e=>(0,H.jsx)(`li`,{children:e},e))}),r.placement?.warning&&(0,H.jsx)(`ul`,{className:`info-bubble-lines`,children:(0,H.jsx)(`li`,{className:`is-warning`,children:r.placement.warning})}),(0,H.jsx)(`div`,{className:`info-bubble-id`,children:r.id})]}),(0,H.jsx)(`span`,{className:`popover-row-state`,children:!t.remote&&(0,H.jsx)(wS,{m:r,busy:C!==null,onDownload:()=>void me(r.id)})})]},r.id)})]},t.id))}),y&&(0,H.jsxs)(`div`,{className:`popover-message`,role:`alert`,children:[y.provider.privacy_notice,` `,(0,H.jsxs)(`button`,{type:`button`,className:`link-btn`,onClick:()=>he(y.model,y.provider),children:[`Use `,Go(y.model)]})]}),h>0&&(0,H.jsxs)(`button`,{type:`button`,className:`popover-item`,onClick:()=>{f(!1),l(`model`)},children:[(0,H.jsx)(`span`,{className:`popover-item-check`}),(0,H.jsx)(`span`,{className:`popover-item-body`,children:(0,H.jsxs)(`span`,{className:`popover-item-note`,children:[h,` `,h===1?`model isn’t`:`models aren’t`,` available on this PC — see why in Settings`]})})]}),(0,H.jsx)(`div`,{className:`popover-divider`}),(0,H.jsxs)(`button`,{type:`button`,className:`popover-item`,onClick:()=>{f(!1),l(`model`)},children:[(0,H.jsx)(`span`,{className:`popover-item-check`}),(0,H.jsx)(`span`,{className:`popover-item-body`,children:(0,H.jsx)(`span`,{className:`popover-item-title`,children:`Providers and keys…`})})]})]})]})}var ES=`gaia:permission-mode`;function DS(e,t){window.dispatchEvent(new CustomEvent(ES,{detail:{sessionId:e,mode:t}}))}function OS(e,t){let n=(0,B.useRef)(t);n.current=t,(0,B.useEffect)(()=>{if(!e)return;let t=t=>{let r=t.detail;r?.sessionId===e&&n.current(r.mode)};return window.addEventListener(ES,t),()=>window.removeEventListener(ES,t)},[e])}var kS=[{mode:`ask`,label:`Ask before acting`,note:`GAIA asks before it edits files, runs commands or uses tools that change things.`},{mode:`full_access`,label:`Full access`,note:`Runs every tool and command without asking, in this chat only.`}];function AS({sessionId:e,disabled:t}){let n=V(e=>e.draftPermissionMode),r=V(e=>e.setDraftPermissionMode),[i,a]=(0,B.useState)(e?`ask`:n),[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(null),f=(0,B.useRef)(null);(0,B.useEffect)(()=>{if(!e){a(n);return}let t=!1;return hi(e).then(e=>{t||a(e.mode)}).catch(e=>{t||d(e instanceof Error?e.message:String(e))}),()=>{t=!0}},[e,n]),OS(e,a);let p=(0,B.useCallback)(async t=>{if(t===`full_access`&&!c)l(!0);else{d(null);try{if(e){let n=(await _i(e,t)).mode;a(n),DS(e,n)}else r(t),a(t);s(!1)}catch(t){d(t instanceof Error?t.message:String(t)),e&&hi(e).then(e=>a(e.mode)).catch(e=>d(t=>`${t??``} Couldn't re-read the saved mode: ${e instanceof Error?e.message:String(e)}`.trim()))}finally{l(!1)}}},[c,e,r]),m=i===`full_access`;return(0,H.jsxs)(`div`,{className:`composer-chip-wrap`,children:[(0,H.jsxs)(`button`,{ref:f,type:`button`,className:`composer-chip${m?` is-warning`:``}`,onClick:()=>{l(!1),s(e=>!e)},disabled:t,"aria-haspopup":`dialog`,"aria-expanded":o,"aria-label":`Permission mode: ${m?`full access`:`ask before acting`}`,children:[(0,H.jsx)(m?an:sn,{size:13,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`composer-chip-label`,children:m?`Full access`:`Ask`}),(0,H.jsx)(se,{size:12,"aria-hidden":`true`})]}),(0,H.jsxs)(Ur,{open:o,onClose:()=>s(!1),anchor:f,label:`Permission mode`,children:[kS.map(e=>(0,H.jsxs)(`button`,{type:`button`,className:`popover-item`,onClick:()=>p(e.mode),"aria-pressed":i===e.mode,children:[(0,H.jsx)(`span`,{className:`popover-item-check`,"aria-hidden":`true`,children:i===e.mode&&(0,H.jsx)(ae,{size:13})}),(0,H.jsxs)(`span`,{className:`popover-item-body`,children:[(0,H.jsx)(`span`,{className:`popover-item-title`,children:e.label}),(0,H.jsx)(`span`,{className:`popover-item-note`,children:e.note})]})]},e.mode)),c&&(0,H.jsxs)(`div`,{className:`popover-message`,role:`alert`,children:[`Full access lets GAIA change files and run commands on this PC without asking.`,` `,(0,H.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>p(`full_access`),children:`Turn it on`})]}),u&&(0,H.jsx)(`div`,{className:`popover-message is-error`,role:`alert`,children:u})]})]})}var jS={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 MS(e,t){return e?jS.queued:t?`GAIA is still busy in this chat. Trying again in a few seconds.`:`Sending next.`}function NS({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:(0,H.jsx)(`ul`,{className:`queued-messages`,"aria-label":`Messages waiting to send`,"aria-live":`polite`,children:o.map(e=>(0,H.jsxs)(`li`,{className:`queued-message is-${e.state}`,children:[e.state===`failed`?(0,H.jsx)(pe,{size:12,"aria-hidden":`true`}):e.state===`queued`?(0,H.jsx)(R,{size:12,"aria-hidden":`true`}):(0,H.jsx)(De,{size:12,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`queued-message-text`,title:e.text,children:e.text}),(0,H.jsx)(`span`,{className:`queued-message-state`,title:e.error,children:e.state===`failed`?`Not sent. ${e.error??``}`.trim():e.state===`queued`?MS(i,a):jS[e.state]}),e.state===`failed`&&(0,H.jsxs)(`button`,{type:`button`,className:`queued-message-steer`,onClick:()=>r(e.id),"aria-label":`Send again: ${e.text}`,children:[(0,H.jsx)(Qt,{size:11,"aria-hidden":`true`}),` Send again`]}),e.state===`queued`&&n&&(0,H.jsx)(`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`)&&(0,H.jsx)(`button`,{type:`button`,className:`queued-message-remove`,onClick:()=>t(e.id),"aria-label":`Remove queued message: ${e.text}`,title:`Remove`,children:(0,H.jsx)(Nn,{size:12})})]},e.id))})}var PS=`unknown`,FS=e=>e.toLocaleString(`en-US`);function IS({n:e}){if(e==null)return(0,H.jsx)(`span`,{className:`cp-unknown`,children:PS});let t=e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(+(e<1e4))}K`:`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`;return(0,H.jsx)(`span`,{title:`${FS(e)} tokens`,children:t})}function LS({s:e}){if(e==null)return(0,H.jsx)(`span`,{className:`cp-unknown`,children:PS});let t=e<.1?e===0?`0 s`:`<0.1 s`:e<10?`${e.toFixed(1)} s`:`${Math.round(e)} s`;return(0,H.jsx)(`span`,{title:`${(e*1e3).toFixed(0)} ms`,children:t})}function RS({r:e}){return e==null?(0,H.jsx)(`span`,{className:`cp-unknown`,children:PS}):(0,H.jsxs)(`span`,{title:`${e} tokens per second`,children:[Math.round(e).toLocaleString(`en-US`),` tokens/s`]})}var zS=(e,t)=>t>0?Math.round(e/t*100):0,BS=(e,t)=>{let n=zS(e,t);return n===0&&e>0?`<1`:String(n)},VS=(e,t)=>t&&e!=null?Math.floor(e/t*100):null,HS=256;function US(e){if(e.provider===`unknown`)return PS;if(e.provider===`cloud`)return`Cloud`;if(e.provider!==`local`)return`Cloud · ${es(e.provider)}`;if(!e.device)return e.loaded===!1?`Not loaded now`:PS;let t=e.device.toUpperCase(),n=e.backend===`npu`?`FLM`:e.backend;return n&&n!==e.device?`${t} · ${n.charAt(0).toUpperCase()}${n.slice(1)}`:t}function WS({label:e,children:t,hint:n}){return(0,H.jsxs)(`div`,{className:`cp-row`,title:n,children:[(0,H.jsx)(`dt`,{children:e}),(0,H.jsx)(`dd`,{children:t})]})}function GS({t:e}){if(e.model_seconds==null||e.gaia_seconds==null)return(0,H.jsxs)(WS,{label:`Took`,children:[(0,H.jsx)(LS,{s:e.wall_seconds}),` · split `,(0,H.jsx)(`span`,{className:`cp-unknown`,children:PS})]});let t=[{key:`model`,label:`In the model`,s:e.model_seconds},{key:`tools`,label:`Running tools`,s:e.tool_seconds},{key:`waiting`,label:`Waiting on you`,s:e.waiting_seconds},{key:`gaia`,label:`GAIA itself`,s:e.own_seconds??0}];return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(WS,{label:`Took`,hint:`From sending the message to the answer being saved`,children:(0,H.jsx)(LS,{s:e.wall_seconds})}),(0,H.jsx)(`div`,{className:`cp-stack`,"aria-hidden":`true`,children:t.map(t=>(0,H.jsx)(`span`,{className:`cp-time-${t.key}`,style:{width:`${zS(t.s,e.wall_seconds)}%`}},t.key))}),(0,H.jsxs)(`dl`,{className:`cp-rows cp-indent`,children:[(0,H.jsx)(WS,{label:`In the model`,children:(0,H.jsx)(LS,{s:e.model_seconds})}),(0,H.jsx)(WS,{label:`In GAIA`,hint:`Everything that was not the model: tools, waiting on you, and GAIA's own work`,children:(0,H.jsx)(LS,{s:e.gaia_seconds})}),t.slice(1).filter(e=>e.s>0).map(e=>(0,H.jsxs)(WS,{label:`· ${e.label}`,children:[(0,H.jsx)(`span`,{className:`swatch cp-time-${e.key}`,"aria-hidden":`true`}),` `,(0,H.jsx)(LS,{s:e.s})]},e.key))]})]})}function KS({why:e}){return(0,H.jsx)(`span`,{className:`cp-unknown`,title:e,children:PS})}var qS={server:`Reported by the model server`,client:`Measured by GAIA on the stream, network included`};function JS(e){return e?qS[e]:void 0}function YS({turn:e}){let t=VS(e.tokens_cached,e.tokens_in),n=e.unknown??{},r=e.tools.map(e=>`${e.name??`tool work outside a step`}: ${e.seconds??`?`} s`).join(`
61
61
  `);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(GS,{t:e.time}),(0,H.jsxs)(`dl`,{className:`cp-rows`,children:[(0,H.jsx)(WS,{label:`First word`,hint:JS(e.first_token_source),children:e.first_token_seconds==null?(0,H.jsx)(KS,{why:n.first_token_seconds}):(0,H.jsxs)(H.Fragment,{children:[`in `,(0,H.jsx)(LS,{s:e.first_token_seconds})]})}),(0,H.jsx)(WS,{label:`Reading the prompt`,hint:`Prefill: new prompt tokens over time to first token`,children:e.tokens_new!=null&&e.tokens_new<HS?(0,H.jsxs)(`span`,{title:`Too few new tokens to give a reading speed; the rest came from the cache`,children:[`only `,e.tokens_new,` new tokens`]}):e.prefill_tokens_per_second==null?(0,H.jsx)(KS,{why:n.prefill_tokens_per_second}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(RS,{r:e.prefill_tokens_per_second}),e.prefill_source===`client`&&(0,H.jsx)(`span`,{className:`cp-chip`,title:`Measured by GAIA from the first word, so it includes network and queue time`,children:`approx.`})]})}),(0,H.jsx)(WS,{label:`Writing the answer`,hint:JS(e.generation_source)??`Generation speed, weighted by tokens`,children:e.generation_tokens_per_second==null?(0,H.jsx)(KS,{why:n.generation_tokens_per_second}):(0,H.jsx)(RS,{r:e.generation_tokens_per_second})}),(0,H.jsxs)(WS,{label:`Tokens in → out`,hint:n.tokens,children:[(0,H.jsx)(IS,{n:e.tokens_in}),` → `,(0,H.jsx)(IS,{n:e.tokens_out})]}),(0,H.jsx)(WS,{label:`Reused from cache`,hint:`Prompt tokens the server did not have to read again`,children:e.tokens_cached==null?(0,H.jsx)(KS,{why:n.tokens_cached}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(IS,{n:e.tokens_cached}),t!=null&&` (${t}%)`]})}),(0,H.jsx)(WS,{label:`Model calls`,children:e.model_calls}),(0,H.jsx)(WS,{label:`Tool calls`,hint:r||void 0,children:e.tool_calls===0&&!e.tool_seconds_total?`none`:(0,H.jsxs)(H.Fragment,{children:[e.tool_calls,` · `,(0,H.jsx)(LS,{s:e.tool_seconds_total??0})]})}),(0,H.jsx)(WS,{label:`Model loads`,children:e.loads.length===0?`none`:(0,H.jsxs)(`span`,{title:e.loads.map(e=>`${e.model}${e.replaced?.length?` replaced ${e.replaced.join(`, `)}`:``}: ${e.seconds} s`).join(`
@@ -75,5 +75,5 @@ Details: ${l}`+d:t instanceof TypeError||l.includes(`fetch`)||l.includes(`Failed
75
75
  `)))}else st.length===0||pt||A||ne||wt.current||Ae||M?.init_state===`initializing`||yt()||!ut.current&&!qt||Kx(e,Jt,()=>Ct.current&&!yt()&&!V.getState().isStreaming&&!At.current)}},[Yt,st,pt,qt,A,ne,Ae,M?.init_state,e,Jt,yt]);let Xt=(0,B.useRef)(!1);(0,B.useEffect)(()=>{Xt.current&&!Yt&&Et(),Xt.current=Yt},[Yt,Et]);let Zt=(0,B.useCallback)(t=>{let n=st.find(e=>e.id===t&&e.state===`queued`);n&&d&&(ct(e=>xr(e,t,`queued`,`sending`)),oi(e,n.text).then(()=>ct(e=>xr(e,t,`sending`,`delivered`))).catch(e=>{u.chat.info(`Follow-up not taken by the running reply; it stays queued: ${e instanceof Error?e.message:e}`),ct(e=>xr(e,t,`sending`,`queued`))}))},[st,d,e,ct]),Qt=(0,B.useCallback)(()=>{for(let e=n.length-1;e>=0;e--)if(n[e].role===`user`){Kt(n[e]);return}},[n,Kt]),$t=()=>{he(se?.title||``),pe(!0)},en=async()=>{let t=me.trim().slice(0,200).trim();t&&me!==se?.title&&t!==se?.title&&(await _a(e,{title:t,title_is_custom:!0}),c(e,{title:t})),pe(!1)},tn=(0,B.useCallback)(async()=>{if(e)try{let t=await Sa(e);c(e,{private:t.private})}catch(e){u.ui.warn(`Failed to toggle private mode`,e)}},[e,c]),nn=(0,B.useCallback)(async(t,n)=>{t.stopPropagation();let r=E.find(e=>e.id===n);u.doc.info(`Detaching document from session: ${r?.filename||n}`);try{await Za(e,n);let t=(V.getState().sessions.find(t=>t.id===e)?.document_ids??[]).filter(e=>e!==n);c(e,{document_ids:t}),t.length<=3&&R(!1),u.doc.info(`Detached document from session: ${r?.filename||n}`)}catch(e){u.doc.error(`Failed to detach document: ${r?.filename||n}`,e)}},[E,e,c]),rn=(0,B.useCallback)(async t=>{if(t.preventDefault(),t.stopPropagation(),L(!1),t.dataTransfer.files.length!==0){for(let n of Array.from(t.dataTransfer.files)){u.doc.info(`Dropped on chat view: ${n.name}`);try{let t=await Ga(n);if(e&&t?.id)try{await Xa(e,t.id);let r=V.getState().sessions.find(t=>t.id===e)?.document_ids??[];r.includes(t.id)||c(e,{document_ids:[...r,t.id]}),u.doc.info(`Auto-attached "${n.name}" to session ${e}`)}catch(e){u.doc.warn(`Could not attach dropped document to session: ${e}`)}}catch(e){u.doc.error(`Upload failed: ${n.name}`,e)}}try{let e=await Ua();D(e.documents||[])}catch(e){u.doc.error(`Could not refresh the document list after a drop`,e)}}},[e,c,D]),an=e=>{e.preventDefault(),e.stopPropagation(),L(!0)},on=e=>{e.preventDefault(),e.stopPropagation(),L(!1)},sn=n.length>0?n[n.length-1]:void 0,cn=!d&&!A&&sn?.role===`assistant`&&oy(sn.content),ln=(0,B.useMemo)(()=>{let e=new Map,t;for(let r of n)if(r.role===`user`&&r.created_at)t=new Date(r.created_at).getTime();else if(r.role===`assistant`&&r.created_at&&t!==void 0){let n=new Date(r.created_at).getTime();n>t&&e.set(r.id,n-t),t=void 0}return e},[n]),un=Ae?`This chat used the retired "${Ae}" agent and is read-only. Start a new chat.`:M?.init_state===`initializing`?Xw:null;return(0,H.jsxs)(`main`,{className:`task-view ${F?`drag-active`:``}`,style:{"--session-panel-w":`${It}px`},onDrop:rn,onDragOver:an,onDragLeave:on,"aria-label":se?.title||`Chat`,children:[(0,H.jsxs)(`header`,{className:`task-header`,children:[(0,H.jsx)(`div`,{className:`task-header-left`,children:fe?(0,H.jsx)(`input`,{className:`title-edit`,value:me,maxLength:200,onChange:e=>he(e.target.value),onBlur:en,onKeyDown:e=>{e.key===`Enter`&&en(),e.key===`Escape`&&(e.preventDefault(),pe(!1))},...l,autoFocus:!0,"aria-label":`Chat title`}):(0,H.jsxs)(`button`,{type:`button`,className:`task-title`,onClick:$t,title:`Rename`,children:[(0,H.jsx)(`span`,{children:se?.title||`New chat`}),(0,H.jsx)(Ht,{size:12,"aria-hidden":`true`,className:`task-title-edit`})]})}),(0,H.jsxs)(`div`,{className:`task-header-right`,children:[(0,H.jsx)(`button`,{className:`btn-icon-sm${se?.private?` active`:``}`,onClick:tn,title:se?.private?`Private: this chat is not saved to memory`:`Make private (not saved to memory)`,"aria-label":se?.private?`Private chat on`:`Make chat private`,"aria-pressed":!!se?.private,children:(0,H.jsx)(Le,{size:15})}),(0,H.jsx)(`button`,{className:`btn-icon-sm`,onClick:()=>k(!0),title:`Browse files on this PC`,"aria-label":`Browse files on this PC`,children:(0,H.jsx)($e,{size:15})}),(0,H.jsx)(`button`,{className:`btn-icon-sm`,onClick:De,title:`Export as Markdown`,"aria-label":`Export chat`,children:(0,H.jsx)(Ne,{size:15})}),(0,H.jsx)(kw,{messages:n,busy:d})]})]}),le.length>0&&(()=>{let e=[...le].sort((e,t)=>{let n=e.last_accessed_at||e.indexed_at||``;return(t.last_accessed_at||t.indexed_at||``).localeCompare(n)}),t=ye?e:e.slice(0,3),n=e.length-3;return(0,H.jsxs)(`div`,{className:`doc-context-bar${ye?` doc-context-expanded`:``}`,"aria-label":`${le.length} indexed document${le.length===1?``:`s`}`,children:[(0,H.jsx)(I,{size:12,className:`doc-context-icon`,"aria-hidden":`true`}),(0,H.jsxs)(`button`,{type:`button`,className:`doc-context-label`,onClick:()=>O(!0),title:`Manage documents`,children:[le.length,` indexed`]}),(0,H.jsxs)(`div`,{className:`doc-context-pills${ye?` doc-context-pills-expanded`:``}`,children:[t.map(e=>(0,H.jsxs)(`span`,{className:`doc-pill`,title:e.filepath||e.filename,children:[(0,H.jsx)(Ge,{size:9,className:`doc-pill-icon`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`doc-pill-name`,children:e.filename}),(0,H.jsx)(`button`,{className:`doc-pill-remove`,onClick:t=>nn(t,e.id),"aria-label":`Remove ${e.filename} from this chat`,children:(0,H.jsx)(Nn,{size:10})})]},e.id)),!ye&&n>0&&(0,H.jsxs)(`button`,{className:`doc-pill-more`,onClick:e=>{e.stopPropagation(),R(!0)},children:[`+`,n,` more`]}),ye&&n>0&&(0,H.jsx)(`button`,{className:`doc-pill-collapse`,onClick:e=>{e.stopPropagation(),R(!1)},children:`show less`})]})]})})(),(0,H.jsx)(`div`,{className:`messages-scroll`,ref:He,onScroll:Ft,children:(0,H.jsxs)(`div`,{className:`messages-column`,children:[A&&(0,H.jsx)(`div`,{className:`skeleton-messages`,"aria-label":`Loading messages`,children:[0,1,2].map(e=>(0,H.jsx)(`div`,{className:`skeleton-msg`,children:(0,H.jsxs)(`div`,{className:`skeleton-lines`,children:[(0,H.jsx)(`div`,{className:`skeleton-line`}),(0,H.jsx)(`div`,{className:`skeleton-line`}),e!==2&&(0,H.jsx)(`div`,{className:`skeleton-line`})]})},e))}),n.map((e,t)=>{if(je&&e.role===`assistant`&&t===n.length-1)return null;let r=e.role===`assistant`?e.historyNotice??oT.get(e.id):void 0,i=!Yt&&!Ot&&!Ae&&!je&&e.role===`assistant`&&t===n.length-1&&!e.stopState&&!Rb(e.content),a=e.stats?.seconds==null?ln.get(e.id):e.stats.seconds*1e3;return(0,H.jsxs)(`div`,{className:be===e.id?`msg-deleting`:void 0,"data-message-id":e.id,"data-role":e.role,children:[r&&(0,H.jsx)(sT,{text:r}),(0,H.jsx)(ix,{message:e,agentSteps:e.role===`assistant`?e.agentSteps:void 0,onDelete:Yt?void 0:Gt,onResend:!Yt&&e.role===`user`&&!Ae?Kt:void 0,extraActions:i?(0,H.jsx)(oC,{answeredBy:e.stats?.model??se?.effective_model,onPick:t=>jt(e,t)}):void 0,latencyMs:a}),Ot?.messageId===e.id&&(0,H.jsx)(lC,{original:e,originalModel:e.stats?.model??se?.effective_model,originalLatencyMs:a,state:Ot.state,keeping:Ot.keeping,onKeep:e=>{Mt(e)},onClose:Nt})]},e.id)}),(d||je)&&Pe&&(0,H.jsx)(sT,{text:Pe}),(d||je)&&(0,H.jsx)(`div`,{className:`streaming-bubble ${je?`stream-ending`:`stream-active`}`,children:(0,H.jsx)(ix,{message:{id:-1,session_id:e,role:`assistant`,content:(d?f:Ie.current)||``,created_at:``,rag_sources:null},isStreaming:d,agentSteps:d?g:Re.current,agentStepsActive:d&&g.some(e=>e.active),agentStepCount:rt,cards:d?C:ze.current,liveStatus:d?re:null,awaitingUser:d&&(ie||ae||oe)})}),(0,H.jsx)(`div`,{ref:Ve})]})}),(0,H.jsx)(Ow,{sessionId:e,messages:n,busy:Yt,onUsage:Dt,onJumpToMessage:Rt}),ge&&(0,H.jsx)(`button`,{className:`scroll-bottom-btn`,onClick:zt,title:`Scroll to bottom`,"aria-label":`Scroll to bottom`,children:(0,H.jsx)(S,{size:16})}),F&&(0,H.jsxs)(`div`,{className:`drag-overlay`,children:[(0,H.jsx)(Dn,{size:32,strokeWidth:1.5,"aria-hidden":`true`}),(0,H.jsx)(`span`,{children:`Drop files to index them for this chat`})]}),Se&&(0,H.jsxs)(`div`,{className:`toast policy-alert-toast`,role:`alert`,children:[(0,H.jsxs)(`span`,{children:[`Blocked: `,Se.tool,` is restricted by policy.`]}),Se.receiptId?(0,H.jsx)(`button`,{type:`button`,className:`policy-alert-toast-link`,onClick:()=>{let e=Se.receiptId;e&&(te(`policy_alert`),P(!0),Ee(e))},children:`View receipt`}):(0,H.jsx)(`span`,{className:`policy-alert-toast-missing`,children:`Receipt unavailable`})]}),(0,H.jsx)(`div`,{className:`input-area`,children:(0,H.jsxs)(`div`,{className:`input-column`,children:[(0,H.jsx)(jw,{message:Oe,onDismiss:ke}),cn&&sn&&(0,H.jsx)(uS,{content:sn.content,onRetry:Qt}),(0,H.jsx)(cv,{sessionId:e}),(0,H.jsx)(iC,{usage:z}),(0,H.jsx)(Aw,{sessionId:e}),(0,H.jsx)(NS,{items:st,onRemove:e=>ct(t=>Sr(t,e)),onRetry:e=>ct(t=>xr(t,e,`failed`,`queued`)),onSteer:d&&!Xe?Zt:void 0,replying:d,busyRetry:!!pt}),(0,H.jsx)(pS,{value:ue,onChange:de,onSubmit:()=>Vt(),onStop:Bt,streaming:d,stopping:Xe,queueWhileStreaming:!0,disabledReason:un,attachments:ve,inputRef:Ue,placeholder:d?`Queue your next message`:n.length===0?`Ask GAIA anything`:`Reply to GAIA`,leftControls:(0,H.jsx)(AS,{sessionId:e,disabled:!!Ae}),rightControls:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(rC,{usage:z,unavailable:Tt,sessionId:e,busy:Yt,onUsage:Dt,onDetails:()=>Lt(`context`)}),(0,H.jsx)(TS,{})]})})]})})]})}function fT({disabled:e}){let t=V(e=>e.draftPrivate),n=V(e=>e.setDraftPrivate);return(0,H.jsxs)(`button`,{type:`button`,className:`composer-chip${t?` is-on`:``}`,onClick:()=>n(!t),disabled:e,"aria-pressed":t,"aria-label":`Private chat`,title:t?`Private: nothing in this chat is saved to memory`:`Start a private chat (not saved to memory)`,children:[(0,H.jsx)(Le,{size:13,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`composer-chip-label`,children:`Private`})]})}function pT({cards:e,onPick:t,disabled:n}){return e.length===0?null:(0,H.jsx)(`ul`,{className:`start-cards`,"aria-label":`Things to try`,children:e.map(e=>(0,H.jsx)(`li`,{children:(0,H.jsxs)(`button`,{type:`button`,className:`start-card`,onClick:()=>t(e),disabled:n,title:e.needs_input?`${e.prompt}…`:e.prompt,children:[(0,H.jsxs)(`span`,{className:`start-card-title`,children:[e.title,(0,H.jsx)(w,{size:13,"aria-hidden":`true`})]}),(0,H.jsx)(`span`,{className:`start-card-note`,children:e.note})]})},e.skill))})}var mT=1e3;function hT(){let[e,t]=(0,B.useState)(null);return(0,B.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(()=>{Mi().then(r,i)},mT)):t(null))},i=n=>{e||(u.system.warn(`Warm-up status unavailable`,n),t(null))};return ji().then(r,i),()=>{e=!0,n&&clearTimeout(n)}},[]),e}function gT(e){return e===`gpu`?`your GPU`:e===`npu`?`your NPU`:e===`cpu`?`the CPU`:null}function _T(e){return e<1?`under 1 GB`:`${e.toFixed(1)} GB`}var vT=15e3;function yT(e=new Date){let t=e.getHours();return`Good ${t<5?`evening`:t<12?`morning`:t<18?`afternoon`:`evening`}. What should we work on?`}function bT({seconds:e,model:t,device:n}){if(!t)return`Getting GAIA ready… ${e}s`;let r=gT(n);return`Loading ${Go(t)}${r?` on ${r}`:``}… ${e}s`}function xT({detail:e,onRetry:t}){let[n,r]=(0,B.useState)(!1);return(0,H.jsxs)(`div`,{className:`new-chat-note`,children:[(0,H.jsxs)(`p`,{children:[`GAIA’s assistant didn’t start, so it can’t suggest tasks yet.`,` `,(0,H.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:t,children:`Try again`})]}),(0,H.jsxs)(`button`,{type:`button`,className:`new-chat-details`,"aria-expanded":n,onClick:()=>r(e=>!e),children:[(0,H.jsx)(le,{size:12,className:n?`is-open`:``,"aria-hidden":`true`}),` Details`]}),n&&(0,H.jsx)(`pre`,{className:`new-chat-details-text`,children:e})]})}var ST=`document-brief`;function CT(){let{documents:e,draftDocumentIds:t,addDraftDocuments:n}=V.getState();n(e.filter(e=>e.indexing_status===`complete`&&!t.includes(e.id)).map(e=>e.id))}function wT(){let e=V(e=>e.documents),t=V(e=>e.draftDocumentIds),n=V(e=>e.removeDraftDocument),r=V(e=>e.setShowDocLibrary),i=e.filter(e=>t.includes(e.id)),a=e.filter(e=>e.indexing_status===`complete`&&!t.includes(e.id));if(!i.length&&!a.length)return null;let o=a.length;return(0,H.jsxs)(`div`,{className:`new-chat-docs`,children:[i.length>0&&(0,H.jsx)(`ul`,{className:`new-chat-doc-list`,"aria-label":`Documents for this chat`,children:i.map(e=>(0,H.jsxs)(`li`,{className:`new-chat-doc`,children:[(0,H.jsx)(Ge,{size:12,"aria-hidden":`true`}),(0,H.jsx)(`span`,{children:e.filename}),(0,H.jsx)(`button`,{type:`button`,className:`new-chat-doc-remove`,onClick:()=>n(e.id),"aria-label":`Don't attach ${e.filename}`,children:(0,H.jsx)(Nn,{size:12,"aria-hidden":`true`})})]},e.id))}),o>0&&(0,H.jsxs)(`p`,{className:`new-chat-note`,children:[i.length?`${o} more document${o===1?``:`s`} in your library. `:`Your library has ${o} document${o===1?``:`s`}; this chat can search only the ones you attach. `,(0,H.jsxs)(`button`,{type:`button`,className:`link-btn`,onClick:CT,children:[`Attach `,o===1?`it`:`all ${o}`]}),o>1&&(0,H.jsxs)(H.Fragment,{children:[` · `,(0,H.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>r(!0),children:`Choose`})]})]})]})}function TT({error:e}){let t=V(e=>e.openSettings);return(0,H.jsxs)(`div`,{className:`new-chat-setup-failed`,role:`alert`,children:[(0,H.jsx)(`p`,{className:`new-chat-setup-failed-title`,children:`GAIA’s first-run setup didn’t finish, so a chat on this PC’s model will fail.`}),(0,H.jsx)(`p`,{className:`new-chat-setup-failed-error`,children:e}),(0,H.jsxs)(`p`,{children:[`Use a cloud model, or pick a smaller one.`,` `,(0,H.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>t(`model`),children:`Choose a model`})]})]})}function ET({onSend:e,initialText:t=``,focusRequest:n=0}){let r=V(e=>e.systemStatus?.init_state===`initializing`),i=V(e=>e.systemStatus?.model_loaded?null:e.systemStatus?.setup_error??null),a=Uo(e=>!!e.active?.remote),[o,s]=(0,B.useState)(t),[c,l]=(0,B.useState)(null),[d,f]=(0,B.useState)(!1),[p,m]=(0,B.useState)(null),[h,g]=(0,B.useState)(null),_=(0,B.useRef)(null),v=Nw(),y=hT();Wo();let b=(0,B.useRef)(!0),x=(0,B.useCallback)((e=!1)=>{e||g(null),Yi().then(e=>{b.current&&(m(e),g(e.skills_error??null))}).catch(e=>{u.api.warn(`New-chat suggestions unavailable`,e),b.current&&g(e instanceof Error?e.message:String(e))})},[]);(0,B.useEffect)(()=>(b.current=!0,x(),()=>{b.current=!1}),[x]),(0,B.useEffect)(()=>{Ua().then(e=>V.getState().setDocuments(e.documents||[])).catch(e=>u.api.warn(`Document library unavailable; not offering its documents`,e))},[]),(0,B.useEffect)(()=>{if(h)return Zw(()=>x(!0),vT)},[h,x]);let S=(0,B.useRef)(!1),C=(0,B.useRef)([]),w=(0,B.useCallback)(async(t,n=``)=>{if(t){if(S.current)C.current.push(n||t),s(``);else{S.current=!0,f(!0),l(null),s(``);try{let n=await e(t);v.clear();let r=C.current.splice(0),i=V.getState().currentSessionId;if(r.length>0&&i){let e=(e,t)=>n===!1?[...e,{...yr(t,`failed`),error:`The first message was not sent.`}]:br(e,t,`queued`);V.getState().updateQueue(i,t=>r.reduce(e,t))}}catch(e){let r=C.current.splice(0);s([n||t,...r].join(`
76
76
 
77
77
  `)),l(e instanceof Error?e.message:String(e))}finally{S.current=!1,f(!1)}}}},[v,e]),T=(0,B.useCallback)(()=>w(v.compose(o.trim()),o.trim()),[v,w,o]);(0,B.useEffect)(()=>{n&&_.current?.focus()},[n]);let E=(0,B.useCallback)(e=>{e.skill===ST&&CT(),e.needs_input?(s(e.prompt),_.current?.focus()):w(v.compose(e.prompt))},[v,w]),D=p?.working_folder;return(0,H.jsx)(`main`,{className:`new-chat`,"aria-label":`New chat`,children:(0,H.jsxs)(`div`,{className:`new-chat-inner`,children:[(0,H.jsx)(`h1`,{className:`new-chat-greeting`,children:yT()}),i&&!a&&(0,H.jsx)(TT,{error:i}),(0,H.jsx)(pS,{value:o,onChange:s,onSubmit:T,attachments:v,disabledReason:r?Xw:null,autoFocus:!0,inputRef:_,leftControls:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(AS,{sessionId:null}),(0,H.jsx)(fT,{disabled:d})]}),rightControls:(0,H.jsx)(TS,{})}),D&&(0,H.jsx)(`div`,{className:`new-chat-meta`,children:(0,H.jsxs)(`span`,{className:`new-chat-folder`,title:D.gaia_folder?`GAIA works in its own folder, ${D.path}. Attach a file or start GAIA from a project folder to work there.`:`GAIA works in ${D.path}`,children:[(0,H.jsx)(tt,{size:13,"aria-hidden":`true`}),(0,H.jsx)(`span`,{children:D.name})]})}),(0,H.jsx)(wT,{}),y!==null&&!r&&(0,H.jsx)(`p`,{className:`new-chat-warmup`,role:`status`,children:bT(y)}),c&&(0,H.jsx)(`p`,{className:`new-chat-error`,role:`alert`,children:c}),p&&(0,H.jsx)(pT,{cards:p.cards,onPick:E,disabled:r||d}),h&&(0,H.jsx)(xT,{detail:h,onRetry:()=>x()})]})})}function DT(e){let t=e?.reason;return t===`needs_key`||t===`bad_key`}function OT({provider:e,limit:t}){let[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(null);if((0,B.useEffect)(()=>{r(null),a(null),ua(e).then(r).catch(e=>a(e instanceof Error?e.message:String(e)))},[e]),i)return(0,H.jsxs)(`p`,{className:`settings-error`,role:`alert`,children:[`Prices could not be loaded: `,i]});if(!n)return(0,H.jsxs)(`p`,{className:`settings-hint`,children:[(0,H.jsx)(z,{size:13,className:`spin`}),` Loading prices…`]});if(n.models.length===0)return(0,H.jsxs)(`p`,{className:`settings-hint cloud-prices-note`,children:[`Price unknown. `,n.note]});let o=t?n.models.slice(0,t):n.models;return(0,H.jsxs)(`div`,{className:`cloud-prices`,"aria-label":`Prices`,children:[(0,H.jsx)(`ul`,{className:`cloud-prices-list`,children:o.map(e=>(0,H.jsxs)(`li`,{children:[(0,H.jsxs)(`span`,{className:`cloud-prices-name`,children:[e.name,e.note&&(0,H.jsxs)(`span`,{className:`cloud-prices-note`,children:[` · `,e.note]})]}),(0,H.jsx)(`span`,{className:`cloud-prices-price`,children:vS(e.price)})]},e.model))}),(0,H.jsxs)(`span`,{className:`settings-hint`,children:[n.source,`. You pay the provider for what you use.`]})]})}function kT({label:e,value:t,ok:n}){return(0,H.jsxs)(`li`,{className:`setup-check-row${n?` is-ok`:``}`,children:[n?(0,H.jsx)(ae,{size:13,"aria-hidden":`true`}):(0,H.jsx)(ht,{size:13,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`setup-check-label`,children:e}),(0,H.jsx)(`span`,{className:`setup-check-value`,children:t})]})}function AT(e){let t=[e.gpu_name,e.npu_detected?`Ryzen AI NPU`:null].filter(Boolean);return t.length?{value:t.join(` · `),ok:!0}:e.lemonade_running?{value:`No GPU or NPU reported; models run on the CPU`,ok:!1}:{value:`Checked once the model server is running`,ok:!1}}function jT({hardware:e,error:t}){if(t)return(0,H.jsxs)(`p`,{className:`setup-hint`,children:[`This PC’s hardware couldn’t be read (`,t,`). Setup still checks it as it goes.`]});if(!e)return(0,H.jsxs)(`p`,{className:`setup-hint`,role:`status`,children:[(0,H.jsx)(z,{size:13,className:`spin`,"aria-hidden":`true`}),` Checking this PC…`]});let n=AT(e),r=e.lemonade_running?e.warnings:e.warnings.filter(e=>!/\bNPU\b/.test(e));return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`ul`,{className:`setup-check`,"aria-label":`This PC`,children:[(0,H.jsx)(kT,{label:`Device`,value:n.value,ok:n.ok}),(0,H.jsx)(kT,{label:`Memory`,value:e.ram_gb==null?`Not reported`:`${e.ram_gb} GB`,ok:e.ram_gb!=null}),(0,H.jsx)(kT,{label:`Disk`,value:e.disk_free_gb==null?`Not reported`:`${Math.round(e.disk_free_gb)} GB free`,ok:e.disk_free_gb!=null&&e.compatible})]}),!e.compatible&&e.blockers.length>0&&(0,H.jsx)(`p`,{className:`setup-error`,role:`alert`,children:e.blockers.join(` `)}),r.length>0&&(0,H.jsx)(`p`,{className:`setup-hint`,children:r.join(` `)})]})}function MT({plan:e,planError:t,chosen:n,locked:r,onPlan:i}){let[a,o]=(0,B.useState)(null),[s,c]=(0,B.useState)(null),[l,u]=(0,B.useState)(!1);if(n){let t=l||e?.chat_model.user_set&&e.chat_model.id===n;return(0,H.jsxs)(`p`,{className:`setup-hint`,children:[t?`You chose `:`Setup chose `,(0,H.jsx)(`strong`,{children:Qo(n)}),t?`.`:` for this PC.`]})}if(t)return(0,H.jsxs)(`p`,{className:`setup-hint`,children:[`Setup names the chat model once it has checked this PC (`,t,`).`]});if(!e)return(0,H.jsxs)(`p`,{className:`setup-hint`,role:`status`,children:[(0,H.jsx)(z,{size:13,className:`spin`,"aria-hidden":`true`}),` Working out which model fits this PC…`]});let d=e.chat_model,f=Qo(d.id);if(e.decided_after_server){let t=e.options.map(e=>Qo(e.id));return(0,H.jsxs)(`p`,{className:`setup-hint`,children:[`Picked once the model server is running: the largest model your GPU holds`,t.length>1?` (${t.slice(0,-1).join(`, `)}, or else ${t[t.length-1]})`:``,`. It’s named here as soon as setup chooses.`]})}let p=async e=>{o(e),c(null);try{i(await Ji(e)),u(!0)}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(null)}},m=e.memory_gb==null?``:` This PC has ${e.memory_gb} GB for models (${e.memory_source}).`,h=d.downloaded?`already downloaded`:d.size_gb==null?null:_T(d.size_gb),g=d.user_set&&!e.options.some(e=>e.id===d.id),_=!r&&!g&&e.lemonade.reachable&&e.options.filter(e=>e.fits!==!1).length>1;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`p`,{className:`setup-hint`,children:[(0,H.jsx)(`strong`,{children:f}),` will answer your chats`,h?` (${h})`:``,`.`,m,g&&` It’s your default_model; change it in Settings → Model after setup.`]}),_&&(0,H.jsx)(`div`,{className:`setup-choices`,role:`radiogroup`,"aria-label":`Chat model`,children:e.options.map(t=>(0,H.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t.id===d.id,className:`setup-choice${t.id===d.id?` is-active`:``}`,disabled:t.fits===!1||a!==null,onClick:()=>{t.id!==d.id&&p(t.id)},children:[a===t.id&&(0,H.jsx)(z,{size:14,className:`spin`,"aria-hidden":`true`}),(0,H.jsxs)(`span`,{children:[(0,H.jsxs)(`span`,{className:`setup-choice-title`,children:[Qo(t.id),t.id===e.recommended_model?` (recommended)`:``]}),(0,H.jsx)(`span`,{className:`setup-choice-note`,children:t.fits===!1?t.reason:t.size_gb==null?`Size unknown`:_T(t.size_gb)})]})]},t.id))}),s&&(0,H.jsx)(`p`,{className:`setup-error`,role:`alert`,children:s})]})}function NT(){let[e,t]=(0,B.useState)(null),n=(0,B.useCallback)(()=>{Promise.resolve($i()).then(e=>t(e?.providers?.find(e=>e.id===`amd`)?.network??null)).catch(e=>{console.warn(`[useGatewayNetwork] could not check the AMD gateway`,e),t(null)})},[]);return(0,B.useEffect)(n,[n]),{network:e,recheck:n}}var PT=[{id:`local`,title:`On this PC`,note:`Private. Models run on your AMD hardware; nothing leaves this machine.`},{id:`fireworks`,title:`Fireworks AI`,note:`Faster, larger cloud models. Needs an API key; chat history is sent to Fireworks AI.`},{id:`amd`,title:`AMD LLM Gateway`,note:`For AMD employees. Needs a gateway key; chat history is sent to the gateway.`}],FT=1e3,IT=`gaia-setup-choice`;function LT(){try{let e=localStorage.getItem(IT);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 RT(e){try{localStorage.setItem(IT,e)}catch(e){console.warn(`[SetupScreen] could not save the provider choice; a reload will ask again`,e)}}function zT({status:e,n:t}){return e===`done`?(0,H.jsx)(ae,{size:14,"aria-hidden":`true`}):e===`active`?(0,H.jsx)(z,{size:14,className:`spin`,"aria-hidden":`true`}):e===`failed`||e===`cancelled`?(0,H.jsx)(pe,{size:14,"aria-hidden":`true`}):(0,H.jsx)(H.Fragment,{children:t})}var BT=[`ok`,`needs_key`,`too_old`];function VT({onChosen:e}){let[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)([]),[s,c]=(0,B.useState)(!1),[l,u]=(0,B.useState)(``),[d,f]=(0,B.useState)(!1),[p,m]=(0,B.useState)(!1),[h,g]=(0,B.useState)(null),[_,v]=(0,B.useState)(null),y=(0,B.useRef)(!0),b=(0,B.useCallback)(async()=>{i(null);try{let e=await Xi();if(!e.offer)return;c(!0);let{found:t,unchecked:r=[]}=await Zi();if(!y.current)return;o(t?[]:r),t&&BT.includes(t.status)&&(n({target:e,found:t}),f(t.status===`needs_key`))}catch(e){y.current&&i(e instanceof Error?e.message:String(e))}finally{y.current&&c(!1)}},[]);(0,B.useEffect)(()=>(y.current=!0,b(),()=>{y.current=!1}),[b]);let x=(0,B.useCallback)(async n=>{if(t){m(!0),g(null);try{await Qi(n===`external`?{mode:n,base_url:t.found.url,api_key:l.trim()||void 0}:{mode:n}),u(``),v(n),e(n)}catch(e){DT(e)&&f(!0),g(e instanceof Error?e.message:String(e))}finally{m(!1)}}},[t,l,e]);if(r||a.length>0)return(0,H.jsxs)(`div`,{className:`setup-row`,children:[(0,H.jsx)(`span`,{className:`setup-hint`,children:r?`Couldn't check for a Lemonade Server you already run: ${r}`:`Couldn't check whether your Lemonade Server at ${a.join(` or `)} is running: it didn't answer in time.`}),(0,H.jsxs)(`button`,{type:`button`,className:`btn-secondary`,disabled:s,onClick:()=>void b(),children:[s&&(0,H.jsx)(z,{size:13,className:`spin`}),` Check again`]})]});if(!t)return s?(0,H.jsxs)(`p`,{className:`setup-hint`,role:`status`,children:[(0,H.jsx)(z,{size:13,className:`spin`,"aria-hidden":`true`}),` Looking for a Lemonade Server you already run…`]}):null;let{target:S,found:C}=t;return _?(0,H.jsx)(`p`,{className:`setup-hint`,role:`status`,children:_===`external`?`GAIA will use your Lemonade Server at ${C.url} and won't install its own.`:`GAIA will set up its own Lemonade Server.`}):C.status===`too_old`?(0,H.jsx)(`p`,{className:`setup-hint`,children:C.message}):(0,H.jsxs)(`form`,{className:`setup-lemonade`,"aria-label":`Use your Lemonade Server`,onSubmit:e=>{e.preventDefault(),x(`external`)},children:[(0,H.jsxs)(`span`,{className:`setup-choice-title`,children:[`Use the Lemonade you already run at `,C.url,C.version?` (v${C.version})`:``]}),(0,H.jsx)(`span`,{className:`setup-choice-note`,children:S.what_gaia_does}),d&&(0,H.jsx)(`input`,{className:`settings-input`,type:`password`,autoComplete:`off`,value:l,onChange:e=>u(e.target.value),placeholder:`The API key your Lemonade Server was started with`,"aria-label":`Lemonade API key`}),(0,H.jsxs)(`div`,{className:`setup-row`,children:[(0,H.jsxs)(`button`,{type:`submit`,className:`btn-primary`,disabled:p||d&&!l.trim(),children:[p&&(0,H.jsx)(z,{size:13,className:`spin`}),` Use mine`]}),(0,H.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:p,onClick:()=>void x(`gaia`),children:`Use GAIA’s own`})]}),h&&(0,H.jsx)(`p`,{className:`setup-error`,role:`alert`,children:h})]})}function HT({problem:e,onRetry:t,onUseGaia:n}){return(0,H.jsxs)(H.Fragment,{children:[e.start&&(0,H.jsx)(`p`,{className:`setup-hint`,children:e.start}),(0,H.jsxs)(`div`,{className:`setup-row`,children:[(0,H.jsx)(`button`,{type:`button`,className:`btn-primary`,onClick:t,children:`Try again`}),e.use_gaia&&(0,H.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:n,children:`Use GAIA’s own instead`})]}),e.use_gaia&&(0,H.jsx)(`p`,{className:`setup-hint`,children:`GAIA’s own Lemonade Server downloads its own copy of the models.`}),e.switch_hint&&(0,H.jsx)(`p`,{className:`setup-hint`,children:e.switch_hint})]})}function UT(e,t,n){return t?e.map(e=>{if(e.key===`server`&&t.lemonade.mode===`external`)return{...e,label:`Use your Lemonade Server`,detail:t.lemonade.url??e.detail};if(e.key===`models`&&!n&&!t.decided_after_server){let n=t.download_gb===0?`already downloaded`:t.download_gb==null?null:_T(t.download_gb),r=`chat model ${Qo(t.chat_model.id)}, plus the embedding model`;return{...e,detail:n?`${r} (${n})`:r}}return e}):e}function WT({initial:e,onReady:t}){let n=Uo(e=>e.refresh),r=Uo(e=>e.select),[i,a]=(0,B.useState)(()=>LT()??`local`),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(null),[u,d]=(0,B.useState)(null),[f,p]=(0,B.useState)(null),[m,h]=(0,B.useState)(``),[g,_]=(0,B.useState)({busy:!1,error:null,done:!1}),[v,y]=(0,B.useState)(!1),[b,x]=(0,B.useState)(null),[S,C]=(0,B.useState)(null),[w,T]=(0,B.useState)(null),[E,D]=(0,B.useState)([]),[O,k]=(0,B.useState)(!1),A=(0,B.useRef)(null),j=(0,B.useRef)(!0);(0,B.useEffect)(()=>()=>{j.current=!1},[]);let{network:M,recheck:N}=NT(),ee=e=>e===`amd`&&M?.reachable===!1,P=i!==`local`,te=u?.steps??UT(P?e.cloud_steps??e.steps:e.steps,b,P),ne=u?.state===`running`||u?.state===`verifying`,re=u?.state===`ready`,ie=ne||re,oe=!!u?.chat_model||!!b&&!b.decided_after_server,se=P?3:4,ce=(0,B.useCallback)(()=>{l(null),Ui().then(s).catch(e=>l(e instanceof Error?e.message:String(e)))},[]),ue=(0,B.useRef)(0),de=(0,B.useCallback)(()=>{let e=++ue.current;x(null),C(null),qi().then(t=>{e===ue.current&&x(t)}).catch(t=>{e===ue.current&&C(t instanceof Error?t.message:String(t))})},[]);(0,B.useEffect)(()=>{Xi().then(e=>k(e.source===`config`)).catch(e=>console.warn(`[SetupScreen] could not read which Lemonade GAIA uses`,e)),ce(),de(),Ki().then(e=>{e.state!==`idle`&&(d(e),e.skip_chat_model&&!LT()&&a(`fireworks`))}).catch(e=>p(`Could not read setup progress: ${e instanceof Error?e.message:e}`))},[ce,de]);let fe=(0,B.useCallback)(()=>{A.current&&clearInterval(A.current),A.current=null},[]);(0,B.useEffect)(()=>(ne&&(A.current=setInterval(()=>{Ki().then(d).catch(e=>{d(t=>t&&{...t,state:`failed`,error:`Lost contact with GAIA: ${e instanceof Error?e.message:e}`})})},FT)),fe),[ne,fe]);let pe=(0,B.useCallback)(async(e=!1)=>{p(null);try{RT(i),d(await Gi(P,e)),e&&k(!1)}catch(e){p(e instanceof Error?e.message:String(e))}},[P,i]),me=(0,B.useCallback)(async()=>{_({busy:!0,error:null,done:!1});try{await na(i,{api_key:!O&&m||void 0},e=>_({busy:!0,error:null,done:!1,waiting:e}),()=>!j.current);let{models:e}=await ia(i),t=e.find(e=>e.rank===1)??e[0];if(!t)throw Error(`Connected, but the provider listed no chat models.`);await r(t.id),T(t.id),h(``),_({busy:!1,error:null,done:!0})}catch(e){_({busy:!1,error:e instanceof Error?e.message:String(e),done:!1})}},[i,m,r,O]),he=(0,B.useCallback)(e=>{RT(e),a(e),_({busy:!1,error:null,done:!1})},[]),F=(0,B.useCallback)(async e=>{await n(),t(e)},[t,n]),I=re&&(!P||g.done),L=te.find(e=>e.status===`active`||e.status===`failed`),ge=P?w:u?.chat_model??(b&&!b.decided_after_server?b.chat_model.id:null);return(0,B.useEffect)(()=>{I&&Yi().then(e=>D(e.cards)).catch(e=>console.warn(`[SetupScreen] no first tasks to offer`,e))},[I]),(0,H.jsx)(`main`,{className:`setup`,"aria-labelledby":`setup-title`,children:(0,H.jsxs)(`div`,{className:`setup-inner`,children:[(0,H.jsx)(`h1`,{id:`setup-title`,className:`setup-title`,children:`Set up GAIA`}),(0,H.jsx)(`p`,{className:`setup-lede`,children:I?`All set.`:u?`Setting things up. Setup keeps going if you switch away.`:`A few minutes of setup, then your first chat.`}),(0,H.jsxs)(`ol`,{className:`setup-steps`,children:[(0,H.jsxs)(`li`,{className:`setup-step${o||c?` is-done`:` is-current`}`,children:[(0,H.jsxs)(`div`,{className:`setup-step-head`,children:[(0,H.jsx)(`span`,{className:`setup-step-num`,children:o||c?(0,H.jsx)(ae,{size:14,"aria-hidden":`true`}):1}),(0,H.jsx)(`span`,{className:`setup-step-label`,children:`Check this PC`})]}),!ie&&(0,H.jsx)(`div`,{className:`setup-step-body`,children:(0,H.jsx)(jT,{hardware:o,error:c})})]}),(0,H.jsxs)(`li`,{className:`setup-step${ie?` is-done`:` is-current`}`,children:[(0,H.jsxs)(`div`,{className:`setup-step-head`,children:[(0,H.jsx)(`span`,{className:`setup-step-num`,children:ie?(0,H.jsx)(ae,{size:14,"aria-hidden":`true`}):2}),(0,H.jsx)(`span`,{className:`setup-step-label`,children:`Choose where GAIA runs`})]}),!ie&&(0,H.jsxs)(`div`,{className:`setup-step-body`,children:[(0,H.jsx)(VT,{onChosen:e=>{k(e===`external`),ce(),de()}}),(0,H.jsx)(`div`,{className:`setup-choices`,role:`radiogroup`,"aria-label":`Where GAIA runs`,children:PT.map(e=>(0,H.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":i===e.id,className:`setup-choice${i===e.id?` is-active`:``}${ee(e.id)?` is-disabled`:``}`,onClick:()=>a(e.id),disabled:ee(e.id),children:[e.id===`local`?(0,H.jsx)(ke,{size:16,"aria-hidden":`true`}):(0,H.jsx)(xe,{size:16,"aria-hidden":`true`}),(0,H.jsxs)(`span`,{children:[(0,H.jsx)(`span`,{className:`setup-choice-title`,children:e.title}),(0,H.jsx)(`span`,{className:`setup-choice-note`,children:ee(e.id)?M?.detail:e.note})]})]},e.id))}),M?.reachable===!1&&(0,H.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:N,children:`Check the AMD gateway again`})]})]}),!P&&(0,H.jsxs)(`li`,{className:`setup-step${ie&&oe?` is-done`:ie?` is-pending`:` is-current`}`,children:[(0,H.jsxs)(`div`,{className:`setup-step-head`,children:[(0,H.jsx)(`span`,{className:`setup-step-num`,children:ie&&oe?(0,H.jsx)(ae,{size:14,"aria-hidden":`true`}):3}),(0,H.jsx)(`span`,{className:`setup-step-label`,children:`Chat model`})]}),(0,H.jsx)(`div`,{className:`setup-step-body`,children:(0,H.jsx)(MT,{plan:b,planError:S,chosen:u?.chat_model??null,locked:ie,onPlan:x})})]}),!u&&(0,H.jsxs)(`li`,{className:`setup-step-action`,children:[(0,H.jsx)(`button`,{type:`button`,className:`btn-primary setup-start`,onClick:()=>void pe(),disabled:ee(i),children:`Start setup`}),ee(i)&&(0,H.jsxs)(`p`,{className:`setup-error`,role:`alert`,children:[M?.detail,`. Choose another option, or connect and check again.`]}),f&&(0,H.jsx)(`p`,{className:`setup-error`,role:`alert`,children:f})]}),te.map((e,t)=>{let n=u?e.status:`pending`,r=n===`active`,i=n===`failed`||n===`cancelled`;return(0,H.jsxs)(`li`,{className:`setup-step is-${n??`pending`}`,"aria-current":r?`step`:void 0,children:[(0,H.jsxs)(`div`,{className:`setup-step-head`,children:[(0,H.jsx)(`span`,{className:`setup-step-num`,children:(0,H.jsx)(zT,{status:n,n:t+se})}),(0,H.jsxs)(`span`,{className:`setup-step-label`,children:[e.label,e.detail&&(0,H.jsxs)(`span`,{className:`setup-step-detail`,children:[` — `,e.detail]})]})]}),r&&u&&(0,H.jsxs)(`div`,{className:`setup-step-body`,children:[(0,H.jsx)(`p`,{className:`setup-hint`,role:`status`,children:u.text}),u.percent!=null&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`progress`,{className:`setup-progress`,max:100,value:u.percent,"aria-label":u.text}),(0,H.jsxs)(`p`,{className:`setup-hint`,children:[u.percent,`%`,u.size?` · ${u.size}`:``]})]})]}),i&&u&&e===L&&(0,H.jsxs)(`div`,{className:`setup-step-body`,children:[(0,H.jsx)(`p`,{className:`setup-error`,role:`alert`,children:u.error??`Setup stopped.`}),u.problem?(0,H.jsx)(HT,{problem:u.problem,onRetry:()=>void pe(),onUseGaia:()=>void pe(!0)}):(0,H.jsxs)(`div`,{className:`setup-row`,children:[(0,H.jsx)(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void pe(!!u.gaia_lemonade),children:`Try again`}),(0,H.jsxs)(`span`,{className:`setup-hint`,children:[`or run `,(0,H.jsx)(`code`,{children:u.command}),` in a terminal.`]})]}),f&&(0,H.jsx)(`p`,{className:`setup-error`,role:`alert`,children:f})]})]},e.key)}),P&&(0,H.jsxs)(`li`,{className:`setup-step${g.done?` is-done`:re?` is-current`:` is-pending`}`,children:[(0,H.jsxs)(`div`,{className:`setup-step-head`,children:[(0,H.jsx)(`span`,{className:`setup-step-num`,children:g.done?(0,H.jsx)(ae,{size:14,"aria-hidden":`true`}):te.length+se}),(0,H.jsxs)(`span`,{className:`setup-step-label`,children:[`Connect `,PT.find(e=>e.id===i)?.title]})]}),re&&!g.done&&(0,H.jsxs)(`form`,{className:`setup-step-body`,onSubmit:e=>{e.preventDefault(),me()},children:[(0,H.jsx)(`div`,{className:`setup-row`,role:`radiogroup`,"aria-label":`Cloud provider`,children:PT.filter(e=>e.id!==`local`).map(e=>(0,H.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":i===e.id,className:i===e.id?`btn-primary`:`btn-secondary`,onClick:()=>he(e.id),disabled:g.busy||ee(e.id),title:ee(e.id)?M?.detail??void 0:void 0,children:e.title},e.id))}),(0,H.jsx)(OT,{provider:i,limit:3}),O?(0,H.jsx)(`p`,{className:`setup-hint`,children:`GAIA uses this provider as your Lemonade Server already has it set up. It doesn’t send your server a key or change its setup.`}):(0,H.jsx)(`p`,{className:`setup-hint`,children:`The key goes to GAIA’s local model server and your OS credential store, nowhere else.`}),(0,H.jsxs)(`div`,{className:`setup-row`,children:[!O&&(0,H.jsx)(`input`,{className:`settings-input`,type:`password`,autoComplete:`off`,value:m,onChange:e=>h(e.target.value),placeholder:`Paste API key (blank uses a key already configured)`,"aria-label":`API key`}),(0,H.jsxs)(`button`,{type:`submit`,className:`btn-primary`,disabled:g.busy,children:[g.busy&&(0,H.jsx)(z,{size:13,className:`spin`}),` Connect`]})]}),g.busy&&g.waiting&&(0,H.jsx)(`p`,{className:`setup-hint`,role:`status`,children:g.waiting}),g.error&&(0,H.jsx)(`p`,{className:`setup-error`,role:`alert`,children:g.error})]})]})]}),u&&u.log_tail&&u.log_tail.length>0&&(0,H.jsxs)(`div`,{className:`setup-log`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`setup-log-toggle`,onClick:()=>y(e=>!e),"aria-expanded":v,children:[(0,H.jsx)(le,{size:13,className:v?`is-open`:``,"aria-hidden":`true`}),` Details`]}),v&&(0,H.jsx)(`pre`,{className:`setup-log-pre`,children:u.log_tail.join(`
78
- `)})]}),I&&(0,H.jsxs)(`div`,{className:`setup-done`,role:`status`,children:[(0,H.jsxs)(`div`,{className:`setup-done-head`,children:[(0,H.jsxs)(`p`,{children:[`GAIA is ready.`,ge&&(0,H.jsxs)(H.Fragment,{children:[` `,(0,H.jsx)(`strong`,{children:Qo(ge)}),` answers`,P?` in the cloud`:` on this PC`,`.`]})]}),(0,H.jsx)(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void F(),autoFocus:!0,children:`Start chatting`})]}),E.length>0&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`p`,{className:`setup-hint`,children:`Or start with one of these:`}),(0,H.jsx)(pT,{cards:E,onPick:e=>void F(e)})]})]})]})})}var GT=Js()?`menu bar`:`tray`,KT=[{key:`minimizeToTray`,label:`Keep running when the window closes`,hint:`GAIA stays in the ${GT} with your model loaded. Quit from the ${GT} menu.`},{key:`startOnLogin`,label:`Start GAIA when you sign in`,hint:`Your first chat of the day starts without waiting for GAIA to open.`},{key:`startMinimized`,label:`Start in the ${GT}`,hint:`GAIA opens without its window. Use the ${GT} icon to show it.`}];function qT(){let e=window.gaiaAPI?.tray,[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(null);(0,B.useEffect)(()=>{e&&e.getConfig().then(e=>n(e.tray)).catch(e=>i(`Couldn't read the desktop settings: ${e instanceof Error?e.message:String(e)}`))},[e]);let s=(0,B.useCallback)(async r=>{if(e&&t&&a===null){o(r),i(null);try{let i=await e.setConfig({tray:{[r]:!t[r]}});n(i.tray)}catch(e){i(e instanceof Error?e.message:String(e))}finally{o(null)}}},[e,t,a]);return e?(0,H.jsxs)(`div`,{className:`settings-field`,role:`group`,"aria-labelledby":`desktop-app-label`,children:[(0,H.jsx)(`span`,{className:`settings-label`,id:`desktop-app-label`,children:`Desktop app`}),KT.map(({key:e,label:n,hint:r})=>(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`label`,{className:`setting-row`,children:[(0,H.jsx)(`span`,{children:n}),(0,H.jsxs)(`span`,{className:`toggle-switch`,children:[(0,H.jsx)(`input`,{type:`checkbox`,role:`switch`,checked:!!t?.[e],"aria-describedby":`desktop-${e}-hint`,onChange:()=>void s(e),disabled:!t||a!==null&&a!==e,"aria-busy":a===e,"aria-label":n}),(0,H.jsx)(`span`,{className:`toggle-track`})]})]}),(0,H.jsx)(`p`,{className:`settings-hint`,id:`desktop-${e}-hint`,children:r})]},e)),r&&(0,H.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r})]}):null}var JT=[{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`system`,label:`Match system`}],YT=[[`Enter`,`Send`],[`Shift+Enter`,`New line`],[`Esc`,`Stop the answer`],[`Mod+Shift+O`,`New chat`],[`Mod+K`,`Search chats`],[`Mod+B`,`Show or hide the sidebar`],[`Mod+,`,`Settings`]];function XT(){let e=V(e=>e.themePreference),t=V(e=>e.setThemePreference),n=V(e=>e.palette),r=V(e=>e.setPalette),i=V(e=>e.customColors),a=V(e=>e.setCustomColors),o=e=>t=>a({...i,[e]:t.target.value.toUpperCase()});return(0,H.jsxs)(`div`,{className:`settings-pane`,children:[(0,H.jsx)(`h2`,{className:`settings-pane-title`,children:`General`}),(0,H.jsxs)(`div`,{className:`settings-field`,children:[(0,H.jsx)(`span`,{className:`settings-label`,id:`appearance-label`,children:`Appearance`}),(0,H.jsx)(`div`,{className:`segmented`,role:`radiogroup`,"aria-labelledby":`appearance-label`,children:JT.map(n=>(0,H.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e===n.value,className:e===n.value?`is-active`:``,onClick:()=>t(n.value),children:n.label},n.value))})]}),(0,H.jsx)(qT,{}),(0,H.jsxs)(`div`,{className:`settings-field`,children:[(0,H.jsx)(`span`,{className:`settings-label`,id:`palette-label`,children:`Colors`}),(0,H.jsxs)(`div`,{className:`palette-grid`,role:`radiogroup`,"aria-labelledby":`palette-label`,children:[tr.map(e=>(0,H.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":n===e.id,className:`palette-tile${n===e.id?` is-active`:``}`,onClick:()=>r(e.id),children:[(0,H.jsx)(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:e.swatch.map(e=>(0,H.jsx)(`i`,{style:{background:e}},e))}),e.name]},e.id)),(0,H.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":n===`custom`,className:`palette-tile${n===`custom`?` is-active`:``}`,onClick:()=>r(`custom`),children:[(0,H.jsxs)(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:[(0,H.jsx)(`i`,{style:{background:i.base}}),(0,H.jsx)(`i`,{style:{background:i.accent}})]}),`Custom`]})]}),n===`custom`&&(0,H.jsxs)(`div`,{className:`palette-custom`,children:[(0,H.jsxs)(`label`,{className:`palette-color`,htmlFor:`custom-accent`,children:[(0,H.jsx)(`input`,{id:`custom-accent`,type:`color`,value:i.accent,onChange:o(`accent`)}),(0,H.jsxs)(`span`,{children:[`Accent`,(0,H.jsx)(`small`,{children:`Buttons, links and focus`})]})]}),(0,H.jsxs)(`label`,{className:`palette-color`,htmlFor:`custom-base`,children:[(0,H.jsx)(`input`,{id:`custom-base`,type:`color`,value:i.base,onChange:o(`base`)}),(0,H.jsxs)(`span`,{children:[`Background tint`,(0,H.jsx)(`small`,{children:`The color the grays lean toward`})]})]}),(0,H.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>a(rr),children:`Reset`}),(0,H.jsx)(`p`,{className:`settings-hint`,children:`Text colors adjust on their own so everything stays readable in light and dark.`})]})]}),(0,H.jsxs)(`div`,{className:`settings-field`,children:[(0,H.jsx)(`span`,{className:`settings-label`,children:`Keyboard shortcuts`}),(0,H.jsx)(`dl`,{className:`shortcut-list`,children:YT.map(([e,t])=>(0,H.jsxs)(`div`,{className:`shortcut-row`,children:[(0,H.jsx)(`dt`,{children:(0,H.jsx)(`kbd`,{children:Qs(e)})}),(0,H.jsx)(`dd`,{children:t})]},e))})]})]})}var ZT=`auto`;function QT({model:e}){let[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(null);(0,B.useEffect)(()=>{n(null),i(null),c(null),aa(e).then(n).catch(e=>i(e instanceof Error?e.message:String(e)))},[e]);let l=(0,B.useCallback)(async t=>{o(!0),i(null),c(null);try{let r=await oa(e,t===ZT?null:Number(t));n(r);let i=r.chosen?rs(r.chosen):`the automatic size`;r.reload?.started?c(`Reloading ${r.display_name} at ${i}. Chat pauses until it's back.`):r.reload?.reason===`already_loaded`?c(`Saved. ${r.display_name} is already loaded at ${i}, so nothing reloads.`):r.reload?.reason===`warm_up`?c(`Saved. GAIA is getting the model ready for a new chat, so ${r.display_name} switches to ${i} the next time it loads.`):r.reload?.reason===`busy`?c(`Saved. GAIA is answering right now, so ${r.display_name} switches to ${i} the next time it loads.`):r.reload?.reason===`not_gaias_server`?c(`Saved. GAIA doesn't reload models on your own server; ${r.display_name} uses ${i} the next time it loads.`):r.reload?.reason===`restarting`?c(`Saved. A reload is already running; this size applies the next time the model loads.`):c(`Saved. It applies the next time this model loads.`)}catch(e){i(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e]);if(r&&!t)return(0,H.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r});if(!t)return(0,H.jsxs)(`p`,{className:`settings-hint`,children:[(0,H.jsx)(z,{size:13,className:`spin`}),` Checking context sizes…`]});let u=t.chosen==null?ZT:String(t.chosen),d=t.chosen!=null&&t.loaded_ctx!=null&&t.loaded_ctx!==t.chosen;return(0,H.jsxs)(`div`,{className:`settings-field`,children:[(0,H.jsx)(`label`,{className:`settings-label`,htmlFor:`ctx-size`,children:`Context size`}),(0,H.jsxs)(`select`,{id:`ctx-size`,className:`settings-input`,value:u,onChange:e=>void l(e.target.value),disabled:a||t.options.length===0,children:[(0,H.jsxs)(`option`,{value:ZT,children:[`Automatic`,t.automatic?` (${rs(t.automatic)})`:``]}),t.options.map(e=>(0,H.jsxs)(`option`,{value:String(e),children:[rs(e),` tokens`]},e))]}),(0,H.jsxs)(`span`,{className:`settings-hint`,children:[t.note??(t.max_fit?`Up to ${rs(t.max_fit)}, the most ${t.display_name} can hold on this PC (${t.memory_source}). A larger window uses more memory. GAIA reloads the model to apply it, except on a Lemonade you run yourself.`:null),d&&` Loaded now at ${rs(t.loaded_ctx)}.`]}),a&&(0,H.jsxs)(`span`,{className:`settings-hint`,children:[(0,H.jsx)(z,{size:13,className:`spin`}),` Applying…`]}),s&&(0,H.jsx)(`p`,{className:`settings-ok`,role:`status`,children:s}),r&&(0,H.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r})]})}function $T(){let[e,t]=(0,B.useState)(null),[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(``),[o,s]=(0,B.useState)(!1),c=(0,B.useCallback)(async e=>{s(!0),r(null);try{let n=await e();t(n),a(n.limit_usd==null?``:String(n.limit_usd))}catch(e){r(e instanceof Error?e.message:String(e))}finally{s(!1)}},[]);if((0,B.useEffect)(()=>{c(da)},[c]),!e)return n?(0,H.jsx)(`p`,{className:`settings-error`,role:`alert`,children:n}):(0,H.jsxs)(`p`,{className:`settings-hint`,children:[(0,H.jsx)(z,{size:13,className:`spin`}),` Loading this month’s spending…`]});let l=e.limit_usd,u=i.trim()===``?null:Number(i),d=u===null||Number.isFinite(u)&&u>0,f=u!==l;return(0,H.jsxs)(`section`,{className:`settings-field spending`,"aria-label":`Cloud spending`,children:[(0,H.jsx)(`span`,{className:`settings-label`,children:`Cloud spending this month`}),(0,H.jsxs)(`p`,{className:`spending-total`,children:[(0,H.jsx)(`strong`,{children:yS(e.total_usd)}),l!=null&&(0,H.jsxs)(H.Fragment,{children:[` of your `,yS(l),` limit`]}),(0,H.jsxs)(`span`,{className:`settings-hint`,children:[` · `,e.turns,` cloud `,e.turns===1?`chat turn`:`chat turns`,`, at list price`]})]}),e.unpriced_turns>0&&(0,H.jsxs)(`p`,{className:`settings-hint`,children:[`Plus `,e.unpriced_turns,` `,e.unpriced_turns===1?`turn`:`turns`,` on models with an unknown price, not included above.`]}),e.state===`near`&&(0,H.jsxs)(`p`,{className:`spending-warning`,role:`status`,children:[(0,H.jsx)(Cn,{size:13,"aria-hidden":`true`}),` Close to your limit. GAIA stops before a cloud chat once it’s reached.`]}),e.state===`reached`&&(0,H.jsxs)(`div`,{className:`spending-warning`,role:`alert`,children:[(0,H.jsxs)(`p`,{children:[(0,H.jsx)(Cn,{size:13,"aria-hidden":`true`}),` You’ve reached your limit, so cloud chats are stopped until next month. Models on this PC still work.`]}),(0,H.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:o,onClick:()=>void c(pa),children:`Allow more this month`})]}),e.state===`allowed_over`&&(0,H.jsx)(`p`,{className:`settings-hint`,children:`Over your limit; you allowed more for this month.`}),(0,H.jsxs)(`form`,{className:`settings-row`,onSubmit:e=>{e.preventDefault(),d&&f&&c(()=>fa(u))},children:[(0,H.jsx)(`label`,{className:`spending-limit-label`,htmlFor:`spend-limit`,children:`Monthly limit ($)`}),(0,H.jsx)(`input`,{id:`spend-limit`,className:`settings-input`,type:`number`,min:`0.01`,step:`0.01`,inputMode:`decimal`,placeholder:`No limit`,value:i,onChange:e=>a(e.target.value),"aria-invalid":!d}),(0,H.jsxs)(`button`,{type:`submit`,className:`btn-secondary`,disabled:o||!d||!f,children:[o?(0,H.jsx)(z,{size:13,className:`spin`}):null,` Save`]}),l!=null&&(0,H.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:o,onClick:()=>void c(()=>fa(null)),children:`Remove limit`})]}),(0,H.jsx)(`span`,{className:`settings-hint`,children:`Counts cloud chats in GAIA’s Agent UI at list price, without cache discounts. Your provider’s bill is the final word. Turns that fail or are stopped before a reply aren’t counted. Models with an unknown price, like the AMD LLM Gateway’s, add nothing to the total, but are stopped too once the limit is reached.`}),n&&(0,H.jsx)(`p`,{className:`settings-error`,role:`alert`,children:n})]})}var eE=2e3;function tE(e){if(e.key_state===`waiting_for_os_permission`)return e.key_message??`Waiting for the OS to allow reading the saved key.`;switch(e.key_source){case`environment`:return`A key is set in ${e.env_var} and is in use.`;case`lemonade`:return`A key is already configured on the local model server.`;case`stored`:return`A saved key will be used.`;default:return`No key yet.`}}function nE(e){return e.key_source===`environment`?`Blank uses the environment key`:e.key_source?`Blank keeps the saved key`:`Paste API key`}function rE(){let e=Uo(e=>e.active),t=Uo(e=>e.select),n=Uo(e=>e.refresh),r=Uo(e=>e.rememberNames),[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(e?.provider??`local`),[u,d]=(0,B.useState)(null),[f,p]=(0,B.useState)(null),[m,h]=(0,B.useState)(``),[g,_]=(0,B.useState)(!1),[v,y]=(0,B.useState)(``),[b,x]=(0,B.useState)({base_url:``,auth_header_name:``,auth_header_prefix:``}),[S,C]=(0,B.useState)(null),[w,T]=(0,B.useState)(null),[E,D]=(0,B.useState)(null),O=(0,B.useRef)(c);O.current=c;let k=(0,B.useRef)(!0);(0,B.useEffect)(()=>()=>{k.current=!1},[]);let A=i?.find(e=>e.id===c)??null,j=e=>e?.network?.reachable===!1,M=!!A&&(!A.remote||!!A.models_discovered),N=(0,B.useCallback)(async()=>{s(null);try{let e=await $i();a(e.providers),e.lemonade_error&&s(e.lemonade_error)}catch(e){s(e instanceof Error?e.message:String(e))}},[]),ee=(0,B.useCallback)(async(e,t=!1)=>{t||(d(null),p(null));try{let t=await ia(e);r(t.models),d(t.models),T(t.memory_gb?`${t.memory_gb} GB (${t.memory_source})`:t.capacity_error??null)}catch(e){p(e instanceof Error?e.message:String(e))}},[r]);(0,B.useEffect)(()=>{N()},[N]);let P=!!i?.some(e=>e.key_state===`waiting_for_os_permission`);(0,B.useEffect)(()=>{if(!P)return;let e=setInterval(()=>{N()},eE);return()=>clearInterval(e)},[P,N]);let te=e?.provider;(0,B.useEffect)(()=>{te&&l(te)},[te]),(0,B.useEffect)(()=>{y(``),D(null),h(``),_(!1)},[c]),(0,B.useEffect)(()=>{M?ee(c):d(null)},[c,M,ee]);let ne=(0,B.useCallback)(async()=>{if(A){C(`connect`),D(null);try{let e=c===`amd`?{api_key:v||void 0,...Object.fromEntries(Object.entries(b).filter(([,e])=>e!==``))}:{api_key:v||void 0},t=()=>!k.current||O.current!==c,n=await na(c,e,e=>{t()||D({ok:!0,text:e})},t);if(t())return;y(``),D({ok:!0,text:n.remember_error?`Connected for this session only — the key could not be kept: ${n.remember_error}`:n.remembered?`Connected. The key is kept for next time.`:`Connected.`}),await N()}catch(e){k.current&&O.current===c&&D({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{k.current&&C(null)}}},[b,c,v,N,A]),re=(0,B.useCallback)(async()=>{C(`forget`),D(null);try{await ra(c),D({ok:!0,text:`Key cleared, here and for future sessions. An environment key, if set, stays active.`}),await N(),await n()}catch(e){D({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{C(null)}},[c,N,n]),ie=(0,B.useCallback)(async e=>{C(e),D(null);try{await t(e),D({ok:!0,text:`New messages use ${Go(e)}. It is remembered across restarts.`})}catch(e){D({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{C(null)}},[t]),oe=(0,B.useCallback)(async e=>{C(`dl:${e}`),D(null);try{await zi(e),await ee(`local`,!0)}catch(e){D({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{C(null)}},[ee]),se=!!u?.some(as);(0,B.useEffect)(()=>{if(c!==`local`||!se)return;let e=setInterval(()=>{ee(`local`,!0)},eE);return()=>clearInterval(e)},[se,c,ee]);let ce=(0,B.useMemo)(()=>{let e=m.trim().toLowerCase();return(u??[]).filter(t=>!e||t.id.toLowerCase().includes(e)||(t.display_name??``).toLowerCase().includes(e))},[u,m]),le=ce.filter(e=>e.available!==!1),ue=c===`fireworks`&&!g&&!m.trim()&&le.some(e=>e.rank!==null),de=t=>t.rank!==null||t.id===e?.model,fe=ue?le.filter(de):le,pe=ue?le.filter(e=>!de(e)):[],me=ce.filter(e=>e.available===!1),he=$o(u??[]),F=e&&!e.remote&&e.model?e.model:null,I=t=>{let n=e?.model===t.id,r=as(t)?t.download_progress:null,i=[ns(t.placement),t.size_gb?`${t.size_gb} GB ${t.downloaded?`on disk`:`download`}`:null,t.tokens_per_second?`${Math.round(t.tokens_per_second)} tok/s measured here`:null,!t.placement&&t.context_length?`Context ${t.context_length.toLocaleString()} tokens`:null].filter(Boolean).join(` · `);return(0,H.jsxs)(`li`,{className:`model-row${n?` is-current`:``}`,children:[(0,H.jsxs)(`div`,{className:`model-row-text`,children:[(0,H.jsxs)(`span`,{className:`model-row-name`,title:t.id,children:[he[t.id],t.rank&&(0,H.jsxs)(`span`,{className:`model-row-rank`,children:[`#`,t.rank,` `,t.note]}),t.state===`loaded`&&(0,H.jsx)(`span`,{className:`model-badge is-loaded`,children:ts.loaded}),t.fits===!0&&t.available!==!1&&(0,H.jsx)(`span`,{className:`model-badge is-fit`,children:`Fits this PC`})]}),A?.remote&&(0,H.jsx)(`span`,{className:`model-row-meta${t.price?``:` is-unknown-price`}`,children:vS(t.price)}),t.display_name&&(0,H.jsx)(`span`,{className:`model-row-meta`,children:t.id}),i&&(0,H.jsx)(`span`,{className:`model-row-meta`,children:i}),t.placement?.warning&&(0,H.jsx)(`span`,{className:`model-row-meta is-warning`,role:`alert`,children:t.placement.warning}),t.unavailable_reason&&(0,H.jsxs)(`span`,{className:`model-row-meta`,children:[`Can't run here: `,t.unavailable_reason]}),t.evidence&&(0,H.jsxs)(`span`,{className:`model-row-meta`,children:[`Measured: `,t.evidence]}),r&&(0,H.jsx)(`progress`,{max:100,value:r.percent,"aria-label":`Downloading ${he[t.id]}`})]}),n?(0,H.jsxs)(`span`,{className:`model-row-current`,children:[(0,H.jsx)(ae,{size:13,"aria-hidden":`true`}),` In use`]}):t.available===!1?null:r?(0,H.jsxs)(`span`,{className:`model-row-current`,children:[(0,H.jsx)(z,{size:13,className:`spin`}),` `,Math.round(r.percent),`%`]}):t.downloaded?(0,H.jsxs)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void ie(t.id),disabled:S!==null,"aria-label":`Use ${he[t.id]}`,children:[S===t.id?(0,H.jsx)(z,{size:13,className:`spin`}):null,` Use`]}):(0,H.jsxs)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void oe(t.id),disabled:S!==null,"aria-label":`Download ${he[t.id]}`,children:[S===`dl:${t.id}`?(0,H.jsx)(z,{size:13,className:`spin`}):null,` Download`]})]},t.id)};return(0,H.jsxs)(`div`,{className:`settings-pane`,children:[(0,H.jsx)(`h2`,{className:`settings-pane-title`,children:`Model`}),(0,H.jsx)(`p`,{className:`settings-pane-lede`,children:`GAIA runs on this PC by default. Cloud providers are used only when you pick one of their models.`}),(0,H.jsx)(`div`,{className:`provider-tabs`,role:`radiogroup`,"aria-label":`Where GAIA runs`,children:(i??[{id:`local`,name:`Local`,remote:!1}]).map(e=>(0,H.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":c===e.id,className:`provider-tab${c===e.id?` is-active`:``}${j(e)?` is-disabled`:``}`,onClick:()=>l(e.id),disabled:j(e)&&c!==e.id,title:j(e)?e.network?.detail??void 0:void 0,children:[e.remote?(0,H.jsx)(xe,{size:14,"aria-hidden":`true`}):(0,H.jsx)(ke,{size:14,"aria-hidden":`true`}),(0,H.jsx)(`span`,{children:e.name}),e.remote&&e.models_discovered&&(0,H.jsx)(`span`,{className:`provider-tab-dot`,"aria-label":`connected`})]},e.id))}),o&&(0,H.jsx)(`p`,{className:`settings-error`,role:`alert`,children:o}),A&&(0,H.jsxs)(`section`,{className:`settings-card`,"aria-label":A.name,children:[(0,H.jsx)(`p`,{className:`settings-note`,children:A.privacy_notice}),A.id===`local`&&(0,H.jsxs)(`p`,{className:`settings-hint`,children:[`Each model runs where it was built to: GGUF models on the GPU, FLM models on the NPU.`,w&&` Memory for models: ${w}.`]}),A.remote&&!M&&(0,H.jsxs)(`div`,{className:`settings-field`,children:[(0,H.jsx)(`span`,{className:`settings-label`,children:`Prices`}),(0,H.jsx)(OT,{provider:A.id})]}),j(A)&&(0,H.jsxs)(`div`,{className:`settings-field`,children:[(0,H.jsx)(`p`,{className:`settings-error`,role:`alert`,children:A.network?.detail}),(0,H.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void N(),children:`Check again`})]}),A.remote&&!j(A)&&(0,H.jsxs)(`form`,{className:`settings-field`,onSubmit:e=>{e.preventDefault(),ne()},children:[(0,H.jsx)(`span`,{className:`settings-label`,children:`API key`}),(0,H.jsx)(`span`,{className:`settings-hint`,children:tE(A)}),A.id===`amd`&&(0,H.jsxs)(`div`,{className:`settings-grid`,children:[(0,H.jsx)(`input`,{className:`settings-input`,placeholder:`Gateway URL (default https://llm-api.amd.com/Unified/v1)`,value:b.base_url,onChange:e=>x({...b,base_url:e.target.value}),"aria-label":`Gateway URL`}),(0,H.jsx)(`input`,{className:`settings-input`,placeholder:`Auth header (default Ocp-Apim-Subscription-Key)`,value:b.auth_header_name,onChange:e=>x({...b,auth_header_name:e.target.value}),"aria-label":`Auth header name`})]}),(0,H.jsxs)(`div`,{className:`settings-row`,children:[(0,H.jsx)(`input`,{className:`settings-input`,type:`password`,autoComplete:`off`,spellCheck:!1,value:v,onChange:e=>y(e.target.value),placeholder:nE(A),"aria-label":`${A.name} API key`}),(0,H.jsxs)(`button`,{type:`submit`,className:`btn-primary`,disabled:S!==null||!v&&!A.key_source,children:[S===`connect`?(0,H.jsx)(z,{size:13,className:`spin`}):null,A.models_discovered?`Reconnect`:`Connect`]}),(A.key_source===`lemonade`||A.key_source===`stored`)&&(0,H.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void re(),disabled:S!==null,children:`Forget key`})]}),A.error&&(0,H.jsx)(`p`,{className:`settings-error`,role:`alert`,children:A.error})]}),E&&(0,H.jsx)(`p`,{className:E.ok?`settings-ok`:`settings-error`,role:E.ok?`status`:`alert`,children:E.text}),A.id===`local`&&F&&e?.downloaded!==!1&&(0,H.jsx)(QT,{model:F}),M&&(0,H.jsxs)(`div`,{className:`settings-field`,children:[(0,H.jsx)(`span`,{className:`settings-label`,children:`Models`}),(u?.length??0)>6&&(0,H.jsx)(`input`,{className:`settings-input`,type:`search`,value:m,onChange:e=>h(e.target.value),placeholder:`Search models`,"aria-label":`Search models`}),f&&(0,H.jsx)(`p`,{className:`settings-error`,role:`alert`,children:f}),!u&&!f&&(0,H.jsxs)(`p`,{className:`settings-hint`,children:[(0,H.jsx)(z,{size:13,className:`spin`}),` Loading…`]}),u&&ce.length===0&&(0,H.jsx)(`p`,{className:`settings-hint`,children:`No models match.`}),(0,H.jsx)(`ul`,{className:`model-list`,children:fe.map(I)}),ue&&pe.length>0&&(0,H.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>_(!0),children:`Show all models`}),c===`fireworks`&&g&&!m.trim()&&(0,H.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>_(!1),children:`Show recommended models`}),me.length>0&&(0,H.jsxs)(`details`,{className:`model-unavailable`,children:[(0,H.jsxs)(`summary`,{children:[`Not available on this PC (`,me.length,`)`]}),(0,H.jsx)(`ul`,{className:`model-list`,children:me.map(I)})]})]}),A.remote&&(0,H.jsx)($T,{})]})]})}function iE(){let e=V(e=>e.sessions),[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)(null),a=(0,B.useCallback)(async()=>{i(null);try{n((await gi()).sessions)}catch(e){i(e instanceof Error?e.message:String(e))}},[]);(0,B.useEffect)(()=>{a()},[a]);let o=(0,B.useCallback)(async e=>{i(null);try{await e(),await a()}catch(e){i(e instanceof Error?e.message:String(e))}},[a]),s=t=>e.find(e=>e.id===t)?.title??t;return(0,H.jsxs)(`div`,{className:`settings-pane`,children:[(0,H.jsx)(`h2`,{className:`settings-pane-title`,children:`Permissions`}),(0,H.jsx)(`p`,{className:`settings-pane-lede`,children:`GAIA asks before it changes files, runs commands, or uses tools that act on your behalf. Pick a mode per chat from the shield next to the message box. “Always allow” covers one exact action in one chat and ends when GAIA restarts.`}),(0,H.jsxs)(`p`,{className:`settings-hint`,children:[`New chats start in full access only when `,(0,H.jsx)(`code`,{children:`full_access`}),` is set in`,(0,H.jsx)(`code`,{children:` ~/.gaia/config.json`}),` (the TUI’s `,(0,H.jsx)(`code`,{children:`/full-access always`}),`).`]}),r&&(0,H.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r}),t&&t.length===0&&(0,H.jsx)(`p`,{className:`settings-hint`,children:`No chat has full access or anything allowed without asking.`}),t?.map(e=>(0,H.jsxs)(`section`,{className:`settings-card`,"aria-label":s(e.session_id),children:[(0,H.jsxs)(`div`,{className:`settings-row settings-row-between`,children:[(0,H.jsx)(`span`,{className:`settings-label`,children:s(e.session_id)}),e.mode===`full_access`&&(0,H.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>o(()=>_i(e.session_id,`ask`)),children:`Turn off full access`})]}),e.grants.length>0&&(0,H.jsx)(`ul`,{className:`grant-list`,children:e.grants.map(t=>(0,H.jsxs)(`li`,{className:`grant-row`,children:[(0,H.jsx)(`code`,{children:t.label}),(0,H.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>o(()=>vi(e.session_id,t.key)),"aria-label":`Revoke ${t.label}`,children:`Revoke`})]},t.key))}),e.grants.length>1&&(0,H.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>o(()=>vi(e.session_id)),children:`Revoke all in this chat`})]},e.session_id))]})}function aE({onUseSkill:e}){let[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)({}),[a,o]=(0,B.useState)(null),[s,c]=(0,B.useState)(``);(0,B.useEffect)(()=>{let e=!1;return ma().then(t=>{e||(n(t.skills),i(t.invalid))}).catch(t=>{e||o(t instanceof Error?t.message:String(t))}),()=>{e=!0}},[]);let l=s.trim().toLowerCase(),u=(t??[]).filter(e=>!l||e.name.toLowerCase().includes(l)||e.description.toLowerCase().includes(l));return(0,H.jsxs)(`div`,{className:`settings-pane`,children:[(0,H.jsx)(`h2`,{className:`settings-pane-title`,children:`Skills`}),(0,H.jsxs)(`p`,{className:`settings-pane-lede`,children:[`Skills teach GAIA a job — a workflow, a CLI, a document type. GAIA loads one when a request needs it, and keeps the lessons it learns while using it. Add your own under `,(0,H.jsx)(`code`,{children:`~/.gaia/skills`}),`.`]}),a&&(0,H.jsx)(`p`,{className:`settings-error`,role:`alert`,children:a}),!t&&!a&&(0,H.jsxs)(`p`,{className:`settings-hint`,children:[(0,H.jsx)(z,{size:13,className:`spin`}),` Loading…`]}),t&&t.length>6&&(0,H.jsx)(`input`,{className:`settings-input`,type:`search`,value:s,onChange:e=>c(e.target.value),placeholder:`Search skills`,"aria-label":`Search skills`}),t&&t.length===0&&(0,H.jsx)(`p`,{className:`settings-hint`,children:`No skills are installed.`}),(0,H.jsx)(`ul`,{className:`skill-list`,children:u.map(t=>(0,H.jsxs)(`li`,{className:`skill-row`,children:[(0,H.jsxs)(`div`,{className:`skill-row-text`,children:[(0,H.jsxs)(`span`,{className:`skill-row-name`,children:[t.name,t.version&&(0,H.jsxs)(`span`,{className:`skill-row-meta`,children:[` v`,t.version]}),t.always_on&&(0,H.jsx)(`span`,{className:`skill-row-meta`,children:` · Always on`})]}),(0,H.jsx)(`span`,{className:`skill-row-desc`,children:t.description})]}),!t.always_on&&(0,H.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>e(t.name),"aria-label":`Use ${t.name} in a new chat`,children:`Use`})]},t.name))}),Object.keys(r).length>0&&(0,H.jsxs)(`div`,{className:`settings-card`,role:`alert`,children:[(0,H.jsx)(`span`,{className:`settings-label`,children:`Skipped, could not be read`}),(0,H.jsx)(`ul`,{className:`grant-list`,children:Object.entries(r).map(([e,t])=>(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`code`,{children:e}),` — `,t]},e))})]})]})}var oE=d();async function sE(e,t,n){let r=`${oE}${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.headers.get(`content-type`)||``).includes(`application/json`))return o.json()}function cE(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 lE(){return sE(`GET`,`/memory/stats`)}function uE(e=30){return sE(`GET`,`/memory/activity?days=${e}`)}function dE(e={}){return sE(`GET`,`/memory/knowledge${cE(e)}`)}function fE(e){return sE(`POST`,`/memory/knowledge`,e)}function pE(e,t){return sE(`PUT`,`/memory/knowledge/${encodeURIComponent(e)}`,t)}function mE(e){return sE(`DELETE`,`/memory/knowledge/${encodeURIComponent(e)}`)}function hE(){return sE(`GET`,`/memory/entities`)}function gE(){return sE(`GET`,`/memory/tools`)}function _E(e=20){return sE(`GET`,`/memory/conversations?limit=${e}`)}function vE(e,t=20){return sE(`GET`,`/memory/conversations/search?query=${encodeURIComponent(e)}&limit=${t}`)}function yE(e){return sE(`GET`,`/memory/conversations/${encodeURIComponent(e)}`)}function bE(e=7){return sE(`GET`,`/memory/upcoming?days=${e}`)}function xE(){return sE(`GET`,`/memory/embedding-coverage`)}function SE(){return sE(`POST`,`/memory/consolidate`)}function CE(){return sE(`POST`,`/memory/rebuild-embeddings`)}function wE(){return sE(`POST`,`/memory/reconcile`)}function TE(){return sE(`POST`,`/memory/rebuild-fts`)}function EE(){return sE(`POST`,`/memory/refresh-system-context`)}function DE(){return new EventSource(`${oE}/memory/stream-discovery`)}function OE(e){return new EventSource(`${oE}/memory/stream-inference?include_browser=${e}`)}function kE(e){return sE(`POST`,`/memory/commit-discovery`,{items:e})}function AE(e){return sE(`POST`,`/memory/commit-inference`,{insights:e})}function jE(){return sE(`GET`,`/memory/settings`)}function ME(e){return sE(`PUT`,`/memory/settings`,e)}function NE(){return sE(`DELETE`,`/memory/all`)}function PE(){return sE(`POST`,`/memory/reinitialize`)}function FE(){return sE(`GET`,`/goals/stats`)}function IE(e={}){return sE(`GET`,`/goals${cE(e)}`)}function LE(e){return sE(`POST`,`/goals`,e)}function RE(e){return sE(`PUT`,`/goals/${encodeURIComponent(e)}/approve`)}function zE(e){return sE(`PUT`,`/goals/${encodeURIComponent(e)}/reject`)}function BE(e){return sE(`PUT`,`/goals/${encodeURIComponent(e)}/cancel`)}function VE(e){return sE(`DELETE`,`/goals/${encodeURIComponent(e)}`)}function HE(){let e=V(e=>e.setShowMemoryDashboard),t=V(e=>e.closeSettings),[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(!1);(0,B.useEffect)(()=>{jE().then(r).catch(e=>a(e instanceof Error?e.message:String(e)))},[]);let c=(0,B.useCallback)(async()=>{if(n){s(!0),a(null);try{r(await ME({memory_enabled:!n.memory_enabled}))}catch(e){a(e instanceof Error?e.message:String(e))}finally{s(!1)}}},[n]);return(0,H.jsxs)(`div`,{className:`settings-pane`,children:[(0,H.jsx)(`h2`,{className:`settings-pane-title`,children:`Memory`}),(0,H.jsx)(`p`,{className:`settings-pane-lede`,children:`GAIA remembers facts, preferences and past conversations across chats, on this PC only. Private chats (the eye icon in a chat) are never remembered.`}),(0,H.jsxs)(`label`,{className:`setting-row`,children:[(0,H.jsx)(`span`,{children:`Remember across chats`}),(0,H.jsxs)(`span`,{className:`toggle-switch`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:!!n?.memory_enabled,onChange:()=>void c(),disabled:!n||o,"aria-label":`Remember across chats`}),(0,H.jsx)(`span`,{className:`toggle-track`})]})]}),i&&(0,H.jsx)(`p`,{className:`settings-error`,role:`alert`,children:i}),(0,H.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{t(),e(!0)},children:`Open the memory dashboard`}),(0,H.jsx)(`p`,{className:`settings-hint`,children:`Search, edit and forget what GAIA remembers.`})]})}var UE=`Keep for: enter a whole number of days from 1 to 365.`,WE=`Use at most: enter a whole number of MB from 10 to 100,000.`;function GE(e,t,n){if(!/^\d+$/.test(e.trim()))return!1;let r=Number(e);return r>=t&&r<=n}function KE(e){return e<1048576?`${Math.ceil(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function qE(){let[e,t]=(0,B.useState)(null),[n,r]=(0,B.useState)(``),[i,a]=(0,B.useState)(``),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(!1);(0,B.useEffect)(()=>{xo().then(e=>{t(e),r(String(e.retention_days)),a(String(e.max_mb))},e=>s({ok:!1,text:`Could not read undo history settings: ${e instanceof Error?e.message:e}`}))},[]);let[u,d]=(0,B.useState)({days:!1,mb:!1}),f=!GE(n,1,365)||u.days,p=!GE(i,10,1e5)||u.mb,m=e!==null&&(n!==String(e.retention_days)||i!==String(e.max_mb)),h=async()=>{if(!(f||p)){l(!0),s(null);try{let e=await So(Number(n),Number(i));t(e),s({ok:!0,text:`Saved. Older undo history beyond these limits was removed.`})}catch(e){let t=e instanceof Ci&&e.httpStatus===422?e.fields:[],n=t.includes(`retention_days`),r=t.includes(`max_mb`);n||r?(d({days:n,mb:r}),s({ok:!1,text:`Not saved. Fix the limit marked above.`})):s({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{l(!1)}}};return(0,H.jsxs)(`div`,{className:`settings-field`,"aria-label":`Undo history`,children:[(0,H.jsx)(`span`,{className:`settings-label`,children:`Undo history`}),(0,H.jsx)(`p`,{className:`settings-hint`,children:`Before GAIA changes a file it keeps a copy, so you can undo a turn. Copies older than the time limit, or past the space limit (oldest first), are deleted. The space limit never deletes the latest turn.`}),e&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`setting-row`,children:[(0,H.jsx)(`label`,{htmlFor:`undo-days`,children:`Keep for (days)`}),(0,H.jsx)(`input`,{id:`undo-days`,type:`number`,className:`model-input undo-history-input`,min:1,max:365,value:n,"aria-invalid":f,"aria-describedby":f?`undo-days-error`:void 0,onChange:e=>{r(e.target.value),d(e=>({...e,days:!1}))}})]}),f&&(0,H.jsx)(`p`,{id:`undo-days-error`,className:`settings-error`,children:UE}),(0,H.jsxs)(`div`,{className:`setting-row`,children:[(0,H.jsx)(`label`,{htmlFor:`undo-mb`,children:`Use at most (MB)`}),(0,H.jsx)(`input`,{id:`undo-mb`,type:`number`,className:`model-input undo-history-input`,min:10,max:1e5,value:i,"aria-invalid":p,"aria-describedby":p?`undo-mb-error`:void 0,onChange:e=>{a(e.target.value),d(e=>({...e,mb:!1}))}})]}),p&&(0,H.jsx)(`p`,{id:`undo-mb-error`,className:`settings-error`,children:WE}),(0,H.jsxs)(`div`,{className:`setting-row setting-row-path`,children:[(0,H.jsx)(`span`,{children:`In use`}),(0,H.jsxs)(`span`,{children:[KE(e.used_bytes),` for `,e.turns,` turn`,e.turns===1?``:`s`,` `,`in `,(0,H.jsx)(`code`,{className:`setting-path`,children:e.path})]})]}),(0,H.jsx)(`button`,{type:`button`,className:`btn-model-save`,onClick:()=>void h(),disabled:!m||c||f||p,children:c?`Saving…`:`Save`})]}),o&&(0,H.jsx)(`p`,{className:o.ok?`settings-ok`:`settings-error`,role:o.ok?`status`:`alert`,children:o.text})]})}function JE(){let e=V(e=>e.sessions),t=V(e=>e.removeSession),n=Yo(),r=V(e=>e.systemStatus?.data_dir),[i,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(null),c=(0,B.useRef)(null);(0,B.useEffect)(()=>()=>{c.current&&clearTimeout(c.current)},[]);let l=(0,B.useCallback)(async()=>{if(!i){a(!0),c.current=setTimeout(()=>a(!1),4e3);return}a(!1);let n=[];for(let r of e)try{await va(r.id),t(r.id)}catch(e){n.push(`${r.title}: ${e instanceof Error?e.message:e}`)}s(n.length?{ok:!1,text:`Could not delete ${n.length} chat(s): ${n.join(`; `)}`}:{ok:!0,text:`All chats deleted.`})},[i,t,e]);return(0,H.jsxs)(`div`,{className:`settings-pane`,children:[(0,H.jsx)(`h2`,{className:`settings-pane-title`,children:`Privacy`}),(0,H.jsxs)(`p`,{className:`settings-pane-lede`,children:[`Chats, documents and memory stay on this PC. `,n?.remote?`Right now answers come from ${n.label}, so each message and the chat history are sent there.`:n?`Right now answers are generated on this PC too.`:`GAIA can't tell right now whether answers are generated on this PC or by a cloud provider.`]}),r&&(0,H.jsxs)(`div`,{className:`setting-row`,children:[(0,H.jsx)(`span`,{children:`Data folder`}),(0,H.jsx)(`code`,{className:`setting-path`,children:r})]}),(0,H.jsx)(qE,{}),(0,H.jsx)(`div`,{className:`danger-divider`}),(0,H.jsx)(`p`,{className:`danger-warning`,children:`Deletes every chat and its messages. Documents and memory are kept.`}),(0,H.jsx)(`button`,{type:`button`,className:`btn-danger`,onClick:()=>void l(),disabled:e.length===0,children:i?`Click again to delete all chats`:`Delete all chats`}),o&&(0,H.jsx)(`p`,{className:o.ok?`settings-ok`:`settings-error`,role:o.ok?`status`:`alert`,children:o.text})]})}var YE=[{id:`needs_approval`,label:`Needs your approval`},{id:`question`,label:`Has a question`},{id:`finished`,label:`Finished`}],XE=[{value:`banner`,label:`Banner`},{value:`badge`,label:`Badge`},{value:`off`,label:`Off`}],ZE=[0,10,20,30,50];function QE(){return typeof Notification>`u`?`unsupported`:Notification.permission}function $E(){let e=Ms(),t=!!window.gaiaAPI,[n,r]=(0,B.useState)(QE),i=Object.values(e.modes).includes(`banner`);return(0,H.jsxs)(`div`,{className:`settings-pane`,children:[(0,H.jsx)(`h2`,{className:`settings-pane-title`,children:`Notifications`}),(0,H.jsx)(`p`,{className:`settings-pane-lede`,children:`When a chat you aren't looking at needs you or finishes. A banner also counts on the badge.`}),YE.map(t=>(0,H.jsxs)(`div`,{className:`setting-row`,children:[(0,H.jsx)(`span`,{id:`alert-${t.id}`,children:t.label}),(0,H.jsx)(`div`,{className:`segmented`,role:`radiogroup`,"aria-labelledby":`alert-${t.id}`,children:XE.map(n=>(0,H.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e.modes[t.id]===n.value,className:e.modes[t.id]===n.value?`is-active`:``,onClick:()=>e.setMode(t.id,n.value),children:n.label},n.value))})]},t.id)),!t&&i&&n!==`granted`&&(n==="default"?(0,H.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{Notification.requestPermission().then(r).catch(e=>{console.error(`[alerts] Notification permission request failed`,e),r(QE())})},children:`Allow banners in this browser`}):(0,H.jsx)(`p`,{className:`settings-error`,role:`alert`,children:n===`unsupported`?`This browser can't show banners; alerts appear in the chat list only.`:`This browser blocks banners from GAIA. Allow notifications for this site in the browser’s site settings.`})),(0,H.jsxs)(`label`,{className:`setting-row`,children:[(0,H.jsx)(`span`,{children:`Play a sound`}),(0,H.jsxs)(`span`,{className:`toggle-switch`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:e.sound,onChange:()=>e.update({sound:!e.sound}),"aria-label":`Play a sound`}),(0,H.jsx)(`span`,{className:`toggle-track`})]})]}),t&&(0,H.jsxs)(`label`,{className:`setting-row`,children:[(0,H.jsx)(`span`,{children:`Flash the taskbar when GAIA isn't focused`}),(0,H.jsxs)(`span`,{className:`toggle-switch`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:e.flash,onChange:()=>e.update({flash:!e.flash}),"aria-label":`Flash the taskbar when GAIA isn't focused`}),(0,H.jsx)(`span`,{className:`toggle-track`})]})]}),(0,H.jsx)(`h3`,{className:`settings-label`,children:`Keep awake`}),t?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`label`,{className:`setting-row`,children:[(0,H.jsx)(`span`,{children:`Keep the PC awake while GAIA works`}),(0,H.jsxs)(`span`,{className:`toggle-switch`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:e.keepAwake,onChange:()=>e.update({keepAwake:!e.keepAwake}),"aria-label":`Keep the PC awake while GAIA works`}),(0,H.jsx)(`span`,{className:`toggle-track`})]})]}),(0,H.jsxs)(`div`,{className:`setting-row`,children:[(0,H.jsx)(`label`,{htmlFor:`battery-floor`,children:`On battery, let it sleep below`}),(0,H.jsx)(`select`,{id:`battery-floor`,value:e.batteryFloor,disabled:!e.keepAwake,onChange:t=>e.update({batteryFloor:Number(t.target.value)}),children:ZE.map(e=>(0,H.jsx)(`option`,{value:e,children:e===0?`Never`:`${e}%`},e))})]}),(0,H.jsx)(`p`,{className:`settings-hint`,children:`The screen can still turn off; only sleep is held off.`})]}):(0,H.jsx)(`p`,{className:`settings-hint`,children:`Keep-awake needs the GAIA desktop app.`})]})}var eD=`modulepreload`,tD=function(e,t){return new URL(e,t).href},nD={},rD=function(e){return e.pathname.endsWith(`.css`)},iD=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},aD=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=tD(t,n);let r=s(t),i=rD(r);return iD(nD,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`:eD,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)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).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)})},oD=(0,B.lazy)(()=>aD(()=>import(`./ConnectorsPane-DrjImgCN.js`).then(e=>({default:e.ConnectorsPane})),__vite__mapDeps([0,1,2,3]),import.meta.url)),sD=(0,B.lazy)(()=>aD(()=>import(`./AdvancedSettings-C67TQFIS.js`).then(e=>({default:e.AdvancedSettings})),__vite__mapDeps([4,1,2,5]),import.meta.url)),cD=[{id:`general`,label:`General`},{id:`model`,label:`Model`},{id:`permissions`,label:`Permissions`},{id:`skills`,label:`Skills`},{id:`connectors`,label:`Connectors`},{id:`memory`,label:`Memory`},{id:`notifications`,label:`Notifications`},{id:`privacy`,label:`Privacy`},{id:`advanced`,label:`Advanced`}];function lD({onUseSkill:e}){let t=V(e=>e.settingsSection),n=V(e=>e.openSettings),r=V(e=>e.closeSettings),i=(0,B.useRef)(null),a=(0,B.useRef)(null),o=t!==null;if(c(o,r),kb(i,o),(0,B.useEffect)(()=>{if(o)return a.current=document.activeElement,()=>{a.current?.focus?.()}},[o,r]),(0,B.useEffect)(()=>{o&&i.current?.querySelector(`.settings-nav-item.is-active`)?.focus()},[o]),!t)return null;let s=(()=>{switch(t){case`general`:return(0,H.jsx)(XT,{});case`model`:return(0,H.jsx)(rE,{});case`permissions`:return(0,H.jsx)(iE,{});case`skills`:return(0,H.jsx)(aE,{onUseSkill:t=>{r(),e(t)}});case`connectors`:return(0,H.jsx)(oD,{});case`memory`:return(0,H.jsx)(HE,{});case`notifications`:return(0,H.jsx)($E,{});case`privacy`:return(0,H.jsx)(JE,{});case`advanced`:return(0,H.jsx)(sD,{})}})();return(0,H.jsx)(`div`,{className:`settings-overlay`,onMouseDown:e=>{e.target===e.currentTarget&&r()},children:(0,H.jsxs)(`div`,{ref:i,className:`settings-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Settings`,children:[(0,H.jsxs)(`nav`,{className:`settings-nav`,"aria-label":`Settings sections`,children:[(0,H.jsx)(`h1`,{className:`settings-nav-title`,children:`Settings`}),cD.map(e=>(0,H.jsx)(`button`,{type:`button`,"data-section":e.id,className:`settings-nav-item${t===e.id?` is-active`:``}`,"aria-current":t===e.id?`page`:void 0,onClick:t=>{t.currentTarget.focus(),n(e.id)},children:e.label},e.id))]}),(0,H.jsxs)(`div`,{className:`settings-body`,children:[(0,H.jsx)(`button`,{type:`button`,className:`settings-close`,onClick:r,"aria-label":`Close settings`,children:(0,H.jsx)(Nn,{size:18})}),(0,H.jsx)(B.Suspense,{fallback:(0,H.jsxs)(`p`,{className:`settings-hint`,children:[(0,H.jsx)(z,{size:13,className:`spin`}),` Loading…`]}),children:s})]})]})})}function uD(e,t){let[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(!1),o=(0,B.useRef)(null),s=(0,B.useRef)(null),c=(0,B.useRef)(null),l=(0,B.useCallback)(()=>{o.current&&=(clearTimeout(o.current),null),s.current&&=(clearTimeout(s.current),null),c.current&&=(clearInterval(c.current),null)},[]);(0,B.useEffect)(()=>l,[l]);let d=(0,B.useCallback)((e,t)=>{c.current&&clearInterval(c.current),c.current=setInterval(async()=>{try{let n=await Ai();t===`load`?n.model_loaded?.toLowerCase()===e.toLowerCase()&&(r(!1),o.current&&=(clearTimeout(o.current),null),c.current&&=(clearInterval(c.current),null)):(n.model_downloaded===!0||n.model_loaded?.toLowerCase()===e.toLowerCase())&&(a(!1),s.current&&=(clearTimeout(s.current),null),c.current&&=(clearInterval(c.current),null))}catch{}},Yw)},[]),f=e??`Gemma-4-E4B-it-GGUF`;return{isLoadingModel:n,isDownloadingModel:i,loadModel:(0,B.useCallback)(async(e,t)=>{let n=e??f,i=t??32768;r(!0);try{if(!await Ri(n,i)){r(!1);return}u.system.info(`Load model triggered: ${n} (ctx=${i})`),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>r(!1),qw),d(n,`load`)}catch(e){u.system.error(`Failed to trigger model load`,e),r(!1)}},[f,t,d]),downloadModel:(0,B.useCallback)(async(e=!1,t)=>{let n=t??f;a(!0);try{await zi(n,e),u.system.info(`Download model triggered: ${n} (force=${e})`),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>a(!1),Jw),d(n,`download`)}catch(e){u.system.error(`Failed to trigger model download`,e),a(!1)}},[f,d])}}var dD=5e3,fD=2e3,pD=3e4,mD=6e4;function hD(e){return e.lemonade_running?`up`:e.lemonade_error?`unresponsive`:`down`}function gD(e){return e.kind===`slow`||e.kind===`error`||e.kind===`ok`&&hD(e.status)===`unresponsive`}function _D(e){let t=e.kind===`ok`?e.status.download_progress?.state:void 0;return t===`downloading`||t===`starting`}function vD(e){let t=null,n=0,r=!1,i=null,a=0,o=null,s=async()=>{let e={controller:new AbortController,cancelled:!1};o=e;let{controller:t}=e,n=setTimeout(()=>t.abort(),mD);try{return{kind:`ok`,status:await Ai(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),o===e&&(o=null)}},c=()=>{if(t)return t;let i=s().then(t=>{if(t!==null){n=gD(t)?n+1:0,r=_D(t);try{e(t)}catch(e){u.system.error(`Could not apply the system status; the next poll will try again`,e)}}}).finally(()=>{t===i&&(t=null)});return t=i,i},l=()=>Math.min((r?fD:dD)*2**n,pD),d=e=>{c().finally(()=>{e===a&&(i=setTimeout(()=>d(e),l()))})};return{check:c,start:()=>{let e=++a;return d(e),()=>{e===a&&(a++,i&&clearTimeout(i),i=null,o&&(o.cancelled=!0,o.controller.abort(),o=null,t=null))}}}}function yD({onRetry:e,label:t}){let[n,r]=(0,B.useState)(!1);return(0,H.jsx)(`button`,{className:`connection-banner__retry`,onClick:()=>{r(!0),Promise.resolve(e()).finally(()=>r(!1))},disabled:n,children:n?`Checking…`:t})}function bD({onRetry:e,backendSlow:t=!1,backendError:n=null}){let{backendConnected:r,systemStatus:i,currentSessionId:a,messages:o}=V(),[s,c]=(0,B.useState)(!1),l=!!a&&o.length>0,u=i?.default_model_name??`Gemma-4-E4B-it-GGUF`,{isDownloadingModel:d,downloadModel:f}=uD(u),p=(0,B.useRef)(i?.lemonade_running),m=(0,B.useRef)(i?.model_downloaded),h=(0,B.useRef)(i?.context_size_sufficient),g=(0,B.useRef)(i?.expected_model_loaded);(0,B.useEffect)(()=>{if(l)return;let e=i?.lemonade_running,t=i?.model_downloaded,n=i?.context_size_sufficient,r=i?.expected_model_loaded,a=!1;p.current!==e&&(p.current=e,e===!1&&(a=!0)),m.current!==t&&(m.current=t,t===!1&&(a=!0)),h.current!==n&&(h.current=n,n===!1&&(a=!0)),g.current!==r&&(g.current=r,r===!1&&(a=!0)),a&&c(!1)},[i,l]);let _=i?.download_progress??null,v=_?.model_name||u;if(d||_?.state===`downloading`||_?.state===`starting`||_?.state===`error`){let e=_?.total_bytes?`${(_.total_bytes/1e9).toFixed(1)} GB`:`large download`,t=_?.state===`error`;return(0,H.jsxs)(`div`,{className:`connection-banner ${t?`connection-banner--error`:`connection-banner--warning`}`,role:t?`alert`:`status`,children:[(0,H.jsx)(`div`,{className:`connection-banner__icon`,children:t?(0,H.jsx)(Cn,{size:16}):(0,H.jsx)(Ne,{size:16})}),(0,H.jsx)(`div`,{className:`connection-banner__text`,children:t?(0,H.jsxs)(H.Fragment,{children:[`Download of `,(0,H.jsx)(`strong`,{children:v}),` failed.`,` `,_?.message&&(0,H.jsx)(`span`,{className:`connection-banner__hint`,children:_.message})]}):(0,H.jsxs)(H.Fragment,{children:[`Downloading `,(0,H.jsx)(`strong`,{children:v}),` (`,e,`).`,_?.state===`downloading`&&_.file&&(0,H.jsxs)(H.Fragment,{children:[` `,(0,H.jsxs)(`span`,{className:`connection-banner__hint`,children:[`File `,_.file_index,` / `,_.total_files,`: `,(0,H.jsx)(`code`,{children:_.file})]})]})]})}),t?(0,H.jsx)(`button`,{className:`connection-banner__retry`,onClick:()=>f(!1,v),children:`Retry`}):(0,H.jsx)(`span`,{className:`connection-banner__loading connection-banner__progress`,children:_&&_.state===`downloading`&&_.total_bytes>0?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`connection-banner__progress-bar`,role:`progressbar`,"aria-valuenow":_.percent,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`Download progress`,children:(0,H.jsx)(`span`,{className:`connection-banner__progress-fill`,style:{width:`${_.percent}%`}})}),(0,H.jsxs)(`span`,{className:`connection-banner__progress-label`,children:[_.percent,`% ·`,` `,(_.downloaded_bytes/1e9).toFixed(2),` /`,` `,(_.total_bytes/1e9).toFixed(2),` GB`]})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(z,{size:13,className:`connection-banner__spinner`}),_?.state===`starting`?`Starting download…`:`Downloading…`]})}),t&&(0,H.jsx)(`button`,{className:`connection-banner__dismiss`,onClick:()=>c(!0),"aria-label":`Dismiss`,children:(0,H.jsx)(Nn,{size:14})})]})}if(i?.init_state===`initializing`){let e=i.init_tasks?.find(e=>e.status===`running`)?.name||`Preparing AI system`;return(0,H.jsxs)(`div`,{className:`connection-banner connection-banner--init`,role:`status`,children:[(0,H.jsx)(`div`,{className:`connection-banner__icon`,children:(0,H.jsx)(z,{size:16,className:`connection-banner__spinner`})}),(0,H.jsxs)(`div`,{className:`connection-banner__text`,children:[e,(0,H.jsxs)(`span`,{className:`thinking-dots`,children:[(0,H.jsx)(`span`,{children:`.`}),(0,H.jsx)(`span`,{children:`.`}),(0,H.jsx)(`span`,{children:`.`})]})]})]})}if(s||l)return null;if(!r)return(0,H.jsxs)(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[(0,H.jsx)(`div`,{className:`connection-banner__icon`,children:(0,H.jsx)(kn,{size:16})}),(0,H.jsxs)(`div`,{className:`connection-banner__text`,children:[`Lost the connection to GAIA.`,` `,(0,H.jsx)(`span`,{className:`connection-banner__hint`,children:`Check that GAIA is still running, then retry.`})]}),e&&(0,H.jsx)(yD,{onRetry:e,label:`Retry`})]});if(n)return(0,H.jsxs)(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[(0,H.jsx)(`div`,{className:`connection-banner__icon`,children:(0,H.jsx)(Cn,{size:16})}),(0,H.jsxs)(`div`,{className:`connection-banner__text`,children:[`GAIA's backend answered with an error (`,n,`).`,` `,(0,H.jsx)(`span`,{className:`connection-banner__hint`,children:`It may be overloaded. GAIA keeps checking; if it lasts, restart GAIA.`})]}),e&&(0,H.jsx)(yD,{onRetry:e,label:`Check again`})]});if(t)return(0,H.jsxs)(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[(0,H.jsx)(`div`,{className:`connection-banner__icon`,children:(0,H.jsx)(Cn,{size:16})}),(0,H.jsxs)(`div`,{className:`connection-banner__text`,children:[`GAIA is slow to answer.`,` `,(0,H.jsx)(`span`,{className:`connection-banner__hint`,children:`It may be busy with another chat or app. GAIA keeps checking.`})]}),e&&(0,H.jsx)(yD,{onRetry:e,label:`Check again`})]});if(i?.config_error)return(0,H.jsxs)(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[(0,H.jsx)(`div`,{className:`connection-banner__icon`,children:(0,H.jsx)(Cn,{size:16})}),(0,H.jsxs)(`div`,{className:`connection-banner__text`,children:[`GAIA settings could not be loaded.`,` `,(0,H.jsx)(`span`,{className:`connection-banner__hint`,children:i.config_error})]}),e&&(0,H.jsx)(yD,{onRetry:e,label:`Check again`})]});if(i&&!i.lemonade_running){let t=hD(i)===`unresponsive`;return(0,H.jsxs)(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[(0,H.jsx)(`div`,{className:`connection-banner__icon`,children:(0,H.jsx)(Cn,{size:16})}),(0,H.jsxs)(`div`,{className:`connection-banner__text`,children:[t?`The model server is not answering (${i.lemonade_error}). It may be busy with another app or loading a model.`:`The model server stopped responding.`,` `,i.start_command?(0,H.jsxs)(`span`,{className:`connection-banner__hint`,children:[t?`If it stays this way, restart it: `:`To start it by hand, run `,(0,H.jsx)(`code`,{children:i.start_command})]}):i.start_instruction&&(0,H.jsx)(`span`,{className:`connection-banner__hint`,children:i.start_instruction})]}),e&&(0,H.jsx)(yD,{onRetry:e,label:`Check again`}),(0,H.jsx)(`button`,{className:`connection-banner__dismiss`,onClick:()=>c(!0),"aria-label":`Dismiss`,children:(0,H.jsx)(Nn,{size:14})})]})}if(i&&i.lemonade_running&&i.model_loaded&&i.context_size_sufficient===!1){let t=i.model_context_size??0;return(0,H.jsxs)(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[(0,H.jsx)(`div`,{className:`connection-banner__icon`,children:(0,H.jsx)(yt,{size:16})}),(0,H.jsxs)(`div`,{className:`connection-banner__text`,children:[`LLM context window is too small (`,t.toLocaleString(),` tokens;`,` `,Gw.toLocaleString(),` required).`,` `,(0,H.jsx)(`span`,{className:`connection-banner__hint`,children:`Reload it with a larger context in Settings → Advanced.`})]}),e&&(0,H.jsx)(yD,{onRetry:e,label:`Check again`}),(0,H.jsx)(`button`,{className:`connection-banner__dismiss`,onClick:()=>c(!0),"aria-label":`Dismiss`,children:(0,H.jsx)(Nn,{size:14})})]})}return null}var xD={status:`idle`,version:null,progress:0,releaseNotes:null,error:null,currentVersion:null,pinnedVersion:null};function SD(){let[e,t]=(0,B.useState)({...xD});return(0,B.useEffect)(()=>{let e=window.gaiaUpdater;if(!e)return;let n=!0;e.getStatus().then(e=>{n&&e&&t(e)}).catch(()=>{});let r=e.onStatusChange(e=>{n&&e&&t(e)});return()=>{n=!1;try{r()}catch{}}},[]),e}function CD(){let e=SD(),[t,n]=(0,B.useState)(!1),r=(0,B.useCallback)(()=>{window.gaiaUpdater?.check().catch(()=>{})},[]);if(t||e.status===`idle`||e.status===`checking`||e.status===`disabled`)return null;if(e.status===`downloading`){let t=Math.max(0,Math.min(100,e.progress));return(0,H.jsxs)(`div`,{className:`update-chip update-chip--downloading`,role:`status`,"aria-live":`polite`,title:`Downloading update${e.version?` ${e.version}`:``}…`,children:[(0,H.jsx)(Ne,{size:13,className:`update-chip__icon`}),(0,H.jsxs)(`span`,{className:`update-chip__label`,children:[`Downloading update… `,t,`%`]})]})}return e.status===`available`?(0,H.jsxs)(`div`,{className:`update-chip update-chip--available`,role:`status`,title:e.releaseNotes||`A new version is available.`,children:[(0,H.jsx)(Ne,{size:13,className:`update-chip__icon`}),(0,H.jsxs)(`span`,{className:`update-chip__label`,children:[`Update available`,e.version?`: ${e.version}`:``]}),(0,H.jsx)(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>n(!0),"aria-label":`Dismiss update notification`,children:(0,H.jsx)(Nn,{size:11})})]}):e.status===`downloaded`?(0,H.jsxs)(`div`,{className:`update-chip update-chip--ready`,role:`status`,"aria-live":`polite`,children:[(0,H.jsx)(Xt,{size:13,className:`update-chip__icon`}),(0,H.jsx)(`button`,{type:`button`,className:`update-chip__action`,onClick:r,title:`Click to restart and apply the update`,children:`Update ready — restart to apply`})]}):e.status===`error`?(0,H.jsxs)(`div`,{className:`update-chip update-chip--error`,role:`status`,title:e.error||`Update check failed.`,children:[(0,H.jsx)(Cn,{size:13,className:`update-chip__icon`}),(0,H.jsx)(`span`,{className:`update-chip__label`,children:`Update check failed`}),(0,H.jsx)(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>n(!0),"aria-label":`Dismiss update error`,children:(0,H.jsx)(Nn,{size:11})})]}):null}var wD={permission_request:{icon:(0,H.jsx)(an,{size:16}),colorClass:`notif-type-permission`,label:`Permission`},policy_alert:{icon:(0,H.jsx)(an,{size:16}),colorClass:`notif-type-policy`,label:`Policy`},security_alert:{icon:(0,H.jsx)(Cn,{size:16}),colorClass:`notif-type-security`,label:`Security`},status_change:{icon:(0,H.jsx)(he,{size:16}),colorClass:`notif-type-status`,label:`Status`},info:{icon:(0,H.jsx)(ht,{size:16}),colorClass:`notif-type-info`,label:`Info`},error:{icon:(0,H.jsx)(pe,{size:16}),colorClass:`notif-type-error`,label:`Error`}};function TD(e){let t=Date.now()-e,n=Math.floor(t/1e3);if(n<60)return`just now`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function ED({onClose:e}){let t=K(Hn(Cs)),n=K(Ss),r=K(e=>e.markRead),i=K(e=>e.markAllRead),a=K(e=>e.clearAll),o=K(e=>e.dismiss),s=K(e=>e.respondToPermission),l=K(e=>e.typeFilter),u=K(e=>e.setTypeFilter),d=(0,B.useCallback)(e=>{r(e)},[r]),f=(0,B.useCallback)(e=>{s(e.id,`allow`).catch(e=>console.error(`[NotificationCenter] allow failed:`,e))},[s]),p=(0,B.useCallback)(e=>{s(e.id,`deny`).catch(e=>console.error(`[NotificationCenter] deny failed:`,e))},[s]);return c(!0,e),(0,H.jsxs)(`div`,{className:`notification-center`,role:`dialog`,"aria-label":`Notification Center`,children:[(0,H.jsxs)(`div`,{className:`notification-center-header`,children:[(0,H.jsxs)(`div`,{className:`notification-center-title-row`,children:[(0,H.jsx)(`h2`,{className:`notification-center-title`,children:`Notifications`}),n>0&&(0,H.jsx)(`span`,{className:`notification-center-badge`,children:n})]}),(0,H.jsx)(`button`,{className:`btn-icon notification-center-close`,onClick:e,"aria-label":`Close notification center`,children:(0,H.jsx)(Nn,{size:18})})]}),(0,H.jsx)(`div`,{className:`notification-filter-bar`,role:`tablist`,"aria-label":`Filter notifications`,children:[{key:null,label:`All`},{key:`permission_request`,label:`Permissions`},{key:`policy_alert`,label:`Policy`},{key:`error`,label:`Errors`},{key:`security_alert`,label:`Security`},{key:`status_change`,label:`Status`},{key:`info`,label:`Info`}].map(e=>(0,H.jsx)(`button`,{role:`tab`,"aria-selected":l===e.key,className:`notification-filter-tab ${l===e.key?`active`:``}`,onClick:()=>u(e.key),children:e.label},e.key??`all`))}),(0,H.jsx)(`div`,{className:`notification-list`,children:t.length===0?(0,H.jsxs)(`div`,{className:`notification-empty`,children:[(0,H.jsx)(O,{size:40,strokeWidth:1.2}),(0,H.jsx)(`span`,{children:`No notifications`})]}):t.map(e=>{let t=wD[e.type];return(0,H.jsxs)(`div`,{className:`notification-item ${e.read?``:`unread`} ${t.colorClass}`,id:e.type===`policy_alert`&&e.receiptId?`policy-receipt-${encodeURIComponent(e.receiptId)}`:void 0,onClick:()=>d(e.id),role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&d(e.id)},children:[!e.read&&(0,H.jsx)(`span`,{className:`notification-unread-dot`}),(0,H.jsx)(`span`,{className:`notification-icon`,children:t.icon}),(0,H.jsxs)(`div`,{className:`notification-content`,children:[(0,H.jsxs)(`div`,{className:`notification-content-header`,children:[(0,H.jsx)(`span`,{className:`notification-agent`,children:e.agentName}),(0,H.jsx)(`span`,{className:`notification-time`,children:TD(e.timestamp)})]}),e.title&&(0,H.jsx)(`span`,{className:`notification-title`,children:e.title}),(0,H.jsx)(`span`,{className:`notification-message`,children:e.message}),e.type===`permission_request`&&e.tool&&e.tool!==`allow_path_access`&&(0,H.jsxs)(`span`,{className:`notification-tool`,children:[`Tool: `,(0,H.jsx)(`code`,{children:e.tool})]}),e.type===`policy_alert`&&(0,H.jsxs)(`div`,{className:`notification-policy-details`,children:[e.tool&&(0,H.jsxs)(`span`,{className:`notification-tool`,children:[`Tool: `,(0,H.jsx)(`code`,{children:e.tool})]}),e.reason&&(0,H.jsxs)(`span`,{className:`notification-policy-reason`,children:[`Reason: `,e.reason]}),e.ruleIds&&e.ruleIds.length>0&&(0,H.jsxs)(`span`,{className:`notification-tool`,children:[`Rules: `,(0,H.jsx)(`code`,{children:e.ruleIds.join(`, `)})]}),e.policyVersion&&(0,H.jsxs)(`span`,{className:`notification-tool`,children:[`Policy: `,(0,H.jsx)(`code`,{children:e.policyVersion})]}),(0,H.jsxs)(`span`,{className:`notification-tool`,children:[`Receipt:`,` `,e.receiptId?(0,H.jsx)(`code`,{children:e.receiptId}):(0,H.jsx)(`em`,{children:`Receipt unavailable`})]})]}),e.type===`permission_request`&&!e.response&&(0,H.jsxs)(`div`,{className:`notification-actions`,children:[(0,H.jsxs)(`button`,{className:`notification-action-btn notification-action-allow`,onClick:t=>{t.stopPropagation(),f(e)},children:[(0,H.jsx)(ae,{size:14}),`Approve`]}),(0,H.jsxs)(`button`,{className:`notification-action-btn notification-action-deny`,onClick:t=>{t.stopPropagation(),p(e)},children:[(0,H.jsx)(Nn,{size:14}),`Deny`]})]}),e.type===`permission_request`&&e.response&&(0,H.jsx)(`span`,{className:`notification-response-badge ${e.response===`allow`?`response-allow`:`response-deny`}`,children:e.response===`allow`?`Approved`:`Denied`})]}),(0,H.jsx)(`button`,{className:`notification-dismiss`,onClick:t=>{t.stopPropagation(),o(e.id)},"aria-label":`Dismiss notification`,children:(0,H.jsx)(Nn,{size:14})})]},e.id)})}),t.length>0&&(0,H.jsxs)(`div`,{className:`notification-center-footer`,children:[(0,H.jsxs)(`button`,{className:`notification-footer-btn`,onClick:i,disabled:n===0,children:[(0,H.jsx)(ae,{size:14}),`Mark All Read`]}),(0,H.jsxs)(`button`,{className:`notification-footer-btn notification-footer-clear`,onClick:a,children:[(0,H.jsx)(xn,{size:14}),`Clear`]})]})]})}var DD=1500,OD=e=>new Promise(t=>setTimeout(t,e));async function kD({onProgress:e,isCancelled:t=()=>!1,pollMs:n=DD}={}){try{await Vi(Bw)}catch(e){if(e?.httpStatus!==409)throw e;let t=await Hi(Bw).catch(()=>null);if(!t||t.status===`completed`||t.status===`failed`)throw e}for(;!t();){let t=await Hi(Bw);if(e?.(t),t.status===`completed`)return;if(t.status===`failed`)throw Error(t.error||`The GAIA agent could not be installed.`);await OD(n)}}function AD({onInstalled:e}){let[t,n]=(0,B.useState)({kind:`idle`}),r=(0,B.useRef)(!1);(0,B.useEffect)(()=>()=>{r.current=!0},[]);let i=(0,B.useCallback)(async()=>{n({kind:`installing`,percent:0});try{if(await kD({isCancelled:()=>r.current,onProgress:e=>{r.current||n({kind:`installing`,percent:e.percent??0})}}),r.current)return;await e(),r.current||n({kind:`idle`})}catch(e){r.current||n({kind:`failed`,error:e instanceof Error?e.message:String(e)})}},[e]);return(0,H.jsxs)(`div`,{className:`app-notice is-warning`,role:`status`,children:[t.kind===`installing`?(0,H.jsxs)(`span`,{children:[`Installing the GAIA agent… `,Math.round(t.percent),`%`]}):t.kind===`failed`?(0,H.jsxs)(`span`,{children:[`The GAIA agent could not be installed: `,t.error]}):(0,H.jsx)(`span`,{children:`The GAIA agent isn't installed, so new chats can't start yet.`}),t.kind!==`installing`&&(0,H.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>void i(),children:t.kind===`failed`?`Try again`:`Install GAIA agent`})]})}function jD(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}function MD(e,t){let{addNotification:n}=K.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:`Scheduled task "${r.name}" failed`,message:r.last_error,timestamp:Date.now(),read:!1,dismissed:!1,priority:`high`,...r.session_id?{sessionId:r.session_id}:{}})}var ND=Jn((e,t)=>({schedules:[],loading:!1,error:null,selectedSchedule:null,results:[],resultsLoading:!1,errorCounts:null,loadSchedules:async()=>{t().schedules.length===0&&!t().error&&e({loading:!0}),e({error:null});try{let n=(await uo()).schedules||[],r=t().errorCounts;r&&MD(r,n),e({schedules:n,loading:!1,errorCounts:Object.fromEntries(n.map(e=>[e.id,e.error_count]))})}catch(t){u.api.error(`Failed to load schedules`,t),e({error:`Failed to load schedules`,loading:!1})}},createSchedule:async(t,n,r)=>{try{let i=await po(t,n,r);e(e=>({schedules:[...e.schedules,i],error:null}))}catch(t){let n=jD(t,`Failed to create schedule`);throw u.api.error(`Failed to create schedule`,t),e({error:n}),t}},updateScheduleStatus:async(t,n)=>{try{let r=await mo(t,n);e(e=>({schedules:e.schedules.map(e=>e.name===t?r:e),error:null}))}catch(n){u.api.error(`Failed to update schedule "${t}"`,n),e({error:jD(n,`Failed to update schedule`)})}},deleteSchedule:async t=>{try{await ho(t),e(e=>({schedules:e.schedules.filter(e=>e.name!==t),selectedSchedule:e.selectedSchedule===t?null:e.selectedSchedule,error:null}))}catch(n){u.api.error(`Failed to delete schedule "${t}"`,n),e({error:jD(n,`Failed to delete schedule`)})}},selectSchedule:n=>{e({selectedSchedule:n,results:[]}),n&&t().loadResults(n)},loadResults:async t=>{e({resultsLoading:!0});try{e({results:(await go(t)).results||[],resultsLoading:!1})}catch(n){u.api.error(`Failed to load results for "${t}"`,n),e({results:[],resultsLoading:!1})}}})),PD=new Set([`loading_model`,`downloading_model`,`model_retry`,`waiting`]),FD=5;function ID(e,t){return{id:e,title:t.get(e)?.title??`Untitled chat`}}function LD(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=>({...ID(e,t),reason:`approval`}));n&&e.awaitingUser&&!a.has(e.currentSessionId)&&o.push({...ID(e.currentSessionId,t),reason:`answer`});for(let[n,r]of Object.entries(e.awaitingBySession))o.some(e=>e.id===n)||o.push({...ID(n,t),reason:r===`question`?`answer`:`approval`});let s=n&&!e.awaitingUser&&e.livePhase&&PD.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,FD).map(e=>ID(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=>ID(e,t)),needsYou:o,recent:u}}function RD(e){let t=(0,B.useRef)(e);t.current=e,(0,B.useEffect)(()=>{let e=window.gaiaAPI?.tray;if(!e)return;let n=``,r=null,i=()=>{let t=V.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:K.getState().notifications},a=r;if(r=i,a&&Object.keys(i).every(e=>i[e]===a[e]))return;let o=LD(i),s=JSON.stringify(o);s!==n&&(n=s,e.setActivity(o).catch(e=>{n=``,u.system.error(`The tray could not take the app state`,e)}))};i();let a=V.subscribe(i),o=K.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`:V.getState().openSettings(e.section);break;case`refresh-status`:t.current.refreshStatus();break;default:u.system.error(`Unknown tray command`,e)}});return()=>{a(),o(),s()}},[])}function zD(){(0,B.useEffect)(()=>{let e=window.gaiaAPI;if(!e)return;let t=K.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=V.getState();n.currentSessionId!==t&&n.setMessages([]),n.setCurrentSession(t)})];return()=>n.forEach(e=>e())},[])}function BD(e,t,n){let r=window.gaiaAPI;if(r){r.notification.show({title:t,body:n,sessionId:e}).then(e=>{e||u.system.warn(`This OS has no desktop notifications; the badge still counts it.`)}).catch(e=>u.system.error(`Could not show the desktop notification`,e));return}if(typeof Notification>`u`){u.system.warn(`This browser has no notifications; the alert was not shown.`);return}if(Notification.permission!==`granted`){u.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(),V.getState().setCurrentSession(e)}}function VD(){let[e,t]=(0,B.useState)(null);return(0,B.useEffect)(()=>{let e=navigator;if(!e.getBattery)return;let n=null,r=()=>{n&&t({charging:n.charging,level:n.level})};return e.getBattery().then(e=>{n=e,r(),e.addEventListener(`levelchange`,r),e.addEventListener(`chargingchange`,r)}).catch(e=>u.system.warn(`Battery level unavailable; keep-awake ignores the battery policy.`,e)),()=>{n?.removeEventListener(`levelchange`,r),n?.removeEventListener(`chargingchange`,r)}},[]),e}function HD(){zD();let e=V(e=>e.runningSessionIds),t=V(e=>e.awaitingBySession),n=V(e=>e.sessions),r=V(e=>e.currentSessionId),i=K(Hn(Ts)),a=Ms(),o=VD(),s=(0,B.useRef)(null),c=zs(e,t,i),l=JSON.stringify(c);(0,B.useEffect)(()=>{let e=JSON.parse(l),t=s.current;if(s.current=e,t===null)return;let{sessions:n,currentSessionId:r}=V.getState(),i=document.hasFocus(),o=!1;for(let{sessionId:s,event:c}of Bs(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`||Us(s,r,i))&&(o=!0,t===`banner`)){if(c!==`finished`){let{title:t,body:n}=Hs(c,e);BD(s,t,n)}else ya(s).then(e=>{V.getState().updateSessionInList(s,e);let{title:t,body:n}=Hs(c,e);BD(s,t,n)}).catch(t=>{u.system.error(`Could not read how chat ${s} ended`,t);let{title:n,body:r}=Hs(c,{...e,last_run_status:null});BD(s,n,r)})}}if(o){if(a.sound)try{Ks()}catch(e){u.system.warn(`Alert sound not played`,e)}a.flash&&!i&&window.gaiaAPI&&window.gaiaAPI.notification.flash().catch(e=>u.system.error(`Could not flash the taskbar button`,e))}},[l,a.modes,a.sound,a.flash]);let d=Ws(n,c,a.modes,r);(0,B.useEffect)(()=>{window.gaiaAPI?.notification.setAttentionCount(d).catch(e=>u.system.error(`Could not update the taskbar badge`,e))},[d]);let f=a.keepAwake&&e.length>0&&Gs(o,a.batteryFloor);(0,B.useEffect)(()=>{window.gaiaAPI?.power.setKeepAwake(f).catch(e=>u.system.error(`Could not change keep-awake`,e))},[f])}function UD(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 WD(e){return e.replace(/-/g,``).slice(0,7)}function GD(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 KD(e,t,n){return!e||t&&(e===t||e===WD(t))?null:n.some(t=>t.id===e)?e:GD(n,e)}function qD(e){return new URLSearchParams(e.search).get(`session`)||e.hash.replace(/^#/,``)||null}var JD=1e3,YD=3e4;function XD(e,{initialMs:t=JD,maxMs:n=YD,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}}var ZD=(0,B.lazy)(()=>aD(()=>import(`./MemoryDashboard-BSvuQ0Gw.js`).then(e=>({default:e.MemoryDashboard})),__vite__mapDeps([6,1,2,7,8,9]),import.meta.url)),QD=(0,B.lazy)(()=>aD(()=>import(`./ScheduleManager-CtKyLXmp.js`).then(e=>({default:e.ScheduleManager})),__vite__mapDeps([10,1,2,8,11]),import.meta.url)),$D=(0,B.lazy)(()=>aD(()=>import(`./DocumentLibrary-Blc3og5s.js`).then(e=>({default:e.DocumentLibrary})),__vite__mapDeps([12,1,2,13]),import.meta.url)),eO=(0,B.lazy)(()=>aD(()=>import(`./FileBrowser-BEHm0tfL.js`).then(e=>({default:e.FileBrowser})),__vite__mapDeps([14,1,2,7,15]),import.meta.url)),tO=(0,B.lazy)(()=>aD(()=>import(`./MobileAccessModal-CesEiNm2.js`).then(e=>({default:e.MobileAccessModal})),__vite__mapDeps([16,1,2,17]),import.meta.url)),nO=3,rO=3e5,iO=6e3;function aO(){return(0,H.jsx)(`div`,{className:`loading-spinner`,role:`status`,"aria-label":`Loading`})}var oO=e=>e===1||e%10==0;function sO(){let e=V(e=>e.currentSessionId),t=V(e=>e.setSessions),n=V(e=>e.setCurrentSession),r=V(e=>e.addSession),a=V(e=>e.setMessages),o=V(e=>e.resetStreaming),s=V(e=>e.showDocLibrary),c=V(e=>e.showFileBrowser),l=V(e=>e.showMemoryDashboard),f=V(e=>e.showSchedules),p=V(e=>e.sidebarOpen),m=V(e=>e.setSidebarOpen),h=V(e=>e.setSystemStatus),g=V(e=>e.setBackendConnected),_=V(e=>e.setAgents),v=V(e=>e.agents),y=V(e=>e.setPendingPrompt),b=V(e=>e.setDefaultPermissionMode),x=V(e=>e.openSettings),S=V(e=>e.settingsSection),C=V(e=>e.syncSystemTheme),w=Uo(e=>e.restoreNotice),T=Uo(e=>e.dismissRestoreNotice),E=K(e=>e.showPanel),D=V(e=>e.systemStatus?.initialized===!0),O=K(e=>e.setShowPanel);(0,B.useEffect)(()=>{if(!w?.ok)return;let e=setTimeout(T,iO);return()=>clearTimeout(e)},[w,T]);let[k,A]=(0,B.useState)({state:`checking`}),j=(0,B.useRef)(k);j.current=k;let[M,N]=(0,B.useState)(!1),ee=(0,B.useRef)(M);ee.current=M;let[P,te]=(0,B.useState)(!1),ne=P||M&&!Vw(v),re=(0,B.useRef)(ne);re.current=ne;let[ie,ae]=(0,B.useState)(null),[oe,se]=(0,B.useState)(``),[ce,le]=(0,B.useState)(0),[ue,de]=(0,B.useState)(!1),[fe,pe]=(0,B.useState)(!1),[me,he]=(0,B.useState)(null),F=(0,B.useCallback)(async(e=!1)=>{e||A({state:`checking`});try{await Uo.getState().refresh();let e=Uo.getState().active,t=await Wi(!!e?.remote);A(t.ready?{state:`ready`}:{state:`needed`,check:t})}catch(e){let t=e instanceof Error?e.message:String(e);u.system.warn(`Setup check could not be answered`,e),A({state:`unknown`,error:t})}},[]),I=(0,B.useRef)(0),L=(0,B.useCallback)(async()=>{let e=++I.current,t=(await Bi()).agents||[];e===I.current&&(_(t),N(!0),Vw(t)&&te(!1))},[_]),ge=(0,B.useCallback)(()=>{let e=ee.current;N(!1),L().catch(t=>{u.api.warn(`Agent list unavailable after setup`,t),e&&N(!0)})},[L]);(0,B.useEffect)(()=>{let e=()=>{re.current&&L().catch(e=>u.api.warn(`Agent list unavailable`,e))};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[L]);let _e=(0,B.useCallback)(async()=>{b((await gi()).default_mode)},[b]),ve=(0,B.useRef)([]);(0,B.useEffect)(()=>{i(`0.25.2rc1`),F();let e=[XD(L,{onError:(e,t)=>{oO(t)&&u.api.warn(`Agent list unavailable (attempt ${t}); retrying`,e)}}),XD(_e,{onError:(e,t)=>{oO(t)&&u.api.warn(`Default permission mode unavailable (attempt ${t}); retrying`,e)}})];return ve.current=e,()=>e.forEach(e=>e.stop())},[F,L,_e]);let ye=(0,B.useCallback)(()=>{ve.current.forEach(e=>e.kick()),Uo.getState().retryNow(),j.current.state===`unknown`&&F(!0)},[F]),R=(0,B.useRef)(ye);R.current=ye;let be=(0,B.useRef)(0),xe=(0,B.useRef)(0),Se=(0,B.useRef)(null),Ce=(0,B.useRef)(!1),[we,Te]=(0,B.useState)(!1),[Ee,De]=(0,B.useState)(null),Oe=(0,B.useCallback)(e=>{if(e.kind===`unreachable`){u.system.warn(`System status check failed`,e.error),Ce.current=!0,xe.current=0,Se.current=null,Te(!1),De(null),g(!1),h(null);return}if(e.kind===`error`){u.system.warn(`System status answered HTTP ${e.httpStatus}`,e.message),Ce.current&&R.current(),Ce.current=!1,xe.current=0,Se.current=null,Te(!1),De(`HTTP ${e.httpStatus}: ${e.message}`),g(!0);return}if(e.kind===`slow`){if(xe.current+=1,Se.current??=Date.now(),De(null),u.system.warn(`System status did not answer in time (${xe.current} in a row)`),Date.now()-Se.current>=rO){Te(!1),g(!1),h(null);return}g(!0),(Ce.current||xe.current>=nO)&&Te(!0);return}let{status:t}=e;Ce.current&&R.current(),Ce.current=!1,xe.current=0,Se.current=null,Te(!1),De(null),g(!0),be.current=t.lemonade_running?0:be.current+1;let n=V.getState().systemStatus;t.lemonade_running||be.current>=nO||!n?.lemonade_running?h(t):h({...n,download_progress:t.download_progress})},[g,h]),ke=(0,B.useRef)(Oe);ke.current=Oe;let[Ae]=(0,B.useState)(()=>vD(e=>ke.current(e))),je=Ae.check;(0,B.useEffect)(()=>Qw(Ae.start),[Ae]);let Me=(0,B.useRef)(``);(0,B.useEffect)(()=>{let e=e=>{ha().then(n=>{let r=n.sessions||[];if(!e&&r.length===0&&V.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(`
78
+ `)})]}),I&&(0,H.jsxs)(`div`,{className:`setup-done`,role:`status`,children:[(0,H.jsxs)(`div`,{className:`setup-done-head`,children:[(0,H.jsxs)(`p`,{children:[`GAIA is ready.`,ge&&(0,H.jsxs)(H.Fragment,{children:[` `,(0,H.jsx)(`strong`,{children:Qo(ge)}),` answers`,P?` in the cloud`:` on this PC`,`.`]})]}),(0,H.jsx)(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void F(),autoFocus:!0,children:`Start chatting`})]}),E.length>0&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`p`,{className:`setup-hint`,children:`Or start with one of these:`}),(0,H.jsx)(pT,{cards:E,onPick:e=>void F(e)})]})]})]})})}var GT=Js()?`menu bar`:`tray`,KT=[{key:`minimizeToTray`,label:`Keep running when the window closes`,hint:`GAIA stays in the ${GT} with your model loaded. Quit from the ${GT} menu.`},{key:`startOnLogin`,label:`Start GAIA when you sign in`,hint:`Your first chat of the day starts without waiting for GAIA to open.`},{key:`startMinimized`,label:`Start in the ${GT}`,hint:`GAIA opens without its window. Use the ${GT} icon to show it.`}];function qT(){let e=window.gaiaAPI?.tray,[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(null);(0,B.useEffect)(()=>{e&&e.getConfig().then(e=>n(e.tray)).catch(e=>i(`Couldn't read the desktop settings: ${e instanceof Error?e.message:String(e)}`))},[e]);let s=(0,B.useCallback)(async r=>{if(e&&t&&a===null){o(r),i(null);try{let i=await e.setConfig({tray:{[r]:!t[r]}});n(i.tray)}catch(e){i(e instanceof Error?e.message:String(e))}finally{o(null)}}},[e,t,a]);return e?(0,H.jsxs)(`div`,{className:`settings-field`,role:`group`,"aria-labelledby":`desktop-app-label`,children:[(0,H.jsx)(`span`,{className:`settings-label`,id:`desktop-app-label`,children:`Desktop app`}),KT.map(({key:e,label:n,hint:r})=>(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`label`,{className:`setting-row`,children:[(0,H.jsx)(`span`,{children:n}),(0,H.jsxs)(`span`,{className:`toggle-switch`,children:[(0,H.jsx)(`input`,{type:`checkbox`,role:`switch`,checked:!!t?.[e],"aria-describedby":`desktop-${e}-hint`,onChange:()=>void s(e),disabled:!t||a!==null&&a!==e,"aria-busy":a===e,"aria-label":n}),(0,H.jsx)(`span`,{className:`toggle-track`})]})]}),(0,H.jsx)(`p`,{className:`settings-hint`,id:`desktop-${e}-hint`,children:r})]},e)),r&&(0,H.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r})]}):null}var JT=[{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`system`,label:`Match system`}],YT=[[`Enter`,`Send`],[`Shift+Enter`,`New line`],[`Esc`,`Stop the answer`],[`Mod+Shift+O`,`New chat`],[`Mod+K`,`Search chats`],[`Mod+B`,`Show or hide the sidebar`],[`Mod+,`,`Settings`]];function XT(){let e=V(e=>e.themePreference),t=V(e=>e.setThemePreference),n=V(e=>e.palette),r=V(e=>e.setPalette),i=V(e=>e.customColors),a=V(e=>e.setCustomColors),o=e=>t=>a({...i,[e]:t.target.value.toUpperCase()});return(0,H.jsxs)(`div`,{className:`settings-pane`,children:[(0,H.jsx)(`h2`,{className:`settings-pane-title`,children:`General`}),(0,H.jsxs)(`div`,{className:`settings-field`,children:[(0,H.jsx)(`span`,{className:`settings-label`,id:`appearance-label`,children:`Appearance`}),(0,H.jsx)(`div`,{className:`segmented`,role:`radiogroup`,"aria-labelledby":`appearance-label`,children:JT.map(n=>(0,H.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e===n.value,className:e===n.value?`is-active`:``,onClick:()=>t(n.value),children:n.label},n.value))})]}),(0,H.jsx)(qT,{}),(0,H.jsxs)(`div`,{className:`settings-field`,children:[(0,H.jsx)(`span`,{className:`settings-label`,id:`palette-label`,children:`Colors`}),(0,H.jsxs)(`div`,{className:`palette-grid`,role:`radiogroup`,"aria-labelledby":`palette-label`,children:[tr.map(e=>(0,H.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":n===e.id,className:`palette-tile${n===e.id?` is-active`:``}`,onClick:()=>r(e.id),children:[(0,H.jsx)(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:e.swatch.map(e=>(0,H.jsx)(`i`,{style:{background:e}},e))}),e.name]},e.id)),(0,H.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":n===`custom`,className:`palette-tile${n===`custom`?` is-active`:``}`,onClick:()=>r(`custom`),children:[(0,H.jsxs)(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:[(0,H.jsx)(`i`,{style:{background:i.base}}),(0,H.jsx)(`i`,{style:{background:i.accent}})]}),`Custom`]})]}),n===`custom`&&(0,H.jsxs)(`div`,{className:`palette-custom`,children:[(0,H.jsxs)(`label`,{className:`palette-color`,htmlFor:`custom-accent`,children:[(0,H.jsx)(`input`,{id:`custom-accent`,type:`color`,value:i.accent,onChange:o(`accent`)}),(0,H.jsxs)(`span`,{children:[`Accent`,(0,H.jsx)(`small`,{children:`Buttons, links and focus`})]})]}),(0,H.jsxs)(`label`,{className:`palette-color`,htmlFor:`custom-base`,children:[(0,H.jsx)(`input`,{id:`custom-base`,type:`color`,value:i.base,onChange:o(`base`)}),(0,H.jsxs)(`span`,{children:[`Background tint`,(0,H.jsx)(`small`,{children:`The color the grays lean toward`})]})]}),(0,H.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>a(rr),children:`Reset`}),(0,H.jsx)(`p`,{className:`settings-hint`,children:`Text colors adjust on their own so everything stays readable in light and dark.`})]})]}),(0,H.jsxs)(`div`,{className:`settings-field`,children:[(0,H.jsx)(`span`,{className:`settings-label`,children:`Keyboard shortcuts`}),(0,H.jsx)(`dl`,{className:`shortcut-list`,children:YT.map(([e,t])=>(0,H.jsxs)(`div`,{className:`shortcut-row`,children:[(0,H.jsx)(`dt`,{children:(0,H.jsx)(`kbd`,{children:Qs(e)})}),(0,H.jsx)(`dd`,{children:t})]},e))})]})]})}var ZT=`auto`;function QT({model:e}){let[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(null);(0,B.useEffect)(()=>{n(null),i(null),c(null),aa(e).then(n).catch(e=>i(e instanceof Error?e.message:String(e)))},[e]);let l=(0,B.useCallback)(async t=>{o(!0),i(null),c(null);try{let r=await oa(e,t===ZT?null:Number(t));n(r);let i=r.chosen?rs(r.chosen):`the automatic size`;r.reload?.started?c(`Reloading ${r.display_name} at ${i}. Chat pauses until it's back.`):r.reload?.reason===`already_loaded`?c(`Saved. ${r.display_name} is already loaded at ${i}, so nothing reloads.`):r.reload?.reason===`warm_up`?c(`Saved. GAIA is getting the model ready for a new chat, so ${r.display_name} switches to ${i} the next time it loads.`):r.reload?.reason===`busy`?c(`Saved. GAIA is answering right now, so ${r.display_name} switches to ${i} the next time it loads.`):r.reload?.reason===`not_gaias_server`?c(`Saved. GAIA doesn't reload models on your own server; ${r.display_name} uses ${i} the next time it loads.`):r.reload?.reason===`restarting`?c(`Saved. A reload is already running; this size applies the next time the model loads.`):c(`Saved. It applies the next time this model loads.`)}catch(e){i(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e]);if(r&&!t)return(0,H.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r});if(!t)return(0,H.jsxs)(`p`,{className:`settings-hint`,children:[(0,H.jsx)(z,{size:13,className:`spin`}),` Checking context sizes…`]});let u=t.chosen==null?ZT:String(t.chosen),d=t.chosen!=null&&t.loaded_ctx!=null&&t.loaded_ctx!==t.chosen;return(0,H.jsxs)(`div`,{className:`settings-field`,children:[(0,H.jsx)(`label`,{className:`settings-label`,htmlFor:`ctx-size`,children:`Context size`}),(0,H.jsxs)(`select`,{id:`ctx-size`,className:`settings-input`,value:u,onChange:e=>void l(e.target.value),disabled:a||t.options.length===0,children:[(0,H.jsxs)(`option`,{value:ZT,children:[`Automatic`,t.automatic?` (${rs(t.automatic)})`:``]}),t.options.map(e=>(0,H.jsxs)(`option`,{value:String(e),children:[rs(e),` tokens`]},e))]}),(0,H.jsxs)(`span`,{className:`settings-hint`,children:[t.note??(t.max_fit?`Up to ${rs(t.max_fit)}, the most ${t.display_name} can hold on this PC (${t.memory_source}). A larger window uses more memory. GAIA reloads the model to apply it, except on a Lemonade you run yourself.`:null),d&&` Loaded now at ${rs(t.loaded_ctx)}.`]}),a&&(0,H.jsxs)(`span`,{className:`settings-hint`,children:[(0,H.jsx)(z,{size:13,className:`spin`}),` Applying…`]}),s&&(0,H.jsx)(`p`,{className:`settings-ok`,role:`status`,children:s}),r&&(0,H.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r})]})}function $T(){let[e,t]=(0,B.useState)(null),[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(``),[o,s]=(0,B.useState)(!1),c=(0,B.useCallback)(async e=>{s(!0),r(null);try{let n=await e();t(n),a(n.limit_usd==null?``:String(n.limit_usd))}catch(e){r(e instanceof Error?e.message:String(e))}finally{s(!1)}},[]);if((0,B.useEffect)(()=>{c(da)},[c]),!e)return n?(0,H.jsx)(`p`,{className:`settings-error`,role:`alert`,children:n}):(0,H.jsxs)(`p`,{className:`settings-hint`,children:[(0,H.jsx)(z,{size:13,className:`spin`}),` Loading this month’s spending…`]});let l=e.limit_usd,u=i.trim()===``?null:Number(i),d=u===null||Number.isFinite(u)&&u>0,f=u!==l;return(0,H.jsxs)(`section`,{className:`settings-field spending`,"aria-label":`Cloud spending`,children:[(0,H.jsx)(`span`,{className:`settings-label`,children:`Cloud spending this month`}),(0,H.jsxs)(`p`,{className:`spending-total`,children:[(0,H.jsx)(`strong`,{children:yS(e.total_usd)}),l!=null&&(0,H.jsxs)(H.Fragment,{children:[` of your `,yS(l),` limit`]}),(0,H.jsxs)(`span`,{className:`settings-hint`,children:[` · `,e.turns,` cloud `,e.turns===1?`chat turn`:`chat turns`,`, at list price`]})]}),e.unpriced_turns>0&&(0,H.jsxs)(`p`,{className:`settings-hint`,children:[`Plus `,e.unpriced_turns,` `,e.unpriced_turns===1?`turn`:`turns`,` on models with an unknown price, not included above.`]}),e.state===`near`&&(0,H.jsxs)(`p`,{className:`spending-warning`,role:`status`,children:[(0,H.jsx)(Cn,{size:13,"aria-hidden":`true`}),` Close to your limit. GAIA stops before a cloud chat once it’s reached.`]}),e.state===`reached`&&(0,H.jsxs)(`div`,{className:`spending-warning`,role:`alert`,children:[(0,H.jsxs)(`p`,{children:[(0,H.jsx)(Cn,{size:13,"aria-hidden":`true`}),` You’ve reached your limit, so cloud chats are stopped until next month. Models on this PC still work.`]}),(0,H.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:o,onClick:()=>void c(pa),children:`Allow more this month`})]}),e.state===`allowed_over`&&(0,H.jsx)(`p`,{className:`settings-hint`,children:`Over your limit; you allowed more for this month.`}),(0,H.jsxs)(`form`,{className:`settings-row`,onSubmit:e=>{e.preventDefault(),d&&f&&c(()=>fa(u))},children:[(0,H.jsx)(`label`,{className:`spending-limit-label`,htmlFor:`spend-limit`,children:`Monthly limit ($)`}),(0,H.jsx)(`input`,{id:`spend-limit`,className:`settings-input`,type:`number`,min:`0.01`,step:`0.01`,inputMode:`decimal`,placeholder:`No limit`,value:i,onChange:e=>a(e.target.value),"aria-invalid":!d}),(0,H.jsxs)(`button`,{type:`submit`,className:`btn-secondary`,disabled:o||!d||!f,children:[o?(0,H.jsx)(z,{size:13,className:`spin`}):null,` Save`]}),l!=null&&(0,H.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:o,onClick:()=>void c(()=>fa(null)),children:`Remove limit`})]}),(0,H.jsx)(`span`,{className:`settings-hint`,children:`Counts cloud chats in GAIA’s Agent UI at list price, without cache discounts. Your provider’s bill is the final word. Turns that fail or are stopped before a reply aren’t counted. Models with an unknown price, like the AMD LLM Gateway’s, add nothing to the total, but are stopped too once the limit is reached.`}),n&&(0,H.jsx)(`p`,{className:`settings-error`,role:`alert`,children:n})]})}var eE=2e3;function tE(e){if(e.key_state===`waiting_for_os_permission`)return e.key_message??`Waiting for the OS to allow reading the saved key.`;switch(e.key_source){case`environment`:return`A key is set in ${e.env_var} and is in use.`;case`lemonade`:return`A key is already configured on the local model server.`;case`stored`:return`A saved key will be used.`;default:return`No key yet.`}}function nE(e){return e.key_source===`environment`?`Blank uses the environment key`:e.key_source?`Blank keeps the saved key`:`Paste API key`}function rE(){let e=Uo(e=>e.active),t=Uo(e=>e.select),n=Uo(e=>e.refresh),r=Uo(e=>e.rememberNames),[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(e?.provider??`local`),[u,d]=(0,B.useState)(null),[f,p]=(0,B.useState)(null),[m,h]=(0,B.useState)(``),[g,_]=(0,B.useState)(!1),[v,y]=(0,B.useState)(``),[b,x]=(0,B.useState)({base_url:``,auth_header_name:``,auth_header_prefix:``}),[S,C]=(0,B.useState)(null),[w,T]=(0,B.useState)(null),[E,D]=(0,B.useState)(null),O=(0,B.useRef)(c);O.current=c;let k=(0,B.useRef)(!0);(0,B.useEffect)(()=>()=>{k.current=!1},[]);let A=i?.find(e=>e.id===c)??null,j=e=>e?.network?.reachable===!1,M=!!A&&(!A.remote||!!A.models_discovered),N=(0,B.useCallback)(async()=>{s(null);try{let e=await $i();a(e.providers),e.lemonade_error&&s(e.lemonade_error)}catch(e){s(e instanceof Error?e.message:String(e))}},[]),ee=(0,B.useCallback)(async(e,t=!1)=>{t||(d(null),p(null));try{let t=await ia(e);r(t.models),d(t.models),T(t.memory_gb?`${t.memory_gb} GB (${t.memory_source})`:t.capacity_error??null)}catch(e){p(e instanceof Error?e.message:String(e))}},[r]);(0,B.useEffect)(()=>{N()},[N]);let P=!!i?.some(e=>e.key_state===`waiting_for_os_permission`);(0,B.useEffect)(()=>{if(!P)return;let e=setInterval(()=>{N()},eE);return()=>clearInterval(e)},[P,N]);let te=e?.provider;(0,B.useEffect)(()=>{te&&l(te)},[te]),(0,B.useEffect)(()=>{y(``),D(null),h(``),_(!1)},[c]),(0,B.useEffect)(()=>{M?ee(c):d(null)},[c,M,ee]);let ne=(0,B.useCallback)(async()=>{if(A){C(`connect`),D(null);try{let e=c===`amd`?{api_key:v||void 0,...Object.fromEntries(Object.entries(b).filter(([,e])=>e!==``))}:{api_key:v||void 0},t=()=>!k.current||O.current!==c,n=await na(c,e,e=>{t()||D({ok:!0,text:e})},t);if(t())return;y(``),D({ok:!0,text:n.remember_error?`Connected for this session only — the key could not be kept: ${n.remember_error}`:n.remembered?`Connected. The key is kept for next time.`:`Connected.`}),await N()}catch(e){k.current&&O.current===c&&D({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{k.current&&C(null)}}},[b,c,v,N,A]),re=(0,B.useCallback)(async()=>{C(`forget`),D(null);try{await ra(c),D({ok:!0,text:`Key cleared, here and for future sessions. An environment key, if set, stays active.`}),await N(),await n()}catch(e){D({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{C(null)}},[c,N,n]),ie=(0,B.useCallback)(async e=>{C(e),D(null);try{await t(e),D({ok:!0,text:`New messages use ${Go(e)}. It is remembered across restarts.`})}catch(e){D({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{C(null)}},[t]),oe=(0,B.useCallback)(async e=>{C(`dl:${e}`),D(null);try{await zi(e),await ee(`local`,!0)}catch(e){D({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{C(null)}},[ee]),se=!!u?.some(as);(0,B.useEffect)(()=>{if(c!==`local`||!se)return;let e=setInterval(()=>{ee(`local`,!0)},eE);return()=>clearInterval(e)},[se,c,ee]);let ce=(0,B.useMemo)(()=>{let e=m.trim().toLowerCase();return(u??[]).filter(t=>!e||t.id.toLowerCase().includes(e)||(t.display_name??``).toLowerCase().includes(e))},[u,m]),le=ce.filter(e=>e.available!==!1),ue=c===`fireworks`&&!g&&!m.trim()&&le.some(e=>e.rank!==null),de=t=>t.rank!==null||t.id===e?.model,fe=ue?le.filter(de):le,pe=ue?le.filter(e=>!de(e)):[],me=ce.filter(e=>e.available===!1),he=$o(u??[]),F=e&&!e.remote&&e.model?e.model:null,I=t=>{let n=e?.model===t.id,r=as(t)?t.download_progress:null,i=[ns(t.placement),t.size_gb?`${t.size_gb} GB ${t.downloaded?`on disk`:`download`}`:null,t.tokens_per_second?`${Math.round(t.tokens_per_second)} tok/s measured here`:null,!t.placement&&t.context_length?`Context ${t.context_length.toLocaleString()} tokens`:null].filter(Boolean).join(` · `);return(0,H.jsxs)(`li`,{className:`model-row${n?` is-current`:``}`,children:[(0,H.jsxs)(`div`,{className:`model-row-text`,children:[(0,H.jsxs)(`span`,{className:`model-row-name`,title:t.id,children:[he[t.id],t.rank&&(0,H.jsxs)(`span`,{className:`model-row-rank`,children:[`#`,t.rank,` `,t.note]}),t.state===`loaded`&&(0,H.jsx)(`span`,{className:`model-badge is-loaded`,children:ts.loaded}),t.fits===!0&&t.available!==!1&&(0,H.jsx)(`span`,{className:`model-badge is-fit`,children:`Fits this PC`})]}),A?.remote&&(0,H.jsx)(`span`,{className:`model-row-meta${t.price?``:` is-unknown-price`}`,children:vS(t.price)}),t.display_name&&(0,H.jsx)(`span`,{className:`model-row-meta`,children:t.id}),i&&(0,H.jsx)(`span`,{className:`model-row-meta`,children:i}),t.placement?.warning&&(0,H.jsx)(`span`,{className:`model-row-meta is-warning`,role:`alert`,children:t.placement.warning}),t.unavailable_reason&&(0,H.jsxs)(`span`,{className:`model-row-meta`,children:[`Can't run here: `,t.unavailable_reason]}),t.evidence&&(0,H.jsxs)(`span`,{className:`model-row-meta`,children:[`Measured: `,t.evidence]}),r&&(0,H.jsx)(`progress`,{max:100,value:r.percent,"aria-label":`Downloading ${he[t.id]}`})]}),n?(0,H.jsxs)(`span`,{className:`model-row-current`,children:[(0,H.jsx)(ae,{size:13,"aria-hidden":`true`}),` In use`]}):t.available===!1?null:r?(0,H.jsxs)(`span`,{className:`model-row-current`,children:[(0,H.jsx)(z,{size:13,className:`spin`}),` `,Math.round(r.percent),`%`]}):t.downloaded?(0,H.jsxs)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void ie(t.id),disabled:S!==null,"aria-label":`Use ${he[t.id]}`,children:[S===t.id?(0,H.jsx)(z,{size:13,className:`spin`}):null,` Use`]}):(0,H.jsxs)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void oe(t.id),disabled:S!==null,"aria-label":`Download ${he[t.id]}`,children:[S===`dl:${t.id}`?(0,H.jsx)(z,{size:13,className:`spin`}):null,` Download`]})]},t.id)};return(0,H.jsxs)(`div`,{className:`settings-pane`,children:[(0,H.jsx)(`h2`,{className:`settings-pane-title`,children:`Model`}),(0,H.jsx)(`p`,{className:`settings-pane-lede`,children:`GAIA runs on this PC by default. Cloud providers are used only when you pick one of their models.`}),(0,H.jsx)(`div`,{className:`provider-tabs`,role:`radiogroup`,"aria-label":`Where GAIA runs`,children:(i??[{id:`local`,name:`Local`,remote:!1}]).map(e=>(0,H.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":c===e.id,className:`provider-tab${c===e.id?` is-active`:``}${j(e)?` is-disabled`:``}`,onClick:()=>l(e.id),disabled:j(e)&&c!==e.id,title:j(e)?e.network?.detail??void 0:void 0,children:[e.remote?(0,H.jsx)(xe,{size:14,"aria-hidden":`true`}):(0,H.jsx)(ke,{size:14,"aria-hidden":`true`}),(0,H.jsx)(`span`,{children:e.name}),e.remote&&e.models_discovered&&(0,H.jsx)(`span`,{className:`provider-tab-dot`,"aria-label":`connected`})]},e.id))}),o&&(0,H.jsx)(`p`,{className:`settings-error`,role:`alert`,children:o}),A&&(0,H.jsxs)(`section`,{className:`settings-card`,"aria-label":A.name,children:[(0,H.jsx)(`p`,{className:`settings-note`,children:A.privacy_notice}),A.id===`local`&&(0,H.jsxs)(`p`,{className:`settings-hint`,children:[`Each model runs where it was built to: GGUF models on the GPU, FLM models on the NPU.`,w&&` Memory for models: ${w}.`]}),A.remote&&!M&&(0,H.jsxs)(`div`,{className:`settings-field`,children:[(0,H.jsx)(`span`,{className:`settings-label`,children:`Prices`}),(0,H.jsx)(OT,{provider:A.id})]}),j(A)&&(0,H.jsxs)(`div`,{className:`settings-field`,children:[(0,H.jsx)(`p`,{className:`settings-error`,role:`alert`,children:A.network?.detail}),(0,H.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void N(),children:`Check again`})]}),A.remote&&!j(A)&&(0,H.jsxs)(`form`,{className:`settings-field`,onSubmit:e=>{e.preventDefault(),ne()},children:[(0,H.jsx)(`span`,{className:`settings-label`,children:`API key`}),(0,H.jsx)(`span`,{className:`settings-hint`,children:tE(A)}),A.id===`amd`&&(0,H.jsxs)(`div`,{className:`settings-grid`,children:[(0,H.jsx)(`input`,{className:`settings-input`,placeholder:`Gateway URL (default https://llm-api.amd.com/Unified/v1)`,value:b.base_url,onChange:e=>x({...b,base_url:e.target.value}),"aria-label":`Gateway URL`}),(0,H.jsx)(`input`,{className:`settings-input`,placeholder:`Auth header (default Ocp-Apim-Subscription-Key)`,value:b.auth_header_name,onChange:e=>x({...b,auth_header_name:e.target.value}),"aria-label":`Auth header name`})]}),(0,H.jsxs)(`div`,{className:`settings-row`,children:[(0,H.jsx)(`input`,{className:`settings-input`,type:`password`,autoComplete:`off`,spellCheck:!1,value:v,onChange:e=>y(e.target.value),placeholder:nE(A),"aria-label":`${A.name} API key`}),(0,H.jsxs)(`button`,{type:`submit`,className:`btn-primary`,disabled:S!==null||!v&&!A.key_source,children:[S===`connect`?(0,H.jsx)(z,{size:13,className:`spin`}):null,A.models_discovered?`Reconnect`:`Connect`]}),(A.key_source===`lemonade`||A.key_source===`stored`)&&(0,H.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void re(),disabled:S!==null,children:`Forget key`})]}),A.error&&(0,H.jsx)(`p`,{className:`settings-error`,role:`alert`,children:A.error})]}),E&&(0,H.jsx)(`p`,{className:E.ok?`settings-ok`:`settings-error`,role:E.ok?`status`:`alert`,children:E.text}),A.id===`local`&&F&&e?.downloaded!==!1&&(0,H.jsx)(QT,{model:F}),M&&(0,H.jsxs)(`div`,{className:`settings-field`,children:[(0,H.jsx)(`span`,{className:`settings-label`,children:`Models`}),(u?.length??0)>6&&(0,H.jsx)(`input`,{className:`settings-input`,type:`search`,value:m,onChange:e=>h(e.target.value),placeholder:`Search models`,"aria-label":`Search models`}),f&&(0,H.jsx)(`p`,{className:`settings-error`,role:`alert`,children:f}),!u&&!f&&(0,H.jsxs)(`p`,{className:`settings-hint`,children:[(0,H.jsx)(z,{size:13,className:`spin`}),` Loading…`]}),u&&ce.length===0&&(0,H.jsx)(`p`,{className:`settings-hint`,children:`No models match.`}),(0,H.jsx)(`ul`,{className:`model-list`,children:fe.map(I)}),ue&&pe.length>0&&(0,H.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>_(!0),children:`Show all models`}),c===`fireworks`&&g&&!m.trim()&&(0,H.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>_(!1),children:`Show recommended models`}),me.length>0&&(0,H.jsxs)(`details`,{className:`model-unavailable`,children:[(0,H.jsxs)(`summary`,{children:[`Not available on this PC (`,me.length,`)`]}),(0,H.jsx)(`ul`,{className:`model-list`,children:me.map(I)})]})]}),A.remote&&(0,H.jsx)($T,{})]})]})}function iE(){let e=V(e=>e.sessions),[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)(null),a=(0,B.useCallback)(async()=>{i(null);try{n((await gi()).sessions)}catch(e){i(e instanceof Error?e.message:String(e))}},[]);(0,B.useEffect)(()=>{a()},[a]);let o=(0,B.useCallback)(async e=>{i(null);try{await e(),await a()}catch(e){i(e instanceof Error?e.message:String(e))}},[a]),s=t=>e.find(e=>e.id===t)?.title??t;return(0,H.jsxs)(`div`,{className:`settings-pane`,children:[(0,H.jsx)(`h2`,{className:`settings-pane-title`,children:`Permissions`}),(0,H.jsx)(`p`,{className:`settings-pane-lede`,children:`GAIA asks before it changes files, runs commands, or uses tools that act on your behalf. Pick a mode per chat from the shield next to the message box. “Always allow” covers one exact action in one chat and ends when GAIA restarts.`}),(0,H.jsxs)(`p`,{className:`settings-hint`,children:[`New chats start in full access only when `,(0,H.jsx)(`code`,{children:`full_access`}),` is set in`,(0,H.jsx)(`code`,{children:` ~/.gaia/config.json`}),` (the TUI’s `,(0,H.jsx)(`code`,{children:`/full-access always`}),`).`]}),r&&(0,H.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r}),t&&t.length===0&&(0,H.jsx)(`p`,{className:`settings-hint`,children:`No chat has full access or anything allowed without asking.`}),t?.map(e=>(0,H.jsxs)(`section`,{className:`settings-card`,"aria-label":s(e.session_id),children:[(0,H.jsxs)(`div`,{className:`settings-row settings-row-between`,children:[(0,H.jsx)(`span`,{className:`settings-label`,children:s(e.session_id)}),e.mode===`full_access`&&(0,H.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>o(()=>_i(e.session_id,`ask`)),children:`Turn off full access`})]}),e.grants.length>0&&(0,H.jsx)(`ul`,{className:`grant-list`,children:e.grants.map(t=>(0,H.jsxs)(`li`,{className:`grant-row`,children:[(0,H.jsx)(`code`,{children:t.label}),(0,H.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>o(()=>vi(e.session_id,t.key)),"aria-label":`Revoke ${t.label}`,children:`Revoke`})]},t.key))}),e.grants.length>1&&(0,H.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>o(()=>vi(e.session_id)),children:`Revoke all in this chat`})]},e.session_id))]})}function aE({onUseSkill:e}){let[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)({}),[a,o]=(0,B.useState)(null),[s,c]=(0,B.useState)(``);(0,B.useEffect)(()=>{let e=!1;return ma().then(t=>{e||(n(t.skills),i(t.invalid))}).catch(t=>{e||o(t instanceof Error?t.message:String(t))}),()=>{e=!0}},[]);let l=s.trim().toLowerCase(),u=(t??[]).filter(e=>!l||e.name.toLowerCase().includes(l)||e.description.toLowerCase().includes(l));return(0,H.jsxs)(`div`,{className:`settings-pane`,children:[(0,H.jsx)(`h2`,{className:`settings-pane-title`,children:`Skills`}),(0,H.jsxs)(`p`,{className:`settings-pane-lede`,children:[`Skills teach GAIA a job — a workflow, a CLI, a document type. GAIA loads one when a request needs it, and keeps the lessons it learns while using it. Add your own under `,(0,H.jsx)(`code`,{children:`~/.gaia/skills`}),`.`]}),a&&(0,H.jsx)(`p`,{className:`settings-error`,role:`alert`,children:a}),!t&&!a&&(0,H.jsxs)(`p`,{className:`settings-hint`,children:[(0,H.jsx)(z,{size:13,className:`spin`}),` Loading…`]}),t&&t.length>6&&(0,H.jsx)(`input`,{className:`settings-input`,type:`search`,value:s,onChange:e=>c(e.target.value),placeholder:`Search skills`,"aria-label":`Search skills`}),t&&t.length===0&&(0,H.jsx)(`p`,{className:`settings-hint`,children:`No skills are installed.`}),(0,H.jsx)(`ul`,{className:`skill-list`,children:u.map(t=>(0,H.jsxs)(`li`,{className:`skill-row`,children:[(0,H.jsxs)(`div`,{className:`skill-row-text`,children:[(0,H.jsxs)(`span`,{className:`skill-row-name`,children:[t.name,t.version&&(0,H.jsxs)(`span`,{className:`skill-row-meta`,children:[` v`,t.version]}),t.always_on&&(0,H.jsx)(`span`,{className:`skill-row-meta`,children:` · Always on`})]}),(0,H.jsx)(`span`,{className:`skill-row-desc`,children:t.description})]}),!t.always_on&&(0,H.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>e(t.name),"aria-label":`Use ${t.name} in a new chat`,children:`Use`})]},t.name))}),Object.keys(r).length>0&&(0,H.jsxs)(`div`,{className:`settings-card`,role:`alert`,children:[(0,H.jsx)(`span`,{className:`settings-label`,children:`Skipped, could not be read`}),(0,H.jsx)(`ul`,{className:`grant-list`,children:Object.entries(r).map(([e,t])=>(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`code`,{children:e}),` — `,t]},e))})]})]})}var oE=d();async function sE(e,t,n){let r=`${oE}${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 cE(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 lE(){return sE(`GET`,`/memory/stats`)}function uE(e=30){return sE(`GET`,`/memory/activity?days=${e}`)}function dE(e={}){return sE(`GET`,`/memory/knowledge${cE(e)}`)}function fE(e){return sE(`POST`,`/memory/knowledge`,e)}function pE(e,t){return sE(`PUT`,`/memory/knowledge/${encodeURIComponent(e)}`,t)}function mE(e){return sE(`DELETE`,`/memory/knowledge/${encodeURIComponent(e)}`)}function hE(){return sE(`GET`,`/memory/entities`)}function gE(){return sE(`GET`,`/memory/tools`)}function _E(e=20){return sE(`GET`,`/memory/conversations?limit=${e}`)}function vE(e,t=20){return sE(`GET`,`/memory/conversations/search?query=${encodeURIComponent(e)}&limit=${t}`)}function yE(e){return sE(`GET`,`/memory/conversations/${encodeURIComponent(e)}`)}function bE(e=7){return sE(`GET`,`/memory/upcoming?days=${e}`)}function xE(){return sE(`GET`,`/memory/embedding-coverage`)}function SE(){return sE(`POST`,`/memory/consolidate`)}function CE(){return sE(`POST`,`/memory/rebuild-embeddings`)}function wE(){return sE(`POST`,`/memory/reconcile`)}function TE(){return sE(`POST`,`/memory/rebuild-fts`)}function EE(){return sE(`POST`,`/memory/refresh-system-context`)}function DE(){return new EventSource(`${oE}/memory/stream-discovery`)}function OE(e){return new EventSource(`${oE}/memory/stream-inference?include_browser=${e}`)}function kE(e){return sE(`POST`,`/memory/commit-discovery`,{items:e})}function AE(e){return sE(`POST`,`/memory/commit-inference`,{insights:e})}function jE(){return sE(`GET`,`/memory/settings`)}function ME(e){return sE(`PUT`,`/memory/settings`,e)}function NE(){return sE(`DELETE`,`/memory/all`)}function PE(){return sE(`POST`,`/memory/reinitialize`)}function FE(){return sE(`GET`,`/goals/stats`)}function IE(e={}){return sE(`GET`,`/goals${cE(e)}`)}function LE(e){return sE(`POST`,`/goals`,e)}function RE(e){return sE(`PUT`,`/goals/${encodeURIComponent(e)}/approve`)}function zE(e){return sE(`PUT`,`/goals/${encodeURIComponent(e)}/reject`)}function BE(e){return sE(`PUT`,`/goals/${encodeURIComponent(e)}/cancel`)}function VE(e){return sE(`DELETE`,`/goals/${encodeURIComponent(e)}`)}function HE(){let e=V(e=>e.setShowMemoryDashboard),t=V(e=>e.closeSettings),[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(!1);(0,B.useEffect)(()=>{jE().then(r).catch(e=>a(e instanceof Error?e.message:String(e)))},[]);let c=(0,B.useCallback)(async()=>{if(n){s(!0),a(null);try{r(await ME({memory_enabled:!n.memory_enabled}))}catch(e){a(e instanceof Error?e.message:String(e))}finally{s(!1)}}},[n]);return(0,H.jsxs)(`div`,{className:`settings-pane`,children:[(0,H.jsx)(`h2`,{className:`settings-pane-title`,children:`Memory`}),(0,H.jsx)(`p`,{className:`settings-pane-lede`,children:`GAIA remembers facts, preferences and past conversations across chats, on this PC only. Private chats (the eye icon in a chat) are never remembered.`}),(0,H.jsxs)(`label`,{className:`setting-row`,children:[(0,H.jsx)(`span`,{children:`Remember across chats`}),(0,H.jsxs)(`span`,{className:`toggle-switch`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:!!n?.memory_enabled,onChange:()=>void c(),disabled:!n||o,"aria-label":`Remember across chats`}),(0,H.jsx)(`span`,{className:`toggle-track`})]})]}),i&&(0,H.jsx)(`p`,{className:`settings-error`,role:`alert`,children:i}),(0,H.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{t(),e(!0)},children:`Open the memory dashboard`}),(0,H.jsx)(`p`,{className:`settings-hint`,children:`Search, edit and forget what GAIA remembers.`})]})}var UE=`Keep for: enter a whole number of days from 1 to 365.`,WE=`Use at most: enter a whole number of MB from 10 to 100,000.`;function GE(e,t,n){if(!/^\d+$/.test(e.trim()))return!1;let r=Number(e);return r>=t&&r<=n}function KE(e){return e<1048576?`${Math.ceil(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function qE(){let[e,t]=(0,B.useState)(null),[n,r]=(0,B.useState)(``),[i,a]=(0,B.useState)(``),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(!1);(0,B.useEffect)(()=>{xo().then(e=>{t(e),r(String(e.retention_days)),a(String(e.max_mb))},e=>s({ok:!1,text:`Could not read undo history settings: ${e instanceof Error?e.message:e}`}))},[]);let[u,d]=(0,B.useState)({days:!1,mb:!1}),f=!GE(n,1,365)||u.days,p=!GE(i,10,1e5)||u.mb,m=e!==null&&(n!==String(e.retention_days)||i!==String(e.max_mb)),h=async()=>{if(!(f||p)){l(!0),s(null);try{let e=await So(Number(n),Number(i));t(e),s({ok:!0,text:`Saved. Older undo history beyond these limits was removed.`})}catch(e){let t=e instanceof Ci&&e.httpStatus===422?e.fields:[],n=t.includes(`retention_days`),r=t.includes(`max_mb`);n||r?(d({days:n,mb:r}),s({ok:!1,text:`Not saved. Fix the limit marked above.`})):s({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{l(!1)}}};return(0,H.jsxs)(`div`,{className:`settings-field`,"aria-label":`Undo history`,children:[(0,H.jsx)(`span`,{className:`settings-label`,children:`Undo history`}),(0,H.jsx)(`p`,{className:`settings-hint`,children:`Before GAIA changes a file it keeps a copy, so you can undo a turn. Copies older than the time limit, or past the space limit (oldest first), are deleted. The space limit never deletes the latest turn.`}),e&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`setting-row`,children:[(0,H.jsx)(`label`,{htmlFor:`undo-days`,children:`Keep for (days)`}),(0,H.jsx)(`input`,{id:`undo-days`,type:`number`,className:`model-input undo-history-input`,min:1,max:365,value:n,"aria-invalid":f,"aria-describedby":f?`undo-days-error`:void 0,onChange:e=>{r(e.target.value),d(e=>({...e,days:!1}))}})]}),f&&(0,H.jsx)(`p`,{id:`undo-days-error`,className:`settings-error`,children:UE}),(0,H.jsxs)(`div`,{className:`setting-row`,children:[(0,H.jsx)(`label`,{htmlFor:`undo-mb`,children:`Use at most (MB)`}),(0,H.jsx)(`input`,{id:`undo-mb`,type:`number`,className:`model-input undo-history-input`,min:10,max:1e5,value:i,"aria-invalid":p,"aria-describedby":p?`undo-mb-error`:void 0,onChange:e=>{a(e.target.value),d(e=>({...e,mb:!1}))}})]}),p&&(0,H.jsx)(`p`,{id:`undo-mb-error`,className:`settings-error`,children:WE}),(0,H.jsxs)(`div`,{className:`setting-row setting-row-path`,children:[(0,H.jsx)(`span`,{children:`In use`}),(0,H.jsxs)(`span`,{children:[KE(e.used_bytes),` for `,e.turns,` turn`,e.turns===1?``:`s`,` `,`in `,(0,H.jsx)(`code`,{className:`setting-path`,children:e.path})]})]}),(0,H.jsx)(`button`,{type:`button`,className:`btn-model-save`,onClick:()=>void h(),disabled:!m||c||f||p,children:c?`Saving…`:`Save`})]}),o&&(0,H.jsx)(`p`,{className:o.ok?`settings-ok`:`settings-error`,role:o.ok?`status`:`alert`,children:o.text})]})}function JE(){let e=V(e=>e.sessions),t=V(e=>e.removeSession),n=Yo(),r=V(e=>e.systemStatus?.data_dir),[i,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(null),c=(0,B.useRef)(null);(0,B.useEffect)(()=>()=>{c.current&&clearTimeout(c.current)},[]);let l=(0,B.useCallback)(async()=>{if(!i){a(!0),c.current=setTimeout(()=>a(!1),4e3);return}a(!1);let n=[];for(let r of e)try{await va(r.id),t(r.id)}catch(e){n.push(`${r.title}: ${e instanceof Error?e.message:e}`)}s(n.length?{ok:!1,text:`Could not delete ${n.length} chat(s): ${n.join(`; `)}`}:{ok:!0,text:`All chats deleted.`})},[i,t,e]);return(0,H.jsxs)(`div`,{className:`settings-pane`,children:[(0,H.jsx)(`h2`,{className:`settings-pane-title`,children:`Privacy`}),(0,H.jsxs)(`p`,{className:`settings-pane-lede`,children:[`Chats, documents and memory stay on this PC. `,n?.remote?`Right now answers come from ${n.label}, so each message and the chat history are sent there.`:n?`Right now answers are generated on this PC too.`:`GAIA can't tell right now whether answers are generated on this PC or by a cloud provider.`]}),r&&(0,H.jsxs)(`div`,{className:`setting-row`,children:[(0,H.jsx)(`span`,{children:`Data folder`}),(0,H.jsx)(`code`,{className:`setting-path`,children:r})]}),(0,H.jsx)(qE,{}),(0,H.jsx)(`div`,{className:`danger-divider`}),(0,H.jsx)(`p`,{className:`danger-warning`,children:`Deletes every chat and its messages. Documents and memory are kept.`}),(0,H.jsx)(`button`,{type:`button`,className:`btn-danger`,onClick:()=>void l(),disabled:e.length===0,children:i?`Click again to delete all chats`:`Delete all chats`}),o&&(0,H.jsx)(`p`,{className:o.ok?`settings-ok`:`settings-error`,role:o.ok?`status`:`alert`,children:o.text})]})}var YE=[{id:`needs_approval`,label:`Needs your approval`},{id:`question`,label:`Has a question`},{id:`finished`,label:`Finished`}],XE=[{value:`banner`,label:`Banner`},{value:`badge`,label:`Badge`},{value:`off`,label:`Off`}],ZE=[0,10,20,30,50];function QE(){return typeof Notification>`u`?`unsupported`:Notification.permission}function $E(){let e=Ms(),t=!!window.gaiaAPI,[n,r]=(0,B.useState)(QE),i=Object.values(e.modes).includes(`banner`);return(0,H.jsxs)(`div`,{className:`settings-pane`,children:[(0,H.jsx)(`h2`,{className:`settings-pane-title`,children:`Notifications`}),(0,H.jsx)(`p`,{className:`settings-pane-lede`,children:`When a chat you aren't looking at needs you or finishes. A banner also counts on the badge.`}),YE.map(t=>(0,H.jsxs)(`div`,{className:`setting-row`,children:[(0,H.jsx)(`span`,{id:`alert-${t.id}`,children:t.label}),(0,H.jsx)(`div`,{className:`segmented`,role:`radiogroup`,"aria-labelledby":`alert-${t.id}`,children:XE.map(n=>(0,H.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e.modes[t.id]===n.value,className:e.modes[t.id]===n.value?`is-active`:``,onClick:()=>e.setMode(t.id,n.value),children:n.label},n.value))})]},t.id)),!t&&i&&n!==`granted`&&(n==="default"?(0,H.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{Notification.requestPermission().then(r).catch(e=>{console.error(`[alerts] Notification permission request failed`,e),r(QE())})},children:`Allow banners in this browser`}):(0,H.jsx)(`p`,{className:`settings-error`,role:`alert`,children:n===`unsupported`?`This browser can't show banners; alerts appear in the chat list only.`:`This browser blocks banners from GAIA. Allow notifications for this site in the browser’s site settings.`})),(0,H.jsxs)(`label`,{className:`setting-row`,children:[(0,H.jsx)(`span`,{children:`Play a sound`}),(0,H.jsxs)(`span`,{className:`toggle-switch`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:e.sound,onChange:()=>e.update({sound:!e.sound}),"aria-label":`Play a sound`}),(0,H.jsx)(`span`,{className:`toggle-track`})]})]}),t&&(0,H.jsxs)(`label`,{className:`setting-row`,children:[(0,H.jsx)(`span`,{children:`Flash the taskbar when GAIA isn't focused`}),(0,H.jsxs)(`span`,{className:`toggle-switch`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:e.flash,onChange:()=>e.update({flash:!e.flash}),"aria-label":`Flash the taskbar when GAIA isn't focused`}),(0,H.jsx)(`span`,{className:`toggle-track`})]})]}),(0,H.jsx)(`h3`,{className:`settings-label`,children:`Keep awake`}),t?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`label`,{className:`setting-row`,children:[(0,H.jsx)(`span`,{children:`Keep the PC awake while GAIA works`}),(0,H.jsxs)(`span`,{className:`toggle-switch`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:e.keepAwake,onChange:()=>e.update({keepAwake:!e.keepAwake}),"aria-label":`Keep the PC awake while GAIA works`}),(0,H.jsx)(`span`,{className:`toggle-track`})]})]}),(0,H.jsxs)(`div`,{className:`setting-row`,children:[(0,H.jsx)(`label`,{htmlFor:`battery-floor`,children:`On battery, let it sleep below`}),(0,H.jsx)(`select`,{id:`battery-floor`,value:e.batteryFloor,disabled:!e.keepAwake,onChange:t=>e.update({batteryFloor:Number(t.target.value)}),children:ZE.map(e=>(0,H.jsx)(`option`,{value:e,children:e===0?`Never`:`${e}%`},e))})]}),(0,H.jsx)(`p`,{className:`settings-hint`,children:`The screen can still turn off; only sleep is held off.`})]}):(0,H.jsx)(`p`,{className:`settings-hint`,children:`Keep-awake needs the GAIA desktop app.`})]})}var eD=`modulepreload`,tD=function(e,t){return new URL(e,t).href},nD={},rD=function(e){return e.pathname.endsWith(`.css`)},iD=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},aD=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=tD(t,n);let r=s(t),i=rD(r);return iD(nD,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`:eD,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)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).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)})},oD=(0,B.lazy)(()=>aD(()=>import(`./ConnectorsPane-BMuJwbQS.js`).then(e=>({default:e.ConnectorsPane})),__vite__mapDeps([0,1,2,3]),import.meta.url)),sD=(0,B.lazy)(()=>aD(()=>import(`./AdvancedSettings-DlNYuBwr.js`).then(e=>({default:e.AdvancedSettings})),__vite__mapDeps([4,1,2,5]),import.meta.url)),cD=[{id:`general`,label:`General`},{id:`model`,label:`Model`},{id:`permissions`,label:`Permissions`},{id:`skills`,label:`Skills`},{id:`connectors`,label:`Connectors`},{id:`memory`,label:`Memory`},{id:`notifications`,label:`Notifications`},{id:`privacy`,label:`Privacy`},{id:`advanced`,label:`Advanced`}];function lD({onUseSkill:e}){let t=V(e=>e.settingsSection),n=V(e=>e.openSettings),r=V(e=>e.closeSettings),i=(0,B.useRef)(null),a=(0,B.useRef)(null),o=t!==null;if(c(o,r),kb(i,o),(0,B.useEffect)(()=>{if(o)return a.current=document.activeElement,()=>{a.current?.focus?.()}},[o,r]),(0,B.useEffect)(()=>{o&&i.current?.querySelector(`.settings-nav-item.is-active`)?.focus()},[o]),!t)return null;let s=(()=>{switch(t){case`general`:return(0,H.jsx)(XT,{});case`model`:return(0,H.jsx)(rE,{});case`permissions`:return(0,H.jsx)(iE,{});case`skills`:return(0,H.jsx)(aE,{onUseSkill:t=>{r(),e(t)}});case`connectors`:return(0,H.jsx)(oD,{});case`memory`:return(0,H.jsx)(HE,{});case`notifications`:return(0,H.jsx)($E,{});case`privacy`:return(0,H.jsx)(JE,{});case`advanced`:return(0,H.jsx)(sD,{})}})();return(0,H.jsx)(`div`,{className:`settings-overlay`,onMouseDown:e=>{e.target===e.currentTarget&&r()},children:(0,H.jsxs)(`div`,{ref:i,className:`settings-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Settings`,children:[(0,H.jsxs)(`nav`,{className:`settings-nav`,"aria-label":`Settings sections`,children:[(0,H.jsx)(`h1`,{className:`settings-nav-title`,children:`Settings`}),cD.map(e=>(0,H.jsx)(`button`,{type:`button`,"data-section":e.id,className:`settings-nav-item${t===e.id?` is-active`:``}`,"aria-current":t===e.id?`page`:void 0,onClick:t=>{t.currentTarget.focus(),n(e.id)},children:e.label},e.id))]}),(0,H.jsxs)(`div`,{className:`settings-body`,children:[(0,H.jsx)(`button`,{type:`button`,className:`settings-close`,onClick:r,"aria-label":`Close settings`,children:(0,H.jsx)(Nn,{size:18})}),(0,H.jsx)(B.Suspense,{fallback:(0,H.jsxs)(`p`,{className:`settings-hint`,children:[(0,H.jsx)(z,{size:13,className:`spin`}),` Loading…`]}),children:s})]})]})})}function uD(e,t){let[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(!1),o=(0,B.useRef)(null),s=(0,B.useRef)(null),c=(0,B.useRef)(null),l=(0,B.useCallback)(()=>{o.current&&=(clearTimeout(o.current),null),s.current&&=(clearTimeout(s.current),null),c.current&&=(clearInterval(c.current),null)},[]);(0,B.useEffect)(()=>l,[l]);let d=(0,B.useCallback)((e,t)=>{c.current&&clearInterval(c.current),c.current=setInterval(async()=>{try{let n=await Ai();t===`load`?n.model_loaded?.toLowerCase()===e.toLowerCase()&&(r(!1),o.current&&=(clearTimeout(o.current),null),c.current&&=(clearInterval(c.current),null)):(n.model_downloaded===!0||n.model_loaded?.toLowerCase()===e.toLowerCase())&&(a(!1),s.current&&=(clearTimeout(s.current),null),c.current&&=(clearInterval(c.current),null))}catch{}},Yw)},[]),f=e??`Gemma-4-E4B-it-GGUF`;return{isLoadingModel:n,isDownloadingModel:i,loadModel:(0,B.useCallback)(async(e,t)=>{let n=e??f,i=t??32768;r(!0);try{if(!await Ri(n,i)){r(!1);return}u.system.info(`Load model triggered: ${n} (ctx=${i})`),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>r(!1),qw),d(n,`load`)}catch(e){u.system.error(`Failed to trigger model load`,e),r(!1)}},[f,t,d]),downloadModel:(0,B.useCallback)(async(e=!1,t)=>{let n=t??f;a(!0);try{await zi(n,e),u.system.info(`Download model triggered: ${n} (force=${e})`),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>a(!1),Jw),d(n,`download`)}catch(e){u.system.error(`Failed to trigger model download`,e),a(!1)}},[f,d])}}var dD=5e3,fD=2e3,pD=3e4,mD=6e4;function hD(e){return e.lemonade_running?`up`:e.lemonade_error?`unresponsive`:`down`}function gD(e){return e.kind===`slow`||e.kind===`error`||e.kind===`ok`&&hD(e.status)===`unresponsive`}function _D(e){let t=e.kind===`ok`?e.status.download_progress?.state:void 0;return t===`downloading`||t===`starting`}function vD(e){let t=null,n=0,r=!1,i=null,a=0,o=null,s=async()=>{let e={controller:new AbortController,cancelled:!1};o=e;let{controller:t}=e,n=setTimeout(()=>t.abort(),mD);try{return{kind:`ok`,status:await Ai(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),o===e&&(o=null)}},c=()=>{if(t)return t;let i=s().then(t=>{if(t!==null){n=gD(t)?n+1:0,r=_D(t);try{e(t)}catch(e){u.system.error(`Could not apply the system status; the next poll will try again`,e)}}}).finally(()=>{t===i&&(t=null)});return t=i,i},l=()=>Math.min((r?fD:dD)*2**n,pD),d=e=>{c().finally(()=>{e===a&&(i=setTimeout(()=>d(e),l()))})};return{check:c,start:()=>{let e=++a;return d(e),()=>{e===a&&(a++,i&&clearTimeout(i),i=null,o&&(o.cancelled=!0,o.controller.abort(),o=null,t=null))}}}}function yD({onRetry:e,label:t}){let[n,r]=(0,B.useState)(!1);return(0,H.jsx)(`button`,{className:`connection-banner__retry`,onClick:()=>{r(!0),Promise.resolve(e()).finally(()=>r(!1))},disabled:n,children:n?`Checking…`:t})}function bD({onRetry:e,backendSlow:t=!1,backendError:n=null}){let{backendConnected:r,systemStatus:i,currentSessionId:a,messages:o}=V(),[s,c]=(0,B.useState)(!1),l=!!a&&o.length>0,u=i?.default_model_name??`Gemma-4-E4B-it-GGUF`,{isDownloadingModel:d,downloadModel:f}=uD(u),p=(0,B.useRef)(i?.lemonade_running),m=(0,B.useRef)(i?.model_downloaded),h=(0,B.useRef)(i?.context_size_sufficient),g=(0,B.useRef)(i?.expected_model_loaded);(0,B.useEffect)(()=>{if(l)return;let e=i?.lemonade_running,t=i?.model_downloaded,n=i?.context_size_sufficient,r=i?.expected_model_loaded,a=!1;p.current!==e&&(p.current=e,e===!1&&(a=!0)),m.current!==t&&(m.current=t,t===!1&&(a=!0)),h.current!==n&&(h.current=n,n===!1&&(a=!0)),g.current!==r&&(g.current=r,r===!1&&(a=!0)),a&&c(!1)},[i,l]);let _=i?.download_progress??null,v=_?.model_name||u;if(d||_?.state===`downloading`||_?.state===`starting`||_?.state===`error`){let e=_?.total_bytes?`${(_.total_bytes/1e9).toFixed(1)} GB`:`large download`,t=_?.state===`error`;return(0,H.jsxs)(`div`,{className:`connection-banner ${t?`connection-banner--error`:`connection-banner--warning`}`,role:t?`alert`:`status`,children:[(0,H.jsx)(`div`,{className:`connection-banner__icon`,children:t?(0,H.jsx)(Cn,{size:16}):(0,H.jsx)(Ne,{size:16})}),(0,H.jsx)(`div`,{className:`connection-banner__text`,children:t?(0,H.jsxs)(H.Fragment,{children:[`Download of `,(0,H.jsx)(`strong`,{children:v}),` failed.`,` `,_?.message&&(0,H.jsx)(`span`,{className:`connection-banner__hint`,children:_.message})]}):(0,H.jsxs)(H.Fragment,{children:[`Downloading `,(0,H.jsx)(`strong`,{children:v}),` (`,e,`).`,_?.state===`downloading`&&_.file&&(0,H.jsxs)(H.Fragment,{children:[` `,(0,H.jsxs)(`span`,{className:`connection-banner__hint`,children:[`File `,_.file_index,` / `,_.total_files,`: `,(0,H.jsx)(`code`,{children:_.file})]})]})]})}),t?(0,H.jsx)(`button`,{className:`connection-banner__retry`,onClick:()=>f(!1,v),children:`Retry`}):(0,H.jsx)(`span`,{className:`connection-banner__loading connection-banner__progress`,children:_&&_.state===`downloading`&&_.total_bytes>0?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`connection-banner__progress-bar`,role:`progressbar`,"aria-valuenow":_.percent,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`Download progress`,children:(0,H.jsx)(`span`,{className:`connection-banner__progress-fill`,style:{width:`${_.percent}%`}})}),(0,H.jsxs)(`span`,{className:`connection-banner__progress-label`,children:[_.percent,`% ·`,` `,(_.downloaded_bytes/1e9).toFixed(2),` /`,` `,(_.total_bytes/1e9).toFixed(2),` GB`]})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(z,{size:13,className:`connection-banner__spinner`}),_?.state===`starting`?`Starting download…`:`Downloading…`]})}),t&&(0,H.jsx)(`button`,{className:`connection-banner__dismiss`,onClick:()=>c(!0),"aria-label":`Dismiss`,children:(0,H.jsx)(Nn,{size:14})})]})}if(i?.init_state===`initializing`){let e=i.init_tasks?.find(e=>e.status===`running`)?.name||`Preparing AI system`;return(0,H.jsxs)(`div`,{className:`connection-banner connection-banner--init`,role:`status`,children:[(0,H.jsx)(`div`,{className:`connection-banner__icon`,children:(0,H.jsx)(z,{size:16,className:`connection-banner__spinner`})}),(0,H.jsxs)(`div`,{className:`connection-banner__text`,children:[e,(0,H.jsxs)(`span`,{className:`thinking-dots`,children:[(0,H.jsx)(`span`,{children:`.`}),(0,H.jsx)(`span`,{children:`.`}),(0,H.jsx)(`span`,{children:`.`})]})]})]})}if(s||l)return null;if(!r)return(0,H.jsxs)(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[(0,H.jsx)(`div`,{className:`connection-banner__icon`,children:(0,H.jsx)(kn,{size:16})}),(0,H.jsxs)(`div`,{className:`connection-banner__text`,children:[`Lost the connection to GAIA.`,` `,(0,H.jsx)(`span`,{className:`connection-banner__hint`,children:`Check that GAIA is still running, then retry.`})]}),e&&(0,H.jsx)(yD,{onRetry:e,label:`Retry`})]});if(n)return(0,H.jsxs)(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[(0,H.jsx)(`div`,{className:`connection-banner__icon`,children:(0,H.jsx)(Cn,{size:16})}),(0,H.jsxs)(`div`,{className:`connection-banner__text`,children:[`GAIA's backend answered with an error (`,n,`).`,` `,(0,H.jsx)(`span`,{className:`connection-banner__hint`,children:`It may be overloaded. GAIA keeps checking; if it lasts, restart GAIA.`})]}),e&&(0,H.jsx)(yD,{onRetry:e,label:`Check again`})]});if(t)return(0,H.jsxs)(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[(0,H.jsx)(`div`,{className:`connection-banner__icon`,children:(0,H.jsx)(Cn,{size:16})}),(0,H.jsxs)(`div`,{className:`connection-banner__text`,children:[`GAIA is slow to answer.`,` `,(0,H.jsx)(`span`,{className:`connection-banner__hint`,children:`It may be busy with another chat or app. GAIA keeps checking.`})]}),e&&(0,H.jsx)(yD,{onRetry:e,label:`Check again`})]});if(i?.config_error)return(0,H.jsxs)(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[(0,H.jsx)(`div`,{className:`connection-banner__icon`,children:(0,H.jsx)(Cn,{size:16})}),(0,H.jsxs)(`div`,{className:`connection-banner__text`,children:[`GAIA settings could not be loaded.`,` `,(0,H.jsx)(`span`,{className:`connection-banner__hint`,children:i.config_error})]}),e&&(0,H.jsx)(yD,{onRetry:e,label:`Check again`})]});if(i&&!i.lemonade_running){let t=hD(i)===`unresponsive`;return(0,H.jsxs)(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[(0,H.jsx)(`div`,{className:`connection-banner__icon`,children:(0,H.jsx)(Cn,{size:16})}),(0,H.jsxs)(`div`,{className:`connection-banner__text`,children:[t?`The model server is not answering (${i.lemonade_error}). It may be busy with another app or loading a model.`:`The model server stopped responding.`,` `,i.start_command?(0,H.jsxs)(`span`,{className:`connection-banner__hint`,children:[t?`If it stays this way, restart it: `:`To start it by hand, run `,(0,H.jsx)(`code`,{children:i.start_command})]}):i.start_instruction&&(0,H.jsx)(`span`,{className:`connection-banner__hint`,children:i.start_instruction})]}),e&&(0,H.jsx)(yD,{onRetry:e,label:`Check again`}),(0,H.jsx)(`button`,{className:`connection-banner__dismiss`,onClick:()=>c(!0),"aria-label":`Dismiss`,children:(0,H.jsx)(Nn,{size:14})})]})}if(i&&i.lemonade_running&&i.model_loaded&&i.context_size_sufficient===!1){let t=i.model_context_size??0;return(0,H.jsxs)(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[(0,H.jsx)(`div`,{className:`connection-banner__icon`,children:(0,H.jsx)(yt,{size:16})}),(0,H.jsxs)(`div`,{className:`connection-banner__text`,children:[`LLM context window is too small (`,t.toLocaleString(),` tokens;`,` `,Gw.toLocaleString(),` required).`,` `,(0,H.jsx)(`span`,{className:`connection-banner__hint`,children:`Reload it with a larger context in Settings → Advanced.`})]}),e&&(0,H.jsx)(yD,{onRetry:e,label:`Check again`}),(0,H.jsx)(`button`,{className:`connection-banner__dismiss`,onClick:()=>c(!0),"aria-label":`Dismiss`,children:(0,H.jsx)(Nn,{size:14})})]})}return null}var xD={status:`idle`,version:null,progress:0,releaseNotes:null,error:null,currentVersion:null,pinnedVersion:null};function SD(){let[e,t]=(0,B.useState)({...xD});return(0,B.useEffect)(()=>{let e=window.gaiaUpdater;if(!e)return;let n=!0;e.getStatus().then(e=>{n&&e&&t(e)}).catch(()=>{});let r=e.onStatusChange(e=>{n&&e&&t(e)});return()=>{n=!1;try{r()}catch{}}},[]),e}function CD(){let e=SD(),[t,n]=(0,B.useState)(!1),r=(0,B.useCallback)(()=>{window.gaiaUpdater?.check().catch(()=>{})},[]);if(t||e.status===`idle`||e.status===`checking`||e.status===`disabled`)return null;if(e.status===`downloading`){let t=Math.max(0,Math.min(100,e.progress));return(0,H.jsxs)(`div`,{className:`update-chip update-chip--downloading`,role:`status`,"aria-live":`polite`,title:`Downloading update${e.version?` ${e.version}`:``}…`,children:[(0,H.jsx)(Ne,{size:13,className:`update-chip__icon`}),(0,H.jsxs)(`span`,{className:`update-chip__label`,children:[`Downloading update… `,t,`%`]})]})}return e.status===`available`?(0,H.jsxs)(`div`,{className:`update-chip update-chip--available`,role:`status`,title:e.releaseNotes||`A new version is available.`,children:[(0,H.jsx)(Ne,{size:13,className:`update-chip__icon`}),(0,H.jsxs)(`span`,{className:`update-chip__label`,children:[`Update available`,e.version?`: ${e.version}`:``]}),(0,H.jsx)(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>n(!0),"aria-label":`Dismiss update notification`,children:(0,H.jsx)(Nn,{size:11})})]}):e.status===`downloaded`?(0,H.jsxs)(`div`,{className:`update-chip update-chip--ready`,role:`status`,"aria-live":`polite`,children:[(0,H.jsx)(Xt,{size:13,className:`update-chip__icon`}),(0,H.jsx)(`button`,{type:`button`,className:`update-chip__action`,onClick:r,title:`Click to restart and apply the update`,children:`Update ready — restart to apply`})]}):e.status===`error`?(0,H.jsxs)(`div`,{className:`update-chip update-chip--error`,role:`status`,title:e.error||`Update check failed.`,children:[(0,H.jsx)(Cn,{size:13,className:`update-chip__icon`}),(0,H.jsx)(`span`,{className:`update-chip__label`,children:`Update check failed`}),(0,H.jsx)(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>n(!0),"aria-label":`Dismiss update error`,children:(0,H.jsx)(Nn,{size:11})})]}):null}var wD={permission_request:{icon:(0,H.jsx)(an,{size:16}),colorClass:`notif-type-permission`,label:`Permission`},policy_alert:{icon:(0,H.jsx)(an,{size:16}),colorClass:`notif-type-policy`,label:`Policy`},security_alert:{icon:(0,H.jsx)(Cn,{size:16}),colorClass:`notif-type-security`,label:`Security`},status_change:{icon:(0,H.jsx)(he,{size:16}),colorClass:`notif-type-status`,label:`Status`},info:{icon:(0,H.jsx)(ht,{size:16}),colorClass:`notif-type-info`,label:`Info`},error:{icon:(0,H.jsx)(pe,{size:16}),colorClass:`notif-type-error`,label:`Error`}};function TD(e){let t=Date.now()-e,n=Math.floor(t/1e3);if(n<60)return`just now`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function ED({onClose:e}){let t=K(Hn(Cs)),n=K(Ss),r=K(e=>e.markRead),i=K(e=>e.markAllRead),a=K(e=>e.clearAll),o=K(e=>e.dismiss),s=K(e=>e.respondToPermission),l=K(e=>e.typeFilter),u=K(e=>e.setTypeFilter),d=(0,B.useCallback)(e=>{r(e)},[r]),f=(0,B.useCallback)(e=>{s(e.id,`allow`).catch(e=>console.error(`[NotificationCenter] allow failed:`,e))},[s]),p=(0,B.useCallback)(e=>{s(e.id,`deny`).catch(e=>console.error(`[NotificationCenter] deny failed:`,e))},[s]);return c(!0,e),(0,H.jsxs)(`div`,{className:`notification-center`,role:`dialog`,"aria-label":`Notification Center`,children:[(0,H.jsxs)(`div`,{className:`notification-center-header`,children:[(0,H.jsxs)(`div`,{className:`notification-center-title-row`,children:[(0,H.jsx)(`h2`,{className:`notification-center-title`,children:`Notifications`}),n>0&&(0,H.jsx)(`span`,{className:`notification-center-badge`,children:n})]}),(0,H.jsx)(`button`,{className:`btn-icon notification-center-close`,onClick:e,"aria-label":`Close notification center`,children:(0,H.jsx)(Nn,{size:18})})]}),(0,H.jsx)(`div`,{className:`notification-filter-bar`,role:`tablist`,"aria-label":`Filter notifications`,children:[{key:null,label:`All`},{key:`permission_request`,label:`Permissions`},{key:`policy_alert`,label:`Policy`},{key:`error`,label:`Errors`},{key:`security_alert`,label:`Security`},{key:`status_change`,label:`Status`},{key:`info`,label:`Info`}].map(e=>(0,H.jsx)(`button`,{role:`tab`,"aria-selected":l===e.key,className:`notification-filter-tab ${l===e.key?`active`:``}`,onClick:()=>u(e.key),children:e.label},e.key??`all`))}),(0,H.jsx)(`div`,{className:`notification-list`,children:t.length===0?(0,H.jsxs)(`div`,{className:`notification-empty`,children:[(0,H.jsx)(O,{size:40,strokeWidth:1.2}),(0,H.jsx)(`span`,{children:`No notifications`})]}):t.map(e=>{let t=wD[e.type];return(0,H.jsxs)(`div`,{className:`notification-item ${e.read?``:`unread`} ${t.colorClass}`,id:e.type===`policy_alert`&&e.receiptId?`policy-receipt-${encodeURIComponent(e.receiptId)}`:void 0,onClick:()=>d(e.id),role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&d(e.id)},children:[!e.read&&(0,H.jsx)(`span`,{className:`notification-unread-dot`}),(0,H.jsx)(`span`,{className:`notification-icon`,children:t.icon}),(0,H.jsxs)(`div`,{className:`notification-content`,children:[(0,H.jsxs)(`div`,{className:`notification-content-header`,children:[(0,H.jsx)(`span`,{className:`notification-agent`,children:e.agentName}),(0,H.jsx)(`span`,{className:`notification-time`,children:TD(e.timestamp)})]}),e.title&&(0,H.jsx)(`span`,{className:`notification-title`,children:e.title}),(0,H.jsx)(`span`,{className:`notification-message`,children:e.message}),e.type===`permission_request`&&e.tool&&e.tool!==`allow_path_access`&&(0,H.jsxs)(`span`,{className:`notification-tool`,children:[`Tool: `,(0,H.jsx)(`code`,{children:e.tool})]}),e.type===`policy_alert`&&(0,H.jsxs)(`div`,{className:`notification-policy-details`,children:[e.tool&&(0,H.jsxs)(`span`,{className:`notification-tool`,children:[`Tool: `,(0,H.jsx)(`code`,{children:e.tool})]}),e.reason&&(0,H.jsxs)(`span`,{className:`notification-policy-reason`,children:[`Reason: `,e.reason]}),e.ruleIds&&e.ruleIds.length>0&&(0,H.jsxs)(`span`,{className:`notification-tool`,children:[`Rules: `,(0,H.jsx)(`code`,{children:e.ruleIds.join(`, `)})]}),e.policyVersion&&(0,H.jsxs)(`span`,{className:`notification-tool`,children:[`Policy: `,(0,H.jsx)(`code`,{children:e.policyVersion})]}),(0,H.jsxs)(`span`,{className:`notification-tool`,children:[`Receipt:`,` `,e.receiptId?(0,H.jsx)(`code`,{children:e.receiptId}):(0,H.jsx)(`em`,{children:`Receipt unavailable`})]})]}),e.type===`permission_request`&&!e.response&&(0,H.jsxs)(`div`,{className:`notification-actions`,children:[(0,H.jsxs)(`button`,{className:`notification-action-btn notification-action-allow`,onClick:t=>{t.stopPropagation(),f(e)},children:[(0,H.jsx)(ae,{size:14}),`Approve`]}),(0,H.jsxs)(`button`,{className:`notification-action-btn notification-action-deny`,onClick:t=>{t.stopPropagation(),p(e)},children:[(0,H.jsx)(Nn,{size:14}),`Deny`]})]}),e.type===`permission_request`&&e.response&&(0,H.jsx)(`span`,{className:`notification-response-badge ${e.response===`allow`?`response-allow`:`response-deny`}`,children:e.response===`allow`?`Approved`:`Denied`})]}),(0,H.jsx)(`button`,{className:`notification-dismiss`,onClick:t=>{t.stopPropagation(),o(e.id)},"aria-label":`Dismiss notification`,children:(0,H.jsx)(Nn,{size:14})})]},e.id)})}),t.length>0&&(0,H.jsxs)(`div`,{className:`notification-center-footer`,children:[(0,H.jsxs)(`button`,{className:`notification-footer-btn`,onClick:i,disabled:n===0,children:[(0,H.jsx)(ae,{size:14}),`Mark All Read`]}),(0,H.jsxs)(`button`,{className:`notification-footer-btn notification-footer-clear`,onClick:a,children:[(0,H.jsx)(xn,{size:14}),`Clear`]})]})]})}var DD=1500,OD=e=>new Promise(t=>setTimeout(t,e));async function kD({onProgress:e,isCancelled:t=()=>!1,pollMs:n=DD}={}){try{await Vi(Bw)}catch(e){if(e?.httpStatus!==409)throw e;let t=await Hi(Bw).catch(()=>null);if(!t||t.status===`completed`||t.status===`failed`)throw e}for(;!t();){let t=await Hi(Bw);if(e?.(t),t.status===`completed`)return;if(t.status===`failed`)throw Error(t.error||`The GAIA agent could not be installed.`);await OD(n)}}function AD({onInstalled:e}){let[t,n]=(0,B.useState)({kind:`idle`}),r=(0,B.useRef)(!1);(0,B.useEffect)(()=>()=>{r.current=!0},[]);let i=(0,B.useCallback)(async()=>{n({kind:`installing`,percent:0});try{if(await kD({isCancelled:()=>r.current,onProgress:e=>{r.current||n({kind:`installing`,percent:e.percent??0})}}),r.current)return;await e(),r.current||n({kind:`idle`})}catch(e){r.current||n({kind:`failed`,error:e instanceof Error?e.message:String(e)})}},[e]);return(0,H.jsxs)(`div`,{className:`app-notice is-warning`,role:`status`,children:[t.kind===`installing`?(0,H.jsxs)(`span`,{children:[`Installing the GAIA agent… `,Math.round(t.percent),`%`]}):t.kind===`failed`?(0,H.jsxs)(`span`,{children:[`The GAIA agent could not be installed: `,t.error]}):(0,H.jsx)(`span`,{children:`The GAIA agent isn't installed, so new chats can't start yet.`}),t.kind!==`installing`&&(0,H.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>void i(),children:t.kind===`failed`?`Try again`:`Install GAIA agent`})]})}function jD(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}function MD(e,t){let{addNotification:n}=K.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:`Scheduled task "${r.name}" failed`,message:r.last_error,timestamp:Date.now(),read:!1,dismissed:!1,priority:`high`,...r.session_id?{sessionId:r.session_id}:{}})}var ND=Jn((e,t)=>({schedules:[],loading:!1,error:null,selectedSchedule:null,results:[],resultsLoading:!1,errorCounts:null,loadSchedules:async()=>{t().schedules.length===0&&!t().error&&e({loading:!0}),e({error:null});try{let n=(await uo()).schedules||[],r=t().errorCounts;r&&MD(r,n),e({schedules:n,loading:!1,errorCounts:Object.fromEntries(n.map(e=>[e.id,e.error_count]))})}catch(t){u.api.error(`Failed to load schedules`,t),e({error:`Failed to load schedules`,loading:!1})}},createSchedule:async(t,n,r)=>{try{let i=await po(t,n,r);e(e=>({schedules:[...e.schedules,i],error:null}))}catch(t){let n=jD(t,`Failed to create schedule`);throw u.api.error(`Failed to create schedule`,t),e({error:n}),t}},updateScheduleStatus:async(t,n)=>{try{let r=await mo(t,n);e(e=>({schedules:e.schedules.map(e=>e.name===t?r:e),error:null}))}catch(n){u.api.error(`Failed to update schedule "${t}"`,n),e({error:jD(n,`Failed to update schedule`)})}},deleteSchedule:async t=>{try{await ho(t),e(e=>({schedules:e.schedules.filter(e=>e.name!==t),selectedSchedule:e.selectedSchedule===t?null:e.selectedSchedule,error:null}))}catch(n){u.api.error(`Failed to delete schedule "${t}"`,n),e({error:jD(n,`Failed to delete schedule`)})}},selectSchedule:n=>{e({selectedSchedule:n,results:[]}),n&&t().loadResults(n)},loadResults:async t=>{e({resultsLoading:!0});try{e({results:(await go(t)).results||[],resultsLoading:!1})}catch(n){u.api.error(`Failed to load results for "${t}"`,n),e({results:[],resultsLoading:!1})}}})),PD=new Set([`loading_model`,`downloading_model`,`model_retry`,`waiting`]),FD=5;function ID(e,t){return{id:e,title:t.get(e)?.title??`Untitled chat`}}function LD(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=>({...ID(e,t),reason:`approval`}));n&&e.awaitingUser&&!a.has(e.currentSessionId)&&o.push({...ID(e.currentSessionId,t),reason:`answer`});for(let[n,r]of Object.entries(e.awaitingBySession))o.some(e=>e.id===n)||o.push({...ID(n,t),reason:r===`question`?`answer`:`approval`});let s=n&&!e.awaitingUser&&e.livePhase&&PD.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,FD).map(e=>ID(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=>ID(e,t)),needsYou:o,recent:u}}function RD(e){let t=(0,B.useRef)(e);t.current=e,(0,B.useEffect)(()=>{let e=window.gaiaAPI?.tray;if(!e)return;let n=``,r=null,i=()=>{let t=V.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:K.getState().notifications},a=r;if(r=i,a&&Object.keys(i).every(e=>i[e]===a[e]))return;let o=LD(i),s=JSON.stringify(o);s!==n&&(n=s,e.setActivity(o).catch(e=>{n=``,u.system.error(`The tray could not take the app state`,e)}))};i();let a=V.subscribe(i),o=K.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`:V.getState().openSettings(e.section);break;case`refresh-status`:t.current.refreshStatus();break;default:u.system.error(`Unknown tray command`,e)}});return()=>{a(),o(),s()}},[])}function zD(){(0,B.useEffect)(()=>{let e=window.gaiaAPI;if(!e)return;let t=K.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=V.getState();n.currentSessionId!==t&&n.setMessages([]),n.setCurrentSession(t)})];return()=>n.forEach(e=>e())},[])}function BD(e,t,n){let r=window.gaiaAPI;if(r){r.notification.show({title:t,body:n,sessionId:e}).then(e=>{e||u.system.warn(`This OS has no desktop notifications; the badge still counts it.`)}).catch(e=>u.system.error(`Could not show the desktop notification`,e));return}if(typeof Notification>`u`){u.system.warn(`This browser has no notifications; the alert was not shown.`);return}if(Notification.permission!==`granted`){u.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(),V.getState().setCurrentSession(e)}}function VD(){let[e,t]=(0,B.useState)(null);return(0,B.useEffect)(()=>{let e=navigator;if(!e.getBattery)return;let n=null,r=()=>{n&&t({charging:n.charging,level:n.level})};return e.getBattery().then(e=>{n=e,r(),e.addEventListener(`levelchange`,r),e.addEventListener(`chargingchange`,r)}).catch(e=>u.system.warn(`Battery level unavailable; keep-awake ignores the battery policy.`,e)),()=>{n?.removeEventListener(`levelchange`,r),n?.removeEventListener(`chargingchange`,r)}},[]),e}function HD(){zD();let e=V(e=>e.runningSessionIds),t=V(e=>e.awaitingBySession),n=V(e=>e.sessions),r=V(e=>e.currentSessionId),i=K(Hn(Ts)),a=Ms(),o=VD(),s=(0,B.useRef)(null),c=zs(e,t,i),l=JSON.stringify(c);(0,B.useEffect)(()=>{let e=JSON.parse(l),t=s.current;if(s.current=e,t===null)return;let{sessions:n,currentSessionId:r}=V.getState(),i=document.hasFocus(),o=!1;for(let{sessionId:s,event:c}of Bs(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`||Us(s,r,i))&&(o=!0,t===`banner`)){if(c!==`finished`){let{title:t,body:n}=Hs(c,e);BD(s,t,n)}else ya(s).then(e=>{V.getState().updateSessionInList(s,e);let{title:t,body:n}=Hs(c,e);BD(s,t,n)}).catch(t=>{u.system.error(`Could not read how chat ${s} ended`,t);let{title:n,body:r}=Hs(c,{...e,last_run_status:null});BD(s,n,r)})}}if(o){if(a.sound)try{Ks()}catch(e){u.system.warn(`Alert sound not played`,e)}a.flash&&!i&&window.gaiaAPI&&window.gaiaAPI.notification.flash().catch(e=>u.system.error(`Could not flash the taskbar button`,e))}},[l,a.modes,a.sound,a.flash]);let d=Ws(n,c,a.modes,r);(0,B.useEffect)(()=>{window.gaiaAPI?.notification.setAttentionCount(d).catch(e=>u.system.error(`Could not update the taskbar badge`,e))},[d]);let f=a.keepAwake&&e.length>0&&Gs(o,a.batteryFloor);(0,B.useEffect)(()=>{window.gaiaAPI?.power.setKeepAwake(f).catch(e=>u.system.error(`Could not change keep-awake`,e))},[f])}function UD(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 WD(e){return e.replace(/-/g,``).slice(0,7)}function GD(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 KD(e,t,n){return!e||t&&(e===t||e===WD(t))?null:n.some(t=>t.id===e)?e:GD(n,e)}function qD(e){return new URLSearchParams(e.search).get(`session`)||e.hash.replace(/^#/,``)||null}var JD=1e3,YD=3e4;function XD(e,{initialMs:t=JD,maxMs:n=YD,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}}var ZD=(0,B.lazy)(()=>aD(()=>import(`./MemoryDashboard-CI0XsMok.js`).then(e=>({default:e.MemoryDashboard})),__vite__mapDeps([6,1,2,7,8,9]),import.meta.url)),QD=(0,B.lazy)(()=>aD(()=>import(`./ScheduleManager-ia8OmdHV.js`).then(e=>({default:e.ScheduleManager})),__vite__mapDeps([10,1,2,8,11]),import.meta.url)),$D=(0,B.lazy)(()=>aD(()=>import(`./DocumentLibrary-BBkaVGFa.js`).then(e=>({default:e.DocumentLibrary})),__vite__mapDeps([12,1,2,13]),import.meta.url)),eO=(0,B.lazy)(()=>aD(()=>import(`./FileBrowser-B3rdG7Th.js`).then(e=>({default:e.FileBrowser})),__vite__mapDeps([14,1,2,7,15]),import.meta.url)),tO=(0,B.lazy)(()=>aD(()=>import(`./MobileAccessModal-Bt5XREFP.js`).then(e=>({default:e.MobileAccessModal})),__vite__mapDeps([16,1,2,17]),import.meta.url)),nO=3,rO=3e5,iO=6e3;function aO(){return(0,H.jsx)(`div`,{className:`loading-spinner`,role:`status`,"aria-label":`Loading`})}var oO=e=>e===1||e%10==0;function sO(){let e=V(e=>e.currentSessionId),t=V(e=>e.setSessions),n=V(e=>e.setCurrentSession),r=V(e=>e.addSession),a=V(e=>e.setMessages),o=V(e=>e.resetStreaming),s=V(e=>e.showDocLibrary),c=V(e=>e.showFileBrowser),l=V(e=>e.showMemoryDashboard),f=V(e=>e.showSchedules),p=V(e=>e.sidebarOpen),m=V(e=>e.setSidebarOpen),h=V(e=>e.setSystemStatus),g=V(e=>e.setBackendConnected),_=V(e=>e.setAgents),v=V(e=>e.agents),y=V(e=>e.setPendingPrompt),b=V(e=>e.setDefaultPermissionMode),x=V(e=>e.openSettings),S=V(e=>e.settingsSection),C=V(e=>e.syncSystemTheme),w=Uo(e=>e.restoreNotice),T=Uo(e=>e.dismissRestoreNotice),E=K(e=>e.showPanel),D=V(e=>e.systemStatus?.initialized===!0),O=K(e=>e.setShowPanel);(0,B.useEffect)(()=>{if(!w?.ok)return;let e=setTimeout(T,iO);return()=>clearTimeout(e)},[w,T]);let[k,A]=(0,B.useState)({state:`checking`}),j=(0,B.useRef)(k);j.current=k;let[M,N]=(0,B.useState)(!1),ee=(0,B.useRef)(M);ee.current=M;let[P,te]=(0,B.useState)(!1),ne=P||M&&!Vw(v),re=(0,B.useRef)(ne);re.current=ne;let[ie,ae]=(0,B.useState)(null),[oe,se]=(0,B.useState)(``),[ce,le]=(0,B.useState)(0),[ue,de]=(0,B.useState)(!1),[fe,pe]=(0,B.useState)(!1),[me,he]=(0,B.useState)(null),F=(0,B.useCallback)(async(e=!1)=>{e||A({state:`checking`});try{await Uo.getState().refresh();let e=Uo.getState().active,t=await Wi(!!e?.remote);A(t.ready?{state:`ready`}:{state:`needed`,check:t})}catch(e){let t=e instanceof Error?e.message:String(e);u.system.warn(`Setup check could not be answered`,e),A({state:`unknown`,error:t})}},[]),I=(0,B.useRef)(0),L=(0,B.useCallback)(async()=>{let e=++I.current,t=(await Bi()).agents||[];e===I.current&&(_(t),N(!0),Vw(t)&&te(!1))},[_]),ge=(0,B.useCallback)(()=>{let e=ee.current;N(!1),L().catch(t=>{u.api.warn(`Agent list unavailable after setup`,t),e&&N(!0)})},[L]);(0,B.useEffect)(()=>{let e=()=>{re.current&&L().catch(e=>u.api.warn(`Agent list unavailable`,e))};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[L]);let _e=(0,B.useCallback)(async()=>{b((await gi()).default_mode)},[b]),ve=(0,B.useRef)([]);(0,B.useEffect)(()=>{i(`0.25.2rc2`),F();let e=[XD(L,{onError:(e,t)=>{oO(t)&&u.api.warn(`Agent list unavailable (attempt ${t}); retrying`,e)}}),XD(_e,{onError:(e,t)=>{oO(t)&&u.api.warn(`Default permission mode unavailable (attempt ${t}); retrying`,e)}})];return ve.current=e,()=>e.forEach(e=>e.stop())},[F,L,_e]);let ye=(0,B.useCallback)(()=>{ve.current.forEach(e=>e.kick()),Uo.getState().retryNow(),j.current.state===`unknown`&&F(!0)},[F]),R=(0,B.useRef)(ye);R.current=ye;let be=(0,B.useRef)(0),xe=(0,B.useRef)(0),Se=(0,B.useRef)(null),Ce=(0,B.useRef)(!1),[we,Te]=(0,B.useState)(!1),[Ee,De]=(0,B.useState)(null),Oe=(0,B.useCallback)(e=>{if(e.kind===`unreachable`){u.system.warn(`System status check failed`,e.error),Ce.current=!0,xe.current=0,Se.current=null,Te(!1),De(null),g(!1),h(null);return}if(e.kind===`error`){u.system.warn(`System status answered HTTP ${e.httpStatus}`,e.message),Ce.current&&R.current(),Ce.current=!1,xe.current=0,Se.current=null,Te(!1),De(`HTTP ${e.httpStatus}: ${e.message}`),g(!0);return}if(e.kind===`slow`){if(xe.current+=1,Se.current??=Date.now(),De(null),u.system.warn(`System status did not answer in time (${xe.current} in a row)`),Date.now()-Se.current>=rO){Te(!1),g(!1),h(null);return}g(!0),(Ce.current||xe.current>=nO)&&Te(!0);return}let{status:t}=e;Ce.current&&R.current(),Ce.current=!1,xe.current=0,Se.current=null,Te(!1),De(null),g(!0),be.current=t.lemonade_running?0:be.current+1;let n=V.getState().systemStatus;t.lemonade_running||be.current>=nO||!n?.lemonade_running?h(t):h({...n,download_progress:t.download_progress})},[g,h]),ke=(0,B.useRef)(Oe);ke.current=Oe;let[Ae]=(0,B.useState)(()=>vD(e=>ke.current(e))),je=Ae.check;(0,B.useEffect)(()=>Qw(Ae.start),[Ae]);let Me=(0,B.useRef)(``);(0,B.useEffect)(()=>{let e=e=>{ha().then(n=>{let r=n.sessions||[];if(!e&&r.length===0&&V.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(`
79
79
  `);if(i===Me.current)return;Me.current=i,t(r);let a=Uo.getState().active?.model;a&&r.some(e=>e.effective_model&&e.effective_model!==a)&&Uo.getState().refresh()}).catch(t=>{e&&u.system.error(`Could not load chats`,t)})};e(!0);let n=setInterval(()=>e(!1),5e3);return()=>clearInterval(n)},[t]),(0,B.useEffect)(()=>Ox(),[]),(0,B.useEffect)(()=>{let e=()=>{ND.getState().loadSchedules()};e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[]),(0,B.useEffect)(()=>Yx(),[]),HD();let Ne=(0,B.useRef)(!1);(0,B.useEffect)(()=>{let e=()=>{let e=qD(window.location),{currentSessionId:t,sessions:r}=V.getState(),i=KD(e,t,r);return i&&(n(i),a([])),i},t=()=>{Ne.current||(Ne.current=!0,!e()&&!V.getState().currentSessionId&&window.location.hash&&window.history.replaceState(null,``,window.location.pathname+window.location.search))},r=V.subscribe(e=>{e.sessions.length>0&&t()});return V.getState().sessions.length>0&&t(),window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{r(),window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[n,a]),(0,B.useEffect)(()=>{let e=null,t=2e3,r=!1,i=null,o=()=>{r||(e=new EventSource(`${d()}/sessions/events`),e.onopen=()=>{t=2e3},e.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch(e){u.api.warn(`Malformed session event`,e);return}t.type===`set_active_session`&&t.session_id&&t.session_id!==V.getState().currentSessionId&&(n(t.session_id),a([]))},e.onerror=()=>{e?.close(),e=null,!r&&(i=setTimeout(o,t),t=Math.min(t*2,3e4))})};return o(),()=>{r=!0,i&&clearTimeout(i),e?.close()}},[n,a]),(0,B.useEffect)(()=>{if(e){let t=WD(e);window.location.hash!==`#${t}`&&window.history.replaceState(null,``,`#${t}`)}else Ne.current&&window.location.hash&&window.history.replaceState(null,``,window.location.pathname+window.location.search)},[e]);let Pe=(0,B.useCallback)(async e=>{ae(null);let t=V.getState(),i;try{i=await ga({title:`New Task`,agent_type:Bw,document_ids:t.draftDocumentIds,private:t.draftPrivate})}catch(e){throw Hw(e)?(te(!0),Error(`The GAIA agent isn't installed. Install it from the notice above, then send again.`)):e}re.current&&(te(!1),L().catch(e=>u.api.warn(`Agent list unavailable`,e))),t.defaultPermissionModeKnown||(await _e().catch(e=>u.api.warn(`Default permission mode unavailable; using the chip's mode`,e)),t=V.getState()),t.clearDraftDocuments(),t.setDraftPrivate(!1),r(i),n(i.id),a([]),se(``);try{await _i(i.id,t.draftPermissionMode)}catch(e){return ae(`The chat was created, but its permission mode could not be set, so your message was not sent: ${e instanceof Error?e.message:e}`),!1}return t.resetDraftPermissionMode(),y(e),!0},[r,n,a,y,L,_e]),Fe=(0,B.useCallback)(()=>{let e=V.getState(),t=e.currentSessionId;t&&ec(t,e)&&tc(t),e.setShowMemoryDashboard(!1),e.setShowSchedules(!1),n(null),a([]),le(e=>e+1)},[n,a]);RD({openChat:(0,B.useCallback)(e=>{let t=V.getState();t.closeSettings(),e!==t.currentSessionId&&(tc(t.currentSessionId),a([])),n(e)},[n,a]),newChat:(0,B.useCallback)(()=>{V.getState().closeSettings(),Fe()},[Fe]),refreshStatus:()=>void je()});let Ie=(0,B.useCallback)(e=>{Fe(),Pe(`Load the \`${e}\` skill, then tell me briefly what it lets you do.`).catch(e=>ae(e instanceof Error?e.message:String(e)))},[Fe,Pe]),Le=(0,B.useCallback)(e=>{A({state:`ready`}),ge(),je(),e&&(e.needs_input?se(e.prompt):Pe(e.prompt).catch(e=>ae(e instanceof Error?e.message:String(e))))},[je,Pe,ge]);(0,B.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&(e.shiftKey&&e.key.toLowerCase()===`o`?(e.preventDefault(),Fe()):!e.shiftKey&&e.key.toLowerCase()===`k`?(e.preventDefault(),window.dispatchEvent(new CustomEvent(`gaia:focus-search`))):!e.shiftKey&&e.key.toLowerCase()===`b`?(e.preventDefault(),V.getState().toggleSidebarCollapsed()):!e.shiftKey&&e.key===`,`&&(e.preventDefault(),x()))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Fe,x]),(0,B.useEffect)(()=>{let e=window.matchMedia?.(`(max-width: 768px)`);if(!e)return;let t=()=>m(!e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[m]),(0,B.useEffect)(()=>{if(typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(prefers-color-scheme: light)`);return e.addEventListener(`change`,C),()=>e.removeEventListener(`change`,C)},[C]),(0,B.useEffect)(()=>{o()},[e,o]),(0,B.useEffect)(()=>{co().then(e=>pe(e.active===!0)).catch(e=>u.system.debug(`Mobile access unavailable`,e))},[]);let Re=(0,B.useCallback)(async()=>{if(de(!0),he(null),!fe)try{let e=await oo();e.error?he(e.error):pe(!0)}catch(e){he(e instanceof Error?e.message:`Could not start mobile access`)}},[fe]),ze=(0,B.useCallback)(async()=>{try{await so(),pe(!1),de(!1)}catch(e){he(e instanceof Error?e.message:`Could not stop mobile access`)}},[]);KC(e=>{e?Re():ze()}),(0,B.useEffect)(()=>{WC(fe)},[fe]);let Be=typeof window<`u`&&window.innerWidth<=768;if(k.state===`checking`&&!D)return(0,H.jsx)(`div`,{className:`app`,children:(0,H.jsxs)(`main`,{className:`startup`,role:`status`,"aria-label":`Starting GAIA`,children:[(0,H.jsx)(`div`,{className:`loading-spinner`,"aria-hidden":`true`}),(0,H.jsx)(`p`,{className:`startup-text`,children:`Starting GAIA…`})]})});if(k.state===`needed`)return(0,H.jsx)(`div`,{className:`app`,children:(0,H.jsx)(WT,{initial:k.check,onReady:Le})});let Ve=l?(0,H.jsx)(B.Suspense,{fallback:(0,H.jsx)(aO,{}),children:(0,H.jsx)(ZD,{})}):f?(0,H.jsx)(B.Suspense,{fallback:(0,H.jsx)(aO,{}),children:(0,H.jsx)(QD,{})}):e?(0,H.jsx)(dT,{sessionId:e},e):(0,H.jsx)(ET,{onSend:Pe,initialText:oe,focusRequest:ce},oe);return(0,H.jsxs)(`div`,{className:`app`,children:[!p&&(0,H.jsx)(`button`,{className:`sidebar-toggle`,onClick:()=>m(!0),"aria-label":`Open sidebar`,children:(0,H.jsx)(Ot,{size:18})}),(0,H.jsx)(`div`,{className:`sidebar-overlay ${p?`visible`:``}`,onClick:()=>m(!1),"aria-hidden":`true`}),(0,H.jsx)(pc,{onNewChat:Fe,onMobileAccess:Be?void 0:()=>void Re(),tunnelActive:fe}),(0,H.jsxs)(`div`,{className:`main-content`,children:[k.state===`ready`&&(0,H.jsx)(bD,{onRetry:je,backendSlow:we,backendError:Ee}),k.state===`unknown`&&(0,H.jsxs)(`div`,{className:`app-notice is-warning`,role:`status`,children:[(0,H.jsxs)(`span`,{children:[`Could not check whether GAIA is set up: `,k.error]}),(0,H.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>void F(),children:`Check again`})]}),ne&&(0,H.jsx)(AD,{onInstalled:L}),w&&(0,H.jsxs)(`div`,{className:`app-notice${w.ok?``:` is-warning`}`,role:`status`,children:[(0,H.jsx)(`span`,{children:w.message}),!w.ok&&(0,H.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>{T(),x(`model`)},children:`Pick a model`}),(0,H.jsx)(`button`,{type:`button`,className:`app-notice-close`,onClick:T,"aria-label":`Dismiss`,children:(0,H.jsx)(Nn,{size:14})})]}),Ve]}),s&&(0,H.jsx)(B.Suspense,{fallback:null,children:(0,H.jsx)($D,{})}),c&&(0,H.jsx)(B.Suspense,{fallback:null,children:(0,H.jsx)(eO,{})}),E&&(0,H.jsx)(`div`,{className:`notification-center-popover`,children:(0,H.jsx)(ED,{onClose:()=>O(!1)})}),ue&&(0,H.jsx)(B.Suspense,{fallback:null,children:(0,H.jsx)(tO,{isOpen:ue,onClose:()=>de(!1),onStop:()=>void ze(),error:me})}),S&&(0,H.jsx)(lD,{onUseSkill:Ie}),(0,H.jsx)(CD,{}),ie&&(0,H.jsx)(`div`,{className:`toast`,role:`alert`,children:ie})]})}fs(),$n();var cO=localStorage.getItem(`gaia-chat-theme`);Qn(Xn(cO===`light`||cO===`dark`?cO:`system`));var lO=V.getState();gr(lO.palette,lO.customColors,lO.theme),In.createRoot(document.getElementById(`root`)).render((0,H.jsx)(B.StrictMode,{children:(0,H.jsx)(sO,{})}));export{qa as $,Fe as $t,OE as A,ni as At,Kw as B,Cn as Bt,_E as C,ii as Ct,bE as D,Gr as Dt,gE as E,Xr as Et,PE as F,Fn as Ft,eS as G,Jt as Gt,iS as H,pn as Ht,zE as I,Nn as It,Go as J,Ct as Jt,kb as K,Mt as Kt,vE as L,jn as Lt,TE as M,Wr as Mt,wE as N,ti as Nt,IE as O,ei as Ot,EE as P,V as Pt,Ka as Q,Ge as Qt,ME as R,Dn as Rt,uE as S,Jr as St,lE as T,Yr as Tt,oS as U,en as Ut,Gw as V,xn as Vt,Qx as W,Xt as Wt,Qa as X,Ye as Xt,Xa as Y,tt as Yt,Ja as Z,qe as Zt,yE as _,Ga as _t,aD as a,ve as an,co as at,FE as b,Kr as bt,NE as c,pe as cn,Ri as ct,SE as d,se as dn,ao as dt,Ne as en,Xi as et,LE as f,ae as fn,Ya as ft,pE as g,Ii as gt,mE as h,Pi as ht,uD as i,R as in,Ai as it,CE as j,$r as jt,DE as k,Qr as kt,kE as l,de as ln,eo as lt,VE as m,E as mn,Qi as mt,ND as n,ke as nn,Ni as nt,RE as o,I as on,$a as ot,fE as p,M as pn,io as pt,Ys as q,z as qt,SD as r,Te as rn,Fi as rt,BE as s,he as sn,Ua as st,UD as t,je as tn,lo as tt,AE as u,le as un,_o as ut,xE as v,Wa as vt,jE as w,Zr as wt,dE as x,qr as xt,hE as y,ri as yt,DT as z,Tn as zt};