@amd-gaia/agent-ui 0.25.2-rc.6 → 0.25.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AdvancedSettings-BlYNI6AZ.js → AdvancedSettings-BtzKYr5B.js} +1 -1
- package/dist/assets/{ConnectorsPane-DtYVWxBo.js → ConnectorsPane-C8w7-TvW.js} +1 -1
- package/dist/assets/{DocumentLibrary-DBHK1rnR.js → DocumentLibrary-CDqFh5v6.js} +1 -1
- package/dist/assets/{FileBrowser-CSXzEgI5.js → FileBrowser-CIx8c6v3.js} +1 -1
- package/dist/assets/{MemoryDashboard-qcp2siub.js → MemoryDashboard-DpZxbN9N.js} +1 -1
- package/dist/assets/{MobileAccessModal-BU3rxH7C.js → MobileAccessModal-Xjac45ac.js} +1 -1
- package/dist/assets/{ScheduleManager-CHq7l6Ex.js → ScheduleManager-KHmfOhd7.js} +1 -1
- package/dist/assets/{index-DIGoe3Yc.js → index-Fhiym-Jy.js} +4 -4
- package/dist/index.html +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ConnectorsPane-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ConnectorsPane-C8w7-TvW.js","./rolldown-runtime-XKyaHtl9.js","./apiBase-CS6zLsJY.js","./ConnectorsPane-Dzu2DRTc.css","./AdvancedSettings-BtzKYr5B.js","./MemoryDashboard-DpZxbN9N.js","./message-square-CLnmengs.js","./MemoryDashboard-Mo721-BI.css","./ScheduleManager-KHmfOhd7.js","./ScheduleManager-DotJl5JW.css","./DocumentLibrary-CDqFh5v6.js","./DocumentLibrary-CIKp6qld.css","./FileBrowser-CIx8c6v3.js","./FileBrowser-Dil1lZJ4.css","./MobileAccessModal-Xjac45ac.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,i,n as a,o,r as s,t as c}from"./apiBase-CS6zLsJY.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 l=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&&A(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&&A(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,ee=k.port2;k.port1.onmessage=D,O=function(){ee.postMessage(null)}}else O=function(){_(D,0)};function A(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,A(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}}}})),u=n(((e,t)=>{t.exports=l()})),d=n((e=>{var t=o();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`),s=Symbol.for(`react.recoverable`),c=Symbol.for(`react.optimistic_key`);function l(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===c?c:``+r,children:e,containerInfo:t,implementation:n}}var u=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(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:s,_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 l(e,t,null,r)},e.flushSync=function(e){var t=u.T,n=i.p;try{if(u.T=null,i.p=2,e)return e()}finally{u.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=d(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=d(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=d(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=d(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 u.H.useFormState(e,t,n)},e.useFormStatus=function(){return u.H.useHostTransitionStatus()},e.version=`19.3.1`})),f=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=d()})),p=n((e=>{var t=u(),n=o(),r=f();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 s(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 c(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 l(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 d(e){if(s(e)!==e)throw Error(i(188))}function p(e){var t=e.alternate;if(!t){if(t=s(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 o=a.alternate;if(o===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===o.child){for(o=a.child;o;){if(o===n)return d(a),e;if(o===r)return d(a),t;o=o.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=o;else{for(var c=!1,l=a.child;l;){if(l===n){c=!0,n=a,r=o;break}if(l===r){c=!0,r=a,n=o;break}l=l.sibling}if(!c){for(l=o.child;l;){if(l===n){c=!0,n=o,r=a;break}if(l===r){c=!0,r=o,n=a;break}l=l.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 m(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=m(e),t!==null)return t;e=e.sibling}return null}function h(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)&&h(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function g(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=g(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`),ee=Symbol.for(`react.portal`),A=Symbol.for(`react.fragment`),j=Symbol.for(`react.strict_mode`),te=Symbol.for(`react.profiler`),M=Symbol.for(`react.consumer`),N=Symbol.for(`react.context`),P=Symbol.for(`react.forward_ref`),ne=Symbol.for(`react.suspense`),re=Symbol.for(`react.suspense_list`),ie=Symbol.for(`react.memo`),F=Symbol.for(`react.lazy`),ae=Symbol.for(`react.activity`),oe=Symbol.for(`react.legacy_hidden`),se=Symbol.for(`react.memo_cache_sentinel`),ce=Symbol.for(`react.view_transition`),le=Symbol.for(`react.recoverable`),ue=Symbol.iterator;function de(e){return typeof e!=`object`||!e?null:(e=ue&&e[ue]||e[`@@iterator`],typeof e==`function`?e:null)}var fe=Symbol.for(`react.client.reference`);function pe(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===fe?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case A:return`Fragment`;case te:return`Profiler`;case j:return`StrictMode`;case ne:return`Suspense`;case re:return`SuspenseList`;case ae:return`Activity`;case ce:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case ee:return`Portal`;case N:return e.displayName||`Context`;case M:return(e._context.displayName||`Context`)+`.Consumer`;case P: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?pe(e.type)||`Memo`:t;case F:t=e._payload,e=e._init;try{return pe(e(t))}catch{}}return null}var me=Array.isArray,I=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,he={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 be(e,t){_e++,ge[_e]=e.current,e.current=t}var xe=ve(null),Se=ve(null),Ce=ve(null),we=ve(null);function Te(e,t){switch(be(Ce,t),be(Se,e),be(xe,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(xe),be(xe,e)}function Ee(){ye(xe),ye(Se),ye(Ce)}function De(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,be(we,e)),t=xe.current;var n=dp(t,e.type);t!==n&&(be(Se,e),be(xe,n))}function Oe(e){Se.current===e&&(ye(xe),ye(Se)),we.current===e&&(ye(we),sh._currentValue=he)}var ke,Ae;function je(e){if(ke===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ke=t&&t[1]||``,Ae=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+ke+e+Ae}var Me=!1;function Ne(e,t){if(!e||Me)return``;Me=!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(`
|
|
@@ -54,11 +54,11 @@ Load ${e} anyway?`)?(await U(e,t,!0),!0):!1}}async function ra(e,t=!1){return H(
|
|
|
54
54
|
`).replace(/\\\\/g,`\\`)}function kx(e){let t;try{t=JSON.parse(e)}catch{let t=Ox(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=>Tx.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 Ax(e,t){let n=``,r=0;for(;r<e.length;){let i=e.indexOf(`{`,r);if(i===-1){n+=e.slice(r);break}if(!Ex.test(e.slice(i,i+40))){n+=e.slice(r,i+1),r=i+1;continue}let a=Dx(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=kx(o);s.action===`answer`?n+=s.text:s.action===`keep`&&(n+=o),r=a+1}return n}var jx=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 Mx(e){return e.replace(/```(\w*)[ \t]*\n([\s\S]*?)```/g,(e,t,n)=>{let r=t.toLowerCase();return r.length>0&&r.length<=2&&!jx.has(r)?n.trim():e})}var Nx=/\n{1,2}Verification: unverified[^\n]*\s*$/;function Px(e){let t=e;for(;;){let e=t.replace(Nx,``);if(e===t)return t;t=e}}function Fx(e,t=!1){if(!e)return e;e=Px(e);let n=e;n=n.replace(wx,``),n=Ax(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,`
|
|
55
55
|
`),n=n.replace(/\\"/g,`"`)),n=Mx(n).trim(),Ix(n)}function Ix(e){let t=!1;return e.split(`
|
|
56
56
|
`).map(e=>(/^\s*(```|~~~)/.test(e)&&(t=!t),t?e:e.replace(/^(\s*\d+)\.(\s*)$/,`$1\\.$2`))).join(`
|
|
57
|
-
`)}function Lx(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 Rx=`Cancelled.`,zx=[`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 Bx(e,t){if(t)return`stopped`;let n=e.trim();return zx.some(e=>n.endsWith(e))?`interrupted`:void 0}function Vx({message:e,isStreaming:t,agentSteps:n,agentStepsActive:r,cards:i,onDelete:a,onResend:o,extraActions:s,latencyMs:c,liveStatus:l,awaitingUser:u}){ls();let d=(0,z.useMemo)(()=>e.role===`assistant`&&!t&&n?Cx(n,e.content):{steps:n,echoed:!1},[n,e.content,e.role,t]),f=e.role===`assistant`&&(d.echoed||xx(e.content)),p=e.role===`assistant`?e.stopState??(e.content.trim()===Rx?`stopped`:void 0):void 0,m=(0,z.useMemo)(()=>e.role===`user`?e.content:Fx(e.content,!!t),[e.content,e.role,t]),[h,g]=(0,z.useState)(!1),[_,v]=(0,z.useState)(!1),y=e.role===`user`&&Rv(e.content),[b,x]=(0,z.useState)(!1),S=(0,z.useId)(),C=(0,z.useRef)(null),w=(0,z.useRef)(!1),T=(0,z.useCallback)(()=>{b&&(w.current=!0),x(!b)},[b]);(0,z.useEffect)(()=>{!b&&w.current&&(w.current=!1,C.current?.scrollIntoView?.({block:`nearest`}))},[b]);let E=(0,z.useRef)(null),D=(0,z.useRef)(null);(0,z.useEffect)(()=>()=>{E.current&&clearTimeout(E.current),D.current&&clearTimeout(D.current)},[]);let O=(0,z.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)}g(!0),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>g(!1),2e3)},[e.content]),k=(0,z.useCallback)(()=>{_?(v(!1),D.current&&clearTimeout(D.current),a?.(e.id)):(v(!0),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>v(!1),3e3))},[_,e.id,a]),ee=(0,z.useCallback)(()=>{o?.(e)},[e,o]),A=e.created_at?`${e.role===`user`?`Sent`:`Replied`} ${Lx(e.created_at)}`:void 0;return(0,V.jsx)(`div`,{className:`msg msg-${e.role} ${f?`msg-error`:``}`,title:A,children:(0,V.jsxs)(`div`,{className:`msg-inner`,children:[(0,V.jsxs)(`div`,{className:`msg-header`,children:[(0,V.jsx)(`div`,{className:`msg-header-left`}),!t&&(0,V.jsxs)(`div`,{className:`msg-actions`,children:[e.role===`user`&&o&&(0,V.jsx)(`button`,{className:`msg-action-btn`,onClick:ee,title:`Resend message`,"aria-label":`Resend message`,children:(0,V.jsx)(tn,{size:12})}),s,(0,V.jsx)(`button`,{className:`msg-copy ${h?`copied`:``}`,onClick:O,title:h?`Copied!`:`Copy message`,"aria-label":h?`Copied to clipboard`:`Copy message`,children:h?(0,V.jsx)(P,{size:12}):(0,V.jsx)(Se,{size:12})}),a&&(0,V.jsx)(`button`,{className:`msg-action-btn msg-delete ${_?`confirm`:``}`,onClick:k,title:_?`Click again to confirm`:`Delete message`,"aria-label":_?`Confirm delete message`:`Delete message`,children:(0,V.jsx)(On,{size:12})})]})]}),(0,V.jsxs)(`div`,{className:`msg-body`,children:[e.role===`assistant`&&(d.steps&&d.steps.length>0||t)&&(0,V.jsx)(xy,{steps:d.steps??[],isActive:r??!1,running:!!t,awaitingUser:u,answer:t?void 0:m,liveLine:t&&(0,V.jsx)(vx,{active:!!r||!m,label:l,awaitingUser:u})}),f&&(0,V.jsxs)(`div`,{className:`error-banner`,children:[(0,V.jsx)(An,{size:14}),(0,V.jsx)(`span`,{children:`Something went wrong`})]}),(e.cards??i)?.map((e,t)=>(0,V.jsx)(Mb,{render:e.render,data:e.data},t)),y?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{ref:C,id:S,className:`msg-collapsible${b?``:` is-collapsed`}`,children:(0,V.jsx)(Qx,{content:m})}),(0,V.jsx)(Bv,{expanded:b,onToggle:T,controls:S,collapsedLabel:`Show all (${zv(e.content)})`,expandedLabel:`Show less`,className:`msg-expand-toggle`})]}):!(p&&m.trim()===Rx)&&(0,V.jsx)(Qx,{content:m,showCursor:t&&!!m&&!r,isStreaming:t}),p&&(0,V.jsxs)(`div`,{className:`msg-stopped${p===`unconfirmed`||e.stopError?` is-unconfirmed`:``}`,role:`note`,children:[(0,V.jsx)(wn,{size:9,fill:`currentColor`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{children:p===`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&&Uy(m)&&(0,V.jsx)(qy,{content:m}),e.role===`assistant`&&!t&&(e.stats||c!=null||e.created_at)&&(0,V.jsxs)(`div`,{className:`msg-stats`,"aria-label":`About this answer`,children:[e.created_at&&(0,V.jsx)(`span`,{className:`msg-stats-ts`,title:`Message timestamp`,children:Lx(e.created_at)}),e.stats?.retried&&e.stats.model&&(0,V.jsx)(`span`,{title:`This answer was kept from Retry with… (${e.stats.model})`,children:us(e.stats.model)}),(0,V.jsx)(Lb,{latencyMs:c,stats:e.stats,ended:Bx(e.content,p)})]}),e.role===`assistant`&&!t&&e.id>0&&e.session_id&&(0,V.jsx)(_x,{sessionId:e.session_id,messageId:e.id})]})]})})}var Hx=(0,z.createContext)(!1);function Ux({lang:e,code:t}){let[n,r]=(0,z.useState)(!1),[i,a]=(0,z.useState)(!1),o=(0,z.useContext)(Hx),s=(0,z.useId)(),c=Lv(t),l=c>(o?20:25),u=l&&!i,d=(0,z.useRef)(null);(0,z.useEffect)(()=>()=>{d.current&&clearTimeout(d.current)},[]);let f=(0,z.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,V.jsxs)(`div`,{className:`code-block${u?` is-collapsed`:``}`,children:[(0,V.jsxs)(`div`,{className:`code-header`,children:[(0,V.jsx)(`span`,{className:`code-lang`,children:e||`code`}),(0,V.jsxs)(`button`,{className:`code-copy ${n?`copied`:``}`,onClick:f,title:n?`Copied!`:`Copy`,"aria-label":n?`Copied to clipboard`:`Copy code`,children:[n?(0,V.jsx)(P,{size:13}):(0,V.jsx)(Se,{size:13}),(0,V.jsx)(`span`,{children:n?`Copied`:`Copy`})]})]}),(0,V.jsx)(`pre`,{id:s,children:(0,V.jsx)(`code`,{children:t})}),l&&(0,V.jsx)(Bv,{expanded:i,onToggle:()=>a(e=>!e),controls:s,collapsedLabel:`Expand (${c.toLocaleString(`en-US`)} lines)`,expandedLabel:`Collapse`,className:`code-expand-toggle`})]})}var Wx=/\b[A-Z]:[\\/][^\s*?"<>|,;)}\]\\/]+(?:[\\/][^\s*?"<>|,;)}\]\\/]+)*[\\/]?/gi,Gx=/[.:!']+$/,Kx=RegExp(`^(?:${Wx.source})$`,`i`);function qx(e){if(typeof e!=`string`)return null;let t=e.trim();return Kx.test(t)?t:null}function Jx({path:e}){let t=t=>{t.preventDefault(),bo(e).catch(e=>{s.ui.error(`Failed to open path`,e)})};return(0,V.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,V.jsx)(Xe,{size:12,className:`file-path-icon`}),e]})}function Yx(e){let t=new RegExp(Wx.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(Gx,``);n.push((0,V.jsx)(Jx,{path:t},i.index)),r=i.index+t.length}return n.length===0?e:(r<e.length&&n.push(e.slice(r)),(0,V.jsx)(V.Fragment,{children:n}))}function Xx(e){return z.Children.map(e,e=>typeof e==`string`?Yx(e):e)}var Zx={code({className:e,children:t,node:n,...r}){let i=qx(t);return i?(0,V.jsx)(Jx,{path:i}):(0,V.jsx)(`code`,{className:`inline-code`,...r,children:t})},pre({children:e}){let t=z.Children.toArray(e)[0];if(z.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,V.jsx)(Ux,{lang:a,code:i})}return(0,V.jsx)(`pre`,{children:e})},table({children:e}){return(0,V.jsx)(`div`,{className:`md-table-wrap`,children:(0,V.jsx)(`table`,{className:`md-table`,children:e})})},a({href:e,children:t}){return(0,V.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`md-link`,children:t})},p({children:e}){return(0,V.jsx)(`p`,{className:`md-p`,children:Xx(e)})},h1({children:e}){return(0,V.jsx)(`h2`,{className:`md-h2`,children:Xx(e)})},h2({children:e}){return(0,V.jsx)(`h3`,{className:`md-h3`,children:Xx(e)})},h3({children:e}){return(0,V.jsx)(`h4`,{className:`md-h4`,children:Xx(e)})},ul({children:e}){return(0,V.jsx)(`ul`,{className:`md-ul`,children:e})},ol({children:e,start:t}){return(0,V.jsx)(`ol`,{className:`md-ol`,start:t,children:e})},li({children:e}){return(0,V.jsx)(`li`,{className:`md-li`,children:Xx(e)})},blockquote({children:e}){return(0,V.jsx)(`blockquote`,{className:`md-blockquote`,children:Xx(e)})},hr(){return(0,V.jsx)(`hr`,{className:`md-hr`})},td({children:e}){return(0,V.jsx)(`td`,{children:Xx(e)})},th({children:e}){return(0,V.jsx)(`th`,{children:Xx(e)})}};function Qx({content:e,showCursor:t,isStreaming:n=!1}){return!e&&!t?null:!e&&t?(0,V.jsx)(`span`,{className:`cursor`}):(0,V.jsx)(Hx.Provider,{value:n,children:(0,V.jsxs)(`div`,{className:`md-content`,children:[(0,V.jsx)(hh,{remarkPlugins:[Sv,Dv,kv],disallowedElements:[...bh],urlTransform:Sh,components:Zx,children:e}),t&&(0,V.jsx)(`span`,{className:`cursor`})]})})}function $x(e){return e.type===`status`&&e.status===`working`&&!e.phase&&(e.message??``).startsWith(`Model is processing`)}function eS(e,t){let n=++t.current,r=Date.now();switch(e.type){case`thinking`:return{id:n,type:`thinking`,label:`Thinking`,detail:e.content,active:!0,timestamp:r};case`commentary`:return{id:n,type:`commentary`,label:`Commentary`,detail:e.content,active:!1,timestamp:r};case`tool_start`:return{id:n,type:`tool`,label:`Using tool`,tool:e.tool,detail:e.detail,narration:e.narration,active:!0,timestamp:r,mcpServer:e.mcp_server,mcpServerLabel:e.mcp_server_label,mcpTool:e.mcp_tool};case`plan`:return{id:n,type:`plan`,label:`Created plan`,planSteps:e.steps,planNarrations:e.step_narrations,currentStep:e.current_step,active:!1,success:!0,timestamp:r};case`step`:return{id:n,type:`status`,label:`Step ${e.step}${e.total?` of ${e.total}`:``}`,active:!0,timestamp:r};case`status`:return e.message?.startsWith(`Agent: `)?null:{id:n,type:`status`,label:e.message||e.status||`Working`,active:e.status===`working`,...e.status===`warning`?{success:!1}:{},timestamp:r};case`agent_error`:return{id:n,type:`error`,label:`Error`,detail:e.content,success:!1,active:!1,timestamp:r};case`policy_alert`:{let t=e.tool||`unknown tool`,i=e.reason||e.message||e.content||`Tool execution was blocked by governance policy.`;return{id:n,type:`policy_alert`,label:`Policy blocked ${t}`,detail:i,tool:t,decision:e.decision||`BLOCK`,reason:i,ruleIds:e.rule_ids??[],policyVersion:e.policy_version,receiptId:e.receipt_id,success:!1,active:!1,timestamp:r}}default:return null}}var tS=1e3,nS=15e3,rS=null,iS=null,aS=tS,oS=0,sS=null;function cS(){if(rS)return rS;let e=Date.now();return rS=ji().then(t=>B.getState().setActiveRuns(t,e)).catch(e=>s.api.warn(`Could not read which chats are running`,e)).finally(()=>{rS=null}),rS}function lS(){let e=B.getState();return e.isStreaming||e.runningSessionIds.length>0}function uS(){return lS()?(aS=tS,tS):(aS=Math.min(aS*2,nS),aS)}function dS(e){cS().then(()=>{e===oS&&(iS=setTimeout(()=>dS(e),uS()))})}function fS(){sS&&(iS&&clearTimeout(iS),iS=null,aS=tS,dS(++oS))}function pS(){sS?.();let e=B.subscribe((e,t)=>{e.isStreaming&&!t.isStreaming&&fS()}),t=()=>fS();window.addEventListener(`focus`,t);let n=()=>{oS++,iS&&clearTimeout(iS),iS=null,e(),window.removeEventListener(`focus`,t),sS===n&&(sS=null)};return sS=n,aS=tS,dS(++oS),n}var mS=[0,3e3,1e4],hS=`The answer to your last message was lost: its run stopped before it finished, most often because GAIA restarted. Send the message again.`;function gS(e){return e.name===`StreamStalledError`||e.name===`StreamDroppedError`}function _S(e){if(gS(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 ro)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 Hi){let t=e.detail?zi(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 vS=3e3,yS=new Set,bS=new Map,xS=new Set,SS=null;function CS(e,t=Date.now()){bS.set(e,t)}function wS(e){let t=B.getState();return t.activeRunsAt>0&&t.activeRunsAt>=(bS.get(e)??0)&&!t.runningSessionIds.includes(e)&&!t.queuedSessionIds.includes(e)}function TS(e){return xS.add(e),()=>{xS.delete(e),SS?.()}}function ES(e){return e instanceof Error?_S(e)??(e.message||`Unknown error`):String(e)}function DS(e){let t=e?.httpStatus;return typeof t==`number`?t:void 0}function OS(e){let t=DS(e);return t===409||t===429}function kS(e){B.getState().setQueueHold(e,!0),setTimeout(()=>B.getState().setQueueHold(e,!1),vS)}function AS(e,t,n){return DS(n)===409&&(s.chat.info(`Chat ${e} was busy; queueing the message to try again`),B.getState().updateQueue(e,e=>Tr(e,t,`queued`)),kS(e),!0)}async function jS(e,t,n){let r=B.getState;if(yS.has(e)||r().queueHolds[e])return;let i=r().messageQueues[e]??[];if(i.some(e=>e.state===`sending`))return;let a=Mr(i);if(a||Ir(i)){yS.add(e);try{if(a){let t;try{t=await Ei(e)}catch(t){if(DS(t)===409){s.chat.info(`Chat ${e} is answering again; its queue waits for that turn to end`);return}s.chat.error(`Could not learn what chat ${e}'s last reply did with the messages added to it`,t),r().updateQueue(e,e=>Fr(e,`GAIA could not say whether it read this message: ${ES(t)}`));return}r().updateQueue(e,e=>Pr(e,t))}let i=Ir(r().messageQueues[e]??[]);if(!i||!n())return;r().updateQueue(e,e=>Er(e,i.id,`queued`,`starting`));let o;try{o=await t(e,i.text)}catch(e){o={kind:`failed`,error:ES(e)}}if(o.kind===`accepted`){CS(e),r().updateQueue(e,e=>Dr(e,i.id)),fS();return}if(o.kind===`busy`){s.chat.info(`Queued message found chat ${e} busy; holding it`),r().updateQueue(e,e=>Or(e,i.id)),kS(e);return}s.chat.error(`Queued message for chat ${e} was not sent: ${o.error}`),r().updateQueue(e,e=>Or(e,i.id,o.error))}finally{yS.delete(e)}}}function MS(e){return e.type!==`status`||e.phase!==`waiting`}var NS=(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))},c=()=>o({kind:`accepted`});s.chat.info(`Sending queued message for chat ${e} in the background`),i=Ja(e,t,{onChunk:c,onAgentEvent:e=>{MS(e)&&c()},onDone:c,onError:e=>{gS(e)?c():OS(e)?o({kind:`busy`}):o({kind:`failed`,error:ES(e)})}}),a&&i.abort()});function PS(e=NS){let t=()=>{let t=B.getState();if(t.systemStatus?.init_state!==`initializing`)for(let n of Object.keys(t.messageQueues))!xS.has(n)&&wS(n)&&jS(n,e,()=>!xS.has(n))},n=B.subscribe((e,n)=>{(e.messageQueues!==n.messageQueues||e.queueHolds!==n.queueHolds||e.activeRunsAt!==n.activeRunsAt||e.runningSessionIds!==n.runningSessionIds||e.systemStatus!==n.systemStatus)&&t()});return SS=t,t(),()=>{n(),SS===t&&(SS=null)}}var FS=`https://github.com/amd/gaia/issues/new`,IS=[{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 LS(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;for(let e of IS)if(e.extensions.has(t))return e;return null}var RS=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 zS(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;return RS.has(t)}function BS(){let e=navigator.userAgent;return`**Environment:**\n- GAIA Version: 0.25.2rc6\n- Platform: ${navigator.platform||`unknown`}\n- User Agent: ${e}\n- Interface: Agent UI (Web)`}function VS(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?_`,``,`---`,BS(),``,`_Submitted from GAIA Agent UI_`].join(`
|
|
57
|
+
`)}function Lx(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 Rx=`Cancelled.`,zx=[`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 Bx(e,t){if(t)return`stopped`;let n=e.trim();return zx.some(e=>n.endsWith(e))?`interrupted`:void 0}function Vx({message:e,isStreaming:t,agentSteps:n,agentStepsActive:r,cards:i,onDelete:a,onResend:o,extraActions:s,latencyMs:c,liveStatus:l,awaitingUser:u}){ls();let d=(0,z.useMemo)(()=>e.role===`assistant`&&!t&&n?Cx(n,e.content):{steps:n,echoed:!1},[n,e.content,e.role,t]),f=e.role===`assistant`&&(d.echoed||xx(e.content)),p=e.role===`assistant`?e.stopState??(e.content.trim()===Rx?`stopped`:void 0):void 0,m=(0,z.useMemo)(()=>e.role===`user`?e.content:Fx(e.content,!!t),[e.content,e.role,t]),[h,g]=(0,z.useState)(!1),[_,v]=(0,z.useState)(!1),y=e.role===`user`&&Rv(e.content),[b,x]=(0,z.useState)(!1),S=(0,z.useId)(),C=(0,z.useRef)(null),w=(0,z.useRef)(!1),T=(0,z.useCallback)(()=>{b&&(w.current=!0),x(!b)},[b]);(0,z.useEffect)(()=>{!b&&w.current&&(w.current=!1,C.current?.scrollIntoView?.({block:`nearest`}))},[b]);let E=(0,z.useRef)(null),D=(0,z.useRef)(null);(0,z.useEffect)(()=>()=>{E.current&&clearTimeout(E.current),D.current&&clearTimeout(D.current)},[]);let O=(0,z.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)}g(!0),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>g(!1),2e3)},[e.content]),k=(0,z.useCallback)(()=>{_?(v(!1),D.current&&clearTimeout(D.current),a?.(e.id)):(v(!0),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>v(!1),3e3))},[_,e.id,a]),ee=(0,z.useCallback)(()=>{o?.(e)},[e,o]),A=e.created_at?`${e.role===`user`?`Sent`:`Replied`} ${Lx(e.created_at)}`:void 0;return(0,V.jsx)(`div`,{className:`msg msg-${e.role} ${f?`msg-error`:``}`,title:A,children:(0,V.jsxs)(`div`,{className:`msg-inner`,children:[(0,V.jsxs)(`div`,{className:`msg-header`,children:[(0,V.jsx)(`div`,{className:`msg-header-left`}),!t&&(0,V.jsxs)(`div`,{className:`msg-actions`,children:[e.role===`user`&&o&&(0,V.jsx)(`button`,{className:`msg-action-btn`,onClick:ee,title:`Resend message`,"aria-label":`Resend message`,children:(0,V.jsx)(tn,{size:12})}),s,(0,V.jsx)(`button`,{className:`msg-copy ${h?`copied`:``}`,onClick:O,title:h?`Copied!`:`Copy message`,"aria-label":h?`Copied to clipboard`:`Copy message`,children:h?(0,V.jsx)(P,{size:12}):(0,V.jsx)(Se,{size:12})}),a&&(0,V.jsx)(`button`,{className:`msg-action-btn msg-delete ${_?`confirm`:``}`,onClick:k,title:_?`Click again to confirm`:`Delete message`,"aria-label":_?`Confirm delete message`:`Delete message`,children:(0,V.jsx)(On,{size:12})})]})]}),(0,V.jsxs)(`div`,{className:`msg-body`,children:[e.role===`assistant`&&(d.steps&&d.steps.length>0||t)&&(0,V.jsx)(xy,{steps:d.steps??[],isActive:r??!1,running:!!t,awaitingUser:u,answer:t?void 0:m,liveLine:t&&(0,V.jsx)(vx,{active:!!r||!m,label:l,awaitingUser:u})}),f&&(0,V.jsxs)(`div`,{className:`error-banner`,children:[(0,V.jsx)(An,{size:14}),(0,V.jsx)(`span`,{children:`Something went wrong`})]}),(e.cards??i)?.map((e,t)=>(0,V.jsx)(Mb,{render:e.render,data:e.data},t)),y?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{ref:C,id:S,className:`msg-collapsible${b?``:` is-collapsed`}`,children:(0,V.jsx)(Qx,{content:m})}),(0,V.jsx)(Bv,{expanded:b,onToggle:T,controls:S,collapsedLabel:`Show all (${zv(e.content)})`,expandedLabel:`Show less`,className:`msg-expand-toggle`})]}):!(p&&m.trim()===Rx)&&(0,V.jsx)(Qx,{content:m,showCursor:t&&!!m&&!r,isStreaming:t}),p&&(0,V.jsxs)(`div`,{className:`msg-stopped${p===`unconfirmed`||e.stopError?` is-unconfirmed`:``}`,role:`note`,children:[(0,V.jsx)(wn,{size:9,fill:`currentColor`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{children:p===`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&&Uy(m)&&(0,V.jsx)(qy,{content:m}),e.role===`assistant`&&!t&&(e.stats||c!=null||e.created_at)&&(0,V.jsxs)(`div`,{className:`msg-stats`,"aria-label":`About this answer`,children:[e.created_at&&(0,V.jsx)(`span`,{className:`msg-stats-ts`,title:`Message timestamp`,children:Lx(e.created_at)}),e.stats?.retried&&e.stats.model&&(0,V.jsx)(`span`,{title:`This answer was kept from Retry with… (${e.stats.model})`,children:us(e.stats.model)}),(0,V.jsx)(Lb,{latencyMs:c,stats:e.stats,ended:Bx(e.content,p)})]}),e.role===`assistant`&&!t&&e.id>0&&e.session_id&&(0,V.jsx)(_x,{sessionId:e.session_id,messageId:e.id})]})]})})}var Hx=(0,z.createContext)(!1);function Ux({lang:e,code:t}){let[n,r]=(0,z.useState)(!1),[i,a]=(0,z.useState)(!1),o=(0,z.useContext)(Hx),s=(0,z.useId)(),c=Lv(t),l=c>(o?20:25),u=l&&!i,d=(0,z.useRef)(null);(0,z.useEffect)(()=>()=>{d.current&&clearTimeout(d.current)},[]);let f=(0,z.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,V.jsxs)(`div`,{className:`code-block${u?` is-collapsed`:``}`,children:[(0,V.jsxs)(`div`,{className:`code-header`,children:[(0,V.jsx)(`span`,{className:`code-lang`,children:e||`code`}),(0,V.jsxs)(`button`,{className:`code-copy ${n?`copied`:``}`,onClick:f,title:n?`Copied!`:`Copy`,"aria-label":n?`Copied to clipboard`:`Copy code`,children:[n?(0,V.jsx)(P,{size:13}):(0,V.jsx)(Se,{size:13}),(0,V.jsx)(`span`,{children:n?`Copied`:`Copy`})]})]}),(0,V.jsx)(`pre`,{id:s,children:(0,V.jsx)(`code`,{children:t})}),l&&(0,V.jsx)(Bv,{expanded:i,onToggle:()=>a(e=>!e),controls:s,collapsedLabel:`Expand (${c.toLocaleString(`en-US`)} lines)`,expandedLabel:`Collapse`,className:`code-expand-toggle`})]})}var Wx=/\b[A-Z]:[\\/][^\s*?"<>|,;)}\]\\/]+(?:[\\/][^\s*?"<>|,;)}\]\\/]+)*[\\/]?/gi,Gx=/[.:!']+$/,Kx=RegExp(`^(?:${Wx.source})$`,`i`);function qx(e){if(typeof e!=`string`)return null;let t=e.trim();return Kx.test(t)?t:null}function Jx({path:e}){let t=t=>{t.preventDefault(),bo(e).catch(e=>{s.ui.error(`Failed to open path`,e)})};return(0,V.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,V.jsx)(Xe,{size:12,className:`file-path-icon`}),e]})}function Yx(e){let t=new RegExp(Wx.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(Gx,``);n.push((0,V.jsx)(Jx,{path:t},i.index)),r=i.index+t.length}return n.length===0?e:(r<e.length&&n.push(e.slice(r)),(0,V.jsx)(V.Fragment,{children:n}))}function Xx(e){return z.Children.map(e,e=>typeof e==`string`?Yx(e):e)}var Zx={code({className:e,children:t,node:n,...r}){let i=qx(t);return i?(0,V.jsx)(Jx,{path:i}):(0,V.jsx)(`code`,{className:`inline-code`,...r,children:t})},pre({children:e}){let t=z.Children.toArray(e)[0];if(z.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,V.jsx)(Ux,{lang:a,code:i})}return(0,V.jsx)(`pre`,{children:e})},table({children:e}){return(0,V.jsx)(`div`,{className:`md-table-wrap`,children:(0,V.jsx)(`table`,{className:`md-table`,children:e})})},a({href:e,children:t}){return(0,V.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`md-link`,children:t})},p({children:e}){return(0,V.jsx)(`p`,{className:`md-p`,children:Xx(e)})},h1({children:e}){return(0,V.jsx)(`h2`,{className:`md-h2`,children:Xx(e)})},h2({children:e}){return(0,V.jsx)(`h3`,{className:`md-h3`,children:Xx(e)})},h3({children:e}){return(0,V.jsx)(`h4`,{className:`md-h4`,children:Xx(e)})},ul({children:e}){return(0,V.jsx)(`ul`,{className:`md-ul`,children:e})},ol({children:e,start:t}){return(0,V.jsx)(`ol`,{className:`md-ol`,start:t,children:e})},li({children:e}){return(0,V.jsx)(`li`,{className:`md-li`,children:Xx(e)})},blockquote({children:e}){return(0,V.jsx)(`blockquote`,{className:`md-blockquote`,children:Xx(e)})},hr(){return(0,V.jsx)(`hr`,{className:`md-hr`})},td({children:e}){return(0,V.jsx)(`td`,{children:Xx(e)})},th({children:e}){return(0,V.jsx)(`th`,{children:Xx(e)})}};function Qx({content:e,showCursor:t,isStreaming:n=!1}){return!e&&!t?null:!e&&t?(0,V.jsx)(`span`,{className:`cursor`}):(0,V.jsx)(Hx.Provider,{value:n,children:(0,V.jsxs)(`div`,{className:`md-content`,children:[(0,V.jsx)(hh,{remarkPlugins:[Sv,Dv,kv],disallowedElements:[...bh],urlTransform:Sh,components:Zx,children:e}),t&&(0,V.jsx)(`span`,{className:`cursor`})]})})}function $x(e){return e.type===`status`&&e.status===`working`&&!e.phase&&(e.message??``).startsWith(`Model is processing`)}function eS(e,t){let n=++t.current,r=Date.now();switch(e.type){case`thinking`:return{id:n,type:`thinking`,label:`Thinking`,detail:e.content,active:!0,timestamp:r};case`commentary`:return{id:n,type:`commentary`,label:`Commentary`,detail:e.content,active:!1,timestamp:r};case`tool_start`:return{id:n,type:`tool`,label:`Using tool`,tool:e.tool,detail:e.detail,narration:e.narration,active:!0,timestamp:r,mcpServer:e.mcp_server,mcpServerLabel:e.mcp_server_label,mcpTool:e.mcp_tool};case`plan`:return{id:n,type:`plan`,label:`Created plan`,planSteps:e.steps,planNarrations:e.step_narrations,currentStep:e.current_step,active:!1,success:!0,timestamp:r};case`step`:return{id:n,type:`status`,label:`Step ${e.step}${e.total?` of ${e.total}`:``}`,active:!0,timestamp:r};case`status`:return e.message?.startsWith(`Agent: `)?null:{id:n,type:`status`,label:e.message||e.status||`Working`,active:e.status===`working`,...e.status===`warning`?{success:!1}:{},timestamp:r};case`agent_error`:return{id:n,type:`error`,label:`Error`,detail:e.content,success:!1,active:!1,timestamp:r};case`policy_alert`:{let t=e.tool||`unknown tool`,i=e.reason||e.message||e.content||`Tool execution was blocked by governance policy.`;return{id:n,type:`policy_alert`,label:`Policy blocked ${t}`,detail:i,tool:t,decision:e.decision||`BLOCK`,reason:i,ruleIds:e.rule_ids??[],policyVersion:e.policy_version,receiptId:e.receipt_id,success:!1,active:!1,timestamp:r}}default:return null}}var tS=1e3,nS=15e3,rS=null,iS=null,aS=tS,oS=0,sS=null;function cS(){if(rS)return rS;let e=Date.now();return rS=ji().then(t=>B.getState().setActiveRuns(t,e)).catch(e=>s.api.warn(`Could not read which chats are running`,e)).finally(()=>{rS=null}),rS}function lS(){let e=B.getState();return e.isStreaming||e.runningSessionIds.length>0}function uS(){return lS()?(aS=tS,tS):(aS=Math.min(aS*2,nS),aS)}function dS(e){cS().then(()=>{e===oS&&(iS=setTimeout(()=>dS(e),uS()))})}function fS(){sS&&(iS&&clearTimeout(iS),iS=null,aS=tS,dS(++oS))}function pS(){sS?.();let e=B.subscribe((e,t)=>{e.isStreaming&&!t.isStreaming&&fS()}),t=()=>fS();window.addEventListener(`focus`,t);let n=()=>{oS++,iS&&clearTimeout(iS),iS=null,e(),window.removeEventListener(`focus`,t),sS===n&&(sS=null)};return sS=n,aS=tS,dS(++oS),n}var mS=[0,3e3,1e4],hS=`The answer to your last message was lost: its run stopped before it finished, most often because GAIA restarted. Send the message again.`;function gS(e){return e.name===`StreamStalledError`||e.name===`StreamDroppedError`}function _S(e){if(gS(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 ro)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 Hi){let t=e.detail?zi(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 vS=3e3,yS=new Set,bS=new Map,xS=new Set,SS=null;function CS(e,t=Date.now()){bS.set(e,t)}function wS(e){let t=B.getState();return t.activeRunsAt>0&&t.activeRunsAt>=(bS.get(e)??0)&&!t.runningSessionIds.includes(e)&&!t.queuedSessionIds.includes(e)}function TS(e){return xS.add(e),()=>{xS.delete(e),SS?.()}}function ES(e){return e instanceof Error?_S(e)??(e.message||`Unknown error`):String(e)}function DS(e){let t=e?.httpStatus;return typeof t==`number`?t:void 0}function OS(e){let t=DS(e);return t===409||t===429}function kS(e){B.getState().setQueueHold(e,!0),setTimeout(()=>B.getState().setQueueHold(e,!1),vS)}function AS(e,t,n){return DS(n)===409&&(s.chat.info(`Chat ${e} was busy; queueing the message to try again`),B.getState().updateQueue(e,e=>Tr(e,t,`queued`)),kS(e),!0)}async function jS(e,t,n){let r=B.getState;if(yS.has(e)||r().queueHolds[e])return;let i=r().messageQueues[e]??[];if(i.some(e=>e.state===`sending`))return;let a=Mr(i);if(a||Ir(i)){yS.add(e);try{if(a){let t;try{t=await Ei(e)}catch(t){if(DS(t)===409){s.chat.info(`Chat ${e} is answering again; its queue waits for that turn to end`);return}s.chat.error(`Could not learn what chat ${e}'s last reply did with the messages added to it`,t),r().updateQueue(e,e=>Fr(e,`GAIA could not say whether it read this message: ${ES(t)}`));return}r().updateQueue(e,e=>Pr(e,t))}let i=Ir(r().messageQueues[e]??[]);if(!i||!n())return;r().updateQueue(e,e=>Er(e,i.id,`queued`,`starting`));let o;try{o=await t(e,i.text)}catch(e){o={kind:`failed`,error:ES(e)}}if(o.kind===`accepted`){CS(e),r().updateQueue(e,e=>Dr(e,i.id)),fS();return}if(o.kind===`busy`){s.chat.info(`Queued message found chat ${e} busy; holding it`),r().updateQueue(e,e=>Or(e,i.id)),kS(e);return}s.chat.error(`Queued message for chat ${e} was not sent: ${o.error}`),r().updateQueue(e,e=>Or(e,i.id,o.error))}finally{yS.delete(e)}}}function MS(e){return e.type!==`status`||e.phase!==`waiting`}var NS=(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))},c=()=>o({kind:`accepted`});s.chat.info(`Sending queued message for chat ${e} in the background`),i=Ja(e,t,{onChunk:c,onAgentEvent:e=>{MS(e)&&c()},onDone:c,onError:e=>{gS(e)?c():OS(e)?o({kind:`busy`}):o({kind:`failed`,error:ES(e)})}}),a&&i.abort()});function PS(e=NS){let t=()=>{let t=B.getState();if(t.systemStatus?.init_state!==`initializing`)for(let n of Object.keys(t.messageQueues))!xS.has(n)&&wS(n)&&jS(n,e,()=>!xS.has(n))},n=B.subscribe((e,n)=>{(e.messageQueues!==n.messageQueues||e.queueHolds!==n.queueHolds||e.activeRunsAt!==n.activeRunsAt||e.runningSessionIds!==n.runningSessionIds||e.systemStatus!==n.systemStatus)&&t()});return SS=t,t(),()=>{n(),SS===t&&(SS=null)}}var FS=`https://github.com/amd/gaia/issues/new`,IS=[{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`],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 LS(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;for(let e of IS)if(e.extensions.has(t))return e;return null}var RS=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 zS(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;return RS.has(t)}function BS(){let e=navigator.userAgent;return`**Environment:**\n- GAIA Version: 0.25.2\n- Platform: ${navigator.platform||`unknown`}\n- User Agent: ${e}\n- Interface: Agent UI (Web)`}function VS(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?_`,``,`---`,BS(),``,`_Submitted from GAIA Agent UI_`].join(`
|
|
58
58
|
`);return`${FS}?${new URLSearchParams({title:`[Feature] ${e}`,body:n,labels:`enhancement,agent-ui`}).toString()}`}function HS(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?_`,``,`---`,BS(),``,`_Submitted from GAIA Agent UI_`].join(`
|
|
59
59
|
`);return`${FS}?${new URLSearchParams({title:`[Bug] ${e}`,body:n,labels:`bug,agent-ui`}).toString()}`}var US={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 WS(e,t){return e.startsWith(t)?e.slice(t.length).trim():e}function GS({filename:e,error:t,status:n,kind:r,onDismiss:i,timeout:a=15e3}){let o=(0,z.useRef)(null);(0,z.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?LS(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=ce,h=r?US[r]:void 0;return h?(d=`"${e}" can't be read`,f=h,p=null,m=An):n===404?(d=`"${e}" doesn't exist`,f=WS(t,`File not found:`),p=null,m=An):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=An):l&&c?(d=`${c.label} files not supported`,f=c.message,p=VS(c.featureTitle),m=An):l&&!s?(d=`"${e}" has no file extension`,f=WS(t,`File type not allowed:`),p=null,m=An):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=VS(`Support ${s} file indexing`),m=An):u?(d=`Connection error`,f=`Could not reach the GAIA server. Make sure the backend is running.`,p=HS(`Upload connection error for ${e}`),m=ce):(d=`Failed to index "${e}"`,f=t||`An unexpected error occurred during indexing.`,p=HS(`Indexing error: ${t.slice(0,80)}`),m=ee),(0,V.jsxs)(`div`,{className:`upload-error-toast`,role:`alert`,children:[(0,V.jsx)(m,{size:16}),(0,V.jsxs)(`div`,{className:`upload-error-content`,children:[(0,V.jsx)(`div`,{className:`upload-error-title`,children:d}),(0,V.jsxs)(`div`,{className:`upload-error-detail`,children:[f,p&&` `,p===null?null:l?(0,V.jsx)(`a`,{href:p,target:`_blank`,rel:`noopener noreferrer`,children:`Request this feature →`}):(0,V.jsx)(`a`,{href:p,target:`_blank`,rel:`noopener noreferrer`,children:`Report this issue →`})]})]}),(0,V.jsx)(`button`,{className:`upload-error-dismiss`,onClick:i,"aria-label":`Dismiss`,children:(0,V.jsx)(Bn,{size:14})})]})}function KS(e,t){let n=e=>t.some(t=>t.id===e&&t.configured),r=Wy(e);return r===`google`?n(`google`):r===`microsoft`?n(`microsoft`):r===`microsoft_work`?n(`microsoft_work`):n(`google`)||n(`microsoft`)||n(`microsoft_work`)}function qS(e,t){let n=e=>t.some(t=>t.id===e&&t.configured),r=Wy(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 JS=4e3;function YS({content:e,onRetry:t}){let[n,r]=(0,z.useState)([]),[i,a]=(0,z.useState)(!1),o=(0,z.useCallback)(()=>{li().then(e=>r(e.connectors||[])).catch(e=>s.ui.warn(`ConnectorRetryBanner: connector fetch failed`,e))},[]),c=KS(e,n);if((0,z.useEffect)(()=>{o();let e=()=>o();return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[o]),(0,z.useEffect)(()=>{if(c)return;let e=setInterval(o,JS);return()=>clearInterval(e)},[c,o]),!c||i)return null;let l=qS(e,n);return(0,V.jsxs)(`div`,{className:`connector-retry-banner`,role:`status`,children:[(0,V.jsx)(fe,{size:14,className:`connector-retry-banner__icon`}),(0,V.jsxs)(`span`,{className:`connector-retry-banner__text`,children:[l,` connected since this reply — ask again to run it now.`]}),(0,V.jsxs)(`button`,{type:`button`,className:`connector-retry-banner__btn`,onClick:()=>{a(!0),t()},children:[(0,V.jsx)(tn,{size:12}),(0,V.jsx)(`span`,{children:`Ask again`})]}),(0,V.jsx)(`button`,{type:`button`,className:`connector-retry-banner__dismiss`,onClick:()=>a(!0),"aria-label":`Dismiss`,children:`×`})]})}var XS=240,ZS=1e5;function QS({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,z.useRef)(null),h=d??m,g=(0,z.useRef)(null),_=!!s,v=e.trim().length>0||c.hasUploaded,y=c.compose(e.trim()).length,b=y>ZS,x=!_&&(!i||o)&&!c.uploading&&v&&!b,C=s||l;(0,z.useLayoutEffect)(()=>{let e=h.current;if(!e)return;let t=()=>{e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,XS)}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,C,h]);let w=(0,z.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),x&&n())},[x,n]),T=(0,z.useCallback)(e=>{e.dataTransfer?.files?.length&&(e.preventDefault(),e.stopPropagation(),c.addFiles(Array.from(e.dataTransfer.files)))},[c]);return(0,V.jsxs)(`div`,{className:`composer${_?` composer-disabled`:``}`,onDrop:T,onDragOver:e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault()},children:[c.attachments.length>0&&(0,V.jsx)(`ul`,{className:`composer-attachments`,"aria-label":`Attached files`,children:c.attachments.map(e=>(0,V.jsxs)(`li`,{className:`composer-attachment${e.error?` has-error`:``}`,children:[e.isImage&&e.url?(0,V.jsx)(`img`,{src:e.url,alt:``,className:`composer-attachment-thumb`}):(0,V.jsx)(Ke,{size:14,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`composer-attachment-name`,title:e.name,children:e.name}),e.uploading&&(0,V.jsx)(`span`,{className:`composer-attachment-state`,children:`Uploading…`}),e.error&&(0,V.jsx)(`span`,{className:`composer-attachment-state`,role:`alert`,title:e.error,children:e.error}),(0,V.jsx)(`button`,{type:`button`,className:`composer-icon-btn`,onClick:()=>c.remove(e.id),"aria-label":`Remove ${e.name}`,children:(0,V.jsx)(Bn,{size:12})})]},e.id))}),(0,V.jsx)(`textarea`,{ref:h,className:`composer-input`,value:e,onChange:e=>t(e.target.value),onKeyDown:w,onPaste:e=>{c.handlePaste(e)},placeholder:C,rows:1,disabled:_,autoFocus:u,"aria-label":`Message`}),b&&(0,V.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,V.jsxs)(`div`,{className:`composer-row`,children:[(0,V.jsxs)(`div`,{className:`composer-row-left`,children:[(0,V.jsx)(`button`,{type:`button`,className:`composer-icon-btn`,onClick:()=>g.current?.click(),disabled:_,"aria-label":`Attach files`,title:`Attach files`,children:(0,V.jsx)($t,{size:16})}),(0,V.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,V.jsxs)(`div`,{className:`composer-row-right`,children:[p,i&&o&&v&&(0,V.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,V.jsx)(S,{size:16})}),i?(0,V.jsx)(`button`,{type:`button`,className:`composer-send is-stop`,onClick:r,disabled:a,"aria-label":`Stop`,title:a?`Stopping…`:`Stop (Esc)`,children:(0,V.jsx)(wn,{size:12,fill:`currentColor`})}):(0,V.jsx)(`button`,{type:`button`,className:`composer-send`,onClick:n,disabled:!x,"aria-label":`Send`,title:`Send (Enter)`,children:(0,V.jsx)(S,{size:16})})]})]})]})}var $S=8,eC=8;function tC({label:e,warning:t,children:n,id:r,pinned:i=!1,onUnpin:a,tabIndex:o}){let s=(0,z.useId)(),c=r??s,l=(0,z.useRef)(null),u=(0,z.useRef)(null),[d,f]=(0,z.useState)(!1),p=d||i,[m,h]=(0,z.useState)(null);return(0,z.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+$S+t.width<=r-eC?(a=n.right+$S,o=e.top+e.height/2-t.height/2):n.left-$S-t.width>=eC?(a=n.left-$S-t.width,o=e.top+e.height/2-t.height/2):(a=Math.min(Math.max(eC,e.right-t.width),r-eC-t.width),o=e.top-$S-t.height>=eC?e.top-$S-t.height:e.bottom+$S),o=Math.min(Math.max(eC,o),i-eC-t.height),h({left:a,top:o})},[p]),(0,z.useEffect)(()=>{if(!p)return;let e=()=>{f(!1),a?.()};return window.addEventListener(`scroll`,e,!0),()=>window.removeEventListener(`scroll`,e,!0)},[p,a]),(0,V.jsxs)(V.Fragment,{children:[(0,V.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,V.jsx)(gt,{size:13,"aria-hidden":`true`})}),p&&(0,ax.createPortal)((0,V.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 nC(e){return e<.1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function rC(e){return e?`${nC(e.input_per_million)} in · ${nC(e.output_per_million)} out per 1M tokens`:`price unknown`}function iC(e){return`$${e.toFixed(2)}`}var aC=2e3,oC=`waiting_for_os_permission`,sC=5;function cC(e,t){let n=e.rank?`#${e.rank} ${e.note??``}`.trim():null;return t?[n,rC(e.price)].filter(e=>!!e):[xs(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 lC({m:e,onDownload:t,busy:n}){if(ws(e)){let t=Math.round(e.download_progress?.percent??0);return(0,V.jsxs)(`span`,{className:`model-state is-downloading`,title:`Downloading, ${t}%`,children:[(0,V.jsx)(R,{size:12,className:`spin`,"aria-hidden":`true`}),` `,t,`%`]})}let r=Cs(e);return r===`not_downloaded`?(0,V.jsx)(`button`,{type:`button`,className:`model-state-btn`,onClick:e=>{e.stopPropagation(),t()},disabled:n,"aria-label":`Download ${e.display_name??e.id}`,title:bs.not_downloaded,tabIndex:-1,children:(0,V.jsx)(Ae,{size:13,"aria-hidden":`true`})}):r===`loaded`?(0,V.jsx)(`span`,{className:`model-state is-loaded`,role:`img`,"aria-label":bs.loaded,title:bs.loaded}):(0,V.jsx)(`span`,{className:`model-state is-ready`,title:bs.downloaded,children:`Ready`})}function uC(){let e=cs(e=>e.active),t=cs(e=>e.select),n=cs(e=>e.queued),r=cs(e=>e.queue),i=cs(e=>e.queueError),a=cs(e=>e.rememberNames);cs(e=>e.names);let o=ms(),s=B(t=>hs(e,t.sessions,t.currentSessionId)),c=B(e=>e.isStreaming),l=B(e=>e.openSettings),u=(0,z.useRef)(null),[d,f]=(0,z.useState)(!1),[p,m]=(0,z.useState)(null),[h,g]=(0,z.useState)(0),[_,v]=(0,z.useState)(null),[y,b]=(0,z.useState)(null),[x,S]=(0,z.useState)(null),[C,w]=(0,z.useState)(null),[T,E]=(0,z.useState)(null),[D,O]=(0,z.useState)(0),[k,ee]=(0,z.useState)(null),A=(0,z.useRef)(0),j=(0,z.useRef)(null),te=(0,z.useId)(),M=(0,z.useRef)(null),[N,ne]=(0,z.useState)(null),[ie,F]=(0,z.useState)(null),ae=(0,z.useCallback)(()=>F(null),[]),oe=(0,z.useCallback)(()=>f(!1),[]),se=(0,z.useRef)(!1),le=(0,z.useCallback)(async(e=!1)=>{e||(se.current=!1,v(null),m(null));try{let{providers:t,lemonade_error:n}=await _a();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 Ca(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||(se.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,z.useEffect)(()=>{d&&(b(null),ne(null),F(null),le())},[d,le]),(0,z.useEffect)(()=>{if(!d||!p||!se.current)return;let e=M.current?.querySelector(`[role="option"][tabindex="0"]`);e&&(se.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(M.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(),F(t=>e.key===`i`&&t===r?null:r);return}case`ArrowLeft`:e.preventDefault(),F(null);return;default:return}e.preventDefault(),t[r].focus(),t[r].scrollIntoView?.({block:`nearest`})},de=!!p?.some(e=>e.models.some(ws)),fe=!!p?.some(e=>e.provider.key_state===oC);(0,z.useEffect)(()=>{if(!(d||T)||!(de||T||fe))return;let e=setInterval(()=>{le(!0)},aC);return()=>clearInterval(e)},[d,de,T,fe,le]);let pe=(0,z.useCallback)(async e=>{w(e),O(e=>e+1),v(null);try{await ra(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]),I=(0,z.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),ee(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,z.useEffect)(()=>{if(!T||!p||D>0)return;let{model:e,provider:t}=T,n=()=>(j.current!==p&&(j.current=p,A.current+=1),A.current>=sC),r=p.flatMap(e=>e.models).find(t=>t.id===e);if(!r){if(!n())return;E(null),ee(`${us(e)} is no longer in the model list, so it wasn't switched to.`);return}if(ws(r)){A.current=0;return}let i=r.download_progress;if(i?.state===`error`)E(null),ee(`Downloading ${us(e)} failed: ${i.message??`no reason given`}`);else if(i?.state!==`complete`&&Cs(r)===`not_downloaded`){if(!n())return;E(null),ee(`The download of ${us(e)} never started. Try the download button again.`)}else E(null),I(e,t).then(t=>{t&&ee(`${us(e)} downloaded, but switching to it failed: ${t}`)})},[p,T,D,I]);let L=p?.flatMap(({provider:e,models:t})=>[...e.remote&&!e.models_discovered?[`key:${e.id}`]:[],...t.filter(e=>x===null&&!ws(e)).map(e=>e.id)])??[],he=n??e?.model,ge=N&&L.includes(N)?N:he&&L.includes(he)?he:L[0],_e=e=>({role:`option`,tabIndex:e===ge?0:-1,"data-row":e,onFocus:()=>ne(e),onBlur:()=>F(null)}),ye=o?.remote?ve:o?Ee:me,be=s?us(s):`Model`,xe=`${be}${o?` · ${o.label}`:``}`,Se=Object.fromEntries((p??[]).map(e=>[e.provider.id,vs(e.models)])),Ce=e?.downloaded===!1&&s===e.model,we=k||i||(n?`${us(n)} is used from your next message.`:e?.config_error?e.config_error:Ce?`${be} 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`):ps);return(0,V.jsxs)(`div`,{className:`composer-chip-wrap`,children:[(0,V.jsxs)(`button`,{ref:u,type:`button`,className:`composer-chip${Ce||i||k?` is-warning`:``}`,onClick:()=>f(e=>!e),"aria-haspopup":`dialog`,"aria-expanded":d,title:we,children:[(0,V.jsx)(ye,{size:13,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`composer-chip-label`,children:xe}),n&&(0,V.jsxs)(`span`,{className:`composer-chip-next`,children:[`→ `,us(n),` next`]}),Ce&&(0,V.jsx)(Ae,{size:12,"aria-label":`Not downloaded`}),k&&(0,V.jsx)(ce,{size:12,"aria-label":`Model switch failed`}),(0,V.jsx)(re,{size:12,"aria-hidden":`true`})]}),(0,V.jsxs)(ni,{open:d,onClose:oe,anchor:u,label:`Choose a model`,align:`end`,children:[c&&(0,V.jsxs)(`div`,{className:`popover-message`,role:`status`,children:[`This reply keeps `,s?us(s):`its model`,`. A model you pick here is used from your next message.`]}),k&&(0,V.jsx)(`div`,{className:`popover-message is-error`,role:`alert`,children:k}),i&&(0,V.jsx)(`div`,{className:`popover-message is-error`,role:`alert`,children:i}),_&&(0,V.jsx)(`div`,{className:`popover-message is-error`,role:`alert`,children:_}),!p&&!_&&(0,V.jsxs)(`div`,{className:`popover-message`,children:[(0,V.jsx)(R,{size:13,className:`spin`}),` Loading models…`]}),p&&(0,V.jsx)(`div`,{ref:M,role:`listbox`,"aria-label":`Models`,onKeyDown:ue,children:p.map(({provider:t,models:r,error:i})=>(0,V.jsxs)(`div`,{role:`group`,"aria-labelledby":`${te}-${t.id}`,children:[(0,V.jsx)(`div`,{className:`popover-heading`,id:`${te}-${t.id}`,children:t.name}),i&&(0,V.jsx)(`div`,{className:`popover-message is-error`,children:i}),t.key_state===oC?(0,V.jsxs)(`div`,{className:`popover-message`,role:`status`,children:[(0,V.jsx)(R,{size:13,className:`spin`,"aria-hidden":`true`}),` `,t.key_message]}):t.remote&&!t.models_discovered&&(0,V.jsxs)(`button`,{type:`button`,className:`popover-item`,..._e(`key:${t.id}`),"aria-selected":!1,onClick:()=>{f(!1),l(`model`,t.id)},children:[(0,V.jsx)(`span`,{className:`popover-item-check`,children:(0,V.jsx)(vt,{size:13,"aria-hidden":`true`})}),(0,V.jsxs)(`span`,{className:`popover-item-body`,children:[(0,V.jsx)(`span`,{className:`popover-item-title`,children:`Add your key`}),(0,V.jsxs)(`span`,{className:`popover-item-note`,children:[`Connect `,t.name,` in Settings`]})]})]}),!i&&r.length===0&&t.models_discovered!==!1&&(0,V.jsx)(`div`,{className:`popover-message`,children:`No models yet.`}),r.map(r=>{let i=(n??e?.model)===r.id,a=!t.remote&&Cs(r)===`not_downloaded`,o=Se[t.id][r.id],s=cC(r,t.remote),c=`${te}-info-${t.id}-${r.id}`;return(0,V.jsxs)(`div`,{className:`popover-row`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`popover-item`,onClick:()=>{a?(A.current=0,ee(null),E({model:r.id,provider:t}),pe(r.id)):(E(null),I(r.id,t))},disabled:x!==null||ws(r),..._e(r.id),"aria-selected":i,"aria-describedby":ie===r.id?c:void 0,children:[(0,V.jsx)(`span`,{className:`popover-item-check`,"aria-hidden":`true`,children:x===r.id?(0,V.jsx)(R,{size:13,className:`spin`}):i?(0,V.jsx)(P,{size:13}):null}),(0,V.jsx)(`span`,{className:`popover-item-body`,children:(0,V.jsx)(`span`,{className:`popover-item-title`,children:o})})]}),(0,V.jsxs)(tC,{label:`About ${o}`,warning:!!r.placement?.warning,id:c,pinned:ie===r.id,onUnpin:ae,tabIndex:-1,children:[(0,V.jsx)(`div`,{className:`info-bubble-title`,children:o}),s.length>0&&(0,V.jsx)(`ul`,{className:`info-bubble-lines`,children:s.map(e=>(0,V.jsx)(`li`,{children:e},e))}),r.placement?.warning&&(0,V.jsx)(`ul`,{className:`info-bubble-lines`,children:(0,V.jsx)(`li`,{className:`is-warning`,children:r.placement.warning})}),(0,V.jsx)(`div`,{className:`info-bubble-id`,children:r.id})]}),(0,V.jsx)(`span`,{className:`popover-row-state`,children:!t.remote&&(0,V.jsx)(lC,{m:r,busy:C!==null,onDownload:()=>void pe(r.id)})})]},r.id)})]},t.id))}),y&&(0,V.jsxs)(`div`,{className:`popover-message`,role:`alert`,children:[y.provider.privacy_notice,` `,(0,V.jsxs)(`button`,{type:`button`,className:`link-btn`,onClick:()=>I(y.model,y.provider),children:[`Use `,us(y.model)]})]}),h>0&&(0,V.jsxs)(`button`,{type:`button`,className:`popover-item`,onClick:()=>{f(!1),l(`model`)},children:[(0,V.jsx)(`span`,{className:`popover-item-check`}),(0,V.jsx)(`span`,{className:`popover-item-body`,children:(0,V.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,V.jsx)(`div`,{className:`popover-divider`}),(0,V.jsxs)(`button`,{type:`button`,className:`popover-item`,onClick:()=>{f(!1),l(`model`)},children:[(0,V.jsx)(`span`,{className:`popover-item-check`}),(0,V.jsx)(`span`,{className:`popover-item-body`,children:(0,V.jsx)(`span`,{className:`popover-item-title`,children:`Providers and keys…`})})]})]})]})}var dC=`gaia:permission-mode`;function fC(e,t){window.dispatchEvent(new CustomEvent(dC,{detail:{sessionId:e,mode:t}}))}function pC(e,t){let n=(0,z.useRef)(t);n.current=t,(0,z.useEffect)(()=>{if(!e)return;let t=t=>{let r=t.detail;r?.sessionId===e&&n.current(r.mode)};return window.addEventListener(dC,t),()=>window.removeEventListener(dC,t)},[e])}var mC=[{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 hC({sessionId:e,disabled:t}){let n=B(e=>e.draftPermissionMode),r=B(e=>e.setDraftPermissionMode),[i,a]=(0,z.useState)(e?`ask`:n),[o,s]=(0,z.useState)(!1),[c,l]=(0,z.useState)(!1),[u,d]=(0,z.useState)(null),f=(0,z.useRef)(null);(0,z.useEffect)(()=>{if(!e){a(n);return}let t=!1;return Pi(e).then(e=>{t||a(e.mode)}).catch(e=>{t||d(e instanceof Error?e.message:String(e))}),()=>{t=!0}},[e,n]),pC(e,a);let p=(0,z.useCallback)(async t=>{if(t===`full_access`&&!c)l(!0);else{d(null);try{if(e){let n=(await Ii(e,t)).mode;a(n),fC(e,n)}else r(t),a(t);s(!1)}catch(t){d(t instanceof Error?t.message:String(t)),e&&Pi(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,V.jsxs)(`div`,{className:`composer-chip-wrap`,children:[(0,V.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,V.jsx)(m?un:fn,{size:13,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`composer-chip-label`,children:m?`Full access`:`Ask`}),(0,V.jsx)(re,{size:12,"aria-hidden":`true`})]}),(0,V.jsxs)(ni,{open:o,onClose:()=>s(!1),anchor:f,label:`Permission mode`,children:[mC.map(e=>(0,V.jsxs)(`button`,{type:`button`,className:`popover-item`,onClick:()=>p(e.mode),"aria-pressed":i===e.mode,children:[(0,V.jsx)(`span`,{className:`popover-item-check`,"aria-hidden":`true`,children:i===e.mode&&(0,V.jsx)(P,{size:13})}),(0,V.jsxs)(`span`,{className:`popover-item-body`,children:[(0,V.jsx)(`span`,{className:`popover-item-title`,children:e.label}),(0,V.jsx)(`span`,{className:`popover-item-note`,children:e.note})]})]},e.mode)),c&&(0,V.jsxs)(`div`,{className:`popover-message`,role:`alert`,children:[`Full access lets GAIA change files and run commands on this PC without asking.`,` `,(0,V.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>p(`full_access`),children:`Turn it on`})]}),u&&(0,V.jsx)(`div`,{className:`popover-message is-error`,role:`alert`,children:u})]})]})}var gC={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 _C(e,t){return e?gC.queued:t?`GAIA is still busy in this chat. Trying again in a few seconds.`:`Sending next.`}function vC({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,V.jsx)(`ul`,{className:`queued-messages`,"aria-label":`Messages waiting to send`,"aria-live":`polite`,children:o.map(e=>(0,V.jsxs)(`li`,{className:`queued-message is-${e.state}`,children:[e.state===`failed`?(0,V.jsx)(ce,{size:12,"aria-hidden":`true`}):e.state===`queued`?(0,V.jsx)(ge,{size:12,"aria-hidden":`true`}):(0,V.jsx)(we,{size:12,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`queued-message-text`,title:e.text,children:e.text}),(0,V.jsx)(`span`,{className:`queued-message-state`,title:e.error,children:e.state===`failed`?`Not sent. ${e.error??``}`.trim():e.state===`queued`?_C(i,a):gC[e.state]}),e.state===`failed`&&(0,V.jsxs)(`button`,{type:`button`,className:`queued-message-steer`,onClick:()=>r(e.id),"aria-label":`Send again: ${e.text}`,children:[(0,V.jsx)(rn,{size:11,"aria-hidden":`true`}),` Send again`]}),e.state===`queued`&&n&&(0,V.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,V.jsx)(`button`,{type:`button`,className:`queued-message-remove`,onClick:()=>t(e.id),"aria-label":`Remove queued message: ${e.text}`,title:`Remove`,children:(0,V.jsx)(Bn,{size:12})})]},e.id))})}var yC=`unknown`,bC=e=>e.toLocaleString(`en-US`);function xC({n:e}){if(e==null)return(0,V.jsx)(`span`,{className:`cp-unknown`,children:yC});let t=e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(+(e<1e4))}K`:`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`;return(0,V.jsx)(`span`,{title:`${bC(e)} tokens`,children:t})}function SC({s:e}){if(e==null)return(0,V.jsx)(`span`,{className:`cp-unknown`,children:yC});let t=e<.1?e===0?`0 s`:`<0.1 s`:e<10?`${e.toFixed(1)} s`:`${Math.round(e)} s`;return(0,V.jsx)(`span`,{title:`${(e*1e3).toFixed(0)} ms`,children:t})}function CC({r:e}){return e==null?(0,V.jsx)(`span`,{className:`cp-unknown`,children:yC}):(0,V.jsxs)(`span`,{title:`${e} tokens per second`,children:[Math.round(e).toLocaleString(`en-US`),` tokens/s`]})}var wC=(e,t)=>t>0?Math.round(e/t*100):0,TC=(e,t)=>{let n=wC(e,t);return n===0&&e>0?`<1`:String(n)},EC=(e,t)=>t&&e!=null?Math.floor(e/t*100):null,DC=256;function OC(e){if(e.provider===`unknown`)return yC;if(e.provider===`cloud`)return`Cloud`;if(e.provider!==`local`)return`Cloud · ${ys(e.provider)}`;if(!e.device)return e.loaded===!1?`Not loaded now`:yC;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 kC({label:e,children:t,hint:n}){return(0,V.jsxs)(`div`,{className:`cp-row`,title:n,children:[(0,V.jsx)(`dt`,{children:e}),(0,V.jsx)(`dd`,{children:t})]})}function AC({t:e}){if(e.model_seconds==null||e.gaia_seconds==null)return(0,V.jsxs)(kC,{label:`Took`,children:[(0,V.jsx)(SC,{s:e.wall_seconds}),` · split `,(0,V.jsx)(`span`,{className:`cp-unknown`,children:yC})]});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,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(kC,{label:`Took`,hint:`From sending the message to the answer being saved`,children:(0,V.jsx)(SC,{s:e.wall_seconds})}),(0,V.jsx)(`div`,{className:`cp-stack`,"aria-hidden":`true`,children:t.map(t=>(0,V.jsx)(`span`,{className:`cp-time-${t.key}`,style:{width:`${wC(t.s,e.wall_seconds)}%`}},t.key))}),(0,V.jsxs)(`dl`,{className:`cp-rows cp-indent`,children:[(0,V.jsx)(kC,{label:`In the model`,children:(0,V.jsx)(SC,{s:e.model_seconds})}),(0,V.jsx)(kC,{label:`In GAIA`,hint:`Everything that was not the model: tools, waiting on you, and GAIA's own work`,children:(0,V.jsx)(SC,{s:e.gaia_seconds})}),t.slice(1).filter(e=>e.s>0).map(e=>(0,V.jsxs)(kC,{label:`· ${e.label}`,children:[(0,V.jsx)(`span`,{className:`swatch cp-time-${e.key}`,"aria-hidden":`true`}),` `,(0,V.jsx)(SC,{s:e.s})]},e.key))]})]})}function jC({why:e}){return(0,V.jsx)(`span`,{className:`cp-unknown`,title:e,children:yC})}var MC={server:`Reported by the model server`,client:`Measured by GAIA on the stream, network included`};function NC(e){return e?MC[e]:void 0}function PC({turn:e}){let t=EC(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(`
|
|
60
60
|
`);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(AC,{t:e.time}),(0,V.jsxs)(`dl`,{className:`cp-rows`,children:[(0,V.jsx)(kC,{label:`First word`,hint:NC(e.first_token_source),children:e.first_token_seconds==null?(0,V.jsx)(jC,{why:n.first_token_seconds}):(0,V.jsxs)(V.Fragment,{children:[`in `,(0,V.jsx)(SC,{s:e.first_token_seconds})]})}),(0,V.jsx)(kC,{label:`Reading the prompt`,hint:`Prefill: new prompt tokens over time to first token`,children:e.tokens_new!=null&&e.tokens_new<DC?(0,V.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,V.jsx)(jC,{why:n.prefill_tokens_per_second}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(CC,{r:e.prefill_tokens_per_second}),e.prefill_source===`client`&&(0,V.jsx)(`span`,{className:`cp-chip`,title:`Measured by GAIA from the first word, so it includes network and queue time`,children:`approx.`})]})}),(0,V.jsx)(kC,{label:`Writing the answer`,hint:NC(e.generation_source)??`Generation speed, weighted by tokens`,children:e.generation_tokens_per_second==null?(0,V.jsx)(jC,{why:n.generation_tokens_per_second}):(0,V.jsx)(CC,{r:e.generation_tokens_per_second})}),(0,V.jsxs)(kC,{label:`Tokens in → out`,hint:n.tokens,children:[(0,V.jsx)(xC,{n:e.tokens_in}),` → `,(0,V.jsx)(xC,{n:e.tokens_out})]}),(0,V.jsx)(kC,{label:`Reused from cache`,hint:`Prompt tokens the server did not have to read again`,children:e.tokens_cached==null?(0,V.jsx)(jC,{why:n.tokens_cached}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(xC,{n:e.tokens_cached}),t!=null&&` (${t}%)`]})}),(0,V.jsx)(kC,{label:`Model calls`,children:e.model_calls}),(0,V.jsx)(kC,{label:`Tool calls`,hint:r||void 0,children:e.tool_calls===0&&!e.tool_seconds_total?`none`:(0,V.jsxs)(V.Fragment,{children:[e.tool_calls,` · `,(0,V.jsx)(SC,{s:e.tool_seconds_total??0})]})}),(0,V.jsx)(kC,{label:`Model loads`,children:e.loads.length===0?`none`:(0,V.jsxs)(`span`,{title:e.loads.map(e=>`${e.model}${e.replaced?.length?` replaced ${e.replaced.join(`, `)}`:``}: ${e.seconds} s`).join(`
|
|
61
|
-
`),children:[e.loads.length,` · `,(0,V.jsx)(SC,{s:e.loads.reduce((e,t)=>e+t.seconds,0)})]})}),(0,V.jsx)(kC,{label:`Cost`,children:(0,V.jsx)(FC,{cost:e.cost})})]})]})}function FC({cost:e}){return e.kind===`local`?(0,V.jsx)(`span`,{title:`Runs on this PC`,children:`$0 · on this PC`}):e.kind===`estimate`&&e.usd!=null?(0,V.jsxs)(`span`,{title:`$${e.usd} at list price`,children:[`about $`,e.usd<.01?e.usd.toFixed(4):e.usd.toFixed(2)]}):(0,V.jsx)(`span`,{className:`cp-unknown`,children:yC})}function IC({totals:e}){let t=EC(e.tokens_cached,e.tokens_in);return(0,V.jsxs)(`dl`,{className:`cp-rows`,children:[(0,V.jsx)(kC,{label:`Turns measured`,children:e.turns}),(0,V.jsx)(kC,{label:`Total time`,children:(0,V.jsx)(SC,{s:e.wall_seconds})}),(0,V.jsx)(kC,{label:`In the model`,children:(0,V.jsx)(SC,{s:e.model_seconds})}),(0,V.jsx)(kC,{label:`In GAIA`,children:(0,V.jsx)(SC,{s:e.gaia_seconds})}),(0,V.jsxs)(kC,{label:`Tokens in → out`,children:[(0,V.jsx)(xC,{n:e.tokens_in}),` → `,(0,V.jsx)(xC,{n:e.tokens_out})]}),(0,V.jsx)(kC,{label:`Reused from cache`,children:e.tokens_cached==null?(0,V.jsx)(`span`,{className:`cp-unknown`,children:yC}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(xC,{n:e.tokens_cached}),t!=null&&` (${t}%)`]})}),(0,V.jsx)(kC,{label:`Tool calls`,children:e.tool_calls}),(0,V.jsx)(kC,{label:`Model loads`,children:e.loads===0?`none`:(0,V.jsxs)(V.Fragment,{children:[e.loads,` · `,(0,V.jsx)(SC,{s:e.load_seconds})]})}),(0,V.jsx)(kC,{label:`Cost`,children:e.unpriced_turns>0?(0,V.jsxs)(`span`,{title:`${e.unpriced_turns} turn(s) on a model with no known price`,children:[`$`,e.usd.toFixed(2),` + `,e.unpriced_turns,` unpriced`]}):e.usd===0?`$0`:`about $${e.usd.toFixed(2)}`})]})}function LC({usage:e}){let t=e.context_state?.put_away,n=e.context_state?.summarized;return(0,V.jsxs)(`div`,{className:`cp-full`,children:[(0,V.jsxs)(`dl`,{className:`cp-rows`,children:[(0,V.jsx)(kC,{label:`Live in the window`,children:(0,V.jsx)(xC,{n:e.used})}),t&&t.results>0&&(0,V.jsxs)(kC,{label:`Put away`,hint:`Older tool results moved out of the prompt; still readable`,children:[t.results,` `,t.results===1?`result`:`results`,` · `,(0,V.jsx)(xC,{n:t.tokens})]}),n&&n.turns>0&&(0,V.jsxs)(kC,{label:`Summarized`,hint:`Older turns folded into a running summary; the originals stay saved`,children:[n.turns,` earlier `,n.turns===1?`turn`:`turns`,` · `,(0,V.jsx)(xC,{n:n.tokens}),` → `,(0,V.jsx)(xC,{n:n.summary_tokens})]})]}),n&&n.turns>0&&(0,V.jsx)(`p`,{className:`cp-note cp-summarized`,children:`Earlier messages summarized — still searchable.`}),e.at_risk.length>0&&(0,V.jsx)(`p`,{className:`cp-warning`,role:`status`,children:`The window is filling up. Older tool results move out of the prompt and stay readable, and the oldest turns may drop out of the model's view. They stay saved, and you can ask GAIA to recall them.`})]})}function RC({sessionId:e,busy:t,onUsage:n}){let[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(null),[c,l]=(0,z.useState)(null),[u,d]=(0,z.useState)(null),[f,p]=(0,z.useState)(null),[m,h]=(0,z.useState)(`turn`),g=(0,z.useRef)(n);g.current=n;let _=(0,z.useCallback)(()=>{let t=!1,n=(n,r)=>i=>{t||(s.chat.error(`Could not read the ${n} for session=${e}`,i),r(i instanceof Error?i.message:String(i)))};return Di(e).then(e=>{t||(e.available?(i(e),o(null),g.current?.(e)):(i(null),o(e.reason)),d(null))}).catch(n(`context usage`,d)),Oi(e).then(e=>{t||(l(e),p(null))}).catch(n(`performance`,p)),()=>{t=!0}},[e]);(0,z.useEffect)(()=>_(),[_]);let v=(0,z.useRef)(t);(0,z.useEffect)(()=>{let e=v.current&&!t;return v.current=t,e?_():void 0},[t,_]);let y=c?.turns[c.turns.length-1]??null,b=y&&y.message_id===c?.latest_message_id?y:null,x=r?Math.max(0,r.window-r.used):0;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`section`,{"aria-labelledby":`cp-context`,children:[(0,V.jsx)(`h3`,{id:`cp-context`,children:`Context`}),u&&(0,V.jsx)(`p`,{className:`cp-error`,role:`alert`,children:u}),!r&&!u&&(0,V.jsx)(`p`,{className:`cp-note`,children:a??`Measuring…`}),r&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`p`,{className:`cp-lead`,children:[(0,V.jsxs)(`strong`,{children:[wC(r.used,r.window),`% used`]}),` · `,(0,V.jsx)(xC,{n:r.used}),` of `,(0,V.jsx)(xC,{n:r.window}),` tokens`,r.model&&(0,V.jsxs)(V.Fragment,{children:[` · `,(0,V.jsx)(`span`,{className:`cp-model`,children:r.model})]}),r.model_window!=null&&r.model_window>r.window&&(0,V.jsxs)(`span`,{className:`cp-window-note`,title:`GAIA admits this much of the window, so older turns drop out of view sooner than the model would need`,children:[` `,`· GAIA uses `,(0,V.jsx)(xC,{n:r.window}),` of the model's `,(0,V.jsx)(xC,{n:r.model_window})]}),r.tokenizer&&!r.tokenizer.exact&&(0,V.jsx)(`span`,{className:`cp-chip`,title:r.tokenizer.reason,children:`approx.`})]}),(0,V.jsx)(`div`,{className:`cp-stack`,"aria-hidden":`true`,children:(r.categories??[]).map(e=>(0,V.jsx)(`span`,{className:`cp-cat-${e.key}`,style:{width:`${e.tokens/r.window*100}%`}},e.key))}),(0,V.jsxs)(`dl`,{className:`cp-rows`,children:[(r.categories??[]).map(e=>(0,V.jsxs)(`div`,{className:`cp-row`,children:[(0,V.jsxs)(`dt`,{children:[(0,V.jsx)(`span`,{className:`swatch cp-cat-${e.key}`,"aria-hidden":`true`}),e.label]}),(0,V.jsxs)(`dd`,{children:[(0,V.jsx)(xC,{n:e.tokens}),` `,(0,V.jsxs)(`span`,{className:`cp-pct`,children:[TC(e.tokens,r.window),`%`]})]})]},e.key)),(0,V.jsxs)(`div`,{className:`cp-row is-quiet`,children:[(0,V.jsxs)(`dt`,{children:[(0,V.jsx)(`span`,{className:`swatch cp-cat-free`,"aria-hidden":`true`}),`Free`]}),(0,V.jsxs)(`dd`,{children:[(0,V.jsx)(xC,{n:x}),` `,(0,V.jsxs)(`span`,{className:`cp-pct`,children:[wC(x,r.window),`%`]})]})]}),(0,V.jsxs)(`div`,{className:`cp-row is-quiet cp-indent`,children:[(0,V.jsx)(`dt`,{children:`of which kept for the reply`}),(0,V.jsx)(`dd`,{children:(0,V.jsx)(xC,{n:Math.min(x,r.reply_reserve)})})]})]}),(0,V.jsxs)(`p`,{className:`cp-note`,children:[r.tokenizer?.exact?`Each part counted with ${r.tokenizer.model}'s own tokenizer.`:`Estimated: ${r.tokenizer?.reason??`counted with a shared tokenizer.`}`,b?.last_prompt_tokens!=null&&(0,V.jsxs)(V.Fragment,{children:[` `,`The last request carried`,` `,(0,V.jsx)(`span`,{title:`${bC(b.last_prompt_tokens)} tokens`,children:bC(b.last_prompt_tokens)}),` `,`tokens as the model server counted them, chat formatting included.`]})]}),r.tool_loading&&r.tool_loading.on_demand.length>0&&(0,V.jsxs)(`details`,{className:`cp-details`,children:[(0,V.jsxs)(`summary`,{children:[r.tool_loading.on_demand.length,` more tools load only when needed`]}),(0,V.jsxs)(`p`,{className:`cp-note`,children:[`Sent now: `,r.tool_loading.loaded.length,`. These cost nothing until a turn needs them:`]}),(0,V.jsx)(`ul`,{className:`cp-tools`,children:r.tool_loading.on_demand.map(e=>(0,V.jsx)(`li`,{children:e},e))})]}),(0,V.jsx)(LC,{usage:r})]})]}),(0,V.jsxs)(`section`,{"aria-labelledby":`cp-hood`,children:[(0,V.jsxs)(`div`,{className:`cp-section-head`,children:[(0,V.jsx)(`h3`,{id:`cp-hood`,children:`Under the hood`}),(0,V.jsxs)(`div`,{className:`cp-toggle`,role:`group`,"aria-label":`Show`,children:[(0,V.jsx)(`button`,{type:`button`,"aria-pressed":m===`turn`,onClick:()=>h(`turn`),children:`Last turn`}),(0,V.jsx)(`button`,{type:`button`,"aria-pressed":m===`chat`,onClick:()=>h(`chat`),children:`This chat`})]})]}),c&&(0,V.jsxs)(`dl`,{className:`cp-rows`,children:[(0,V.jsx)(kC,{label:`Runs on`,hint:c.now.error??void 0,children:OC(c.now)}),c.now.provider===`local`&&(0,V.jsxs)(kC,{label:`Model memory`,hint:`Model weights + KV cache at this window; free memory now`,children:[c.now.weights_gb==null?(0,V.jsx)(`span`,{className:`cp-unknown`,children:yC}):(0,V.jsxs)(V.Fragment,{children:[c.now.weights_gb.toFixed(1),` GB model`,c.now.kv_cache_gb!=null&&` + ${c.now.kv_cache_gb.toFixed(1)} GB cache`]}),` · `,c.now.free_gb==null?(0,V.jsxs)(`span`,{className:`cp-unknown`,children:[`free `,yC]}):`${c.now.free_gb.toFixed(1)} GB free`]})]}),f&&(0,V.jsx)(`p`,{className:`cp-error`,role:`alert`,children:f}),!c&&!f&&(0,V.jsx)(`p`,{className:`cp-note`,children:`Measuring…`}),c&&m===`turn`&&(b?(0,V.jsx)(PC,{turn:b}):(0,V.jsx)(`p`,{className:`cp-note`,children:c.latest_message_id==null?`Shown after GAIA's next answer in this chat.`:(0,V.jsxs)(V.Fragment,{children:[`Latest answer: `,(0,V.jsx)(`span`,{className:`cp-unknown`,children:yC}),`. It was not measured.`]})})),c&&m===`chat`&&(0,V.jsx)(IC,{totals:c.totals})]})]})}function zC({sessionId:e,busy:t,onClose:n,onUsage:r}){let i=(0,z.useRef)(null),a=(0,z.useRef)(n);a.current=n,(0,z.useEffect)(()=>{i.current?.focus()},[]),ei(!0,(0,z.useCallback)(()=>a.current(),[]));let o=(0,z.useRef)(null);return fx(o,!0),(0,V.jsx)(`div`,{className:`cp-overlay`,onClick:n,children:(0,V.jsxs)(`aside`,{ref:o,className:`cp-sheet`,role:`dialog`,"aria-modal":`true`,"aria-label":`Context and performance`,onClick:e=>e.stopPropagation(),children:[(0,V.jsxs)(`header`,{className:`cp-header`,children:[(0,V.jsx)(`h2`,{children:`Context & performance`}),(0,V.jsx)(`button`,{ref:i,type:`button`,className:`cp-icon`,onClick:n,"aria-label":`Close`,children:(0,V.jsx)(Bn,{size:16})})]}),(0,V.jsx)(`div`,{className:`cp-body`,children:(0,V.jsx)(RC,{sessionId:e,busy:t,onUsage:r})})]})})}function BC(e){return e<1e3?String(e):`${(e/1e3).toFixed(+(e<1e4))}K`}var VC=[{key:`system`,label:`System prompt`},{key:`tools`,label:`Tools`},{key:`documents`,label:`Documents`},{key:`history`,label:`Conversation`},{key:`query`,label:`Your message`}];function HC({usage:e,unavailable:t,sessionId:n,busy:r=!1,onUsage:i,onDetails:a}){let o=(0,z.useRef)(null),[s,c]=(0,z.useState)(!1),[l,u]=(0,z.useState)(!1),d=l&&n?(0,V.jsx)(zC,{sessionId:n,busy:r,onUsage:i,onClose:()=>u(!1)}):null;if(!e)return t?(0,V.jsxs)(`span`,{className:`context-meter is-empty`,title:t,children:[(0,V.jsx)(`span`,{className:`context-meter-bar`,"aria-hidden":`true`,children:(0,V.jsx)(`span`,{style:{width:0}})}),(0,V.jsx)(`span`,{className:`context-meter-label`,children:`Context`})]}):null;let f=Math.min(100,Math.round(e.used/e.window*100)),p=e.at_risk.length>0,m=Math.max(0,e.window-e.used-e.reply_reserve);return(0,V.jsxs)(`div`,{className:`composer-chip-wrap context-meter-wrap`,children:[(0,V.jsxs)(`button`,{ref:o,type:`button`,className:`context-meter${p?` is-warning`:``}`,onClick:()=>c(e=>!e),"aria-expanded":s,"aria-label":`Context ${f}% full: ${BC(e.used)} of ${BC(e.window)} tokens`,title:`How full the model's context window is`,children:[(0,V.jsx)(`span`,{className:`context-meter-bar`,"aria-hidden":`true`,children:(0,V.jsx)(`span`,{style:{width:`${f}%`}})}),(0,V.jsxs)(`span`,{className:`context-meter-label`,children:[f,`%`]})]}),(0,V.jsx)(ni,{open:s,onClose:()=>c(!1),anchor:o,label:`Context window`,align:`end`,children:(0,V.jsxs)(`div`,{className:`context-meter-panel`,children:[(0,V.jsxs)(`div`,{className:`context-meter-head`,children:[(0,V.jsx)(`strong`,{children:BC(e.used)}),` of `,BC(e.window),` tokens`]}),(0,V.jsx)(`div`,{className:`context-meter-stack`,"aria-hidden":`true`,children:VC.map(({key:t})=>(0,V.jsx)(`span`,{className:`part-${t}`,style:{width:`${e[t]/e.window*100}%`}},t))}),(0,V.jsxs)(`dl`,{className:`context-meter-rows`,children:[VC.filter(({key:t})=>t!==`query`||e.query>0).map(({key:t,label:n})=>(0,V.jsxs)(`div`,{className:`context-meter-row`,children:[(0,V.jsxs)(`dt`,{children:[(0,V.jsx)(`span`,{className:`swatch part-${t}`,"aria-hidden":`true`}),n]}),(0,V.jsx)(`dd`,{children:BC(e[t])})]},t)),(0,V.jsxs)(`div`,{className:`context-meter-row is-quiet`,children:[(0,V.jsx)(`dt`,{children:`Kept free for the reply`}),(0,V.jsx)(`dd`,{children:BC(e.reply_reserve)})]}),(0,V.jsxs)(`div`,{className:`context-meter-row is-quiet`,children:[(0,V.jsx)(`dt`,{children:`Free`}),(0,V.jsx)(`dd`,{children:BC(m)})]})]}),(0,V.jsxs)(`p`,{className:`context-meter-note`,children:[e.turns_in_view,` earlier `,e.turns_in_view===1?`turn is`:`turns are`,` in view`,e.turns_hidden>0&&`; ${e.turns_hidden} older ${e.turns_hidden===1?`is`:`are`} out of view`,`.`,` `,e.tokenizer?.exact?`Counted with the model's tokenizer.`:`Estimates.`,` `,`Older turns stay saved and can be recalled.`]}),n&&(0,V.jsx)(`button`,{type:`button`,className:`context-meter-details`,onClick:()=>{c(!1),a?a():u(!0)},children:`Details: context & performance`})]})}),d]})}function UC({usage:e}){if(!e||e.at_risk.length===0)return null;let t=e.at_risk.length;return(0,V.jsxs)(`div`,{className:`context-warning`,role:`status`,children:[(0,V.jsx)(An,{size:13,"aria-hidden":`true`}),(0,V.jsxs)(`span`,{children:[`The conversation is filling the model's context. The oldest`,t===1?` turn`:` ${t} turns`,` may drop out of the model's view next:`,` `,e.at_risk.map((e,t)=>(0,V.jsxs)(`span`,{children:[t>0&&`, `,(0,V.jsx)(`q`,{children:e})]},t)),`. They stay saved, and you can ask GAIA to recall them.`]})]})}async function WC(){let{providers:e,lemonade_error:t}=await _a();if(t)throw Error(t);return(await Promise.all(e.filter(e=>!e.remote).map(e=>Ca(e.id)))).flatMap(e=>e.models.filter(e=>e.downloaded).map(e=>({id:e.id,name:e.display_name??us(e.id)})))}function GC({answeredBy:e,onPick:t}){let n=(0,z.useRef)(null),[r,i]=(0,z.useState)(!1),[a,o]=(0,z.useState)(null),[s,c]=(0,z.useState)(null),l=(0,z.useCallback)(async()=>{o(null),c(null);try{o(await WC())}catch(e){c(e instanceof Error?e.message:String(e))}},[]);(0,z.useEffect)(()=>{r&&l()},[r,l]);let u=a?.filter(t=>t.id!==e)??[];return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{ref:n,type:`button`,className:`msg-action-btn`,onClick:()=>i(e=>!e),title:`Retry with another model`,"aria-label":`Retry with another model`,"aria-expanded":r,children:(0,V.jsx)(gn,{size:12})}),(0,V.jsx)(ni,{open:r,onClose:()=>i(!1),anchor:n,label:`Retry with`,placement:`below`,align:`end`,children:(0,V.jsxs)(`div`,{className:`retry-menu`,children:[(0,V.jsx)(`div`,{className:`retry-menu-head`,children:`Retry with…`}),s&&(0,V.jsx)(`div`,{className:`retry-menu-error`,role:`alert`,children:s}),!s&&a===null&&(0,V.jsxs)(`div`,{className:`retry-menu-empty`,children:[(0,V.jsx)(R,{size:12,className:`spin`,"aria-hidden":`true`}),` Loading models…`]}),a!==null&&u.length===0&&(0,V.jsx)(`div`,{className:`retry-menu-empty`,children:`No other model is downloaded on this PC. Add one in Settings → Model.`}),u.map(e=>(0,V.jsx)(`button`,{type:`button`,className:`retry-menu-item`,title:e.id,onClick:()=>{i(!1),t(e.id)},children:e.name},e.id))]})})]})}function KC(e){return e!=null&&e>0?`${(e/1e3).toFixed(1)} s`:null}function qC({parts:e}){let t=e.filter(Boolean);return t.length?(0,V.jsx)(`div`,{className:`compare-meta`,children:t.join(` · `)}):null}function JC({original:e,originalModel:t,originalLatencyMs:n,state:r,keeping:i,onKeep:a,onClose:o}){ls();let s=r.status===`ready`?r.result.model:r.model,c=e.stats?.tokens_per_second;return(0,V.jsxs)(`section`,{className:`answer-compare`,"aria-label":`Compare answers`,children:[(0,V.jsxs)(`header`,{className:`answer-compare-head`,children:[(0,V.jsx)(`span`,{children:`Compare answers`}),(0,V.jsx)(`button`,{type:`button`,className:`msg-action-btn`,onClick:o,"aria-label":`Close comparison`,disabled:!!i,children:(0,V.jsx)(Bn,{size:12})})]}),(0,V.jsxs)(`div`,{className:`answer-compare-cols`,children:[(0,V.jsxs)(`article`,{className:`compare-col`,"aria-label":`Answer from ${t??`the original model`}`,children:[(0,V.jsx)(`h4`,{children:t?us(t):`Original answer`}),(0,V.jsx)(qC,{parts:[KC(n),c?`${c} tok/s`:null]}),(0,V.jsx)(`div`,{className:`compare-body`,children:(0,V.jsx)(Qx,{content:e.content})}),(0,V.jsx)(`button`,{type:`button`,className:`compare-keep`,onClick:()=>a(`original`),disabled:!!i||r.status===`running`,children:i===`original`?`Keeping…`:`Keep this answer`})]}),(0,V.jsxs)(`article`,{className:`compare-col`,"aria-label":`Answer from ${s}`,children:[(0,V.jsx)(`h4`,{children:us(s)}),r.status===`running`&&(0,V.jsxs)(`div`,{className:`compare-wait`,children:[(0,V.jsx)(R,{size:14,className:`spin`,"aria-hidden":`true`}),(0,V.jsxs)(`span`,{children:[`Loading `,us(s),`, then answering from the same evidence. Tools are not run again.`]})]}),r.status===`failed`&&(0,V.jsx)(`div`,{className:`compare-error`,role:`alert`,children:r.error}),r.status===`ready`&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(qC,{parts:[`${r.result.stats.seconds.toFixed(1)} s`,r.result.stats.load_seconds>=1?`incl. ${r.result.stats.load_seconds.toFixed(1)} s loading`:null,r.result.stats.tokens_per_second?`${r.result.stats.tokens_per_second} tok/s`:null]}),(0,V.jsx)(`div`,{className:`compare-body`,children:(0,V.jsx)(Qx,{content:r.result.content})}),(0,V.jsx)(`button`,{type:`button`,className:`compare-keep`,onClick:()=>a(`retry`),disabled:!!i,children:i===`retry`?`Keeping…`:`Keep this answer`})]})]})]})]})}var YC=`gaia.sessionPanel.open`,XC=`gaia.sessionPanel.width`,ZC=`gaia.sessionPanel.sections`,QC={answer:!0,environment:!0,context:!1,outputs:!0,changes:!0};function $C(e,t,n){try{let r=window.localStorage.getItem(e);return r==null?n:t(r)}catch(t){return s.ui.warn(`Session panel setting ${e} unavailable; using the default`,t),n}}function ew(e,t){try{window.localStorage.setItem(e,t)}catch(t){s.ui.warn(`Could not remember session panel setting ${e}`,t)}}function tw(e){let t=typeof window<`u`?Math.floor(window.innerWidth*.5):640;return Math.round(Math.max(280,Math.min(e,640,Math.max(280,t))))}function nw(){return{open:$C(YC,e=>e!==`0`,!0),width:tw($C(XC,e=>Number(e)||320,320)),sections:{...QC,...$C(ZC,e=>JSON.parse(e),{})}}}var rw=$n((e,t)=>({...nw(),overlayOpen:!1,focus:null,setOpen:t=>{ew(YC,t?`1`:`0`),e({open:t})},setOverlayOpen:t=>e({overlayOpen:t}),setWidth:t=>{let n=tw(t);ew(XC,String(n)),e({width:n})},setSection:(n,r)=>{let i={...t().sections,[n]:r};ew(ZC,JSON.stringify(i)),e({sections:i})},reveal:n=>{let r={...t().sections,[n]:!0};ew(ZC,JSON.stringify(r)),ew(YC,`1`),e({sections:r,open:!0,overlayOpen:!0,focus:{section:n,nonce:Date.now()}})},reload:()=>e({...nw(),overlayOpen:!1,focus:null})}));function iw(e,t){if(t)return e.some(e=>e.turnSummary)?{kind:`busy`}:null;let n=e[e.length-1];return!n||n.role!==`assistant`||!n.turnSummary?null:{kind:`turn`,turn:n}}function aw(e){let t=e.live_data?.attempted??0;return t>0&&(e.live_data?.failed??0)>=t}function ow(e){try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}}function sw(e){return!e||e.length===0?null:`${e.length===1?`p.`:`pp.`} ${e.join(`, `)}`}function cw(e){let{cost:t}=e;return t.kind===`local`?`No cloud charges`:t.kind===`estimate`&&typeof t.usd==`number`?`About $${t.usd<.01?t.usd.toFixed(4):t.usd.toFixed(2)} at list price`:e.model?`Not known for this model`:`Not known`}function lw(e){return e instanceof Hi?e.detail||e.message:e instanceof Error?e.message:String(e)}function uw({messages:e,busy:t=!1}){let n=iw(e,t);if(!n)return null;let r=n.kind===`turn`?n.turn.turnSummary??null:null,i=r?aw(r):!1;return(0,V.jsxs)(`div`,{className:`side-rail-body`,children:[!r&&(0,V.jsx)(`p`,{className:`side-rail-pending`,role:`status`,children:`Working on this answer. Its sources, files and where its data went appear here when it finishes.`}),i&&(0,V.jsxs)(`div`,{className:`side-rail-warn`,role:`status`,children:[(0,V.jsx)(An,{size:14,"aria-hidden":`true`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`strong`,{children:`Couldn't get live data`}),(0,V.jsx)(`span`,{children:`Every web lookup this turn failed, so the answer isn't based on current information.`})]})]}),r&&(r.error?(0,V.jsxs)(`p`,{className:`side-rail-error`,role:`alert`,children:[`Couldn't put together this turn's sources and details: `,r.error]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fw,{summary:r}),(0,V.jsx)(hw,{summary:r}),(0,V.jsx)(gw,{summary:r})]}))]})}function dw({title:e,children:t}){let[n,r]=(0,z.useState)(!0);return(0,V.jsxs)(`section`,{className:`side-rail-section`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`side-rail-section-head`,onClick:()=>r(!n),"aria-expanded":n,children:[(0,V.jsx)(F,{size:12,className:`side-rail-chevron${n?` open`:``}`,"aria-hidden":`true`}),e]}),n&&(0,V.jsx)(`div`,{className:`side-rail-section-body`,children:t})]})}function fw({summary:e}){let t=e.pages??[],n=e.documents??[];return t.length===0&&n.length===0?null:(0,V.jsx)(dw,{title:`Sources`,children:(0,V.jsxs)(`ul`,{className:`side-rail-list`,children:[t.map(e=>(0,V.jsxs)(`li`,{className:`side-rail-item`,children:[(0,V.jsx)(ut,{size:13,className:`side-rail-item-icon`,"aria-hidden":`true`}),(0,V.jsxs)(`div`,{className:`side-rail-item-text`,children:[(0,V.jsxs)(`a`,{href:Sh(e.url)||void 0,target:`_blank`,rel:`noopener noreferrer`,className:`side-rail-link`,title:e.url,children:[(0,V.jsx)(`span`,{className:`side-rail-link-text`,children:e.title||ow(e.url)}),(0,V.jsx)(Pe,{size:10,"aria-hidden":`true`,className:`side-rail-link-icon`})]}),(0,V.jsxs)(`span`,{className:`side-rail-meta`,children:[ow(e.url),e.kind===`search_result`?` · search result`:``]})]})]},e.url)),n.map(e=>{let t=sw(e.pages),n=e.passages??0;return(0,V.jsxs)(`li`,{className:`side-rail-item`,children:[(0,V.jsx)(Ke,{size:13,className:`side-rail-item-icon`,"aria-hidden":`true`}),(0,V.jsxs)(`div`,{className:`side-rail-item-text`,children:[(0,V.jsx)(`span`,{className:`side-rail-name`,title:e.name,children:e.name}),(0,V.jsx)(`span`,{className:`side-rail-meta`,children:[t,`${n} passage${n===1?``:`s`}`].filter(Boolean).join(` · `)})]})]},e.path)})]})})}var pw=4e3;function mw(e){let t=e.join(`
|
|
61
|
+
`),children:[e.loads.length,` · `,(0,V.jsx)(SC,{s:e.loads.reduce((e,t)=>e+t.seconds,0)})]})}),(0,V.jsx)(kC,{label:`Cost`,children:(0,V.jsx)(FC,{cost:e.cost})})]})]})}function FC({cost:e}){return e.kind===`local`?(0,V.jsx)(`span`,{title:`Runs on this PC`,children:`$0 · on this PC`}):e.kind===`estimate`&&e.usd!=null?(0,V.jsxs)(`span`,{title:`$${e.usd} at list price`,children:[`about $`,e.usd<.01?e.usd.toFixed(4):e.usd.toFixed(2)]}):(0,V.jsx)(`span`,{className:`cp-unknown`,children:yC})}function IC({totals:e}){let t=EC(e.tokens_cached,e.tokens_in);return(0,V.jsxs)(`dl`,{className:`cp-rows`,children:[(0,V.jsx)(kC,{label:`Turns measured`,children:e.turns}),(0,V.jsx)(kC,{label:`Total time`,children:(0,V.jsx)(SC,{s:e.wall_seconds})}),(0,V.jsx)(kC,{label:`In the model`,children:(0,V.jsx)(SC,{s:e.model_seconds})}),(0,V.jsx)(kC,{label:`In GAIA`,children:(0,V.jsx)(SC,{s:e.gaia_seconds})}),(0,V.jsxs)(kC,{label:`Tokens in → out`,children:[(0,V.jsx)(xC,{n:e.tokens_in}),` → `,(0,V.jsx)(xC,{n:e.tokens_out})]}),(0,V.jsx)(kC,{label:`Reused from cache`,children:e.tokens_cached==null?(0,V.jsx)(`span`,{className:`cp-unknown`,children:yC}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(xC,{n:e.tokens_cached}),t!=null&&` (${t}%)`]})}),(0,V.jsx)(kC,{label:`Tool calls`,children:e.tool_calls??(0,V.jsx)(`span`,{className:`cp-unknown`,children:yC})}),(0,V.jsx)(kC,{label:`Model loads`,children:e.loads===0?`none`:(0,V.jsxs)(V.Fragment,{children:[e.loads,` · `,(0,V.jsx)(SC,{s:e.load_seconds})]})}),(0,V.jsx)(kC,{label:`Cost`,children:e.usd==null?(0,V.jsx)(`span`,{className:`cp-unknown`,children:yC}):e.unpriced_turns>0?(0,V.jsxs)(`span`,{title:`${e.unpriced_turns} turn(s) on a model with no known price`,children:[`$`,e.usd.toFixed(2),` + `,e.unpriced_turns,` unpriced`]}):e.usd===0?`$0`:`about $${e.usd.toFixed(2)}`})]})}function LC({usage:e}){let t=e.context_state?.put_away,n=e.context_state?.summarized;return(0,V.jsxs)(`div`,{className:`cp-full`,children:[(0,V.jsxs)(`dl`,{className:`cp-rows`,children:[(0,V.jsx)(kC,{label:`Live in the window`,children:(0,V.jsx)(xC,{n:e.used})}),t&&t.results>0&&(0,V.jsxs)(kC,{label:`Put away`,hint:`Older tool results moved out of the prompt; still readable`,children:[t.results,` `,t.results===1?`result`:`results`,` · `,(0,V.jsx)(xC,{n:t.tokens})]}),n&&n.turns>0&&(0,V.jsxs)(kC,{label:`Summarized`,hint:`Older turns folded into a running summary; the originals stay saved`,children:[n.turns,` earlier `,n.turns===1?`turn`:`turns`,` · `,(0,V.jsx)(xC,{n:n.tokens}),` → `,(0,V.jsx)(xC,{n:n.summary_tokens})]})]}),n&&n.turns>0&&(0,V.jsx)(`p`,{className:`cp-note cp-summarized`,children:`Earlier messages summarized — still searchable.`}),e.at_risk.length>0&&(0,V.jsx)(`p`,{className:`cp-warning`,role:`status`,children:`The window is filling up. Older tool results move out of the prompt and stay readable, and the oldest turns may drop out of the model's view. They stay saved, and you can ask GAIA to recall them.`})]})}function RC({sessionId:e,busy:t,onUsage:n}){let[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(null),[c,l]=(0,z.useState)(null),[u,d]=(0,z.useState)(null),[f,p]=(0,z.useState)(null),[m,h]=(0,z.useState)(`turn`),g=(0,z.useRef)(n);g.current=n;let _=(0,z.useCallback)(()=>{let t=!1,n=(n,r)=>i=>{t||(s.chat.error(`Could not read the ${n} for session=${e}`,i),r(i instanceof Error?i.message:String(i)))};return Di(e).then(e=>{t||(e.available?(i(e),o(null),g.current?.(e)):(i(null),o(e.reason)),d(null))}).catch(n(`context usage`,d)),Oi(e).then(e=>{t||(l(e),p(null))}).catch(n(`performance`,p)),()=>{t=!0}},[e]);(0,z.useEffect)(()=>_(),[_]);let v=(0,z.useRef)(t);(0,z.useEffect)(()=>{let e=v.current&&!t;return v.current=t,e?_():void 0},[t,_]);let y=c?.turns[c.turns.length-1]??null,b=y&&y.message_id===c?.latest_message_id?y:null,x=r?Math.max(0,r.window-r.used):0;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`section`,{"aria-labelledby":`cp-context`,children:[(0,V.jsx)(`h3`,{id:`cp-context`,children:`Context`}),u&&(0,V.jsx)(`p`,{className:`cp-error`,role:`alert`,children:u}),!r&&!u&&(0,V.jsx)(`p`,{className:`cp-note`,children:a??`Measuring…`}),r&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`p`,{className:`cp-lead`,children:[(0,V.jsxs)(`strong`,{children:[wC(r.used,r.window),`% used`]}),` · `,(0,V.jsx)(xC,{n:r.used}),` of `,(0,V.jsx)(xC,{n:r.window}),` tokens`,r.model&&(0,V.jsxs)(V.Fragment,{children:[` · `,(0,V.jsx)(`span`,{className:`cp-model`,children:r.model})]}),r.model_window!=null&&r.model_window>r.window&&(0,V.jsxs)(`span`,{className:`cp-window-note`,title:`GAIA admits this much of the window, so older turns drop out of view sooner than the model would need`,children:[` `,`· GAIA uses `,(0,V.jsx)(xC,{n:r.window}),` of the model's `,(0,V.jsx)(xC,{n:r.model_window})]}),r.tokenizer&&!r.tokenizer.exact&&(0,V.jsx)(`span`,{className:`cp-chip`,title:r.tokenizer.reason,children:`approx.`})]}),(0,V.jsx)(`div`,{className:`cp-stack`,"aria-hidden":`true`,children:(r.categories??[]).map(e=>(0,V.jsx)(`span`,{className:`cp-cat-${e.key}`,style:{width:`${e.tokens/r.window*100}%`}},e.key))}),(0,V.jsxs)(`dl`,{className:`cp-rows`,children:[(r.categories??[]).map(e=>(0,V.jsxs)(`div`,{className:`cp-row`,children:[(0,V.jsxs)(`dt`,{children:[(0,V.jsx)(`span`,{className:`swatch cp-cat-${e.key}`,"aria-hidden":`true`}),e.label]}),(0,V.jsxs)(`dd`,{children:[(0,V.jsx)(xC,{n:e.tokens}),` `,(0,V.jsxs)(`span`,{className:`cp-pct`,children:[TC(e.tokens,r.window),`%`]})]})]},e.key)),(0,V.jsxs)(`div`,{className:`cp-row is-quiet`,children:[(0,V.jsxs)(`dt`,{children:[(0,V.jsx)(`span`,{className:`swatch cp-cat-free`,"aria-hidden":`true`}),`Free`]}),(0,V.jsxs)(`dd`,{children:[(0,V.jsx)(xC,{n:x}),` `,(0,V.jsxs)(`span`,{className:`cp-pct`,children:[wC(x,r.window),`%`]})]})]}),(0,V.jsxs)(`div`,{className:`cp-row is-quiet cp-indent`,children:[(0,V.jsx)(`dt`,{children:`of which kept for the reply`}),(0,V.jsx)(`dd`,{children:(0,V.jsx)(xC,{n:Math.min(x,r.reply_reserve)})})]})]}),(0,V.jsxs)(`p`,{className:`cp-note`,children:[r.tokenizer?.exact?`Each part counted with ${r.tokenizer.model}'s own tokenizer.`:`Estimated: ${r.tokenizer?.reason??`counted with a shared tokenizer.`}`,b?.last_prompt_tokens!=null&&(0,V.jsxs)(V.Fragment,{children:[` `,`The last request carried`,` `,(0,V.jsx)(`span`,{title:`${bC(b.last_prompt_tokens)} tokens`,children:bC(b.last_prompt_tokens)}),` `,`tokens as the model server counted them, chat formatting included.`]})]}),r.tool_loading&&r.tool_loading.on_demand.length>0&&(0,V.jsxs)(`details`,{className:`cp-details`,children:[(0,V.jsxs)(`summary`,{children:[r.tool_loading.on_demand.length,` more tools load only when needed`]}),(0,V.jsxs)(`p`,{className:`cp-note`,children:[`Sent now: `,r.tool_loading.loaded.length,`. These cost nothing until a turn needs them:`]}),(0,V.jsx)(`ul`,{className:`cp-tools`,children:r.tool_loading.on_demand.map(e=>(0,V.jsx)(`li`,{children:e},e))})]}),(0,V.jsx)(LC,{usage:r})]})]}),(0,V.jsxs)(`section`,{"aria-labelledby":`cp-hood`,children:[(0,V.jsxs)(`div`,{className:`cp-section-head`,children:[(0,V.jsx)(`h3`,{id:`cp-hood`,children:`Under the hood`}),(0,V.jsxs)(`div`,{className:`cp-toggle`,role:`group`,"aria-label":`Show`,children:[(0,V.jsx)(`button`,{type:`button`,"aria-pressed":m===`turn`,onClick:()=>h(`turn`),children:`Last turn`}),(0,V.jsx)(`button`,{type:`button`,"aria-pressed":m===`chat`,onClick:()=>h(`chat`),children:`This chat`})]})]}),c&&(0,V.jsxs)(`dl`,{className:`cp-rows`,children:[(0,V.jsx)(kC,{label:`Runs on`,hint:c.now.error??void 0,children:OC(c.now)}),c.now.provider===`local`&&(0,V.jsxs)(kC,{label:`Model memory`,hint:`Model weights + KV cache at this window; free memory now`,children:[c.now.weights_gb==null?(0,V.jsx)(`span`,{className:`cp-unknown`,children:yC}):(0,V.jsxs)(V.Fragment,{children:[c.now.weights_gb.toFixed(1),` GB model`,c.now.kv_cache_gb!=null&&` + ${c.now.kv_cache_gb.toFixed(1)} GB cache`]}),` · `,c.now.free_gb==null?(0,V.jsxs)(`span`,{className:`cp-unknown`,children:[`free `,yC]}):`${c.now.free_gb.toFixed(1)} GB free`]})]}),f&&(0,V.jsx)(`p`,{className:`cp-error`,role:`alert`,children:f}),!c&&!f&&(0,V.jsx)(`p`,{className:`cp-note`,children:`Measuring…`}),c&&m===`turn`&&(b?(0,V.jsx)(PC,{turn:b}):(0,V.jsx)(`p`,{className:`cp-note`,children:c.latest_message_id==null?`Shown after GAIA's next answer in this chat.`:(0,V.jsxs)(V.Fragment,{children:[`Latest answer: `,(0,V.jsx)(`span`,{className:`cp-unknown`,children:yC}),`. It was not measured.`]})})),c&&m===`chat`&&(0,V.jsx)(IC,{totals:c.totals})]})]})}function zC({sessionId:e,busy:t,onClose:n,onUsage:r}){let i=(0,z.useRef)(null),a=(0,z.useRef)(n);a.current=n,(0,z.useEffect)(()=>{i.current?.focus()},[]),ei(!0,(0,z.useCallback)(()=>a.current(),[]));let o=(0,z.useRef)(null);return fx(o,!0),(0,V.jsx)(`div`,{className:`cp-overlay`,onClick:n,children:(0,V.jsxs)(`aside`,{ref:o,className:`cp-sheet`,role:`dialog`,"aria-modal":`true`,"aria-label":`Context and performance`,onClick:e=>e.stopPropagation(),children:[(0,V.jsxs)(`header`,{className:`cp-header`,children:[(0,V.jsx)(`h2`,{children:`Context & performance`}),(0,V.jsx)(`button`,{ref:i,type:`button`,className:`cp-icon`,onClick:n,"aria-label":`Close`,children:(0,V.jsx)(Bn,{size:16})})]}),(0,V.jsx)(`div`,{className:`cp-body`,children:(0,V.jsx)(RC,{sessionId:e,busy:t,onUsage:r})})]})})}function BC(e){return e<1e3?String(e):`${(e/1e3).toFixed(+(e<1e4))}K`}var VC=[{key:`system`,label:`System prompt`},{key:`tools`,label:`Tools`},{key:`documents`,label:`Documents`},{key:`history`,label:`Conversation`},{key:`query`,label:`Your message`}];function HC({usage:e,unavailable:t,sessionId:n,busy:r=!1,onUsage:i,onDetails:a}){let o=(0,z.useRef)(null),[s,c]=(0,z.useState)(!1),[l,u]=(0,z.useState)(!1),d=l&&n?(0,V.jsx)(zC,{sessionId:n,busy:r,onUsage:i,onClose:()=>u(!1)}):null;if(!e)return t?(0,V.jsxs)(`span`,{className:`context-meter is-empty`,title:t,children:[(0,V.jsx)(`span`,{className:`context-meter-bar`,"aria-hidden":`true`,children:(0,V.jsx)(`span`,{style:{width:0}})}),(0,V.jsx)(`span`,{className:`context-meter-label`,children:`Context`})]}):null;let f=Math.min(100,Math.round(e.used/e.window*100)),p=e.at_risk.length>0,m=Math.max(0,e.window-e.used-e.reply_reserve);return(0,V.jsxs)(`div`,{className:`composer-chip-wrap context-meter-wrap`,children:[(0,V.jsxs)(`button`,{ref:o,type:`button`,className:`context-meter${p?` is-warning`:``}`,onClick:()=>c(e=>!e),"aria-expanded":s,"aria-label":`Context ${f}% full: ${BC(e.used)} of ${BC(e.window)} tokens`,title:`How full the model's context window is`,children:[(0,V.jsx)(`span`,{className:`context-meter-bar`,"aria-hidden":`true`,children:(0,V.jsx)(`span`,{style:{width:`${f}%`}})}),(0,V.jsxs)(`span`,{className:`context-meter-label`,children:[f,`%`]})]}),(0,V.jsx)(ni,{open:s,onClose:()=>c(!1),anchor:o,label:`Context window`,align:`end`,children:(0,V.jsxs)(`div`,{className:`context-meter-panel`,children:[(0,V.jsxs)(`div`,{className:`context-meter-head`,children:[(0,V.jsx)(`strong`,{children:BC(e.used)}),` of `,BC(e.window),` tokens`]}),(0,V.jsx)(`div`,{className:`context-meter-stack`,"aria-hidden":`true`,children:VC.map(({key:t})=>(0,V.jsx)(`span`,{className:`part-${t}`,style:{width:`${e[t]/e.window*100}%`}},t))}),(0,V.jsxs)(`dl`,{className:`context-meter-rows`,children:[VC.filter(({key:t})=>t!==`query`||e.query>0).map(({key:t,label:n})=>(0,V.jsxs)(`div`,{className:`context-meter-row`,children:[(0,V.jsxs)(`dt`,{children:[(0,V.jsx)(`span`,{className:`swatch part-${t}`,"aria-hidden":`true`}),n]}),(0,V.jsx)(`dd`,{children:BC(e[t])})]},t)),(0,V.jsxs)(`div`,{className:`context-meter-row is-quiet`,children:[(0,V.jsx)(`dt`,{children:`Kept free for the reply`}),(0,V.jsx)(`dd`,{children:BC(e.reply_reserve)})]}),(0,V.jsxs)(`div`,{className:`context-meter-row is-quiet`,children:[(0,V.jsx)(`dt`,{children:`Free`}),(0,V.jsx)(`dd`,{children:BC(m)})]})]}),(0,V.jsxs)(`p`,{className:`context-meter-note`,children:[e.turns_in_view,` earlier `,e.turns_in_view===1?`turn is`:`turns are`,` in view`,e.turns_hidden>0&&`; ${e.turns_hidden} older ${e.turns_hidden===1?`is`:`are`} out of view`,`.`,` `,e.tokenizer?.exact?`Counted with the model's tokenizer.`:`Estimates.`,` `,`Older turns stay saved and can be recalled.`]}),n&&(0,V.jsx)(`button`,{type:`button`,className:`context-meter-details`,onClick:()=>{c(!1),a?a():u(!0)},children:`Details: context & performance`})]})}),d]})}function UC({usage:e}){if(!e||e.at_risk.length===0)return null;let t=e.at_risk.length;return(0,V.jsxs)(`div`,{className:`context-warning`,role:`status`,children:[(0,V.jsx)(An,{size:13,"aria-hidden":`true`}),(0,V.jsxs)(`span`,{children:[`The conversation is filling the model's context. The oldest`,t===1?` turn`:` ${t} turns`,` may drop out of the model's view next:`,` `,e.at_risk.map((e,t)=>(0,V.jsxs)(`span`,{children:[t>0&&`, `,(0,V.jsx)(`q`,{children:e})]},t)),`. They stay saved, and you can ask GAIA to recall them.`]})]})}async function WC(){let{providers:e,lemonade_error:t}=await _a();if(t)throw Error(t);return(await Promise.all(e.filter(e=>!e.remote).map(e=>Ca(e.id)))).flatMap(e=>e.models.filter(e=>e.downloaded).map(e=>({id:e.id,name:e.display_name??us(e.id)})))}function GC({answeredBy:e,onPick:t}){let n=(0,z.useRef)(null),[r,i]=(0,z.useState)(!1),[a,o]=(0,z.useState)(null),[s,c]=(0,z.useState)(null),l=(0,z.useCallback)(async()=>{o(null),c(null);try{o(await WC())}catch(e){c(e instanceof Error?e.message:String(e))}},[]);(0,z.useEffect)(()=>{r&&l()},[r,l]);let u=a?.filter(t=>t.id!==e)??[];return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{ref:n,type:`button`,className:`msg-action-btn`,onClick:()=>i(e=>!e),title:`Retry with another model`,"aria-label":`Retry with another model`,"aria-expanded":r,children:(0,V.jsx)(gn,{size:12})}),(0,V.jsx)(ni,{open:r,onClose:()=>i(!1),anchor:n,label:`Retry with`,placement:`below`,align:`end`,children:(0,V.jsxs)(`div`,{className:`retry-menu`,children:[(0,V.jsx)(`div`,{className:`retry-menu-head`,children:`Retry with…`}),s&&(0,V.jsx)(`div`,{className:`retry-menu-error`,role:`alert`,children:s}),!s&&a===null&&(0,V.jsxs)(`div`,{className:`retry-menu-empty`,children:[(0,V.jsx)(R,{size:12,className:`spin`,"aria-hidden":`true`}),` Loading models…`]}),a!==null&&u.length===0&&(0,V.jsx)(`div`,{className:`retry-menu-empty`,children:`No other model is downloaded on this PC. Add one in Settings → Model.`}),u.map(e=>(0,V.jsx)(`button`,{type:`button`,className:`retry-menu-item`,title:e.id,onClick:()=>{i(!1),t(e.id)},children:e.name},e.id))]})})]})}function KC(e){return e!=null&&e>0?`${(e/1e3).toFixed(1)} s`:null}function qC({parts:e}){let t=e.filter(Boolean);return t.length?(0,V.jsx)(`div`,{className:`compare-meta`,children:t.join(` · `)}):null}function JC({original:e,originalModel:t,originalLatencyMs:n,state:r,keeping:i,onKeep:a,onClose:o}){ls();let s=r.status===`ready`?r.result.model:r.model,c=e.stats?.tokens_per_second;return(0,V.jsxs)(`section`,{className:`answer-compare`,"aria-label":`Compare answers`,children:[(0,V.jsxs)(`header`,{className:`answer-compare-head`,children:[(0,V.jsx)(`span`,{children:`Compare answers`}),(0,V.jsx)(`button`,{type:`button`,className:`msg-action-btn`,onClick:o,"aria-label":`Close comparison`,disabled:!!i,children:(0,V.jsx)(Bn,{size:12})})]}),(0,V.jsxs)(`div`,{className:`answer-compare-cols`,children:[(0,V.jsxs)(`article`,{className:`compare-col`,"aria-label":`Answer from ${t??`the original model`}`,children:[(0,V.jsx)(`h4`,{children:t?us(t):`Original answer`}),(0,V.jsx)(qC,{parts:[KC(n),c?`${c} tok/s`:null]}),(0,V.jsx)(`div`,{className:`compare-body`,children:(0,V.jsx)(Qx,{content:e.content})}),(0,V.jsx)(`button`,{type:`button`,className:`compare-keep`,onClick:()=>a(`original`),disabled:!!i||r.status===`running`,children:i===`original`?`Keeping…`:`Keep this answer`})]}),(0,V.jsxs)(`article`,{className:`compare-col`,"aria-label":`Answer from ${s}`,children:[(0,V.jsx)(`h4`,{children:us(s)}),r.status===`running`&&(0,V.jsxs)(`div`,{className:`compare-wait`,children:[(0,V.jsx)(R,{size:14,className:`spin`,"aria-hidden":`true`}),(0,V.jsxs)(`span`,{children:[`Loading `,us(s),`, then answering from the same evidence. Tools are not run again.`]})]}),r.status===`failed`&&(0,V.jsx)(`div`,{className:`compare-error`,role:`alert`,children:r.error}),r.status===`ready`&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(qC,{parts:[`${r.result.stats.seconds.toFixed(1)} s`,r.result.stats.load_seconds>=1?`incl. ${r.result.stats.load_seconds.toFixed(1)} s loading`:null,r.result.stats.tokens_per_second?`${r.result.stats.tokens_per_second} tok/s`:null]}),(0,V.jsx)(`div`,{className:`compare-body`,children:(0,V.jsx)(Qx,{content:r.result.content})}),(0,V.jsx)(`button`,{type:`button`,className:`compare-keep`,onClick:()=>a(`retry`),disabled:!!i,children:i===`retry`?`Keeping…`:`Keep this answer`})]})]})]})]})}var YC=`gaia.sessionPanel.open`,XC=`gaia.sessionPanel.width`,ZC=`gaia.sessionPanel.sections`,QC={answer:!0,environment:!0,context:!1,outputs:!0,changes:!0};function $C(e,t,n){try{let r=window.localStorage.getItem(e);return r==null?n:t(r)}catch(t){return s.ui.warn(`Session panel setting ${e} unavailable; using the default`,t),n}}function ew(e,t){try{window.localStorage.setItem(e,t)}catch(t){s.ui.warn(`Could not remember session panel setting ${e}`,t)}}function tw(e){let t=typeof window<`u`?Math.floor(window.innerWidth*.5):640;return Math.round(Math.max(280,Math.min(e,640,Math.max(280,t))))}function nw(){return{open:$C(YC,e=>e!==`0`,!0),width:tw($C(XC,e=>Number(e)||320,320)),sections:{...QC,...$C(ZC,e=>JSON.parse(e),{})}}}var rw=$n((e,t)=>({...nw(),overlayOpen:!1,focus:null,setOpen:t=>{ew(YC,t?`1`:`0`),e({open:t})},setOverlayOpen:t=>e({overlayOpen:t}),setWidth:t=>{let n=tw(t);ew(XC,String(n)),e({width:n})},setSection:(n,r)=>{let i={...t().sections,[n]:r};ew(ZC,JSON.stringify(i)),e({sections:i})},reveal:n=>{let r={...t().sections,[n]:!0};ew(ZC,JSON.stringify(r)),ew(YC,`1`),e({sections:r,open:!0,overlayOpen:!0,focus:{section:n,nonce:Date.now()}})},reload:()=>e({...nw(),overlayOpen:!1,focus:null})}));function iw(e,t){if(t)return e.some(e=>e.turnSummary)?{kind:`busy`}:null;let n=e[e.length-1];return!n||n.role!==`assistant`||!n.turnSummary?null:{kind:`turn`,turn:n}}function aw(e){let t=e.live_data?.attempted??0;return t>0&&(e.live_data?.failed??0)>=t}function ow(e){try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}}function sw(e){return!e||e.length===0?null:`${e.length===1?`p.`:`pp.`} ${e.join(`, `)}`}function cw(e){let{cost:t}=e;return t.kind===`local`?`No cloud charges`:t.kind===`estimate`&&typeof t.usd==`number`?`About $${t.usd<.01?t.usd.toFixed(4):t.usd.toFixed(2)} at list price`:e.model?`Not known for this model`:`Not known`}function lw(e){return e instanceof Hi?e.detail||e.message:e instanceof Error?e.message:String(e)}function uw({messages:e,busy:t=!1}){let n=iw(e,t);if(!n)return null;let r=n.kind===`turn`?n.turn.turnSummary??null:null,i=r?aw(r):!1;return(0,V.jsxs)(`div`,{className:`side-rail-body`,children:[!r&&(0,V.jsx)(`p`,{className:`side-rail-pending`,role:`status`,children:`Working on this answer. Its sources, files and where its data went appear here when it finishes.`}),i&&(0,V.jsxs)(`div`,{className:`side-rail-warn`,role:`status`,children:[(0,V.jsx)(An,{size:14,"aria-hidden":`true`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`strong`,{children:`Couldn't get live data`}),(0,V.jsx)(`span`,{children:`Every web lookup this turn failed, so the answer isn't based on current information.`})]})]}),r&&(r.error?(0,V.jsxs)(`p`,{className:`side-rail-error`,role:`alert`,children:[`Couldn't put together this turn's sources and details: `,r.error]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fw,{summary:r}),(0,V.jsx)(hw,{summary:r}),(0,V.jsx)(gw,{summary:r})]}))]})}function dw({title:e,children:t}){let[n,r]=(0,z.useState)(!0);return(0,V.jsxs)(`section`,{className:`side-rail-section`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`side-rail-section-head`,onClick:()=>r(!n),"aria-expanded":n,children:[(0,V.jsx)(F,{size:12,className:`side-rail-chevron${n?` open`:``}`,"aria-hidden":`true`}),e]}),n&&(0,V.jsx)(`div`,{className:`side-rail-section-body`,children:t})]})}function fw({summary:e}){let t=e.pages??[],n=e.documents??[];return t.length===0&&n.length===0?null:(0,V.jsx)(dw,{title:`Sources`,children:(0,V.jsxs)(`ul`,{className:`side-rail-list`,children:[t.map(e=>(0,V.jsxs)(`li`,{className:`side-rail-item`,children:[(0,V.jsx)(ut,{size:13,className:`side-rail-item-icon`,"aria-hidden":`true`}),(0,V.jsxs)(`div`,{className:`side-rail-item-text`,children:[(0,V.jsxs)(`a`,{href:Sh(e.url)||void 0,target:`_blank`,rel:`noopener noreferrer`,className:`side-rail-link`,title:e.url,children:[(0,V.jsx)(`span`,{className:`side-rail-link-text`,children:e.title||ow(e.url)}),(0,V.jsx)(Pe,{size:10,"aria-hidden":`true`,className:`side-rail-link-icon`})]}),(0,V.jsxs)(`span`,{className:`side-rail-meta`,children:[ow(e.url),e.kind===`search_result`?` · search result`:``]})]})]},e.url)),n.map(e=>{let t=sw(e.pages),n=e.passages??0;return(0,V.jsxs)(`li`,{className:`side-rail-item`,children:[(0,V.jsx)(Ke,{size:13,className:`side-rail-item-icon`,"aria-hidden":`true`}),(0,V.jsxs)(`div`,{className:`side-rail-item-text`,children:[(0,V.jsx)(`span`,{className:`side-rail-name`,title:e.name,children:e.name}),(0,V.jsx)(`span`,{className:`side-rail-meta`,children:[t,`${n} passage${n===1?``:`s`}`].filter(Boolean).join(` · `)})]})]},e.path)})]})})}var pw=4e3;function mw(e){let t=e.join(`
|
|
62
62
|
`),[n,r]=(0,z.useState)(()=>new Map),[i,a]=(0,z.useState)(null);return(0,z.useEffect)(()=>{if(!t)return;let e=t.split(`
|
|
63
63
|
`),n=!1,i=()=>{document.visibilityState!==`hidden`&&So(e).then(e=>{n||(r(new Map(e.files.map(e=>[e.path,e]))),a(null))},e=>{n||(s.ui.warn(`Could not re-check the files this turn wrote`,e),a(lw(e)))})};i();let o=window.setInterval(i,pw);return window.addEventListener(`focus`,i),()=>{n=!0,window.clearInterval(o),window.removeEventListener(`focus`,i)}},[t]),{status:n,error:i}}function hw({summary:e}){let t=e.files??[],[n,r]=(0,z.useState)(null),{status:i,error:a}=mw(t.map(e=>e.path));if(t.length===0)return null;let o=(e,t)=>{r(null),e.catch(e=>{s.ui.error(`Failed to open ${t}`,e),r(`Couldn't open ${t}: ${lw(e)}`)})};return(0,V.jsxs)(dw,{title:`Files`,children:[(0,V.jsx)(`ul`,{className:`side-rail-list`,children:t.map(e=>{let t=i.get(e.path);if(t?.exists===!1)return(0,V.jsxs)(`li`,{className:`side-rail-item side-rail-item-gone`,children:[(0,V.jsx)(Ke,{size:13,className:`side-rail-item-icon`,"aria-hidden":`true`}),(0,V.jsxs)(`div`,{className:`side-rail-item-text`,children:[(0,V.jsx)(`span`,{className:`side-rail-name`,title:e.path,children:e.name}),(0,V.jsx)(`span`,{className:`side-rail-meta`,children:`No longer on disk`})]})]},e.path);let n=t?.exists===!0&&typeof t.mtime==`number`&&typeof e.mtime==`number`&&t.mtime!==e.mtime;return(0,V.jsxs)(`li`,{className:`side-rail-item`,children:[(0,V.jsx)(Ke,{size:13,className:`side-rail-item-icon`,"aria-hidden":`true`}),(0,V.jsxs)(`div`,{className:`side-rail-item-text`,children:[(0,V.jsx)(`span`,{className:`side-rail-name`,title:e.path,children:e.name}),n&&(0,V.jsx)(`span`,{className:`side-rail-meta`,children:`Changed since this turn`}),(0,V.jsxs)(`span`,{className:`side-rail-actions`,children:[e.openable&&(0,V.jsx)(`button`,{type:`button`,className:`side-rail-action`,onClick:()=>o(xo(e.path),e.name),children:`Open`}),(0,V.jsxs)(`button`,{type:`button`,className:`side-rail-action`,onClick:()=>o(bo(e.path,!0),e.name),children:[(0,V.jsx)(Xe,{size:11,"aria-hidden":`true`}),`Show in folder`]})]})]})]},e.path)})}),n&&(0,V.jsx)(`p`,{className:`side-rail-error`,role:`alert`,children:n}),a&&(0,V.jsxs)(`p`,{className:`side-rail-error`,children:[`Couldn't check whether these files changed: `,a]})]})}function gw({summary:e}){ls();let{model:t}=e,n=e.sites??[],r=(e.documents??[]).length>0;return(0,V.jsx)(dw,{title:`This turn`,children:(0,V.jsxs)(`dl`,{className:`side-rail-facts`,children:[(0,V.jsx)(`dt`,{children:`Model`}),(0,V.jsxs)(`dd`,{children:[t?(0,V.jsxs)(`span`,{className:`side-rail-where${t.remote?` remote`:``}`,children:[t.remote?(0,V.jsx)(ve,{size:12,"aria-hidden":`true`}):(0,V.jsx)(Ft,{size:12,"aria-hidden":`true`}),t.remote?`${t.provider_name} (cloud)`:`This PC`]}):(0,V.jsx)(`span`,{className:`side-rail-where`,children:`Not reported`}),t?.name&&(0,V.jsx)(`span`,{className:`side-rail-meta`,title:t.name,children:us(t.name)})]}),r&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{children:`Documents`}),(0,V.jsx)(`dd`,{children:t?.remote?`Searched on this PC. The passages used were sent to ${t.provider_name}.`:t?`Read on this PC and stayed here.`:`Searched on this PC.`})]}),(0,V.jsx)(`dt`,{children:`Websites`}),(0,V.jsx)(`dd`,{children:n.length>0?n.join(`, `):`None from GAIA's web tools`}),(0,V.jsx)(`dt`,{children:`Cost`}),(0,V.jsx)(`dd`,{children:cw(e)})]})})}function _w({id:e,title:t,summary:n,children:r}){let i=rw(t=>t.sections[e]),a=rw(e=>e.setSection),o=rw(e=>e.focus),s=(0,z.useRef)(null),c=`sp-section-${e}`;return(0,z.useEffect)(()=>{o?.section===e&&s.current?.scrollIntoView?.({block:`start`,behavior:Vb()})},[o,e]),(0,V.jsxs)(`section`,{ref:s,className:`sp-section`,"aria-labelledby":`${c}-title`,children:[(0,V.jsx)(`h3`,{className:`sp-section-heading`,children:(0,V.jsxs)(`button`,{type:`button`,id:`${c}-title`,className:`sp-section-head`,"aria-expanded":i,"aria-controls":c,onClick:()=>a(e,!i),children:[(0,V.jsx)(F,{size:13,className:`sp-chevron${i?` is-open`:``}`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`sp-section-title`,children:t}),n!=null&&(0,V.jsx)(`span`,{className:`sp-section-summary`,children:n})]})}),i&&(0,V.jsx)(`div`,{id:c,className:`sp-section-body`,children:r})]})}function vw(e,t,n){if(e==null||!t(e))throw Error(`the server sent no ${n}`);return e}var yw=e=>e.startsWith(`.`);function bw({onPick:e,onClose:t}){let[n,r]=(0,z.useState)(null),[i,a]=(0,z.useState)(``),[o,s]=(0,z.useState)(null),[c,l]=(0,z.useState)(!1),[u,d]=(0,z.useState)(!1);ei(!0,t);let f=(0,z.useRef)(null);fx(f,!0);let p=(0,z.useCallback)(e=>{l(!0),s(null),Promise.resolve().then(()=>vo(e)).then(e=>{let t=vw(e,e=>Array.isArray(e.entries),`folder listing`);r(t),a(t.current_path)}).catch(e=>s(e instanceof Hi?e.detail||e.message:String(e))).finally(()=>l(!1))},[]);(0,z.useEffect)(()=>p(),[p]);let m=n?.entries.filter(e=>e.type===`folder`)??[],h=u?m:m.filter(e=>!yw(e.name));return(0,V.jsx)(`div`,{className:`modal-overlay`,onClick:t,children:(0,V.jsxs)(`div`,{ref:f,className:`modal-panel sp-picker`,role:`dialog`,"aria-modal":`true`,"aria-label":`Add a folder to this chat`,onClick:e=>e.stopPropagation(),children:[(0,V.jsxs)(`div`,{className:`modal-header`,children:[(0,V.jsx)(`h3`,{children:`Add a folder`}),(0,V.jsx)(`button`,{type:`button`,className:`btn-icon`,onClick:t,"aria-label":`Close`,children:(0,V.jsx)(Bn,{size:18})})]}),(0,V.jsxs)(`div`,{className:`modal-body sp-picker-body`,children:[(0,V.jsx)(`p`,{className:`sp-meta`,children:`GAIA will be able to read and write everything in the folder you pick, in this chat only.`}),(0,V.jsxs)(`form`,{className:`sp-picker-path`,onSubmit:e=>{e.preventDefault(),i.trim()&&p(i.trim())},children:[(0,V.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),"aria-label":`Folder path`,spellCheck:!1}),(0,V.jsx)(`button`,{type:`submit`,className:`sp-action`,children:`Go`})]}),n&&(0,V.jsxs)(`div`,{className:`sp-picker-quick`,children:[n.quick_links.map(e=>(0,V.jsx)(`button`,{type:`button`,className:`sp-action`,onClick:()=>p(e.path),children:e.name},e.path)),(0,V.jsxs)(`label`,{className:`sp-picker-hidden`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked)}),`Show hidden`]})]}),(0,V.jsxs)(`ul`,{className:`sp-picker-list`,"aria-busy":c,children:[n?.parent_path&&(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,onClick:()=>p(n.parent_path??void 0),children:[(0,V.jsx)(S,{size:13,"aria-hidden":`true`}),` Up one level`]})}),h.map(e=>(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,onClick:()=>p(e.path),children:[(0,V.jsx)(nt,{size:13,"aria-hidden":`true`}),` `,e.name]})},e.path)),n&&h.length===0&&(0,V.jsx)(`li`,{className:`sp-meta`,children:m.length>0?`Only hidden folders here. Turn on Show hidden to see them.`:`No folders inside.`}),c&&(0,V.jsxs)(`li`,{className:`sp-meta`,children:[(0,V.jsx)(R,{size:12,className:`spin`,"aria-hidden":`true`}),` Loading…`]})]}),o&&(0,V.jsx)(`p`,{className:`sp-error`,role:`alert`,children:o})]}),(0,V.jsxs)(`div`,{className:`sp-picker-actions`,children:[(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:t,children:`Cancel`}),(0,V.jsx)(`button`,{type:`button`,className:`btn-primary`,disabled:!n,onClick:()=>n&&e(n.current_path),children:`Use this folder`})]})]})})}function xw(e){let[t,n]=(0,z.useState)(!1),[r,i]=(0,z.useState)(null);return{open:t=>{i(null);let r=window.gaiaAPI?.dialog;r?r.pickFolder(t).then(t=>{t&&e(t)}).catch(e=>i(`Couldn't open the folder picker: ${e instanceof Error?e.message:String(e)}`)):n(!0)},picker:t?(0,V.jsx)(bw,{onPick:t=>{n(!1),e(t)},onClose:()=>n(!1)}):null,error:r}}var Sw=new Map;function Cw(e){let t=Sw.get(e);return t||(t={env:null,error:null,inFlight:null,version:0,listeners:new Set},Sw.set(e,t)),t}function ww(e,t,n){let r=Cw(e);r.env=t??r.env,r.error=n,r.listeners.forEach(e=>e())}function Tw(e){let t=Cw(e);if(t.inFlight)return t.inFlight;let n=t.version;return t.inFlight=Promise.resolve().then(()=>Ho(e)).then(r=>{let i=vw(r,e=>Array.isArray(e.folders),`chat's environment`);t.version===n&&ww(e,i,null)}).catch(t=>ww(e,null,t instanceof Error?t.message:String(t))).finally(()=>{t.inFlight=null}),t.inFlight}function Ew(e){let[,t]=(0,z.useState)(0);(0,z.useEffect)(()=>{let n=Cw(e),r=()=>t(e=>e+1);return n.listeners.add(r),!n.env&&!n.inFlight&&Tw(e),()=>{n.listeners.delete(r)}},[e]);let n=(0,z.useCallback)(()=>Tw(e),[e]),r=(0,z.useCallback)(async t=>{let n=await t();return Cw(e).version+=1,ww(e,n,null),n},[e]),i=Cw(e);return{env:i.env,error:i.error,refresh:n,change:r}}function Dw(e,t){let n=(0,z.useRef)(e),r=(0,z.useRef)(t);r.current=t,(0,z.useEffect)(()=>{let t=n.current&&!e;n.current=e,t&&r.current()},[e])}var Ow=`gaia:mobile-access-request`,kw=`gaia:mobile-access-state`;function Aw(e){window.dispatchEvent(new CustomEvent(Ow,{detail:e}))}function jw(e){window.dispatchEvent(new CustomEvent(kw,{detail:e}))}function Mw(e,t){let n=(0,z.useRef)(t);n.current=t,(0,z.useEffect)(()=>{let t=e=>n.current(!!e.detail);return window.addEventListener(e,t),()=>window.removeEventListener(e,t)},[e])}var Nw=e=>Mw(Ow,e),Pw=e=>Mw(kw,e);function Fw({checked:e,onChange:t,label:n,text:r,disabled:i}){return(0,V.jsxs)(`span`,{className:`sp-switch-wrap`,children:[(0,V.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":n,className:`sp-switch${e?` is-on`:``}`,onClick:()=>t(!e),disabled:i,children:(0,V.jsx)(`span`,{className:`sp-switch-knob`,"aria-hidden":`true`})}),r&&(0,V.jsx)(`span`,{className:`sp-state-text`,children:r})]})}var Iw={added:`Added by you`,gaia_documents:`GAIA's documents folder`,scratch:`GAIA's scratch folder`,document:`Document in this chat`,working_folder:`Folder GAIA started in`,approved:`Approved during this chat`,allowed_paths:`Set by GAIA_ALLOWED_PATHS`},Lw=3;function Rw(e){return e instanceof Hi?e.detail||e.message:e instanceof Error?e.message:String(e)}function zw(e){let t=e.split(/[\\/]/).filter(Boolean);return t[t.length-1]??e}function Bw({sessionId:e,busy:t}){let{env:n}=Ew(e),r=n&&!n.internet?`Offline`:null;return(0,V.jsxs)(_w,{id:`environment`,title:`Environment`,summary:r,children:[(0,V.jsx)(Uw,{sessionId:e,busy:t}),(0,V.jsx)(Ww,{sessionId:e}),(0,V.jsx)(Gw,{sessionId:e}),(0,V.jsx)(Kw,{}),(0,V.jsx)(qw,{sessionId:e})]})}function Vw({label:e,children:t}){return(0,V.jsxs)(`div`,{className:`sp-env-row`,children:[(0,V.jsx)(`div`,{className:`sp-env-label`,children:e}),(0,V.jsx)(`div`,{className:`sp-env-value`,children:t})]})}function Hw(e,t){let n=e=>e.toLowerCase().replace(/^user\./,``);return n(e)===n(t)}function Uw({sessionId:e,busy:t}){let n=ms(),r=cs(e=>e.active),i=B(t=>hs(r,t.sessions,e)),[a,o]=(0,z.useState)(null),[c,l]=(0,z.useState)(null),u=n?.remote===!0,d=(0,z.useCallback)(()=>{u||Promise.resolve().then(()=>Ea()).then(e=>{o(vw(e,e=>typeof e.state==`string`,`model status`)),l(null)}).catch(e=>{s.ui.warn(`Could not read where the local model runs`,e),l(Rw(e))})},[u]);if((0,z.useEffect)(d,[d]),Dw(t,d),u)return(0,V.jsxs)(Vw,{label:`Runs on`,children:[(0,V.jsxs)(`span`,{className:`sp-place is-remote`,children:[(0,V.jsx)(ve,{size:13,"aria-hidden":`true`}),` `,n?.label,` (cloud)`]}),n?.description&&(0,V.jsx)(`span`,{className:`sp-meta`,children:n.description})]});if(!n)return(0,V.jsx)(Vw,{label:`Runs on`,children:(0,V.jsx)(`span`,{className:`sp-meta`,title:ps,children:`Not known yet`})});let f=!!(a?.model&&i&&!Hw(a.model,i)),p=f?null:a?.memory;return(0,V.jsxs)(Vw,{label:`Runs on`,children:[(0,V.jsxs)(`span`,{className:`sp-place`,children:[(0,V.jsx)(Ft,{size:13,"aria-hidden":`true`}),` This PC`,!f&&a?.placement?.label?` · ${a.placement.label}`:``]}),f?(0,V.jsxs)(`span`,{className:`sp-meta`,children:[us(i),` · not loaded right now`]}):a?.display_name&&(0,V.jsxs)(`span`,{className:`sp-meta`,children:[a.display_name,a.state===`loaded`?``:` · ${a.state}`]}),p&&(0,V.jsxs)(`span`,{className:`sp-meta`,children:[p.model_gb==null?`Memory in use unknown`:`${p.model_gb.toFixed(1)} GB in use`,p.free_gb==null?``:` · ${p.free_gb.toFixed(1)} GB free`]}),(c||a?.error)&&(0,V.jsx)(`span`,{className:`sp-error`,children:c??a?.error})]})}function Ww({sessionId:e}){let{env:t,error:n,change:r}=Ew(e),i=B(t=>t.sessions.find(t=>t.id===e)?.agent_type===`gaia`),[a,o]=(0,z.useState)(null),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(!1),d=async(e,t)=>{c(e),o(null);try{await t()}catch(e){o(Rw(e))}finally{c(null)}},f=t=>d(t.path,()=>r(()=>Wo(e,t.path))),{open:p,picker:m,error:h}=xw(t=>{d(t,()=>r(()=>Uo(e,t)))}),g=t?.folders.filter(e=>e.kind===`folder`)??[],_=t?.folders.filter(e=>e.kind===`file`)??[],v=l?_:_.slice(0,Lw),y=!t||!t.enforced,b=e=>(0,V.jsxs)(`li`,{className:`sp-scope-item`,children:[e.kind===`folder`?(0,V.jsx)(nt,{size:13,className:`sp-item-icon`,"aria-hidden":`true`}):(0,V.jsx)(Je,{size:13,className:`sp-item-icon`,"aria-hidden":`true`}),(0,V.jsxs)(`div`,{className:`sp-item-text`,children:[(0,V.jsx)(`span`,{className:`sp-item-name`,title:e.path,children:zw(e.path)}),(0,V.jsxs)(`span`,{className:`sp-meta`,title:e.path,children:[Iw[e.source],` · `,e.path]})]}),e.removable&&!y&&(0,V.jsx)(`button`,{type:`button`,className:`btn-icon-sm sp-item-remove`,onClick:()=>void f(e),disabled:s!==null,"aria-label":`Remove ${e.path} from this chat`,title:`Remove from this chat`,children:(0,V.jsx)(Bn,{size:12})})]},e.path);return(0,V.jsxs)(Vw,{label:t&&!t.enforced?`Files GAIA can reach`:`Can read and write`,children:[!t&&!n&&(0,V.jsx)(`span`,{className:`sp-meta`,children:`Checking…`}),t&&!t.enforced&&(0,V.jsx)(`span`,{className:`sp-meta`,children:i?`These folders are where GAIA starts, not a limit: it can also open folders inside your user folder, one at a time, but never the whole user folder at once. In Ask mode it asks before it opens a new folder or changes anything.`:`These folders are where this chat's agent starts; it applies its own limits.`}),n&&(0,V.jsxs)(`span`,{className:`sp-error`,children:[`Couldn't read this chat's folders: `,n]}),t&&(0,V.jsxs)(V.Fragment,{children:[t.folders.length===0&&(0,V.jsx)(`span`,{className:`sp-meta`,children:`Nothing yet. GAIA can't read or write any folder in this chat.`}),(0,V.jsxs)(`ul`,{className:`sp-list`,children:[g.map(b),v.map(b)]}),_.length>Lw&&(0,V.jsx)(`button`,{type:`button`,className:`link-btn sp-more`,onClick:()=>u(e=>!e),children:l?`Show fewer files`:`Show all ${_.length} files`}),!t.enforced&&(0,V.jsx)(`span`,{className:`sp-meta`,children:`This chat's agent runs as its own process, so its folders can't be changed from here.`}),t.removed.length>0&&(0,V.jsxs)(`span`,{className:`sp-meta`,children:[`Removed: `,t.removed.map(zw).join(`, `),`. GAIA is refused there until you add it back.`]}),!y&&(0,V.jsxs)(`button`,{type:`button`,className:`sp-action`,onClick:()=>p(),disabled:s!==null,children:[(0,V.jsx)(Qe,{size:12,"aria-hidden":`true`}),` Add folder`]})]}),(a??h)&&(0,V.jsx)(`span`,{className:`sp-error`,role:`alert`,children:a??h}),m]})}function Gw({sessionId:e}){let{env:t,change:n,refresh:r}=Ew(e),[i,a]=(0,z.useState)(null),[o,s]=(0,z.useState)(!1);if(!t)return null;let c=async t=>{s(!0),a(null);try{await n(()=>Go(e,t))}catch(e){a(Rw(e)),r()}finally{s(!1)}};return t.internet_enforced?(0,V.jsxs)(Vw,{label:`Internet`,children:[(0,V.jsx)(Fw,{checked:t.internet,onChange:e=>void c(e),disabled:o,label:`Internet for this chat`,text:t.internet?`On`:`Off: web search and pages are blocked`}),i&&(0,V.jsx)(`span`,{className:`sp-error`,role:`alert`,children:i})]}):(0,V.jsx)(Vw,{label:`Internet`,children:(0,V.jsx)(`span`,{className:`sp-state-text`,children:t.internet?`On`:`Off`})})}function Kw(){let[e,t]=(0,z.useState)(null),[n,r]=(0,z.useState)(!1),[i,a]=(0,z.useState)(null),o=(0,z.useCallback)(()=>{Promise.resolve().then(()=>Oo()).then(e=>{t(vw(e,e=>typeof e.active==`boolean`,`phone access status`)),a(null)}).catch(e=>a(Rw(e)))},[]);(0,z.useEffect)(o,[o]),Pw(()=>{r(!1),o()});let s=e?.active===!0;return(0,V.jsxs)(Vw,{label:`Phone access`,children:[(0,V.jsx)(Fw,{checked:s,onChange:e=>{r(!0),Aw(e)},disabled:n,label:`Phone access`,text:n?s?`Stopping…`:`Starting…`:s?`On`:`Off`}),s&&(0,V.jsxs)(`span`,{className:`sp-meta`,children:[(0,V.jsx)(vn,{size:12,"aria-hidden":`true`}),` `,e?.device?`${e.device.name} connected`:`No phone connected yet`]}),s&&(0,V.jsx)(`button`,{type:`button`,className:`sp-action`,onClick:()=>Aw(!0),children:`Show QR code`}),(i||e?.error)&&(0,V.jsx)(`span`,{className:`sp-error`,children:i??e?.error})]})}function qw({sessionId:e}){let[t,n]=(0,z.useState)(null),[r,i]=(0,z.useState)(!1),[a,o]=(0,z.useState)(null);(0,z.useEffect)(()=>{let t=!0;return Promise.resolve().then(()=>Pi(e)).then(e=>{t&&n(vw(e,e=>typeof e.mode==`string`,`permission mode`).mode)}).catch(e=>{t&&o(Rw(e))}),()=>{t=!1}},[e]),pC(e,n);let s=async t=>{i(!1),o(null);try{let r=(await Ii(e,t)).mode;n(r),fC(e,r)}catch(e){o(Rw(e))}},c=mC.find(e=>e.mode===t)?.note;return(0,V.jsxs)(Vw,{label:`Permission mode`,children:[(0,V.jsx)(`div`,{className:`sp-segmented`,role:`radiogroup`,"aria-label":`Permission mode`,children:mC.map(e=>(0,V.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t===e.mode,className:t===e.mode?`is-selected`:void 0,onClick:()=>e.mode===`full_access`?i(!0):void s(e.mode),children:[e.mode===`full_access`?(0,V.jsx)(un,{size:12,"aria-hidden":`true`}):(0,V.jsx)(fn,{size:12,"aria-hidden":`true`}),e.mode===`ask`?`Ask`:e.label]},e.mode))}),c&&(0,V.jsx)(`span`,{className:`sp-meta`,children:c}),r&&(0,V.jsxs)(`span`,{className:`sp-confirm`,role:`alert`,children:[`Full access lets GAIA change files and run commands on this PC without asking.`,(0,V.jsx)(`button`,{type:`button`,className:`sp-action is-warning`,onClick:()=>void s(`full_access`),children:`Turn it on`}),(0,V.jsx)(`button`,{type:`button`,className:`sp-action`,onClick:()=>i(!1),children:`Cancel`})]}),a&&(0,V.jsx)(`span`,{className:`sp-error`,role:`alert`,children:a})]})}var Jw={file:{label:`File`,Icon:Ke},export:{label:`Export`,Icon:He},image:{label:`Image`,Icon:ft},document:{label:`Indexed document`,Icon:St},memory:{label:`Memory saved`,Icon:O},schedule:{label:`Scheduled task`,Icon:j}},Yw={created:`created`,edited:`edited`,deleted:`deleted`};function Xw(e){return e instanceof Hi?e.detail||e.message:e instanceof Error?e.message:String(e)}function Zw(e,t=Date.now()){if(!e)return``;let n=Date.parse(`${e.replace(` `,`T`)}Z`);if(Number.isNaN(n))return``;let r=Math.max(0,Math.round((t-n)/1e3));return r<60?`just now`:r<3600?`${Math.floor(r/60)} min ago`:r<86400?`${Math.floor(r/3600)} h ago`:new Date(n).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Qw(e){return e.state===`undone`?`Undone`:e.state===`gone`?`No longer on disk`:null}function $w({sessionId:e,busy:t,onJumpToMessage:n}){return(0,V.jsx)(_w,{id:`outputs`,title:`Outputs`,children:(0,V.jsx)(eT,{sessionId:e,busy:t,onJumpToMessage:n})})}function eT({sessionId:e,busy:t,onJumpToMessage:n}){let[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(null),[c,l]=(0,z.useState)(null),[u,d]=(0,z.useState)(!1),f=(0,z.useCallback)(()=>{let t=!0;return Promise.resolve().then(()=>Ko(e)).then(e=>{t&&(i(vw(e,e=>Array.isArray(e.items),`list of outputs`).items),o(null))}).catch(n=>{t&&(s.ui.warn(`Could not list what session=${e} produced`,n),o(Xw(n)))}),()=>{t=!1}},[e]);(0,z.useEffect)(f,[f]),Dw(t,f),Yb(e,f);let p=(e,t)=>{l(null),e.catch(e=>l(`Couldn't open ${t}: ${Xw(e)}`))};if(a)return(0,V.jsxs)(`p`,{className:`sp-error`,children:[`Couldn't list what this chat produced: `,a]});if(!r)return(0,V.jsx)(`p`,{className:`sp-meta`,children:`Checking…`});if(r.length===0)return(0,V.jsx)(`p`,{className:`sp-meta`,children:`Nothing yet. Files, documents, images and memories this chat makes appear here.`});let m=u?r:r.slice(0,5);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`ul`,{className:`sp-list`,"aria-label":`What this chat produced`,children:m.map(e=>{let{label:t,Icon:r}=Jw[e.kind],i=Qw(e),a=e.change&&e.kind!==`document`?Yw[e.change]:void 0,o=a?`${t} ${a}`:t;return(0,V.jsxs)(`li`,{className:`sp-output${e.state===`present`?``:` is-inactive`}`,children:[(0,V.jsx)(r,{size:13,className:`sp-item-icon`,"aria-hidden":`true`}),(0,V.jsxs)(`div`,{className:`sp-item-text`,children:[(0,V.jsx)(`span`,{className:`sp-item-name`,title:e.path??e.name,children:e.name}),(0,V.jsx)(`span`,{className:`sp-meta`,children:[o,Zw(e.created_at),i].filter(Boolean).join(` · `)}),(0,V.jsxs)(`span`,{className:`sp-item-actions`,children:[e.message_id!=null&&(0,V.jsxs)(`button`,{type:`button`,className:`sp-action`,onClick:()=>{n(e.message_id)||l(`That turn isn't loaded in the chat right now.`)},"aria-label":`Go to the turn that made ${e.name}`,children:[(0,V.jsx)(we,{size:11,"aria-hidden":`true`}),` Go to turn`]}),e.openable&&e.path&&(0,V.jsx)(`button`,{type:`button`,className:`sp-action`,onClick:()=>p(xo(e.path),e.name),children:`Open`}),e.revealable&&e.path&&(0,V.jsxs)(`button`,{type:`button`,className:`sp-action`,onClick:()=>p(bo(e.path,!0),e.name),children:[(0,V.jsx)(Xe,{size:11,"aria-hidden":`true`}),` Show in folder`]})]})]})]},e.id)})}),r.length>5&&(0,V.jsx)(`button`,{type:`button`,className:`link-btn sp-more`,onClick:()=>d(e=>!e),children:u?`Show fewer`:`Show ${r.length-5} more`}),c&&(0,V.jsx)(`p`,{className:`sp-error`,role:`alert`,children:c})]})}function tT(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}function nT(e){return e instanceof Hi?e.detail||e.message:e instanceof Error?e.message:String(e)}function rT(e){let t=e.split(/[\\/]/).filter(Boolean);return t[t.length-1]??e}function iT(e){let{files:t,additions:n,deletions:r}=e.totals;return`${tT(t,`file`)} changed, +${n} −${r}`}var aT={edited:`Edited`,created:`Created`,deleted:`Deleted`};function oT({sessionId:e,busy:t,onJumpToMessage:n}){let[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(null),[c,l]=(0,z.useState)(null),u=(0,z.useCallback)(()=>{Promise.resolve().then(()=>qo(e)).then(e=>{i(vw(e,e=>Array.isArray(e.files),`list of this chat's changes`)),o(null)}).catch(t=>{s.ui.warn(`Could not total what session=${e} changed`,t),o(nT(t))})},[e]);(0,z.useEffect)(u,[u]),Dw(t,()=>{l(null),u()}),Yb(e,u);let d=!r||r.files.length===0;return!a&&d&&!c?null:(0,V.jsxs)(_w,{id:`changes`,title:`Changes`,summary:r&&!d?`${tT(r.totals.files,`file`)} · +${r.totals.additions} −${r.totals.deletions}`:null,children:[a&&(0,V.jsxs)(`p`,{className:`sp-error`,children:[`Couldn't total this chat's changes: `,a]}),r&&!d&&(0,V.jsx)(sT,{sessionId:e,busy:t,changes:r,onChanged:u,onUndone:l,onJumpToMessage:n}),d&&c&&(0,V.jsx)(`p`,{className:`sp-ok`,role:`status`,children:c})]})}function sT({sessionId:e,busy:t,changes:n,onChanged:r,onUndone:i,onJumpToMessage:a}){let[o,s]=(0,z.useState)(!1),[c,l]=(0,z.useState)(`idle`),[u,d]=(0,z.useState)(null),f=n.files.length,p=async t=>{l(`working`),d(null);try{let n=await Jo(e,t),r=[];n.restored.length&&r.push(`restored ${tT(n.restored.length,`file`)}`),n.removed.length&&r.push(`removed ${tT(n.removed.length,`new file`)}`);let a=`Undone: ${r.join(`, `)||`no files needed changing`}.`;n.kept_folders.length&&(a+=` Kept ${tT(n.kept_folders.length,`folder`)} the chat created, because they now hold other files.`),d(a),l(`done`),i(a),Jb(e),await Gb(e)}catch(e){let t=e?.reason===`conflict`;d(nT(e)),l(t?`conflict`:`idle`)}};return(0,V.jsxs)(`div`,{className:`sp-changes`,children:[(0,V.jsxs)(`p`,{className:`sp-changes-total`,"aria-live":`polite`,children:[(0,V.jsx)(`strong`,{children:iT(n)}),n.totals.uncounted>0&&(0,V.jsxs)(`span`,{className:`sp-meta`,children:[` · `,tT(n.totals.uncounted,`binary or large file`),` not line-counted`]})]}),n.pending&&(0,V.jsx)(`p`,{className:`sp-meta`,children:`A reply is still running; its changes are added when it ends.`}),(0,V.jsx)(`ul`,{className:`sp-list`,children:n.files.map(e=>{let t=e.message_ids[e.message_ids.length-1];return(0,V.jsxs)(`li`,{className:`sp-change`,children:[(0,V.jsxs)(`div`,{className:`sp-item-text`,children:[(0,V.jsx)(`span`,{className:`sp-item-name`,title:e.path,children:rT(e.path)}),(0,V.jsxs)(`span`,{className:`sp-meta`,children:[aT[e.change],e.additions!=null&&(0,V.jsxs)(V.Fragment,{children:[` · `,(0,V.jsxs)(`span`,{className:`sp-add`,children:[`+`,e.additions]}),` `,(0,V.jsxs)(`span`,{className:`sp-del`,children:[`−`,e.deletions]})]}),e.message_ids.length>1&&` · ${tT(e.message_ids.length,`turn`)}`]}),e.changed_since&&(0,V.jsxs)(`span`,{className:`sp-warn-text`,children:[(0,V.jsx)(An,{size:11,"aria-hidden":`true`}),` Changed outside GAIA: `,e.changed_since]})]}),t!=null&&(0,V.jsx)(`button`,{type:`button`,className:`btn-icon-sm`,onClick:()=>a(t),"aria-label":`Go to the last turn that changed ${rT(e.path)}`,title:`Go to turn`,children:(0,V.jsx)(we,{size:12})})]},e.path)})}),n.incomplete&&(0,V.jsxs)(`p`,{className:`sp-warn-text`,role:`note`,children:[(0,V.jsx)(An,{size:11,"aria-hidden":`true`}),` `,ix(n.untracked,{inChat:!0,undo:`Undo all`})]}),(0,V.jsxs)(`div`,{className:`sp-actions-row`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`sp-action`,onClick:()=>s(!0),children:[(0,V.jsx)(Be,{size:12,"aria-hidden":`true`}),` Review changes`]}),c!==`confirm`&&c!==`conflict`&&(0,V.jsxs)(`button`,{type:`button`,className:`sp-action`,onClick:()=>l(`confirm`),disabled:c===`working`||t,title:t?`Wait for the reply to finish`:void 0,children:[(0,V.jsx)(Mn,{size:12,"aria-hidden":`true`}),` `,c===`working`?`Undoing…`:`Undo all`]})]}),c===`confirm`&&(0,V.jsxs)(`div`,{className:`sp-confirm`,role:`group`,"aria-label":`Confirm undo all`,children:[`Put `,tT(f,`file`),` back the way `,f===1?`it was`:`they were`,` before this chat? Every turn's file changes are undone.`,(0,V.jsxs)(`span`,{className:`sp-actions-row`,children:[(0,V.jsx)(`button`,{type:`button`,className:`sp-action is-danger`,onClick:()=>void p(!1),children:`Undo all`}),(0,V.jsx)(`button`,{type:`button`,className:`sp-action`,onClick:()=>l(`idle`),children:`Cancel`})]})]}),u&&(0,V.jsxs)(`div`,{className:c===`done`?`sp-ok`:`sp-error`,role:c===`done`?`status`:`alert`,children:[u,c===`conflict`&&(0,V.jsxs)(`span`,{className:`sp-actions-row`,children:[(0,V.jsx)(`button`,{type:`button`,className:`sp-action is-danger`,onClick:()=>void p(!0),children:`Undo anyway and lose those changes`}),(0,V.jsx)(`button`,{type:`button`,className:`sp-action`,onClick:()=>{l(`idle`),d(null)},children:`Keep them`})]})]}),(0,V.jsx)(uT,{sessionId:e,busy:t,onCommitted:r}),o&&(0,V.jsx)(lT,{changes:n,onClose:()=>s(!1)})]})}function cT(e){if(e.too_large)return`Too large to show: ${e.before_size} → ${e.after_size} bytes.`;if(e.binary)return`Binary file: ${e.before_size} → ${e.after_size} bytes. No text diff.`;if(e.truncated)return`Diff shortened: the change is too long to show in full.`}function lT({changes:e,onClose:t}){ei(!0,t);let n=(0,z.useRef)(null);return fx(n,!0),(0,V.jsx)(`div`,{ref:n,className:`modal-overlay`,onClick:t,role:`dialog`,"aria-modal":`true`,"aria-label":`Review this chat's changes`,children:(0,V.jsxs)(`div`,{className:`modal-panel changes-review`,onClick:e=>e.stopPropagation(),children:[(0,V.jsxs)(`div`,{className:`modal-header`,children:[(0,V.jsxs)(`h3`,{children:[`Changes in this chat · `,iT(e)]}),(0,V.jsx)(`button`,{type:`button`,className:`btn-icon`,onClick:t,"aria-label":`Close`,children:(0,V.jsx)(Bn,{size:18})})]}),(0,V.jsx)(`div`,{className:`modal-body changes-review-body`,children:e.files.map(e=>(0,V.jsx)(`section`,{className:`changes-review-file`,children:(0,V.jsx)(yb,{data:{title:e.path,badge:aT[e.change],note:cT(e),unified:e.binary||e.too_large?``:e.unified}})},e.path))})]})})}function uT({sessionId:e,busy:t,onCommitted:n}){let[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(null),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(null),d=(0,z.useCallback)(()=>{Promise.resolve().then(()=>Yo(e)).then(e=>{i(vw(e,e=>Array.isArray(e.repos),`list of git repositories`)),o(null)}).catch(e=>o(nT(e)))},[e]);return(0,z.useEffect)(d,[d]),Dw(t,d),Yb(e,d),a?(0,V.jsxs)(`p`,{className:`sp-error`,children:[`Couldn't check for a git repository: `,a]}):!r||!r.available||r.repos.length===0?null:(0,V.jsxs)(`div`,{className:`sp-git`,children:[r.repos.map(e=>(0,V.jsxs)(`div`,{className:`sp-git-repo`,children:[(0,V.jsxs)(`span`,{className:`sp-meta`,title:e.root,children:[(0,V.jsx)(it,{size:12,"aria-hidden":`true`}),` `,rT(e.root),` · `,e.branch,e.uncommitted.length===0&&e.files.length>0&&` · committed`]}),(0,V.jsxs)(`span`,{className:`sp-actions-row`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`sp-action`,disabled:t||e.uncommitted.length===0,onClick:()=>{u(null),c({kind:`commit`,repo:e})},children:[(0,V.jsx)(ot,{size:12,"aria-hidden":`true`}),` Commit…`]}),(0,V.jsxs)(`button`,{type:`button`,className:`sp-action`,disabled:t||e.pr_blocked!=null,title:e.pr_blocked??void 0,onClick:()=>{u(null),c({kind:`pr`,repo:e})},children:[(0,V.jsx)(ct,{size:12,"aria-hidden":`true`}),` Create PR…`]})]}),e.pr_blocked&&(0,V.jsx)(`span`,{className:`sp-meta`,children:e.pr_blocked})]},e.root)),l&&(0,V.jsx)(`p`,{className:`sp-ok`,role:`status`,children:l}),s&&(0,V.jsx)(dT,{sessionId:e,kind:s.kind,repo:s.repo,onClose:()=>c(null),onDone:e=>{c(null),u(e),d(),n()}})]})}function dT({sessionId:e,kind:t,repo:n,onClose:r,onDone:i}){let[a,o]=(0,z.useState)(n.draft.title),[s,c]=(0,z.useState)(n.draft.body),[l,u]=(0,z.useState)(!1),[d,f]=(0,z.useState)(null);ei(!0,r,!l);let p=(0,z.useRef)(null);fx(p,!0);let m=async()=>{u(!0),f(null);try{if(t===`commit`){let t=await Xo(e,n.root,`${a.trim()}\n\n${s.trim()}`.trim());i(`Committed ${tT(t.files.length,`file`)} as ${t.commit}.`)}else i(`Opened ${(await Zo(e,n.root,a,s)).url}`)}catch(e){f(nT(e)),u(!1)}},h=t===`commit`?n.uncommitted:n.files;return(0,V.jsx)(`div`,{className:`modal-overlay`,onClick:l?void 0:r,children:(0,V.jsxs)(`div`,{ref:p,className:`modal-panel sp-git-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":t===`commit`?`Commit this chat’s changes`:`Create a pull request`,onClick:e=>e.stopPropagation(),children:[(0,V.jsxs)(`div`,{className:`modal-header`,children:[(0,V.jsx)(`h3`,{children:t===`commit`?`Commit this chat’s changes`:`Create a pull request`}),(0,V.jsx)(`button`,{type:`button`,className:`btn-icon`,onClick:r,disabled:l,"aria-label":`Close`,children:(0,V.jsx)(Bn,{size:18})})]}),(0,V.jsxs)(`div`,{className:`modal-body sp-git-body`,children:[(0,V.jsx)(`p`,{className:`sp-meta`,children:t===`commit`?`In ${n.root} on ${n.branch}. Only the files below are committed; anything else you changed stays as it is.`:`Pushes ${n.branch} to ${n.remote} (never forced), then opens a pull request with GitHub's gh tool.`}),(0,V.jsxs)(`label`,{className:`sp-field`,children:[(0,V.jsx)(`span`,{children:t===`commit`?`Summary`:`Title`}),(0,V.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),disabled:l})]}),(0,V.jsxs)(`label`,{className:`sp-field`,children:[(0,V.jsx)(`span`,{children:t===`commit`?`Details`:`Description`}),(0,V.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),rows:7,disabled:l})]}),(0,V.jsxs)(`div`,{className:`sp-meta`,children:[tT(h.length,`file`),`: `,h.join(`, `)]}),t===`commit`&&n.ignored.length>0&&(0,V.jsxs)(`div`,{className:`sp-meta`,children:[`Left out, because git ignores `,n.ignored.length===1?`it`:`them`,`: `,n.ignored.join(`, `)]}),d&&(0,V.jsx)(`p`,{className:`sp-error`,role:`alert`,children:d})]}),(0,V.jsxs)(`div`,{className:`sp-picker-actions`,children:[(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:r,disabled:l,children:`Cancel`}),(0,V.jsxs)(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void m(),disabled:l||!a.trim(),children:[l&&(0,V.jsx)(R,{size:13,className:`spin`,"aria-hidden":`true`}),t===`commit`?`Commit ${tT(h.length,`file`)}`:`Push and open PR`]})]})]})})}var fT=`(max-width: 1099px)`,pT=16;function mT({sessionId:e,messages:t,busy:n,onUsage:r,onJumpToMessage:i}){let a=Dc(fT),o=rw(e=>a?e.overlayOpen:e.open),s=rw(e=>e.width),c=rw(e=>e.setWidth),l=rw(e=>e.setOpen),u=rw(e=>e.setOverlayOpen),d=rw(e=>e.focus),f=(0,z.useRef)(null),[p,m]=(0,z.useState)(null),h=(0,z.useCallback)(()=>{a?u(!1):l(!1)},[a,l,u]);ei(o&&a,h);let g=(0,z.useRef)(null);fx(g,o&&a),(0,z.useEffect)(()=>{o&&a&&f.current?.focus()},[o,a]),(0,z.useEffect)(()=>{d&&a&&u(!0)},[d,a,u]);let _=(0,z.useCallback)(e=>{if(e.button!==0)return;e.preventDefault();let t=e.clientX,n=s,r=e.currentTarget;r.setPointerCapture?.(e.pointerId);let i=n,a=e=>{i=tw(n+(t-e.clientX)),m(i)},o=()=>{r.removeEventListener(`pointermove`,a),r.removeEventListener(`pointerup`,o),r.removeEventListener(`pointercancel`,o),m(null),c(i)};r.addEventListener(`pointermove`,a),r.addEventListener(`pointerup`,o),r.addEventListener(`pointercancel`,o)},[c,s]),v=(0,z.useCallback)(e=>{let t={ArrowLeft:s+pT,ArrowRight:s-pT,Home:280,End:640}[e.key];t!==void 0&&(e.preventDefault(),c(t))},[c,s]);if(!o)return null;let y=p??s,b=iw(t,n);return(0,V.jsxs)(V.Fragment,{children:[a&&(0,V.jsx)(`div`,{className:`sp-backdrop`,onClick:h,"aria-hidden":`true`}),(0,V.jsxs)(`aside`,{ref:g,className:`session-panel ${a?`is-overlay`:`is-docked`}`,style:a?void 0:{width:y},"aria-label":`Session panel`,role:a?`dialog`:`complementary`,"aria-modal":a?!0:void 0,children:[!a&&(0,V.jsx)(`div`,{className:`sp-resize${p==null?``:` is-dragging`}`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize session panel`,"aria-valuemin":280,"aria-valuemax":640,"aria-valuenow":y,tabIndex:0,onPointerDown:_,onKeyDown:v,onDoubleClick:()=>c(320)}),(0,V.jsxs)(`header`,{className:`sp-header`,children:[(0,V.jsx)(`h2`,{className:`sp-title`,children:`This chat`}),(0,V.jsx)(`button`,{ref:f,type:`button`,className:`btn-icon-sm`,onClick:h,"aria-label":`Close session panel`,title:`Close`,children:a?(0,V.jsx)(Bn,{size:14}):(0,V.jsx)(Vt,{size:14})})]}),(0,V.jsxs)(`div`,{className:`sp-body`,children:[b&&(0,V.jsx)(_w,{id:`answer`,title:`This answer`,children:(0,V.jsx)(uw,{messages:t,busy:n})}),(0,V.jsx)(Bw,{sessionId:e,busy:n}),(0,V.jsx)(_w,{id:`context`,title:`Context & performance`,children:(0,V.jsx)(`div`,{className:`sp-context`,children:(0,V.jsx)(RC,{sessionId:e,busy:n,onUsage:r})})}),(0,V.jsx)($w,{sessionId:e,busy:n,onJumpToMessage:i}),(0,V.jsx)(oT,{sessionId:e,busy:n,onJumpToMessage:i})]})]})]})}function hT({messages:e,busy:t}){let n=Dc(fT),r=rw(e=>n?e.overlayOpen:e.open),i=rw(e=>e.setOpen),a=rw(e=>e.setOverlayOpen),o=iw(e,t),s=!r&&o?.kind===`turn`&&o.turn.turnSummary?aw(o.turn.turnSummary):!1,c=r?`Hide session panel`:s?`Show session panel: couldn't get live data`:`Show session panel`;return(0,V.jsx)(`button`,{type:`button`,className:`btn-icon-sm sp-toggle${r?` active`:``}${s?` is-warn`:``}`,onClick:()=>n?a(!r):i(!r),"aria-label":c,"aria-pressed":r,title:c,children:s?(0,V.jsx)(An,{size:15}):r?(0,V.jsx)(Vt,{size:15}):(0,V.jsx)(Ut,{size:15})})}function gT({isPrivate:e,onToggle:t}){return(0,V.jsx)(`button`,{className:`btn-icon-sm task-header-private`,onClick:t,title:e?`Turn off private chat. This chat isn't saved to memory.`:`Turn on private chat. It won't be saved to memory.`,"aria-label":e?`Turn off private chat`:`Turn on private chat`,"data-private":e?`true`:void 0,children:e?(0,V.jsx)(Ie,{size:15}):(0,V.jsx)(Re,{size:15})})}function _T({sessionId:e}){let{env:t,change:n}=Ew(e),[r,i]=(0,z.useState)(null);return!t||t.internet?null:(0,V.jsxs)(`div`,{className:`offline-notice`,role:`status`,children:[(0,V.jsx)(In,{size:13,"aria-hidden":`true`}),(0,V.jsxs)(`span`,{children:[`Offline: internet is off for this chat, so GAIA won't search the web or open pages.`,r&&(0,V.jsxs)(`span`,{className:`offline-notice-error`,children:[` Couldn't turn it on: `,r]})]}),(0,V.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>{i(null),n(()=>Go(e,!0)).catch(e=>{i(e instanceof Hi?e.detail||e.message:String(e))})},children:`Turn on`})]})}function vT({message:e,onDismiss:t}){return e?(0,V.jsxs)(`div`,{className:`export-error-bar`,role:`alert`,children:[(0,V.jsx)(`span`,{children:e}),(0,V.jsx)(`button`,{type:`button`,className:`btn-icon-sm`,onClick:t,"aria-label":`Dismiss export error`,children:(0,V.jsx)(Bn,{size:13})})]}):null}function yT(){return`screenshot-${new Date().toISOString().slice(0,19).replace(/[T:]/g,`-`)}.png`}function bT(){let[e,t]=(0,z.useState)([]),n=(0,z.useRef)(!0);(0,z.useEffect)(()=>(n.current=!0,()=>{n.current=!1}),[]);let r=(0,z.useCallback)(async e=>{try{let r=await Co(e.file);if(!n.current)return;t(t=>t.map(t=>t.id===e.id?{...t,uploading:!1,uploaded:!0,serverUrl:r.url}:t))}catch(r){if(s.chat.error(`Upload failed: ${e.name}`,r),!n.current)return;let i=r instanceof Error?r.message:`Upload failed`;t(t=>t.map(t=>t.id===e.id?{...t,uploading:!1,error:i}:t))}},[]),i=(0,z.useCallback)(e=>{for(let n of e){let e=n.type.startsWith(`image/`),i={id:`attach-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,file:n,name:n.name||(e?yT():`file`),url:e?URL.createObjectURL(n):``,uploading:!0,uploaded:!1,isImage:e};t(e=>[...e,i]),r(i)}},[r]),a=(0,z.useCallback)(e=>{let t=Array.from(e.clipboardData?.items??[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>e!==null);return t.length!==0&&(e.preventDefault(),i(t),!0)},[i]),o=(0,z.useCallback)(e=>{t(t=>{let n=t.find(t=>t.id===e);return n?.url&&URL.revokeObjectURL(n.url),t.filter(t=>t.id!==e)})},[]),c=(0,z.useCallback)(()=>{t(e=>(e.forEach(e=>{e.url&&URL.revokeObjectURL(e.url)}),[]))},[]),l=(0,z.useCallback)(t=>{let n=e.filter(e=>e.uploaded&&e.serverUrl).map(e=>e.isImage?``:`[${e.name}](${e.serverUrl})`).join(`
|
|
64
64
|
`);return n?t?`${t}\n\n${n}`:n:t},[e]);return{attachments:e,addFiles:i,handlePaste:a,remove:o,clear:c,hasUploaded:e.some(e=>e.uploaded),uploading:e.some(e=>e.uploading),compose:l}}function xT({sessionId:e,isStreaming:t,isStale:n,setMessages:r,refreshContext:i}){let[a,o]=(0,z.useState)(null),c=a?.state.status===`running`,l=(0,z.useRef)(!1);l.current=c;let u=(0,z.useRef)(a);u.current=a,(0,z.useEffect)(()=>{o(null)},[e]);let d=(0,z.useCallback)((r,i)=>{t||l.current||(s.chat.info(`Retrying message ${r.id} with ${i}`),o({messageId:r.id,state:{status:`running`,model:i},keeping:null}),ki(e,r.id,i).then(e=>{n()||o(t=>t&&t.messageId===r.id?{...t,state:{status:`ready`,result:e}}:t)}).catch(e=>{s.chat.error(`Retry with ${i} failed`,e),!n()&&o(t=>t&&t.messageId===r.id?{...t,state:{status:`failed`,model:i,error:e instanceof Error?e.message:String(e)}}:t)}))},[e,t,n]),f=(0,z.useCallback)(async t=>{if(!a)return;let{messageId:c}=a;o({...a,keeping:t});try{let a=await Ai(e,c,t);if(n())return;if(a.kept===`retry`){let e=a.stats;r(B.getState().messages.map(t=>t.id===c?{...t,content:a.content,stats:{...t.stats,...e,tokens_per_second:e.tokens_per_second??0,time_to_first_token:e.time_to_first_token??0,input_tokens:e.input_tokens??0,output_tokens:e.output_tokens??0,retried:!0}}:t)),i()}o(null)}catch(e){if(s.chat.error(`Could not keep the chosen answer`,e),n())return;o(t=>t&&{...t,keeping:null,state:{status:`failed`,model:t.state.status===`ready`?t.state.result.model:t.state.model,error:e instanceof Error?e.message:String(e)}})}},[a,e,r,n,i]);return{comparison:a,comparing:c,comparingRef:l,handleRetryWith:d,handleKeepAnswer:f,handleCloseComparison:(0,z.useCallback)(()=>{a?.state.status===`ready`?f(`original`):o(null)},[a,f]),closeForNewTurn:(0,z.useCallback)(()=>{let t=u.current;t&&(t.state.status===`ready`&&Ai(e,t.messageId,`original`).catch(e=>s.chat.error(`Could not close the answer comparison`,e)),o(null))},[e])}}function ST(e,t){let[n,r]=(0,z.useState)(null),[i,a]=(0,z.useState)(null);(0,z.useEffect)(()=>{r(null),a(null)},[e]);let o=(0,z.useCallback)(()=>{Di(e).then(e=>{t()||(e.available?(r(e),a(null)):(r(null),a(e.reason)))}).catch(t=>s.chat.error(`Could not measure the context for session=${e}`,t))},[e,t]);return(0,z.useEffect)(()=>{o()},[o]),{contextUsage:n,contextUnavailable:i,refreshContext:o,showContextUsage:(0,z.useCallback)(e=>{r(e),a(null)},[])}}function CT(e,t){return(0,z.useCallback)(n=>{let r=e.current?.querySelector(`[data-message-id="${n}"]`);if(!r)return!1;let i=r.previousElementSibling,a=i?.dataset.role===`user`?i:r;return t.current=!1,a.scrollIntoView?.({block:`start`,behavior:Vb()}),r.classList.add(`msg-jump-target`),window.setTimeout(()=>r.classList.remove(`msg-jump-target`),1600),!0},[e,t])}function wT(e,t){let[n,r]=(0,z.useState)(null);(0,z.useEffect)(()=>{r(null)},[e]);let i=(0,z.useCallback)(()=>r(null),[]);return{exportChat:(0,z.useCallback)(async()=>{r(null);try{let n=await Wa(e),r=new Blob([n.content],{type:`text/markdown`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`${(t||`chat`).replace(/[/\\:*?"<>|]/g,`_`).slice(0,100)}.md`,a.click(),URL.revokeObjectURL(i)}catch(e){s.chat.error(`Export failed`,e),r(e instanceof Hi?`Couldn't export this chat: GAIA's backend returned an error (HTTP ${e.httpStatus}). Try Export again; if it keeps failing, check the backend log.`:`Couldn't export this chat because GAIA's backend isn't reachable. Check that GAIA is running, then try Export again.`)}},[e,t]),exportError:n,clearExportError:i}}var TT=5200;function ET(e=TT){let[t,n]=(0,z.useState)(null),r=(0,z.useRef)(null),i=(0,z.useCallback)(()=>{r.current&&=(clearTimeout(r.current),null)},[]),a=(0,z.useCallback)(()=>{i(),n(null)},[i]),o=(0,z.useCallback)(t=>{i(),n(t),r.current=setTimeout(()=>{r.current=null,n(null)},e)},[i,e]);return(0,z.useEffect)(()=>i,[i]),{policyToast:t,showPolicyToast:o,dismissPolicyToast:a}}var DT=`gaia`;function OT(e){return e.some(e=>e.id===DT)}function kT(e){let t=e;return t?.httpStatus===422&&`${typeof t.detail==`string`?t.detail:``} ${typeof t.message==`string`?t.message:``}`.includes(`Unknown agent_type '${DT}'`)}var AT=new Set([``,`new chat`,`new task`,`untitled`,`untitled session`,`chat`]);function jT(e){return AT.has((e??``).trim().toLowerCase())}function MT(e,t){let n=()=>typeof document<`u`&&document.visibilityState===`hidden`,r=setInterval(()=>{n()||e()},t),i=()=>{n()||e()};return document.addEventListener(`visibilitychange`,i),()=>{clearInterval(r),document.removeEventListener(`visibilitychange`,i)}}function NT(e){let t=()=>typeof document<`u`&&document.visibilityState===`hidden`,n=t()?null:e(),r=()=>{t()?(n?.(),n=null):n||=e()};return document.addEventListener(`visibilitychange`,r),()=>{document.removeEventListener(`visibilitychange`,r),n?.(),n=null}}function PT(e,t=``){let[n,r]=(0,z.useState)(()=>e&&oi(e)||t),i=(0,z.useRef)(e);return(0,z.useEffect)(()=>{i.current!==e&&(i.current=e,r(e?oi(e):``))},[e]),(0,z.useEffect)(()=>{e&&i.current===e&&si(e,n)},[e,n]),[n,r]}function FT(e,t){return PT(t?null:ii(e))}var IT=/\s*\{\s*"?(?:tool|thought|goal)"?\s*:\s*"[^"]*"[^}]*(?:"?tool_args"?\s*:\s*\{[^}]*\})?\s*\}/g,LT=new Set([`tool_start`,`tool_end`,`tool_result`]),RT=`Connection lost. Reconnecting`,zT=15e3,BT=[];function VT(e){let t=e.trim();if(!t.startsWith(`{`)||!t.includes(`"thought"`)&&!t.includes(`"answer"`)&&!t.includes(`"goal"`))return e;try{let e=JSON.parse(t);if(e.answer!==void 0)return String(e.answer)}catch{}let n=t.indexOf(`"answer"`);if(n===-1)return``;let r=t.indexOf(`:`,n+8);if(r===-1)return``;let i=r+1;for(;i<t.length&&/\s/.test(t[i]);)i++;if(i>=t.length||t[i]!==`"`)return``;let a=t.slice(i+1);return a.endsWith(`"}`)?a=a.slice(0,-2):a.endsWith(`"`)&&(a=a.slice(0,-1)),a.replace(/\\"/g,`"`).replace(/\\n/g,`
|
|
@@ -74,5 +74,5 @@ Details: ${u}`+f:t instanceof TypeError||u.includes(`fetch`)||u.includes(`Failed
|
|
|
74
74
|
`)))}else rt.length===0||lt||O||N||bt.current||ke||ee?.init_state===`initializing`||ht()||!ot.current&&!Ht||jS(e,Ut,()=>yt.current&&!ht()&&!B.getState().isStreaming&&!Dt.current)}},[Wt,rt,lt,Ht,O,N,ke,ee?.init_state,e,Ut,ht]);let Kt=(0,z.useRef)(!1);(0,z.useEffect)(()=>{Kt.current&&!Wt&&Ct(),Kt.current=Wt},[Wt,Ct]);let qt=(0,z.useCallback)(t=>{let n=rt.find(e=>e.id===t&&e.state===`queued`);n&&l&&(it(e=>Er(e,t,`queued`,`sending`)),Ti(e,n.text).then(()=>it(e=>Er(e,t,`sending`,`delivered`))).catch(e=>{s.chat.info(`Follow-up not taken by the running reply; it stays queued: ${e instanceof Error?e.message:e}`),it(e=>Er(e,t,`sending`,`queued`))}))},[rt,l,e,it]),Jt=(0,z.useCallback)(()=>{for(let e=n.length-1;e>=0;e--)if(n[e].role===`user`){Vt(n[e]);return}},[n,Vt]),Yt=()=>{pe(F?.title||``),ue(!0)},Xt=async()=>{let t=de.trim().slice(0,200).trim();t&&de!==F?.title&&t!==F?.title&&(await Ia(e,{title:t,title_is_custom:!0}),c(e,{title:t})),ue(!1)},Zt=(0,z.useCallback)(async()=>{if(e)try{let t=await Va(e);c(e,{private:t.private})}catch(e){s.ui.warn(`Failed to toggle private mode`,e)}},[e,c]),Qt=(0,z.useCallback)(async(t,n)=>{t.stopPropagation();let r=w.find(e=>e.id===n);s.doc.info(`Detaching document from session: ${r?.filename||n}`);try{await _o(e,n);let t=(B.getState().sessions.find(t=>t.id===e)?.document_ids??[]).filter(e=>e!==n);c(e,{document_ids:t}),t.length<=3&&ve(!1),s.doc.info(`Detached document from session: ${r?.filename||n}`)}catch(e){s.doc.error(`Failed to detach document: ${r?.filename||n}`,e)}},[w,e,c]),$t=(0,z.useCallback)(async t=>{if(t.preventDefault(),t.stopPropagation(),I(!1),t.dataTransfer.files.length!==0){for(let n of Array.from(t.dataTransfer.files)){s.doc.info(`Dropped on chat view: ${n.name}`);try{let t=await uo(n);if(e&&t?.id)try{await go(e,t.id);let r=B.getState().sessions.find(t=>t.id===e)?.document_ids??[];r.includes(t.id)||c(e,{document_ids:[...r,t.id]}),s.doc.info(`Auto-attached "${n.name}" to session ${e}`)}catch(e){s.doc.warn(`Could not attach dropped document to session: ${e}`)}}catch(e){s.doc.error(`Upload failed: ${n.name}`,e)}}try{let e=await co();T(e.documents||[])}catch(e){s.doc.error(`Could not refresh the document list after a drop`,e)}}},[e,c,T]),en=e=>{e.preventDefault(),e.stopPropagation(),I(!0)},tn=e=>{e.preventDefault(),e.stopPropagation(),I(!1)},nn=n.length>0?n[n.length-1]:void 0,rn=!l&&!O&&nn?.role===`assistant`&&Uy(nn.content),an=(0,z.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]),on=ke?`This chat used the retired "${ke}" agent and is read-only. Start a new chat.`:ee?.init_state===`initializing`?Ec:null;return(0,V.jsxs)(`main`,{className:`task-view ${me?`drag-active`:``}`,style:{"--session-panel-w":`${Mt}px`},onDrop:$t,onDragOver:en,onDragLeave:tn,"aria-label":F?.title||`Chat`,children:[(0,V.jsxs)(`header`,{className:`task-header`,children:[(0,V.jsx)(`div`,{className:`task-header-left`,children:le?(0,V.jsx)(`input`,{className:`title-edit`,value:de,maxLength:200,onChange:e=>pe(e.target.value),onBlur:Xt,onKeyDown:e=>{e.key===`Enter`&&Xt(),e.key===`Escape`&&(e.preventDefault(),ue(!1))},...Jr,autoFocus:!0,"aria-label":`Chat title`}):(0,V.jsxs)(`button`,{type:`button`,className:`task-title`,onClick:Yt,title:`Rename`,children:[(0,V.jsx)(`span`,{children:F?.title||`New chat`}),(0,V.jsx)(Gt,{size:12,"aria-hidden":`true`,className:`task-title-edit`})]})}),(0,V.jsxs)(`div`,{className:`task-header-right`,children:[(0,V.jsx)(gT,{isPrivate:!!F?.private,onToggle:Zt}),(0,V.jsx)(`button`,{className:`btn-icon-sm`,onClick:()=>D(!0),title:`Browse files on this PC`,"aria-label":`Browse files on this PC`,children:(0,V.jsx)(et,{size:15})}),(0,V.jsx)(`button`,{className:`btn-icon-sm`,onClick:Ee,title:`Export as Markdown`,"aria-label":`Export chat`,children:(0,V.jsx)(Ae,{size:15})}),(0,V.jsx)(hT,{messages:n,busy:l})]})]}),oe.length>0&&(()=>{let e=[...oe].sort((e,t)=>{let n=e.last_accessed_at||e.indexed_at||``;return(t.last_accessed_at||t.indexed_at||``).localeCompare(n)}),t=_e?e:e.slice(0,3),n=e.length-3;return(0,V.jsxs)(`div`,{className:`doc-context-bar${_e?` doc-context-expanded`:``}`,"aria-label":`${oe.length} indexed document${oe.length===1?``:`s`}`,children:[(0,V.jsx)(fe,{size:12,className:`doc-context-icon`,"aria-hidden":`true`}),(0,V.jsxs)(`button`,{type:`button`,className:`doc-context-label`,onClick:()=>E(!0),title:`Manage documents`,children:[oe.length,` indexed`]}),(0,V.jsxs)(`div`,{className:`doc-context-pills${_e?` doc-context-pills-expanded`:``}`,children:[t.map(e=>(0,V.jsxs)(`span`,{className:`doc-pill`,title:e.filepath||e.filename,children:[(0,V.jsx)(Ke,{size:9,className:`doc-pill-icon`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`doc-pill-name`,children:e.filename}),(0,V.jsx)(`button`,{className:`doc-pill-remove`,onClick:t=>Qt(t,e.id),"aria-label":`Remove ${e.filename} from this chat`,children:(0,V.jsx)(Bn,{size:10})})]},e.id)),!_e&&n>0&&(0,V.jsxs)(`button`,{className:`doc-pill-more`,onClick:e=>{e.stopPropagation(),ve(!0)},children:[`+`,n,` more`]}),_e&&n>0&&(0,V.jsx)(`button`,{className:`doc-pill-collapse`,onClick:e=>{e.stopPropagation(),ve(!1)},children:`show less`})]})]})})(),(0,V.jsx)(`div`,{className:`messages-scroll`,ref:Be,onScroll:jt,children:(0,V.jsxs)(`div`,{className:`messages-column`,children:[O&&(0,V.jsx)(`div`,{className:`skeleton-messages`,"aria-label":`Loading messages`,children:[0,1,2].map(e=>(0,V.jsx)(`div`,{className:`skeleton-msg`,children:(0,V.jsxs)(`div`,{className:`skeleton-lines`,children:[(0,V.jsx)(`div`,{className:`skeleton-line`}),(0,V.jsx)(`div`,{className:`skeleton-line`}),e!==2&&(0,V.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??UT.get(e.id):void 0,i=!Wt&&!Tt&&!ke&&!je&&e.role===`assistant`&&t===n.length-1&&!e.stopState&&!xx(e.content),a=e.stats?.seconds==null?an.get(e.id):e.stats.seconds*1e3;return(0,V.jsxs)(`div`,{className:ye===e.id?`msg-deleting`:void 0,"data-message-id":e.id,"data-role":e.role,children:[r&&(0,V.jsx)(WT,{text:r}),(0,V.jsx)(Vx,{message:e,agentSteps:e.role===`assistant`?e.agentSteps:void 0,onDelete:Wt?void 0:Bt,onResend:!Wt&&e.role===`user`&&!ke?Vt:void 0,extraActions:i?(0,V.jsx)(GC,{answeredBy:e.stats?.model??F?.effective_model,onPick:t=>R(e,t)}):void 0,latencyMs:a}),Tt?.messageId===e.id&&(0,V.jsx)(JC,{original:e,originalModel:e.stats?.model??F?.effective_model,originalLatencyMs:a,state:Tt.state,keeping:Tt.keeping,onKeep:e=>{Ot(e)},onClose:kt})]},e.id)}),(l||je)&&Ne&&(0,V.jsx)(WT,{text:Ne}),(l||je)&&(0,V.jsx)(`div`,{className:`streaming-bubble ${je?`stream-ending`:`stream-active`}`,children:(0,V.jsx)(Vx,{message:{id:-1,session_id:e,role:`assistant`,content:(l?u:Fe.current)||``,created_at:``,rag_sources:null},isStreaming:l,agentSteps:l?m:Ie.current,agentStepsActive:l&&m.some(e=>e.active),cards:l?x:Le.current,liveStatus:l?P:null,awaitingUser:l&&(ne||re||ie)})}),(0,V.jsx)(`div`,{ref:ze})]})}),(0,V.jsx)(mT,{sessionId:e,messages:n,busy:Wt,onUsage:wt,onJumpToMessage:Pt}),L&&(0,V.jsx)(`button`,{className:`scroll-bottom-btn`,onClick:Ft,title:`Scroll to bottom`,"aria-label":`Scroll to bottom`,children:(0,V.jsx)(v,{size:16})}),me&&(0,V.jsxs)(`div`,{className:`drag-overlay`,children:[(0,V.jsx)(Pn,{size:32,strokeWidth:1.5,"aria-hidden":`true`}),(0,V.jsx)(`span`,{children:`Drop files to index them for this chat`})]}),xe&&(0,V.jsxs)(`div`,{className:`toast policy-alert-toast`,role:`alert`,children:[(0,V.jsxs)(`span`,{children:[`Blocked: `,xe.tool,` is restricted by policy.`]}),xe.receiptId?(0,V.jsx)(`button`,{type:`button`,className:`policy-alert-toast-link`,onClick:()=>{let e=xe.receiptId;e&&(M(`policy_alert`),te(!0),Te(e))},children:`View receipt`}):(0,V.jsx)(`span`,{className:`policy-alert-toast-missing`,children:`Receipt unavailable`})]}),(0,V.jsx)(`div`,{className:`input-area`,children:(0,V.jsxs)(`div`,{className:`input-column`,children:[(0,V.jsx)(vT,{message:De,onDismiss:Oe}),rn&&nn&&(0,V.jsx)(YS,{content:nn.content,onRetry:Jt}),(0,V.jsx)(Pv,{sessionId:e}),(0,V.jsx)(UC,{usage:xt}),(0,V.jsx)(_T,{sessionId:e}),(0,V.jsx)(vC,{items:rt,onRemove:e=>it(t=>Dr(t,e)),onRetry:e=>it(t=>Er(t,e,`failed`,`queued`)),onSteer:l&&!Je?qt:void 0,replying:l,busyRetry:!!lt}),(0,V.jsx)(QS,{value:se,onChange:ce,onSubmit:()=>Lt(),onStop:It,streaming:l,stopping:Je,queueWhileStreaming:!0,disabledReason:on,attachments:ge,inputRef:Ve,placeholder:l?`Queue your next message`:n.length===0?`Ask GAIA anything`:`Reply to GAIA`,leftControls:(0,V.jsx)(hC,{sessionId:e,disabled:!!ke}),rightControls:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(HC,{usage:xt,unavailable:St,sessionId:e,busy:Wt,onUsage:wt,onDetails:()=>Nt(`context`)}),(0,V.jsx)(uC,{})]})})]})})]})}var JT=e=>e.split(/[\\/]/).filter(Boolean).pop()??e;function YT({folder:e,disabled:t}){let n=B(e=>e.draftFolder),r=B(e=>e.setDraftFolder),{open:i,picker:a,error:o}=xw(r),s=e.gaia_folder?`GAIA works in its own folder, ${e.path}.`:`GAIA works in ${e.path}.`;return e.choosable?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`button`,{type:`button`,className:`new-chat-folder is-button${n?` is-on`:``}`,onClick:()=>i(e.path),disabled:t,"aria-haspopup":`dialog`,"aria-label":n?`Folder for this chat: ${e.name}, plus ${JT(n)}`:`Folder for this chat: ${e.name}`,title:n?`This chat can read and write ${n}. Click to pick another folder.`:`${s} Click to give this chat another folder.`,children:[(0,V.jsx)(nt,{size:13,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`new-chat-folder-name`,children:n?`${e.name} + ${JT(n)}`:e.name}),(0,V.jsx)(re,{size:12,"aria-hidden":`true`})]}),n&&(0,V.jsx)(`button`,{type:`button`,className:`btn-icon-sm new-chat-folder-clear`,onClick:()=>r(null),disabled:t,"aria-label":`Don't give this chat ${JT(n)}`,title:`Don't add this folder`,children:(0,V.jsx)(Bn,{size:12})}),o&&(0,V.jsx)(`span`,{className:`new-chat-folder-error`,role:`alert`,children:o}),a]}):(0,V.jsxs)(`span`,{className:`new-chat-folder`,title:e.gaia_folder?`${s} Attach a file or start GAIA from a project folder to work there.`:s,children:[(0,V.jsx)(nt,{size:13,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`new-chat-folder-name`,children:e.name})]})}var XT=c();async function ZT(e,t,n){let r=`${XT}${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 QT(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 $T(){return ZT(`GET`,`/memory/stats`)}function eE(e=30){return ZT(`GET`,`/memory/activity?days=${e}`)}function tE(e={}){return ZT(`GET`,`/memory/knowledge${QT(e)}`)}function nE(e){return ZT(`POST`,`/memory/knowledge`,e)}function rE(e,t){return ZT(`PUT`,`/memory/knowledge/${encodeURIComponent(e)}`,t)}function iE(e){return ZT(`DELETE`,`/memory/knowledge/${encodeURIComponent(e)}`)}function aE(){return ZT(`GET`,`/memory/entities`)}function oE(){return ZT(`GET`,`/memory/tools`)}function sE(e=20){return ZT(`GET`,`/memory/conversations?limit=${e}`)}function cE(e,t=20){return ZT(`GET`,`/memory/conversations/search?query=${encodeURIComponent(e)}&limit=${t}`)}function lE(e){return ZT(`GET`,`/memory/conversations/${encodeURIComponent(e)}`)}function uE(e=7){return ZT(`GET`,`/memory/upcoming?days=${e}`)}function dE(){return ZT(`GET`,`/memory/embedding-coverage`)}function fE(){return ZT(`POST`,`/memory/consolidate`)}function pE(){return ZT(`POST`,`/memory/rebuild-embeddings`)}function mE(){return ZT(`POST`,`/memory/reconcile`)}function hE(){return ZT(`POST`,`/memory/rebuild-fts`)}function gE(){return ZT(`POST`,`/memory/refresh-system-context`)}function _E(){return new EventSource(`${XT}/memory/stream-discovery`)}function vE(e){return new EventSource(`${XT}/memory/stream-inference?include_browser=${e}`)}function yE(e){return ZT(`POST`,`/memory/commit-discovery`,{items:e})}function bE(e){return ZT(`POST`,`/memory/commit-inference`,{insights:e})}function xE(){return ZT(`GET`,`/memory/settings`)}function SE(e){return ZT(`PUT`,`/memory/settings`,e)}function CE(){return ZT(`DELETE`,`/memory/all`)}function wE(){return ZT(`POST`,`/memory/reinitialize`)}function TE(){return ZT(`GET`,`/goals/stats`)}function EE(e={}){return ZT(`GET`,`/goals${QT(e)}`)}function DE(e){return ZT(`POST`,`/goals`,e)}function OE(e){return ZT(`PUT`,`/goals/${encodeURIComponent(e)}/approve`)}function kE(e){return ZT(`PUT`,`/goals/${encodeURIComponent(e)}/reject`)}function AE(e){return ZT(`PUT`,`/goals/${encodeURIComponent(e)}/cancel`)}function jE(e){return ZT(`DELETE`,`/goals/${encodeURIComponent(e)}`)}function ME({disabled:e}){let t=B(e=>e.draftPrivate),n=B(e=>e.setDraftPrivate),r=B(e=>e.settingsSection!==null),[i,a]=(0,z.useState)(null),[o,c]=(0,z.useState)(!1);return(0,z.useEffect)(()=>{if(r)return;let e=!1;return xE().then(t=>{e||(a(t.memory_enabled),c(!1))}).catch(t=>{e||(s.ui.error(`Could not read the memory setting for the Private chip`,t),a(null),c(!0))}),()=>{e=!0}},[r]),(0,z.useEffect)(()=>{i===!1&&t&&n(!1)},[i,t,n]),i===!1?(0,V.jsxs)(`button`,{type:`button`,className:`composer-chip is-unavailable`,disabled:!0,"aria-label":`Memory off`,title:`Memory is off in Settings, so no chat is saved to memory`,children:[(0,V.jsx)(Ie,{size:13,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`composer-chip-label`,children:`Memory off`})]}):(0,V.jsxs)(`button`,{type:`button`,className:`composer-chip${t?` is-on`:``}`,onClick:()=>n(!t),disabled:e,"aria-label":t?`Turn off private chat`:`Turn on private chat`,title:t?`Turn off private chat. This chat won't be saved to memory.`:o?`Couldn't read the memory setting. Turn on private chat to keep this chat out of memory either way.`:`Turn on private chat. It won't be saved to memory.`,children:[t?(0,V.jsx)(Ie,{size:13,"aria-hidden":`true`}):(0,V.jsx)(Re,{size:13,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`composer-chip-label`,children:t?`Private`:o?`Memory unknown`:`Memory on`})]})}function NE({cards:e,onPick:t,disabled:n}){return e.length===0?null:(0,V.jsx)(`ul`,{className:`start-cards`,"aria-label":`Things to try`,children:e.map(e=>(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,className:`start-card`,onClick:()=>t(e),disabled:n,title:e.needs_input?`${e.prompt}…`:e.prompt,children:[(0,V.jsxs)(`span`,{className:`start-card-title`,children:[e.title,(0,V.jsx)(b,{size:13,"aria-hidden":`true`})]}),(0,V.jsx)(`span`,{className:`start-card-note`,children:e.note})]})},e.skill))})}var PE=1e3;function FE(){let[e,t]=(0,z.useState)(null);return(0,z.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(()=>{Zi().then(r,i)},PE)):t(null))},i=n=>{e||(s.system.warn(`Warm-up status unavailable`,n),t(null))};return Xi().then(r,i),()=>{e=!0,n&&clearTimeout(n)}},[]),e}function IE(e){return e===`gpu`?`your GPU`:e===`npu`?`your NPU`:e===`cpu`?`the CPU`:null}function LE(e){return e<1?`under 1 GB`:`${e.toFixed(1)} GB`}var RE=15e3;function zE(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 BE({seconds:e,model:t,device:n}){if(!t)return`Getting GAIA ready… ${e}s`;let r=IE(n);return`Loading ${us(t)}${r?` on ${r}`:``}… ${e}s`}function VE({detail:e,onRetry:t}){let[n,r]=(0,z.useState)(!1);return(0,V.jsxs)(`div`,{className:`new-chat-note`,children:[(0,V.jsxs)(`p`,{children:[`GAIA’s assistant didn’t start, so it can’t suggest tasks yet.`,` `,(0,V.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:t,children:`Try again`})]}),(0,V.jsxs)(`button`,{type:`button`,className:`new-chat-details`,"aria-expanded":n,onClick:()=>r(e=>!e),children:[(0,V.jsx)(F,{size:12,className:n?`is-open`:``,"aria-hidden":`true`}),` Details`]}),n&&(0,V.jsx)(`pre`,{className:`new-chat-details-text`,children:e})]})}var HE=`document-brief`;function UE(){let{documents:e,draftDocumentIds:t,addDraftDocuments:n}=B.getState();n(e.filter(e=>e.indexing_status===`complete`&&!t.includes(e.id)).map(e=>e.id))}function WE(){let e=B(e=>e.documents),t=B(e=>e.draftDocumentIds),n=B(e=>e.removeDraftDocument),r=B(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,V.jsxs)(`div`,{className:`new-chat-docs`,children:[i.length>0&&(0,V.jsx)(`ul`,{className:`new-chat-doc-list`,"aria-label":`Documents for this chat`,children:i.map(e=>(0,V.jsxs)(`li`,{className:`new-chat-doc`,children:[(0,V.jsx)(Ke,{size:12,"aria-hidden":`true`}),(0,V.jsx)(`span`,{children:e.filename}),(0,V.jsx)(`button`,{type:`button`,className:`new-chat-doc-remove`,onClick:()=>n(e.id),"aria-label":`Don't attach ${e.filename}`,children:(0,V.jsx)(Bn,{size:12,"aria-hidden":`true`})})]},e.id))}),o>0&&(0,V.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,V.jsxs)(`button`,{type:`button`,className:`link-btn`,onClick:UE,children:[`Attach `,o===1?`it`:`all ${o}`]}),o>1&&(0,V.jsxs)(V.Fragment,{children:[` · `,(0,V.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>r(!0),children:`Choose`})]})]})]})}function GE({error:e}){let t=B(e=>e.openSettings);return(0,V.jsxs)(`div`,{className:`new-chat-setup-failed`,role:`alert`,children:[(0,V.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,V.jsx)(`p`,{className:`new-chat-setup-failed-error`,children:e}),(0,V.jsxs)(`p`,{children:[`Use a cloud model, or pick a smaller one.`,` `,(0,V.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>t(`model`),children:`Choose a model`})]})]})}function KE({onSend:e,initialText:t=``,focusRequest:n=0}){let r=B(e=>e.systemStatus?.init_state===`initializing`),i=B(e=>e.systemStatus?.model_loaded?null:e.systemStatus?.setup_error??null),a=cs(e=>!!e.active?.remote),[o,c]=PT(ai,t),[l,u]=(0,z.useState)(null),[d,f]=(0,z.useState)(!1),[p,m]=(0,z.useState)(null),[h,g]=(0,z.useState)(null),_=(0,z.useRef)(null),v=bT(),y=FE();ls();let b=(0,z.useRef)(!0),x=(0,z.useCallback)((e=!1)=>{e||g(null),pa().then(e=>{b.current&&(m(e),g(e.skills_error??null))}).catch(e=>{s.api.warn(`New-chat suggestions unavailable`,e),b.current&&g(e instanceof Error?e.message:String(e))})},[]);(0,z.useEffect)(()=>(b.current=!0,x(),()=>{b.current=!1}),[x]),(0,z.useEffect)(()=>{co().then(e=>B.getState().setDocuments(e.documents||[])).catch(e=>s.api.warn(`Document library unavailable; not offering its documents`,e))},[]),(0,z.useEffect)(()=>{if(h)return MT(()=>x(!0),RE)},[h,x]);let S=(0,z.useRef)(!1),C=(0,z.useRef)([]),w=(0,z.useCallback)(async(t,n=``)=>{if(t){if(S.current)C.current.push(n||t),c(``);else{S.current=!0,f(!0),u(null),c(``);try{let n=await e(t);v.clear();let r=C.current.splice(0),i=B.getState().currentSessionId;if(r.length>0&&i){let e=(e,t)=>n===!1?[...e,{...wr(t,`failed`),error:`The first message was not sent.`}]:Tr(e,t,`queued`);B.getState().updateQueue(i,t=>r.reduce(e,t))}}catch(e){let r=C.current.splice(0);c([n||t,...r].join(`
|
|
75
75
|
|
|
76
76
|
`)),u(e instanceof Error?e.message:String(e))}finally{S.current=!1,f(!1)}}}},[v,e]),T=(0,z.useCallback)(()=>w(v.compose(o.trim()),o.trim()),[v,w,o]);(0,z.useEffect)(()=>{n&&_.current?.focus()},[n]);let E=(0,z.useCallback)(e=>{e.skill===HE&&UE(),e.needs_input?(c(e.prompt),_.current?.focus()):w(v.compose(e.prompt))},[v,w]),D=p?.working_folder;return(0,V.jsx)(`main`,{className:`new-chat`,"aria-label":`New chat`,children:(0,V.jsxs)(`div`,{className:`new-chat-inner`,children:[(0,V.jsx)(`h1`,{className:`new-chat-greeting`,children:zE()}),i&&!a&&(0,V.jsx)(GE,{error:i}),(0,V.jsx)(QS,{value:o,onChange:c,onSubmit:T,attachments:v,disabledReason:r?Ec:null,autoFocus:!0,inputRef:_,leftControls:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(hC,{sessionId:null}),(0,V.jsx)(ME,{disabled:d})]}),rightControls:(0,V.jsx)(uC,{})}),(0,V.jsx)(`div`,{className:`new-chat-meta`,children:D&&(0,V.jsx)(YT,{folder:D,disabled:r||d})}),(0,V.jsx)(WE,{}),y!==null&&!r&&(0,V.jsx)(`p`,{className:`new-chat-warmup`,role:`status`,children:BE(y)}),l&&(0,V.jsx)(`p`,{className:`new-chat-error`,role:`alert`,children:l}),p&&(0,V.jsx)(NE,{cards:p.cards,onPick:E,disabled:r||d}),h&&(0,V.jsx)(VE,{detail:h,onRetry:()=>x()})]})})}function qE(e){let t=e?.reason;return t===`needs_key`||t===`bad_key`}function JE({provider:e,limit:t}){let[n,r]=(0,z.useState)(null),[i,a]=(0,z.useState)(null);if((0,z.useEffect)(()=>{r(null),a(null),ka(e).then(r).catch(e=>a(e instanceof Error?e.message:String(e)))},[e]),i)return(0,V.jsxs)(`p`,{className:`settings-error`,role:`alert`,children:[`Prices could not be loaded: `,i]});if(!n)return(0,V.jsxs)(`p`,{className:`settings-hint`,children:[(0,V.jsx)(R,{size:13,className:`spin`}),` Loading prices…`]});if(n.models.length===0)return(0,V.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,V.jsxs)(`div`,{className:`cloud-prices`,"aria-label":`Prices`,children:[(0,V.jsx)(`ul`,{className:`cloud-prices-list`,children:o.map(e=>(0,V.jsxs)(`li`,{children:[(0,V.jsxs)(`span`,{className:`cloud-prices-name`,children:[e.name,e.note&&(0,V.jsxs)(`span`,{className:`cloud-prices-note`,children:[` · `,e.note]})]}),(0,V.jsx)(`span`,{className:`cloud-prices-price`,children:rC(e.price)})]},e.model))}),(0,V.jsxs)(`span`,{className:`settings-hint`,children:[n.source,`. You pay the provider for what you use.`]})]})}function YE({label:e,value:t,ok:n}){return(0,V.jsxs)(`li`,{className:`setup-check-row${n?` is-ok`:``}`,children:[n?(0,V.jsx)(P,{size:13,"aria-hidden":`true`}):(0,V.jsx)(gt,{size:13,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`setup-check-label`,children:e}),(0,V.jsx)(`span`,{className:`setup-check-value`,children:t})]})}function XE(e){return!!e.gpu_name||!!e.npu_detected||e.lemonade_running}function ZE(e){let t=[e.gpu_name,e.npu_detected?`Ryzen AI NPU`:null].filter(Boolean);return t.length?{value:t.join(` · `),ok:!0}:XE(e)?{value:`No GPU or NPU reported; models run on the CPU`,ok:!1}:{value:`Checked once the model server is running`,ok:!1}}function QE({hardware:e,error:t}){if(t)return(0,V.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,V.jsxs)(`p`,{className:`setup-hint`,role:`status`,children:[(0,V.jsx)(R,{size:13,className:`spin`,"aria-hidden":`true`}),` Checking this PC…`]});let n=ZE(e),r=e.lemonade_running?e.warnings:e.warnings.filter(e=>!/\bNPU\b/.test(e));return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`ul`,{className:`setup-check`,"aria-label":`This PC`,children:[(0,V.jsx)(YE,{label:`Device`,value:n.value,ok:n.ok}),(0,V.jsx)(YE,{label:`Memory`,value:e.ram_gb==null?`Not reported`:`${e.ram_gb} GB`,ok:e.ram_gb!=null}),(0,V.jsx)(YE,{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,V.jsx)(`p`,{className:`setup-error`,role:`alert`,children:e.blockers.join(` `)}),r.length>0&&(0,V.jsx)(`p`,{className:`setup-hint`,children:r.join(` `)})]})}function $E({plan:e,planError:t,chosen:n,locked:r,onPlan:i}){let[a,o]=(0,z.useState)(null),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(!1);if(n){let t=l||e?.chat_model.user_set&&e.chat_model.id===n;return(0,V.jsxs)(`p`,{className:`setup-hint`,children:[t?`You chose `:`Setup chose `,(0,V.jsx)(`strong`,{children:_s(n)}),t?`.`:` for this PC.`]})}if(t)return(0,V.jsxs)(`p`,{className:`setup-hint`,children:[`Setup names the chat model once it has checked this PC (`,t,`).`]});if(!e)return(0,V.jsxs)(`p`,{className:`setup-hint`,role:`status`,children:[(0,V.jsx)(R,{size:13,className:`spin`,"aria-hidden":`true`}),` Working out which model fits this PC…`]});let d=e.chat_model,f=_s(d.id);if(e.decided_after_server){let t=e.options.map(e=>_s(e.id));return(0,V.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 fa(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:LE(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,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`p`,{className:`setup-hint`,children:[(0,V.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,V.jsx)(`div`,{className:`setup-choices`,role:`radiogroup`,"aria-label":`Chat model`,children:e.options.map(t=>(0,V.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,V.jsx)(R,{size:14,className:`spin`,"aria-hidden":`true`}),(0,V.jsxs)(`span`,{children:[(0,V.jsxs)(`span`,{className:`setup-choice-title`,children:[_s(t.id),t.id===e.recommended_model?` (recommended)`:``]}),(0,V.jsx)(`span`,{className:`setup-choice-note`,children:t.fits===!1?t.reason:t.size_gb==null?`Size unknown`:LE(t.size_gb)})]})]},t.id))}),s&&(0,V.jsx)(`p`,{className:`setup-error`,role:`alert`,children:s})]})}function eD(){let[e,t]=(0,z.useState)(null),n=(0,z.useCallback)(()=>{Promise.resolve(_a()).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,z.useEffect)(n,[n]),{network:e,recheck:n}}var tD=[{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.`}],nD=1e3,rD=`gaia-setup-choice`;function iD(){try{let e=localStorage.getItem(rD);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 aD(e){try{localStorage.setItem(rD,e)}catch(e){console.warn(`[SetupScreen] could not save the provider choice; a reload will ask again`,e)}}function oD({status:e,n:t}){return e===`done`?(0,V.jsx)(P,{size:14,"aria-hidden":`true`}):e===`active`?(0,V.jsx)(R,{size:14,className:`spin`,"aria-hidden":`true`}):e===`failed`||e===`cancelled`?(0,V.jsx)(ce,{size:14,"aria-hidden":`true`}):(0,V.jsx)(V.Fragment,{children:t})}var sD=[`ok`,`needs_key`,`too_old`];function cD({onChosen:e}){let[t,n]=(0,z.useState)(null),[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)([]),[s,c]=(0,z.useState)(!1),[l,u]=(0,z.useState)(``),[d,f]=(0,z.useState)(!1),[p,m]=(0,z.useState)(!1),[h,g]=(0,z.useState)(null),[_,v]=(0,z.useState)(null),y=(0,z.useRef)(!0),b=(0,z.useCallback)(async()=>{i(null);try{let e=await ma();if(!e.offer)return;c(!0);let{found:t,unchecked:r=[]}=await ha();if(!y.current)return;o(t?[]:r),t&&sD.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,z.useEffect)(()=>(y.current=!0,b(),()=>{y.current=!1}),[b]);let x=(0,z.useCallback)(async n=>{if(t){m(!0),g(null);try{await ga(n===`external`?{mode:n,base_url:t.found.url,api_key:l.trim()||void 0}:{mode:n}),u(``),v(n),e(n)}catch(e){qE(e)&&f(!0),g(e instanceof Error?e.message:String(e))}finally{m(!1)}}},[t,l,e]);if(r||a.length>0)return(0,V.jsxs)(`div`,{className:`setup-row`,children:[(0,V.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,V.jsxs)(`button`,{type:`button`,className:`btn-secondary`,disabled:s,onClick:()=>void b(),children:[s&&(0,V.jsx)(R,{size:13,className:`spin`}),` Check again`]})]});if(!t)return s?(0,V.jsxs)(`p`,{className:`setup-hint`,role:`status`,children:[(0,V.jsx)(R,{size:13,className:`spin`,"aria-hidden":`true`}),` Looking for a Lemonade Server you already run…`]}):null;let{target:S,found:C}=t;return _?(0,V.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,V.jsx)(`p`,{className:`setup-hint`,children:C.message}):(0,V.jsxs)(`form`,{className:`setup-lemonade`,"aria-label":`Use your Lemonade Server`,onSubmit:e=>{e.preventDefault(),x(`external`)},children:[(0,V.jsxs)(`span`,{className:`setup-choice-title`,children:[`Use the Lemonade you already run at `,C.url,C.version?` (v${C.version})`:``]}),(0,V.jsx)(`span`,{className:`setup-choice-note`,children:S.what_gaia_does}),d&&(0,V.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,V.jsxs)(`div`,{className:`setup-row`,children:[(0,V.jsxs)(`button`,{type:`submit`,className:`btn-primary`,disabled:p||d&&!l.trim(),children:[p&&(0,V.jsx)(R,{size:13,className:`spin`}),` Use mine`]}),(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:p,onClick:()=>void x(`gaia`),children:`Use GAIA’s own`})]}),h&&(0,V.jsx)(`p`,{className:`setup-error`,role:`alert`,children:h})]})}function lD({problem:e,onRetry:t,onUseGaia:n}){return(0,V.jsxs)(V.Fragment,{children:[e.start&&(0,V.jsx)(`p`,{className:`setup-hint`,children:e.start}),(0,V.jsxs)(`div`,{className:`setup-row`,children:[(0,V.jsx)(`button`,{type:`button`,className:`btn-primary`,onClick:t,children:`Try again`}),e.use_gaia&&(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:n,children:`Use GAIA’s own instead`})]}),e.use_gaia&&(0,V.jsx)(`p`,{className:`setup-hint`,children:`GAIA’s own Lemonade Server downloads its own copy of the models.`}),e.switch_hint&&(0,V.jsx)(`p`,{className:`setup-hint`,children:e.switch_hint})]})}function uD(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:LE(t.download_gb),r=`chat model ${_s(t.chat_model.id)}, plus the embedding model`;return{...e,detail:n?`${r} (${n})`:r}}return e}):e}function dD({initial:e,onReady:t}){let n=cs(e=>e.refresh),r=cs(e=>e.select),[i,a]=(0,z.useState)(()=>iD()??`local`),[o,s]=(0,z.useState)(null),[c,l]=(0,z.useState)(null),[u,d]=(0,z.useState)(null),[f,p]=(0,z.useState)(null),[m,h]=(0,z.useState)(``),[g,_]=(0,z.useState)({busy:!1,error:null,done:!1}),[v,y]=(0,z.useState)(!1),[b,x]=(0,z.useState)(null),[S,C]=(0,z.useState)(null),[w,T]=(0,z.useState)(null),[E,D]=(0,z.useState)([]),[O,k]=(0,z.useState)(!1),ee=(0,z.useRef)(null),A=(0,z.useRef)(!0);(0,z.useEffect)(()=>()=>{A.current=!1},[]);let{network:j,recheck:te}=eD(),M=e=>e===`amd`&&j?.reachable===!1,N=i!==`local`,ne=u?.steps??uD(N?e.cloud_steps??e.steps:e.steps,b,N),re=u?.state===`running`||u?.state===`verifying`,ie=u?.state===`ready`,ae=re||ie,oe=!!u?.chat_model||!!b&&!b.decided_after_server,se=N?3:4,ce=!!c||!!o&&!XE(o),le=(0,z.useCallback)(()=>{l(null),sa().then(s).catch(e=>l(e instanceof Error?e.message:String(e)))},[]),ue=(0,z.useRef)(0),de=(0,z.useCallback)(()=>{let e=++ue.current;x(null),C(null),da().then(t=>{e===ue.current&&x(t)}).catch(t=>{e===ue.current&&C(t instanceof Error?t.message:String(t))})},[]);(0,z.useEffect)(()=>{ma().then(e=>k(e.source===`config`)).catch(e=>console.warn(`[SetupScreen] could not read which Lemonade GAIA uses`,e)),le(),de(),ua().then(e=>{e.state!==`idle`&&(d(e),e.skip_chat_model&&!iD()&&a(`fireworks`))}).catch(e=>p(`Could not read setup progress: ${e instanceof Error?e.message:e}`))},[le,de]);let fe=(0,z.useCallback)(()=>{ee.current&&clearInterval(ee.current),ee.current=null},[]);(0,z.useEffect)(()=>{ie&&le()},[ie,le]),(0,z.useEffect)(()=>(re&&(ee.current=setInterval(()=>{ua().then(d).catch(e=>{d(t=>t&&{...t,state:`failed`,error:`Lost contact with GAIA: ${e instanceof Error?e.message:e}`})})},nD)),fe),[re,fe]);let pe=(0,z.useCallback)(async(e=!1)=>{p(null);try{aD(i),d(await la(N,e)),e&&k(!1)}catch(e){p(e instanceof Error?e.message:String(e))}},[N,i]),me=(0,z.useCallback)(async()=>{_({busy:!0,error:null,done:!1});try{await xa(i,{api_key:!O&&m||void 0},e=>_({busy:!0,error:null,done:!1,waiting:e}),()=>!A.current);let{models:e}=await Ca(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]),I=(0,z.useCallback)(e=>{aD(e),a(e),_({busy:!1,error:null,done:!1})},[]),L=(0,z.useCallback)(async e=>{await n(),t(e)},[t,n]),he=ie&&(!N||g.done),ge=ne.find(e=>e.status===`active`||e.status===`failed`),_e=N?w:u?.chat_model??(b&&!b.decided_after_server?b.chat_model.id:null);return(0,z.useEffect)(()=>{he&&pa().then(e=>D(e.cards)).catch(e=>console.warn(`[SetupScreen] no first tasks to offer`,e))},[he]),(0,V.jsx)(`main`,{className:`setup`,"aria-labelledby":`setup-title`,children:(0,V.jsxs)(`div`,{className:`setup-inner`,children:[(0,V.jsx)(`h1`,{id:`setup-title`,className:`setup-title`,children:`Set up GAIA`}),(0,V.jsx)(`p`,{className:`setup-lede`,children:he?`All set.`:u?`Setting things up. Setup keeps going if you switch away.`:`A few minutes of setup, then your first chat.`}),(0,V.jsxs)(`ol`,{className:`setup-steps`,children:[(0,V.jsxs)(`li`,{className:`setup-step${ce?``:o?` is-done`:` is-current`}`,children:[(0,V.jsxs)(`div`,{className:`setup-step-head`,children:[(0,V.jsx)(`span`,{className:`setup-step-num`,children:ce?(0,V.jsx)(gt,{size:14,"aria-hidden":`true`}):o?(0,V.jsx)(P,{size:14,"aria-hidden":`true`}):1}),(0,V.jsx)(`span`,{className:`setup-step-label`,children:`Check this PC`})]}),!ae&&(0,V.jsx)(`div`,{className:`setup-step-body`,children:(0,V.jsx)(QE,{hardware:o,error:c})})]}),(0,V.jsxs)(`li`,{className:`setup-step${ae?` is-done`:` is-current`}`,children:[(0,V.jsxs)(`div`,{className:`setup-step-head`,children:[(0,V.jsx)(`span`,{className:`setup-step-num`,children:ae?(0,V.jsx)(P,{size:14,"aria-hidden":`true`}):2}),(0,V.jsx)(`span`,{className:`setup-step-label`,children:`Choose where GAIA runs`})]}),!ae&&(0,V.jsxs)(`div`,{className:`setup-step-body`,children:[(0,V.jsx)(cD,{onChosen:e=>{k(e===`external`),le(),de()}}),(0,V.jsx)(`div`,{className:`setup-choices`,role:`radiogroup`,"aria-label":`Where GAIA runs`,children:tD.map(e=>(0,V.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":i===e.id,className:`setup-choice${i===e.id?` is-active`:``}${M(e.id)?` is-disabled`:``}`,onClick:()=>a(e.id),disabled:M(e.id),children:[e.id===`local`?(0,V.jsx)(Ee,{size:16,"aria-hidden":`true`}):(0,V.jsx)(ve,{size:16,"aria-hidden":`true`}),(0,V.jsxs)(`span`,{children:[(0,V.jsx)(`span`,{className:`setup-choice-title`,children:e.title}),(0,V.jsx)(`span`,{className:`setup-choice-note`,children:M(e.id)?j?.detail:e.note})]})]},e.id))}),j?.reachable===!1&&(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:te,children:`Check the AMD gateway again`})]})]}),!N&&(0,V.jsxs)(`li`,{className:`setup-step${ae&&oe?` is-done`:ae?` is-pending`:` is-current`}`,children:[(0,V.jsxs)(`div`,{className:`setup-step-head`,children:[(0,V.jsx)(`span`,{className:`setup-step-num`,children:ae&&oe?(0,V.jsx)(P,{size:14,"aria-hidden":`true`}):3}),(0,V.jsx)(`span`,{className:`setup-step-label`,children:`Chat model`})]}),(0,V.jsx)(`div`,{className:`setup-step-body`,children:(0,V.jsx)($E,{plan:b,planError:S,chosen:u?.chat_model??null,locked:ae,onPlan:x})})]}),!u&&(0,V.jsxs)(`li`,{className:`setup-step-action`,children:[(0,V.jsx)(`button`,{type:`button`,className:`btn-primary setup-start`,onClick:()=>void pe(),disabled:M(i),children:`Start setup`}),M(i)&&(0,V.jsxs)(`p`,{className:`setup-error`,role:`alert`,children:[j?.detail,`. Choose another option, or connect and check again.`]}),f&&(0,V.jsx)(`p`,{className:`setup-error`,role:`alert`,children:f})]}),ne.map((e,t)=>{let n=u?e.status:`pending`,r=n===`active`,i=n===`failed`||n===`cancelled`;return(0,V.jsxs)(`li`,{className:`setup-step is-${n??`pending`}`,"aria-current":r?`step`:void 0,children:[(0,V.jsxs)(`div`,{className:`setup-step-head`,children:[(0,V.jsx)(`span`,{className:`setup-step-num`,children:(0,V.jsx)(oD,{status:n,n:t+se})}),(0,V.jsxs)(`span`,{className:`setup-step-label`,children:[e.label,e.detail&&(0,V.jsxs)(`span`,{className:`setup-step-detail`,children:[` — `,e.detail]})]})]}),r&&u&&(0,V.jsxs)(`div`,{className:`setup-step-body`,children:[(0,V.jsx)(`p`,{className:`setup-hint`,role:`status`,children:u.text}),u.percent!=null&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`progress`,{className:`setup-progress`,max:100,value:u.percent,"aria-label":u.text}),(0,V.jsxs)(`p`,{className:`setup-hint`,children:[u.percent,`%`,u.size?` · ${u.size}`:``]})]})]}),i&&u&&e===ge&&(0,V.jsxs)(`div`,{className:`setup-step-body`,children:[(0,V.jsx)(`p`,{className:`setup-error`,role:`alert`,children:u.error??`Setup stopped.`}),u.problem?(0,V.jsx)(lD,{problem:u.problem,onRetry:()=>void pe(),onUseGaia:()=>void pe(!0)}):(0,V.jsxs)(`div`,{className:`setup-row`,children:[(0,V.jsx)(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void pe(!!u.gaia_lemonade),children:`Try again`}),(0,V.jsxs)(`span`,{className:`setup-hint`,children:[`or run `,(0,V.jsx)(`code`,{children:u.command}),` in a terminal.`]})]}),f&&(0,V.jsx)(`p`,{className:`setup-error`,role:`alert`,children:f})]})]},e.key)}),N&&(0,V.jsxs)(`li`,{className:`setup-step${g.done?` is-done`:ie?` is-current`:` is-pending`}`,children:[(0,V.jsxs)(`div`,{className:`setup-step-head`,children:[(0,V.jsx)(`span`,{className:`setup-step-num`,children:g.done?(0,V.jsx)(P,{size:14,"aria-hidden":`true`}):ne.length+se}),(0,V.jsxs)(`span`,{className:`setup-step-label`,children:[`Connect `,tD.find(e=>e.id===i)?.title]})]}),ie&&!g.done&&(0,V.jsxs)(`form`,{className:`setup-step-body`,onSubmit:e=>{e.preventDefault(),me()},children:[(0,V.jsx)(`div`,{className:`setup-row`,role:`radiogroup`,"aria-label":`Cloud provider`,children:tD.filter(e=>e.id!==`local`).map(e=>(0,V.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":i===e.id,className:i===e.id?`btn-primary`:`btn-secondary`,onClick:()=>I(e.id),disabled:g.busy||M(e.id),title:M(e.id)?j?.detail??void 0:void 0,children:e.title},e.id))}),(0,V.jsx)(JE,{provider:i,limit:3}),O?(0,V.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,V.jsx)(`p`,{className:`setup-hint`,children:`The key goes to GAIA’s local model server and your OS credential store, nowhere else.`}),(0,V.jsxs)(`div`,{className:`setup-row`,children:[!O&&(0,V.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,V.jsxs)(`button`,{type:`submit`,className:`btn-primary`,disabled:g.busy,children:[g.busy&&(0,V.jsx)(R,{size:13,className:`spin`}),` Connect`]})]}),g.busy&&g.waiting&&(0,V.jsx)(`p`,{className:`setup-hint`,role:`status`,children:g.waiting}),g.error&&(0,V.jsx)(`p`,{className:`setup-error`,role:`alert`,children:g.error})]})]})]}),u&&u.log_tail&&u.log_tail.length>0&&(0,V.jsxs)(`div`,{className:`setup-log`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`setup-log-toggle`,onClick:()=>y(e=>!e),"aria-expanded":v,children:[(0,V.jsx)(F,{size:13,className:v?`is-open`:``,"aria-hidden":`true`}),` Details`]}),v&&(0,V.jsx)(`pre`,{className:`setup-log-pre`,children:u.log_tail.join(`
|
|
77
|
-
`)})]}),he&&(0,V.jsxs)(`div`,{className:`setup-done`,role:`status`,children:[(0,V.jsxs)(`div`,{className:`setup-done-head`,children:[(0,V.jsxs)(`p`,{children:[`GAIA is ready.`,_e&&(0,V.jsxs)(V.Fragment,{children:[` `,(0,V.jsx)(`strong`,{children:_s(_e)}),` answers`,N?` in the cloud`:` on this PC`,`.`]})]}),(0,V.jsx)(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void L(),autoFocus:!0,children:`Start chatting`})]}),E.length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`setup-hint`,children:`Or start with one of these:`}),(0,V.jsx)(NE,{cards:E,onPick:e=>void L(e)})]})]})]})})}var fD=pc()?`menu bar`:`tray`,pD=[{key:`minimizeToTray`,label:`Keep running when the window closes`,hint:`GAIA stays in the ${fD} with your model loaded. Quit from the ${fD} 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 ${fD}`,hint:`GAIA opens without its window. Use the ${fD} icon to show it.`}];function mD(){let e=window.gaiaAPI?.tray,[t,n]=(0,z.useState)(null),[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(null);(0,z.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,z.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,V.jsxs)(`div`,{className:`settings-field`,role:`group`,"aria-labelledby":`desktop-app-label`,children:[(0,V.jsx)(`span`,{className:`settings-label`,id:`desktop-app-label`,children:`Desktop app`}),pD.map(({key:e,label:n,hint:r})=>(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`label`,{className:`setting-row`,children:[(0,V.jsx)(`span`,{children:n}),(0,V.jsxs)(`span`,{className:`toggle-switch`,children:[(0,V.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,V.jsx)(`span`,{className:`toggle-track`})]})]}),(0,V.jsx)(`p`,{className:`settings-hint`,id:`desktop-${e}-hint`,children:r})]},e)),r&&(0,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r})]}):null}function hD(){return window.gaiaUpdater}var gD={status:`idle`,version:null,progress:0,releaseNotes:null,error:null,currentVersion:null,pinnedVersion:null,autoUpdate:!1,includePrereleases:!1};function _D(){let[e,t]=(0,z.useState)({...gD});return(0,z.useEffect)(()=>{let e=hD();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 vD(){return window.gaiaUpdater}function yD({onClose:e}){let[t,n]=(0,z.useState)({kind:`loading`}),r=(0,z.useRef)(null);(0,z.useEffect)(()=>{let e=vD();e?e.listReleases().then(e=>{n(Array.isArray(e)?{kind:`list`,releases:e}:{kind:`error`,message:e.error})}).catch(()=>{n({kind:`error`,message:`Couldn't reach GitHub to list releases — check your connection; you can still download installers from the Releases page.`})}):n({kind:`error`,message:`Couldn't reach GitHub to list releases — check your connection; you can still download installers from the Releases page.`})},[]),ei(!0,e),fx(r,!0),(0,z.useEffect)(()=>{let e=r.current;e&&e.querySelector(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)?.focus()},[]),(0,z.useEffect)(()=>{let e=r.current;if(!e)return;function t(t){if(t.key!==`Tab`||!e)return;let n=e.querySelectorAll(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);if(n.length===0)return;let r=n[0],i=n[n.length-1];t.shiftKey?document.activeElement===r&&(t.preventDefault(),i?.focus()):document.activeElement===i&&(t.preventDefault(),r?.focus())}return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[]);function i(e,t){e.isCurrent||n({kind:`confirm`,release:e,releases:t})}async function a(t){n({kind:`installing`});let r=vD();if(!r)n({kind:`error`,message:`Bridge unavailable — please restart the app.`});else try{await r.installVersion(t.tag),e()}catch(e){let t=e instanceof Error?e.message:String(e);n({kind:`error`,message:`Failed to install that version: ${t}`})}}function o(e){if(!e)return``;try{return new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}catch{return e}}return(0,V.jsx)(`div`,{className:`version-picker-overlay`,onClick:t=>{t.target===t.currentTarget&&e()},children:(0,V.jsxs)(`div`,{className:`version-picker-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Install a specific version`,ref:r,children:[(0,V.jsxs)(`div`,{className:`version-picker-header`,children:[(0,V.jsx)(`h3`,{children:`Install a specific version`}),(0,V.jsx)(`button`,{className:`version-picker-close`,onClick:e,"aria-label":`Close`,type:`button`,children:`×`})]}),(0,V.jsxs)(`div`,{className:`version-picker-body`,children:[t.kind===`loading`&&(0,V.jsxs)(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[(0,V.jsx)(`span`,{className:`version-picker-spinner`}),`Loading releases…`]}),t.kind===`error`&&(0,V.jsxs)(`div`,{className:`version-picker-error`,children:[(0,V.jsx)(`p`,{children:t.message}),(0,V.jsx)(`p`,{children:(0,V.jsx)(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:`Browse releases on GitHub`})})]}),t.kind===`list`&&(0,V.jsx)(`ul`,{className:`version-picker-list`,role:`listbox`,"aria-label":`Available releases`,children:t.releases.map(e=>(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,className:`version-picker-row`,"data-version":e.version,"aria-label":`${e.version}${e.isCurrent?` — installed`:``}${e.isPinned?` — pinned`:``}`,"aria-disabled":e.isCurrent?`true`:`false`,onClick:()=>i(e,t.releases),disabled:e.isCurrent,children:[(0,V.jsx)(`span`,{className:`vp-version`,children:e.version}),(0,V.jsx)(`span`,{className:`vp-date`,children:o(e.date)}),e.isCurrent&&(0,V.jsx)(`span`,{className:`vp-badge vp-badge-current`,children:`Installed`}),e.isPinned&&!e.isCurrent&&(0,V.jsx)(`span`,{className:`vp-badge vp-badge-pinned`,children:`Pinned`}),!e.isCurrent&&(0,V.jsx)(`span`,{className:`vp-arrow`,"aria-hidden":`true`,children:`›`})]})},e.tag))}),t.kind===`list`&&(0,V.jsxs)(`p`,{className:`version-picker-more`,children:[`Showing the `,t.releases.length,` most recent.`,` `,(0,V.jsx)(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:`Browse all releases on GitHub`})]}),t.kind===`confirm`&&(0,V.jsxs)(`div`,{className:`version-picker-confirm`,children:[(0,V.jsxs)(`p`,{children:[`This will `,(0,V.jsxs)(`strong`,{children:[`install v`,t.release.version]}),` and restart the app.`]}),(0,V.jsxs)(`p`,{className:`vp-confirm-note`,children:[`GAIA will stay on v`,t.release.version,`: updates are paused until you unpin it in Settings → Updates.`]}),(0,V.jsxs)(`div`,{className:`vp-confirm-actions`,children:[(0,V.jsx)(`button`,{type:`button`,className:`vp-btn-cancel`,onClick:()=>n({kind:`list`,releases:t.releases}),children:`Back`}),(0,V.jsx)(`button`,{type:`button`,className:`vp-btn-confirm`,onClick:()=>a(t.release),children:`Install & restart`})]})]}),t.kind===`installing`&&(0,V.jsxs)(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[(0,V.jsx)(`span`,{className:`version-picker-spinner`}),`Starting download…`]})]})]})})}var bD=`Install updates automatically`,xD=`Include release candidates`;function SD(e){return/^\d+\.\d+\.\d+-/.test(e??``)}function CD(e){switch(e.status){case`checking`:return`Checking for updates…`;case`available`:return`GAIA ${e.version??``} is available.`;case`downloading`:return`Downloading GAIA ${e.version??``}… ${e.progress}%`;case`downloaded`:return`GAIA ${e.version??``} is ready — restart to finish installing.`;case`error`:return`Update check failed: ${e.error??`unknown error`}`;case`no-channel`:return e.error??`No GAIA release publishes a desktop update for this platform yet.`;case`disabled`:return`Updates are turned off for this install (GAIA_DISABLE_UPDATE=1).`;default:return`GAIA is up to date.`}}function wD(){let e=_D(),t=hD(),[n,r]=(0,z.useState)(!1),[i,a]=(0,z.useState)(null),[o,c]=(0,z.useState)(!1);if(!t)return null;async function l(e,n){if(t){r(!0),a(null);try{await n(t)}catch(t){s.system.error(`${e} failed`,t),a(`${e} failed: ${t instanceof Error?t.message:String(t)}`)}finally{r(!1)}}}let u=e.status===`disabled`,d=n||e.status===`checking`||e.status===`downloading`;return(0,V.jsxs)(`div`,{className:`settings-field`,role:`group`,"aria-labelledby":`updates-label`,children:[(0,V.jsx)(`span`,{className:`settings-label`,id:`updates-label`,children:`Updates`}),(0,V.jsxs)(`p`,{className:`settings-hint`,role:`status`,children:[`Running GAIA `,e.currentVersion??`unknown`,`. `,CD(e)]}),(0,V.jsxs)(`label`,{className:`setting-row`,children:[(0,V.jsx)(`span`,{children:bD}),(0,V.jsxs)(`span`,{className:`toggle-switch`,children:[(0,V.jsx)(`input`,{type:`checkbox`,role:`switch`,checked:e.autoUpdate,"aria-describedby":`updates-auto-hint`,"aria-label":bD,"aria-busy":n,disabled:u,onChange:()=>{n||l(`Saving the auto-update setting`,t=>t.setAutoUpdate(!e.autoUpdate))}}),(0,V.jsx)(`span`,{className:`toggle-track`})]})]}),(0,V.jsx)(`p`,{className:`settings-hint`,id:`updates-auto-hint`,children:`Off by default while GAIA is changing quickly — you choose when to update. The Terminal UI follows the same setting.`}),(0,V.jsxs)(`label`,{className:`setting-row`,children:[(0,V.jsx)(`span`,{children:xD}),(0,V.jsxs)(`span`,{className:`toggle-switch`,children:[(0,V.jsx)(`input`,{type:`checkbox`,role:`switch`,checked:!!e.includePrereleases,"aria-describedby":`updates-rc-hint`,"aria-label":xD,"aria-busy":n,disabled:u,onChange:()=>{n||l(`Saving the release-candidate setting`,t=>t.setIncludePrereleases(!e.includePrereleases))}}),(0,V.jsx)(`span`,{className:`toggle-track`})]})]}),(0,V.jsxs)(`p`,{className:`settings-hint`,id:`updates-rc-hint`,children:[`Also offer test builds (vX.Y.Z-rcN) before they become a final release. Off by default.`,SD(e.currentVersion)&&` This is a release candidate, so newer ones are offered either way.`]}),e.pinnedVersion&&(0,V.jsxs)(`p`,{className:`settings-hint`,children:[`Pinned to `,e.pinnedVersion,`, so updates are paused.`,` `,(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:n,onClick:()=>void l(`Resuming updates`,e=>e.resumeUpdates()),children:`Unpin`})]}),(0,V.jsxs)(`div`,{className:`setting-actions`,children:[e.status===`available`&&!e.pinnedVersion&&(0,V.jsxs)(`button`,{type:`button`,className:`btn-primary`,disabled:n,onClick:()=>void l(`Downloading the update`,e=>e.downloadUpdate()),children:[`Update to `,e.version]}),e.status===`downloaded`&&(0,V.jsx)(`button`,{type:`button`,className:`btn-primary`,disabled:n,onClick:()=>void l(`Restarting to install`,e=>e.restart()),children:`Restart to install`}),(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:d||u,onClick:()=>void l(`Checking for updates`,e=>e.check()),children:`Check for updates`}),(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:d||u,onClick:()=>c(!0),children:`Install a specific version…`})]}),e.configError&&(0,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:e.configError}),i&&(0,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:i}),o&&(0,V.jsx)(yD,{onClose:()=>c(!1)})]})}var TD=[{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`system`,label:`Match system`}],ED=[[`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 DD(){let e=B(e=>e.themePreference),t=B(e=>e.setThemePreference),n=B(e=>e.palette),r=B(e=>e.setPalette),i=B(e=>e.customColors),a=B(e=>e.setCustomColors),o=e=>t=>a({...i,[e]:t.target.value.toUpperCase()});return(0,V.jsxs)(`div`,{className:`settings-pane`,children:[(0,V.jsx)(`h2`,{className:`settings-pane-title`,children:`General`}),(0,V.jsxs)(`div`,{className:`settings-field`,children:[(0,V.jsx)(`span`,{className:`settings-label`,id:`appearance-label`,children:`Appearance`}),(0,V.jsx)(`div`,{className:`segmented`,role:`radiogroup`,"aria-labelledby":`appearance-label`,children:TD.map(n=>(0,V.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,V.jsx)(mD,{}),(0,V.jsx)(wD,{}),(0,V.jsxs)(`div`,{className:`settings-field`,children:[(0,V.jsx)(`span`,{className:`settings-label`,id:`palette-label`,children:`Colors`}),(0,V.jsxs)(`div`,{className:`palette-grid`,role:`radiogroup`,"aria-labelledby":`palette-label`,children:[or.map(e=>(0,V.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,V.jsx)(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:e.swatch.map(e=>(0,V.jsx)(`i`,{style:{background:e}},e))}),e.name]},e.id)),(0,V.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":n===`custom`,className:`palette-tile${n===`custom`?` is-active`:``}`,onClick:()=>r(`custom`),children:[(0,V.jsxs)(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:[(0,V.jsx)(`i`,{style:{background:i.base}}),(0,V.jsx)(`i`,{style:{background:i.accent}})]}),`Custom`]})]}),n===`custom`&&(0,V.jsxs)(`div`,{className:`palette-custom`,children:[(0,V.jsxs)(`label`,{className:`palette-color`,htmlFor:`custom-accent`,children:[(0,V.jsx)(`input`,{id:`custom-accent`,type:`color`,value:i.accent,onChange:o(`accent`)}),(0,V.jsxs)(`span`,{children:[`Accent`,(0,V.jsx)(`small`,{children:`Buttons, links and focus`})]})]}),(0,V.jsxs)(`label`,{className:`palette-color`,htmlFor:`custom-base`,children:[(0,V.jsx)(`input`,{id:`custom-base`,type:`color`,value:i.base,onChange:o(`base`)}),(0,V.jsxs)(`span`,{children:[`Background tint`,(0,V.jsx)(`small`,{children:`The color the grays lean toward`})]})]}),(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>a(cr),children:`Reset`}),(0,V.jsx)(`p`,{className:`settings-hint`,children:`Text colors adjust on their own so everything stays readable in light and dark.`})]})]}),(0,V.jsxs)(`div`,{className:`settings-field`,children:[(0,V.jsx)(`span`,{className:`settings-label`,children:`Keyboard shortcuts`}),(0,V.jsx)(`dl`,{className:`shortcut-list`,children:ED.map(([e,t])=>(0,V.jsxs)(`div`,{className:`shortcut-row`,children:[(0,V.jsx)(`dt`,{children:(0,V.jsx)(`kbd`,{children:_c(e)})}),(0,V.jsx)(`dd`,{children:t})]},e))})]})]})}var OD=`auto`;function kD({model:e}){let[t,n]=(0,z.useState)(null),[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(!1),[s,c]=(0,z.useState)(null);(0,z.useEffect)(()=>{n(null),i(null),c(null),wa(e).then(n).catch(e=>i(e instanceof Error?e.message:String(e)))},[e]);let l=(0,z.useCallback)(async t=>{o(!0),i(null),c(null);try{let r=await Ta(e,t===OD?null:Number(t));n(r);let i=r.chosen?Ss(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,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r});if(!t)return(0,V.jsxs)(`p`,{className:`settings-hint`,children:[(0,V.jsx)(R,{size:13,className:`spin`}),` Checking context sizes…`]});let u=t.chosen==null?OD:String(t.chosen),d=t.chosen!=null&&t.loaded_ctx!=null&&t.loaded_ctx!==t.chosen;return(0,V.jsxs)(`div`,{className:`settings-field`,children:[(0,V.jsx)(`label`,{className:`settings-label`,htmlFor:`ctx-size`,children:`Context size`}),(0,V.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,V.jsxs)(`option`,{value:OD,children:[`Automatic`,t.automatic?` (${Ss(t.automatic)})`:``]}),t.options.map(e=>(0,V.jsxs)(`option`,{value:String(e),children:[Ss(e),` tokens`]},e))]}),(0,V.jsxs)(`span`,{className:`settings-hint`,children:[t.note??(t.max_fit?`Up to ${Ss(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 ${Ss(t.loaded_ctx)}.`]}),a&&(0,V.jsxs)(`span`,{className:`settings-hint`,children:[(0,V.jsx)(R,{size:13,className:`spin`}),` Applying…`]}),s&&(0,V.jsx)(`p`,{className:`settings-ok`,role:`status`,children:s}),r&&(0,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r})]})}function AD(){let[e,t]=(0,z.useState)(null),[n,r]=(0,z.useState)(null),[i,a]=(0,z.useState)(``),[o,s]=(0,z.useState)(!1),c=(0,z.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,z.useEffect)(()=>{c(Aa)},[c]),!e)return n?(0,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:n}):(0,V.jsxs)(`p`,{className:`settings-hint`,children:[(0,V.jsx)(R,{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,V.jsxs)(`section`,{className:`settings-field spending`,"aria-label":`Cloud spending`,children:[(0,V.jsx)(`span`,{className:`settings-label`,children:`Cloud spending this month`}),(0,V.jsxs)(`p`,{className:`spending-total`,children:[(0,V.jsx)(`strong`,{children:iC(e.total_usd)}),l!=null&&(0,V.jsxs)(V.Fragment,{children:[` of your `,iC(l),` limit`]}),(0,V.jsxs)(`span`,{className:`settings-hint`,children:[` · `,e.turns,` cloud `,e.turns===1?`chat turn`:`chat turns`,`, at list price`]})]}),e.unpriced_turns>0&&(0,V.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,V.jsxs)(`p`,{className:`spending-warning`,role:`status`,children:[(0,V.jsx)(An,{size:13,"aria-hidden":`true`}),` Close to your limit. GAIA stops before a cloud chat once it’s reached.`]}),e.state===`reached`&&(0,V.jsxs)(`div`,{className:`spending-warning`,role:`alert`,children:[(0,V.jsxs)(`p`,{children:[(0,V.jsx)(An,{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,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:o,onClick:()=>void c(Ma),children:`Allow more this month`})]}),e.state===`allowed_over`&&(0,V.jsx)(`p`,{className:`settings-hint`,children:`Over your limit; you allowed more for this month.`}),(0,V.jsxs)(`form`,{className:`settings-row`,onSubmit:e=>{e.preventDefault(),d&&f&&c(()=>ja(u))},children:[(0,V.jsx)(`label`,{className:`spending-limit-label`,htmlFor:`spend-limit`,children:`Monthly limit ($)`}),(0,V.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,V.jsxs)(`button`,{type:`submit`,className:`btn-secondary`,disabled:o||!d||!f,children:[o?(0,V.jsx)(R,{size:13,className:`spin`}):null,` Save`]}),l!=null&&(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:o,onClick:()=>void c(()=>ja(null)),children:`Remove limit`})]}),(0,V.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,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:n})]})}var jD=2e3;function MD(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 ND(e){return e.key_source===`environment`?`Blank uses the environment key`:e.key_source?`Blank keeps the saved key`:`Paste API key`}function PD(){let e=cs(e=>e.active),t=cs(e=>e.select),n=cs(e=>e.refresh),r=cs(e=>e.rememberNames),[i,a]=(0,z.useState)(null),[o,s]=(0,z.useState)(null),c=B(e=>e.settingsProvider),[l,u]=(0,z.useState)(c??e?.provider??`local`),[d,f]=(0,z.useState)(null),[p,m]=(0,z.useState)(null),[h,g]=(0,z.useState)(``),[_,v]=(0,z.useState)(!1),[y,b]=(0,z.useState)(``),[x,S]=(0,z.useState)({base_url:``,auth_header_name:``,auth_header_prefix:``}),[C,w]=(0,z.useState)(null),[T,E]=(0,z.useState)(null),[D,O]=(0,z.useState)(null),k=(0,z.useRef)(l);k.current=l;let ee=(0,z.useRef)(!0);(0,z.useEffect)(()=>()=>{ee.current=!1},[]);let A=i?.find(e=>e.id===l)??null,j=e=>e?.network?.reachable===!1,te=!!A&&(!A.remote||!!A.models_discovered),M=(0,z.useCallback)(async()=>{s(null);try{let e=await _a();a(e.providers),e.lemonade_error&&s(e.lemonade_error)}catch(e){s(e instanceof Error?e.message:String(e))}},[]),N=(0,z.useCallback)(async(e,t=!1)=>{t||(f(null),m(null));try{let t=await Ca(e);r(t.models),f(t.models),E(t.memory_gb?`${t.memory_gb} GB (${t.memory_source})`:t.capacity_error??null)}catch(e){m(e instanceof Error?e.message:String(e))}},[r]);(0,z.useEffect)(()=>{M()},[M]);let ne=!!i?.some(e=>e.key_state===`waiting_for_os_permission`);(0,z.useEffect)(()=>{if(!ne)return;let e=setInterval(()=>{M()},jD);return()=>clearInterval(e)},[ne,M]);let re=e?.provider;(0,z.useEffect)(()=>{re&&!c&&u(re)},[re,c]),(0,z.useEffect)(()=>{b(``),O(null),g(``),v(!1)},[l]),(0,z.useEffect)(()=>{te?N(l):f(null)},[l,te,N]);let ie=(0,z.useCallback)(async()=>{if(A){w(`connect`),O(null);try{let e=l===`amd`?{api_key:y||void 0,...Object.fromEntries(Object.entries(x).filter(([,e])=>e!==``))}:{api_key:y||void 0},t=()=>!ee.current||k.current!==l,n=await xa(l,e,e=>{t()||O({ok:!0,text:e})},t);if(t())return;b(``),O({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 M()}catch(e){ee.current&&k.current===l&&O({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{ee.current&&w(null)}}},[x,l,y,M,A]),F=(0,z.useCallback)(async()=>{w(`forget`),O(null);try{await Sa(l),O({ok:!0,text:`Key cleared, here and for future sessions. An environment key, if set, stays active.`}),await M(),await n()}catch(e){O({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{w(null)}},[l,M,n]),ae=(0,z.useCallback)(async e=>{w(e),O(null);try{await t(e),O({ok:!0,text:`New messages use ${us(e)}. It is remembered across restarts.`})}catch(e){O({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{w(null)}},[t]),oe=(0,z.useCallback)(async e=>{w(`dl:${e}`),O(null);try{await ra(e),await N(`local`,!0)}catch(e){O({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{w(null)}},[N]),se=!!d?.some(ws);(0,z.useEffect)(()=>{if(l!==`local`||!se)return;let e=setInterval(()=>{N(`local`,!0)},jD);return()=>clearInterval(e)},[se,l,N]);let ce=(0,z.useMemo)(()=>{let e=h.trim().toLowerCase();return(d??[]).filter(t=>!e||t.id.toLowerCase().includes(e)||(t.display_name??``).toLowerCase().includes(e))},[d,h]),le=ce.filter(e=>e.available!==!1),ue=l===`fireworks`&&!_&&!h.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),I=vs(d??[]),L=e&&!e.remote&&e.model?e.model:null,he=t=>{let n=e?.model===t.id,r=ws(t)?t.download_progress:null,i=[xs(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,V.jsxs)(`li`,{className:`model-row${n?` is-current`:``}`,children:[(0,V.jsxs)(`div`,{className:`model-row-text`,children:[(0,V.jsxs)(`span`,{className:`model-row-name`,title:t.id,children:[I[t.id],t.rank&&(0,V.jsxs)(`span`,{className:`model-row-rank`,children:[`#`,t.rank,` `,t.note]}),t.state===`loaded`&&(0,V.jsx)(`span`,{className:`model-badge is-loaded`,children:bs.loaded}),t.fits===!0&&t.available!==!1&&(0,V.jsx)(`span`,{className:`model-badge is-fit`,children:`Fits this PC`})]}),A?.remote&&(0,V.jsx)(`span`,{className:`model-row-meta${t.price?``:` is-unknown-price`}`,children:rC(t.price)}),t.display_name&&(0,V.jsx)(`span`,{className:`model-row-meta`,children:t.id}),i&&(0,V.jsx)(`span`,{className:`model-row-meta`,children:i}),t.placement?.warning&&(0,V.jsx)(`span`,{className:`model-row-meta is-warning`,role:`alert`,children:t.placement.warning}),t.unavailable_reason&&(0,V.jsxs)(`span`,{className:`model-row-meta`,children:[`Can't run here: `,t.unavailable_reason]}),t.evidence&&(0,V.jsxs)(`span`,{className:`model-row-meta`,children:[`Measured: `,t.evidence]}),r&&(0,V.jsx)(`progress`,{max:100,value:r.percent,"aria-label":`Downloading ${I[t.id]}`})]}),n?(0,V.jsxs)(`span`,{className:`model-row-current`,children:[(0,V.jsx)(P,{size:13,"aria-hidden":`true`}),` In use`]}):t.available===!1?null:r?(0,V.jsxs)(`span`,{className:`model-row-current`,children:[(0,V.jsx)(R,{size:13,className:`spin`}),` `,Math.round(r.percent),`%`]}):t.downloaded?(0,V.jsxs)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void ae(t.id),disabled:C!==null,"aria-label":`Use ${I[t.id]}`,children:[C===t.id?(0,V.jsx)(R,{size:13,className:`spin`}):null,` Use`]}):(0,V.jsxs)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void oe(t.id),disabled:C!==null,"aria-label":`Download ${I[t.id]}`,children:[C===`dl:${t.id}`?(0,V.jsx)(R,{size:13,className:`spin`}):null,` Download`]})]},t.id)};return(0,V.jsxs)(`div`,{className:`settings-pane`,children:[(0,V.jsx)(`h2`,{className:`settings-pane-title`,children:`Model`}),(0,V.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,V.jsx)(`div`,{className:`provider-tabs`,role:`radiogroup`,"aria-label":`Where GAIA runs`,children:(i??[{id:`local`,name:`Local`,remote:!1}]).map(e=>(0,V.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":l===e.id,className:`provider-tab${l===e.id?` is-active`:``}${j(e)?` is-disabled`:``}`,onClick:()=>u(e.id),disabled:j(e)&&l!==e.id,title:j(e)?e.network?.detail??void 0:void 0,children:[e.remote?(0,V.jsx)(ve,{size:14,"aria-hidden":`true`}):(0,V.jsx)(Ee,{size:14,"aria-hidden":`true`}),(0,V.jsx)(`span`,{children:e.name}),e.remote&&e.models_discovered&&(0,V.jsx)(`span`,{className:`provider-tab-dot`,"aria-label":`connected`})]},e.id))}),o&&(0,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:o}),A&&(0,V.jsxs)(`section`,{className:`settings-card`,"aria-label":A.name,children:[(0,V.jsx)(`p`,{className:`settings-note`,children:A.privacy_notice}),A.id===`local`&&(0,V.jsxs)(`p`,{className:`settings-hint`,children:[`Each model runs where it was built to: GGUF models on the GPU, FLM models on the NPU.`,T&&` Memory for models: ${T}.`]}),A.remote&&!te&&(0,V.jsxs)(`div`,{className:`settings-field`,children:[(0,V.jsx)(`span`,{className:`settings-label`,children:`Prices`}),(0,V.jsx)(JE,{provider:A.id})]}),j(A)&&(0,V.jsxs)(`div`,{className:`settings-field`,children:[(0,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:A.network?.detail}),(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void M(),children:`Check again`})]}),A.remote&&!j(A)&&(0,V.jsxs)(`form`,{className:`settings-field`,onSubmit:e=>{e.preventDefault(),ie()},children:[(0,V.jsx)(`span`,{className:`settings-label`,children:`API key`}),(0,V.jsx)(`span`,{className:`settings-hint`,children:MD(A)}),A.id===`amd`&&(0,V.jsxs)(`div`,{className:`settings-grid`,children:[(0,V.jsx)(`input`,{className:`settings-input`,placeholder:`Gateway URL (default https://llm-api.amd.com/Unified/v1)`,value:x.base_url,onChange:e=>S({...x,base_url:e.target.value}),"aria-label":`Gateway URL`}),(0,V.jsx)(`input`,{className:`settings-input`,placeholder:`Auth header (default Ocp-Apim-Subscription-Key)`,value:x.auth_header_name,onChange:e=>S({...x,auth_header_name:e.target.value}),"aria-label":`Auth header name`})]}),(0,V.jsxs)(`div`,{className:`settings-row`,children:[(0,V.jsx)(`input`,{className:`settings-input`,type:`password`,autoComplete:`off`,spellCheck:!1,value:y,onChange:e=>b(e.target.value),placeholder:ND(A),"aria-label":`${A.name} API key`}),(0,V.jsxs)(`button`,{type:`submit`,className:`btn-primary`,disabled:C!==null||!y&&!A.key_source,children:[C===`connect`?(0,V.jsx)(R,{size:13,className:`spin`}):null,A.models_discovered?`Reconnect`:`Connect`]}),(A.key_source===`lemonade`||A.key_source===`stored`)&&(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void F(),disabled:C!==null,children:`Forget key`})]}),A.error&&(0,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:A.error})]}),D&&(0,V.jsx)(`p`,{className:D.ok?`settings-ok`:`settings-error`,role:D.ok?`status`:`alert`,children:D.text}),A.id===`local`&&L&&e?.downloaded!==!1&&(0,V.jsx)(kD,{model:L}),te&&(0,V.jsxs)(`div`,{className:`settings-field`,children:[(0,V.jsx)(`span`,{className:`settings-label`,children:`Models`}),(d?.length??0)>6&&(0,V.jsx)(`input`,{className:`settings-input`,type:`search`,value:h,onChange:e=>g(e.target.value),placeholder:`Search models`,"aria-label":`Search models`}),p&&(0,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:p}),!d&&!p&&(0,V.jsxs)(`p`,{className:`settings-hint`,children:[(0,V.jsx)(R,{size:13,className:`spin`}),` Loading…`]}),d&&ce.length===0&&(0,V.jsx)(`p`,{className:`settings-hint`,children:`No models match.`}),(0,V.jsx)(`ul`,{className:`model-list`,children:fe.map(he)}),ue&&pe.length>0&&(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>v(!0),children:`Show all models`}),l===`fireworks`&&_&&!h.trim()&&(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>v(!1),children:`Show recommended models`}),me.length>0&&(0,V.jsxs)(`details`,{className:`model-unavailable`,children:[(0,V.jsxs)(`summary`,{children:[`Not available on this PC (`,me.length,`)`]}),(0,V.jsx)(`ul`,{className:`model-list`,children:me.map(he)})]})]}),A.remote&&(0,V.jsx)(AD,{})]})]})}function FD(){let e=B(e=>e.sessions),[t,n]=(0,z.useState)(null),[r,i]=(0,z.useState)(null),a=(0,z.useCallback)(async()=>{i(null);try{n((await Fi()).sessions)}catch(e){i(e instanceof Error?e.message:String(e))}},[]);(0,z.useEffect)(()=>{a()},[a]);let o=(0,z.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,V.jsxs)(`div`,{className:`settings-pane`,children:[(0,V.jsx)(`h2`,{className:`settings-pane-title`,children:`Permissions`}),(0,V.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,V.jsxs)(`p`,{className:`settings-hint`,children:[`New chats start in full access only when `,(0,V.jsx)(`code`,{children:`full_access`}),` is set in`,(0,V.jsx)(`code`,{children:` ~/.gaia/config.json`}),` (the TUI’s `,(0,V.jsx)(`code`,{children:`/full-access always`}),`).`]}),r&&(0,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r}),t&&t.length===0&&(0,V.jsx)(`p`,{className:`settings-hint`,children:`No chat has full access or anything allowed without asking.`}),t?.map(e=>(0,V.jsxs)(`section`,{className:`settings-card`,"aria-label":s(e.session_id),children:[(0,V.jsxs)(`div`,{className:`settings-row settings-row-between`,children:[(0,V.jsx)(`span`,{className:`settings-label`,children:s(e.session_id)}),e.mode===`full_access`&&(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>o(async()=>{let t=(await Ii(e.session_id,`ask`)).mode;fC(e.session_id,t)}),children:`Turn off full access`})]}),e.grants.length>0&&(0,V.jsx)(`ul`,{className:`grant-list`,children:e.grants.map(t=>(0,V.jsxs)(`li`,{className:`grant-row`,children:[(0,V.jsx)(`code`,{children:t.label}),(0,V.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>o(()=>Li(e.session_id,t.key)),"aria-label":`Revoke ${t.label}`,children:`Revoke`})]},t.key))}),e.grants.length>1&&(0,V.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>o(()=>Li(e.session_id)),children:`Revoke all in this chat`})]},e.session_id))]})}var ID=[{source:`agent-bundled`,title:`Built into GAIA`,note:`Ship with GAIA.`},{source:`user`,title:`Yours`,note:`From your ~/.gaia/skills folder.`,empty:`None yet. Add a folder with a SKILL.md file to ~/.gaia/skills and reopen this page.`},{source:`claude-import`,title:`From Claude Code`,note:`Found in your Claude Code skill folders. GAIA reads them in place and does not change them.`}];function LD({onUseSkill:e}){let[t,n]=(0,z.useState)(null),[r,i]=(0,z.useState)({}),[a,o]=(0,z.useState)(null),[s,c]=(0,z.useState)(``);(0,z.useEffect)(()=>{let e=!1;return Na().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)),d=t?.every(e=>e.source)??!1,f=t=>(0,V.jsxs)(`li`,{className:`skill-row`,children:[(0,V.jsxs)(`div`,{className:`skill-row-text`,children:[(0,V.jsxs)(`span`,{className:`skill-row-name`,children:[t.name,t.version&&(0,V.jsxs)(`span`,{className:`skill-row-meta`,children:[` v`,t.version]}),t.always_on&&(0,V.jsx)(`span`,{className:`skill-row-meta`,children:` · Always on`})]}),(0,V.jsx)(`span`,{className:`skill-row-desc`,children:t.description})]}),!t.always_on&&(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>e(t.name),"aria-label":`Use ${t.name} in a new chat`,children:`Use`})]},t.name);return(0,V.jsxs)(`div`,{className:`settings-pane`,children:[(0,V.jsx)(`h2`,{className:`settings-pane-title`,children:`Skills`}),(0,V.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. Your own skills go in `,(0,V.jsx)(`code`,{children:`~/.gaia/skills`}),`, one folder each with a `,(0,V.jsx)(`code`,{children:`SKILL.md`}),` file.`]}),a&&(0,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:a}),!t&&!a&&(0,V.jsxs)(`p`,{className:`settings-hint`,children:[(0,V.jsx)(R,{size:13,className:`spin`}),` Loading…`]}),t&&t.length>6&&(0,V.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,V.jsx)(`p`,{className:`settings-hint`,children:`No skills are installed.`}),d?ID.map(e=>{let n=u.filter(t=>t.source===e.source),r=(t??[]).filter(t=>t.source===e.source).length;return n.length===0&&(l||!e.empty)?null:(0,V.jsxs)(`section`,{className:`skill-group`,"aria-label":e.title,children:[(0,V.jsxs)(`h3`,{className:`skill-group-title`,children:[e.title,` `,(0,V.jsx)(`span`,{className:`skill-row-meta`,children:r})]}),(0,V.jsx)(`p`,{className:`settings-hint`,children:e.note}),n.length===0?(0,V.jsx)(`p`,{className:`settings-hint`,children:e.empty}):(0,V.jsx)(`ul`,{className:`skill-list`,children:n.map(f)})]},e.source)}):(0,V.jsx)(`ul`,{className:`skill-list`,children:u.map(f)}),Object.keys(r).length>0&&(0,V.jsxs)(`div`,{className:`settings-card`,role:`alert`,children:[(0,V.jsx)(`span`,{className:`settings-label`,children:`Skipped, could not be read`}),(0,V.jsx)(`ul`,{className:`grant-list`,children:Object.entries(r).map(([e,t])=>(0,V.jsxs)(`li`,{children:[(0,V.jsx)(`code`,{children:e}),` — `,t]},e))})]})]})}function RD(){let e=B(e=>e.setShowMemoryDashboard),t=B(e=>e.closeSettings),[n,r]=(0,z.useState)(null),[i,a]=(0,z.useState)(null),[o,s]=(0,z.useState)(!1);(0,z.useEffect)(()=>{xE().then(r).catch(e=>a(e instanceof Error?e.message:String(e)))},[]);let c=(0,z.useCallback)(async()=>{if(n){s(!0),a(null);try{r(await SE({memory_enabled:!n.memory_enabled}))}catch(e){a(e instanceof Error?e.message:String(e))}finally{s(!1)}}},[n]);return(0,V.jsxs)(`div`,{className:`settings-pane`,children:[(0,V.jsx)(`h2`,{className:`settings-pane-title`,children:`Memory`}),(0,V.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,V.jsxs)(`label`,{className:`setting-row`,children:[(0,V.jsx)(`span`,{children:`Remember across chats`}),(0,V.jsxs)(`span`,{className:`toggle-switch`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:!!n?.memory_enabled,onChange:()=>void c(),disabled:!n||o,"aria-label":`Remember across chats`}),(0,V.jsx)(`span`,{className:`toggle-track`})]})]}),i&&(0,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:i}),(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{t(),e(!0)},children:`Open the memory dashboard`}),(0,V.jsx)(`p`,{className:`settings-hint`,children:`Search, edit and forget what GAIA remembers.`})]})}var zD=`Keep for: enter a whole number of days from 1 to 365.`,BD=`Use at most: enter a whole number of MB from 10 to 100,000.`;function VD(e,t,n){if(!/^\d+$/.test(e.trim()))return!1;let r=Number(e);return r>=t&&r<=n}function HD(e){return e<1048576?`${Math.ceil(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function UD(){let[e,t]=(0,z.useState)(null),[n,r]=(0,z.useState)(``),[i,a]=(0,z.useState)(``),[o,s]=(0,z.useState)(null),[c,l]=(0,z.useState)(!1);(0,z.useEffect)(()=>{W().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,z.useState)({days:!1,mb:!1}),f=!VD(n,1,365)||u.days,p=!VD(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 Bo(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 Hi&&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,V.jsxs)(`div`,{className:`settings-field`,"aria-label":`Undo history`,children:[(0,V.jsx)(`span`,{className:`settings-label`,children:`Undo history`}),(0,V.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,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`setting-row`,children:[(0,V.jsx)(`label`,{htmlFor:`undo-days`,children:`Keep for (days)`}),(0,V.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,V.jsx)(`p`,{id:`undo-days-error`,className:`settings-error`,children:zD}),(0,V.jsxs)(`div`,{className:`setting-row`,children:[(0,V.jsx)(`label`,{htmlFor:`undo-mb`,children:`Use at most (MB)`}),(0,V.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,V.jsx)(`p`,{id:`undo-mb-error`,className:`settings-error`,children:BD}),(0,V.jsxs)(`div`,{className:`setting-row setting-row-path`,children:[(0,V.jsx)(`span`,{children:`In use`}),(0,V.jsxs)(`span`,{children:[HD(e.used_bytes),` for `,e.turns,` turn`,e.turns===1?``:`s`,` `,`in `,(0,V.jsx)(`code`,{className:`setting-path`,children:e.path})]})]}),(0,V.jsx)(`button`,{type:`button`,className:`btn-model-save`,onClick:()=>void h(),disabled:!m||c||f||p,children:c?`Saving…`:`Save`})]}),o&&(0,V.jsx)(`p`,{className:o.ok?`settings-ok`:`settings-error`,role:o.ok?`status`:`alert`,children:o.text})]})}function WD(){let e=B(e=>e.sessions),t=B(e=>e.removeSession),n=ms(),r=B(e=>e.systemStatus?.data_dir),[i,a]=(0,z.useState)(!1),[o,s]=(0,z.useState)(null),c=(0,z.useRef)(null);(0,z.useEffect)(()=>()=>{c.current&&clearTimeout(c.current)},[]);let l=(0,z.useCallback)(async()=>{if(!i){a(!0),c.current=setTimeout(()=>a(!1),4e3);return}a(!1);let n=[];for(let r of e)try{await La(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,V.jsxs)(`div`,{className:`settings-pane`,children:[(0,V.jsx)(`h2`,{className:`settings-pane-title`,children:`Privacy`}),(0,V.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,V.jsxs)(`div`,{className:`setting-row`,children:[(0,V.jsx)(`span`,{children:`Data folder`}),(0,V.jsx)(`code`,{className:`setting-path`,children:r})]}),(0,V.jsx)(UD,{}),(0,V.jsx)(`div`,{className:`danger-divider`}),(0,V.jsx)(`p`,{className:`danger-warning`,children:`Deletes every chat and its messages. Documents and memory are kept.`}),(0,V.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,V.jsx)(`p`,{className:o.ok?`settings-ok`:`settings-error`,role:o.ok?`status`:`alert`,children:o.text})]})}var GD=[{id:`needs_approval`,label:`Needs your approval`},{id:`question`,label:`Has a question`},{id:`finished`,label:`Finished`}],KD=[{value:`banner`,label:`Banner`},{value:`badge`,label:`Badge`},{value:`off`,label:`Off`}],qD=[0,10,20,30,50];function JD(){return typeof Notification>`u`?`unsupported`:Notification.permission}function YD(){let e=Zs(),t=!!window.gaiaAPI,[n,r]=(0,z.useState)(JD),i=Object.values(e.modes).includes(`banner`);return(0,V.jsxs)(`div`,{className:`settings-pane`,children:[(0,V.jsx)(`h2`,{className:`settings-pane-title`,children:`Notifications`}),(0,V.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.`}),GD.map(t=>(0,V.jsxs)(`div`,{className:`setting-row`,children:[(0,V.jsx)(`span`,{id:`alert-${t.id}`,children:t.label}),(0,V.jsx)(`div`,{className:`segmented`,role:`radiogroup`,"aria-labelledby":`alert-${t.id}`,children:KD.map(n=>(0,V.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,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{Notification.requestPermission().then(r).catch(e=>{console.error(`[alerts] Notification permission request failed`,e),r(JD())})},children:`Allow banners in this browser`}):(0,V.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,V.jsxs)(`label`,{className:`setting-row`,children:[(0,V.jsx)(`span`,{children:`Play a sound`}),(0,V.jsxs)(`span`,{className:`toggle-switch`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:e.sound,onChange:()=>e.update({sound:!e.sound}),"aria-label":`Play a sound`}),(0,V.jsx)(`span`,{className:`toggle-track`})]})]}),t&&(0,V.jsxs)(`label`,{className:`setting-row`,children:[(0,V.jsx)(`span`,{children:`Flash the taskbar when GAIA isn't focused`}),(0,V.jsxs)(`span`,{className:`toggle-switch`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:e.flash,onChange:()=>e.update({flash:!e.flash}),"aria-label":`Flash the taskbar when GAIA isn't focused`}),(0,V.jsx)(`span`,{className:`toggle-track`})]})]}),(0,V.jsx)(`h3`,{className:`settings-label`,children:`Keep awake`}),t?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`label`,{className:`setting-row`,children:[(0,V.jsx)(`span`,{children:`Keep the PC awake while GAIA works`}),(0,V.jsxs)(`span`,{className:`toggle-switch`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:e.keepAwake,onChange:()=>e.update({keepAwake:!e.keepAwake}),"aria-label":`Keep the PC awake while GAIA works`}),(0,V.jsx)(`span`,{className:`toggle-track`})]})]}),(0,V.jsxs)(`div`,{className:`setting-row`,children:[(0,V.jsx)(`label`,{htmlFor:`battery-floor`,children:`On battery, let it sleep below`}),(0,V.jsx)(`select`,{id:`battery-floor`,value:e.batteryFloor,disabled:!e.keepAwake,onChange:t=>e.update({batteryFloor:Number(t.target.value)}),children:qD.map(e=>(0,V.jsx)(`option`,{value:e,children:e===0?`Never`:`${e}%`},e))})]}),(0,V.jsx)(`p`,{className:`settings-hint`,children:`The screen can still turn off; only sleep is held off.`})]}):(0,V.jsx)(`p`,{className:`settings-hint`,children:`Keep-awake needs the GAIA desktop app.`})]})}var XD=`modulepreload`,ZD=function(e,t){return new URL(e,t).href},QD={},$D=function(e){return e.pathname.endsWith(`.css`)},eO=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},tO=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=ZD(t,n);let r=s(t),i=$D(r);return eO(QD,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`:XD,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)})},nO=(0,z.lazy)(()=>tO(()=>import(`./ConnectorsPane-DtYVWxBo.js`).then(e=>({default:e.ConnectorsPane})),__vite__mapDeps([0,1,2,3]),import.meta.url)),rO=(0,z.lazy)(()=>tO(()=>import(`./AdvancedSettings-BlYNI6AZ.js`).then(e=>({default:e.AdvancedSettings})),__vite__mapDeps([4,1,2]),import.meta.url)),iO=[{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 aO({onUseSkill:e}){let t=B(e=>e.settingsSection),n=B(e=>e.openSettings),r=B(e=>e.closeSettings),i=(0,z.useRef)(null),a=(0,z.useRef)(null),o=t!==null;if(ei(o,r),fx(i,o),(0,z.useEffect)(()=>{if(o)return a.current=document.activeElement,()=>{a.current?.focus?.()}},[o,r]),(0,z.useEffect)(()=>{o&&i.current?.querySelector(`.settings-nav-item.is-active`)?.focus()},[o]),!t)return null;let s=(()=>{switch(t){case`general`:return(0,V.jsx)(DD,{});case`model`:return(0,V.jsx)(PD,{});case`permissions`:return(0,V.jsx)(FD,{});case`skills`:return(0,V.jsx)(LD,{onUseSkill:t=>{r(),e(t)}});case`connectors`:return(0,V.jsx)(nO,{});case`memory`:return(0,V.jsx)(RD,{});case`notifications`:return(0,V.jsx)(YD,{});case`privacy`:return(0,V.jsx)(WD,{});case`advanced`:return(0,V.jsx)(rO,{})}})();return(0,V.jsx)(`div`,{className:`settings-overlay`,onMouseDown:e=>{e.target===e.currentTarget&&r()},children:(0,V.jsxs)(`div`,{ref:i,className:`settings-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Settings`,children:[(0,V.jsxs)(`nav`,{className:`settings-nav`,"aria-label":`Settings sections`,children:[(0,V.jsx)(`h1`,{className:`settings-nav-title`,children:`Settings`}),iO.map(e=>(0,V.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,V.jsxs)(`div`,{className:`settings-body`,children:[(0,V.jsx)(`button`,{type:`button`,className:`settings-close`,onClick:r,"aria-label":`Close settings`,children:(0,V.jsx)(Bn,{size:18})}),(0,V.jsx)(z.Suspense,{fallback:(0,V.jsxs)(`p`,{className:`settings-hint`,children:[(0,V.jsx)(R,{size:13,className:`spin`}),` Loading…`]}),children:s})]})]})})}function oO(e,t){let[n,r]=(0,z.useState)(!1),[i,a]=(0,z.useState)(!1),o=(0,z.useRef)(null),c=(0,z.useRef)(null),l=(0,z.useRef)(null),u=(0,z.useCallback)(()=>{o.current&&=(clearTimeout(o.current),null),c.current&&=(clearTimeout(c.current),null),l.current&&=(clearInterval(l.current),null)},[]);(0,z.useEffect)(()=>u,[u]);let d=(0,z.useCallback)((e,t)=>{l.current&&clearInterval(l.current),l.current=setInterval(async()=>{try{let n=await Yi();t===`load`?n.model_loaded?.toLowerCase()===e.toLowerCase()&&(r(!1),o.current&&=(clearTimeout(o.current),null),l.current&&=(clearInterval(l.current),null)):(n.model_downloaded===!0||n.model_loaded?.toLowerCase()===e.toLowerCase())&&(a(!1),c.current&&=(clearTimeout(c.current),null),l.current&&=(clearInterval(l.current),null))}catch{}},Tc)},[]),f=e??`Gemma-4-E4B-it-GGUF`;return{isLoadingModel:n,isDownloadingModel:i,loadModel:(0,z.useCallback)(async(e,t)=>{let n=e??f,i=t??32768;r(!0);try{if(!await na(n,i)){r(!1);return}s.system.info(`Load model triggered: ${n} (ctx=${i})`),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>r(!1),Cc),d(n,`load`)}catch(e){s.system.error(`Failed to trigger model load`,e),r(!1)}},[f,t,d]),downloadModel:(0,z.useCallback)(async(e=!1,t)=>{let n=t??f;a(!0);try{await ra(n,e),s.system.info(`Download model triggered: ${n} (force=${e})`),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>a(!1),wc),d(n,`download`)}catch(e){s.system.error(`Failed to trigger model download`,e),a(!1)}},[f,d])}}var sO=5e3,cO=2e3,lO=3e4,uO=6e4;function dO(e){return e.lemonade_running?`up`:e.lemonade_error?`unresponsive`:`down`}function fO(e){return e.kind===`slow`||e.kind===`error`||e.kind===`ok`&&dO(e.status)===`unresponsive`}function pO(e){let t=e.kind===`ok`?e.status.download_progress?.state:void 0;return t===`downloading`||t===`starting`}function mO(e){let t=null,n=0,r=!1,i=null,a=0,o=null,c=async()=>{let e={controller:new AbortController,cancelled:!1};o=e;let{controller:t}=e,n=setTimeout(()=>t.abort(),uO);try{return{kind:`ok`,status:await Yi(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)}},l=()=>{if(t)return t;let i=c().then(t=>{if(t!==null){n=fO(t)?n+1:0,r=pO(t);try{e(t)}catch(e){s.system.error(`Could not apply the system status; the next poll will try again`,e)}}}).finally(()=>{t===i&&(t=null)});return t=i,i},u=()=>Math.min((r?cO:sO)*2**n,lO),d=e=>{l().finally(()=>{e===a&&(i=setTimeout(()=>d(e),u()))})};return{check:l,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 hO({onRetry:e,label:t}){let[n,r]=(0,z.useState)(!1);return(0,V.jsx)(`button`,{className:`connection-banner__retry`,onClick:()=>{r(!0),Promise.resolve(e()).finally(()=>r(!1))},disabled:n,children:n?`Checking…`:t})}function gO({onRetry:e,backendSlow:t=!1,backendError:n=null}){let{backendConnected:r,systemStatus:i,currentSessionId:a,messages:o}=B(),[s,c]=(0,z.useState)(!1),l=!!a&&o.length>0,u=i?.default_model_name??`Gemma-4-E4B-it-GGUF`,{isDownloadingModel:d,downloadModel:f}=oO(u),p=(0,z.useRef)(i?.lemonade_running),m=(0,z.useRef)(i?.model_downloaded),h=(0,z.useRef)(i?.context_size_sufficient),g=(0,z.useRef)(i?.expected_model_loaded);(0,z.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,V.jsxs)(`div`,{className:`connection-banner ${t?`connection-banner--error`:`connection-banner--warning`}`,role:t?`alert`:`status`,children:[(0,V.jsx)(`div`,{className:`connection-banner__icon`,children:t?(0,V.jsx)(An,{size:16}):(0,V.jsx)(Ae,{size:16})}),(0,V.jsx)(`div`,{className:`connection-banner__text`,children:t?(0,V.jsxs)(V.Fragment,{children:[`Download of `,(0,V.jsx)(`strong`,{children:v}),` failed.`,` `,_?.message&&(0,V.jsx)(`span`,{className:`connection-banner__hint`,children:_.message})]}):(0,V.jsxs)(V.Fragment,{children:[`Downloading `,(0,V.jsx)(`strong`,{children:v}),` (`,e,`).`,_?.state===`downloading`&&_.file&&(0,V.jsxs)(V.Fragment,{children:[` `,(0,V.jsxs)(`span`,{className:`connection-banner__hint`,children:[`File `,_.file_index,` / `,_.total_files,`: `,(0,V.jsx)(`code`,{children:_.file})]})]})]})}),t?(0,V.jsx)(`button`,{className:`connection-banner__retry`,onClick:()=>f(!1,v),children:`Retry`}):(0,V.jsx)(`span`,{className:`connection-banner__loading connection-banner__progress`,children:_&&_.state===`downloading`&&_.total_bytes>0?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`connection-banner__progress-bar`,role:`progressbar`,"aria-valuenow":_.percent,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`Download progress`,children:(0,V.jsx)(`span`,{className:`connection-banner__progress-fill`,style:{width:`${_.percent}%`}})}),(0,V.jsxs)(`span`,{className:`connection-banner__progress-label`,children:[_.percent,`% ·`,` `,(_.downloaded_bytes/1e9).toFixed(2),` /`,` `,(_.total_bytes/1e9).toFixed(2),` GB`]})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(R,{size:13,className:`connection-banner__spinner`}),_?.state===`starting`?`Starting download…`:`Downloading…`]})}),t&&(0,V.jsx)(`button`,{className:`connection-banner__dismiss`,onClick:()=>c(!0),"aria-label":`Dismiss`,children:(0,V.jsx)(Bn,{size:14})})]})}if(i?.init_state===`initializing`){let e=i.init_tasks?.find(e=>e.status===`running`)?.name||`Preparing AI system`;return(0,V.jsxs)(`div`,{className:`connection-banner connection-banner--init`,role:`status`,children:[(0,V.jsx)(`div`,{className:`connection-banner__icon`,children:(0,V.jsx)(R,{size:16,className:`connection-banner__spinner`})}),(0,V.jsxs)(`div`,{className:`connection-banner__text`,children:[e,(0,V.jsxs)(`span`,{className:`thinking-dots`,children:[(0,V.jsx)(`span`,{children:`.`}),(0,V.jsx)(`span`,{children:`.`}),(0,V.jsx)(`span`,{children:`.`})]})]})]})}if(s||l)return null;if(!r)return(0,V.jsxs)(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[(0,V.jsx)(`div`,{className:`connection-banner__icon`,children:(0,V.jsx)(In,{size:16})}),(0,V.jsxs)(`div`,{className:`connection-banner__text`,children:[`Lost the connection to GAIA.`,` `,(0,V.jsx)(`span`,{className:`connection-banner__hint`,children:`Check that GAIA is still running, then retry.`})]}),e&&(0,V.jsx)(hO,{onRetry:e,label:`Retry`})]});if(n)return(0,V.jsxs)(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[(0,V.jsx)(`div`,{className:`connection-banner__icon`,children:(0,V.jsx)(An,{size:16})}),(0,V.jsxs)(`div`,{className:`connection-banner__text`,children:[`GAIA's backend answered with an error (`,n,`).`,` `,(0,V.jsx)(`span`,{className:`connection-banner__hint`,children:`It may be overloaded. GAIA keeps checking; if it lasts, restart GAIA.`})]}),e&&(0,V.jsx)(hO,{onRetry:e,label:`Check again`})]});if(t)return(0,V.jsxs)(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[(0,V.jsx)(`div`,{className:`connection-banner__icon`,children:(0,V.jsx)(An,{size:16})}),(0,V.jsxs)(`div`,{className:`connection-banner__text`,children:[`GAIA is slow to answer.`,` `,(0,V.jsx)(`span`,{className:`connection-banner__hint`,children:`It may be busy with another chat or app. GAIA keeps checking.`})]}),e&&(0,V.jsx)(hO,{onRetry:e,label:`Check again`})]});if(i?.config_error)return(0,V.jsxs)(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[(0,V.jsx)(`div`,{className:`connection-banner__icon`,children:(0,V.jsx)(An,{size:16})}),(0,V.jsxs)(`div`,{className:`connection-banner__text`,children:[`GAIA settings could not be loaded.`,` `,(0,V.jsx)(`span`,{className:`connection-banner__hint`,children:i.config_error})]}),e&&(0,V.jsx)(hO,{onRetry:e,label:`Check again`})]});if(i&&!i.lemonade_running){let t=dO(i)===`unresponsive`;return(0,V.jsxs)(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[(0,V.jsx)(`div`,{className:`connection-banner__icon`,children:(0,V.jsx)(An,{size:16})}),(0,V.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 isn't running.`,` `,i.start_command?(0,V.jsxs)(`span`,{className:`connection-banner__hint`,children:[t?`If it stays this way, restart it: `:`To start it by hand, run `,(0,V.jsx)(`code`,{children:i.start_command})]}):i.start_instruction&&(0,V.jsx)(`span`,{className:`connection-banner__hint`,children:i.start_instruction})]}),e&&(0,V.jsx)(hO,{onRetry:e,label:`Check again`}),(0,V.jsx)(`button`,{className:`connection-banner__dismiss`,onClick:()=>c(!0),"aria-label":`Dismiss`,children:(0,V.jsx)(Bn,{size:14})})]})}if(i&&i.lemonade_running&&i.model_loaded&&i.context_size_sufficient===!1){let t=i.model_context_size??0;return(0,V.jsxs)(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[(0,V.jsx)(`div`,{className:`connection-banner__icon`,children:(0,V.jsx)(bt,{size:16})}),(0,V.jsxs)(`div`,{className:`connection-banner__text`,children:[`LLM context window is too small (`,t.toLocaleString(),` tokens;`,` `,xc.toLocaleString(),` required).`,` `,(0,V.jsx)(`span`,{className:`connection-banner__hint`,children:`Reload it with a larger context in Settings → Advanced.`})]}),e&&(0,V.jsx)(hO,{onRetry:e,label:`Check again`}),(0,V.jsx)(`button`,{className:`connection-banner__dismiss`,onClick:()=>c(!0),"aria-label":`Dismiss`,children:(0,V.jsx)(Bn,{size:14})})]})}return null}function _O(){let e=_D(),[t,n]=(0,z.useState)(!1),[r,i]=(0,z.useState)(null),a=(0,z.useCallback)(e=>{let t=hD();t&&(i(null),t[e]().catch(t=>{let n=t instanceof Error?t.message:String(t);s.system.error(`Update ${e} failed`,t),i(n)}))},[]);if(t||e.status===`idle`||e.status===`checking`||e.status===`disabled`||e.status===`no-channel`)return null;if(e.status===`downloading`){let t=Math.max(0,Math.min(100,e.progress));return(0,V.jsxs)(`div`,{className:`update-chip update-chip--downloading`,role:`status`,"aria-live":`polite`,title:`Downloading update${e.version?` ${e.version}`:``}…`,children:[(0,V.jsx)(Ae,{size:13,className:`update-chip__icon`}),(0,V.jsxs)(`span`,{className:`update-chip__label`,children:[`Downloading update… `,t,`%`]})]})}return e.status===`available`?(0,V.jsxs)(`div`,{className:`update-chip update-chip--available`,role:`status`,title:r||e.releaseNotes||`A new version is available.`,children:[(0,V.jsx)(Ae,{size:13,className:`update-chip__icon`}),(0,V.jsx)(`span`,{className:`update-chip__label`,children:r?`Update failed — try again`:`GAIA ${e.version??``} is available`}),!e.pinnedVersion&&(0,V.jsx)(`button`,{type:`button`,className:`update-chip__action`,onClick:()=>a(`downloadUpdate`),children:`Update now`}),(0,V.jsx)(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>n(!0),"aria-label":`Dismiss update notification`,children:(0,V.jsx)(Bn,{size:11})})]}):e.status===`downloaded`?(0,V.jsxs)(`div`,{className:`update-chip update-chip--ready`,role:`status`,"aria-live":`polite`,children:[(0,V.jsx)(tn,{size:13,className:`update-chip__icon`}),(0,V.jsx)(`button`,{type:`button`,className:`update-chip__action`,onClick:()=>a(`restart`),title:r||`Click to restart and apply the update`,children:r?`Restart failed — try again`:`Update ready — restart to apply`})]}):e.status===`error`?(0,V.jsxs)(`div`,{className:`update-chip update-chip--error`,role:`status`,title:e.error||`Update check failed.`,children:[(0,V.jsx)(An,{size:13,className:`update-chip__icon`}),(0,V.jsx)(`span`,{className:`update-chip__label`,children:`Update check failed`}),(0,V.jsx)(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>n(!0),"aria-label":`Dismiss update error`,children:(0,V.jsx)(Bn,{size:11})})]}):null}var vO={permission_request:{icon:(0,V.jsx)(un,{size:16}),colorClass:`notif-type-permission`,label:`Permission`},policy_alert:{icon:(0,V.jsx)(un,{size:16}),colorClass:`notif-type-policy`,label:`Policy`},security_alert:{icon:(0,V.jsx)(An,{size:16}),colorClass:`notif-type-security`,label:`Security`},status_change:{icon:(0,V.jsx)(ue,{size:16}),colorClass:`notif-type-status`,label:`Status`},info:{icon:(0,V.jsx)(gt,{size:16}),colorClass:`notif-type-info`,label:`Info`},error:{icon:(0,V.jsx)(ce,{size:16}),colorClass:`notif-type-error`,label:`Error`}};function yO(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 bO({onClose:e}){let t=G(qn(Hs)),n=G(Vs),r=G(e=>e.markRead),i=G(e=>e.markAllRead),a=G(e=>e.clearAll),o=G(e=>e.dismiss),s=G(e=>e.respondToPermission),c=G(e=>e.typeFilter),l=G(e=>e.setTypeFilter),u=(0,z.useCallback)(e=>{r(e)},[r]),d=(0,z.useCallback)(e=>{s(e.id,`allow`).catch(e=>console.error(`[NotificationCenter] allow failed:`,e))},[s]),f=(0,z.useCallback)(e=>{s(e.id,`deny`).catch(e=>console.error(`[NotificationCenter] deny failed:`,e))},[s]);return ei(!0,e),(0,V.jsxs)(`div`,{className:`notification-center`,role:`dialog`,"aria-label":`Notification Center`,children:[(0,V.jsxs)(`div`,{className:`notification-center-header`,children:[(0,V.jsxs)(`div`,{className:`notification-center-title-row`,children:[(0,V.jsx)(`h2`,{className:`notification-center-title`,children:`Notifications`}),n>0&&(0,V.jsx)(`span`,{className:`notification-center-badge`,children:n})]}),(0,V.jsx)(`button`,{className:`btn-icon notification-center-close`,onClick:e,"aria-label":`Close notification center`,children:(0,V.jsx)(Bn,{size:18})})]}),(0,V.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,V.jsx)(`button`,{role:`tab`,"aria-selected":c===e.key,className:`notification-filter-tab ${c===e.key?`active`:``}`,onClick:()=>l(e.key),children:e.label},e.key??`all`))}),(0,V.jsx)(`div`,{className:`notification-list`,children:t.length===0?(0,V.jsxs)(`div`,{className:`notification-empty`,children:[(0,V.jsx)(w,{size:40,strokeWidth:1.2}),(0,V.jsx)(`span`,{children:`No notifications`})]}):t.map(e=>{let t=vO[e.type];return(0,V.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:()=>u(e.id),role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&u(e.id)},children:[!e.read&&(0,V.jsx)(`span`,{className:`notification-unread-dot`}),(0,V.jsx)(`span`,{className:`notification-icon`,children:t.icon}),(0,V.jsxs)(`div`,{className:`notification-content`,children:[(0,V.jsxs)(`div`,{className:`notification-content-header`,children:[(0,V.jsx)(`span`,{className:`notification-agent`,children:e.agentName}),(0,V.jsx)(`span`,{className:`notification-time`,children:yO(e.timestamp)})]}),e.title&&(0,V.jsx)(`span`,{className:`notification-title`,children:e.title}),(0,V.jsx)(`span`,{className:`notification-message`,children:e.message}),e.type===`permission_request`&&e.tool&&e.tool!==`allow_path_access`&&(0,V.jsxs)(`span`,{className:`notification-tool`,children:[`Tool: `,(0,V.jsx)(`code`,{children:e.tool})]}),e.type===`policy_alert`&&(0,V.jsxs)(`div`,{className:`notification-policy-details`,children:[e.tool&&(0,V.jsxs)(`span`,{className:`notification-tool`,children:[`Tool: `,(0,V.jsx)(`code`,{children:e.tool})]}),e.reason&&(0,V.jsxs)(`span`,{className:`notification-policy-reason`,children:[`Reason: `,e.reason]}),e.ruleIds&&e.ruleIds.length>0&&(0,V.jsxs)(`span`,{className:`notification-tool`,children:[`Rules: `,(0,V.jsx)(`code`,{children:e.ruleIds.join(`, `)})]}),e.policyVersion&&(0,V.jsxs)(`span`,{className:`notification-tool`,children:[`Policy: `,(0,V.jsx)(`code`,{children:e.policyVersion})]}),(0,V.jsxs)(`span`,{className:`notification-tool`,children:[`Receipt:`,` `,e.receiptId?(0,V.jsx)(`code`,{children:e.receiptId}):(0,V.jsx)(`em`,{children:`Receipt unavailable`})]})]}),e.type===`permission_request`&&!e.response&&(0,V.jsxs)(`div`,{className:`notification-actions`,children:[(0,V.jsxs)(`button`,{className:`notification-action-btn notification-action-allow`,onClick:t=>{t.stopPropagation(),d(e)},children:[(0,V.jsx)(P,{size:14}),`Approve`]}),(0,V.jsxs)(`button`,{className:`notification-action-btn notification-action-deny`,onClick:t=>{t.stopPropagation(),f(e)},children:[(0,V.jsx)(Bn,{size:14}),`Deny`]})]}),e.type===`permission_request`&&e.response&&(0,V.jsx)(`span`,{className:`notification-response-badge ${e.response===`allow`?`response-allow`:`response-deny`}`,children:e.response===`allow`?`Approved`:`Denied`})]}),(0,V.jsx)(`button`,{className:`notification-dismiss`,onClick:t=>{t.stopPropagation(),o(e.id)},"aria-label":`Dismiss notification`,children:(0,V.jsx)(Bn,{size:14})})]},e.id)})}),t.length>0&&(0,V.jsxs)(`div`,{className:`notification-center-footer`,children:[(0,V.jsxs)(`button`,{className:`notification-footer-btn`,onClick:i,disabled:n===0,children:[(0,V.jsx)(P,{size:14}),`Mark All Read`]}),(0,V.jsxs)(`button`,{className:`notification-footer-btn notification-footer-clear`,onClick:a,children:[(0,V.jsx)(On,{size:14}),`Clear`]})]})]})}var xO=1500,SO=e=>new Promise(t=>setTimeout(t,e));async function CO({onProgress:e,isCancelled:t=()=>!1,pollMs:n=xO}={}){try{await aa(DT)}catch(e){if(e?.httpStatus!==409)throw e;let t=await oa(DT).catch(()=>null);if(!t||t.status===`completed`||t.status===`failed`)throw e}for(;!t();){let t=await oa(DT);if(e?.(t),t.status===`completed`)return;if(t.status===`failed`)throw Error(t.error||`The GAIA agent could not be installed.`);await SO(n)}}function wO({onInstalled:e}){let[t,n]=(0,z.useState)({kind:`idle`}),r=(0,z.useRef)(!1);(0,z.useEffect)(()=>()=>{r.current=!0},[]);let i=(0,z.useCallback)(async()=>{n({kind:`installing`,percent:0});try{if(await CO({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,V.jsxs)(`div`,{className:`app-notice is-warning`,role:`status`,children:[t.kind===`installing`?(0,V.jsxs)(`span`,{children:[`Installing the GAIA agent… `,Math.round(t.percent),`%`]}):t.kind===`failed`?(0,V.jsxs)(`span`,{children:[`The GAIA agent could not be installed: `,t.error]}):(0,V.jsx)(`span`,{children:`The GAIA agent isn't installed, so new chats can't start yet.`}),t.kind!==`installing`&&(0,V.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>void i(),children:t.kind===`failed`?`Try again`:`Install GAIA agent`})]})}function TO(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 EO(e,t){let{addNotification:n}=G.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 DO=$n((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 Ao()).schedules||[],r=t().errorCounts;r&&EO(r,n),e({schedules:n,loading:!1,errorCounts:Object.fromEntries(n.map(e=>[e.id,e.error_count]))})}catch(t){s.api.error(`Failed to load schedules`,t),e({error:`Failed to load schedules`,loading:!1})}},createSchedule:async(t,n,r)=>{try{let i=await Mo(t,n,r);e(e=>({schedules:[...e.schedules,i],error:null}))}catch(t){let n=TO(t,`Failed to create schedule`);throw s.api.error(`Failed to create schedule`,t),e({error:n}),t}},updateScheduleStatus:async(t,n)=>{try{let r=await No(t,n);e(e=>({schedules:e.schedules.map(e=>e.name===t?r:e),error:null}))}catch(n){s.api.error(`Failed to update schedule "${t}"`,n),e({error:TO(n,`Failed to update schedule`)})}},deleteSchedule:async t=>{try{await Po(t),e(e=>({schedules:e.schedules.filter(e=>e.name!==t),selectedSchedule:e.selectedSchedule===t?null:e.selectedSchedule,error:null}))}catch(n){s.api.error(`Failed to delete schedule "${t}"`,n),e({error:TO(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 Fo(t)).results||[],resultsLoading:!1})}catch(n){s.api.error(`Failed to load results for "${t}"`,n),e({results:[],resultsLoading:!1})}}})),OO=new Set([`loading_model`,`downloading_model`,`model_retry`,`waiting`]),kO=5;function AO(e,t){return{id:e,title:t.get(e)?.title??`Untitled chat`}}function jO(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=>({...AO(e,t),reason:`approval`}));n&&e.awaitingUser&&!a.has(e.currentSessionId)&&o.push({...AO(e.currentSessionId,t),reason:`answer`});for(let[n,r]of Object.entries(e.awaitingBySession))o.some(e=>e.id===n)||o.push({...AO(n,t),reason:r===`question`?`answer`:`approval`});let s=n&&!e.awaitingUser&&e.livePhase&&OO.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,kO).map(e=>AO(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=>AO(e,t)),needsYou:o,recent:u}}function MO(e){let t=(0,z.useRef)(e);t.current=e,(0,z.useEffect)(()=>{let e=window.gaiaAPI?.tray;if(!e)return;let n=``,r=null,i=()=>{let t=B.getState(),i={backendConnected:t.backendConnected,systemStatus:t.systemStatus,sessions:t.sessions,runningSessionIds:t.runningSessionIds,awaitingBySession:t.awaitingBySession,currentSessionId:t.currentSessionId,isStreaming:t.isStreaming,awaitingUser:t.awaitingUser,liveStatus:t.liveStatus,livePhase:t.livePhase,notifications:G.getState().notifications},a=r;if(r=i,a&&Object.keys(i).every(e=>i[e]===a[e]))return;let o=jO(i),c=JSON.stringify(o);c!==n&&(n=c,e.setActivity(o).catch(e=>{n=``,s.system.error(`The tray could not take the app state`,e)}))};i();let a=B.subscribe(i),o=G.subscribe(i),c=e.onCommand(e=>{switch(e.type){case`open-chat`:t.current.openChat(e.sessionId);break;case`new-chat`:t.current.newChat();break;case`open-settings`:B.getState().openSettings(e.section);break;case`refresh-status`:t.current.refreshStatus();break;default:s.system.error(`Unknown tray command`,e)}});return()=>{a(),o(),c()}},[])}function NO(){(0,z.useEffect)(()=>{let e=window.gaiaAPI;if(!e)return;let t=G.getState().addNotification,n=[e.notification.onNotification(t),e.notification.onPermissionRequest(t),e.tray.onNavigate(e=>{let t=typeof e==`string`&&e.startsWith(`session:`)?e.slice(8):null;if(!t)return;let n=B.getState();n.currentSessionId!==t&&n.setMessages([]),n.setCurrentSession(t)})];return()=>n.forEach(e=>e())},[])}function PO(e,t,n){let r=window.gaiaAPI;if(r){r.notification.show({title:t,body:n,sessionId:e}).then(e=>{e||s.system.warn(`This OS has no desktop notifications; the badge still counts it.`)}).catch(e=>s.system.error(`Could not show the desktop notification`,e));return}if(typeof Notification>`u`){s.system.warn(`This browser has no notifications; the alert was not shown.`);return}if(Notification.permission!==`granted`){s.system.warn(`Browser notifications are ${Notification.permission}; allow them in Settings → Notifications.`);return}let i=new Notification(t,{body:n,tag:`gaia-${e}`});i.onclick=()=>{window.focus(),B.getState().setCurrentSession(e)}}function FO(){let[e,t]=(0,z.useState)(null);return(0,z.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=>s.system.warn(`Battery level unavailable; keep-awake ignores the battery policy.`,e)),()=>{n?.removeEventListener(`levelchange`,r),n?.removeEventListener(`chargingchange`,r)}},[]),e}function IO(){NO();let e=B(e=>e.runningSessionIds),t=B(e=>e.awaitingBySession),n=B(e=>e.sessions),r=B(e=>e.currentSessionId),i=G(qn(Ws)),a=Zs(),o=FO(),c=(0,z.useRef)(null),l=ic(e,t,i),u=JSON.stringify(l);(0,z.useEffect)(()=>{let e=JSON.parse(u),t=c.current;if(c.current=e,t===null)return;let{sessions:n,currentSessionId:r}=B.getState(),i=document.hasFocus(),o=!1;for(let{sessionId:c,event:l}of ac(t,e)){let e=n.find(e=>e.id===c);if(e?.kind===`eval`||e?.kind===`scheduled`)continue;let t=a.modes[l];if(!(t===`off`||cc(c,r,i))&&(o=!0,t===`banner`)){if(l!==`finished`){let{title:t,body:n}=sc(l,e);PO(c,t,n)}else Ra(c).then(e=>{B.getState().updateSessionInList(c,e);let{title:t,body:n}=sc(l,e);PO(c,t,n)}).catch(t=>{s.system.error(`Could not read how chat ${c} ended`,t);let{title:n,body:r}=sc(l,{...e,last_run_status:null});PO(c,n,r)})}}if(o){if(a.sound)try{dc()}catch(e){s.system.warn(`Alert sound not played`,e)}a.flash&&!i&&window.gaiaAPI&&window.gaiaAPI.notification.flash().catch(e=>s.system.error(`Could not flash the taskbar button`,e))}},[u,a.modes,a.sound,a.flash]);let d=lc(n,l,a.modes,r);(0,z.useEffect)(()=>{window.gaiaAPI?.notification.setAttentionCount(d).catch(e=>s.system.error(`Could not update the taskbar badge`,e))},[d]);let f=a.keepAwake&&e.length>0&&uc(o,a.batteryFloor);(0,z.useEffect)(()=>{window.gaiaAPI?.power.setKeepAwake(f).catch(e=>s.system.error(`Could not change keep-awake`,e))},[f])}function LO(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 RO(e){return e.replace(/-/g,``).slice(0,7)}function zO(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 BO(e,t,n){return!e||t&&(e===t||e===RO(t))?null:n.some(t=>t.id===e)?e:zO(n,e)}function VO(e){return new URLSearchParams(e.search).get(`session`)||e.hash.replace(/^#/,``)||null}var HO=`gaia:last-session`;function UO(e){try{e?localStorage.setItem(HO,e):localStorage.removeItem(HO)}catch(e){s.ui.warn(`Could not save the open chat for the next launch`,e)}}function WO(){try{return localStorage.getItem(HO)}catch(e){return s.ui.warn(`Could not read the chat open at last launch`,e),null}}var GO=1e3,KO=3e4;function qO(e,{initialMs:t=GO,maxMs:n=KO,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 JO=(0,z.lazy)(()=>tO(()=>import(`./MemoryDashboard-qcp2siub.js`).then(e=>({default:e.MemoryDashboard})),__vite__mapDeps([5,1,2,6,7]),import.meta.url)),YO=(0,z.lazy)(()=>tO(()=>import(`./ScheduleManager-CHq7l6Ex.js`).then(e=>({default:e.ScheduleManager})),__vite__mapDeps([8,1,2,6,9]),import.meta.url)),XO=(0,z.lazy)(()=>tO(()=>import(`./DocumentLibrary-DBHK1rnR.js`).then(e=>({default:e.DocumentLibrary})),__vite__mapDeps([10,1,2,11]),import.meta.url)),ZO=(0,z.lazy)(()=>tO(()=>import(`./FileBrowser-CSXzEgI5.js`).then(e=>({default:e.FileBrowser})),__vite__mapDeps([12,1,2,13]),import.meta.url)),QO=(0,z.lazy)(()=>tO(()=>import(`./MobileAccessModal-BU3rxH7C.js`).then(e=>({default:e.MobileAccessModal})),__vite__mapDeps([14,1,2,15]),import.meta.url)),$O=3,ek=3e5,tk=6e3,nk=6e4,rk=e=>e instanceof TypeError,ik=e=>new Promise(t=>setTimeout(t,e));function ak(){return(0,V.jsx)(`div`,{className:`loading-spinner`,role:`status`,"aria-label":`Loading`})}var ok=e=>e===1||e%10==0;function sk(){let e=B(e=>e.currentSessionId),t=B(e=>e.setSessions),n=B(e=>e.setCurrentSession),r=B(e=>e.addSession),a=B(e=>e.setMessages),o=B(e=>e.showDocLibrary),l=B(e=>e.showFileBrowser),u=B(e=>e.showMemoryDashboard),d=B(e=>e.showSchedules),f=B(e=>e.sidebarOpen),p=B(e=>e.setSidebarOpen),m=B(e=>e.setSystemStatus),h=B(e=>e.setBackendConnected),g=B(e=>e.setAgents),_=B(e=>e.agents),v=B(e=>e.setPendingPrompt),y=B(e=>e.setDefaultPermissionMode),b=B(e=>e.openSettings),x=B(e=>e.settingsSection),S=B(e=>e.syncSystemTheme),C=cs(e=>e.restoreNotice),w=cs(e=>e.dismissRestoreNotice),T=G(e=>e.showPanel),E=B(e=>e.systemStatus?.initialized===!0),D=G(e=>e.setShowPanel);(0,z.useEffect)(()=>{if(!C?.ok)return;let e=setTimeout(w,tk);return()=>clearTimeout(e)},[C,w]);let[O,k]=(0,z.useState)({state:`checking`}),ee=(0,z.useRef)(O);ee.current=O;let[A,j]=(0,z.useState)(!1),te=(0,z.useRef)(A);te.current=A;let[M,N]=(0,z.useState)(!1),P=M||A&&!OT(_),ne=(0,z.useRef)(P);ne.current=P;let[re,ie]=(0,z.useState)(null),[F,ae]=(0,z.useState)(``),[oe,se]=(0,z.useState)(0),[ce,le]=(0,z.useState)(!1),[ue,de]=(0,z.useState)(!1),[fe,pe]=(0,z.useState)(null),me=(0,z.useRef)(async()=>{}),I=(0,z.useRef)(async()=>{}),L=(0,z.useCallback)(async(e=!1,t=!1)=>{e||k({state:`checking`});let n=0;try{for(;;){await cs.getState().refresh();let e=cs.getState().active,r;try{r=await ca(!!e?.remote)}catch(e){if(!t||!rk(e)||n>=nk)throw e;await ik(GO),n+=GO;continue}n>0&&await Promise.all([me.current(),I.current()]),k(r.ready?{state:`ready`}:{state:`needed`,check:r});return}}catch(e){let t=e instanceof Error?e.message:String(e);s.system.warn(`Setup check could not be answered`,e),k({state:`unknown`,error:t})}},[]),he=(0,z.useRef)(0),ge=(0,z.useCallback)(async()=>{let e=++he.current,t=(await ia()).agents||[];e===he.current&&(g(t),j(!0),OT(t)&&N(!1))},[g]),_e=(0,z.useCallback)(()=>{let e=te.current;j(!1),ge().catch(t=>{s.api.warn(`Agent list unavailable after setup`,t),e&&j(!0)})},[ge]);(0,z.useEffect)(()=>{let e=()=>{ne.current&&ge().catch(e=>s.api.warn(`Agent list unavailable`,e))};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[ge]);let ve=(0,z.useCallback)(async()=>{y((await Fi()).default_mode)},[y]),ye=(0,z.useRef)([]);(0,z.useEffect)(()=>{i(`0.25.2rc6`),L(!1,!0);let e=[qO(ge,{onError:(e,t)=>{ok(t)&&s.api.warn(`Agent list unavailable (attempt ${t}); retrying`,e)}}),qO(ve,{onError:(e,t)=>{ok(t)&&s.api.warn(`Default permission mode unavailable (attempt ${t}); retrying`,e)}})];return ye.current=e,()=>e.forEach(e=>e.stop())},[L,ge,ve]);let be=(0,z.useCallback)(()=>{ye.current.forEach(e=>e.kick()),cs.getState().retryNow(),I.current(),ee.current.state===`unknown`&&L(!0)},[L]),xe=(0,z.useRef)(be);xe.current=be;let Se=(0,z.useRef)(0),Ce=(0,z.useRef)(0),we=(0,z.useRef)(null),Te=(0,z.useRef)(!1),[Ee,De]=(0,z.useState)(!1),[Oe,ke]=(0,z.useState)(null),Ae=(0,z.useCallback)(e=>{if(e.kind===`unreachable`){s.system.warn(`System status check failed`,e.error),Te.current=!0,Ce.current=0,we.current=null,De(!1),ke(null),h(!1),m(null);return}if(e.kind===`error`){s.system.warn(`System status answered HTTP ${e.httpStatus}`,e.message),Te.current&&xe.current(),Te.current=!1,Ce.current=0,we.current=null,De(!1),ke(`HTTP ${e.httpStatus}: ${e.message}`),h(!0);return}if(e.kind===`slow`){if(Ce.current+=1,we.current??=Date.now(),ke(null),s.system.warn(`System status did not answer in time (${Ce.current} in a row)`),Date.now()-we.current>=ek){De(!1),h(!1),m(null);return}h(!0),(Te.current||Ce.current>=$O)&&De(!0);return}let{status:t}=e;Te.current&&xe.current(),Te.current=!1,Ce.current=0,we.current=null,De(!1),ke(null),h(!0),Se.current=t.lemonade_running?0:Se.current+1;let n=B.getState().systemStatus;t.lemonade_running||Se.current>=$O||!n?.lemonade_running?m(t):m({...n,download_progress:t.download_progress})},[h,m]),je=(0,z.useRef)(Ae);je.current=Ae;let[Me]=(0,z.useState)(()=>mO(e=>je.current(e))),Ne=Me.check;me.current=Ne,(0,z.useEffect)(()=>NT(Me.start),[Me]);let Pe=(0,z.useRef)(``);(0,z.useEffect)(()=>{let e=e=>Pa().then(n=>{let r=n.sessions||[];if(!e&&r.length===0&&B.getState().sessions.length>0)return;let i=r.map(e=>`${e.id}|${e.updated_at}|${e.title}|${e.inference_remote}|${e.inference_provider}|${e.inference_description}|${e.effective_model}|${e.unread}|${e.pinned}|${e.last_run_status}|${e.kind}`).join(`
|
|
77
|
+
`)})]}),he&&(0,V.jsxs)(`div`,{className:`setup-done`,role:`status`,children:[(0,V.jsxs)(`div`,{className:`setup-done-head`,children:[(0,V.jsxs)(`p`,{children:[`GAIA is ready.`,_e&&(0,V.jsxs)(V.Fragment,{children:[` `,(0,V.jsx)(`strong`,{children:_s(_e)}),` answers`,N?` in the cloud`:` on this PC`,`.`]})]}),(0,V.jsx)(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void L(),autoFocus:!0,children:`Start chatting`})]}),E.length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`setup-hint`,children:`Or start with one of these:`}),(0,V.jsx)(NE,{cards:E,onPick:e=>void L(e)})]})]})]})})}var fD=pc()?`menu bar`:`tray`,pD=[{key:`minimizeToTray`,label:`Keep running when the window closes`,hint:`GAIA stays in the ${fD} with your model loaded. Quit from the ${fD} 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 ${fD}`,hint:`GAIA opens without its window. Use the ${fD} icon to show it.`}];function mD(){let e=window.gaiaAPI?.tray,[t,n]=(0,z.useState)(null),[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(null);(0,z.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,z.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,V.jsxs)(`div`,{className:`settings-field`,role:`group`,"aria-labelledby":`desktop-app-label`,children:[(0,V.jsx)(`span`,{className:`settings-label`,id:`desktop-app-label`,children:`Desktop app`}),pD.map(({key:e,label:n,hint:r})=>(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`label`,{className:`setting-row`,children:[(0,V.jsx)(`span`,{children:n}),(0,V.jsxs)(`span`,{className:`toggle-switch`,children:[(0,V.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,V.jsx)(`span`,{className:`toggle-track`})]})]}),(0,V.jsx)(`p`,{className:`settings-hint`,id:`desktop-${e}-hint`,children:r})]},e)),r&&(0,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r})]}):null}function hD(){return window.gaiaUpdater}var gD={status:`idle`,version:null,progress:0,releaseNotes:null,error:null,currentVersion:null,pinnedVersion:null,autoUpdate:!1,includePrereleases:!1};function _D(){let[e,t]=(0,z.useState)({...gD});return(0,z.useEffect)(()=>{let e=hD();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 vD(){return window.gaiaUpdater}function yD({onClose:e}){let[t,n]=(0,z.useState)({kind:`loading`}),r=(0,z.useRef)(null);(0,z.useEffect)(()=>{let e=vD();e?e.listReleases().then(e=>{n(Array.isArray(e)?{kind:`list`,releases:e}:{kind:`error`,message:e.error})}).catch(()=>{n({kind:`error`,message:`Couldn't reach GitHub to list releases — check your connection; you can still download installers from the Releases page.`})}):n({kind:`error`,message:`Couldn't reach GitHub to list releases — check your connection; you can still download installers from the Releases page.`})},[]),ei(!0,e),fx(r,!0),(0,z.useEffect)(()=>{let e=r.current;e&&e.querySelector(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)?.focus()},[]),(0,z.useEffect)(()=>{let e=r.current;if(!e)return;function t(t){if(t.key!==`Tab`||!e)return;let n=e.querySelectorAll(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);if(n.length===0)return;let r=n[0],i=n[n.length-1];t.shiftKey?document.activeElement===r&&(t.preventDefault(),i?.focus()):document.activeElement===i&&(t.preventDefault(),r?.focus())}return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[]);function i(e,t){e.isCurrent||n({kind:`confirm`,release:e,releases:t})}async function a(t){n({kind:`installing`});let r=vD();if(!r)n({kind:`error`,message:`Bridge unavailable — please restart the app.`});else try{await r.installVersion(t.tag),e()}catch(e){let t=e instanceof Error?e.message:String(e);n({kind:`error`,message:`Failed to install that version: ${t}`})}}function o(e){if(!e)return``;try{return new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}catch{return e}}return(0,V.jsx)(`div`,{className:`version-picker-overlay`,onClick:t=>{t.target===t.currentTarget&&e()},children:(0,V.jsxs)(`div`,{className:`version-picker-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Install a specific version`,ref:r,children:[(0,V.jsxs)(`div`,{className:`version-picker-header`,children:[(0,V.jsx)(`h3`,{children:`Install a specific version`}),(0,V.jsx)(`button`,{className:`version-picker-close`,onClick:e,"aria-label":`Close`,type:`button`,children:`×`})]}),(0,V.jsxs)(`div`,{className:`version-picker-body`,children:[t.kind===`loading`&&(0,V.jsxs)(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[(0,V.jsx)(`span`,{className:`version-picker-spinner`}),`Loading releases…`]}),t.kind===`error`&&(0,V.jsxs)(`div`,{className:`version-picker-error`,children:[(0,V.jsx)(`p`,{children:t.message}),(0,V.jsx)(`p`,{children:(0,V.jsx)(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:`Browse releases on GitHub`})})]}),t.kind===`list`&&(0,V.jsx)(`ul`,{className:`version-picker-list`,role:`listbox`,"aria-label":`Available releases`,children:t.releases.map(e=>(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,className:`version-picker-row`,"data-version":e.version,"aria-label":`${e.version}${e.isCurrent?` — installed`:``}${e.isPinned?` — pinned`:``}`,"aria-disabled":e.isCurrent?`true`:`false`,onClick:()=>i(e,t.releases),disabled:e.isCurrent,children:[(0,V.jsx)(`span`,{className:`vp-version`,children:e.version}),(0,V.jsx)(`span`,{className:`vp-date`,children:o(e.date)}),e.isCurrent&&(0,V.jsx)(`span`,{className:`vp-badge vp-badge-current`,children:`Installed`}),e.isPinned&&!e.isCurrent&&(0,V.jsx)(`span`,{className:`vp-badge vp-badge-pinned`,children:`Pinned`}),!e.isCurrent&&(0,V.jsx)(`span`,{className:`vp-arrow`,"aria-hidden":`true`,children:`›`})]})},e.tag))}),t.kind===`list`&&(0,V.jsxs)(`p`,{className:`version-picker-more`,children:[`Showing the `,t.releases.length,` most recent.`,` `,(0,V.jsx)(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:`Browse all releases on GitHub`})]}),t.kind===`confirm`&&(0,V.jsxs)(`div`,{className:`version-picker-confirm`,children:[(0,V.jsxs)(`p`,{children:[`This will `,(0,V.jsxs)(`strong`,{children:[`install v`,t.release.version]}),` and restart the app.`]}),(0,V.jsxs)(`p`,{className:`vp-confirm-note`,children:[`GAIA will stay on v`,t.release.version,`: updates are paused until you unpin it in Settings → Updates.`]}),(0,V.jsxs)(`div`,{className:`vp-confirm-actions`,children:[(0,V.jsx)(`button`,{type:`button`,className:`vp-btn-cancel`,onClick:()=>n({kind:`list`,releases:t.releases}),children:`Back`}),(0,V.jsx)(`button`,{type:`button`,className:`vp-btn-confirm`,onClick:()=>a(t.release),children:`Install & restart`})]})]}),t.kind===`installing`&&(0,V.jsxs)(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[(0,V.jsx)(`span`,{className:`version-picker-spinner`}),`Starting download…`]})]})]})})}var bD=`Install updates automatically`,xD=`Include release candidates`;function SD(e){return/^\d+\.\d+\.\d+-/.test(e??``)}function CD(e){switch(e.status){case`checking`:return`Checking for updates…`;case`available`:return`GAIA ${e.version??``} is available.`;case`downloading`:return`Downloading GAIA ${e.version??``}… ${e.progress}%`;case`downloaded`:return`GAIA ${e.version??``} is ready — restart to finish installing.`;case`error`:return`Update check failed: ${e.error??`unknown error`}`;case`no-channel`:return e.error??`No GAIA release publishes a desktop update for this platform yet.`;case`disabled`:return`Updates are turned off for this install (GAIA_DISABLE_UPDATE=1).`;default:return`GAIA is up to date.`}}function wD(){let e=_D(),t=hD(),[n,r]=(0,z.useState)(!1),[i,a]=(0,z.useState)(null),[o,c]=(0,z.useState)(!1);if(!t)return null;async function l(e,n){if(t){r(!0),a(null);try{await n(t)}catch(t){s.system.error(`${e} failed`,t),a(`${e} failed: ${t instanceof Error?t.message:String(t)}`)}finally{r(!1)}}}let u=e.status===`disabled`,d=n||e.status===`checking`||e.status===`downloading`;return(0,V.jsxs)(`div`,{className:`settings-field`,role:`group`,"aria-labelledby":`updates-label`,children:[(0,V.jsx)(`span`,{className:`settings-label`,id:`updates-label`,children:`Updates`}),(0,V.jsxs)(`p`,{className:`settings-hint`,role:`status`,children:[`Running GAIA `,e.currentVersion??`unknown`,`. `,CD(e)]}),(0,V.jsxs)(`label`,{className:`setting-row`,children:[(0,V.jsx)(`span`,{children:bD}),(0,V.jsxs)(`span`,{className:`toggle-switch`,children:[(0,V.jsx)(`input`,{type:`checkbox`,role:`switch`,checked:e.autoUpdate,"aria-describedby":`updates-auto-hint`,"aria-label":bD,"aria-busy":n,disabled:u,onChange:()=>{n||l(`Saving the auto-update setting`,t=>t.setAutoUpdate(!e.autoUpdate))}}),(0,V.jsx)(`span`,{className:`toggle-track`})]})]}),(0,V.jsx)(`p`,{className:`settings-hint`,id:`updates-auto-hint`,children:`Off by default while GAIA is changing quickly — you choose when to update. The Terminal UI follows the same setting.`}),(0,V.jsxs)(`label`,{className:`setting-row`,children:[(0,V.jsx)(`span`,{children:xD}),(0,V.jsxs)(`span`,{className:`toggle-switch`,children:[(0,V.jsx)(`input`,{type:`checkbox`,role:`switch`,checked:!!e.includePrereleases,"aria-describedby":`updates-rc-hint`,"aria-label":xD,"aria-busy":n,disabled:u,onChange:()=>{n||l(`Saving the release-candidate setting`,t=>t.setIncludePrereleases(!e.includePrereleases))}}),(0,V.jsx)(`span`,{className:`toggle-track`})]})]}),(0,V.jsxs)(`p`,{className:`settings-hint`,id:`updates-rc-hint`,children:[`Also offer test builds (vX.Y.Z-rcN) before they become a final release. Off by default.`,SD(e.currentVersion)&&` This is a release candidate, so newer ones are offered either way.`]}),e.pinnedVersion&&(0,V.jsxs)(`p`,{className:`settings-hint`,children:[`Pinned to `,e.pinnedVersion,`, so updates are paused.`,` `,(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:n,onClick:()=>void l(`Resuming updates`,e=>e.resumeUpdates()),children:`Unpin`})]}),(0,V.jsxs)(`div`,{className:`setting-actions`,children:[e.status===`available`&&!e.pinnedVersion&&(0,V.jsxs)(`button`,{type:`button`,className:`btn-primary`,disabled:n,onClick:()=>void l(`Downloading the update`,e=>e.downloadUpdate()),children:[`Update to `,e.version]}),e.status===`downloaded`&&(0,V.jsx)(`button`,{type:`button`,className:`btn-primary`,disabled:n,onClick:()=>void l(`Restarting to install`,e=>e.restart()),children:`Restart to install`}),(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:d||u,onClick:()=>void l(`Checking for updates`,e=>e.check()),children:`Check for updates`}),(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:d||u,onClick:()=>c(!0),children:`Install a specific version…`})]}),e.configError&&(0,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:e.configError}),i&&(0,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:i}),o&&(0,V.jsx)(yD,{onClose:()=>c(!1)})]})}var TD=[{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`system`,label:`Match system`}],ED=[[`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 DD(){let e=B(e=>e.themePreference),t=B(e=>e.setThemePreference),n=B(e=>e.palette),r=B(e=>e.setPalette),i=B(e=>e.customColors),a=B(e=>e.setCustomColors),o=e=>t=>a({...i,[e]:t.target.value.toUpperCase()});return(0,V.jsxs)(`div`,{className:`settings-pane`,children:[(0,V.jsx)(`h2`,{className:`settings-pane-title`,children:`General`}),(0,V.jsxs)(`div`,{className:`settings-field`,children:[(0,V.jsx)(`span`,{className:`settings-label`,id:`appearance-label`,children:`Appearance`}),(0,V.jsx)(`div`,{className:`segmented`,role:`radiogroup`,"aria-labelledby":`appearance-label`,children:TD.map(n=>(0,V.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,V.jsx)(mD,{}),(0,V.jsx)(wD,{}),(0,V.jsxs)(`div`,{className:`settings-field`,children:[(0,V.jsx)(`span`,{className:`settings-label`,id:`palette-label`,children:`Colors`}),(0,V.jsxs)(`div`,{className:`palette-grid`,role:`radiogroup`,"aria-labelledby":`palette-label`,children:[or.map(e=>(0,V.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,V.jsx)(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:e.swatch.map(e=>(0,V.jsx)(`i`,{style:{background:e}},e))}),e.name]},e.id)),(0,V.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":n===`custom`,className:`palette-tile${n===`custom`?` is-active`:``}`,onClick:()=>r(`custom`),children:[(0,V.jsxs)(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:[(0,V.jsx)(`i`,{style:{background:i.base}}),(0,V.jsx)(`i`,{style:{background:i.accent}})]}),`Custom`]})]}),n===`custom`&&(0,V.jsxs)(`div`,{className:`palette-custom`,children:[(0,V.jsxs)(`label`,{className:`palette-color`,htmlFor:`custom-accent`,children:[(0,V.jsx)(`input`,{id:`custom-accent`,type:`color`,value:i.accent,onChange:o(`accent`)}),(0,V.jsxs)(`span`,{children:[`Accent`,(0,V.jsx)(`small`,{children:`Buttons, links and focus`})]})]}),(0,V.jsxs)(`label`,{className:`palette-color`,htmlFor:`custom-base`,children:[(0,V.jsx)(`input`,{id:`custom-base`,type:`color`,value:i.base,onChange:o(`base`)}),(0,V.jsxs)(`span`,{children:[`Background tint`,(0,V.jsx)(`small`,{children:`The color the grays lean toward`})]})]}),(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>a(cr),children:`Reset`}),(0,V.jsx)(`p`,{className:`settings-hint`,children:`Text colors adjust on their own so everything stays readable in light and dark.`})]})]}),(0,V.jsxs)(`div`,{className:`settings-field`,children:[(0,V.jsx)(`span`,{className:`settings-label`,children:`Keyboard shortcuts`}),(0,V.jsx)(`dl`,{className:`shortcut-list`,children:ED.map(([e,t])=>(0,V.jsxs)(`div`,{className:`shortcut-row`,children:[(0,V.jsx)(`dt`,{children:(0,V.jsx)(`kbd`,{children:_c(e)})}),(0,V.jsx)(`dd`,{children:t})]},e))})]})]})}var OD=`auto`;function kD({model:e}){let[t,n]=(0,z.useState)(null),[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(!1),[s,c]=(0,z.useState)(null);(0,z.useEffect)(()=>{n(null),i(null),c(null),wa(e).then(n).catch(e=>i(e instanceof Error?e.message:String(e)))},[e]);let l=(0,z.useCallback)(async t=>{o(!0),i(null),c(null);try{let r=await Ta(e,t===OD?null:Number(t));n(r);let i=r.chosen?Ss(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,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r});if(!t)return(0,V.jsxs)(`p`,{className:`settings-hint`,children:[(0,V.jsx)(R,{size:13,className:`spin`}),` Checking context sizes…`]});let u=t.chosen==null?OD:String(t.chosen),d=t.chosen!=null&&t.loaded_ctx!=null&&t.loaded_ctx!==t.chosen;return(0,V.jsxs)(`div`,{className:`settings-field`,children:[(0,V.jsx)(`label`,{className:`settings-label`,htmlFor:`ctx-size`,children:`Context size`}),(0,V.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,V.jsxs)(`option`,{value:OD,children:[`Automatic`,t.automatic?` (${Ss(t.automatic)})`:``]}),t.options.map(e=>(0,V.jsxs)(`option`,{value:String(e),children:[Ss(e),` tokens`]},e))]}),(0,V.jsxs)(`span`,{className:`settings-hint`,children:[t.note??(t.max_fit?`Up to ${Ss(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 ${Ss(t.loaded_ctx)}.`]}),a&&(0,V.jsxs)(`span`,{className:`settings-hint`,children:[(0,V.jsx)(R,{size:13,className:`spin`}),` Applying…`]}),s&&(0,V.jsx)(`p`,{className:`settings-ok`,role:`status`,children:s}),r&&(0,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r})]})}function AD(){let[e,t]=(0,z.useState)(null),[n,r]=(0,z.useState)(null),[i,a]=(0,z.useState)(``),[o,s]=(0,z.useState)(!1),c=(0,z.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,z.useEffect)(()=>{c(Aa)},[c]),!e)return n?(0,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:n}):(0,V.jsxs)(`p`,{className:`settings-hint`,children:[(0,V.jsx)(R,{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,V.jsxs)(`section`,{className:`settings-field spending`,"aria-label":`Cloud spending`,children:[(0,V.jsx)(`span`,{className:`settings-label`,children:`Cloud spending this month`}),(0,V.jsxs)(`p`,{className:`spending-total`,children:[(0,V.jsx)(`strong`,{children:iC(e.total_usd)}),l!=null&&(0,V.jsxs)(V.Fragment,{children:[` of your `,iC(l),` limit`]}),(0,V.jsxs)(`span`,{className:`settings-hint`,children:[` · `,e.turns,` cloud `,e.turns===1?`chat turn`:`chat turns`,`, at list price`]})]}),e.unpriced_turns>0&&(0,V.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,V.jsxs)(`p`,{className:`spending-warning`,role:`status`,children:[(0,V.jsx)(An,{size:13,"aria-hidden":`true`}),` Close to your limit. GAIA stops before a cloud chat once it’s reached.`]}),e.state===`reached`&&(0,V.jsxs)(`div`,{className:`spending-warning`,role:`alert`,children:[(0,V.jsxs)(`p`,{children:[(0,V.jsx)(An,{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,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:o,onClick:()=>void c(Ma),children:`Allow more this month`})]}),e.state===`allowed_over`&&(0,V.jsx)(`p`,{className:`settings-hint`,children:`Over your limit; you allowed more for this month.`}),(0,V.jsxs)(`form`,{className:`settings-row`,onSubmit:e=>{e.preventDefault(),d&&f&&c(()=>ja(u))},children:[(0,V.jsx)(`label`,{className:`spending-limit-label`,htmlFor:`spend-limit`,children:`Monthly limit ($)`}),(0,V.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,V.jsxs)(`button`,{type:`submit`,className:`btn-secondary`,disabled:o||!d||!f,children:[o?(0,V.jsx)(R,{size:13,className:`spin`}):null,` Save`]}),l!=null&&(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:o,onClick:()=>void c(()=>ja(null)),children:`Remove limit`})]}),(0,V.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,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:n})]})}var jD=2e3;function MD(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 ND(e){return e.key_source===`environment`?`Blank uses the environment key`:e.key_source?`Blank keeps the saved key`:`Paste API key`}function PD(){let e=cs(e=>e.active),t=cs(e=>e.select),n=cs(e=>e.refresh),r=cs(e=>e.rememberNames),[i,a]=(0,z.useState)(null),[o,s]=(0,z.useState)(null),c=B(e=>e.settingsProvider),[l,u]=(0,z.useState)(c??e?.provider??`local`),[d,f]=(0,z.useState)(null),[p,m]=(0,z.useState)(null),[h,g]=(0,z.useState)(``),[_,v]=(0,z.useState)(!1),[y,b]=(0,z.useState)(``),[x,S]=(0,z.useState)({base_url:``,auth_header_name:``,auth_header_prefix:``}),[C,w]=(0,z.useState)(null),[T,E]=(0,z.useState)(null),[D,O]=(0,z.useState)(null),k=(0,z.useRef)(l);k.current=l;let ee=(0,z.useRef)(!0);(0,z.useEffect)(()=>()=>{ee.current=!1},[]);let A=i?.find(e=>e.id===l)??null,j=e=>e?.network?.reachable===!1,te=!!A&&(!A.remote||!!A.models_discovered),M=(0,z.useCallback)(async()=>{s(null);try{let e=await _a();a(e.providers),e.lemonade_error&&s(e.lemonade_error)}catch(e){s(e instanceof Error?e.message:String(e))}},[]),N=(0,z.useCallback)(async(e,t=!1)=>{t||(f(null),m(null));try{let t=await Ca(e);r(t.models),f(t.models),E(t.memory_gb?`${t.memory_gb} GB (${t.memory_source})`:t.capacity_error??null)}catch(e){m(e instanceof Error?e.message:String(e))}},[r]);(0,z.useEffect)(()=>{M()},[M]);let ne=!!i?.some(e=>e.key_state===`waiting_for_os_permission`);(0,z.useEffect)(()=>{if(!ne)return;let e=setInterval(()=>{M()},jD);return()=>clearInterval(e)},[ne,M]);let re=e?.provider;(0,z.useEffect)(()=>{re&&!c&&u(re)},[re,c]),(0,z.useEffect)(()=>{b(``),O(null),g(``),v(!1)},[l]),(0,z.useEffect)(()=>{te?N(l):f(null)},[l,te,N]);let ie=(0,z.useCallback)(async()=>{if(A){w(`connect`),O(null);try{let e=l===`amd`?{api_key:y||void 0,...Object.fromEntries(Object.entries(x).filter(([,e])=>e!==``))}:{api_key:y||void 0},t=()=>!ee.current||k.current!==l,n=await xa(l,e,e=>{t()||O({ok:!0,text:e})},t);if(t())return;b(``),O({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 M()}catch(e){ee.current&&k.current===l&&O({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{ee.current&&w(null)}}},[x,l,y,M,A]),F=(0,z.useCallback)(async()=>{w(`forget`),O(null);try{await Sa(l),O({ok:!0,text:`Key cleared, here and for future sessions. An environment key, if set, stays active.`}),await M(),await n()}catch(e){O({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{w(null)}},[l,M,n]),ae=(0,z.useCallback)(async e=>{w(e),O(null);try{await t(e),O({ok:!0,text:`New messages use ${us(e)}. It is remembered across restarts.`})}catch(e){O({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{w(null)}},[t]),oe=(0,z.useCallback)(async e=>{w(`dl:${e}`),O(null);try{await ra(e),await N(`local`,!0)}catch(e){O({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{w(null)}},[N]),se=!!d?.some(ws);(0,z.useEffect)(()=>{if(l!==`local`||!se)return;let e=setInterval(()=>{N(`local`,!0)},jD);return()=>clearInterval(e)},[se,l,N]);let ce=(0,z.useMemo)(()=>{let e=h.trim().toLowerCase();return(d??[]).filter(t=>!e||t.id.toLowerCase().includes(e)||(t.display_name??``).toLowerCase().includes(e))},[d,h]),le=ce.filter(e=>e.available!==!1),ue=l===`fireworks`&&!_&&!h.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),I=vs(d??[]),L=e&&!e.remote&&e.model?e.model:null,he=t=>{let n=e?.model===t.id,r=ws(t)?t.download_progress:null,i=[xs(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,V.jsxs)(`li`,{className:`model-row${n?` is-current`:``}`,children:[(0,V.jsxs)(`div`,{className:`model-row-text`,children:[(0,V.jsxs)(`span`,{className:`model-row-name`,title:t.id,children:[I[t.id],t.rank&&(0,V.jsxs)(`span`,{className:`model-row-rank`,children:[`#`,t.rank,` `,t.note]}),t.state===`loaded`&&(0,V.jsx)(`span`,{className:`model-badge is-loaded`,children:bs.loaded}),t.fits===!0&&t.available!==!1&&(0,V.jsx)(`span`,{className:`model-badge is-fit`,children:`Fits this PC`})]}),A?.remote&&(0,V.jsx)(`span`,{className:`model-row-meta${t.price?``:` is-unknown-price`}`,children:rC(t.price)}),t.display_name&&(0,V.jsx)(`span`,{className:`model-row-meta`,children:t.id}),i&&(0,V.jsx)(`span`,{className:`model-row-meta`,children:i}),t.placement?.warning&&(0,V.jsx)(`span`,{className:`model-row-meta is-warning`,role:`alert`,children:t.placement.warning}),t.unavailable_reason&&(0,V.jsxs)(`span`,{className:`model-row-meta`,children:[`Can't run here: `,t.unavailable_reason]}),t.evidence&&(0,V.jsxs)(`span`,{className:`model-row-meta`,children:[`Measured: `,t.evidence]}),r&&(0,V.jsx)(`progress`,{max:100,value:r.percent,"aria-label":`Downloading ${I[t.id]}`})]}),n?(0,V.jsxs)(`span`,{className:`model-row-current`,children:[(0,V.jsx)(P,{size:13,"aria-hidden":`true`}),` In use`]}):t.available===!1?null:r?(0,V.jsxs)(`span`,{className:`model-row-current`,children:[(0,V.jsx)(R,{size:13,className:`spin`}),` `,Math.round(r.percent),`%`]}):t.downloaded?(0,V.jsxs)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void ae(t.id),disabled:C!==null,"aria-label":`Use ${I[t.id]}`,children:[C===t.id?(0,V.jsx)(R,{size:13,className:`spin`}):null,` Use`]}):(0,V.jsxs)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void oe(t.id),disabled:C!==null,"aria-label":`Download ${I[t.id]}`,children:[C===`dl:${t.id}`?(0,V.jsx)(R,{size:13,className:`spin`}):null,` Download`]})]},t.id)};return(0,V.jsxs)(`div`,{className:`settings-pane`,children:[(0,V.jsx)(`h2`,{className:`settings-pane-title`,children:`Model`}),(0,V.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,V.jsx)(`div`,{className:`provider-tabs`,role:`radiogroup`,"aria-label":`Where GAIA runs`,children:(i??[{id:`local`,name:`Local`,remote:!1}]).map(e=>(0,V.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":l===e.id,className:`provider-tab${l===e.id?` is-active`:``}${j(e)?` is-disabled`:``}`,onClick:()=>u(e.id),disabled:j(e)&&l!==e.id,title:j(e)?e.network?.detail??void 0:void 0,children:[e.remote?(0,V.jsx)(ve,{size:14,"aria-hidden":`true`}):(0,V.jsx)(Ee,{size:14,"aria-hidden":`true`}),(0,V.jsx)(`span`,{children:e.name}),e.remote&&e.models_discovered&&(0,V.jsx)(`span`,{className:`provider-tab-dot`,"aria-label":`connected`})]},e.id))}),o&&(0,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:o}),A&&(0,V.jsxs)(`section`,{className:`settings-card`,"aria-label":A.name,children:[(0,V.jsx)(`p`,{className:`settings-note`,children:A.privacy_notice}),A.id===`local`&&(0,V.jsxs)(`p`,{className:`settings-hint`,children:[`Each model runs where it was built to: GGUF models on the GPU, FLM models on the NPU.`,T&&` Memory for models: ${T}.`]}),A.remote&&!te&&(0,V.jsxs)(`div`,{className:`settings-field`,children:[(0,V.jsx)(`span`,{className:`settings-label`,children:`Prices`}),(0,V.jsx)(JE,{provider:A.id})]}),j(A)&&(0,V.jsxs)(`div`,{className:`settings-field`,children:[(0,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:A.network?.detail}),(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void M(),children:`Check again`})]}),A.remote&&!j(A)&&(0,V.jsxs)(`form`,{className:`settings-field`,onSubmit:e=>{e.preventDefault(),ie()},children:[(0,V.jsx)(`span`,{className:`settings-label`,children:`API key`}),(0,V.jsx)(`span`,{className:`settings-hint`,children:MD(A)}),A.id===`amd`&&(0,V.jsxs)(`div`,{className:`settings-grid`,children:[(0,V.jsx)(`input`,{className:`settings-input`,placeholder:`Gateway URL (default https://llm-api.amd.com/Unified/v1)`,value:x.base_url,onChange:e=>S({...x,base_url:e.target.value}),"aria-label":`Gateway URL`}),(0,V.jsx)(`input`,{className:`settings-input`,placeholder:`Auth header (default Ocp-Apim-Subscription-Key)`,value:x.auth_header_name,onChange:e=>S({...x,auth_header_name:e.target.value}),"aria-label":`Auth header name`})]}),(0,V.jsxs)(`div`,{className:`settings-row`,children:[(0,V.jsx)(`input`,{className:`settings-input`,type:`password`,autoComplete:`off`,spellCheck:!1,value:y,onChange:e=>b(e.target.value),placeholder:ND(A),"aria-label":`${A.name} API key`}),(0,V.jsxs)(`button`,{type:`submit`,className:`btn-primary`,disabled:C!==null||!y&&!A.key_source,children:[C===`connect`?(0,V.jsx)(R,{size:13,className:`spin`}):null,A.models_discovered?`Reconnect`:`Connect`]}),(A.key_source===`lemonade`||A.key_source===`stored`)&&(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void F(),disabled:C!==null,children:`Forget key`})]}),A.error&&(0,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:A.error})]}),D&&(0,V.jsx)(`p`,{className:D.ok?`settings-ok`:`settings-error`,role:D.ok?`status`:`alert`,children:D.text}),A.id===`local`&&L&&e?.downloaded!==!1&&(0,V.jsx)(kD,{model:L}),te&&(0,V.jsxs)(`div`,{className:`settings-field`,children:[(0,V.jsx)(`span`,{className:`settings-label`,children:`Models`}),(d?.length??0)>6&&(0,V.jsx)(`input`,{className:`settings-input`,type:`search`,value:h,onChange:e=>g(e.target.value),placeholder:`Search models`,"aria-label":`Search models`}),p&&(0,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:p}),!d&&!p&&(0,V.jsxs)(`p`,{className:`settings-hint`,children:[(0,V.jsx)(R,{size:13,className:`spin`}),` Loading…`]}),d&&ce.length===0&&(0,V.jsx)(`p`,{className:`settings-hint`,children:`No models match.`}),(0,V.jsx)(`ul`,{className:`model-list`,children:fe.map(he)}),ue&&pe.length>0&&(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>v(!0),children:`Show all models`}),l===`fireworks`&&_&&!h.trim()&&(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>v(!1),children:`Show recommended models`}),me.length>0&&(0,V.jsxs)(`details`,{className:`model-unavailable`,children:[(0,V.jsxs)(`summary`,{children:[`Not available on this PC (`,me.length,`)`]}),(0,V.jsx)(`ul`,{className:`model-list`,children:me.map(he)})]})]}),A.remote&&(0,V.jsx)(AD,{})]})]})}function FD(){let e=B(e=>e.sessions),[t,n]=(0,z.useState)(null),[r,i]=(0,z.useState)(null),a=(0,z.useCallback)(async()=>{i(null);try{n((await Fi()).sessions)}catch(e){i(e instanceof Error?e.message:String(e))}},[]);(0,z.useEffect)(()=>{a()},[a]);let o=(0,z.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,V.jsxs)(`div`,{className:`settings-pane`,children:[(0,V.jsx)(`h2`,{className:`settings-pane-title`,children:`Permissions`}),(0,V.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,V.jsxs)(`p`,{className:`settings-hint`,children:[`New chats start in full access only when `,(0,V.jsx)(`code`,{children:`full_access`}),` is set in`,(0,V.jsx)(`code`,{children:` ~/.gaia/config.json`}),` (the TUI’s `,(0,V.jsx)(`code`,{children:`/full-access always`}),`).`]}),r&&(0,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r}),t&&t.length===0&&(0,V.jsx)(`p`,{className:`settings-hint`,children:`No chat has full access or anything allowed without asking.`}),t?.map(e=>(0,V.jsxs)(`section`,{className:`settings-card`,"aria-label":s(e.session_id),children:[(0,V.jsxs)(`div`,{className:`settings-row settings-row-between`,children:[(0,V.jsx)(`span`,{className:`settings-label`,children:s(e.session_id)}),e.mode===`full_access`&&(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>o(async()=>{let t=(await Ii(e.session_id,`ask`)).mode;fC(e.session_id,t)}),children:`Turn off full access`})]}),e.grants.length>0&&(0,V.jsx)(`ul`,{className:`grant-list`,children:e.grants.map(t=>(0,V.jsxs)(`li`,{className:`grant-row`,children:[(0,V.jsx)(`code`,{children:t.label}),(0,V.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>o(()=>Li(e.session_id,t.key)),"aria-label":`Revoke ${t.label}`,children:`Revoke`})]},t.key))}),e.grants.length>1&&(0,V.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>o(()=>Li(e.session_id)),children:`Revoke all in this chat`})]},e.session_id))]})}var ID=[{source:`agent-bundled`,title:`Built into GAIA`,note:`Ship with GAIA.`},{source:`user`,title:`Yours`,note:`From your ~/.gaia/skills folder.`,empty:`None yet. Add a folder with a SKILL.md file to ~/.gaia/skills and reopen this page.`},{source:`claude-import`,title:`From Claude Code`,note:`Found in your Claude Code skill folders. GAIA reads them in place and does not change them.`}];function LD({onUseSkill:e}){let[t,n]=(0,z.useState)(null),[r,i]=(0,z.useState)({}),[a,o]=(0,z.useState)(null),[s,c]=(0,z.useState)(``);(0,z.useEffect)(()=>{let e=!1;return Na().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)),d=t?.every(e=>e.source)??!1,f=t=>(0,V.jsxs)(`li`,{className:`skill-row`,children:[(0,V.jsxs)(`div`,{className:`skill-row-text`,children:[(0,V.jsxs)(`span`,{className:`skill-row-name`,children:[t.name,t.version&&(0,V.jsxs)(`span`,{className:`skill-row-meta`,children:[` v`,t.version]}),t.always_on&&(0,V.jsx)(`span`,{className:`skill-row-meta`,children:` · Always on`})]}),(0,V.jsx)(`span`,{className:`skill-row-desc`,children:t.description})]}),!t.always_on&&(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>e(t.name),"aria-label":`Use ${t.name} in a new chat`,children:`Use`})]},t.name);return(0,V.jsxs)(`div`,{className:`settings-pane`,children:[(0,V.jsx)(`h2`,{className:`settings-pane-title`,children:`Skills`}),(0,V.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. Your own skills go in `,(0,V.jsx)(`code`,{children:`~/.gaia/skills`}),`, one folder each with a `,(0,V.jsx)(`code`,{children:`SKILL.md`}),` file.`]}),a&&(0,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:a}),!t&&!a&&(0,V.jsxs)(`p`,{className:`settings-hint`,children:[(0,V.jsx)(R,{size:13,className:`spin`}),` Loading…`]}),t&&t.length>6&&(0,V.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,V.jsx)(`p`,{className:`settings-hint`,children:`No skills are installed.`}),d?ID.map(e=>{let n=u.filter(t=>t.source===e.source),r=(t??[]).filter(t=>t.source===e.source).length;return n.length===0&&(l||!e.empty)?null:(0,V.jsxs)(`section`,{className:`skill-group`,"aria-label":e.title,children:[(0,V.jsxs)(`h3`,{className:`skill-group-title`,children:[e.title,` `,(0,V.jsx)(`span`,{className:`skill-row-meta`,children:r})]}),(0,V.jsx)(`p`,{className:`settings-hint`,children:e.note}),n.length===0?(0,V.jsx)(`p`,{className:`settings-hint`,children:e.empty}):(0,V.jsx)(`ul`,{className:`skill-list`,children:n.map(f)})]},e.source)}):(0,V.jsx)(`ul`,{className:`skill-list`,children:u.map(f)}),Object.keys(r).length>0&&(0,V.jsxs)(`div`,{className:`settings-card`,role:`alert`,children:[(0,V.jsx)(`span`,{className:`settings-label`,children:`Skipped, could not be read`}),(0,V.jsx)(`ul`,{className:`grant-list`,children:Object.entries(r).map(([e,t])=>(0,V.jsxs)(`li`,{children:[(0,V.jsx)(`code`,{children:e}),` — `,t]},e))})]})]})}function RD(){let e=B(e=>e.setShowMemoryDashboard),t=B(e=>e.closeSettings),[n,r]=(0,z.useState)(null),[i,a]=(0,z.useState)(null),[o,s]=(0,z.useState)(!1);(0,z.useEffect)(()=>{xE().then(r).catch(e=>a(e instanceof Error?e.message:String(e)))},[]);let c=(0,z.useCallback)(async()=>{if(n){s(!0),a(null);try{r(await SE({memory_enabled:!n.memory_enabled}))}catch(e){a(e instanceof Error?e.message:String(e))}finally{s(!1)}}},[n]);return(0,V.jsxs)(`div`,{className:`settings-pane`,children:[(0,V.jsx)(`h2`,{className:`settings-pane-title`,children:`Memory`}),(0,V.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,V.jsxs)(`label`,{className:`setting-row`,children:[(0,V.jsx)(`span`,{children:`Remember across chats`}),(0,V.jsxs)(`span`,{className:`toggle-switch`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:!!n?.memory_enabled,onChange:()=>void c(),disabled:!n||o,"aria-label":`Remember across chats`}),(0,V.jsx)(`span`,{className:`toggle-track`})]})]}),i&&(0,V.jsx)(`p`,{className:`settings-error`,role:`alert`,children:i}),(0,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{t(),e(!0)},children:`Open the memory dashboard`}),(0,V.jsx)(`p`,{className:`settings-hint`,children:`Search, edit and forget what GAIA remembers.`})]})}var zD=`Keep for: enter a whole number of days from 1 to 365.`,BD=`Use at most: enter a whole number of MB from 10 to 100,000.`;function VD(e,t,n){if(!/^\d+$/.test(e.trim()))return!1;let r=Number(e);return r>=t&&r<=n}function HD(e){return e<1048576?`${Math.ceil(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function UD(){let[e,t]=(0,z.useState)(null),[n,r]=(0,z.useState)(``),[i,a]=(0,z.useState)(``),[o,s]=(0,z.useState)(null),[c,l]=(0,z.useState)(!1);(0,z.useEffect)(()=>{W().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,z.useState)({days:!1,mb:!1}),f=!VD(n,1,365)||u.days,p=!VD(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 Bo(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 Hi&&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,V.jsxs)(`div`,{className:`settings-field`,"aria-label":`Undo history`,children:[(0,V.jsx)(`span`,{className:`settings-label`,children:`Undo history`}),(0,V.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,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`setting-row`,children:[(0,V.jsx)(`label`,{htmlFor:`undo-days`,children:`Keep for (days)`}),(0,V.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,V.jsx)(`p`,{id:`undo-days-error`,className:`settings-error`,children:zD}),(0,V.jsxs)(`div`,{className:`setting-row`,children:[(0,V.jsx)(`label`,{htmlFor:`undo-mb`,children:`Use at most (MB)`}),(0,V.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,V.jsx)(`p`,{id:`undo-mb-error`,className:`settings-error`,children:BD}),(0,V.jsxs)(`div`,{className:`setting-row setting-row-path`,children:[(0,V.jsx)(`span`,{children:`In use`}),(0,V.jsxs)(`span`,{children:[HD(e.used_bytes),` for `,e.turns,` turn`,e.turns===1?``:`s`,` `,`in `,(0,V.jsx)(`code`,{className:`setting-path`,children:e.path})]})]}),(0,V.jsx)(`button`,{type:`button`,className:`btn-model-save`,onClick:()=>void h(),disabled:!m||c||f||p,children:c?`Saving…`:`Save`})]}),o&&(0,V.jsx)(`p`,{className:o.ok?`settings-ok`:`settings-error`,role:o.ok?`status`:`alert`,children:o.text})]})}function WD(){let e=B(e=>e.sessions),t=B(e=>e.removeSession),n=ms(),r=B(e=>e.systemStatus?.data_dir),[i,a]=(0,z.useState)(!1),[o,s]=(0,z.useState)(null),c=(0,z.useRef)(null);(0,z.useEffect)(()=>()=>{c.current&&clearTimeout(c.current)},[]);let l=(0,z.useCallback)(async()=>{if(!i){a(!0),c.current=setTimeout(()=>a(!1),4e3);return}a(!1);let n=[];for(let r of e)try{await La(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,V.jsxs)(`div`,{className:`settings-pane`,children:[(0,V.jsx)(`h2`,{className:`settings-pane-title`,children:`Privacy`}),(0,V.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,V.jsxs)(`div`,{className:`setting-row`,children:[(0,V.jsx)(`span`,{children:`Data folder`}),(0,V.jsx)(`code`,{className:`setting-path`,children:r})]}),(0,V.jsx)(UD,{}),(0,V.jsx)(`div`,{className:`danger-divider`}),(0,V.jsx)(`p`,{className:`danger-warning`,children:`Deletes every chat and its messages. Documents and memory are kept.`}),(0,V.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,V.jsx)(`p`,{className:o.ok?`settings-ok`:`settings-error`,role:o.ok?`status`:`alert`,children:o.text})]})}var GD=[{id:`needs_approval`,label:`Needs your approval`},{id:`question`,label:`Has a question`},{id:`finished`,label:`Finished`}],KD=[{value:`banner`,label:`Banner`},{value:`badge`,label:`Badge`},{value:`off`,label:`Off`}],qD=[0,10,20,30,50];function JD(){return typeof Notification>`u`?`unsupported`:Notification.permission}function YD(){let e=Zs(),t=!!window.gaiaAPI,[n,r]=(0,z.useState)(JD),i=Object.values(e.modes).includes(`banner`);return(0,V.jsxs)(`div`,{className:`settings-pane`,children:[(0,V.jsx)(`h2`,{className:`settings-pane-title`,children:`Notifications`}),(0,V.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.`}),GD.map(t=>(0,V.jsxs)(`div`,{className:`setting-row`,children:[(0,V.jsx)(`span`,{id:`alert-${t.id}`,children:t.label}),(0,V.jsx)(`div`,{className:`segmented`,role:`radiogroup`,"aria-labelledby":`alert-${t.id}`,children:KD.map(n=>(0,V.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,V.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{Notification.requestPermission().then(r).catch(e=>{console.error(`[alerts] Notification permission request failed`,e),r(JD())})},children:`Allow banners in this browser`}):(0,V.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,V.jsxs)(`label`,{className:`setting-row`,children:[(0,V.jsx)(`span`,{children:`Play a sound`}),(0,V.jsxs)(`span`,{className:`toggle-switch`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:e.sound,onChange:()=>e.update({sound:!e.sound}),"aria-label":`Play a sound`}),(0,V.jsx)(`span`,{className:`toggle-track`})]})]}),t&&(0,V.jsxs)(`label`,{className:`setting-row`,children:[(0,V.jsx)(`span`,{children:`Flash the taskbar when GAIA isn't focused`}),(0,V.jsxs)(`span`,{className:`toggle-switch`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:e.flash,onChange:()=>e.update({flash:!e.flash}),"aria-label":`Flash the taskbar when GAIA isn't focused`}),(0,V.jsx)(`span`,{className:`toggle-track`})]})]}),(0,V.jsx)(`h3`,{className:`settings-label`,children:`Keep awake`}),t?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`label`,{className:`setting-row`,children:[(0,V.jsx)(`span`,{children:`Keep the PC awake while GAIA works`}),(0,V.jsxs)(`span`,{className:`toggle-switch`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:e.keepAwake,onChange:()=>e.update({keepAwake:!e.keepAwake}),"aria-label":`Keep the PC awake while GAIA works`}),(0,V.jsx)(`span`,{className:`toggle-track`})]})]}),(0,V.jsxs)(`div`,{className:`setting-row`,children:[(0,V.jsx)(`label`,{htmlFor:`battery-floor`,children:`On battery, let it sleep below`}),(0,V.jsx)(`select`,{id:`battery-floor`,value:e.batteryFloor,disabled:!e.keepAwake,onChange:t=>e.update({batteryFloor:Number(t.target.value)}),children:qD.map(e=>(0,V.jsx)(`option`,{value:e,children:e===0?`Never`:`${e}%`},e))})]}),(0,V.jsx)(`p`,{className:`settings-hint`,children:`The screen can still turn off; only sleep is held off.`})]}):(0,V.jsx)(`p`,{className:`settings-hint`,children:`Keep-awake needs the GAIA desktop app.`})]})}var XD=`modulepreload`,ZD=function(e,t){return new URL(e,t).href},QD={},$D=function(e){return e.pathname.endsWith(`.css`)},eO=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},tO=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=ZD(t,n);let r=s(t),i=$D(r);return eO(QD,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`:XD,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)})},nO=(0,z.lazy)(()=>tO(()=>import(`./ConnectorsPane-C8w7-TvW.js`).then(e=>({default:e.ConnectorsPane})),__vite__mapDeps([0,1,2,3]),import.meta.url)),rO=(0,z.lazy)(()=>tO(()=>import(`./AdvancedSettings-BtzKYr5B.js`).then(e=>({default:e.AdvancedSettings})),__vite__mapDeps([4,1,2]),import.meta.url)),iO=[{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 aO({onUseSkill:e}){let t=B(e=>e.settingsSection),n=B(e=>e.openSettings),r=B(e=>e.closeSettings),i=(0,z.useRef)(null),a=(0,z.useRef)(null),o=t!==null;if(ei(o,r),fx(i,o),(0,z.useEffect)(()=>{if(o)return a.current=document.activeElement,()=>{a.current?.focus?.()}},[o,r]),(0,z.useEffect)(()=>{o&&i.current?.querySelector(`.settings-nav-item.is-active`)?.focus()},[o]),!t)return null;let s=(()=>{switch(t){case`general`:return(0,V.jsx)(DD,{});case`model`:return(0,V.jsx)(PD,{});case`permissions`:return(0,V.jsx)(FD,{});case`skills`:return(0,V.jsx)(LD,{onUseSkill:t=>{r(),e(t)}});case`connectors`:return(0,V.jsx)(nO,{});case`memory`:return(0,V.jsx)(RD,{});case`notifications`:return(0,V.jsx)(YD,{});case`privacy`:return(0,V.jsx)(WD,{});case`advanced`:return(0,V.jsx)(rO,{})}})();return(0,V.jsx)(`div`,{className:`settings-overlay`,onMouseDown:e=>{e.target===e.currentTarget&&r()},children:(0,V.jsxs)(`div`,{ref:i,className:`settings-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Settings`,children:[(0,V.jsxs)(`nav`,{className:`settings-nav`,"aria-label":`Settings sections`,children:[(0,V.jsx)(`h1`,{className:`settings-nav-title`,children:`Settings`}),iO.map(e=>(0,V.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,V.jsxs)(`div`,{className:`settings-body`,children:[(0,V.jsx)(`button`,{type:`button`,className:`settings-close`,onClick:r,"aria-label":`Close settings`,children:(0,V.jsx)(Bn,{size:18})}),(0,V.jsx)(z.Suspense,{fallback:(0,V.jsxs)(`p`,{className:`settings-hint`,children:[(0,V.jsx)(R,{size:13,className:`spin`}),` Loading…`]}),children:s})]})]})})}function oO(e,t){let[n,r]=(0,z.useState)(!1),[i,a]=(0,z.useState)(!1),o=(0,z.useRef)(null),c=(0,z.useRef)(null),l=(0,z.useRef)(null),u=(0,z.useCallback)(()=>{o.current&&=(clearTimeout(o.current),null),c.current&&=(clearTimeout(c.current),null),l.current&&=(clearInterval(l.current),null)},[]);(0,z.useEffect)(()=>u,[u]);let d=(0,z.useCallback)((e,t)=>{l.current&&clearInterval(l.current),l.current=setInterval(async()=>{try{let n=await Yi();t===`load`?n.model_loaded?.toLowerCase()===e.toLowerCase()&&(r(!1),o.current&&=(clearTimeout(o.current),null),l.current&&=(clearInterval(l.current),null)):(n.model_downloaded===!0||n.model_loaded?.toLowerCase()===e.toLowerCase())&&(a(!1),c.current&&=(clearTimeout(c.current),null),l.current&&=(clearInterval(l.current),null))}catch{}},Tc)},[]),f=e??`Gemma-4-E4B-it-GGUF`;return{isLoadingModel:n,isDownloadingModel:i,loadModel:(0,z.useCallback)(async(e,t)=>{let n=e??f,i=t??32768;r(!0);try{if(!await na(n,i)){r(!1);return}s.system.info(`Load model triggered: ${n} (ctx=${i})`),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>r(!1),Cc),d(n,`load`)}catch(e){s.system.error(`Failed to trigger model load`,e),r(!1)}},[f,t,d]),downloadModel:(0,z.useCallback)(async(e=!1,t)=>{let n=t??f;a(!0);try{await ra(n,e),s.system.info(`Download model triggered: ${n} (force=${e})`),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>a(!1),wc),d(n,`download`)}catch(e){s.system.error(`Failed to trigger model download`,e),a(!1)}},[f,d])}}var sO=5e3,cO=2e3,lO=3e4,uO=6e4;function dO(e){return e.lemonade_running?`up`:e.lemonade_error?`unresponsive`:`down`}function fO(e){return e.kind===`slow`||e.kind===`error`||e.kind===`ok`&&dO(e.status)===`unresponsive`}function pO(e){let t=e.kind===`ok`?e.status.download_progress?.state:void 0;return t===`downloading`||t===`starting`}function mO(e){let t=null,n=0,r=!1,i=null,a=0,o=null,c=async()=>{let e={controller:new AbortController,cancelled:!1};o=e;let{controller:t}=e,n=setTimeout(()=>t.abort(),uO);try{return{kind:`ok`,status:await Yi(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)}},l=()=>{if(t)return t;let i=c().then(t=>{if(t!==null){n=fO(t)?n+1:0,r=pO(t);try{e(t)}catch(e){s.system.error(`Could not apply the system status; the next poll will try again`,e)}}}).finally(()=>{t===i&&(t=null)});return t=i,i},u=()=>Math.min((r?cO:sO)*2**n,lO),d=e=>{l().finally(()=>{e===a&&(i=setTimeout(()=>d(e),u()))})};return{check:l,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 hO({onRetry:e,label:t}){let[n,r]=(0,z.useState)(!1);return(0,V.jsx)(`button`,{className:`connection-banner__retry`,onClick:()=>{r(!0),Promise.resolve(e()).finally(()=>r(!1))},disabled:n,children:n?`Checking…`:t})}function gO({onRetry:e,backendSlow:t=!1,backendError:n=null}){let{backendConnected:r,systemStatus:i,currentSessionId:a,messages:o}=B(),[s,c]=(0,z.useState)(!1),l=!!a&&o.length>0,u=i?.default_model_name??`Gemma-4-E4B-it-GGUF`,{isDownloadingModel:d,downloadModel:f}=oO(u),p=(0,z.useRef)(i?.lemonade_running),m=(0,z.useRef)(i?.model_downloaded),h=(0,z.useRef)(i?.context_size_sufficient),g=(0,z.useRef)(i?.expected_model_loaded);(0,z.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,V.jsxs)(`div`,{className:`connection-banner ${t?`connection-banner--error`:`connection-banner--warning`}`,role:t?`alert`:`status`,children:[(0,V.jsx)(`div`,{className:`connection-banner__icon`,children:t?(0,V.jsx)(An,{size:16}):(0,V.jsx)(Ae,{size:16})}),(0,V.jsx)(`div`,{className:`connection-banner__text`,children:t?(0,V.jsxs)(V.Fragment,{children:[`Download of `,(0,V.jsx)(`strong`,{children:v}),` failed.`,` `,_?.message&&(0,V.jsx)(`span`,{className:`connection-banner__hint`,children:_.message})]}):(0,V.jsxs)(V.Fragment,{children:[`Downloading `,(0,V.jsx)(`strong`,{children:v}),` (`,e,`).`,_?.state===`downloading`&&_.file&&(0,V.jsxs)(V.Fragment,{children:[` `,(0,V.jsxs)(`span`,{className:`connection-banner__hint`,children:[`File `,_.file_index,` / `,_.total_files,`: `,(0,V.jsx)(`code`,{children:_.file})]})]})]})}),t?(0,V.jsx)(`button`,{className:`connection-banner__retry`,onClick:()=>f(!1,v),children:`Retry`}):(0,V.jsx)(`span`,{className:`connection-banner__loading connection-banner__progress`,children:_&&_.state===`downloading`&&_.total_bytes>0?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`connection-banner__progress-bar`,role:`progressbar`,"aria-valuenow":_.percent,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`Download progress`,children:(0,V.jsx)(`span`,{className:`connection-banner__progress-fill`,style:{width:`${_.percent}%`}})}),(0,V.jsxs)(`span`,{className:`connection-banner__progress-label`,children:[_.percent,`% ·`,` `,(_.downloaded_bytes/1e9).toFixed(2),` /`,` `,(_.total_bytes/1e9).toFixed(2),` GB`]})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(R,{size:13,className:`connection-banner__spinner`}),_?.state===`starting`?`Starting download…`:`Downloading…`]})}),t&&(0,V.jsx)(`button`,{className:`connection-banner__dismiss`,onClick:()=>c(!0),"aria-label":`Dismiss`,children:(0,V.jsx)(Bn,{size:14})})]})}if(i?.init_state===`initializing`){let e=i.init_tasks?.find(e=>e.status===`running`)?.name||`Preparing AI system`;return(0,V.jsxs)(`div`,{className:`connection-banner connection-banner--init`,role:`status`,children:[(0,V.jsx)(`div`,{className:`connection-banner__icon`,children:(0,V.jsx)(R,{size:16,className:`connection-banner__spinner`})}),(0,V.jsxs)(`div`,{className:`connection-banner__text`,children:[e,(0,V.jsxs)(`span`,{className:`thinking-dots`,children:[(0,V.jsx)(`span`,{children:`.`}),(0,V.jsx)(`span`,{children:`.`}),(0,V.jsx)(`span`,{children:`.`})]})]})]})}if(s||l)return null;if(!r)return(0,V.jsxs)(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[(0,V.jsx)(`div`,{className:`connection-banner__icon`,children:(0,V.jsx)(In,{size:16})}),(0,V.jsxs)(`div`,{className:`connection-banner__text`,children:[`Lost the connection to GAIA.`,` `,(0,V.jsx)(`span`,{className:`connection-banner__hint`,children:`Check that GAIA is still running, then retry.`})]}),e&&(0,V.jsx)(hO,{onRetry:e,label:`Retry`})]});if(n)return(0,V.jsxs)(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[(0,V.jsx)(`div`,{className:`connection-banner__icon`,children:(0,V.jsx)(An,{size:16})}),(0,V.jsxs)(`div`,{className:`connection-banner__text`,children:[`GAIA's backend answered with an error (`,n,`).`,` `,(0,V.jsx)(`span`,{className:`connection-banner__hint`,children:`It may be overloaded. GAIA keeps checking; if it lasts, restart GAIA.`})]}),e&&(0,V.jsx)(hO,{onRetry:e,label:`Check again`})]});if(t)return(0,V.jsxs)(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[(0,V.jsx)(`div`,{className:`connection-banner__icon`,children:(0,V.jsx)(An,{size:16})}),(0,V.jsxs)(`div`,{className:`connection-banner__text`,children:[`GAIA is slow to answer.`,` `,(0,V.jsx)(`span`,{className:`connection-banner__hint`,children:`It may be busy with another chat or app. GAIA keeps checking.`})]}),e&&(0,V.jsx)(hO,{onRetry:e,label:`Check again`})]});if(i?.config_error)return(0,V.jsxs)(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[(0,V.jsx)(`div`,{className:`connection-banner__icon`,children:(0,V.jsx)(An,{size:16})}),(0,V.jsxs)(`div`,{className:`connection-banner__text`,children:[`GAIA settings could not be loaded.`,` `,(0,V.jsx)(`span`,{className:`connection-banner__hint`,children:i.config_error})]}),e&&(0,V.jsx)(hO,{onRetry:e,label:`Check again`})]});if(i&&!i.lemonade_running){let t=dO(i)===`unresponsive`;return(0,V.jsxs)(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[(0,V.jsx)(`div`,{className:`connection-banner__icon`,children:(0,V.jsx)(An,{size:16})}),(0,V.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 isn't running.`,` `,i.start_command?(0,V.jsxs)(`span`,{className:`connection-banner__hint`,children:[t?`If it stays this way, restart it: `:`To start it by hand, run `,(0,V.jsx)(`code`,{children:i.start_command})]}):i.start_instruction&&(0,V.jsx)(`span`,{className:`connection-banner__hint`,children:i.start_instruction})]}),e&&(0,V.jsx)(hO,{onRetry:e,label:`Check again`}),(0,V.jsx)(`button`,{className:`connection-banner__dismiss`,onClick:()=>c(!0),"aria-label":`Dismiss`,children:(0,V.jsx)(Bn,{size:14})})]})}if(i&&i.lemonade_running&&i.model_loaded&&i.context_size_sufficient===!1){let t=i.model_context_size??0;return(0,V.jsxs)(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[(0,V.jsx)(`div`,{className:`connection-banner__icon`,children:(0,V.jsx)(bt,{size:16})}),(0,V.jsxs)(`div`,{className:`connection-banner__text`,children:[`LLM context window is too small (`,t.toLocaleString(),` tokens;`,` `,xc.toLocaleString(),` required).`,` `,(0,V.jsx)(`span`,{className:`connection-banner__hint`,children:`Reload it with a larger context in Settings → Advanced.`})]}),e&&(0,V.jsx)(hO,{onRetry:e,label:`Check again`}),(0,V.jsx)(`button`,{className:`connection-banner__dismiss`,onClick:()=>c(!0),"aria-label":`Dismiss`,children:(0,V.jsx)(Bn,{size:14})})]})}return null}function _O(){let e=_D(),[t,n]=(0,z.useState)(!1),[r,i]=(0,z.useState)(null),a=(0,z.useCallback)(e=>{let t=hD();t&&(i(null),t[e]().catch(t=>{let n=t instanceof Error?t.message:String(t);s.system.error(`Update ${e} failed`,t),i(n)}))},[]);if(t||e.status===`idle`||e.status===`checking`||e.status===`disabled`||e.status===`no-channel`)return null;if(e.status===`downloading`){let t=Math.max(0,Math.min(100,e.progress));return(0,V.jsxs)(`div`,{className:`update-chip update-chip--downloading`,role:`status`,"aria-live":`polite`,title:`Downloading update${e.version?` ${e.version}`:``}…`,children:[(0,V.jsx)(Ae,{size:13,className:`update-chip__icon`}),(0,V.jsxs)(`span`,{className:`update-chip__label`,children:[`Downloading update… `,t,`%`]})]})}return e.status===`available`?(0,V.jsxs)(`div`,{className:`update-chip update-chip--available`,role:`status`,title:r||e.releaseNotes||`A new version is available.`,children:[(0,V.jsx)(Ae,{size:13,className:`update-chip__icon`}),(0,V.jsx)(`span`,{className:`update-chip__label`,children:r?`Update failed — try again`:`GAIA ${e.version??``} is available`}),!e.pinnedVersion&&(0,V.jsx)(`button`,{type:`button`,className:`update-chip__action`,onClick:()=>a(`downloadUpdate`),children:`Update now`}),(0,V.jsx)(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>n(!0),"aria-label":`Dismiss update notification`,children:(0,V.jsx)(Bn,{size:11})})]}):e.status===`downloaded`?(0,V.jsxs)(`div`,{className:`update-chip update-chip--ready`,role:`status`,"aria-live":`polite`,children:[(0,V.jsx)(tn,{size:13,className:`update-chip__icon`}),(0,V.jsx)(`button`,{type:`button`,className:`update-chip__action`,onClick:()=>a(`restart`),title:r||`Click to restart and apply the update`,children:r?`Restart failed — try again`:`Update ready — restart to apply`})]}):e.status===`error`?(0,V.jsxs)(`div`,{className:`update-chip update-chip--error`,role:`status`,title:e.error||`Update check failed.`,children:[(0,V.jsx)(An,{size:13,className:`update-chip__icon`}),(0,V.jsx)(`span`,{className:`update-chip__label`,children:`Update check failed`}),(0,V.jsx)(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>n(!0),"aria-label":`Dismiss update error`,children:(0,V.jsx)(Bn,{size:11})})]}):null}var vO={permission_request:{icon:(0,V.jsx)(un,{size:16}),colorClass:`notif-type-permission`,label:`Permission`},policy_alert:{icon:(0,V.jsx)(un,{size:16}),colorClass:`notif-type-policy`,label:`Policy`},security_alert:{icon:(0,V.jsx)(An,{size:16}),colorClass:`notif-type-security`,label:`Security`},status_change:{icon:(0,V.jsx)(ue,{size:16}),colorClass:`notif-type-status`,label:`Status`},info:{icon:(0,V.jsx)(gt,{size:16}),colorClass:`notif-type-info`,label:`Info`},error:{icon:(0,V.jsx)(ce,{size:16}),colorClass:`notif-type-error`,label:`Error`}};function yO(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 bO({onClose:e}){let t=G(qn(Hs)),n=G(Vs),r=G(e=>e.markRead),i=G(e=>e.markAllRead),a=G(e=>e.clearAll),o=G(e=>e.dismiss),s=G(e=>e.respondToPermission),c=G(e=>e.typeFilter),l=G(e=>e.setTypeFilter),u=(0,z.useCallback)(e=>{r(e)},[r]),d=(0,z.useCallback)(e=>{s(e.id,`allow`).catch(e=>console.error(`[NotificationCenter] allow failed:`,e))},[s]),f=(0,z.useCallback)(e=>{s(e.id,`deny`).catch(e=>console.error(`[NotificationCenter] deny failed:`,e))},[s]);return ei(!0,e),(0,V.jsxs)(`div`,{className:`notification-center`,role:`dialog`,"aria-label":`Notification Center`,children:[(0,V.jsxs)(`div`,{className:`notification-center-header`,children:[(0,V.jsxs)(`div`,{className:`notification-center-title-row`,children:[(0,V.jsx)(`h2`,{className:`notification-center-title`,children:`Notifications`}),n>0&&(0,V.jsx)(`span`,{className:`notification-center-badge`,children:n})]}),(0,V.jsx)(`button`,{className:`btn-icon notification-center-close`,onClick:e,"aria-label":`Close notification center`,children:(0,V.jsx)(Bn,{size:18})})]}),(0,V.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,V.jsx)(`button`,{role:`tab`,"aria-selected":c===e.key,className:`notification-filter-tab ${c===e.key?`active`:``}`,onClick:()=>l(e.key),children:e.label},e.key??`all`))}),(0,V.jsx)(`div`,{className:`notification-list`,children:t.length===0?(0,V.jsxs)(`div`,{className:`notification-empty`,children:[(0,V.jsx)(w,{size:40,strokeWidth:1.2}),(0,V.jsx)(`span`,{children:`No notifications`})]}):t.map(e=>{let t=vO[e.type];return(0,V.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:()=>u(e.id),role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&u(e.id)},children:[!e.read&&(0,V.jsx)(`span`,{className:`notification-unread-dot`}),(0,V.jsx)(`span`,{className:`notification-icon`,children:t.icon}),(0,V.jsxs)(`div`,{className:`notification-content`,children:[(0,V.jsxs)(`div`,{className:`notification-content-header`,children:[(0,V.jsx)(`span`,{className:`notification-agent`,children:e.agentName}),(0,V.jsx)(`span`,{className:`notification-time`,children:yO(e.timestamp)})]}),e.title&&(0,V.jsx)(`span`,{className:`notification-title`,children:e.title}),(0,V.jsx)(`span`,{className:`notification-message`,children:e.message}),e.type===`permission_request`&&e.tool&&e.tool!==`allow_path_access`&&(0,V.jsxs)(`span`,{className:`notification-tool`,children:[`Tool: `,(0,V.jsx)(`code`,{children:e.tool})]}),e.type===`policy_alert`&&(0,V.jsxs)(`div`,{className:`notification-policy-details`,children:[e.tool&&(0,V.jsxs)(`span`,{className:`notification-tool`,children:[`Tool: `,(0,V.jsx)(`code`,{children:e.tool})]}),e.reason&&(0,V.jsxs)(`span`,{className:`notification-policy-reason`,children:[`Reason: `,e.reason]}),e.ruleIds&&e.ruleIds.length>0&&(0,V.jsxs)(`span`,{className:`notification-tool`,children:[`Rules: `,(0,V.jsx)(`code`,{children:e.ruleIds.join(`, `)})]}),e.policyVersion&&(0,V.jsxs)(`span`,{className:`notification-tool`,children:[`Policy: `,(0,V.jsx)(`code`,{children:e.policyVersion})]}),(0,V.jsxs)(`span`,{className:`notification-tool`,children:[`Receipt:`,` `,e.receiptId?(0,V.jsx)(`code`,{children:e.receiptId}):(0,V.jsx)(`em`,{children:`Receipt unavailable`})]})]}),e.type===`permission_request`&&!e.response&&(0,V.jsxs)(`div`,{className:`notification-actions`,children:[(0,V.jsxs)(`button`,{className:`notification-action-btn notification-action-allow`,onClick:t=>{t.stopPropagation(),d(e)},children:[(0,V.jsx)(P,{size:14}),`Approve`]}),(0,V.jsxs)(`button`,{className:`notification-action-btn notification-action-deny`,onClick:t=>{t.stopPropagation(),f(e)},children:[(0,V.jsx)(Bn,{size:14}),`Deny`]})]}),e.type===`permission_request`&&e.response&&(0,V.jsx)(`span`,{className:`notification-response-badge ${e.response===`allow`?`response-allow`:`response-deny`}`,children:e.response===`allow`?`Approved`:`Denied`})]}),(0,V.jsx)(`button`,{className:`notification-dismiss`,onClick:t=>{t.stopPropagation(),o(e.id)},"aria-label":`Dismiss notification`,children:(0,V.jsx)(Bn,{size:14})})]},e.id)})}),t.length>0&&(0,V.jsxs)(`div`,{className:`notification-center-footer`,children:[(0,V.jsxs)(`button`,{className:`notification-footer-btn`,onClick:i,disabled:n===0,children:[(0,V.jsx)(P,{size:14}),`Mark All Read`]}),(0,V.jsxs)(`button`,{className:`notification-footer-btn notification-footer-clear`,onClick:a,children:[(0,V.jsx)(On,{size:14}),`Clear`]})]})]})}var xO=1500,SO=e=>new Promise(t=>setTimeout(t,e));async function CO({onProgress:e,isCancelled:t=()=>!1,pollMs:n=xO}={}){try{await aa(DT)}catch(e){if(e?.httpStatus!==409)throw e;let t=await oa(DT).catch(()=>null);if(!t||t.status===`completed`||t.status===`failed`)throw e}for(;!t();){let t=await oa(DT);if(e?.(t),t.status===`completed`)return;if(t.status===`failed`)throw Error(t.error||`The GAIA agent could not be installed.`);await SO(n)}}function wO({onInstalled:e}){let[t,n]=(0,z.useState)({kind:`idle`}),r=(0,z.useRef)(!1);(0,z.useEffect)(()=>()=>{r.current=!0},[]);let i=(0,z.useCallback)(async()=>{n({kind:`installing`,percent:0});try{if(await CO({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,V.jsxs)(`div`,{className:`app-notice is-warning`,role:`status`,children:[t.kind===`installing`?(0,V.jsxs)(`span`,{children:[`Installing the GAIA agent… `,Math.round(t.percent),`%`]}):t.kind===`failed`?(0,V.jsxs)(`span`,{children:[`The GAIA agent could not be installed: `,t.error]}):(0,V.jsx)(`span`,{children:`The GAIA agent isn't installed, so new chats can't start yet.`}),t.kind!==`installing`&&(0,V.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>void i(),children:t.kind===`failed`?`Try again`:`Install GAIA agent`})]})}function TO(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 EO(e,t){let{addNotification:n}=G.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 DO=$n((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 Ao()).schedules||[],r=t().errorCounts;r&&EO(r,n),e({schedules:n,loading:!1,errorCounts:Object.fromEntries(n.map(e=>[e.id,e.error_count]))})}catch(t){s.api.error(`Failed to load schedules`,t),e({error:`Failed to load schedules`,loading:!1})}},createSchedule:async(t,n,r)=>{try{let i=await Mo(t,n,r);e(e=>({schedules:[...e.schedules,i],error:null}))}catch(t){let n=TO(t,`Failed to create schedule`);throw s.api.error(`Failed to create schedule`,t),e({error:n}),t}},updateScheduleStatus:async(t,n)=>{try{let r=await No(t,n);e(e=>({schedules:e.schedules.map(e=>e.name===t?r:e),error:null}))}catch(n){s.api.error(`Failed to update schedule "${t}"`,n),e({error:TO(n,`Failed to update schedule`)})}},deleteSchedule:async t=>{try{await Po(t),e(e=>({schedules:e.schedules.filter(e=>e.name!==t),selectedSchedule:e.selectedSchedule===t?null:e.selectedSchedule,error:null}))}catch(n){s.api.error(`Failed to delete schedule "${t}"`,n),e({error:TO(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 Fo(t)).results||[],resultsLoading:!1})}catch(n){s.api.error(`Failed to load results for "${t}"`,n),e({results:[],resultsLoading:!1})}}})),OO=new Set([`loading_model`,`downloading_model`,`model_retry`,`waiting`]),kO=5;function AO(e,t){return{id:e,title:t.get(e)?.title??`Untitled chat`}}function jO(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=>({...AO(e,t),reason:`approval`}));n&&e.awaitingUser&&!a.has(e.currentSessionId)&&o.push({...AO(e.currentSessionId,t),reason:`answer`});for(let[n,r]of Object.entries(e.awaitingBySession))o.some(e=>e.id===n)||o.push({...AO(n,t),reason:r===`question`?`answer`:`approval`});let s=n&&!e.awaitingUser&&e.livePhase&&OO.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,kO).map(e=>AO(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=>AO(e,t)),needsYou:o,recent:u}}function MO(e){let t=(0,z.useRef)(e);t.current=e,(0,z.useEffect)(()=>{let e=window.gaiaAPI?.tray;if(!e)return;let n=``,r=null,i=()=>{let t=B.getState(),i={backendConnected:t.backendConnected,systemStatus:t.systemStatus,sessions:t.sessions,runningSessionIds:t.runningSessionIds,awaitingBySession:t.awaitingBySession,currentSessionId:t.currentSessionId,isStreaming:t.isStreaming,awaitingUser:t.awaitingUser,liveStatus:t.liveStatus,livePhase:t.livePhase,notifications:G.getState().notifications},a=r;if(r=i,a&&Object.keys(i).every(e=>i[e]===a[e]))return;let o=jO(i),c=JSON.stringify(o);c!==n&&(n=c,e.setActivity(o).catch(e=>{n=``,s.system.error(`The tray could not take the app state`,e)}))};i();let a=B.subscribe(i),o=G.subscribe(i),c=e.onCommand(e=>{switch(e.type){case`open-chat`:t.current.openChat(e.sessionId);break;case`new-chat`:t.current.newChat();break;case`open-settings`:B.getState().openSettings(e.section);break;case`refresh-status`:t.current.refreshStatus();break;default:s.system.error(`Unknown tray command`,e)}});return()=>{a(),o(),c()}},[])}function NO(){(0,z.useEffect)(()=>{let e=window.gaiaAPI;if(!e)return;let t=G.getState().addNotification,n=[e.notification.onNotification(t),e.notification.onPermissionRequest(t),e.tray.onNavigate(e=>{let t=typeof e==`string`&&e.startsWith(`session:`)?e.slice(8):null;if(!t)return;let n=B.getState();n.currentSessionId!==t&&n.setMessages([]),n.setCurrentSession(t)})];return()=>n.forEach(e=>e())},[])}function PO(e,t,n){let r=window.gaiaAPI;if(r){r.notification.show({title:t,body:n,sessionId:e}).then(e=>{e||s.system.warn(`This OS has no desktop notifications; the badge still counts it.`)}).catch(e=>s.system.error(`Could not show the desktop notification`,e));return}if(typeof Notification>`u`){s.system.warn(`This browser has no notifications; the alert was not shown.`);return}if(Notification.permission!==`granted`){s.system.warn(`Browser notifications are ${Notification.permission}; allow them in Settings → Notifications.`);return}let i=new Notification(t,{body:n,tag:`gaia-${e}`});i.onclick=()=>{window.focus(),B.getState().setCurrentSession(e)}}function FO(){let[e,t]=(0,z.useState)(null);return(0,z.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=>s.system.warn(`Battery level unavailable; keep-awake ignores the battery policy.`,e)),()=>{n?.removeEventListener(`levelchange`,r),n?.removeEventListener(`chargingchange`,r)}},[]),e}function IO(){NO();let e=B(e=>e.runningSessionIds),t=B(e=>e.awaitingBySession),n=B(e=>e.sessions),r=B(e=>e.currentSessionId),i=G(qn(Ws)),a=Zs(),o=FO(),c=(0,z.useRef)(null),l=ic(e,t,i),u=JSON.stringify(l);(0,z.useEffect)(()=>{let e=JSON.parse(u),t=c.current;if(c.current=e,t===null)return;let{sessions:n,currentSessionId:r}=B.getState(),i=document.hasFocus(),o=!1;for(let{sessionId:c,event:l}of ac(t,e)){let e=n.find(e=>e.id===c);if(e?.kind===`eval`||e?.kind===`scheduled`)continue;let t=a.modes[l];if(!(t===`off`||cc(c,r,i))&&(o=!0,t===`banner`)){if(l!==`finished`){let{title:t,body:n}=sc(l,e);PO(c,t,n)}else Ra(c).then(e=>{B.getState().updateSessionInList(c,e);let{title:t,body:n}=sc(l,e);PO(c,t,n)}).catch(t=>{s.system.error(`Could not read how chat ${c} ended`,t);let{title:n,body:r}=sc(l,{...e,last_run_status:null});PO(c,n,r)})}}if(o){if(a.sound)try{dc()}catch(e){s.system.warn(`Alert sound not played`,e)}a.flash&&!i&&window.gaiaAPI&&window.gaiaAPI.notification.flash().catch(e=>s.system.error(`Could not flash the taskbar button`,e))}},[u,a.modes,a.sound,a.flash]);let d=lc(n,l,a.modes,r);(0,z.useEffect)(()=>{window.gaiaAPI?.notification.setAttentionCount(d).catch(e=>s.system.error(`Could not update the taskbar badge`,e))},[d]);let f=a.keepAwake&&e.length>0&&uc(o,a.batteryFloor);(0,z.useEffect)(()=>{window.gaiaAPI?.power.setKeepAwake(f).catch(e=>s.system.error(`Could not change keep-awake`,e))},[f])}function LO(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 RO(e){return e.replace(/-/g,``).slice(0,7)}function zO(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 BO(e,t,n){return!e||t&&(e===t||e===RO(t))?null:n.some(t=>t.id===e)?e:zO(n,e)}function VO(e){return new URLSearchParams(e.search).get(`session`)||e.hash.replace(/^#/,``)||null}var HO=`gaia:last-session`;function UO(e){try{e?localStorage.setItem(HO,e):localStorage.removeItem(HO)}catch(e){s.ui.warn(`Could not save the open chat for the next launch`,e)}}function WO(){try{return localStorage.getItem(HO)}catch(e){return s.ui.warn(`Could not read the chat open at last launch`,e),null}}var GO=1e3,KO=3e4;function qO(e,{initialMs:t=GO,maxMs:n=KO,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 JO=(0,z.lazy)(()=>tO(()=>import(`./MemoryDashboard-DpZxbN9N.js`).then(e=>({default:e.MemoryDashboard})),__vite__mapDeps([5,1,2,6,7]),import.meta.url)),YO=(0,z.lazy)(()=>tO(()=>import(`./ScheduleManager-KHmfOhd7.js`).then(e=>({default:e.ScheduleManager})),__vite__mapDeps([8,1,2,6,9]),import.meta.url)),XO=(0,z.lazy)(()=>tO(()=>import(`./DocumentLibrary-CDqFh5v6.js`).then(e=>({default:e.DocumentLibrary})),__vite__mapDeps([10,1,2,11]),import.meta.url)),ZO=(0,z.lazy)(()=>tO(()=>import(`./FileBrowser-CIx8c6v3.js`).then(e=>({default:e.FileBrowser})),__vite__mapDeps([12,1,2,13]),import.meta.url)),QO=(0,z.lazy)(()=>tO(()=>import(`./MobileAccessModal-Xjac45ac.js`).then(e=>({default:e.MobileAccessModal})),__vite__mapDeps([14,1,2,15]),import.meta.url)),$O=3,ek=3e5,tk=6e3,nk=6e4,rk=e=>e instanceof TypeError,ik=e=>new Promise(t=>setTimeout(t,e));function ak(){return(0,V.jsx)(`div`,{className:`loading-spinner`,role:`status`,"aria-label":`Loading`})}var ok=e=>e===1||e%10==0;function sk(){let e=B(e=>e.currentSessionId),t=B(e=>e.setSessions),n=B(e=>e.setCurrentSession),r=B(e=>e.addSession),a=B(e=>e.setMessages),o=B(e=>e.showDocLibrary),l=B(e=>e.showFileBrowser),u=B(e=>e.showMemoryDashboard),d=B(e=>e.showSchedules),f=B(e=>e.sidebarOpen),p=B(e=>e.setSidebarOpen),m=B(e=>e.setSystemStatus),h=B(e=>e.setBackendConnected),g=B(e=>e.setAgents),_=B(e=>e.agents),v=B(e=>e.setPendingPrompt),y=B(e=>e.setDefaultPermissionMode),b=B(e=>e.openSettings),x=B(e=>e.settingsSection),S=B(e=>e.syncSystemTheme),C=cs(e=>e.restoreNotice),w=cs(e=>e.dismissRestoreNotice),T=G(e=>e.showPanel),E=B(e=>e.systemStatus?.initialized===!0),D=G(e=>e.setShowPanel);(0,z.useEffect)(()=>{if(!C?.ok)return;let e=setTimeout(w,tk);return()=>clearTimeout(e)},[C,w]);let[O,k]=(0,z.useState)({state:`checking`}),ee=(0,z.useRef)(O);ee.current=O;let[A,j]=(0,z.useState)(!1),te=(0,z.useRef)(A);te.current=A;let[M,N]=(0,z.useState)(!1),P=M||A&&!OT(_),ne=(0,z.useRef)(P);ne.current=P;let[re,ie]=(0,z.useState)(null),[F,ae]=(0,z.useState)(``),[oe,se]=(0,z.useState)(0),[ce,le]=(0,z.useState)(!1),[ue,de]=(0,z.useState)(!1),[fe,pe]=(0,z.useState)(null),me=(0,z.useRef)(async()=>{}),I=(0,z.useRef)(async()=>{}),L=(0,z.useCallback)(async(e=!1,t=!1)=>{e||k({state:`checking`});let n=0;try{for(;;){await cs.getState().refresh();let e=cs.getState().active,r;try{r=await ca(!!e?.remote)}catch(e){if(!t||!rk(e)||n>=nk)throw e;await ik(GO),n+=GO;continue}n>0&&await Promise.all([me.current(),I.current()]),k(r.ready?{state:`ready`}:{state:`needed`,check:r});return}}catch(e){let t=e instanceof Error?e.message:String(e);s.system.warn(`Setup check could not be answered`,e),k({state:`unknown`,error:t})}},[]),he=(0,z.useRef)(0),ge=(0,z.useCallback)(async()=>{let e=++he.current,t=(await ia()).agents||[];e===he.current&&(g(t),j(!0),OT(t)&&N(!1))},[g]),_e=(0,z.useCallback)(()=>{let e=te.current;j(!1),ge().catch(t=>{s.api.warn(`Agent list unavailable after setup`,t),e&&j(!0)})},[ge]);(0,z.useEffect)(()=>{let e=()=>{ne.current&&ge().catch(e=>s.api.warn(`Agent list unavailable`,e))};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[ge]);let ve=(0,z.useCallback)(async()=>{y((await Fi()).default_mode)},[y]),ye=(0,z.useRef)([]);(0,z.useEffect)(()=>{i(`0.25.2`),L(!1,!0);let e=[qO(ge,{onError:(e,t)=>{ok(t)&&s.api.warn(`Agent list unavailable (attempt ${t}); retrying`,e)}}),qO(ve,{onError:(e,t)=>{ok(t)&&s.api.warn(`Default permission mode unavailable (attempt ${t}); retrying`,e)}})];return ye.current=e,()=>e.forEach(e=>e.stop())},[L,ge,ve]);let be=(0,z.useCallback)(()=>{ye.current.forEach(e=>e.kick()),cs.getState().retryNow(),I.current(),ee.current.state===`unknown`&&L(!0)},[L]),xe=(0,z.useRef)(be);xe.current=be;let Se=(0,z.useRef)(0),Ce=(0,z.useRef)(0),we=(0,z.useRef)(null),Te=(0,z.useRef)(!1),[Ee,De]=(0,z.useState)(!1),[Oe,ke]=(0,z.useState)(null),Ae=(0,z.useCallback)(e=>{if(e.kind===`unreachable`){s.system.warn(`System status check failed`,e.error),Te.current=!0,Ce.current=0,we.current=null,De(!1),ke(null),h(!1),m(null);return}if(e.kind===`error`){s.system.warn(`System status answered HTTP ${e.httpStatus}`,e.message),Te.current&&xe.current(),Te.current=!1,Ce.current=0,we.current=null,De(!1),ke(`HTTP ${e.httpStatus}: ${e.message}`),h(!0);return}if(e.kind===`slow`){if(Ce.current+=1,we.current??=Date.now(),ke(null),s.system.warn(`System status did not answer in time (${Ce.current} in a row)`),Date.now()-we.current>=ek){De(!1),h(!1),m(null);return}h(!0),(Te.current||Ce.current>=$O)&&De(!0);return}let{status:t}=e;Te.current&&xe.current(),Te.current=!1,Ce.current=0,we.current=null,De(!1),ke(null),h(!0),Se.current=t.lemonade_running?0:Se.current+1;let n=B.getState().systemStatus;t.lemonade_running||Se.current>=$O||!n?.lemonade_running?m(t):m({...n,download_progress:t.download_progress})},[h,m]),je=(0,z.useRef)(Ae);je.current=Ae;let[Me]=(0,z.useState)(()=>mO(e=>je.current(e))),Ne=Me.check;me.current=Ne,(0,z.useEffect)(()=>NT(Me.start),[Me]);let Pe=(0,z.useRef)(``);(0,z.useEffect)(()=>{let e=e=>Pa().then(n=>{let r=n.sessions||[];if(!e&&r.length===0&&B.getState().sessions.length>0)return;let i=r.map(e=>`${e.id}|${e.updated_at}|${e.title}|${e.inference_remote}|${e.inference_provider}|${e.inference_description}|${e.effective_model}|${e.unread}|${e.pinned}|${e.last_run_status}|${e.kind}`).join(`
|
|
78
78
|
`);if(i===Pe.current)return;Pe.current=i,t(r);let a=cs.getState().active?.model;a&&r.some(e=>e.effective_model&&e.effective_model!==a)&&cs.getState().refresh()}).catch(t=>{e&&s.system.error(`Could not load chats`,t)});I.current=()=>e(!1),e(!0);let n=setInterval(()=>void e(!1),5e3);return()=>clearInterval(n)},[t]),(0,z.useEffect)(()=>pS(),[]),(0,z.useEffect)(()=>{let e=()=>{DO.getState().loadSchedules()};e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[]),(0,z.useEffect)(()=>PS(),[]),IO();let Fe=(0,z.useRef)(!1),Ie=(0,z.useRef)(!1);(0,z.useEffect)(()=>{let e=()=>{let e=VO(window.location),{currentSessionId:t,sessions:r}=B.getState(),i=BO(e,t,r);return i&&(n(i),a([])),i},t=()=>{if(Fe.current||(Fe.current=!0,e()||B.getState().currentSessionId))return;if(window.location.hash){window.history.replaceState(null,``,window.location.pathname+window.location.search);return}if(Ie.current||oi(`new-chat`))return;let{sessions:t}=B.getState(),r=BO(WO(),null,t);r&&(n(r),a([]))},r=B.subscribe(e=>{e.sessions.length>0&&t()});return B.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,z.useEffect)(()=>{let e=null,t=2e3,r=!1,i=null,o=()=>{r||(e=new EventSource(`${c()}/sessions/events`),e.onopen=()=>{t=2e3},e.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch(e){s.api.warn(`Malformed session event`,e);return}t.type===`set_active_session`&&t.session_id&&t.session_id!==B.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,z.useEffect)(()=>{if(Fe.current&&UO(e),e){let t=RO(e);window.location.hash!==`#${t}`&&window.history.replaceState(null,``,`#${t}`)}else Fe.current&&window.location.hash&&window.history.replaceState(null,``,window.location.pathname+window.location.search)},[e]);let Le=(0,z.useCallback)(async e=>{ie(null);let t=B.getState(),i;try{i=await Fa({title:`New Task`,agent_type:DT,document_ids:t.draftDocumentIds,private:t.draftPrivate,folders:t.draftFolder?[t.draftFolder]:[]})}catch(e){throw kT(e)?(N(!0),Error(`The GAIA agent isn't installed. Install it from the notice above, then send again.`)):e}ne.current&&(N(!1),ge().catch(e=>s.api.warn(`Agent list unavailable`,e))),t.defaultPermissionModeKnown||(await ve().catch(e=>s.api.warn(`Default permission mode unavailable; using the chip's mode`,e)),t=B.getState()),t.clearDraftDocuments(),t.setDraftPrivate(!1),t.setDraftFolder(null);let o=null;try{await Ii(i.id,t.draftPermissionMode)}catch(e){o=e}return ci(ai),o&&!i.private&&si(ii(i.id),e),r(i),n(i.id),a([]),ae(``),o?(ie(`The chat was created, but its permission mode could not be set, so your message was not sent${i.private?``:` — it is in the chat's box`}: ${o instanceof Error?o.message:o}`),!1):(t.resetDraftPermissionMode(),v({sessionId:i.id,text:e}),!0)},[r,n,a,v,ge,ve]),Re=(0,z.useCallback)(()=>{let e=B.getState(),t=e.currentSessionId;t&&yc(t,e)&&bc(t),e.setShowMemoryDashboard(!1),e.setShowSchedules(!1),Ie.current=!0,n(null),a([]),se(e=>e+1)},[n,a]);MO({openChat:(0,z.useCallback)(e=>{let t=B.getState();t.closeSettings(),e!==t.currentSessionId&&(bc(t.currentSessionId),a([])),n(e)},[n,a]),newChat:(0,z.useCallback)(()=>{B.getState().closeSettings(),Re()},[Re]),refreshStatus:()=>void Ne()});let ze=(0,z.useCallback)(e=>{Re(),Le(`Load the \`${e}\` skill, then tell me briefly what it lets you do.`).catch(e=>ie(e instanceof Error?e.message:String(e)))},[Re,Le]),Be=(0,z.useCallback)(e=>{k({state:`ready`}),_e(),Ne(),e&&(e.needs_input?ae(e.prompt):Le(e.prompt).catch(e=>ie(e instanceof Error?e.message:String(e))))},[Ne,Le,_e]);(0,z.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&(e.shiftKey&&e.key.toLowerCase()===`o`?(e.preventDefault(),Re()):!e.shiftKey&&e.key.toLowerCase()===`k`?(e.preventDefault(),window.dispatchEvent(new CustomEvent(`gaia:focus-search`))):!e.shiftKey&&e.key.toLowerCase()===`b`?(e.preventDefault(),B.getState().toggleSidebarCollapsed()):!e.shiftKey&&e.key===`,`&&(e.preventDefault(),b()))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Re,b]),(0,z.useEffect)(()=>{let e=window.matchMedia?.(`(max-width: 768px)`);if(!e)return;let t=()=>p(!e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[p]),(0,z.useEffect)(()=>{if(typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(prefers-color-scheme: light)`);return e.addEventListener(`change`,S),()=>e.removeEventListener(`change`,S)},[S]),(0,z.useEffect)(()=>{Oo().then(e=>de(e.active===!0)).catch(e=>s.system.debug(`Mobile access unavailable`,e))},[]);let Ve=(0,z.useCallback)(async()=>{if(le(!0),pe(null),!ue)try{let e=await Eo();e.error?pe(e.error):de(!0)}catch(e){pe(e instanceof Error?e.message:`Could not start mobile access`)}},[ue]),He=(0,z.useCallback)(async()=>{try{await Do(),de(!1),le(!1)}catch(e){pe(e instanceof Error?e.message:`Could not stop mobile access`)}},[]);Nw(e=>{e?Ve():He()}),(0,z.useEffect)(()=>{jw(ue)},[ue]);let Ue=typeof window<`u`&&window.innerWidth<=768;if(O.state===`checking`&&!E)return(0,V.jsx)(`div`,{className:`app`,children:(0,V.jsxs)(`main`,{className:`startup`,role:`status`,"aria-label":`Starting GAIA`,children:[(0,V.jsx)(`div`,{className:`loading-spinner`,"aria-hidden":`true`}),(0,V.jsx)(`p`,{className:`startup-text`,children:`Starting GAIA…`})]})});if(O.state===`needed`)return(0,V.jsx)(`div`,{className:`app`,children:(0,V.jsx)(dD,{initial:O.check,onReady:Be})});let We=u?(0,V.jsx)(z.Suspense,{fallback:(0,V.jsx)(ak,{}),children:(0,V.jsx)(JO,{})}):e?(0,V.jsx)(qT,{sessionId:e},e):(0,V.jsx)(KE,{onSend:Le,initialText:F,focusRequest:oe},F);return(0,V.jsxs)(`div`,{className:`app`,children:[!f&&(0,V.jsx)(`button`,{className:`sidebar-toggle`,onClick:()=>p(!0),"aria-label":`Open sidebar`,children:(0,V.jsx)(jt,{size:18})}),(0,V.jsx)(`div`,{className:`sidebar-overlay ${f?`visible`:``}`,onClick:()=>p(!1),"aria-hidden":`true`}),(0,V.jsx)(zc,{onNewChat:Re,onMobileAccess:Ue?void 0:()=>void Ve(),tunnelActive:ue}),(0,V.jsxs)(`div`,{className:`main-content`,children:[O.state===`ready`&&(0,V.jsx)(gO,{onRetry:Ne,backendSlow:Ee,backendError:Oe}),O.state===`unknown`&&(0,V.jsxs)(`div`,{className:`app-notice is-warning`,role:`status`,children:[(0,V.jsxs)(`span`,{children:[`Could not check whether GAIA is set up: `,O.error]}),(0,V.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>void L(),children:`Check again`})]}),P&&(0,V.jsx)(wO,{onInstalled:ge}),C&&(0,V.jsxs)(`div`,{className:`app-notice${C.ok?``:` is-warning`}`,role:`status`,children:[(0,V.jsx)(`span`,{children:C.message}),!C.ok&&(0,V.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>{w(),b(`model`)},children:`Pick a model`}),(0,V.jsx)(`button`,{type:`button`,className:`app-notice-close`,onClick:w,"aria-label":`Dismiss`,children:(0,V.jsx)(Bn,{size:14})})]}),We]}),d&&(0,V.jsx)(z.Suspense,{fallback:null,children:(0,V.jsx)(YO,{})}),o&&(0,V.jsx)(z.Suspense,{fallback:null,children:(0,V.jsx)(XO,{})}),l&&(0,V.jsx)(z.Suspense,{fallback:null,children:(0,V.jsx)(ZO,{onStartChat:Le})}),T&&(0,V.jsx)(`div`,{className:`notification-center-popover`,children:(0,V.jsx)(bO,{onClose:()=>D(!1)})}),ce&&(0,V.jsx)(z.Suspense,{fallback:null,children:(0,V.jsx)(QO,{isOpen:ce,onClose:()=>le(!1),onStop:()=>void He(),error:fe})}),x&&(0,V.jsx)(aO,{onUseSkill:ze}),(0,V.jsx)(_O,{}),re&&(0,V.jsx)(`div`,{className:`toast`,role:`alert`,children:re})]})}js(),ir();var ck=localStorage.getItem(`gaia-chat-theme`);rr(tr(ck===`light`||ck===`dark`?ck:`system`));var lk=B.getState();xr(lk.palette,lk.customColors,lk.theme),Vn.createRoot(document.getElementById(`root`)).render((0,V.jsx)(z.StrictMode,{children:(0,V.jsx)(sk,{})}));export{po as $,Je as $t,_E as A,xi as At,US as B,An as Bt,eE as C,Ci as Ct,oE as D,ui as Dt,$T as E,hi as Et,gE as F,B as Ft,Sc as G,tn as Gt,LS as H,bn as Ht,wE as I,Bn as It,us as J,Ft as Jt,xc as K,$t as Kt,kE as L,Rn as Lt,pE as M,li as Mt,hE as N,bi as Nt,uE as O,yi as Ot,mE as P,ei as Pt,fo as Q,Xe as Qt,cE as R,Pn as Rt,tE as S,pi as St,xE as T,mi as Tt,zS as U,vn as Ut,GS as V,On as Vt,fx as W,on as Wt,vo as X,Et as Xt,go as Y,R as Yt,mo as Z,nt as Zt,rE as _,O as _n,uo as _t,qE as a,Oe as an,Oo as at,aE as b,di as bt,AE as c,ge as cn,na as ct,bE as d,ue as dn,To as dt,Ke as en,ma as et,fE as f,ce as fn,ho as ft,iE as g,P as gn,ta as gt,jE as h,re as hn,$i as ht,tO as i,Ae as in,Yi as it,vE as j,vi as jt,EE as k,_i as kt,CE as l,L as ln,bo as lt,nE as m,F as mn,ga as mt,DO as n,Pe as nn,Qi as nt,LE as o,Ee as on,yo as ot,DE as p,oe as pn,wo as pt,mc as q,qt,oO as r,Me as rn,ea as rt,OE as s,Se as sn,co as st,LO as t,Re as tn,ko as tt,yE as u,fe as un,Io as ut,lE as v,S as vn,lo as vt,sE as w,gi as wt,TE as x,fi as xt,dE as y,Si as yt,SE as z,Mn as zt};
|