@amd-gaia/agent-ui 0.25.3-rc.1 → 0.25.3
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-vsSRlTRJ.js → AdvancedSettings-DERzP9Jc.js} +1 -1
- package/dist/assets/{ConnectorsPane-QC6sb-o5.js → ConnectorsPane-s0fFxmus.js} +1 -1
- package/dist/assets/{DocumentLibrary-Cs7_bM_p.js → DocumentLibrary-DqapN_Tr.js} +1 -1
- package/dist/assets/{FileBrowser-kw0x-OQP.js → FileBrowser-vAJV41RT.js} +1 -1
- package/dist/assets/{MemoryDashboard-CH1rYgBS.js → MemoryDashboard-CP5wVWkY.js} +1 -1
- package/dist/assets/{MobileAccessModal-7LB2ZwbS.js → MobileAccessModal-B31mPs50.js} +1 -1
- package/dist/assets/{ScheduleManager-C842iHFu.js → ScheduleManager-b0gTAf2R.js} +1 -1
- package/dist/assets/{index-Ck42TJHO.js → index-Cae5Fje-.js} +3 -3
- 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-s0fFxmus.js","./rolldown-runtime-XKyaHtl9.js","./apiBase-CS6zLsJY.js","./ConnectorsPane-Dzu2DRTc.css","./AdvancedSettings-DERzP9Jc.js","./MemoryDashboard-CP5wVWkY.js","./zap-BogJn9oN.js","./MemoryDashboard-Mo721-BI.css","./ScheduleManager-b0gTAf2R.js","./ScheduleManager-D5c4gVIt.css","./DocumentLibrary-DqapN_Tr.js","./DocumentLibrary-CIKp6qld.css","./FileBrowser-vAJV41RT.js","./FileBrowser-Dil1lZJ4.css","./MobileAccessModal-B31mPs50.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&&ee(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&&ee(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function ee(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,ee(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`),A=Symbol.for(`react.portal`),ee=Symbol.for(`react.fragment`),j=Symbol.for(`react.strict_mode`),M=Symbol.for(`react.profiler`),N=Symbol.for(`react.consumer`),P=Symbol.for(`react.context`),te=Symbol.for(`react.forward_ref`),ne=Symbol.for(`react.suspense`),re=Symbol.for(`react.suspense_list`),ie=Symbol.for(`react.memo`),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 I(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 ee:return`Fragment`;case M: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 A:return`Portal`;case P:return e.displayName||`Context`;case N:return(e._context.displayName||`Context`)+`.Consumer`;case te:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ie:return t=e.displayName||null,t===null?I(e.type)||`Memo`:t;case F:t=e._payload,e=e._init;try{return I(e(t))}catch{}}return null}var pe=Array.isArray,L=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,me={pending:!1,data:null,method:null,action:null},he=[],ge=-1;function _e(e){return{current:e}}function ve(e){0>ge||(e.current=he[ge],he[ge]=null,ge--)}function z(e,t){ge++,he[ge]=e.current,e.current=t}var ye=_e(null),be=_e(null),xe=_e(null),Se=_e(null);function Ce(e,t){switch(z(xe,t),z(be,e),z(ye,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}}ve(ye),z(ye,e)}function we(){ve(ye),ve(be),ve(xe)}function Te(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,z(Se,e)),t=ye.current;var n=dp(t,e.type);t!==n&&(z(be,e),z(ye,n))}function Ee(e){be.current===e&&(ve(ye),ve(be)),Se.current===e&&(ve(Se),sh._currentValue=me)}var De,Oe;function ke(e){if(De===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);De=t&&t[1]||``,Oe=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+De+e+Oe}var Ae=!1;function je(e,t){if(!e||Ae)return``;Ae=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
@@ -55,7 +55,7 @@ Load ${e} anyway?`)?(await ta(e,t,!0),!0):!1}}async function ra(e,t=!1){return W
|
|
|
55
55
|
`),n=n.replace(/\\"/g,`"`)),n=Jx(n).trim(),Qx(n)}function Qx(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
57
|
`)}function $x(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 eS=`Cancelled.`,tS=[`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 nS(e,t){if(t)return`stopped`;let n=e.trim();return tS.some(e=>n.endsWith(e))?`interrupted`:void 0}function rS({message:e,isStreaming:t,agentSteps:n,agentStepsActive:r,cards:i,onDelete:a,onResend:o,extraActions:s,latencyMs:c,liveStatus:l,awaitingUser:u}){ms();let d=(0,V.useMemo)(()=>e.role===`assistant`&&!t&&n?zx(n,e.content):{steps:n,echoed:!1},[n,e.content,e.role,t]),f=e.role===`assistant`&&(d.echoed||Lx(e.content)),p=e.role===`assistant`?e.stopState??(e.content.trim()===eS?`stopped`:void 0):void 0,m=(0,V.useMemo)(()=>e.role===`user`?e.content:Zx(e.content,!!t),[e.content,e.role,t]),[h,g]=(0,V.useState)(!1),[_,v]=(0,V.useState)(!1),y=e.role===`user`&&$v(e.content),[b,x]=(0,V.useState)(!1),S=(0,V.useId)(),C=(0,V.useRef)(null),w=(0,V.useRef)(!1),T=(0,V.useCallback)(()=>{b&&(w.current=!0),x(!b)},[b]);(0,V.useEffect)(()=>{!b&&w.current&&(w.current=!1,C.current?.scrollIntoView?.({block:`nearest`}))},[b]);let E=(0,V.useRef)(null),D=(0,V.useRef)(null);(0,V.useEffect)(()=>()=>{E.current&&clearTimeout(E.current),D.current&&clearTimeout(D.current)},[]);let O=(0,V.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,V.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]),A=(0,V.useCallback)(()=>{o?.(e)},[e,o]),ee=e.created_at?`${e.role===`user`?`Sent`:`Replied`} ${$x(e.created_at)}`:void 0;return(0,U.jsx)(`div`,{className:`msg msg-${e.role} ${f?`msg-error`:``}`,title:ee,children:(0,U.jsxs)(`div`,{className:`msg-inner`,children:[(0,U.jsxs)(`div`,{className:`msg-header`,children:[(0,U.jsx)(`div`,{className:`msg-header-left`}),!t&&(0,U.jsxs)(`div`,{className:`msg-actions`,children:[e.role===`user`&&o&&(0,U.jsx)(`button`,{className:`msg-action-btn`,onClick:A,title:`Resend message`,"aria-label":`Resend message`,children:(0,U.jsx)(tn,{size:12})}),s,(0,U.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,U.jsx)(te,{size:12}):(0,U.jsx)(be,{size:12})}),a&&(0,U.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,U.jsx)(On,{size:12})})]})]}),(0,U.jsxs)(`div`,{className:`msg-body`,children:[e.role===`assistant`&&(d.steps&&d.steps.length>0||t)&&(0,U.jsx)(Iy,{steps:d.steps??[],isActive:r??!1,running:!!t,awaitingUser:u,answer:t?void 0:m,liveLine:t&&(0,U.jsx)(Px,{active:!!r||!m,label:l,awaitingUser:u})}),f&&(0,U.jsxs)(`div`,{className:`error-banner`,children:[(0,U.jsx)(An,{size:14}),(0,U.jsx)(`span`,{children:`Something went wrong`})]}),(e.cards??i)?.map((e,t)=>(0,U.jsx)(qb,{render:e.render,data:e.data},t)),y?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{ref:C,id:S,className:`msg-collapsible${b?``:` is-collapsed`}`,children:(0,U.jsx)(mS,{content:m})}),(0,U.jsx)(ty,{expanded:b,onToggle:T,controls:S,collapsedLabel:`Show all (${ey(e.content)})`,expandedLabel:`Show less`,className:`msg-expand-toggle`})]}):!(p&&m.trim()===eS)&&(0,U.jsx)(mS,{content:m,showCursor:t&&!!m&&!r,isStreaming:t}),p&&(0,U.jsxs)(`div`,{className:`msg-stopped${p===`unconfirmed`||e.stopError?` is-unconfirmed`:``}`,role:`note`,children:[(0,U.jsx)(wn,{size:9,fill:`currentColor`,"aria-hidden":`true`}),(0,U.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&&ib(m)&&(0,U.jsx)(cb,{content:m}),e.role===`assistant`&&!t&&(e.stats||c!=null||e.created_at)&&(0,U.jsxs)(`div`,{className:`msg-stats`,"aria-label":`About this answer`,children:[e.created_at&&(0,U.jsx)(`span`,{className:`msg-stats-ts`,title:`Message timestamp`,children:$x(e.created_at)}),e.stats?.retried&&e.stats.model&&(0,U.jsx)(`span`,{title:`This answer was kept from Retry with… (${e.stats.model})`,children:gs(e.stats.model)}),(0,U.jsx)(Qb,{latencyMs:c,stats:e.stats,ended:nS(e.content,p)})]}),e.role===`assistant`&&!t&&e.id>0&&e.session_id&&(0,U.jsx)(Nx,{sessionId:e.session_id,messageId:e.id})]})]})})}var iS=(0,V.createContext)(!1);function aS({lang:e,code:t}){let[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(!1),o=(0,V.useContext)(iS),s=(0,V.useId)(),c=Qv(t),l=c>(o?20:25),u=l&&!i,d=(0,V.useRef)(null);(0,V.useEffect)(()=>()=>{d.current&&clearTimeout(d.current)},[]);let f=(0,V.useCallback)(()=>{if(navigator.clipboard?.writeText)navigator.clipboard.writeText(t).catch(()=>{});else{let e=document.createElement(`textarea`);e.value=t,e.style.position=`fixed`,e.style.opacity=`0`,document.body.appendChild(e),e.select(),document.execCommand(`copy`),document.body.removeChild(e)}r(!0),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>r(!1),2e3)},[t]);return(0,U.jsxs)(`div`,{className:`code-block${u?` is-collapsed`:``}`,children:[(0,U.jsxs)(`div`,{className:`code-header`,children:[(0,U.jsx)(`span`,{className:`code-lang`,children:e||`code`}),(0,U.jsxs)(`button`,{className:`code-copy ${n?`copied`:``}`,onClick:f,title:n?`Copied!`:`Copy`,"aria-label":n?`Copied to clipboard`:`Copy code`,children:[n?(0,U.jsx)(te,{size:13}):(0,U.jsx)(be,{size:13}),(0,U.jsx)(`span`,{children:n?`Copied`:`Copy`})]})]}),(0,U.jsx)(`pre`,{id:s,children:(0,U.jsx)(`code`,{children:t})}),l&&(0,U.jsx)(ty,{expanded:i,onToggle:()=>a(e=>!e),controls:s,collapsedLabel:`Expand (${c.toLocaleString(`en-US`)} lines)`,expandedLabel:`Collapse`,className:`code-expand-toggle`})]})}var oS=/\b[A-Z]:[\\/][^\s*?"<>|,;)}\]\\/]+(?:[\\/][^\s*?"<>|,;)}\]\\/]+)*[\\/]?/gi,sS=/[.:!']+$/,cS=RegExp(`^(?:${oS.source})$`,`i`);function lS(e){if(typeof e!=`string`)return null;let t=e.trim();return cS.test(t)?t:null}function uS({path:e}){let t=t=>{t.preventDefault(),wo(e).catch(e=>{s.ui.error(`Failed to open path`,e)})};return(0,U.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,U.jsx)(Je,{size:12,className:`file-path-icon`}),e]})}function dS(e){let t=new RegExp(oS.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(sS,``);n.push((0,U.jsx)(uS,{path:t},i.index)),r=i.index+t.length}return n.length===0?e:(r<e.length&&n.push(e.slice(r)),(0,U.jsx)(U.Fragment,{children:n}))}function fS(e){return V.Children.map(e,e=>typeof e==`string`?dS(e):e)}var pS={code({className:e,children:t,node:n,...r}){let i=lS(t);return i?(0,U.jsx)(uS,{path:i}):(0,U.jsx)(`code`,{className:`inline-code`,...r,children:t})},pre({children:e}){let t=V.Children.toArray(e)[0];if(V.isValidElement(t)&&(t.type===`code`||t.props?.className!==void 0||typeof t.props?.children==`string`)){let e=t.props,n=e?.className||``,r=/language-([\w-]+)/.exec(n),i=String(e?.children||``).replace(/\n$/,``),a=r?.[1]||``;return(0,U.jsx)(aS,{lang:a,code:i})}return(0,U.jsx)(`pre`,{children:e})},table({children:e}){return(0,U.jsx)(`div`,{className:`md-table-wrap`,children:(0,U.jsx)(`table`,{className:`md-table`,children:e})})},a({href:e,children:t}){return(0,U.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`md-link`,children:t})},p({children:e}){return(0,U.jsx)(`p`,{className:`md-p`,children:fS(e)})},h1({children:e}){return(0,U.jsx)(`h2`,{className:`md-h2`,children:fS(e)})},h2({children:e}){return(0,U.jsx)(`h3`,{className:`md-h3`,children:fS(e)})},h3({children:e}){return(0,U.jsx)(`h4`,{className:`md-h4`,children:fS(e)})},ul({children:e}){return(0,U.jsx)(`ul`,{className:`md-ul`,children:e})},ol({children:e,start:t}){return(0,U.jsx)(`ol`,{className:`md-ol`,start:t,children:e})},li({children:e}){return(0,U.jsx)(`li`,{className:`md-li`,children:fS(e)})},blockquote({children:e}){return(0,U.jsx)(`blockquote`,{className:`md-blockquote`,children:fS(e)})},hr(){return(0,U.jsx)(`hr`,{className:`md-hr`})},td({children:e}){return(0,U.jsx)(`td`,{children:fS(e)})},th({children:e}){return(0,U.jsx)(`th`,{children:fS(e)})}};function mS({content:e,showCursor:t,isStreaming:n=!1}){return!e&&!t?null:!e&&t?(0,U.jsx)(`span`,{className:`cursor`}):(0,U.jsx)(iS.Provider,{value:n,children:(0,U.jsxs)(`div`,{className:`md-content`,children:[(0,U.jsx)(Ah,{remarkPlugins:[Lv,Hv,Wv],disallowedElements:[...Fh],urlTransform:Lh,components:pS,children:e}),t&&(0,U.jsx)(`span`,{className:`cursor`})]})})}function hS(e){return e.type===`status`&&e.status===`working`&&!e.phase&&(e.message??``).startsWith(`Model is processing`)}function gS(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 _S=/\s*\{\s*"?(?:tool|thought|goal)"?\s*:\s*"[^"]*"[^}]*(?:"?tool_args"?\s*:\s*\{[^}]*\})?\s*\}/g;function vS(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,`
|
|
58
|
-
`).replace(/\\\\/g,`\\`)}function yS(e,t){if(e.type!==`agent_error`||e.recoverable!==!0)return!1;let n=t[t.length-1];return!n||n.type!==`tool`?!1:n.success===!1||!!n.active&&n.success==null}function bS(e){return(e||[]).map(e=>({...e,agentSteps:e.agentSteps||e.agent_steps||void 0,stats:e.stats||e.inference_stats||void 0,turnSummary:e.turnSummary||e.turn_summary||void 0}))}function xS(e){return`policy-receipt-${encodeURIComponent(e)}`}var SS=1e3,CS=15e3,wS=null,TS=null,ES=SS,DS=0,OS=null;function kS(){if(wS)return wS;let e=Date.now();return wS=ji().then(t=>H.getState().setActiveRuns(t,e)).catch(e=>s.api.warn(`Could not read which chats are running`,e)).finally(()=>{wS=null}),wS}function AS(){let e=H.getState();return e.isStreaming||e.runningSessionIds.length>0}function jS(){return AS()?(ES=SS,SS):(ES=Math.min(ES*2,CS),ES)}function MS(e){kS().then(()=>{e===DS&&(TS=setTimeout(()=>MS(e),jS()))})}function NS(){OS&&(TS&&clearTimeout(TS),TS=null,ES=SS,MS(++DS))}function PS(){OS?.();let e=H.subscribe((e,t)=>{e.isStreaming&&!t.isStreaming&&NS()}),t=()=>NS();window.addEventListener(`focus`,t);let n=()=>{DS++,TS&&clearTimeout(TS),TS=null,e(),window.removeEventListener(`focus`,t),OS===n&&(OS=null)};return OS=n,ES=SS,MS(++DS),n}var FS=[0,3e3,1e4],IS=`The answer to your last message was lost: its run stopped before it finished, most often because GAIA restarted. Send the message again.`;function LS(e){return e.name===`StreamStalledError`||e.name===`StreamDroppedError`}function RS(e){if(LS(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 so)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 zS=3e3,BS=new Set,VS=new Map,HS=new Set,US=null;function WS(e,t=Date.now()){VS.set(e,t)}function GS(e){let t=H.getState();return t.activeRunsAt>0&&t.activeRunsAt>=(VS.get(e)??0)&&!t.runningSessionIds.includes(e)&&!t.queuedSessionIds.includes(e)}function KS(e){return HS.add(e),()=>{HS.delete(e),US?.()}}function qS(e){return e instanceof Error?RS(e)??(e.message||`Unknown error`):String(e)}function JS(e){let t=e?.httpStatus;return typeof t==`number`?t:void 0}function YS(e){let t=JS(e);return t===409||t===429}function XS(e){H.getState().setQueueHold(e,!0),setTimeout(()=>H.getState().setQueueHold(e,!1),zS)}function ZS(e,t,n){return JS(n)===409&&(s.chat.info(`Chat ${e} was busy; queueing the message to try again`),H.getState().updateQueue(e,e=>Tr(e,t,`queued`)),XS(e),!0)}async function QS(e,t,n){let r=H.getState;if(BS.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)){BS.add(e);try{if(a){let t;try{t=await Ei(e)}catch(t){if(JS(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: ${qS(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:qS(e)}}if(o.kind===`accepted`){WS(e),r().updateQueue(e,e=>Dr(e,i.id)),NS();return}if(o.kind===`busy`){s.chat.info(`Queued message found chat ${e} busy; holding it`),r().updateQueue(e,e=>Or(e,i.id)),XS(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{BS.delete(e)}}}function $S(e){return e.type!==`status`||e.phase!==`waiting`}var eC=(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=Qa(e,t,{onChunk:c,onAgentEvent:e=>{$S(e)&&c()},onDone:c,onError:e=>{LS(e)?c():YS(e)?o({kind:`busy`}):o({kind:`failed`,error:qS(e)})}}),a&&i.abort()});function tC(e=eC){let t=()=>{let t=H.getState();if(t.systemStatus?.init_state!==`initializing`)for(let n of Object.keys(t.messageQueues))!HS.has(n)&&GS(n)&&QS(n,e,()=>!HS.has(n))},n=H.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 US=t,t(),()=>{n(),US===t&&(US=null)}}var nC=`https://github.com/amd/gaia/issues/new`,rC=[{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 iC(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;for(let e of rC)if(e.extensions.has(t))return e;return null}var aC=new Set(`.pdf,.pptx,.docx,.txt,.md,.mdx,.markdown,.rst,.csv,.json,.xlsx,.epub,.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 oC(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;return aC.has(t)}function sC(){let e=navigator.userAgent;return`**Environment:**\n- GAIA Version: 0.25.
|
|
58
|
+
`).replace(/\\\\/g,`\\`)}function yS(e,t){if(e.type!==`agent_error`||e.recoverable!==!0)return!1;let n=t[t.length-1];return!n||n.type!==`tool`?!1:n.success===!1||!!n.active&&n.success==null}function bS(e){return(e||[]).map(e=>({...e,agentSteps:e.agentSteps||e.agent_steps||void 0,stats:e.stats||e.inference_stats||void 0,turnSummary:e.turnSummary||e.turn_summary||void 0}))}function xS(e){return`policy-receipt-${encodeURIComponent(e)}`}var SS=1e3,CS=15e3,wS=null,TS=null,ES=SS,DS=0,OS=null;function kS(){if(wS)return wS;let e=Date.now();return wS=ji().then(t=>H.getState().setActiveRuns(t,e)).catch(e=>s.api.warn(`Could not read which chats are running`,e)).finally(()=>{wS=null}),wS}function AS(){let e=H.getState();return e.isStreaming||e.runningSessionIds.length>0}function jS(){return AS()?(ES=SS,SS):(ES=Math.min(ES*2,CS),ES)}function MS(e){kS().then(()=>{e===DS&&(TS=setTimeout(()=>MS(e),jS()))})}function NS(){OS&&(TS&&clearTimeout(TS),TS=null,ES=SS,MS(++DS))}function PS(){OS?.();let e=H.subscribe((e,t)=>{e.isStreaming&&!t.isStreaming&&NS()}),t=()=>NS();window.addEventListener(`focus`,t);let n=()=>{DS++,TS&&clearTimeout(TS),TS=null,e(),window.removeEventListener(`focus`,t),OS===n&&(OS=null)};return OS=n,ES=SS,MS(++DS),n}var FS=[0,3e3,1e4],IS=`The answer to your last message was lost: its run stopped before it finished, most often because GAIA restarted. Send the message again.`;function LS(e){return e.name===`StreamStalledError`||e.name===`StreamDroppedError`}function RS(e){if(LS(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 so)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 zS=3e3,BS=new Set,VS=new Map,HS=new Set,US=null;function WS(e,t=Date.now()){VS.set(e,t)}function GS(e){let t=H.getState();return t.activeRunsAt>0&&t.activeRunsAt>=(VS.get(e)??0)&&!t.runningSessionIds.includes(e)&&!t.queuedSessionIds.includes(e)}function KS(e){return HS.add(e),()=>{HS.delete(e),US?.()}}function qS(e){return e instanceof Error?RS(e)??(e.message||`Unknown error`):String(e)}function JS(e){let t=e?.httpStatus;return typeof t==`number`?t:void 0}function YS(e){let t=JS(e);return t===409||t===429}function XS(e){H.getState().setQueueHold(e,!0),setTimeout(()=>H.getState().setQueueHold(e,!1),zS)}function ZS(e,t,n){return JS(n)===409&&(s.chat.info(`Chat ${e} was busy; queueing the message to try again`),H.getState().updateQueue(e,e=>Tr(e,t,`queued`)),XS(e),!0)}async function QS(e,t,n){let r=H.getState;if(BS.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)){BS.add(e);try{if(a){let t;try{t=await Ei(e)}catch(t){if(JS(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: ${qS(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:qS(e)}}if(o.kind===`accepted`){WS(e),r().updateQueue(e,e=>Dr(e,i.id)),NS();return}if(o.kind===`busy`){s.chat.info(`Queued message found chat ${e} busy; holding it`),r().updateQueue(e,e=>Or(e,i.id)),XS(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{BS.delete(e)}}}function $S(e){return e.type!==`status`||e.phase!==`waiting`}var eC=(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=Qa(e,t,{onChunk:c,onAgentEvent:e=>{$S(e)&&c()},onDone:c,onError:e=>{LS(e)?c():YS(e)?o({kind:`busy`}):o({kind:`failed`,error:qS(e)})}}),a&&i.abort()});function tC(e=eC){let t=()=>{let t=H.getState();if(t.systemStatus?.init_state!==`initializing`)for(let n of Object.keys(t.messageQueues))!HS.has(n)&&GS(n)&&QS(n,e,()=>!HS.has(n))},n=H.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 US=t,t(),()=>{n(),US===t&&(US=null)}}var nC=`https://github.com/amd/gaia/issues/new`,rC=[{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 iC(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;for(let e of rC)if(e.extensions.has(t))return e;return null}var aC=new Set(`.pdf,.pptx,.docx,.txt,.md,.mdx,.markdown,.rst,.csv,.json,.xlsx,.epub,.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 oC(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;return aC.has(t)}function sC(){let e=navigator.userAgent;return`**Environment:**\n- GAIA Version: 0.25.3\n- Platform: ${navigator.platform||`unknown`}\n- User Agent: ${e}\n- Interface: Agent UI (Web)`}function cC(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?_`,``,`---`,sC(),``,`_Submitted from GAIA Agent UI_`].join(`
|
|
59
59
|
`);return`${nC}?${new URLSearchParams({title:`[Feature] ${e}`,body:n,labels:`enhancement,agent-ui`}).toString()}`}function lC(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?_`,``,`---`,sC(),``,`_Submitted from GAIA Agent UI_`].join(`
|
|
60
60
|
`);return`${nC}?${new URLSearchParams({title:`[Bug] ${e}`,body:n,labels:`bug,agent-ui`}).toString()}`}var uC={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 dC(e,t){return e.startsWith(t)?e.slice(t.length).trim():e}function fC({filename:e,error:t,status:n,kind:r,onDismiss:i,timeout:a=15e3}){let o=(0,V.useRef)(null);(0,V.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?iC(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?uC[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=dC(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=cC(c.featureTitle),m=An):l&&!s?(d=`"${e}" has no file extension`,f=dC(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=cC(`Support ${s} file indexing`),m=An):u?(d=`Connection error`,f=`Could not reach the GAIA server. Make sure the backend is running.`,p=lC(`Upload connection error for ${e}`),m=ce):(d=`Failed to index "${e}"`,f=t||`An unexpected error occurred during indexing.`,p=lC(`Indexing error: ${t.slice(0,80)}`),m=A),(0,U.jsxs)(`div`,{className:`upload-error-toast`,role:`alert`,children:[(0,U.jsx)(m,{size:16}),(0,U.jsxs)(`div`,{className:`upload-error-content`,children:[(0,U.jsx)(`div`,{className:`upload-error-title`,children:d}),(0,U.jsxs)(`div`,{className:`upload-error-detail`,children:[f,p&&` `,p===null?null:l?(0,U.jsx)(`a`,{href:p,target:`_blank`,rel:`noopener noreferrer`,children:`Request this feature →`}):(0,U.jsx)(`a`,{href:p,target:`_blank`,rel:`noopener noreferrer`,children:`Report this issue →`})]})]}),(0,U.jsx)(`button`,{className:`upload-error-dismiss`,onClick:i,"aria-label":`Dismiss`,children:(0,U.jsx)(Bn,{size:14})})]})}function pC(e,t){let n=e=>t.some(t=>t.id===e&&t.configured),r=ab(e);return r===`google`?n(`google`):r===`microsoft`?n(`microsoft`):r===`microsoft_work`?n(`microsoft_work`):n(`google`)||n(`microsoft`)||n(`microsoft_work`)}function mC(e,t){let n=e=>t.some(t=>t.id===e&&t.configured),r=ab(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 hC=4e3;function gC({content:e,onRetry:t}){let[n,r]=(0,V.useState)([]),[i,a]=(0,V.useState)(!1),o=(0,V.useCallback)(()=>{li().then(e=>r(e.connectors||[])).catch(e=>s.ui.warn(`ConnectorRetryBanner: connector fetch failed`,e))},[]),c=pC(e,n);if((0,V.useEffect)(()=>{o();let e=()=>o();return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[o]),(0,V.useEffect)(()=>{if(c)return;let e=setInterval(o,hC);return()=>clearInterval(e)},[c,o]),!c||i)return null;let l=mC(e,n);return(0,U.jsxs)(`div`,{className:`connector-retry-banner`,role:`status`,children:[(0,U.jsx)(fe,{size:14,className:`connector-retry-banner__icon`}),(0,U.jsxs)(`span`,{className:`connector-retry-banner__text`,children:[l,` connected since this reply — ask again to run it now.`]}),(0,U.jsxs)(`button`,{type:`button`,className:`connector-retry-banner__btn`,onClick:()=>{a(!0),t()},children:[(0,U.jsx)(tn,{size:12}),(0,U.jsx)(`span`,{children:`Ask again`})]}),(0,U.jsx)(`button`,{type:`button`,className:`connector-retry-banner__dismiss`,onClick:()=>a(!0),"aria-label":`Dismiss`,children:`×`})]})}var _C=240,vC=1e5;function yC({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,V.useRef)(null),h=d??m,g=(0,V.useRef)(null),_=!!s,v=e.trim().length>0||c.hasUploaded,y=c.compose(e.trim()).length,b=y>vC,x=!_&&(!i||o)&&!c.uploading&&v&&!b,C=s||l;(0,V.useLayoutEffect)(()=>{let e=h.current;if(!e)return;let t=()=>{e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,_C)}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,V.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),x&&n())},[x,n]),T=(0,V.useCallback)(e=>{e.dataTransfer?.files?.length&&(e.preventDefault(),e.stopPropagation(),c.addFiles(Array.from(e.dataTransfer.files)))},[c]);return(0,U.jsxs)(`div`,{className:`composer${_?` composer-disabled`:``}`,onDrop:T,onDragOver:e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault()},children:[c.attachments.length>0&&(0,U.jsx)(`ul`,{className:`composer-attachments`,"aria-label":`Attached files`,children:c.attachments.map(e=>(0,U.jsxs)(`li`,{className:`composer-attachment${e.error?` has-error`:``}`,children:[e.isImage&&e.url?(0,U.jsx)(`img`,{src:e.url,alt:``,className:`composer-attachment-thumb`}):(0,U.jsx)(We,{size:14,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`composer-attachment-name`,title:e.name,children:e.name}),e.uploading&&(0,U.jsx)(`span`,{className:`composer-attachment-state`,children:`Uploading…`}),e.error&&(0,U.jsx)(`span`,{className:`composer-attachment-state`,role:`alert`,title:e.error,children:e.error}),(0,U.jsx)(`button`,{type:`button`,className:`composer-icon-btn`,onClick:()=>c.remove(e.id),"aria-label":`Remove ${e.name}`,children:(0,U.jsx)(Bn,{size:12})})]},e.id))}),(0,U.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,U.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,U.jsxs)(`div`,{className:`composer-row`,children:[(0,U.jsxs)(`div`,{className:`composer-row-left`,children:[(0,U.jsx)(`button`,{type:`button`,className:`composer-icon-btn`,onClick:()=>g.current?.click(),disabled:_,"aria-label":`Attach files`,title:`Attach files`,children:(0,U.jsx)($t,{size:16})}),(0,U.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,U.jsxs)(`div`,{className:`composer-row-right`,children:[p,i&&o&&v&&(0,U.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,U.jsx)(S,{size:16})}),i?(0,U.jsx)(`button`,{type:`button`,className:`composer-send is-stop`,onClick:r,disabled:a,"aria-label":`Stop`,title:a?`Stopping…`:`Stop (Esc)`,children:(0,U.jsx)(wn,{size:12,fill:`currentColor`})}):(0,U.jsx)(`button`,{type:`button`,className:`composer-send`,onClick:n,disabled:!x,"aria-label":`Send`,title:`Send (Enter)`,children:(0,U.jsx)(S,{size:16})})]})]})]})}var bC=8,xC=8;function SC({label:e,warning:t,children:n,id:r,pinned:i=!1,onUnpin:a,tabIndex:o}){let s=(0,V.useId)(),c=r??s,l=(0,V.useRef)(null),u=(0,V.useRef)(null),[d,f]=(0,V.useState)(!1),p=d||i,[m,h]=(0,V.useState)(null);return(0,V.useLayoutEffect)(()=>{if(!p){h(null);return}let e=l.current?.getBoundingClientRect(),t=u.current?.getBoundingClientRect(),n=l.current?.closest(`[role="dialog"]`)?.getBoundingClientRect()??e;if(!e||!t||!n)return;let r=window.innerWidth,i=window.innerHeight,a,o;n.right+bC+t.width<=r-xC?(a=n.right+bC,o=e.top+e.height/2-t.height/2):n.left-bC-t.width>=xC?(a=n.left-bC-t.width,o=e.top+e.height/2-t.height/2):(a=Math.min(Math.max(xC,e.right-t.width),r-xC-t.width),o=e.top-bC-t.height>=xC?e.top-bC-t.height:e.bottom+bC),o=Math.min(Math.max(xC,o),i-xC-t.height),h({left:a,top:o})},[p]),(0,V.useEffect)(()=>{if(!p)return;let e=()=>{f(!1),a?.()};return window.addEventListener(`scroll`,e,!0),()=>window.removeEventListener(`scroll`,e,!0)},[p,a]),(0,U.jsxs)(U.Fragment,{children:[(0,U.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,U.jsx)(mt,{size:13,"aria-hidden":`true`})}),p&&(0,xx.createPortal)((0,U.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 CC(e){return e<.1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function wC(e){return e?`${CC(e.input_per_million)} in · ${CC(e.output_per_million)} out per 1M tokens`:`price unknown`}function TC(e){return`$${e.toFixed(2)}`}var EC=2e3,DC=`waiting_for_os_permission`,OC=5;function kC(e,t){let n=e.rank?`#${e.rank} ${e.note??``}`.trim():null;return t?[n,wC(e.price)].filter(e=>!!e):[Ds(e.placement),e.size_gb?`${e.size_gb} GB`:null,e.tokens_per_second?`${Math.round(e.tokens_per_second)} tok/s on this PC`:null,n,e.custom?`added by you`:null].filter(e=>!!e)}function AC({m:e,onDownload:t,busy:n}){if(As(e)){let t=Math.round(e.download_progress?.percent??0);return(0,U.jsxs)(`span`,{className:`model-state is-downloading`,title:`Downloading, ${t}%`,children:[(0,U.jsx)(B,{size:12,className:`spin`,"aria-hidden":`true`}),` `,t,`%`]})}let r=ks(e);return r===`not_downloaded`?(0,U.jsx)(`button`,{type:`button`,className:`model-state-btn`,onClick:e=>{e.stopPropagation(),t()},disabled:n,"aria-label":`Download ${e.display_name??e.id}`,title:Es.not_downloaded,tabIndex:-1,children:(0,U.jsx)(Oe,{size:13,"aria-hidden":`true`})}):r===`loaded`?(0,U.jsx)(`span`,{className:`model-state is-loaded`,role:`img`,"aria-label":Es.loaded,title:Es.loaded}):(0,U.jsx)(`span`,{className:`model-state is-ready`,title:Es.downloaded,children:`Ready`})}function jC(){let e=ps(e=>e.active),t=ps(e=>e.select),n=ps(e=>e.queued),r=ps(e=>e.queue),i=ps(e=>e.queueError),a=ps(e=>e.rememberNames);ps(e=>e.names);let o=bs(),s=H(t=>xs(e,t.sessions,t.currentSessionId)),c=H(e=>e.isStreaming),l=H(e=>e.openSettings),u=(0,V.useRef)(null),[d,f]=(0,V.useState)(!1),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(0),[_,v]=(0,V.useState)(null),[y,b]=(0,V.useState)(null),[x,S]=(0,V.useState)(null),[C,w]=(0,V.useState)(null),[T,E]=(0,V.useState)(null),[D,O]=(0,V.useState)(0),[k,A]=(0,V.useState)(null),ee=(0,V.useRef)(0),j=(0,V.useRef)(null),M=(0,V.useId)(),N=(0,V.useRef)(null),[P,ne]=(0,V.useState)(null),[ie,F]=(0,V.useState)(null),ae=(0,V.useCallback)(()=>F(null),[]),oe=(0,V.useCallback)(()=>f(!1),[]),se=(0,V.useRef)(!1),le=(0,V.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,V.useEffect)(()=>{d&&(b(null),ne(null),F(null),le())},[d,le]),(0,V.useEffect)(()=>{if(!d||!p||!se.current)return;let e=N.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(N.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(As)),fe=!!p?.some(e=>e.provider.key_state===DC);(0,V.useEffect)(()=>{if(!(d||T)||!(de||T||fe))return;let e=setInterval(()=>{le(!0)},EC);return()=>clearInterval(e)},[d,de,T,fe,le]);let I=(0,V.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]),L=(0,V.useCallback)(async(n,i)=>{if(i.remote&&!e?.remote&&y?.model!==n)return b({model:n,provider:i}),null;if(b(null),c)return r(n===e?.model?null:n),f(!1),null;S(n),v(null);try{return await t(n),A(null),f(!1),null}catch(e){let t=e instanceof Error?e.message:String(e);return v(t),t}finally{S(null)}},[e?.model,e?.remote,y,r,t,c]);(0,V.useEffect)(()=>{if(!T||!p||D>0)return;let{model:e,provider:t}=T,n=()=>(j.current!==p&&(j.current=p,ee.current+=1),ee.current>=OC),r=p.flatMap(e=>e.models).find(t=>t.id===e);if(!r){if(!n())return;E(null),A(`${gs(e)} is no longer in the model list, so it wasn't switched to.`);return}if(As(r)){ee.current=0;return}let i=r.download_progress;if(i?.state===`error`)E(null),A(`Downloading ${gs(e)} failed: ${i.message??`no reason given`}`);else if(i?.state!==`complete`&&ks(r)===`not_downloaded`){if(!n())return;E(null),A(`The download of ${gs(e)} never started. Try the download button again.`)}else E(null),L(e,t).then(t=>{t&&A(`${gs(e)} downloaded, but switching to it failed: ${t}`)})},[p,T,D,L]);let R=p?.flatMap(({provider:e,models:t})=>[...e.remote&&!e.models_discovered?[`key:${e.id}`]:[],...t.filter(e=>x===null&&!As(e)).map(e=>e.id)])??[],me=n??e?.model,he=P&&R.includes(P)?P:me&&R.includes(me)?me:R[0],ge=e=>({role:`option`,tabIndex:e===he?0:-1,"data-row":e,onFocus:()=>ne(e),onBlur:()=>F(null)}),ve=o?.remote?_e:o?we:pe,z=s?gs(s):`Model`,ye=`${z}${o?` · ${o.label}`:``}`,be=Object.fromEntries((p??[]).map(e=>[e.provider.id,ws(e.models)])),xe=e?.downloaded===!1&&s===e.model,Se=k||i||(n?`${gs(n)} is used from your next message.`:e?.config_error?e.config_error:xe?`${z} 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`):ys);return(0,U.jsxs)(`div`,{className:`composer-chip-wrap`,children:[(0,U.jsxs)(`button`,{ref:u,type:`button`,className:`composer-chip${xe||i||k?` is-warning`:``}`,onClick:()=>f(e=>!e),"aria-haspopup":`dialog`,"aria-expanded":d,title:Se,children:[(0,U.jsx)(ve,{size:13,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`composer-chip-label`,children:ye}),n&&(0,U.jsxs)(`span`,{className:`composer-chip-next`,children:[`→ `,gs(n),` next`]}),xe&&(0,U.jsx)(Oe,{size:12,"aria-label":`Not downloaded`}),k&&(0,U.jsx)(ce,{size:12,"aria-label":`Model switch failed`}),(0,U.jsx)(re,{size:12,"aria-hidden":`true`})]}),(0,U.jsxs)(ni,{open:d,onClose:oe,anchor:u,label:`Choose a model`,align:`end`,children:[c&&(0,U.jsxs)(`div`,{className:`popover-message`,role:`status`,children:[`This reply keeps `,s?gs(s):`its model`,`. A model you pick here is used from your next message.`]}),k&&(0,U.jsx)(`div`,{className:`popover-message is-error`,role:`alert`,children:k}),i&&(0,U.jsx)(`div`,{className:`popover-message is-error`,role:`alert`,children:i}),_&&(0,U.jsx)(`div`,{className:`popover-message is-error`,role:`alert`,children:_}),!p&&!_&&(0,U.jsxs)(`div`,{className:`popover-message`,children:[(0,U.jsx)(B,{size:13,className:`spin`}),` Loading models…`]}),p&&(0,U.jsx)(`div`,{ref:N,role:`listbox`,"aria-label":`Models`,onKeyDown:ue,children:p.map(({provider:t,models:r,error:i})=>(0,U.jsxs)(`div`,{role:`group`,"aria-labelledby":`${M}-${t.id}`,children:[(0,U.jsx)(`div`,{className:`popover-heading`,id:`${M}-${t.id}`,children:t.name}),i&&(0,U.jsx)(`div`,{className:`popover-message is-error`,children:i}),t.key_state===DC?(0,U.jsxs)(`div`,{className:`popover-message`,role:`status`,children:[(0,U.jsx)(B,{size:13,className:`spin`,"aria-hidden":`true`}),` `,t.key_message]}):t.remote&&!t.models_discovered&&(0,U.jsxs)(`button`,{type:`button`,className:`popover-item`,...ge(`key:${t.id}`),"aria-selected":!1,onClick:()=>{f(!1),l(`model`,t.id)},children:[(0,U.jsx)(`span`,{className:`popover-item-check`,children:(0,U.jsx)(gt,{size:13,"aria-hidden":`true`})}),(0,U.jsxs)(`span`,{className:`popover-item-body`,children:[(0,U.jsx)(`span`,{className:`popover-item-title`,children:`Add your key`}),(0,U.jsxs)(`span`,{className:`popover-item-note`,children:[`Connect `,t.name,` in Settings`]})]})]}),!i&&r.length===0&&t.models_discovered!==!1&&(0,U.jsx)(`div`,{className:`popover-message`,children:`No models yet.`}),r.map(r=>{let i=hs(n??e?.model,r.id),a=!t.remote&&ks(r)===`not_downloaded`,o=be[t.id][r.id],s=kC(r,t.remote),c=`${M}-info-${t.id}-${r.id}`;return(0,U.jsxs)(`div`,{className:`popover-row`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`popover-item`,onClick:()=>{a?(ee.current=0,A(null),E({model:r.id,provider:t}),I(r.id)):(E(null),L(r.id,t))},disabled:x!==null||As(r),...ge(r.id),"aria-selected":i,"aria-describedby":ie===r.id?c:void 0,children:[(0,U.jsx)(`span`,{className:`popover-item-check`,"aria-hidden":`true`,children:x===r.id?(0,U.jsx)(B,{size:13,className:`spin`}):i?(0,U.jsx)(te,{size:13}):null}),(0,U.jsx)(`span`,{className:`popover-item-body`,children:(0,U.jsx)(`span`,{className:`popover-item-title`,children:o})})]}),(0,U.jsxs)(SC,{label:`About ${o}`,warning:!!r.placement?.warning,id:c,pinned:ie===r.id,onUnpin:ae,tabIndex:-1,children:[(0,U.jsx)(`div`,{className:`info-bubble-title`,children:o}),s.length>0&&(0,U.jsx)(`ul`,{className:`info-bubble-lines`,children:s.map(e=>(0,U.jsx)(`li`,{children:e},e))}),r.placement?.warning&&(0,U.jsx)(`ul`,{className:`info-bubble-lines`,children:(0,U.jsx)(`li`,{className:`is-warning`,children:r.placement.warning})}),(0,U.jsx)(`div`,{className:`info-bubble-id`,children:r.id})]}),(0,U.jsx)(`span`,{className:`popover-row-state`,children:!t.remote&&(0,U.jsx)(AC,{m:r,busy:C!==null,onDownload:()=>void I(r.id)})})]},r.id)})]},t.id))}),y&&(0,U.jsxs)(`div`,{className:`popover-message`,role:`alert`,children:[y.provider.privacy_notice,` `,(0,U.jsxs)(`button`,{type:`button`,className:`link-btn`,onClick:()=>L(y.model,y.provider),children:[`Use `,gs(y.model)]})]}),h>0&&(0,U.jsxs)(`button`,{type:`button`,className:`popover-item`,onClick:()=>{f(!1),l(`model`)},children:[(0,U.jsx)(`span`,{className:`popover-item-check`}),(0,U.jsx)(`span`,{className:`popover-item-body`,children:(0,U.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,U.jsx)(`div`,{className:`popover-divider`}),(0,U.jsxs)(`button`,{type:`button`,className:`popover-item`,onClick:()=>{f(!1),l(`model`)},children:[(0,U.jsx)(`span`,{className:`popover-item-check`,children:(0,U.jsx)(St,{size:13,"aria-hidden":`true`})}),(0,U.jsxs)(`span`,{className:`popover-item-body`,children:[(0,U.jsx)(`span`,{className:`popover-item-title`,children:`Add a model from a link…`}),(0,U.jsx)(`span`,{className:`popover-item-note`,children:`Any GGUF chat model on Hugging Face`})]})]}),(0,U.jsxs)(`button`,{type:`button`,className:`popover-item`,onClick:()=>{f(!1),l(`model`)},children:[(0,U.jsx)(`span`,{className:`popover-item-check`}),(0,U.jsx)(`span`,{className:`popover-item-body`,children:(0,U.jsx)(`span`,{className:`popover-item-title`,children:`Providers and keys…`})})]})]})]})}function MC(e,t,n){if(e==null||!t(e))throw Error(`the server sent no ${n}`);return e}var NC=e=>e.startsWith(`.`);function PC({onPick:e,onClose:t}){let[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(``),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(!1);ei(!0,t);let f=(0,V.useRef)(null);Ox(f,!0);let p=(0,V.useCallback)(e=>{l(!0),s(null),Promise.resolve().then(()=>So(e)).then(e=>{let t=MC(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,V.useEffect)(()=>p(),[p]);let m=n?.entries.filter(e=>e.type===`folder`)??[],h=u?m:m.filter(e=>!NC(e.name));return(0,U.jsx)(`div`,{className:`modal-overlay`,onClick:t,children:(0,U.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,U.jsxs)(`div`,{className:`modal-header`,children:[(0,U.jsx)(`h3`,{children:`Add a folder`}),(0,U.jsx)(`button`,{type:`button`,className:`btn-icon`,onClick:t,"aria-label":`Close`,children:(0,U.jsx)(Bn,{size:18})})]}),(0,U.jsxs)(`div`,{className:`modal-body sp-picker-body`,children:[(0,U.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,U.jsxs)(`form`,{className:`sp-picker-path`,onSubmit:e=>{e.preventDefault(),i.trim()&&p(i.trim())},children:[(0,U.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),"aria-label":`Folder path`,spellCheck:!1}),(0,U.jsx)(`button`,{type:`submit`,className:`sp-action`,children:`Go`})]}),n&&(0,U.jsxs)(`div`,{className:`sp-picker-quick`,children:[n.quick_links.map(e=>(0,U.jsx)(`button`,{type:`button`,className:`sp-action`,onClick:()=>p(e.path),children:e.name},e.path)),(0,U.jsxs)(`label`,{className:`sp-picker-hidden`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked)}),`Show hidden`]})]}),(0,U.jsxs)(`ul`,{className:`sp-picker-list`,"aria-busy":c,children:[n?.parent_path&&(0,U.jsx)(`li`,{children:(0,U.jsxs)(`button`,{type:`button`,onClick:()=>p(n.parent_path??void 0),children:[(0,U.jsx)(S,{size:13,"aria-hidden":`true`}),` Up one level`]})}),h.map(e=>(0,U.jsx)(`li`,{children:(0,U.jsxs)(`button`,{type:`button`,onClick:()=>p(e.path),children:[(0,U.jsx)(et,{size:13,"aria-hidden":`true`}),` `,e.name]})},e.path)),n&&h.length===0&&(0,U.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,U.jsxs)(`li`,{className:`sp-meta`,children:[(0,U.jsx)(B,{size:12,className:`spin`,"aria-hidden":`true`}),` Loading…`]})]}),o&&(0,U.jsx)(`p`,{className:`sp-error`,role:`alert`,children:o})]}),(0,U.jsxs)(`div`,{className:`sp-picker-actions`,children:[(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:t,children:`Cancel`}),(0,U.jsx)(`button`,{type:`button`,className:`btn-primary`,disabled:!n,onClick:()=>n&&e(n.current_path),children:`Use this folder`})]})]})})}function FC(e){let[t,n]=(0,V.useState)(!1),[r,i]=(0,V.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,U.jsx)(PC,{onPick:t=>{n(!1),e(t)},onClose:()=>n(!1)}):null,error:r}}var IC=new Map;function LC(e){let t=IC.get(e);return t||(t={env:null,error:null,inFlight:null,version:0,listeners:new Set},IC.set(e,t)),t}function RC(e,t,n){let r=LC(e);r.env=t??r.env,r.error=n,r.listeners.forEach(e=>e())}function zC(e){let t=LC(e);if(t.inFlight)return t.inFlight;let n=t.version;return t.inFlight=Promise.resolve().then(()=>qo(e)).then(r=>{let i=MC(r,e=>Array.isArray(e.folders),`chat's environment`);t.version===n&&RC(e,i,null)}).catch(t=>RC(e,null,t instanceof Error?t.message:String(t))).finally(()=>{t.inFlight=null}),t.inFlight}function BC(e){let[,t]=(0,V.useState)(0);(0,V.useEffect)(()=>{let n=LC(e),r=()=>t(e=>e+1);return n.listeners.add(r),!n.env&&!n.inFlight&&zC(e),()=>{n.listeners.delete(r)}},[e]);let n=(0,V.useCallback)(()=>zC(e),[e]),r=(0,V.useCallback)(async t=>{let n=await t();return LC(e).version+=1,RC(e,n,null),n},[e]),i=LC(e);return{env:i.env,error:i.error,refresh:n,change:r}}var VC=e=>e.split(/[\\/]/).filter(Boolean).pop()??e;function HC({folder:e,disabled:t}){let n=H(e=>e.draftFolder),r=H(e=>e.setDraftFolder),{open:i,picker:a,error:o}=FC(r),s=e.gaia_folder?`GAIA works in its own folder, ${e.path}.`:`GAIA works in ${e.path}.`;return e.choosable?(0,U.jsxs)(U.Fragment,{children:[(0,U.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 ${VC(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,U.jsx)(et,{size:13,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`new-chat-folder-name`,children:n?`${e.name} + ${VC(n)}`:e.name}),(0,U.jsx)(re,{size:12,"aria-hidden":`true`})]}),n&&(0,U.jsx)(`button`,{type:`button`,className:`btn-icon-sm new-chat-folder-clear`,onClick:()=>r(null),disabled:t,"aria-label":`Don't give this chat ${VC(n)}`,title:`Don't add this folder`,children:(0,U.jsx)(Bn,{size:12})}),o&&(0,U.jsx)(`span`,{className:`new-chat-folder-error`,role:`alert`,children:o}),a]}):(0,U.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,U.jsx)(et,{size:13,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`new-chat-folder-name`,children:e.name})]})}function UC({sessionId:e,onOpen:t}){let{env:n}=BC(e),r=n?.folders.find(e=>e.source===`working_folder`);if(!r)return null;let i=VC(r.path);return(0,U.jsxs)(`button`,{type:`button`,className:`composer-chip folder-chip`,title:`GAIA works in ${r.path}`,"aria-label":`Working folder ${i}, show the chat's folders`,onClick:t,children:[(0,U.jsx)(et,{size:13,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`composer-chip-label`,children:i})]})}var WC=`gaia:permission-mode`;function GC(e,t){window.dispatchEvent(new CustomEvent(WC,{detail:{sessionId:e,mode:t}}))}function KC(e,t){let n=(0,V.useRef)(t);n.current=t,(0,V.useEffect)(()=>{if(!e)return;let t=t=>{let r=t.detail;r?.sessionId===e&&n.current(r.mode)};return window.addEventListener(WC,t),()=>window.removeEventListener(WC,t)},[e])}var qC=[{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 JC({sessionId:e,disabled:t}){let n=H(e=>e.draftPermissionMode),r=H(e=>e.setDraftPermissionMode),[i,a]=(0,V.useState)(e?`ask`:n),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(null),f=(0,V.useRef)(null);(0,V.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]),KC(e,a);let p=(0,V.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),GC(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,U.jsxs)(`div`,{className:`composer-chip-wrap`,children:[(0,U.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,U.jsx)(m?un:fn,{size:13,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`composer-chip-label`,children:m?`Full access`:`Ask`}),(0,U.jsx)(re,{size:12,"aria-hidden":`true`})]}),(0,U.jsxs)(ni,{open:o,onClose:()=>s(!1),anchor:f,label:`Permission mode`,children:[qC.map(e=>(0,U.jsxs)(`button`,{type:`button`,className:`popover-item`,onClick:()=>p(e.mode),"aria-pressed":i===e.mode,children:[(0,U.jsx)(`span`,{className:`popover-item-check`,"aria-hidden":`true`,children:i===e.mode&&(0,U.jsx)(te,{size:13})}),(0,U.jsxs)(`span`,{className:`popover-item-body`,children:[(0,U.jsx)(`span`,{className:`popover-item-title`,children:e.label}),(0,U.jsx)(`span`,{className:`popover-item-note`,children:e.note})]})]},e.mode)),c&&(0,U.jsxs)(`div`,{className:`popover-message`,role:`alert`,children:[`Full access lets GAIA change files and run commands on this PC without asking.`,` `,(0,U.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>p(`full_access`),children:`Turn it on`})]}),u&&(0,U.jsx)(`div`,{className:`popover-message is-error`,role:`alert`,children:u})]})]})}var YC={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 XC(e,t){return e?YC.queued:t?`GAIA is still busy in this chat. Trying again in a few seconds.`:`Sending next.`}function ZC({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,U.jsx)(`ul`,{className:`queued-messages`,"aria-label":`Messages waiting to send`,"aria-live":`polite`,children:o.map(e=>(0,U.jsxs)(`li`,{className:`queued-message is-${e.state}`,children:[e.state===`failed`?(0,U.jsx)(ce,{size:12,"aria-hidden":`true`}):e.state===`queued`?(0,U.jsx)(he,{size:12,"aria-hidden":`true`}):(0,U.jsx)(Se,{size:12,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`queued-message-text`,title:e.text,children:e.text}),(0,U.jsx)(`span`,{className:`queued-message-state`,title:e.error,children:e.state===`failed`?`Not sent. ${e.error??``}`.trim():e.state===`queued`?XC(i,a):YC[e.state]}),e.state===`failed`&&(0,U.jsxs)(`button`,{type:`button`,className:`queued-message-steer`,onClick:()=>r(e.id),"aria-label":`Send again: ${e.text}`,children:[(0,U.jsx)(rn,{size:11,"aria-hidden":`true`}),` Send again`]}),e.state===`queued`&&n&&(0,U.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,U.jsx)(`button`,{type:`button`,className:`queued-message-remove`,onClick:()=>t(e.id),"aria-label":`Remove queued message: ${e.text}`,title:`Remove`,children:(0,U.jsx)(Bn,{size:12})})]},e.id))})}var QC=`unknown`,$C=e=>e.toLocaleString(`en-US`);function ew({n:e}){if(e==null)return(0,U.jsx)(`span`,{className:`cp-unknown`,children:QC});let t=e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(+(e<1e4))}K`:`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`;return(0,U.jsx)(`span`,{title:`${$C(e)} tokens`,children:t})}function tw({s:e}){if(e==null)return(0,U.jsx)(`span`,{className:`cp-unknown`,children:QC});let t=e<.1?e===0?`0 s`:`<0.1 s`:e<10?`${e.toFixed(1)} s`:`${Math.round(e)} s`;return(0,U.jsx)(`span`,{title:`${(e*1e3).toFixed(0)} ms`,children:t})}function nw({r:e}){return e==null?(0,U.jsx)(`span`,{className:`cp-unknown`,children:QC}):(0,U.jsxs)(`span`,{title:`${e} tokens per second`,children:[Math.round(e).toLocaleString(`en-US`),` tokens/s`]})}var rw=(e,t)=>t>0?Math.round(e/t*100):0,iw=(e,t)=>{let n=rw(e,t);return n===0&&e>0?`<1`:String(n)},aw=(e,t)=>t&&e!=null?Math.floor(e/t*100):null,ow=256;function sw(e){if(e.provider===`unknown`)return QC;if(e.provider===`cloud`)return`Cloud`;if(e.provider!==`local`)return`Cloud · ${Ts(e.provider)}`;if(!e.device)return e.loaded===!1?`Not loaded now`:QC;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 cw({label:e,children:t,hint:n}){return(0,U.jsxs)(`div`,{className:`cp-row`,title:n,children:[(0,U.jsx)(`dt`,{children:e}),(0,U.jsx)(`dd`,{children:t})]})}function lw({t:e}){if(e.model_seconds==null||e.gaia_seconds==null)return(0,U.jsxs)(cw,{label:`Took`,children:[(0,U.jsx)(tw,{s:e.wall_seconds}),` · split `,(0,U.jsx)(`span`,{className:`cp-unknown`,children:QC})]});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,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(cw,{label:`Took`,hint:`From sending the message to the answer being saved`,children:(0,U.jsx)(tw,{s:e.wall_seconds})}),(0,U.jsx)(`div`,{className:`cp-stack`,"aria-hidden":`true`,children:t.map(t=>(0,U.jsx)(`span`,{className:`cp-time-${t.key}`,style:{width:`${rw(t.s,e.wall_seconds)}%`}},t.key))}),(0,U.jsxs)(`dl`,{className:`cp-rows cp-indent`,children:[(0,U.jsx)(cw,{label:`In the model`,children:(0,U.jsx)(tw,{s:e.model_seconds})}),(0,U.jsx)(cw,{label:`In GAIA`,hint:`Everything that was not the model: tools, waiting on you, and GAIA's own work`,children:(0,U.jsx)(tw,{s:e.gaia_seconds})}),t.slice(1).filter(e=>e.s>0).map(e=>(0,U.jsxs)(cw,{label:`· ${e.label}`,children:[(0,U.jsx)(`span`,{className:`swatch cp-time-${e.key}`,"aria-hidden":`true`}),` `,(0,U.jsx)(tw,{s:e.s})]},e.key))]})]})}function uw({why:e}){return(0,U.jsx)(`span`,{className:`cp-unknown`,title:e,children:QC})}var dw={server:`Reported by the model server`,client:`Measured by GAIA on the stream, network included`};function fw(e){return e?dw[e]:void 0}function pw({turn:e}){let t=aw(e.tokens_cached,e.tokens_in),n=e.unknown??{},r=e.tools.map(e=>`${e.name??`tool work outside a step`}: ${e.seconds??`?`} s`).join(`
|
|
61
61
|
`);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(lw,{t:e.time}),(0,U.jsxs)(`dl`,{className:`cp-rows`,children:[(0,U.jsx)(cw,{label:`First word`,hint:fw(e.first_token_source),children:e.first_token_seconds==null?(0,U.jsx)(uw,{why:n.first_token_seconds}):(0,U.jsxs)(U.Fragment,{children:[`in `,(0,U.jsx)(tw,{s:e.first_token_seconds})]})}),(0,U.jsx)(cw,{label:`Reading the prompt`,hint:`Prefill: new prompt tokens over time to first token`,children:e.tokens_new!=null&&e.tokens_new<ow?(0,U.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,U.jsx)(uw,{why:n.prefill_tokens_per_second}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(nw,{r:e.prefill_tokens_per_second}),e.prefill_source===`client`&&(0,U.jsx)(`span`,{className:`cp-chip`,title:`Measured by GAIA from the first word, so it includes network and queue time`,children:`approx.`})]})}),(0,U.jsx)(cw,{label:`Writing the answer`,hint:fw(e.generation_source)??`Generation speed, weighted by tokens`,children:e.generation_tokens_per_second==null?(0,U.jsx)(uw,{why:n.generation_tokens_per_second}):(0,U.jsx)(nw,{r:e.generation_tokens_per_second})}),(0,U.jsxs)(cw,{label:`Tokens in → out`,hint:n.tokens,children:[(0,U.jsx)(ew,{n:e.tokens_in}),` → `,(0,U.jsx)(ew,{n:e.tokens_out})]}),(0,U.jsx)(cw,{label:`Reused from cache`,hint:`Prompt tokens the server did not have to read again`,children:e.tokens_cached==null?(0,U.jsx)(uw,{why:n.tokens_cached}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ew,{n:e.tokens_cached}),t!=null&&` (${t}%)`]})}),(0,U.jsx)(cw,{label:`Model calls`,children:e.model_calls}),(0,U.jsx)(cw,{label:`Tool calls`,hint:r||void 0,children:e.tool_calls===0&&!e.tool_seconds_total?`none`:(0,U.jsxs)(U.Fragment,{children:[e.tool_calls,` · `,(0,U.jsx)(tw,{s:e.tool_seconds_total??0})]})}),(0,U.jsx)(cw,{label:`Model loads`,children:e.loads.length===0?`none`:(0,U.jsxs)(`span`,{title:e.loads.map(e=>`${e.model}${e.replaced?.length?` replaced ${e.replaced.join(`, `)}`:``}: ${e.seconds} s`).join(`
|
|
@@ -74,5 +74,5 @@ Details: ${u}`+f:t instanceof TypeError||u.includes(`fetch`)||u.includes(`Failed
|
|
|
74
74
|
`)))}else tt.length===0||st||O||P||vt.current||De||A?.init_state===`initializing`||pt()||!it.current&&!Bt||QS(e,Vt,()=>_t.current&&!pt()&&!H.getState().isStreaming&&!Tt.current)}},[Ht,tt,st,Bt,O,P,De,A?.init_state,e,Vt,pt]);let Ut=(0,V.useRef)(!1);(0,V.useEffect)(()=>{Ut.current&&!Ht&&xt(),Ut.current=Ht},[Ht,xt]);let Wt=(0,V.useCallback)(t=>{let n=tt.find(e=>e.id===t&&e.state===`queued`);n&&l&&(nt(e=>Er(e,t,`queued`,`sending`)),Ti(e,n.text).then(()=>nt(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}`),nt(e=>Er(e,t,`sending`,`queued`))}))},[tt,l,e,nt]),Kt=(0,V.useCallback)(()=>{for(let e=n.length-1;e>=0;e--)if(n[e].role===`user`){zt(n[e]);return}},[n,zt]),qt=()=>{I(F?.title||``),ue(!0)},Jt=async()=>{let t=de.trim().slice(0,200).trim();t&&de!==F?.title&&t!==F?.title&&(await za(e,{title:t,title_is_custom:!0}),c(e,{title:t})),ue(!1)},Yt=(0,V.useCallback)(async()=>{if(e)try{let t=await Ga(e);c(e,{private:t.private})}catch(e){s.ui.warn(`Failed to toggle private mode`,e)}},[e,c]),Xt=(0,V.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 xo(e,n);let t=(H.getState().sessions.find(t=>t.id===e)?.document_ids??[]).filter(e=>e!==n);c(e,{document_ids:t}),t.length<=3&&_e(!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]),Zt=(0,V.useCallback)(async t=>{if(t.preventDefault(),t.stopPropagation(),L(!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 ho(n);if(e&&t?.id)try{await bo(e,t.id);let r=H.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 po();T(e.documents||[])}catch(e){s.doc.error(`Could not refresh the document list after a drop`,e)}}},[e,c,T]),Qt=e=>{e.preventDefault(),e.stopPropagation(),L(!0)},$t=e=>{e.preventDefault(),e.stopPropagation(),L(!1)},en=n.length>0?n[n.length-1]:void 0,tn=!l&&!O&&en?.role===`assistant`&&ib(en.content),nn=(0,V.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]),rn=De?`This chat used the retired "${De}" agent and is read-only. Start a new chat.`:A?.init_state===`initializing`?Nc:null;return(0,U.jsxs)(`main`,{className:`task-view ${pe?`drag-active`:``}`,style:{"--session-panel-w":`${At}px`},onDrop:Zt,onDragOver:Qt,onDragLeave:$t,"aria-label":F?.title||`Chat`,children:[(0,U.jsxs)(`header`,{className:`task-header`,children:[(0,U.jsx)(`div`,{className:`task-header-left`,children:le?(0,U.jsx)(`input`,{className:`title-edit`,value:de,maxLength:200,onChange:e=>I(e.target.value),onBlur:Jt,onKeyDown:e=>{e.key===`Enter`&&Jt(),e.key===`Escape`&&(e.preventDefault(),ue(!1))},...Jr,autoFocus:!0,"aria-label":`Chat title`}):(0,U.jsxs)(`button`,{type:`button`,className:`task-title`,onClick:qt,title:`Rename`,children:[(0,U.jsx)(`span`,{children:F?.title||`New chat`}),(0,U.jsx)(Gt,{size:12,"aria-hidden":`true`,className:`task-title-edit`})]})}),(0,U.jsxs)(`div`,{className:`task-header-right`,children:[(0,U.jsx)(BT,{isPrivate:!!F?.private,onToggle:Yt}),(0,U.jsx)(`button`,{className:`btn-icon-sm`,onClick:()=>D(!0),title:`Browse files on this PC`,"aria-label":`Browse files on this PC`,children:(0,U.jsx)(Qe,{size:15})}),(0,U.jsx)(`button`,{className:`btn-icon-sm`,onClick:we,title:`Export as Markdown`,"aria-label":`Export chat`,children:(0,U.jsx)(Oe,{size:15})}),(0,U.jsx)(zT,{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=ge?e:e.slice(0,3),n=e.length-3;return(0,U.jsxs)(`div`,{className:`doc-context-bar${ge?` doc-context-expanded`:``}`,"aria-label":`${oe.length} indexed document${oe.length===1?``:`s`}`,children:[(0,U.jsx)(fe,{size:12,className:`doc-context-icon`,"aria-hidden":`true`}),(0,U.jsxs)(`button`,{type:`button`,className:`doc-context-label`,onClick:()=>E(!0),title:`Manage documents`,children:[oe.length,` indexed`]}),(0,U.jsxs)(`div`,{className:`doc-context-pills${ge?` doc-context-pills-expanded`:``}`,children:[t.map(e=>(0,U.jsxs)(`span`,{className:`doc-pill`,title:e.filepath||e.filename,children:[(0,U.jsx)(We,{size:9,className:`doc-pill-icon`,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`doc-pill-name`,children:e.filename}),(0,U.jsx)(`button`,{className:`doc-pill-remove`,onClick:t=>Xt(t,e.id),"aria-label":`Remove ${e.filename} from this chat`,children:(0,U.jsx)(Bn,{size:10})})]},e.id)),!ge&&n>0&&(0,U.jsxs)(`button`,{className:`doc-pill-more`,onClick:e=>{e.stopPropagation(),_e(!0)},children:[`+`,n,` more`]}),ge&&n>0&&(0,U.jsx)(`button`,{className:`doc-pill-collapse`,onClick:e=>{e.stopPropagation(),_e(!1)},children:`show less`})]})]})})(),(0,U.jsx)(`div`,{className:`messages-scroll`,ref:Re,onScroll:kt,children:(0,U.jsxs)(`div`,{className:`messages-column`,children:[O&&(0,U.jsx)(`div`,{className:`skeleton-messages`,"aria-label":`Loading messages`,children:[0,1,2].map(e=>(0,U.jsx)(`div`,{className:`skeleton-msg`,children:(0,U.jsxs)(`div`,{className:`skeleton-lines`,children:[(0,U.jsx)(`div`,{className:`skeleton-line`}),(0,U.jsx)(`div`,{className:`skeleton-line`}),e!==2&&(0,U.jsx)(`div`,{className:`skeleton-line`})]})},e))}),n.map((e,t)=>{if(ke&&e.role===`assistant`&&t===n.length-1)return null;let r=e.role===`assistant`?e.historyNotice??uE.get(e.id):void 0,i=!Ht&&!Ct&&!De&&!ke&&e.role===`assistant`&&t===n.length-1&&!e.stopState&&!Lx(e.content),a=e.stats?.seconds==null?nn.get(e.id):e.stats.seconds*1e3;return(0,U.jsxs)(`div`,{className:ve===e.id?`msg-deleting`:void 0,"data-message-id":e.id,"data-role":e.role,children:[r&&(0,U.jsx)(dE,{text:r}),(0,U.jsx)(rS,{message:e,agentSteps:e.role===`assistant`?e.agentSteps:void 0,onDelete:Ht?void 0:Rt,onResend:!Ht&&e.role===`user`&&!De?zt:void 0,extraActions:i?(0,U.jsx)(ww,{answeredBy:e.stats?.model??F?.effective_model,onPick:t=>Et(e,t)}):void 0,latencyMs:a}),Ct?.messageId===e.id&&(0,U.jsx)(Dw,{original:e,originalModel:e.stats?.model??F?.effective_model,originalLatencyMs:a,state:Ct.state,keeping:Ct.keeping,onKeep:e=>{Dt(e)},onClose:B})]},e.id)}),(l||ke)&&je&&(0,U.jsx)(dE,{text:je}),(l||ke)&&(0,U.jsx)(`div`,{className:`streaming-bubble ${ke?`stream-ending`:`stream-active`}`,children:(0,U.jsx)(rS,{message:{id:-1,session_id:e,role:`assistant`,content:(l?u:Ne.current)||``,created_at:``,rag_sources:null},isStreaming:l,agentSteps:l?m:Pe.current,agentStepsActive:l&&m.some(e=>e.active),cards:l?x:Fe.current,liveStatus:l?te:null,awaitingUser:l&&(ne||re||ie)})}),(0,U.jsx)(`div`,{ref:Le})]})}),(0,U.jsx)(RT,{sessionId:e,messages:n,busy:Ht,onUsage:St,onJumpToMessage:Mt}),R&&(0,U.jsx)(`button`,{className:`scroll-bottom-btn`,onClick:Nt,title:`Scroll to bottom`,"aria-label":`Scroll to bottom`,children:(0,U.jsx)(v,{size:16})}),pe&&(0,U.jsxs)(`div`,{className:`drag-overlay`,children:[(0,U.jsx)(Pn,{size:32,strokeWidth:1.5,"aria-hidden":`true`}),(0,U.jsx)(`span`,{children:`Drop files to index them for this chat`})]}),ye&&(0,U.jsxs)(`div`,{className:`toast policy-alert-toast`,role:`alert`,children:[(0,U.jsxs)(`span`,{children:[`Blocked: `,ye.tool,` is restricted by policy.`]}),ye.receiptId?(0,U.jsx)(`button`,{type:`button`,className:`policy-alert-toast-link`,onClick:()=>{let e=ye.receiptId;e&&(N(`policy_alert`),M(!0),Ce(e))},children:`View receipt`}):(0,U.jsx)(`span`,{className:`policy-alert-toast-missing`,children:`Receipt unavailable`})]}),(0,U.jsx)(`div`,{className:`input-area`,children:(0,U.jsxs)(`div`,{className:`input-column`,children:[(0,U.jsx)(HT,{message:Te,onDismiss:Ee}),tn&&en&&(0,U.jsx)(gC,{content:en.content,onRetry:Kt}),(0,U.jsx)(Yv,{sessionId:e}),(0,U.jsx)(Sw,{usage:yt}),(0,U.jsx)(VT,{sessionId:e}),(0,U.jsx)(ZC,{items:tt,onRemove:e=>nt(t=>Dr(t,e)),onRetry:e=>nt(t=>Er(t,e,`failed`,`queued`)),onSteer:l&&!Ke?Wt:void 0,replying:l,busyRetry:!!st}),(0,U.jsx)(yC,{value:se,onChange:ce,onSubmit:()=>Ft(),onStop:Pt,streaming:l,stopping:Ke,queueWhileStreaming:!0,disabledReason:rn,attachments:he,inputRef:ze,placeholder:l?`Queue your next message`:n.length===0?`Ask GAIA anything`:`Reply to GAIA`,leftControls:(0,U.jsx)(JC,{sessionId:e,disabled:!!De}),rightControls:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(xw,{usage:yt,unavailable:bt,sessionId:e,busy:Ht,onUsage:St,onDetails:()=>jt(`context`)}),(0,U.jsx)(UC,{sessionId:e,onOpen:()=>jt(`environment`)}),(0,U.jsx)(jC,{})]})})]})})]})}var pE=1.1,mE=60,hE=110,gE=24,_E=2.4,vE=Math.PI*2,yE=(e,t,n)=>{let r=Math.min(1,Math.max(0,(n-e)/(t-e)));return r*r*(3-2*r)};function bE(e){let t=e;return()=>{t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}var xE=class{cols=0;rows=0;w=0;h=0;ox=0;oy=0;time=0;energy=new Float32Array;offset=new Float32Array;mask=new Float32Array;phase=new Float32Array;waves=[];ripples=[];waveIn=1.5;dragIn=0;activity=`idle`;progress=0;pointer=null;exit=null;done=!1;settled=!1;rand;constructor(e=7){this.rand=bE(e)}get cleared(){return this.done}get dissolving(){return this.exit!==null||this.done}resize(e,t,n){this.w=e,this.h=t,this.cols=Math.ceil(e/30),this.rows=Math.ceil(t/30),this.ox=(e-this.cols*30)/2,this.oy=(t-this.rows*30)/2;let r=this.cols*this.rows;this.energy=new Float32Array(r),this.offset=new Float32Array(r*2),this.phase=Float32Array.from({length:r},()=>this.rand()*vE),this.setHole(n)}setHole(e){this.mask.length!==this.cols*this.rows&&(this.mask=new Float32Array(this.cols*this.rows));for(let t=0;t<this.rows;t++)for(let n=0;n<this.cols;n++){let[r,i]=this.center(n,t),a=Math.hypot((r-e.cx)/e.rx,(i-e.cy)/e.ry);this.mask[t*this.cols+n]=(.3+.7*yE(.75,1.5,a))*yE(0,50,i)*yE(0,50,this.h-i)}}setActivity(e){e!==this.activity&&(this.activity=e,this.waveIn=0)}setProgress(e){this.progress=Math.min(1,Math.max(0,e))}setPointer(e,t,n,r=0){this.pointer={x:e,y:t,down:n,speed:r}}clearPointer(){this.pointer=null}ripple(e,t,n){this.ripples.length>24&&this.ripples.shift(),this.ripples.push({x:e,y:t,r:0,t:0,life:1.2+n*.6,strength:n,speed:150+this.rand()*50,phase:this.rand()*vE})}dissolve(e,t){this.ripple(e,t,1);let n=Math.hypot(Math.max(e,this.w-e),Math.max(t,this.h-t))*1.15;this.exit={x:e,y:t,t:0,reach:n,phase:this.rand()*vE},this.done=!1}restore(){this.exit=null,this.done=!1,this.settled=!1,this.energy.fill(0),this.offset.fill(0),this.ripples=[],this.waves=[]}energyAt(e,t){return this.energy[t*this.cols+e]}offsetAt(e,t){let n=t*this.cols+e;return[this.offset[n*2],this.offset[n*2+1]]}center(e,t){return[this.ox+(e+.5)*30,this.oy+(t+.5)*30]}step(e){if(this.done)return!1;if(this.settled&&this.activity===`idle`&&!this.pointer&&!this.ripples.length&&!this.waves.length&&!this.exit&&this.waveIn>e)return this.waveIn-=e,!1;this.time+=e;let t=this.time,n=this.cols+this.rows*.6;if(this.waveIn-=e,this.waveIn<=0){if(this.activity===`loading`)this.waveIn=.9+this.rand()*.5,this.waves.push({front:-3,speed:14+this.rand()*6,dir:1,span:n,strength:.5+this.rand()*.2});else if(this.activity===`idle`){this.waveIn=3+this.rand()*4;let e=this.rand()<.5?1:-1;this.waves.push({front:e>0?-3:n+3,speed:7+this.rand()*4,dir:e,span:n,strength:.45})}else this.waveIn=1}let r=this.pointer;r?.down&&(this.dragIn-=e,this.dragIn<=0&&(this.dragIn=.12,this.ripple(r.x,r.y,.7)));let i=Math.exp(-e*_E),a=Math.min(1,e*14),o=Math.min(1,e*9),s=r?mE+Math.min(80,r.speed*.08):0,c=r?.5+Math.min(.45,r.speed/2e3):0,l=this.activity===`download`?this.progress*this.rows:-1,{cols:u,rows:d,energy:f,offset:p}=this,m=0,h=0;for(let e=0;e<d;e++)for(let n=0;n<u;n++){let g=e*u+n,[_,v]=this.center(n,e),y=f[g]*i,b=0,x=0,S=0,C=.55+.45*Math.sin(n*1.7+e*2.3+t*.6),w=n+e*.6+.9*Math.sin(e*.45+t*.8)+.5*Math.sin(n*.21-t*1.1);for(let e of this.waves){let t=1-Math.abs(w-e.front)/1.5;t>0&&(b=Math.max(b,t*e.strength*C))}for(let e of this.ripples){let t=_-e.x,n=v-e.y,r=Math.hypot(t,n)||1;if(Math.abs(r-e.r)>gE+.11*e.r)continue;let i=Math.atan2(n,t),a=e.r*(1+.07*Math.sin(5*i+e.phase)+.04*Math.sin(9*i-e.phase*2)),o=1-Math.abs(r-a)/gE;if(o<=0)continue;let s=(1-e.t/e.life)**1.3;b=Math.max(b,o*.85*e.strength*s),x+=t/r*o*7*e.strength*s,S+=n/r*o*7*e.strength*s}if(r){let e=_-r.x,t=v-r.y,n=Math.hypot(e,t)||1;if(n<s&&(b=Math.max(b,(1-n/s)**1.4*c)),n<hE){let i=(1-n/hE)**2*(10+Math.min(10,r.speed/120));x+=e/n*i,S+=t/n*i}}let T=0;if(l>=0){let r=l-(d-1-e+.5+.35*Math.sin(n*.55+t*2.1)+.2*Math.sin(n*1.31-t*1.3));r>0&&(T=.16),r>-1&&r<1&&(b=Math.max(b,(1-Math.abs(r))*(.45+.35*Math.sin(t*3+this.phase[g]))))}f[g]=Math.max(T,b>y?y+(b-y)*a:y),p[g*2]+=(x-p[g*2])*o,p[g*2+1]+=(S-p[g*2+1])*o,m=Math.max(m,f[g]),h=Math.max(h,Math.abs(p[g*2]),Math.abs(p[g*2+1]))}return this.settled=m<.04&&h<.05,this.waves=this.waves.filter(t=>(t.front+=t.dir*t.speed*e,t.front>=-4&&t.front<=t.span+4)),this.ripples=this.ripples.filter(t=>(t.t+=e,t.r+=t.speed*e*(1-.35*t.t/t.life),t.t<t.life)),this.exit&&(this.exit.t+=e,this.exit.t>=1.1&&(this.exit=null,this.done=!0)),!0}draw(e,t){if(e.clearRect(0,0,this.w,this.h),this.done)return;let{cols:n,rows:r,energy:i,offset:a,mask:o}=this,s=t.dark?.17:.14;e.lineWidth=1;for(let c=0;c<r;c++)for(let r=0;r<n;r++){let l=c*n+r,[u,d]=this.center(r,c),f=u+a[l*2],p=d+a[l*2+1],m=i[l],h=o[l];if(m<.04){e.fillStyle=t.fg,e.globalAlpha=s*h,e.fillRect(f-1,p-1,2,2);continue}let g=2+m*19,_=Math.max(1,6-m*3);e.beginPath(),e.roundRect(f-g/2,p-g/2,g,g,_),e.fillStyle=t.accent,e.globalAlpha=(.12+m*.22)*h,e.fill(),e.strokeStyle=t.accent,e.globalAlpha=m*.5*h,e.stroke()}this.exit&&this.drawExit(e,t),e.globalAlpha=1}drawExit(e,t){let n=this.exit,r=Math.min(1,n.t/pE),i=(1-(1-r)**3)*n.reach,a=new Path2D;for(let e=0;e<=180;e++){let t=e/180*vE,r=i*(1+.06*Math.sin(3*t+n.phase+n.t*1.5)+.03*Math.sin(5*t-n.phase*1.7-n.t*2.2)),o=n.x+Math.cos(t)*r,s=n.y+Math.sin(t)*r;e?a.lineTo(o,s):a.moveTo(o,s)}a.closePath(),e.globalAlpha=1,e.globalCompositeOperation=`destination-out`,e.fill(a),e.globalCompositeOperation=`source-over`,e.strokeStyle=t.accent,e.lineWidth=1.4,e.globalAlpha=.55*(1-r)**.7,e.stroke(a)}},SE=90;function CE(){let e=getComputedStyle(document.documentElement);return{fg:e.getPropertyValue(`--text-primary`).trim(),accent:e.getPropertyValue(`--accent-solid`).trim(),dark:document.documentElement.getAttribute(`data-theme`)===`dark`}}function wE(e,t,n){let r=e.getBoundingClientRect();return r.width?{cx:r.left-t.left+r.width/2,cy:r.top-t.top+r.height/2,rx:r.width/2+n,ry:r.height/2+n+10}:null}function TE({activity:e,progress:t=0,pulse:n,docked:r,contentRef:i,composerRef:a}){let o=(0,V.useRef)(null),c=(0,V.useRef)(null),l=(0,V.useRef)(null),u=(0,V.useRef)(()=>{}),d=(0,V.useRef)(()=>{}),f=(0,V.useRef)(r),p=(0,V.useRef)({value:n,at:0});f.current=r,(0,V.useEffect)(()=>{let e=o.current,t=e?.parentElement;if(!e||!t)return;let n=e.getContext(`2d`);if(!n){s.ui.warn(`New-chat background is off: the browser gave no 2D canvas context (often low graphics memory).`);return}l.current=t;let r=new xE;c.current=r;let p=typeof window.matchMedia==`function`?window.matchMedia(ex):null,m=CE(),h=0,g=0,_=!1,v=``,y={x:0,y:0,at:0,speed:0},b=()=>r.draw(n,m),x=(e,t=!1)=>{let n=f.current?a.current:i.current,r=(n&&wE(n,e,f.current?24:40))??{cx:e.width/2,cy:e.height/2,rx:1,ry:1},o=`${Math.round(r.cx)},${Math.round(r.cy)},${Math.round(r.rx)},${Math.round(r.ry)}`;return t||o!==v?(v=o,r):null},S=()=>{let i=t.getBoundingClientRect();if(!i.width||!i.height)return;let a=Math.min(2,window.devicePixelRatio||1);e.width=Math.round(i.width*a),e.height=Math.round(i.height*a),n.setTransform(a,0,0,a,0,0),r.resize(i.width,i.height,x(i,!0)),b()},C=e=>{if(h=requestAnimationFrame(C),e-g<31.833333333333336)return;let n=Math.min(.1,(e-g)/1e3);g=e;let i=x(t.getBoundingClientRect());i&&r.setHole(i),e-y.at>80&&(y.speed*=.8),(r.step(n)||i)&&b(),r.cleared&&T()},w=()=>{_||document.hidden||p?.matches||r.cleared||(_=!0,g=performance.now(),h=requestAnimationFrame(C))},T=()=>{_=!1,cancelAnimationFrame(h)};u.current=w,d.current=()=>{let e=x(t.getBoundingClientRect());e&&r.setHole(e),_||b()};let E=()=>document.hidden?T():w(),D=()=>{T(),b(),w()},O=()=>{m=CE(),b()},k=e=>{let n=t.getBoundingClientRect(),i=e.clientX-n.left,a=e.clientY-n.top,o=performance.now();if(y.at&&o>y.at){let e=Math.hypot(i-y.x,a-y.y)/((o-y.at)/1e3);y.speed+=(Math.min(4e3,e)-y.speed)*.35}Object.assign(y,{x:i,y:a,at:o});let s=e.target instanceof Element&&e.target.closest(`button, a, input, textarea, .composer`);r.setPointer(i,a,(e.buttons&1)==1&&!s,y.speed)},A=()=>{y.at=0,y.speed=0,r.clearPointer()},ee=typeof ResizeObserver>`u`?null:new ResizeObserver(S);ee?.observe(t,{box:`border-box`});let j=new MutationObserver(O);return j.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`,`data-palette`,`style`]}),document.addEventListener(`visibilitychange`,E),p?.addEventListener(`change`,D),t.addEventListener(`pointermove`,k),t.addEventListener(`pointerleave`,A),S(),w(),()=>{T(),ee?.disconnect(),j.disconnect(),document.removeEventListener(`visibilitychange`,E),p?.removeEventListener(`change`,D),t.removeEventListener(`pointermove`,k),t.removeEventListener(`pointerleave`,A),c.current=null,u.current=()=>{},d.current=()=>{}}},[i,a]);let m=(0,V.useCallback)(()=>{let e=l.current,t=a.current;if(!e||!t)return null;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return[r.left-n.left+r.width/2,r.top-n.top+r.height/2]},[a]);return(0,V.useEffect)(()=>{let t=c.current;if(t){if(t.setActivity(e),e===`sending`){let e=m();e&&t.dissolve(...e)}else t.dissolving&&(t.restore(),u.current())}},[e,m]),(0,V.useEffect)(()=>{c.current?.setProgress(t)},[t]),(0,V.useEffect)(()=>{d.current()},[r]),(0,V.useEffect)(()=>{let e=p.current;if(n===e.value)return;let t=performance.now();if(e.value=n,t-e.at<SE)return;e.at=t;let r=m();r&&c.current?.ripple(...r,.45)},[n,m]),(0,U.jsx)(`canvas`,{ref:o,className:`npu-backdrop`,"aria-hidden":`true`})}var EE=c();async function DE(e,t,n){let r=`${EE}${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 OE(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 kE(){return DE(`GET`,`/memory/stats`)}function AE(e=30){return DE(`GET`,`/memory/activity?days=${e}`)}function jE(e={}){return DE(`GET`,`/memory/knowledge${OE(e)}`)}function ME(e){return DE(`POST`,`/memory/knowledge`,e)}function NE(e,t){return DE(`PUT`,`/memory/knowledge/${encodeURIComponent(e)}`,t)}function PE(e){return DE(`DELETE`,`/memory/knowledge/${encodeURIComponent(e)}`)}function FE(){return DE(`GET`,`/memory/entities`)}function IE(){return DE(`GET`,`/memory/tools`)}function LE(e=20){return DE(`GET`,`/memory/conversations?limit=${e}`)}function RE(e,t=20){return DE(`GET`,`/memory/conversations/search?query=${encodeURIComponent(e)}&limit=${t}`)}function zE(e){return DE(`GET`,`/memory/conversations/${encodeURIComponent(e)}`)}function BE(e=7){return DE(`GET`,`/memory/upcoming?days=${e}`)}function VE(){return DE(`GET`,`/memory/embedding-coverage`)}function HE(){return DE(`POST`,`/memory/consolidate`)}function UE(){return DE(`POST`,`/memory/rebuild-embeddings`)}function WE(){return DE(`POST`,`/memory/reconcile`)}function GE(){return DE(`POST`,`/memory/rebuild-fts`)}function KE(){return DE(`POST`,`/memory/refresh-system-context`)}function qE(){return new EventSource(`${EE}/memory/stream-discovery`)}function JE(e){return new EventSource(`${EE}/memory/stream-inference?include_browser=${e}`)}function YE(e){return DE(`POST`,`/memory/commit-discovery`,{items:e})}function XE(e){return DE(`POST`,`/memory/commit-inference`,{insights:e})}function ZE(){return DE(`GET`,`/memory/settings`)}function QE(e){return DE(`PUT`,`/memory/settings`,e)}function $E(){return DE(`DELETE`,`/memory/all`)}function eD(){return DE(`POST`,`/memory/reinitialize`)}function tD(){return DE(`GET`,`/goals/stats`)}function nD(e={}){return DE(`GET`,`/goals${OE(e)}`)}function rD(e){return DE(`POST`,`/goals`,e)}function iD(e){return DE(`PUT`,`/goals/${encodeURIComponent(e)}/approve`)}function aD(e){return DE(`PUT`,`/goals/${encodeURIComponent(e)}/reject`)}function oD(e){return DE(`PUT`,`/goals/${encodeURIComponent(e)}/cancel`)}function sD(e){return DE(`DELETE`,`/goals/${encodeURIComponent(e)}`)}function cD({disabled:e}){let t=H(e=>e.draftPrivate),n=H(e=>e.setDraftPrivate),r=H(e=>e.settingsSection!==null),[i,a]=(0,V.useState)(null),[o,c]=(0,V.useState)(!1);return(0,V.useEffect)(()=>{if(r)return;let e=!1;return ZE().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,V.useEffect)(()=>{i===!1&&t&&n(!1)},[i,t,n]),i===!1?(0,U.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,U.jsx)(Pe,{size:13,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`composer-chip-label`,children:`Memory off`})]}):(0,U.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,U.jsx)(Pe,{size:13,"aria-hidden":`true`}):(0,U.jsx)(Ie,{size:13,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`composer-chip-label`,children:t?`Private`:o?`Memory unknown`:`Memory on`})]})}var lD=1e3;function uD(){let[e,t]=(0,V.useState)(null);return(0,V.useEffect)(()=>{let e=!1,n,r=a=>{e||(a.state===`warming`?(t({seconds:Math.floor(a.elapsed_seconds??0),model:a.model??null,device:a.device??null}),n=setTimeout(()=>{Zi().then(r,i)},lD)):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 dD(e){return e===`gpu`?`your GPU`:e===`npu`?`your NPU`:e===`cpu`?`the CPU`:null}function fD(e){return e<1?`under 1 GB`:`${e.toFixed(1)} GB`}var pD=15e3;function mD(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 hD({seconds:e,model:t,device:n}){if(!t)return`Getting GAIA ready… ${e}s`;let r=dD(n);return`Loading ${gs(t)}${r?` on ${r}`:``}… ${e}s`}function gD({detail:e,onRetry:t}){let[n,r]=(0,V.useState)(!1);return(0,U.jsxs)(`div`,{className:`new-chat-note`,children:[(0,U.jsxs)(`p`,{children:[`GAIA’s assistant didn’t start yet.`,` `,(0,U.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:t,children:`Try again`})]}),(0,U.jsxs)(`button`,{type:`button`,className:`new-chat-details`,"aria-expanded":n,onClick:()=>r(e=>!e),children:[(0,U.jsx)(F,{size:12,className:n?`is-open`:``,"aria-hidden":`true`}),` Details`]}),n&&(0,U.jsx)(`pre`,{className:`new-chat-details-text`,children:e})]})}function _D(){let{documents:e,draftDocumentIds:t,addDraftDocuments:n}=H.getState();n(e.filter(e=>e.indexing_status===`complete`&&!t.includes(e.id)).map(e=>e.id))}function vD(){let e=H(e=>e.documents),t=H(e=>e.draftDocumentIds),n=H(e=>e.removeDraftDocument),r=H(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,U.jsxs)(`div`,{className:`new-chat-docs`,children:[i.length>0&&(0,U.jsx)(`ul`,{className:`new-chat-doc-list`,"aria-label":`Documents for this chat`,children:i.map(e=>(0,U.jsxs)(`li`,{className:`new-chat-doc`,children:[(0,U.jsx)(We,{size:12,"aria-hidden":`true`}),(0,U.jsx)(`span`,{children:e.filename}),(0,U.jsx)(`button`,{type:`button`,className:`new-chat-doc-remove`,onClick:()=>n(e.id),"aria-label":`Don't attach ${e.filename}`,children:(0,U.jsx)(Bn,{size:12,"aria-hidden":`true`})})]},e.id))}),o>0&&(0,U.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,U.jsxs)(`button`,{type:`button`,className:`link-btn`,onClick:_D,children:[`Attach `,o===1?`it`:`all ${o}`]}),o>1&&(0,U.jsxs)(U.Fragment,{children:[` · `,(0,U.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>r(!0),children:`Choose`})]})]})]})}function yD({error:e}){let t=H(e=>e.openSettings);return(0,U.jsxs)(`div`,{className:`new-chat-setup-failed`,role:`alert`,children:[(0,U.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,U.jsx)(`p`,{className:`new-chat-setup-failed-error`,children:e}),(0,U.jsxs)(`p`,{children:[`Use a cloud model, or pick a smaller one.`,` `,(0,U.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>t(`model`),children:`Choose a model`})]})]})}function bD({onSend:e,initialText:t=``,focusRequest:n=0}){let r=H(e=>e.systemStatus?.init_state===`initializing`),i=H(e=>e.systemStatus?.download_progress??null),a=H(e=>e.systemStatus?.model_loaded?null:e.systemStatus?.setup_error??null),o=ps(e=>!!e.active?.remote),[c,l]=iE(ai,t),[u,d]=(0,V.useState)(null),[f,p]=(0,V.useState)(!1),[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)(null),v=(0,V.useRef)(null),y=(0,V.useRef)(null),b=(0,V.useRef)(null),x=WT(),S=uD();ms();let C=(0,V.useRef)(!0),w=(0,V.useCallback)((e=!1)=>{e||_(null),pa().then(e=>{C.current&&(h(e),_(e.skills_error??null))}).catch(e=>{s.api.warn(`New-chat start screen unavailable`,e),C.current&&_(e instanceof Error?e.message:String(e))})},[]);(0,V.useEffect)(()=>(C.current=!0,w(),()=>{C.current=!1}),[w]),(0,V.useEffect)(()=>{po().then(e=>H.getState().setDocuments(e.documents||[])).catch(e=>s.api.warn(`Document library unavailable; not offering its documents`,e))},[]),(0,V.useEffect)(()=>{if(g)return nE(()=>w(!0),pD)},[g,w]);let T=(0,V.useRef)(!1),E=(0,V.useRef)([]),D=(0,V.useCallback)(async(t,n=``)=>{if(t){if(T.current)E.current.push(n||t),l(``);else{T.current=!0,p(!0),d(null),l(``);try{let n=await e(t);x.clear();let r=E.current.splice(0),i=H.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`);H.getState().updateQueue(i,t=>r.reduce(e,t))}}catch(e){let r=E.current.splice(0);l([n||t,...r].join(`
|
|
75
75
|
|
|
76
76
|
`)),d(e instanceof Error?e.message:String(e))}finally{T.current=!1,p(!1)}}}},[x,e]),O=(0,V.useCallback)(()=>D(x.compose(c.trim()),c.trim()),[x,D,c]);(0,V.useEffect)(()=>{n&&v.current?.focus()},[n]);let k=c.length>0||f,A=(0,V.useRef)(null);(0,V.useLayoutEffect)(()=>{let e=y.current;if(!e)return;typeof e.getAnimations==`function`&&e.getAnimations().forEach(e=>e.cancel());let t=e.getBoundingClientRect().top,n=A.current;if(A.current={top:t,docked:k},!n||n.docked===k||nx()||typeof e.animate!=`function`)return;let r=getComputedStyle(document.documentElement).getPropertyValue(`--ease`).trim();if(!r)throw Error(`Motion token --ease is not set; check styles/index.css.`);e.animate([{transform:`translateY(${n.top-t}px)`},{transform:`none`}],{duration:tx(`--duration-spring`),easing:r})});let ee=i?.state===`starting`||i?.state===`downloading`,j=f?`sending`:ee?`download`:r||S!==null?`loading`:`idle`,M=m?.working_folder;return(0,U.jsxs)(`main`,{className:`new-chat${k?` is-docked`:``}`,"aria-label":`New chat`,children:[(0,U.jsx)(TE,{activity:j,progress:(i?.percent??0)/100,pulse:c.length,docked:k,contentRef:y,composerRef:b}),(0,U.jsxs)(`div`,{className:`new-chat-inner`,ref:y,children:[(0,U.jsx)(`h1`,{className:`new-chat-greeting`,"aria-hidden":k,children:mD()}),a&&!o&&(0,U.jsx)(yD,{error:a}),(0,U.jsx)(`div`,{ref:b,children:(0,U.jsx)(yC,{value:c,onChange:l,onSubmit:O,attachments:x,disabledReason:r?Nc:null,autoFocus:!0,inputRef:v,leftControls:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(JC,{sessionId:null}),(0,U.jsx)(cD,{disabled:f})]}),rightControls:(0,U.jsx)(jC,{})})}),(0,U.jsx)(`div`,{className:`new-chat-meta`,children:M&&(0,U.jsx)(HC,{folder:M,disabled:r||f})}),(0,U.jsx)(vD,{}),S!==null&&!r&&(0,U.jsx)(`p`,{className:`new-chat-warmup`,role:`status`,children:hD(S)}),u&&(0,U.jsx)(`p`,{className:`new-chat-error`,role:`alert`,children:u}),g&&(0,U.jsx)(gD,{detail:g,onRetry:()=>w()})]})]})}function xD(e){let t=e?.reason;return t===`needs_key`||t===`bad_key`}function SD({provider:e,limit:t}){let[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null);if((0,V.useEffect)(()=>{r(null),a(null),Ma(e).then(r).catch(e=>a(e instanceof Error?e.message:String(e)))},[e]),i)return(0,U.jsxs)(`p`,{className:`settings-error`,role:`alert`,children:[`Prices could not be loaded: `,i]});if(!n)return(0,U.jsxs)(`p`,{className:`settings-hint`,children:[(0,U.jsx)(B,{size:13,className:`spin`}),` Loading prices…`]});if(n.models.length===0)return(0,U.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,U.jsxs)(`div`,{className:`cloud-prices`,"aria-label":`Prices`,children:[(0,U.jsx)(`ul`,{className:`cloud-prices-list`,children:o.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsxs)(`span`,{className:`cloud-prices-name`,children:[e.name,e.note&&(0,U.jsxs)(`span`,{className:`cloud-prices-note`,children:[` · `,e.note]})]}),(0,U.jsx)(`span`,{className:`cloud-prices-price`,children:wC(e.price)})]},e.model))}),(0,U.jsxs)(`span`,{className:`settings-hint`,children:[n.source,`. You pay the provider for what you use.`]})]})}function CD({label:e,value:t,ok:n}){return(0,U.jsxs)(`li`,{className:`setup-check-row${n?` is-ok`:``}`,children:[n?(0,U.jsx)(te,{size:13,"aria-hidden":`true`}):(0,U.jsx)(mt,{size:13,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`setup-check-label`,children:e}),(0,U.jsx)(`span`,{className:`setup-check-value`,children:t})]})}function wD(e){return!!e.gpu_name||!!e.npu_detected||e.lemonade_running}function TD(e){let t=[e.gpu_name,e.npu_detected?`Ryzen AI NPU`:null].filter(Boolean);return t.length?{value:t.join(` · `),ok:!0}:wD(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 ED({hardware:e,error:t}){if(t)return(0,U.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,U.jsxs)(`p`,{className:`setup-hint`,role:`status`,children:[(0,U.jsx)(B,{size:13,className:`spin`,"aria-hidden":`true`}),` Checking this PC…`]});let n=TD(e),r=e.lemonade_running?e.warnings:e.warnings.filter(e=>!/\bNPU\b/.test(e));return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`ul`,{className:`setup-check`,"aria-label":`This PC`,children:[(0,U.jsx)(CD,{label:`Device`,value:n.value,ok:n.ok}),(0,U.jsx)(CD,{label:`Memory`,value:e.ram_gb==null?`Not reported`:`${e.ram_gb} GB`,ok:e.ram_gb!=null}),(0,U.jsx)(CD,{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,U.jsx)(`p`,{className:`setup-error`,role:`alert`,children:e.blockers.join(` `)}),r.length>0&&(0,U.jsx)(`p`,{className:`setup-hint`,children:r.join(` `)})]})}function DD({plan:e,planError:t,chosen:n,locked:r,onPlan:i}){let[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1);if(n){let t=l||e?.chat_model.user_set&&e.chat_model.id===n;return(0,U.jsxs)(`p`,{className:`setup-hint`,children:[t?`You chose `:`Setup chose `,(0,U.jsx)(`strong`,{children:Cs(n)}),t?`.`:` for this PC.`]})}if(t)return(0,U.jsxs)(`p`,{className:`setup-hint`,children:[`Setup names the chat model once it has checked this PC (`,t,`).`]});if(!e)return(0,U.jsxs)(`p`,{className:`setup-hint`,role:`status`,children:[(0,U.jsx)(B,{size:13,className:`spin`,"aria-hidden":`true`}),` Working out which model fits this PC…`]});let d=e.chat_model,f=Cs(d.id);if(e.decided_after_server){let t=e.options.map(e=>Cs(e.id));return(0,U.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:fD(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,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`p`,{className:`setup-hint`,children:[(0,U.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,U.jsx)(`div`,{className:`setup-choices`,role:`radiogroup`,"aria-label":`Chat model`,children:e.options.map(t=>(0,U.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,U.jsx)(B,{size:14,className:`spin`,"aria-hidden":`true`}),(0,U.jsxs)(`span`,{children:[(0,U.jsxs)(`span`,{className:`setup-choice-title`,children:[Cs(t.id),t.id===e.recommended_model?` (recommended)`:``]}),(0,U.jsx)(`span`,{className:`setup-choice-note`,children:t.fits===!1?t.reason:t.size_gb==null?`Size unknown`:fD(t.size_gb)})]})]},t.id))}),s&&(0,U.jsx)(`p`,{className:`setup-error`,role:`alert`,children:s})]})}function OD({cards:e,onPick:t,disabled:n}){return e.length===0?null:(0,U.jsx)(`ul`,{className:`start-cards`,"aria-label":`Things to try`,children:e.map(e=>(0,U.jsx)(`li`,{children:(0,U.jsxs)(`button`,{type:`button`,className:`start-card`,onClick:()=>t(e),disabled:n,title:e.needs_input?`${e.prompt}…`:e.prompt,children:[(0,U.jsxs)(`span`,{className:`start-card-title`,children:[e.title,(0,U.jsx)(b,{size:13,"aria-hidden":`true`})]}),(0,U.jsx)(`span`,{className:`start-card-note`,children:e.note})]})},e.skill))})}function kD(){let[e,t]=(0,V.useState)(null),n=(0,V.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,V.useEffect)(n,[n]),{network:e,recheck:n}}var AD=[{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.`}],jD=1e3,MD=`gaia-setup-choice`;function ND(){try{let e=localStorage.getItem(MD);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 PD(e){try{localStorage.setItem(MD,e)}catch(e){console.warn(`[SetupScreen] could not save the provider choice; a reload will ask again`,e)}}function FD({status:e,n:t}){return e===`done`?(0,U.jsx)(te,{size:14,"aria-hidden":`true`}):e===`active`?(0,U.jsx)(B,{size:14,className:`spin`,"aria-hidden":`true`}):e===`failed`||e===`cancelled`?(0,U.jsx)(ce,{size:14,"aria-hidden":`true`}):(0,U.jsx)(U.Fragment,{children:t})}var ID=[`ok`,`needs_key`,`too_old`];function LD({onChosen:e}){let[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)([]),[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(``),[d,f]=(0,V.useState)(!1),[p,m]=(0,V.useState)(!1),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(null),y=(0,V.useRef)(!0),b=(0,V.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&&ID.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,V.useEffect)(()=>(y.current=!0,b(),()=>{y.current=!1}),[b]);let x=(0,V.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){xD(e)&&f(!0),g(e instanceof Error?e.message:String(e))}finally{m(!1)}}},[t,l,e]);if(r||a.length>0)return(0,U.jsxs)(`div`,{className:`setup-row`,children:[(0,U.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,U.jsxs)(`button`,{type:`button`,className:`btn-secondary`,disabled:s,onClick:()=>void b(),children:[s&&(0,U.jsx)(B,{size:13,className:`spin`}),` Check again`]})]});if(!t)return s?(0,U.jsxs)(`p`,{className:`setup-hint`,role:`status`,children:[(0,U.jsx)(B,{size:13,className:`spin`,"aria-hidden":`true`}),` Looking for a Lemonade Server you already run…`]}):null;let{target:S,found:C}=t;return _?(0,U.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,U.jsx)(`p`,{className:`setup-hint`,children:C.message}):(0,U.jsxs)(`form`,{className:`setup-lemonade`,"aria-label":`Use your Lemonade Server`,onSubmit:e=>{e.preventDefault(),x(`external`)},children:[(0,U.jsxs)(`span`,{className:`setup-choice-title`,children:[`Use the Lemonade you already run at `,C.url,C.version?` (v${C.version})`:``]}),(0,U.jsx)(`span`,{className:`setup-choice-note`,children:S.what_gaia_does}),d&&(0,U.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,U.jsxs)(`div`,{className:`setup-row`,children:[(0,U.jsxs)(`button`,{type:`submit`,className:`btn-primary`,disabled:p||d&&!l.trim(),children:[p&&(0,U.jsx)(B,{size:13,className:`spin`}),` Use mine`]}),(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:p,onClick:()=>void x(`gaia`),children:`Use GAIA’s own`})]}),h&&(0,U.jsx)(`p`,{className:`setup-error`,role:`alert`,children:h})]})}function RD({problem:e,onRetry:t,onUseGaia:n}){return(0,U.jsxs)(U.Fragment,{children:[e.start&&(0,U.jsx)(`p`,{className:`setup-hint`,children:e.start}),(0,U.jsxs)(`div`,{className:`setup-row`,children:[(0,U.jsx)(`button`,{type:`button`,className:`btn-primary`,onClick:t,children:`Try again`}),e.use_gaia&&(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:n,children:`Use GAIA’s own instead`})]}),e.use_gaia&&(0,U.jsx)(`p`,{className:`setup-hint`,children:`GAIA’s own Lemonade Server downloads its own copy of the models.`}),e.switch_hint&&(0,U.jsx)(`p`,{className:`setup-hint`,children:e.switch_hint})]})}function zD(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:fD(t.download_gb),r=`chat model ${Cs(t.chat_model.id)}, plus the embedding model`;return{...e,detail:n?`${r} (${n})`:r}}return e}):e}function BD({initial:e,onReady:t}){let n=ps(e=>e.refresh),r=ps(e=>e.select),[i,a]=(0,V.useState)(()=>ND()??`local`),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(null),[f,p]=(0,V.useState)(null),[m,h]=(0,V.useState)(``),[g,_]=(0,V.useState)({busy:!1,error:null,done:!1}),[v,y]=(0,V.useState)(!1),[b,x]=(0,V.useState)(null),[S,C]=(0,V.useState)(null),[w,T]=(0,V.useState)(null),[E,D]=(0,V.useState)([]),[O,k]=(0,V.useState)(!1),A=(0,V.useRef)(null),ee=(0,V.useRef)(!0);(0,V.useEffect)(()=>()=>{ee.current=!1},[]);let{network:j,recheck:M}=kD(),N=e=>e===`amd`&&j?.reachable===!1,P=i!==`local`,ne=u?.steps??zD(P?e.cloud_steps??e.steps:e.steps,b,P),re=u?.state===`running`||u?.state===`verifying`,ie=u?.state===`ready`,ae=re||ie,oe=!!u?.chat_model||!!b&&!b.decided_after_server,se=P?3:4,ce=!!c||!!o&&!wD(o),le=(0,V.useCallback)(()=>{l(null),sa().then(s).catch(e=>l(e instanceof Error?e.message:String(e)))},[]),ue=(0,V.useRef)(0),de=(0,V.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,V.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&&!ND()&&a(`fireworks`))}).catch(e=>p(`Could not read setup progress: ${e instanceof Error?e.message:e}`))},[le,de]);let fe=(0,V.useCallback)(()=>{A.current&&clearInterval(A.current),A.current=null},[]);(0,V.useEffect)(()=>{ie&&le()},[ie,le]),(0,V.useEffect)(()=>(re&&(A.current=setInterval(()=>{ua().then(d).catch(e=>{d(t=>t&&{...t,state:`failed`,error:`Lost contact with GAIA: ${e instanceof Error?e.message:e}`})})},jD)),fe),[re,fe]);let I=(0,V.useCallback)(async(e=!1)=>{p(null);try{PD(i),d(await la(P,e)),e&&k(!1)}catch(e){p(e instanceof Error?e.message:String(e))}},[P,i]),pe=(0,V.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}),()=>!ee.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]),L=(0,V.useCallback)(e=>{PD(e),a(e),_({busy:!1,error:null,done:!1})},[]),R=(0,V.useCallback)(async e=>{await n(),t(e)},[t,n]),me=ie&&(!P||g.done),he=ne.find(e=>e.status===`active`||e.status===`failed`),ge=P?w:u?.chat_model??(b&&!b.decided_after_server?b.chat_model.id:null);return(0,V.useEffect)(()=>{me&&pa().then(e=>D(e.cards)).catch(e=>console.warn(`[SetupScreen] no first tasks to offer`,e))},[me]),(0,U.jsx)(`main`,{className:`setup`,"aria-labelledby":`setup-title`,children:(0,U.jsxs)(`div`,{className:`setup-inner`,children:[(0,U.jsx)(`h1`,{id:`setup-title`,className:`setup-title`,children:`Set up GAIA`}),(0,U.jsx)(`p`,{className:`setup-lede`,children:me?`All set.`:u?`Setting things up. Setup keeps going if you switch away.`:`A few minutes of setup, then your first chat.`}),(0,U.jsxs)(`ol`,{className:`setup-steps`,children:[(0,U.jsxs)(`li`,{className:`setup-step${ce?``:o?` is-done`:` is-current`}`,children:[(0,U.jsxs)(`div`,{className:`setup-step-head`,children:[(0,U.jsx)(`span`,{className:`setup-step-num`,children:ce?(0,U.jsx)(mt,{size:14,"aria-hidden":`true`}):o?(0,U.jsx)(te,{size:14,"aria-hidden":`true`}):1}),(0,U.jsx)(`span`,{className:`setup-step-label`,children:`Check this PC`})]}),!ae&&(0,U.jsx)(`div`,{className:`setup-step-body`,children:(0,U.jsx)(ED,{hardware:o,error:c})})]}),(0,U.jsxs)(`li`,{className:`setup-step${ae?` is-done`:` is-current`}`,children:[(0,U.jsxs)(`div`,{className:`setup-step-head`,children:[(0,U.jsx)(`span`,{className:`setup-step-num`,children:ae?(0,U.jsx)(te,{size:14,"aria-hidden":`true`}):2}),(0,U.jsx)(`span`,{className:`setup-step-label`,children:`Choose where GAIA runs`})]}),!ae&&(0,U.jsxs)(`div`,{className:`setup-step-body`,children:[(0,U.jsx)(LD,{onChosen:e=>{k(e===`external`),le(),de()}}),(0,U.jsx)(`div`,{className:`setup-choices`,role:`radiogroup`,"aria-label":`Where GAIA runs`,children:AD.map(e=>(0,U.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":i===e.id,className:`setup-choice${i===e.id?` is-active`:``}${N(e.id)?` is-disabled`:``}`,onClick:()=>a(e.id),disabled:N(e.id),children:[e.id===`local`?(0,U.jsx)(we,{size:16,"aria-hidden":`true`}):(0,U.jsx)(_e,{size:16,"aria-hidden":`true`}),(0,U.jsxs)(`span`,{children:[(0,U.jsx)(`span`,{className:`setup-choice-title`,children:e.title}),(0,U.jsx)(`span`,{className:`setup-choice-note`,children:N(e.id)?j?.detail:e.note})]})]},e.id))}),j?.reachable===!1&&(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:M,children:`Check the AMD gateway again`})]})]}),!P&&(0,U.jsxs)(`li`,{className:`setup-step${ae&&oe?` is-done`:ae?` is-pending`:` is-current`}`,children:[(0,U.jsxs)(`div`,{className:`setup-step-head`,children:[(0,U.jsx)(`span`,{className:`setup-step-num`,children:ae&&oe?(0,U.jsx)(te,{size:14,"aria-hidden":`true`}):3}),(0,U.jsx)(`span`,{className:`setup-step-label`,children:`Chat model`})]}),(0,U.jsx)(`div`,{className:`setup-step-body`,children:(0,U.jsx)(DD,{plan:b,planError:S,chosen:u?.chat_model??null,locked:ae,onPlan:x})})]}),!u&&(0,U.jsxs)(`li`,{className:`setup-step-action`,children:[(0,U.jsx)(`button`,{type:`button`,className:`btn-primary setup-start`,onClick:()=>void I(),disabled:N(i),children:`Start setup`}),N(i)&&(0,U.jsxs)(`p`,{className:`setup-error`,role:`alert`,children:[j?.detail,`. Choose another option, or connect and check again.`]}),f&&(0,U.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,U.jsxs)(`li`,{className:`setup-step is-${n??`pending`}`,"aria-current":r?`step`:void 0,children:[(0,U.jsxs)(`div`,{className:`setup-step-head`,children:[(0,U.jsx)(`span`,{className:`setup-step-num`,children:(0,U.jsx)(FD,{status:n,n:t+se})}),(0,U.jsxs)(`span`,{className:`setup-step-label`,children:[e.label,e.detail&&(0,U.jsxs)(`span`,{className:`setup-step-detail`,children:[` — `,e.detail]})]})]}),r&&u&&(0,U.jsxs)(`div`,{className:`setup-step-body`,children:[(0,U.jsx)(`p`,{className:`setup-hint`,role:`status`,children:u.text}),u.percent!=null&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`progress`,{className:`setup-progress`,max:100,value:u.percent,"aria-label":u.text}),(0,U.jsxs)(`p`,{className:`setup-hint`,children:[u.percent,`%`,u.size?` · ${u.size}`:``]})]})]}),i&&u&&e===he&&(0,U.jsxs)(`div`,{className:`setup-step-body`,children:[(0,U.jsx)(`p`,{className:`setup-error`,role:`alert`,children:u.error??`Setup stopped.`}),u.problem?(0,U.jsx)(RD,{problem:u.problem,onRetry:()=>void I(),onUseGaia:()=>void I(!0)}):(0,U.jsxs)(`div`,{className:`setup-row`,children:[(0,U.jsx)(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void I(!!u.gaia_lemonade),children:`Try again`}),(0,U.jsxs)(`span`,{className:`setup-hint`,children:[`or run `,(0,U.jsx)(`code`,{children:u.command}),` in a terminal.`]})]}),f&&(0,U.jsx)(`p`,{className:`setup-error`,role:`alert`,children:f})]})]},e.key)}),P&&(0,U.jsxs)(`li`,{className:`setup-step${g.done?` is-done`:ie?` is-current`:` is-pending`}`,children:[(0,U.jsxs)(`div`,{className:`setup-step-head`,children:[(0,U.jsx)(`span`,{className:`setup-step-num`,children:g.done?(0,U.jsx)(te,{size:14,"aria-hidden":`true`}):ne.length+se}),(0,U.jsxs)(`span`,{className:`setup-step-label`,children:[`Connect `,AD.find(e=>e.id===i)?.title]})]}),ie&&!g.done&&(0,U.jsxs)(`form`,{className:`setup-step-body`,onSubmit:e=>{e.preventDefault(),pe()},children:[(0,U.jsx)(`div`,{className:`setup-row`,role:`radiogroup`,"aria-label":`Cloud provider`,children:AD.filter(e=>e.id!==`local`).map(e=>(0,U.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":i===e.id,className:i===e.id?`btn-primary`:`btn-secondary`,onClick:()=>L(e.id),disabled:g.busy||N(e.id),title:N(e.id)?j?.detail??void 0:void 0,children:e.title},e.id))}),(0,U.jsx)(SD,{provider:i,limit:3}),O?(0,U.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,U.jsx)(`p`,{className:`setup-hint`,children:`The key goes to GAIA’s local model server and your OS credential store, nowhere else.`}),(0,U.jsxs)(`div`,{className:`setup-row`,children:[!O&&(0,U.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,U.jsxs)(`button`,{type:`submit`,className:`btn-primary`,disabled:g.busy,children:[g.busy&&(0,U.jsx)(B,{size:13,className:`spin`}),` Connect`]})]}),g.busy&&g.waiting&&(0,U.jsx)(`p`,{className:`setup-hint`,role:`status`,children:g.waiting}),g.error&&(0,U.jsx)(`p`,{className:`setup-error`,role:`alert`,children:g.error})]})]})]}),u&&u.log_tail&&u.log_tail.length>0&&(0,U.jsxs)(`div`,{className:`setup-log`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`setup-log-toggle`,onClick:()=>y(e=>!e),"aria-expanded":v,children:[(0,U.jsx)(F,{size:13,className:v?`is-open`:``,"aria-hidden":`true`}),` Details`]}),v&&(0,U.jsx)(`pre`,{className:`setup-log-pre`,children:u.log_tail.join(`
|
|
77
|
-
`)})]}),me&&(0,U.jsxs)(`div`,{className:`setup-done`,role:`status`,children:[(0,U.jsxs)(`div`,{className:`setup-done-head`,children:[(0,U.jsxs)(`p`,{children:[`GAIA is ready.`,ge&&(0,U.jsxs)(U.Fragment,{children:[` `,(0,U.jsx)(`strong`,{children:Cs(ge)}),` answers`,P?` in the cloud`:` on this PC`,`.`]})]}),(0,U.jsx)(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void R(),autoFocus:!0,children:`Start chatting`})]}),E.length>0&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`setup-hint`,children:`Or start with one of these:`}),(0,U.jsx)(OD,{cards:E,onPick:e=>void R(e)})]})]})]})})}var VD=bc()?`menu bar`:`tray`,HD=[{key:`minimizeToTray`,label:`Keep running when the window closes`,hint:`GAIA stays in the ${VD} with your model loaded. Quit from the ${VD} 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 ${VD}`,hint:`GAIA opens without its window. Use the ${VD} icon to show it.`}];function UD(){let e=window.gaiaAPI?.tray,[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(null);(0,V.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,V.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,U.jsxs)(`div`,{className:`settings-field`,role:`group`,"aria-labelledby":`desktop-app-label`,children:[(0,U.jsx)(`span`,{className:`settings-label`,id:`desktop-app-label`,children:`Desktop app`}),HD.map(({key:e,label:n,hint:r})=>(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`label`,{className:`setting-row`,children:[(0,U.jsx)(`span`,{children:n}),(0,U.jsxs)(`span`,{className:`toggle-switch`,children:[(0,U.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,U.jsx)(`span`,{className:`toggle-track`})]})]}),(0,U.jsx)(`p`,{className:`settings-hint`,id:`desktop-${e}-hint`,children:r})]},e)),r&&(0,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r})]}):null}function WD(){return window.gaiaUpdater}var GD={status:`idle`,version:null,progress:0,releaseNotes:null,error:null,currentVersion:null,pinnedVersion:null,autoUpdate:!1,includePrereleases:!1};function KD(){let[e,t]=(0,V.useState)({...GD});return(0,V.useEffect)(()=>{let e=WD();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 qD(){return window.gaiaUpdater}function JD({onClose:e}){let[t,n]=(0,V.useState)({kind:`loading`}),r=(0,V.useRef)(null);(0,V.useEffect)(()=>{let e=qD();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),Ox(r,!0),(0,V.useEffect)(()=>{let e=r.current;e&&e.querySelector(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)?.focus()},[]),(0,V.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=qD();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,U.jsx)(`div`,{className:`version-picker-overlay`,onClick:t=>{t.target===t.currentTarget&&e()},children:(0,U.jsxs)(`div`,{className:`version-picker-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Install a specific version`,ref:r,children:[(0,U.jsxs)(`div`,{className:`version-picker-header`,children:[(0,U.jsx)(`h3`,{children:`Install a specific version`}),(0,U.jsx)(`button`,{className:`version-picker-close`,onClick:e,"aria-label":`Close`,type:`button`,children:`×`})]}),(0,U.jsxs)(`div`,{className:`version-picker-body`,children:[t.kind===`loading`&&(0,U.jsxs)(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[(0,U.jsx)(`span`,{className:`version-picker-spinner`}),`Loading releases…`]}),t.kind===`error`&&(0,U.jsxs)(`div`,{className:`version-picker-error`,children:[(0,U.jsx)(`p`,{children:t.message}),(0,U.jsx)(`p`,{children:(0,U.jsx)(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:`Browse releases on GitHub`})})]}),t.kind===`list`&&(0,U.jsx)(`ul`,{className:`version-picker-list`,role:`listbox`,"aria-label":`Available releases`,children:t.releases.map(e=>(0,U.jsx)(`li`,{children:(0,U.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,U.jsx)(`span`,{className:`vp-version`,children:e.version}),(0,U.jsx)(`span`,{className:`vp-date`,children:o(e.date)}),e.isCurrent&&(0,U.jsx)(`span`,{className:`vp-badge vp-badge-current`,children:`Installed`}),e.isPinned&&!e.isCurrent&&(0,U.jsx)(`span`,{className:`vp-badge vp-badge-pinned`,children:`Pinned`}),!e.isCurrent&&(0,U.jsx)(`span`,{className:`vp-arrow`,"aria-hidden":`true`,children:`›`})]})},e.tag))}),t.kind===`list`&&(0,U.jsxs)(`p`,{className:`version-picker-more`,children:[`Showing the `,t.releases.length,` most recent.`,` `,(0,U.jsx)(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:`Browse all releases on GitHub`})]}),t.kind===`confirm`&&(0,U.jsxs)(`div`,{className:`version-picker-confirm`,children:[(0,U.jsxs)(`p`,{children:[`This will `,(0,U.jsxs)(`strong`,{children:[`install v`,t.release.version]}),` and restart the app.`]}),(0,U.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,U.jsxs)(`div`,{className:`vp-confirm-actions`,children:[(0,U.jsx)(`button`,{type:`button`,className:`vp-btn-cancel`,onClick:()=>n({kind:`list`,releases:t.releases}),children:`Back`}),(0,U.jsx)(`button`,{type:`button`,className:`vp-btn-confirm`,onClick:()=>a(t.release),children:`Install & restart`})]})]}),t.kind===`installing`&&(0,U.jsxs)(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[(0,U.jsx)(`span`,{className:`version-picker-spinner`}),`Starting download…`]})]})]})})}var YD=`Install updates automatically`,XD=`Include release candidates`;function ZD(e){return/^\d+\.\d+\.\d+-/.test(e??``)}function QD(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 $D(){let e=KD(),t=WD(),[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(null),[o,c]=(0,V.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,U.jsxs)(`div`,{className:`settings-field`,role:`group`,"aria-labelledby":`updates-label`,children:[(0,U.jsx)(`span`,{className:`settings-label`,id:`updates-label`,children:`Updates`}),(0,U.jsxs)(`p`,{className:`settings-hint`,role:`status`,children:[`Running GAIA `,e.currentVersion??`unknown`,`. `,QD(e)]}),(0,U.jsxs)(`label`,{className:`setting-row`,children:[(0,U.jsx)(`span`,{children:YD}),(0,U.jsxs)(`span`,{className:`toggle-switch`,children:[(0,U.jsx)(`input`,{type:`checkbox`,role:`switch`,checked:e.autoUpdate,"aria-describedby":`updates-auto-hint`,"aria-label":YD,"aria-busy":n,disabled:u,onChange:()=>{n||l(`Saving the auto-update setting`,t=>t.setAutoUpdate(!e.autoUpdate))}}),(0,U.jsx)(`span`,{className:`toggle-track`})]})]}),(0,U.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,U.jsxs)(`label`,{className:`setting-row`,children:[(0,U.jsx)(`span`,{children:XD}),(0,U.jsxs)(`span`,{className:`toggle-switch`,children:[(0,U.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,U.jsx)(`span`,{className:`toggle-track`})]})]}),(0,U.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.`,ZD(e.currentVersion)&&` This is a release candidate, so newer ones are offered either way.`]}),e.pinnedVersion&&(0,U.jsxs)(`p`,{className:`settings-hint`,children:[`Pinned to `,e.pinnedVersion,`, so updates are paused.`,` `,(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:n,onClick:()=>void l(`Resuming updates`,e=>e.resumeUpdates()),children:`Unpin`})]}),(0,U.jsxs)(`div`,{className:`setting-actions`,children:[e.status===`available`&&!e.pinnedVersion&&(0,U.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,U.jsx)(`button`,{type:`button`,className:`btn-primary`,disabled:n,onClick:()=>void l(`Restarting to install`,e=>e.restart()),children:`Restart to install`}),(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:d||u,onClick:()=>void l(`Checking for updates`,e=>e.check()),children:`Check for updates`}),(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:d||u,onClick:()=>c(!0),children:`Install a specific version…`})]}),e.configError&&(0,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:e.configError}),i&&(0,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:i}),o&&(0,U.jsx)(JD,{onClose:()=>c(!1)})]})}var eO=[{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`system`,label:`Match system`}],tO=[[`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 nO(){let e=H(e=>e.themePreference),t=H(e=>e.setThemePreference),n=H(e=>e.palette),r=H(e=>e.setPalette),i=H(e=>e.customColors),a=H(e=>e.setCustomColors),o=e=>t=>a({...i,[e]:t.target.value.toUpperCase()});return(0,U.jsxs)(`div`,{className:`settings-pane`,children:[(0,U.jsx)(`h2`,{className:`settings-pane-title`,children:`General`}),(0,U.jsxs)(`div`,{className:`settings-field`,children:[(0,U.jsx)(`span`,{className:`settings-label`,id:`appearance-label`,children:`Appearance`}),(0,U.jsx)(`div`,{className:`segmented`,role:`radiogroup`,"aria-labelledby":`appearance-label`,children:eO.map(n=>(0,U.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,U.jsx)(UD,{}),(0,U.jsx)($D,{}),(0,U.jsxs)(`div`,{className:`settings-field`,children:[(0,U.jsx)(`span`,{className:`settings-label`,id:`palette-label`,children:`Colors`}),(0,U.jsxs)(`div`,{className:`palette-grid`,role:`radiogroup`,"aria-labelledby":`palette-label`,children:[or.map(e=>(0,U.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,U.jsx)(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:e.swatch.map(e=>(0,U.jsx)(`i`,{style:{background:e}},e))}),e.name]},e.id)),(0,U.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":n===`custom`,className:`palette-tile${n===`custom`?` is-active`:``}`,onClick:()=>r(`custom`),children:[(0,U.jsxs)(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:[(0,U.jsx)(`i`,{style:{background:i.base}}),(0,U.jsx)(`i`,{style:{background:i.accent}})]}),`Custom`]})]}),n===`custom`&&(0,U.jsxs)(`div`,{className:`palette-custom`,children:[(0,U.jsxs)(`label`,{className:`palette-color`,htmlFor:`custom-accent`,children:[(0,U.jsx)(`input`,{id:`custom-accent`,type:`color`,value:i.accent,onChange:o(`accent`)}),(0,U.jsxs)(`span`,{children:[`Accent`,(0,U.jsx)(`small`,{children:`Buttons, links and focus`})]})]}),(0,U.jsxs)(`label`,{className:`palette-color`,htmlFor:`custom-base`,children:[(0,U.jsx)(`input`,{id:`custom-base`,type:`color`,value:i.base,onChange:o(`base`)}),(0,U.jsxs)(`span`,{children:[`Background tint`,(0,U.jsx)(`small`,{children:`The color the grays lean toward`})]})]}),(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>a(cr),children:`Reset`}),(0,U.jsx)(`p`,{className:`settings-hint`,children:`Text colors adjust on their own so everything stays readable in light and dark.`})]})]}),(0,U.jsxs)(`div`,{className:`settings-field`,children:[(0,U.jsx)(`span`,{className:`settings-label`,children:`Keyboard shortcuts`}),(0,U.jsx)(`dl`,{className:`shortcut-list`,children:tO.map(([e,t])=>(0,U.jsxs)(`div`,{className:`shortcut-row`,children:[(0,U.jsx)(`dt`,{children:(0,U.jsx)(`kbd`,{children:wc(e)})}),(0,U.jsx)(`dd`,{children:t})]},e))})]})]})}var rO=`auto`;function iO({model:e}){let[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(null);(0,V.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,V.useCallback)(async t=>{o(!0),i(null),c(null);try{let r=await Ta(e,t===rO?null:Number(t));n(r);let i=r.chosen?Os(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,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r});if(!t)return(0,U.jsxs)(`p`,{className:`settings-hint`,children:[(0,U.jsx)(B,{size:13,className:`spin`}),` Checking context sizes…`]});let u=t.chosen==null?rO:String(t.chosen),d=t.chosen!=null&&t.loaded_ctx!=null&&t.loaded_ctx!==t.chosen;return(0,U.jsxs)(`div`,{className:`settings-field`,children:[(0,U.jsx)(`label`,{className:`settings-label`,htmlFor:`ctx-size`,children:`Context size`}),(0,U.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,U.jsxs)(`option`,{value:rO,children:[`Automatic`,t.automatic?` (${Os(t.automatic)})`:``]}),t.options.map(e=>(0,U.jsxs)(`option`,{value:String(e),children:[Os(e),` tokens`]},e))]}),(0,U.jsxs)(`span`,{className:`settings-hint`,children:[t.note??(t.max_fit?`Up to ${Os(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 ${Os(t.loaded_ctx)}.`]}),a&&(0,U.jsxs)(`span`,{className:`settings-hint`,children:[(0,U.jsx)(B,{size:13,className:`spin`}),` Applying…`]}),s&&(0,U.jsx)(`p`,{className:`settings-ok`,role:`status`,children:s}),r&&(0,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r})]})}function aO({onAdded:e}){let[t,n]=(0,V.useState)(``),[r,i]=(0,V.useState)(``),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(null),d=(0,V.useRef)(``),f=(0,V.useCallback)(async e=>{let n=t.trim();d.current=n,c(`check`),u(null);try{let t=await ka(n,e);if(d.current!==n)return;o(t),i(t.file??e)}catch(e){if(d.current!==n)return;o(null),u(e instanceof Error?e.message:String(e))}finally{c(null)}},[t]),p=(0,V.useCallback)(async()=>{c(`add`),u(null);try{let{report:a}=await Aa(t.trim(),r);n(``),i(``),o(null),e(a.display_name??a.model_id??`The model`)}catch(e){u(e instanceof Error?e.message:String(e))}finally{c(null)}},[e,r,t]);return(0,U.jsxs)(`form`,{className:`settings-field custom-model-add`,onSubmit:e=>{e.preventDefault(),f(``)},children:[(0,U.jsx)(`label`,{className:`settings-label`,htmlFor:`custom-model-url`,children:`Add a model from Hugging Face`}),(0,U.jsx)(`span`,{className:`settings-hint`,children:`Paste the link to a GGUF model. GAIA checks that it is a chat model your model server can run and that it fits this PC before adding it. It downloads when you choose Download.`}),(0,U.jsxs)(`div`,{className:`settings-row`,children:[(0,U.jsx)(`input`,{id:`custom-model-url`,className:`settings-input`,type:`url`,inputMode:`url`,spellCheck:!1,autoComplete:`off`,value:t,readOnly:s!==null,onChange:e=>{n(e.target.value),o(null),i(``),d.current=``},placeholder:`https://huggingface.co/unsloth/Qwen3-4B-Instruct-2507-GGUF`}),(0,U.jsxs)(`button`,{type:`submit`,className:`btn-secondary`,disabled:s!==null||!t.trim(),children:[s===`check`?(0,U.jsx)(B,{size:13,className:`spin`}):null,` Check`]})]}),a&&(()=>{let e=(0,U.jsx)(`ul`,{className:`custom-model-checks`,"aria-label":`Checks`,children:a.checks.map(e=>(0,U.jsxs)(`li`,{className:e.ok?`is-ok`:`is-failed`,children:[e.ok?(0,U.jsx)(te,{size:13,"aria-label":`Passed`}):(0,U.jsx)(Bn,{size:13,"aria-label":`Failed`}),(0,U.jsxs)(`span`,{children:[(0,U.jsx)(`strong`,{children:e.label}),` — `,e.detail]})]},e.id))});return a.ok?(0,U.jsxs)(`details`,{className:`custom-model-checks-summary`,children:[(0,U.jsxs)(`summary`,{children:[(0,U.jsx)(te,{size:13,"aria-hidden":`true`}),` All `,a.checks.length,` checks passed`]}),e]}):e})(),a&&a.warnings.length>0&&(0,U.jsx)(`ul`,{className:`custom-model-checks`,"aria-label":`Warnings`,children:a.warnings.map(e=>(0,U.jsxs)(`li`,{className:`is-warning`,children:[(0,U.jsx)(An,{size:13,"aria-label":`Warning`}),` `,(0,U.jsx)(`span`,{children:e})]},e))}),a&&a.variants.length>1&&(0,U.jsxs)(`div`,{className:`settings-row`,children:[(0,U.jsx)(`label`,{className:`settings-hint`,htmlFor:`custom-model-quant`,children:`Quantization`}),(0,U.jsx)(`select`,{id:`custom-model-quant`,className:`settings-input`,value:r,onChange:e=>void f(e.target.value),disabled:s!==null,children:a.variants.map(e=>(0,U.jsxs)(`option`,{value:e.file,children:[e.quant,` · `,e.size_gb,` GB`,e.fits?``:` · too large for this PC`]},e.file))})]}),a?.ok&&(0,U.jsxs)(`div`,{className:`settings-row`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void p(),disabled:s!==null,children:[s===`add`?(0,U.jsx)(B,{size:13,className:`spin`}):null,` Add `,a.display_name]}),(0,U.jsxs)(`span`,{className:`settings-hint`,children:[a.size_gb,` GB download`]})]}),l&&(0,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:l})]})}function oO(){let[e,t]=(0,V.useState)(null),[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(``),[o,s]=(0,V.useState)(!1),c=(0,V.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,V.useEffect)(()=>{c(Na)},[c]),!e)return n?(0,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:n}):(0,U.jsxs)(`p`,{className:`settings-hint`,children:[(0,U.jsx)(B,{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,U.jsxs)(`section`,{className:`settings-field spending`,"aria-label":`Cloud spending`,children:[(0,U.jsx)(`span`,{className:`settings-label`,children:`Cloud spending this month`}),(0,U.jsxs)(`p`,{className:`spending-total`,children:[(0,U.jsx)(`strong`,{children:TC(e.total_usd)}),l!=null&&(0,U.jsxs)(U.Fragment,{children:[` of your `,TC(l),` limit`]}),(0,U.jsxs)(`span`,{className:`settings-hint`,children:[` · `,e.turns,` cloud `,e.turns===1?`chat turn`:`chat turns`,`, at list price`]})]}),e.unpriced_turns>0&&(0,U.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,U.jsxs)(`p`,{className:`spending-warning`,role:`status`,children:[(0,U.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,U.jsxs)(`div`,{className:`spending-warning`,role:`alert`,children:[(0,U.jsxs)(`p`,{children:[(0,U.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,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:o,onClick:()=>void c(Fa),children:`Allow more this month`})]}),e.state===`allowed_over`&&(0,U.jsx)(`p`,{className:`settings-hint`,children:`Over your limit; you allowed more for this month.`}),(0,U.jsxs)(`form`,{className:`settings-row`,onSubmit:e=>{e.preventDefault(),d&&f&&c(()=>Pa(u))},children:[(0,U.jsx)(`label`,{className:`spending-limit-label`,htmlFor:`spend-limit`,children:`Monthly limit ($)`}),(0,U.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,U.jsxs)(`button`,{type:`submit`,className:`btn-secondary`,disabled:o||!d||!f,children:[o?(0,U.jsx)(B,{size:13,className:`spin`}):null,` Save`]}),l!=null&&(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:o,onClick:()=>void c(()=>Pa(null)),children:`Remove limit`})]}),(0,U.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,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:n})]})}var sO=2e3;function cO(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 lO(e){return e.key_source===`environment`?`Blank uses the environment key`:e.key_source?`Blank keeps the saved key`:`Paste API key`}function uO(){let e=ps(e=>e.active),t=ps(e=>e.select),n=ps(e=>e.refresh),r=ps(e=>e.rememberNames),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(null),c=H(e=>e.settingsProvider),[l,u]=(0,V.useState)(c??e?.provider??`local`),[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(``),[_,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(``),[x,S]=(0,V.useState)({base_url:``,auth_header_name:``,auth_header_prefix:``}),[C,w]=(0,V.useState)(null),[T,E]=(0,V.useState)(null),[D,O]=(0,V.useState)(null),[k,A]=(0,V.useState)(null),ee=(0,V.useRef)(l);ee.current=l;let j=(0,V.useRef)(!0);(0,V.useEffect)(()=>()=>{j.current=!1},[]);let M=i?.find(e=>e.id===l)??null,N=e=>e?.network?.reachable===!1,P=!!M&&(!M.remote||!!M.models_discovered),ne=(0,V.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))}},[]),re=(0,V.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,V.useEffect)(()=>{ne()},[ne]);let ie=!!i?.some(e=>e.key_state===`waiting_for_os_permission`);(0,V.useEffect)(()=>{if(!ie)return;let e=setInterval(()=>{ne()},sO);return()=>clearInterval(e)},[ie,ne]);let F=e?.provider;(0,V.useEffect)(()=>{F&&!c&&u(F)},[F,c]),(0,V.useEffect)(()=>{b(``),O(null),g(``),v(!1)},[l]),(0,V.useEffect)(()=>{P?re(l):f(null)},[l,P,re]);let ae=(0,V.useCallback)(async()=>{if(M){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=()=>!j.current||ee.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 ne()}catch(e){j.current&&ee.current===l&&O({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{j.current&&w(null)}}},[x,l,y,ne,M]),oe=(0,V.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 ne(),await n()}catch(e){O({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{w(null)}},[l,ne,n]),se=(0,V.useCallback)(async e=>{w(e),O(null);try{await t(e),O({ok:!0,text:`New messages use ${gs(e)}. It is remembered across restarts.`})}catch(e){O({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{w(null)}},[t]),ce=(0,V.useCallback)(async e=>{w(`dl:${e}`),O(null);try{await ra(e),await re(`local`,!0)}catch(e){O({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{w(null)}},[re]),le=(0,V.useCallback)(async e=>{w(`rm:${e}`),O(null);try{let t=await ja(e);A(null);let r=t.cleared.includes(`last_model`)?` New messages use your default model.`:t.cleared.includes(`default_model`)?` It was your default model, so GAIA's own default takes its place.`:``;O({ok:!0,text:`Removed ${t.display_name} and its download.${r}`}),await re(`local`,!0),await n()}catch(e){O({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{w(null)}},[re,n]),ue=(0,V.useCallback)(async e=>{O({ok:!0,text:`Added ${e}. Choose Download to fetch it, then Use.`}),await re(`local`,!0)},[re]),de=!!d?.some(As);(0,V.useEffect)(()=>{if(l!==`local`||!de)return;let e=setInterval(()=>{re(`local`,!0)},sO);return()=>clearInterval(e)},[de,l,re]);let fe=(0,V.useMemo)(()=>{let e=h.trim().toLowerCase();return(d??[]).filter(t=>!e||t.id.toLowerCase().includes(e)||(t.display_name??``).toLowerCase().includes(e))},[d,h]),I=fe.filter(e=>e.available!==!1),pe=l===`fireworks`&&!_&&!h.trim()&&I.some(e=>e.rank!==null),L=t=>t.rank!==null||t.id===e?.model,R=pe?I.filter(L):I,me=pe?I.filter(e=>!L(e)):[],he=fe.filter(e=>e.available===!1),ge=ws(d??[]),ve=e&&!e.remote&&e.model?e.model:null,z=t=>{let n=hs(e?.model,t.id),r=As(t)?t.download_progress:null,i=[Ds(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,U.jsxs)(`li`,{className:`model-row${n?` is-current`:``}`,children:[(0,U.jsxs)(`div`,{className:`model-row-text`,children:[(0,U.jsxs)(`span`,{className:`model-row-name`,title:t.id,children:[ge[t.id],t.rank&&(0,U.jsxs)(`span`,{className:`model-row-rank`,children:[`#`,t.rank,` `,t.note]}),t.state===`loaded`&&(0,U.jsx)(`span`,{className:`model-badge is-loaded`,children:Es.loaded}),t.fits===!0&&t.available!==!1&&(0,U.jsx)(`span`,{className:`model-badge is-fit`,children:`Fits this PC`}),t.custom&&(0,U.jsx)(`span`,{className:`model-badge is-custom`,children:`Added by you`})]}),M?.remote&&(0,U.jsx)(`span`,{className:`model-row-meta${t.price?``:` is-unknown-price`}`,children:wC(t.price)}),t.display_name&&(0,U.jsx)(`span`,{className:`model-row-meta`,children:t.id}),i&&(0,U.jsx)(`span`,{className:`model-row-meta`,children:i}),t.placement?.warning&&(0,U.jsx)(`span`,{className:`model-row-meta is-warning`,role:`alert`,children:t.placement.warning}),t.unavailable_reason&&(0,U.jsxs)(`span`,{className:`model-row-meta`,children:[`Can't run here: `,t.unavailable_reason]}),t.evidence&&(0,U.jsxs)(`span`,{className:`model-row-meta`,children:[`Measured: `,t.evidence]}),r&&(0,U.jsx)(`progress`,{max:100,value:r.percent,"aria-label":`Downloading ${ge[t.id]}`}),t.custom&&t.source_url&&(0,U.jsxs)(`span`,{className:`model-row-meta`,children:[`From `,t.source_url]})]}),t.custom&&!n&&!r&&(k===t.id?(0,U.jsxs)(`span`,{className:`model-row-confirm`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`btn-danger`,onClick:()=>void le(t.id),disabled:C!==null,children:[C===`rm:${t.id}`?(0,U.jsx)(B,{size:13,className:`spin`}):null,t.downloaded?`Remove and delete download`:`Remove`]}),(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>A(null),disabled:C!==null,children:`Keep`})]}):(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>A(t.id),disabled:C!==null,"aria-label":`Remove ${ge[t.id]}`,children:`Remove`})),n?(0,U.jsxs)(`span`,{className:`model-row-current`,children:[(0,U.jsx)(te,{size:13,"aria-hidden":`true`}),` In use`]}):t.available===!1?null:r?(0,U.jsxs)(`span`,{className:`model-row-current`,children:[(0,U.jsx)(B,{size:13,className:`spin`}),` `,Math.round(r.percent),`%`]}):t.downloaded?(0,U.jsxs)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void se(t.id),disabled:C!==null,"aria-label":`Use ${ge[t.id]}`,children:[C===t.id?(0,U.jsx)(B,{size:13,className:`spin`}):null,` Use`]}):(0,U.jsxs)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void ce(t.id),disabled:C!==null,"aria-label":`Download ${ge[t.id]}`,children:[C===`dl:${t.id}`?(0,U.jsx)(B,{size:13,className:`spin`}):null,` Download`]})]},t.id)};return(0,U.jsxs)(`div`,{className:`settings-pane`,children:[(0,U.jsx)(`h2`,{className:`settings-pane-title`,children:`Model`}),(0,U.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,U.jsx)(`div`,{className:`provider-tabs`,role:`radiogroup`,"aria-label":`Where GAIA runs`,children:(i??[{id:`local`,name:`Local`,remote:!1}]).map(e=>(0,U.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":l===e.id,className:`provider-tab${l===e.id?` is-active`:``}${N(e)?` is-disabled`:``}`,onClick:()=>u(e.id),disabled:N(e)&&l!==e.id,title:N(e)?e.network?.detail??void 0:void 0,children:[e.remote?(0,U.jsx)(_e,{size:14,"aria-hidden":`true`}):(0,U.jsx)(we,{size:14,"aria-hidden":`true`}),(0,U.jsx)(`span`,{children:e.name}),e.remote&&e.models_discovered&&(0,U.jsx)(`span`,{className:`provider-tab-dot`,"aria-label":`connected`})]},e.id))}),o&&(0,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:o}),M&&(0,U.jsxs)(`section`,{className:`settings-card`,"aria-label":M.name,children:[(0,U.jsx)(`p`,{className:`settings-note`,children:M.privacy_notice}),M.id===`local`&&(0,U.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}.`]}),M.remote&&!P&&(0,U.jsxs)(`div`,{className:`settings-field`,children:[(0,U.jsx)(`span`,{className:`settings-label`,children:`Prices`}),(0,U.jsx)(SD,{provider:M.id})]}),N(M)&&(0,U.jsxs)(`div`,{className:`settings-field`,children:[(0,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:M.network?.detail}),(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void ne(),children:`Check again`})]}),M.remote&&!N(M)&&(0,U.jsxs)(`form`,{className:`settings-field`,onSubmit:e=>{e.preventDefault(),ae()},children:[(0,U.jsx)(`span`,{className:`settings-label`,children:`API key`}),(0,U.jsx)(`span`,{className:`settings-hint`,children:cO(M)}),M.id===`amd`&&(0,U.jsxs)(`div`,{className:`settings-grid`,children:[(0,U.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,U.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,U.jsxs)(`div`,{className:`settings-row`,children:[(0,U.jsx)(`input`,{className:`settings-input`,type:`password`,autoComplete:`off`,spellCheck:!1,value:y,onChange:e=>b(e.target.value),placeholder:lO(M),"aria-label":`${M.name} API key`}),(0,U.jsxs)(`button`,{type:`submit`,className:`btn-primary`,disabled:C!==null||!y&&!M.key_source,children:[C===`connect`?(0,U.jsx)(B,{size:13,className:`spin`}):null,M.models_discovered?`Reconnect`:`Connect`]}),(M.key_source===`lemonade`||M.key_source===`stored`)&&(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void oe(),disabled:C!==null,children:`Forget key`})]}),M.error&&(0,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:M.error})]}),D&&(0,U.jsx)(`p`,{className:D.ok?`settings-ok`:`settings-error`,role:D.ok?`status`:`alert`,children:D.text}),M.id===`local`&&ve&&e?.downloaded!==!1&&(0,U.jsx)(iO,{model:ve}),P&&(0,U.jsxs)(`div`,{className:`settings-field`,children:[(0,U.jsx)(`span`,{className:`settings-label`,children:`Models`}),(d?.length??0)>6&&(0,U.jsx)(`input`,{className:`settings-input`,type:`search`,value:h,onChange:e=>g(e.target.value),placeholder:`Search models`,"aria-label":`Search models`}),p&&(0,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:p}),!d&&!p&&(0,U.jsxs)(`p`,{className:`settings-hint`,children:[(0,U.jsx)(B,{size:13,className:`spin`}),` Loading…`]}),d&&fe.length===0&&(0,U.jsx)(`p`,{className:`settings-hint`,children:`No models match.`}),(0,U.jsx)(`ul`,{className:`model-list`,children:R.map(z)}),pe&&me.length>0&&(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>v(!0),children:`Show all models`}),l===`fireworks`&&_&&!h.trim()&&(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>v(!1),children:`Show recommended models`}),he.length>0&&(0,U.jsxs)(`details`,{className:`model-unavailable`,children:[(0,U.jsxs)(`summary`,{children:[`Not available on this PC (`,he.length,`)`]}),(0,U.jsx)(`ul`,{className:`model-list`,children:he.map(z)})]})]}),M.id===`local`&&P&&(0,U.jsx)(aO,{onAdded:e=>void ue(e)}),M.remote&&(0,U.jsx)(oO,{})]})]})}function dO(){let e=H(e=>e.sessions),[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(null),a=(0,V.useCallback)(async()=>{i(null);try{n((await Fi()).sessions)}catch(e){i(e instanceof Error?e.message:String(e))}},[]);(0,V.useEffect)(()=>{a()},[a]);let o=(0,V.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,U.jsxs)(`div`,{className:`settings-pane`,children:[(0,U.jsx)(`h2`,{className:`settings-pane-title`,children:`Permissions`}),(0,U.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,U.jsxs)(`p`,{className:`settings-hint`,children:[`New chats start in full access only when `,(0,U.jsx)(`code`,{children:`full_access`}),` is set in`,(0,U.jsx)(`code`,{children:` ~/.gaia/config.json`}),` (the TUI’s `,(0,U.jsx)(`code`,{children:`/full-access always`}),`).`]}),r&&(0,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r}),t&&t.length===0&&(0,U.jsx)(`p`,{className:`settings-hint`,children:`No chat has full access or anything allowed without asking.`}),t?.map(e=>(0,U.jsxs)(`section`,{className:`settings-card`,"aria-label":s(e.session_id),children:[(0,U.jsxs)(`div`,{className:`settings-row settings-row-between`,children:[(0,U.jsx)(`span`,{className:`settings-label`,children:s(e.session_id)}),e.mode===`full_access`&&(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>o(async()=>{let t=(await Ii(e.session_id,`ask`)).mode;GC(e.session_id,t)}),children:`Turn off full access`})]}),e.grants.length>0&&(0,U.jsx)(`ul`,{className:`grant-list`,children:e.grants.map(t=>(0,U.jsxs)(`li`,{className:`grant-row`,children:[(0,U.jsx)(`code`,{children:t.label}),(0,U.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,U.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>o(()=>Li(e.session_id)),children:`Revoke all in this chat`})]},e.session_id))]})}var fO=[{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 pO({onUseSkill:e}){let[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)({}),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(``);(0,V.useEffect)(()=>{let e=!1;return Ia().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,U.jsxs)(`li`,{className:`skill-row`,children:[(0,U.jsxs)(`div`,{className:`skill-row-text`,children:[(0,U.jsxs)(`span`,{className:`skill-row-name`,children:[t.name,t.version&&(0,U.jsxs)(`span`,{className:`skill-row-meta`,children:[` v`,t.version]}),t.always_on&&(0,U.jsx)(`span`,{className:`skill-row-meta`,children:` · Always on`})]}),(0,U.jsx)(`span`,{className:`skill-row-desc`,children:t.description})]}),!t.always_on&&(0,U.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,U.jsxs)(`div`,{className:`settings-pane`,children:[(0,U.jsx)(`h2`,{className:`settings-pane-title`,children:`Skills`}),(0,U.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,U.jsx)(`code`,{children:`~/.gaia/skills`}),`, one folder each with a `,(0,U.jsx)(`code`,{children:`SKILL.md`}),` file.`]}),a&&(0,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:a}),!t&&!a&&(0,U.jsxs)(`p`,{className:`settings-hint`,children:[(0,U.jsx)(B,{size:13,className:`spin`}),` Loading…`]}),t&&t.length>6&&(0,U.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,U.jsx)(`p`,{className:`settings-hint`,children:`No skills are installed.`}),d?fO.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,U.jsxs)(`section`,{className:`skill-group`,"aria-label":e.title,children:[(0,U.jsxs)(`h3`,{className:`skill-group-title`,children:[e.title,` `,(0,U.jsx)(`span`,{className:`skill-row-meta`,children:r})]}),(0,U.jsx)(`p`,{className:`settings-hint`,children:e.note}),n.length===0?(0,U.jsx)(`p`,{className:`settings-hint`,children:e.empty}):(0,U.jsx)(`ul`,{className:`skill-list`,children:n.map(f)})]},e.source)}):(0,U.jsx)(`ul`,{className:`skill-list`,children:u.map(f)}),Object.keys(r).length>0&&(0,U.jsxs)(`div`,{className:`settings-card`,role:`alert`,children:[(0,U.jsx)(`span`,{className:`settings-label`,children:`Skipped, could not be read`}),(0,U.jsx)(`ul`,{className:`grant-list`,children:Object.entries(r).map(([e,t])=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`code`,{children:e}),` — `,t]},e))})]})]})}function mO(){let e=H(e=>e.setShowMemoryDashboard),t=H(e=>e.closeSettings),[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(!1);(0,V.useEffect)(()=>{ZE().then(r).catch(e=>a(e instanceof Error?e.message:String(e)))},[]);let c=(0,V.useCallback)(async()=>{if(n){s(!0),a(null);try{r(await QE({memory_enabled:!n.memory_enabled}))}catch(e){a(e instanceof Error?e.message:String(e))}finally{s(!1)}}},[n]);return(0,U.jsxs)(`div`,{className:`settings-pane`,children:[(0,U.jsx)(`h2`,{className:`settings-pane-title`,children:`Memory`}),(0,U.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,U.jsxs)(`label`,{className:`setting-row`,children:[(0,U.jsx)(`span`,{children:`Remember across chats`}),(0,U.jsxs)(`span`,{className:`toggle-switch`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:!!n?.memory_enabled,onChange:()=>void c(),disabled:!n||o,"aria-label":`Remember across chats`}),(0,U.jsx)(`span`,{className:`toggle-track`})]})]}),i&&(0,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:i}),(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{t(),e(!0)},children:`Open the memory dashboard`}),(0,U.jsx)(`p`,{className:`settings-hint`,children:`Search, edit and forget what GAIA remembers.`})]})}var hO=`Keep for: enter a whole number of days from 1 to 365.`,gO=`Use at most: enter a whole number of MB from 10 to 100,000.`;function _O(e,t,n){if(!/^\d+$/.test(e.trim()))return!1;let r=Number(e);return r>=t&&r<=n}function vO(e){return e<1048576?`${Math.ceil(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function yO(){let[e,t]=(0,V.useState)(null),[n,r]=(0,V.useState)(``),[i,a]=(0,V.useState)(``),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(!1);(0,V.useEffect)(()=>{Wo().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,V.useState)({days:!1,mb:!1}),f=!_O(n,1,365)||u.days,p=!_O(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 Go(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,U.jsxs)(`div`,{className:`settings-field`,"aria-label":`Undo history`,children:[(0,U.jsx)(`span`,{className:`settings-label`,children:`Undo history`}),(0,U.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,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`setting-row`,children:[(0,U.jsx)(`label`,{htmlFor:`undo-days`,children:`Keep for (days)`}),(0,U.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,U.jsx)(`p`,{id:`undo-days-error`,className:`settings-error`,children:hO}),(0,U.jsxs)(`div`,{className:`setting-row`,children:[(0,U.jsx)(`label`,{htmlFor:`undo-mb`,children:`Use at most (MB)`}),(0,U.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,U.jsx)(`p`,{id:`undo-mb-error`,className:`settings-error`,children:gO}),(0,U.jsxs)(`div`,{className:`setting-row setting-row-path`,children:[(0,U.jsx)(`span`,{children:`In use`}),(0,U.jsxs)(`span`,{children:[vO(e.used_bytes),` for `,e.turns,` turn`,e.turns===1?``:`s`,` `,`in `,(0,U.jsx)(`code`,{className:`setting-path`,children:e.path})]})]}),(0,U.jsx)(`button`,{type:`button`,className:`btn-model-save`,onClick:()=>void h(),disabled:!m||c||f||p,children:c?`Saving…`:`Save`})]}),o&&(0,U.jsx)(`p`,{className:o.ok?`settings-ok`:`settings-error`,role:o.ok?`status`:`alert`,children:o.text})]})}function bO(){let e=H(e=>e.sessions),t=H(e=>e.removeSession),n=bs(),r=H(e=>e.systemStatus?.data_dir),[i,a]=(0,V.useState)(!1),[o,s]=(0,V.useState)(null),c=(0,V.useRef)(null);(0,V.useEffect)(()=>()=>{c.current&&clearTimeout(c.current)},[]);let l=(0,V.useCallback)(async()=>{if(!i){a(!0),c.current=setTimeout(()=>a(!1),4e3);return}a(!1);let n=[];for(let r of e)try{await Ba(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,U.jsxs)(`div`,{className:`settings-pane`,children:[(0,U.jsx)(`h2`,{className:`settings-pane-title`,children:`Privacy`}),(0,U.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,U.jsxs)(`div`,{className:`setting-row`,children:[(0,U.jsx)(`span`,{children:`Data folder`}),(0,U.jsx)(`code`,{className:`setting-path`,children:r})]}),(0,U.jsx)(yO,{}),(0,U.jsx)(`div`,{className:`danger-divider`}),(0,U.jsx)(`p`,{className:`danger-warning`,children:`Deletes every chat and its messages. Documents and memory are kept.`}),(0,U.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,U.jsx)(`p`,{className:o.ok?`settings-ok`:`settings-error`,role:o.ok?`status`:`alert`,children:o.text})]})}var xO=[{id:`needs_approval`,label:`Needs your approval`},{id:`question`,label:`Has a question`},{id:`finished`,label:`Finished`}],SO=[{value:`banner`,label:`Banner`},{value:`badge`,label:`Badge`},{value:`off`,label:`Off`}],CO=[0,10,20,30,50];function wO(){return typeof Notification>`u`?`unsupported`:Notification.permission}function TO(){let e=ic(),t=!!window.gaiaAPI,[n,r]=(0,V.useState)(wO),i=Object.values(e.modes).includes(`banner`);return(0,U.jsxs)(`div`,{className:`settings-pane`,children:[(0,U.jsx)(`h2`,{className:`settings-pane-title`,children:`Notifications`}),(0,U.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.`}),xO.map(t=>(0,U.jsxs)(`div`,{className:`setting-row`,children:[(0,U.jsx)(`span`,{id:`alert-${t.id}`,children:t.label}),(0,U.jsx)(`div`,{className:`segmented`,role:`radiogroup`,"aria-labelledby":`alert-${t.id}`,children:SO.map(n=>(0,U.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,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{Notification.requestPermission().then(r).catch(e=>{console.error(`[alerts] Notification permission request failed`,e),r(wO())})},children:`Allow banners in this browser`}):(0,U.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,U.jsxs)(`label`,{className:`setting-row`,children:[(0,U.jsx)(`span`,{children:`Play a sound`}),(0,U.jsxs)(`span`,{className:`toggle-switch`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:e.sound,onChange:()=>e.update({sound:!e.sound}),"aria-label":`Play a sound`}),(0,U.jsx)(`span`,{className:`toggle-track`})]})]}),t&&(0,U.jsxs)(`label`,{className:`setting-row`,children:[(0,U.jsx)(`span`,{children:`Flash the taskbar when GAIA isn't focused`}),(0,U.jsxs)(`span`,{className:`toggle-switch`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:e.flash,onChange:()=>e.update({flash:!e.flash}),"aria-label":`Flash the taskbar when GAIA isn't focused`}),(0,U.jsx)(`span`,{className:`toggle-track`})]})]}),(0,U.jsx)(`h3`,{className:`settings-label`,children:`Keep awake`}),t?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`label`,{className:`setting-row`,children:[(0,U.jsx)(`span`,{children:`Keep the PC awake while GAIA works`}),(0,U.jsxs)(`span`,{className:`toggle-switch`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:e.keepAwake,onChange:()=>e.update({keepAwake:!e.keepAwake}),"aria-label":`Keep the PC awake while GAIA works`}),(0,U.jsx)(`span`,{className:`toggle-track`})]})]}),(0,U.jsxs)(`div`,{className:`setting-row`,children:[(0,U.jsx)(`label`,{htmlFor:`battery-floor`,children:`On battery, let it sleep below`}),(0,U.jsx)(`select`,{id:`battery-floor`,value:e.batteryFloor,disabled:!e.keepAwake,onChange:t=>e.update({batteryFloor:Number(t.target.value)}),children:CO.map(e=>(0,U.jsx)(`option`,{value:e,children:e===0?`Never`:`${e}%`},e))})]}),(0,U.jsx)(`p`,{className:`settings-hint`,children:`The screen can still turn off; only sleep is held off.`})]}):(0,U.jsx)(`p`,{className:`settings-hint`,children:`Keep-awake needs the GAIA desktop app.`})]})}var EO=`modulepreload`,DO=function(e,t){return new URL(e,t).href},OO={},kO=function(e){return e.pathname.endsWith(`.css`)},AO=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},jO=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=DO(t,n);let r=s(t),i=kO(r);return AO(OO,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`:EO,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)})},MO=(0,V.lazy)(()=>jO(()=>import(`./ConnectorsPane-QC6sb-o5.js`).then(e=>({default:e.ConnectorsPane})),__vite__mapDeps([0,1,2,3]),import.meta.url)),NO=(0,V.lazy)(()=>jO(()=>import(`./AdvancedSettings-vsSRlTRJ.js`).then(e=>({default:e.AdvancedSettings})),__vite__mapDeps([4,1,2]),import.meta.url)),PO=[{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 FO({onUseSkill:e}){let t=H(e=>e.settingsSection),n=H(e=>e.openSettings),r=H(e=>e.closeSettings),i=(0,V.useRef)(null),a=(0,V.useRef)(null),o=t!==null;if(ei(o,r),Ox(i,o),(0,V.useEffect)(()=>{if(o)return a.current=document.activeElement,()=>{a.current?.focus?.()}},[o,r]),(0,V.useEffect)(()=>{o&&i.current?.querySelector(`.settings-nav-item.is-active`)?.focus()},[o]),!t)return null;let s=(()=>{switch(t){case`general`:return(0,U.jsx)(nO,{});case`model`:return(0,U.jsx)(uO,{});case`permissions`:return(0,U.jsx)(dO,{});case`skills`:return(0,U.jsx)(pO,{onUseSkill:t=>{r(),e(t)}});case`connectors`:return(0,U.jsx)(MO,{});case`memory`:return(0,U.jsx)(mO,{});case`notifications`:return(0,U.jsx)(TO,{});case`privacy`:return(0,U.jsx)(bO,{});case`advanced`:return(0,U.jsx)(NO,{})}})();return(0,U.jsx)(`div`,{className:`settings-overlay`,onMouseDown:e=>{e.target===e.currentTarget&&r()},children:(0,U.jsxs)(`div`,{ref:i,className:`settings-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Settings`,children:[(0,U.jsxs)(`nav`,{className:`settings-nav`,"aria-label":`Settings sections`,children:[(0,U.jsx)(`h1`,{className:`settings-nav-title`,children:`Settings`}),PO.map(e=>(0,U.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,U.jsxs)(`div`,{className:`settings-body`,children:[(0,U.jsx)(`button`,{type:`button`,className:`settings-close`,onClick:r,"aria-label":`Close settings`,children:(0,U.jsx)(Bn,{size:18})}),(0,U.jsx)(V.Suspense,{fallback:(0,U.jsxs)(`p`,{className:`settings-hint`,children:[(0,U.jsx)(B,{size:13,className:`spin`}),` Loading…`]}),children:s})]})]})})}function IO(e,t){let[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(!1),o=(0,V.useRef)(null),c=(0,V.useRef)(null),l=(0,V.useRef)(null),u=(0,V.useCallback)(()=>{o.current&&=(clearTimeout(o.current),null),c.current&&=(clearTimeout(c.current),null),l.current&&=(clearInterval(l.current),null)},[]);(0,V.useEffect)(()=>u,[u]);let d=(0,V.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{}},Mc)},[]),f=e??`Gemma-4-E4B-it-GGUF`;return{isLoadingModel:n,isDownloadingModel:i,loadModel:(0,V.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),Ac),d(n,`load`)}catch(e){s.system.error(`Failed to trigger model load`,e),r(!1)}},[f,t,d]),downloadModel:(0,V.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),jc),d(n,`download`)}catch(e){s.system.error(`Failed to trigger model download`,e),a(!1)}},[f,d])}}var LO=5e3,RO=2e3,zO=3e4,BO=6e4;function VO(e){return e.lemonade_running?`up`:e.lemonade_error?`unresponsive`:`down`}function HO(e){return e.kind===`slow`||e.kind===`error`||e.kind===`ok`&&VO(e.status)===`unresponsive`}function UO(e){let t=e.kind===`ok`?e.status.download_progress?.state:void 0;return t===`downloading`||t===`starting`}function WO(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(),BO);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=HO(t)?n+1:0,r=UO(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?RO:LO)*2**n,zO),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 GO({onRetry:e,label:t}){let[n,r]=(0,V.useState)(!1);return(0,U.jsx)(`button`,{className:`connection-banner__retry`,onClick:()=>{r(!0),Promise.resolve(e()).finally(()=>r(!1))},disabled:n,children:n?`Checking…`:t})}function KO({onRetry:e,backendSlow:t=!1,backendError:n=null}){let{backendConnected:r,systemStatus:i,currentSessionId:a,messages:o}=H(),[s,c]=(0,V.useState)(!1),l=!!a&&o.length>0,u=i?.default_model_name??`Gemma-4-E4B-it-GGUF`,{isDownloadingModel:d,downloadModel:f}=IO(u),p=(0,V.useRef)(i?.lemonade_running),m=(0,V.useRef)(i?.model_downloaded),h=(0,V.useRef)(i?.context_size_sufficient),g=(0,V.useRef)(i?.expected_model_loaded);(0,V.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,U.jsxs)(`div`,{className:`connection-banner ${t?`connection-banner--error`:`connection-banner--warning`}`,role:t?`alert`:`status`,children:[(0,U.jsx)(`div`,{className:`connection-banner__icon`,children:t?(0,U.jsx)(An,{size:16}):(0,U.jsx)(Oe,{size:16})}),(0,U.jsx)(`div`,{className:`connection-banner__text`,children:t?(0,U.jsxs)(U.Fragment,{children:[`Download of `,(0,U.jsx)(`strong`,{children:v}),` failed.`,` `,_?.message&&(0,U.jsx)(`span`,{className:`connection-banner__hint`,children:_.message})]}):(0,U.jsxs)(U.Fragment,{children:[`Downloading `,(0,U.jsx)(`strong`,{children:v}),` (`,e,`).`,_?.state===`downloading`&&_.file&&(0,U.jsxs)(U.Fragment,{children:[` `,(0,U.jsxs)(`span`,{className:`connection-banner__hint`,children:[`File `,_.file_index,` / `,_.total_files,`: `,(0,U.jsx)(`code`,{children:_.file})]})]})]})}),t?(0,U.jsx)(`button`,{className:`connection-banner__retry`,onClick:()=>f(!1,v),children:`Retry`}):(0,U.jsx)(`span`,{className:`connection-banner__loading connection-banner__progress`,children:_&&_.state===`downloading`&&_.total_bytes>0?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`connection-banner__progress-bar`,role:`progressbar`,"aria-valuenow":_.percent,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`Download progress`,children:(0,U.jsx)(`span`,{className:`connection-banner__progress-fill`,style:{width:`${_.percent}%`}})}),(0,U.jsxs)(`span`,{className:`connection-banner__progress-label`,children:[_.percent,`% ·`,` `,(_.downloaded_bytes/1e9).toFixed(2),` /`,` `,(_.total_bytes/1e9).toFixed(2),` GB`]})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(B,{size:13,className:`connection-banner__spinner`}),_?.state===`starting`?`Starting download…`:`Downloading…`]})}),t&&(0,U.jsx)(`button`,{className:`connection-banner__dismiss`,onClick:()=>c(!0),"aria-label":`Dismiss`,children:(0,U.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,U.jsxs)(`div`,{className:`connection-banner connection-banner--init`,role:`status`,children:[(0,U.jsx)(`div`,{className:`connection-banner__icon`,children:(0,U.jsx)(B,{size:16,className:`connection-banner__spinner`})}),(0,U.jsxs)(`div`,{className:`connection-banner__text`,children:[e,(0,U.jsxs)(`span`,{className:`thinking-dots`,children:[(0,U.jsx)(`span`,{children:`.`}),(0,U.jsx)(`span`,{children:`.`}),(0,U.jsx)(`span`,{children:`.`})]})]})]})}if(s||l)return null;if(!r)return(0,U.jsxs)(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[(0,U.jsx)(`div`,{className:`connection-banner__icon`,children:(0,U.jsx)(In,{size:16})}),(0,U.jsxs)(`div`,{className:`connection-banner__text`,children:[`Lost the connection to GAIA.`,` `,(0,U.jsx)(`span`,{className:`connection-banner__hint`,children:`Check that GAIA is still running, then retry.`})]}),e&&(0,U.jsx)(GO,{onRetry:e,label:`Retry`})]});if(n)return(0,U.jsxs)(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[(0,U.jsx)(`div`,{className:`connection-banner__icon`,children:(0,U.jsx)(An,{size:16})}),(0,U.jsxs)(`div`,{className:`connection-banner__text`,children:[`GAIA's backend answered with an error (`,n,`).`,` `,(0,U.jsx)(`span`,{className:`connection-banner__hint`,children:`It may be overloaded. GAIA keeps checking; if it lasts, restart GAIA.`})]}),e&&(0,U.jsx)(GO,{onRetry:e,label:`Check again`})]});if(t)return(0,U.jsxs)(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[(0,U.jsx)(`div`,{className:`connection-banner__icon`,children:(0,U.jsx)(An,{size:16})}),(0,U.jsxs)(`div`,{className:`connection-banner__text`,children:[`GAIA is slow to answer.`,` `,(0,U.jsx)(`span`,{className:`connection-banner__hint`,children:`It may be busy with another chat or app. GAIA keeps checking.`})]}),e&&(0,U.jsx)(GO,{onRetry:e,label:`Check again`})]});if(i?.config_error)return(0,U.jsxs)(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[(0,U.jsx)(`div`,{className:`connection-banner__icon`,children:(0,U.jsx)(An,{size:16})}),(0,U.jsxs)(`div`,{className:`connection-banner__text`,children:[`GAIA settings could not be loaded.`,` `,(0,U.jsx)(`span`,{className:`connection-banner__hint`,children:i.config_error})]}),e&&(0,U.jsx)(GO,{onRetry:e,label:`Check again`})]});if(i&&!i.lemonade_running){let t=VO(i)===`unresponsive`;return(0,U.jsxs)(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[(0,U.jsx)(`div`,{className:`connection-banner__icon`,children:(0,U.jsx)(An,{size:16})}),(0,U.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,U.jsxs)(`span`,{className:`connection-banner__hint`,children:[t?`If it stays this way, restart it: `:`To start it by hand, run `,(0,U.jsx)(`code`,{children:i.start_command})]}):i.start_instruction&&(0,U.jsx)(`span`,{className:`connection-banner__hint`,children:i.start_instruction})]}),e&&(0,U.jsx)(GO,{onRetry:e,label:`Check again`}),(0,U.jsx)(`button`,{className:`connection-banner__dismiss`,onClick:()=>c(!0),"aria-label":`Dismiss`,children:(0,U.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,U.jsxs)(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[(0,U.jsx)(`div`,{className:`connection-banner__icon`,children:(0,U.jsx)(vt,{size:16})}),(0,U.jsxs)(`div`,{className:`connection-banner__text`,children:[`LLM context window is too small (`,t.toLocaleString(),` tokens;`,` `,Oc.toLocaleString(),` required).`,` `,(0,U.jsx)(`span`,{className:`connection-banner__hint`,children:`Reload it with a larger context in Settings → Advanced.`})]}),e&&(0,U.jsx)(GO,{onRetry:e,label:`Check again`}),(0,U.jsx)(`button`,{className:`connection-banner__dismiss`,onClick:()=>c(!0),"aria-label":`Dismiss`,children:(0,U.jsx)(Bn,{size:14})})]})}return null}function qO(){let e=KD(),[t,n]=(0,V.useState)(!1),[r,i]=(0,V.useState)(null),a=(0,V.useCallback)(e=>{let t=WD();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,U.jsxs)(`div`,{className:`update-chip update-chip--downloading`,role:`status`,"aria-live":`polite`,title:`Downloading update${e.version?` ${e.version}`:``}…`,children:[(0,U.jsx)(Oe,{size:13,className:`update-chip__icon`}),(0,U.jsxs)(`span`,{className:`update-chip__label`,children:[`Downloading update… `,t,`%`]})]})}return e.status===`available`?(0,U.jsxs)(`div`,{className:`update-chip update-chip--available`,role:`status`,title:r||e.releaseNotes||`A new version is available.`,children:[(0,U.jsx)(Oe,{size:13,className:`update-chip__icon`}),(0,U.jsx)(`span`,{className:`update-chip__label`,children:r?`Update failed — try again`:`GAIA ${e.version??``} is available`}),!e.pinnedVersion&&(0,U.jsx)(`button`,{type:`button`,className:`update-chip__action`,onClick:()=>a(`downloadUpdate`),children:`Update now`}),(0,U.jsx)(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>n(!0),"aria-label":`Dismiss update notification`,children:(0,U.jsx)(Bn,{size:11})})]}):e.status===`downloaded`?(0,U.jsxs)(`div`,{className:`update-chip update-chip--ready`,role:`status`,"aria-live":`polite`,children:[(0,U.jsx)(tn,{size:13,className:`update-chip__icon`}),(0,U.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,U.jsxs)(`div`,{className:`update-chip update-chip--error`,role:`status`,title:e.error||`Update check failed.`,children:[(0,U.jsx)(An,{size:13,className:`update-chip__icon`}),(0,U.jsx)(`span`,{className:`update-chip__label`,children:`Update check failed`}),(0,U.jsx)(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>n(!0),"aria-label":`Dismiss update error`,children:(0,U.jsx)(Bn,{size:11})})]}):null}var JO={permission_request:{icon:(0,U.jsx)(un,{size:16}),colorClass:`notif-type-permission`,label:`Permission`},policy_alert:{icon:(0,U.jsx)(un,{size:16}),colorClass:`notif-type-policy`,label:`Policy`},security_alert:{icon:(0,U.jsx)(An,{size:16}),colorClass:`notif-type-security`,label:`Security`},status_change:{icon:(0,U.jsx)(ue,{size:16}),colorClass:`notif-type-status`,label:`Status`},info:{icon:(0,U.jsx)(mt,{size:16}),colorClass:`notif-type-info`,label:`Info`},error:{icon:(0,U.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 XO({onClose:e}){let t=qs(qn(Ys)),n=qs(Js),r=qs(e=>e.markRead),i=qs(e=>e.markAllRead),a=qs(e=>e.clearAll),o=qs(e=>e.dismiss),s=qs(e=>e.respondToPermission),c=qs(e=>e.typeFilter),l=qs(e=>e.setTypeFilter),u=(0,V.useCallback)(e=>{r(e)},[r]),d=(0,V.useCallback)(e=>{s(e.id,`allow`).catch(e=>console.error(`[NotificationCenter] allow failed:`,e))},[s]),f=(0,V.useCallback)(e=>{s(e.id,`deny`).catch(e=>console.error(`[NotificationCenter] deny failed:`,e))},[s]);return ei(!0,e),(0,U.jsxs)(`div`,{className:`notification-center`,role:`dialog`,"aria-label":`Notification Center`,children:[(0,U.jsxs)(`div`,{className:`notification-center-header`,children:[(0,U.jsxs)(`div`,{className:`notification-center-title-row`,children:[(0,U.jsx)(`h2`,{className:`notification-center-title`,children:`Notifications`}),n>0&&(0,U.jsx)(`span`,{className:`notification-center-badge`,children:n})]}),(0,U.jsx)(`button`,{className:`btn-icon notification-center-close`,onClick:e,"aria-label":`Close notification center`,children:(0,U.jsx)(Bn,{size:18})})]}),(0,U.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,U.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,U.jsx)(`div`,{className:`notification-list`,children:t.length===0?(0,U.jsxs)(`div`,{className:`notification-empty`,children:[(0,U.jsx)(w,{size:40,strokeWidth:1.2}),(0,U.jsx)(`span`,{children:`No notifications`})]}):t.map(e=>{let t=JO[e.type];return(0,U.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,U.jsx)(`span`,{className:`notification-unread-dot`}),(0,U.jsx)(`span`,{className:`notification-icon`,children:t.icon}),(0,U.jsxs)(`div`,{className:`notification-content`,children:[(0,U.jsxs)(`div`,{className:`notification-content-header`,children:[(0,U.jsx)(`span`,{className:`notification-agent`,children:e.agentName}),(0,U.jsx)(`span`,{className:`notification-time`,children:YO(e.timestamp)})]}),e.title&&(0,U.jsx)(`span`,{className:`notification-title`,children:e.title}),(0,U.jsx)(`span`,{className:`notification-message`,children:e.message}),e.type===`permission_request`&&e.tool&&e.tool!==`allow_path_access`&&(0,U.jsxs)(`span`,{className:`notification-tool`,children:[`Tool: `,(0,U.jsx)(`code`,{children:e.tool})]}),e.type===`policy_alert`&&(0,U.jsxs)(`div`,{className:`notification-policy-details`,children:[e.tool&&(0,U.jsxs)(`span`,{className:`notification-tool`,children:[`Tool: `,(0,U.jsx)(`code`,{children:e.tool})]}),e.reason&&(0,U.jsxs)(`span`,{className:`notification-policy-reason`,children:[`Reason: `,e.reason]}),e.ruleIds&&e.ruleIds.length>0&&(0,U.jsxs)(`span`,{className:`notification-tool`,children:[`Rules: `,(0,U.jsx)(`code`,{children:e.ruleIds.join(`, `)})]}),e.policyVersion&&(0,U.jsxs)(`span`,{className:`notification-tool`,children:[`Policy: `,(0,U.jsx)(`code`,{children:e.policyVersion})]}),(0,U.jsxs)(`span`,{className:`notification-tool`,children:[`Receipt:`,` `,e.receiptId?(0,U.jsx)(`code`,{children:e.receiptId}):(0,U.jsx)(`em`,{children:`Receipt unavailable`})]})]}),e.type===`permission_request`&&!e.response&&(0,U.jsxs)(`div`,{className:`notification-actions`,children:[(0,U.jsxs)(`button`,{className:`notification-action-btn notification-action-allow`,onClick:t=>{t.stopPropagation(),d(e)},children:[(0,U.jsx)(te,{size:14}),`Approve`]}),(0,U.jsxs)(`button`,{className:`notification-action-btn notification-action-deny`,onClick:t=>{t.stopPropagation(),f(e)},children:[(0,U.jsx)(Bn,{size:14}),`Deny`]})]}),e.type===`permission_request`&&e.response&&(0,U.jsx)(`span`,{className:`notification-response-badge ${e.response===`allow`?`response-allow`:`response-deny`}`,children:e.response===`allow`?`Approved`:`Denied`})]}),(0,U.jsx)(`button`,{className:`notification-dismiss`,onClick:t=>{t.stopPropagation(),o(e.id)},"aria-label":`Dismiss notification`,children:(0,U.jsx)(Bn,{size:14})})]},e.id)})}),t.length>0&&(0,U.jsxs)(`div`,{className:`notification-center-footer`,children:[(0,U.jsxs)(`button`,{className:`notification-footer-btn`,onClick:i,disabled:n===0,children:[(0,U.jsx)(te,{size:14}),`Mark All Read`]}),(0,U.jsxs)(`button`,{className:`notification-footer-btn notification-footer-clear`,onClick:a,children:[(0,U.jsx)(On,{size:14}),`Clear`]})]})]})}var ZO=1500,QO=e=>new Promise(t=>setTimeout(t,e));async function $O({onProgress:e,isCancelled:t=()=>!1,pollMs:n=ZO}={}){try{await aa(ZT)}catch(e){if(e?.httpStatus!==409)throw e;let t=await oa(ZT).catch(()=>null);if(!t||t.status===`completed`||t.status===`failed`)throw e}for(;!t();){let t=await oa(ZT);if(e?.(t),t.status===`completed`)return;if(t.status===`failed`)throw Error(t.error||`The GAIA agent could not be installed.`);await QO(n)}}function ek({onInstalled:e}){let[t,n]=(0,V.useState)({kind:`idle`}),r=(0,V.useRef)(!1);(0,V.useEffect)(()=>()=>{r.current=!0},[]);let i=(0,V.useCallback)(async()=>{n({kind:`installing`,percent:0});try{if(await $O({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,U.jsxs)(`div`,{className:`app-notice is-warning`,role:`status`,children:[t.kind===`installing`?(0,U.jsxs)(`span`,{children:[`Installing the GAIA agent… `,Math.round(t.percent),`%`]}):t.kind===`failed`?(0,U.jsxs)(`span`,{children:[`The GAIA agent could not be installed: `,t.error]}):(0,U.jsx)(`span`,{children:`The GAIA agent isn't installed, so new chats can't start yet.`}),t.kind!==`installing`&&(0,U.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>void i(),children:t.kind===`failed`?`Try again`:`Install GAIA agent`})]})}function tk(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 nk(e,t){let{addNotification:n}=qs.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 rk=$n((e,t)=>({schedules:[],loading:!1,error:null,actionError: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 Po()).schedules||[],r=t().errorCounts;r&&nk(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 Io(t,n,r);e(e=>({schedules:[...e.schedules,i],actionError:null}))}catch(e){throw s.api.error(`Failed to create schedule`,e),e}},updateScheduleStatus:async(t,n)=>{try{let r=await Lo(t,n);e(e=>({schedules:e.schedules.map(e=>e.name===t?r:e),actionError:null}))}catch(n){s.api.error(`Failed to update schedule "${t}"`,n),e({actionError:tk(n,`Failed to update schedule`)})}},runScheduleNow:async t=>{try{let n=await K(t);e(e=>({schedules:e.schedules.map(e=>e.name===t?n:e),actionError:null}))}catch(n){s.api.error(`Failed to run schedule "${t}" now`,n),e({actionError:tk(n,`Could not run the schedule now`)})}},deleteSchedule:async t=>{try{await Ro(t),e(e=>({schedules:e.schedules.filter(e=>e.name!==t),selectedSchedule:e.selectedSchedule===t?null:e.selectedSchedule,actionError:null}))}catch(n){s.api.error(`Failed to delete schedule "${t}"`,n),e({actionError:tk(n,`Failed to delete schedule`)})}},selectSchedule:n=>{e({selectedSchedule:n,results:[],resultsLoading:!1}),n&&t().loadResults(n)},loadResults:async n=>{e({resultsLoading:!0});try{let r=await zo(n);if(t().selectedSchedule!==n)return;e({results:r.results||[],resultsLoading:!1})}catch(r){if(s.api.error(`Failed to load results for "${n}"`,r),t().selectedSchedule!==n)return;e({results:[],resultsLoading:!1})}},dismissActionError:()=>e({actionError:null})})),ik=new Set([`loading_model`,`downloading_model`,`model_retry`,`waiting`]),ak=5;function ok(e,t){return{id:e,title:t.get(e)?.title??`Untitled chat`}}function sk(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=>({...ok(e,t),reason:`approval`}));n&&e.awaitingUser&&!a.has(e.currentSessionId)&&o.push({...ok(e.currentSessionId,t),reason:`answer`});for(let[n,r]of Object.entries(e.awaitingBySession))o.some(e=>e.id===n)||o.push({...ok(n,t),reason:r===`question`?`answer`:`approval`});let s=n&&!e.awaitingUser&&e.livePhase&&ik.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,ak).map(e=>ok(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=>ok(e,t)),needsYou:o,recent:u}}function ck(e){let t=(0,V.useRef)(e);t.current=e,(0,V.useEffect)(()=>{let e=window.gaiaAPI?.tray;if(!e)return;let n=``,r=null,i=()=>{let t=H.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:qs.getState().notifications},a=r;if(r=i,a&&Object.keys(i).every(e=>i[e]===a[e]))return;let o=sk(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=H.subscribe(i),o=qs.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`:H.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 lk(){(0,V.useEffect)(()=>{let e=window.gaiaAPI;if(!e)return;let t=qs.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=H.getState();n.currentSessionId!==t&&n.setMessages([]),n.setCurrentSession(t)})];return()=>n.forEach(e=>e())},[])}function uk(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(),H.getState().setCurrentSession(e)}}function dk(){let[e,t]=(0,V.useState)(null);return(0,V.useEffect)(()=>{let e=navigator;if(!e.getBattery)return;let n=null,r=()=>{n&&t({charging:n.charging,level:n.level})};return e.getBattery().then(e=>{n=e,r(),e.addEventListener(`levelchange`,r),e.addEventListener(`chargingchange`,r)}).catch(e=>s.system.warn(`Battery level unavailable; keep-awake ignores the battery policy.`,e)),()=>{n?.removeEventListener(`levelchange`,r),n?.removeEventListener(`chargingchange`,r)}},[]),e}function fk(){lk();let e=H(e=>e.runningSessionIds),t=H(e=>e.awaitingBySession),n=H(e=>e.sessions),r=H(e=>e.currentSessionId),i=qs(qn(Zs)),a=ic(),o=dk(),c=(0,V.useRef)(null),l=dc(e,t,i),u=JSON.stringify(l);(0,V.useEffect)(()=>{let e=JSON.parse(u),t=c.current;if(c.current=e,t===null)return;let{sessions:n,currentSessionId:r}=H.getState(),i=document.hasFocus(),o=!1;for(let{sessionId:c,event:l}of fc(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`||hc(c,r,i))&&(o=!0,t===`banner`)){if(l!==`finished`){let{title:t,body:n}=mc(l,e);uk(c,t,n)}else Va(c).then(e=>{H.getState().updateSessionInList(c,e);let{title:t,body:n}=mc(l,e);uk(c,t,n)}).catch(t=>{s.system.error(`Could not read how chat ${c} ended`,t);let{title:n,body:r}=mc(l,{...e,last_run_status:null});uk(c,n,r)})}}if(o){if(a.sound)try{vc()}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=gc(n,l,a.modes,r);(0,V.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&&_c(o,a.batteryFloor);(0,V.useEffect)(()=>{window.gaiaAPI?.power.setKeepAwake(f).catch(e=>s.system.error(`Could not change keep-awake`,e))},[f])}function pk(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 mk(e){return e.replace(/-/g,``).slice(0,7)}function hk(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 gk(e,t,n){return!e||t&&(e===t||e===mk(t))?null:n.some(t=>t.id===e)?e:hk(n,e)}function _k(e){return new URLSearchParams(e.search).get(`session`)||e.hash.replace(/^#/,``)||null}var vk=`gaia:last-session`;function yk(e){try{e?localStorage.setItem(vk,e):localStorage.removeItem(vk)}catch(e){s.ui.warn(`Could not save the open chat for the next launch`,e)}}function bk(){try{return localStorage.getItem(vk)}catch(e){return s.ui.warn(`Could not read the chat open at last launch`,e),null}}var xk=1e3,Sk=3e4;function Ck(e,{initialMs:t=xk,maxMs:n=Sk,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 wk=(0,V.lazy)(()=>jO(()=>import(`./MemoryDashboard-CH1rYgBS.js`).then(e=>({default:e.MemoryDashboard})),__vite__mapDeps([5,1,2,6,7]),import.meta.url)),Tk=(0,V.lazy)(()=>jO(()=>import(`./ScheduleManager-C842iHFu.js`).then(e=>({default:e.ScheduleManager})),__vite__mapDeps([8,1,2,6,9]),import.meta.url)),Ek=(0,V.lazy)(()=>jO(()=>import(`./DocumentLibrary-Cs7_bM_p.js`).then(e=>({default:e.DocumentLibrary})),__vite__mapDeps([10,1,2,11]),import.meta.url)),Dk=(0,V.lazy)(()=>jO(()=>import(`./FileBrowser-kw0x-OQP.js`).then(e=>({default:e.FileBrowser})),__vite__mapDeps([12,1,2,13]),import.meta.url)),Ok=(0,V.lazy)(()=>jO(()=>import(`./MobileAccessModal-7LB2ZwbS.js`).then(e=>({default:e.MobileAccessModal})),__vite__mapDeps([14,1,2,15]),import.meta.url)),kk=3,Ak=3e5,jk=6e3,Mk=6e4,Nk=e=>e instanceof TypeError,Pk=e=>new Promise(t=>setTimeout(t,e));function Fk(){return(0,U.jsx)(`div`,{className:`loading-spinner`,role:`status`,"aria-label":`Loading`})}var Ik=e=>e===1||e%10==0;function Lk(){let e=H(e=>e.currentSessionId),t=H(e=>e.setSessions),n=H(e=>e.setCurrentSession),r=H(e=>e.addSession),a=H(e=>e.setMessages),o=H(e=>e.showDocLibrary),l=H(e=>e.showFileBrowser),u=H(e=>e.showMemoryDashboard),d=H(e=>e.showSchedules),f=H(e=>e.sidebarOpen),p=H(e=>e.setSidebarOpen),m=H(e=>e.setSystemStatus),h=H(e=>e.setBackendConnected),g=H(e=>e.setAgents),_=H(e=>e.agents),v=H(e=>e.setPendingPrompt),y=H(e=>e.setDefaultPermissionMode),b=H(e=>e.openSettings),x=H(e=>e.settingsSection),S=H(e=>e.syncSystemTheme),C=ps(e=>e.restoreNotice),w=ps(e=>e.dismissRestoreNotice),T=qs(e=>e.showPanel),E=H(e=>e.systemStatus?.initialized===!0),D=qs(e=>e.setShowPanel);(0,V.useEffect)(()=>{if(!C?.ok)return;let e=setTimeout(w,jk);return()=>clearTimeout(e)},[C,w]);let[O,k]=(0,V.useState)({state:`checking`}),A=(0,V.useRef)(O);A.current=O;let[ee,j]=(0,V.useState)(!1),M=(0,V.useRef)(ee);M.current=ee;let[N,P]=(0,V.useState)(!1),te=N||ee&&!QT(_),ne=(0,V.useRef)(te);ne.current=te;let[re,ie]=(0,V.useState)(null),[F,ae]=(0,V.useState)(``),[oe,se]=(0,V.useState)(0),[ce,le]=(0,V.useState)(!1),[ue,de]=(0,V.useState)(!1),[fe,I]=(0,V.useState)(null),pe=(0,V.useRef)(async()=>{}),L=(0,V.useRef)(async()=>{}),R=(0,V.useCallback)(async(e=!1,t=!1)=>{e||k({state:`checking`});let n=0;try{for(;;){await ps.getState().refresh();let e=ps.getState().active,r;try{r=await ca(!!e?.remote)}catch(e){if(!t||!Nk(e)||n>=Mk)throw e;await Pk(xk),n+=xk;continue}n>0&&await Promise.all([pe.current(),L.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})}},[]),me=(0,V.useRef)(0),he=(0,V.useCallback)(async()=>{let e=++me.current,t=(await ia()).agents||[];e===me.current&&(g(t),j(!0),QT(t)&&P(!1))},[g]),ge=(0,V.useCallback)(()=>{let e=M.current;j(!1),he().catch(t=>{s.api.warn(`Agent list unavailable after setup`,t),e&&j(!0)})},[he]);(0,V.useEffect)(()=>{let e=()=>{ne.current&&he().catch(e=>s.api.warn(`Agent list unavailable`,e))};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[he]);let _e=(0,V.useCallback)(async()=>{y((await Fi()).default_mode)},[y]),ve=(0,V.useRef)([]);(0,V.useEffect)(()=>{i(`0.25.3rc1`),R(!1,!0);let e=[Ck(he,{onError:(e,t)=>{Ik(t)&&s.api.warn(`Agent list unavailable (attempt ${t}); retrying`,e)}}),Ck(_e,{onError:(e,t)=>{Ik(t)&&s.api.warn(`Default permission mode unavailable (attempt ${t}); retrying`,e)}})];return ve.current=e,()=>e.forEach(e=>e.stop())},[R,he,_e]);let z=(0,V.useCallback)(()=>{ve.current.forEach(e=>e.kick()),ps.getState().retryNow(),L.current(),A.current.state===`unknown`&&R(!0)},[R]),ye=(0,V.useRef)(z);ye.current=z;let be=(0,V.useRef)(0),xe=(0,V.useRef)(0),Se=(0,V.useRef)(null),Ce=(0,V.useRef)(!1),[we,Te]=(0,V.useState)(!1),[Ee,De]=(0,V.useState)(null),Oe=(0,V.useCallback)(e=>{if(e.kind===`unreachable`){s.system.warn(`System status check failed`,e.error),Ce.current=!0,xe.current=0,Se.current=null,Te(!1),De(null),h(!1),m(null);return}if(e.kind===`error`){s.system.warn(`System status answered HTTP ${e.httpStatus}`,e.message),Ce.current&&ye.current(),Ce.current=!1,xe.current=0,Se.current=null,Te(!1),De(`HTTP ${e.httpStatus}: ${e.message}`),h(!0);return}if(e.kind===`slow`){if(xe.current+=1,Se.current??=Date.now(),De(null),s.system.warn(`System status did not answer in time (${xe.current} in a row)`),Date.now()-Se.current>=Ak){Te(!1),h(!1),m(null);return}h(!0),(Ce.current||xe.current>=kk)&&Te(!0);return}let{status:t}=e;Ce.current&&ye.current(),Ce.current=!1,xe.current=0,Se.current=null,Te(!1),De(null),h(!0),be.current=t.lemonade_running?0:be.current+1;let n=H.getState().systemStatus;t.lemonade_running||be.current>=kk||!n?.lemonade_running?m(t):m({...n,download_progress:t.download_progress})},[h,m]),ke=(0,V.useRef)(Oe);ke.current=Oe;let[Ae]=(0,V.useState)(()=>WO(e=>ke.current(e))),je=Ae.check;pe.current=je,(0,V.useEffect)(()=>rE(Ae.start),[Ae]);let Me=(0,V.useRef)(``);(0,V.useEffect)(()=>{let e=e=>La().then(n=>{let r=n.sessions||[];if(!e&&r.length===0&&H.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
|
+
`)})]}),me&&(0,U.jsxs)(`div`,{className:`setup-done`,role:`status`,children:[(0,U.jsxs)(`div`,{className:`setup-done-head`,children:[(0,U.jsxs)(`p`,{children:[`GAIA is ready.`,ge&&(0,U.jsxs)(U.Fragment,{children:[` `,(0,U.jsx)(`strong`,{children:Cs(ge)}),` answers`,P?` in the cloud`:` on this PC`,`.`]})]}),(0,U.jsx)(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void R(),autoFocus:!0,children:`Start chatting`})]}),E.length>0&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`setup-hint`,children:`Or start with one of these:`}),(0,U.jsx)(OD,{cards:E,onPick:e=>void R(e)})]})]})]})})}var VD=bc()?`menu bar`:`tray`,HD=[{key:`minimizeToTray`,label:`Keep running when the window closes`,hint:`GAIA stays in the ${VD} with your model loaded. Quit from the ${VD} 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 ${VD}`,hint:`GAIA opens without its window. Use the ${VD} icon to show it.`}];function UD(){let e=window.gaiaAPI?.tray,[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(null);(0,V.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,V.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,U.jsxs)(`div`,{className:`settings-field`,role:`group`,"aria-labelledby":`desktop-app-label`,children:[(0,U.jsx)(`span`,{className:`settings-label`,id:`desktop-app-label`,children:`Desktop app`}),HD.map(({key:e,label:n,hint:r})=>(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`label`,{className:`setting-row`,children:[(0,U.jsx)(`span`,{children:n}),(0,U.jsxs)(`span`,{className:`toggle-switch`,children:[(0,U.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,U.jsx)(`span`,{className:`toggle-track`})]})]}),(0,U.jsx)(`p`,{className:`settings-hint`,id:`desktop-${e}-hint`,children:r})]},e)),r&&(0,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r})]}):null}function WD(){return window.gaiaUpdater}var GD={status:`idle`,version:null,progress:0,releaseNotes:null,error:null,currentVersion:null,pinnedVersion:null,autoUpdate:!1,includePrereleases:!1};function KD(){let[e,t]=(0,V.useState)({...GD});return(0,V.useEffect)(()=>{let e=WD();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 qD(){return window.gaiaUpdater}function JD({onClose:e}){let[t,n]=(0,V.useState)({kind:`loading`}),r=(0,V.useRef)(null);(0,V.useEffect)(()=>{let e=qD();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),Ox(r,!0),(0,V.useEffect)(()=>{let e=r.current;e&&e.querySelector(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)?.focus()},[]),(0,V.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=qD();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,U.jsx)(`div`,{className:`version-picker-overlay`,onClick:t=>{t.target===t.currentTarget&&e()},children:(0,U.jsxs)(`div`,{className:`version-picker-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Install a specific version`,ref:r,children:[(0,U.jsxs)(`div`,{className:`version-picker-header`,children:[(0,U.jsx)(`h3`,{children:`Install a specific version`}),(0,U.jsx)(`button`,{className:`version-picker-close`,onClick:e,"aria-label":`Close`,type:`button`,children:`×`})]}),(0,U.jsxs)(`div`,{className:`version-picker-body`,children:[t.kind===`loading`&&(0,U.jsxs)(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[(0,U.jsx)(`span`,{className:`version-picker-spinner`}),`Loading releases…`]}),t.kind===`error`&&(0,U.jsxs)(`div`,{className:`version-picker-error`,children:[(0,U.jsx)(`p`,{children:t.message}),(0,U.jsx)(`p`,{children:(0,U.jsx)(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:`Browse releases on GitHub`})})]}),t.kind===`list`&&(0,U.jsx)(`ul`,{className:`version-picker-list`,role:`listbox`,"aria-label":`Available releases`,children:t.releases.map(e=>(0,U.jsx)(`li`,{children:(0,U.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,U.jsx)(`span`,{className:`vp-version`,children:e.version}),(0,U.jsx)(`span`,{className:`vp-date`,children:o(e.date)}),e.isCurrent&&(0,U.jsx)(`span`,{className:`vp-badge vp-badge-current`,children:`Installed`}),e.isPinned&&!e.isCurrent&&(0,U.jsx)(`span`,{className:`vp-badge vp-badge-pinned`,children:`Pinned`}),!e.isCurrent&&(0,U.jsx)(`span`,{className:`vp-arrow`,"aria-hidden":`true`,children:`›`})]})},e.tag))}),t.kind===`list`&&(0,U.jsxs)(`p`,{className:`version-picker-more`,children:[`Showing the `,t.releases.length,` most recent.`,` `,(0,U.jsx)(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:`Browse all releases on GitHub`})]}),t.kind===`confirm`&&(0,U.jsxs)(`div`,{className:`version-picker-confirm`,children:[(0,U.jsxs)(`p`,{children:[`This will `,(0,U.jsxs)(`strong`,{children:[`install v`,t.release.version]}),` and restart the app.`]}),(0,U.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,U.jsxs)(`div`,{className:`vp-confirm-actions`,children:[(0,U.jsx)(`button`,{type:`button`,className:`vp-btn-cancel`,onClick:()=>n({kind:`list`,releases:t.releases}),children:`Back`}),(0,U.jsx)(`button`,{type:`button`,className:`vp-btn-confirm`,onClick:()=>a(t.release),children:`Install & restart`})]})]}),t.kind===`installing`&&(0,U.jsxs)(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[(0,U.jsx)(`span`,{className:`version-picker-spinner`}),`Starting download…`]})]})]})})}var YD=`Install updates automatically`,XD=`Include release candidates`;function ZD(e){return/^\d+\.\d+\.\d+-/.test(e??``)}function QD(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 $D(){let e=KD(),t=WD(),[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(null),[o,c]=(0,V.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,U.jsxs)(`div`,{className:`settings-field`,role:`group`,"aria-labelledby":`updates-label`,children:[(0,U.jsx)(`span`,{className:`settings-label`,id:`updates-label`,children:`Updates`}),(0,U.jsxs)(`p`,{className:`settings-hint`,role:`status`,children:[`Running GAIA `,e.currentVersion??`unknown`,`. `,QD(e)]}),(0,U.jsxs)(`label`,{className:`setting-row`,children:[(0,U.jsx)(`span`,{children:YD}),(0,U.jsxs)(`span`,{className:`toggle-switch`,children:[(0,U.jsx)(`input`,{type:`checkbox`,role:`switch`,checked:e.autoUpdate,"aria-describedby":`updates-auto-hint`,"aria-label":YD,"aria-busy":n,disabled:u,onChange:()=>{n||l(`Saving the auto-update setting`,t=>t.setAutoUpdate(!e.autoUpdate))}}),(0,U.jsx)(`span`,{className:`toggle-track`})]})]}),(0,U.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,U.jsxs)(`label`,{className:`setting-row`,children:[(0,U.jsx)(`span`,{children:XD}),(0,U.jsxs)(`span`,{className:`toggle-switch`,children:[(0,U.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,U.jsx)(`span`,{className:`toggle-track`})]})]}),(0,U.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.`,ZD(e.currentVersion)&&` This is a release candidate, so newer ones are offered either way.`]}),e.pinnedVersion&&(0,U.jsxs)(`p`,{className:`settings-hint`,children:[`Pinned to `,e.pinnedVersion,`, so updates are paused.`,` `,(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:n,onClick:()=>void l(`Resuming updates`,e=>e.resumeUpdates()),children:`Unpin`})]}),(0,U.jsxs)(`div`,{className:`setting-actions`,children:[e.status===`available`&&!e.pinnedVersion&&(0,U.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,U.jsx)(`button`,{type:`button`,className:`btn-primary`,disabled:n,onClick:()=>void l(`Restarting to install`,e=>e.restart()),children:`Restart to install`}),(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:d||u,onClick:()=>void l(`Checking for updates`,e=>e.check()),children:`Check for updates`}),(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:d||u,onClick:()=>c(!0),children:`Install a specific version…`})]}),e.configError&&(0,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:e.configError}),i&&(0,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:i}),o&&(0,U.jsx)(JD,{onClose:()=>c(!1)})]})}var eO=[{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`system`,label:`Match system`}],tO=[[`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 nO(){let e=H(e=>e.themePreference),t=H(e=>e.setThemePreference),n=H(e=>e.palette),r=H(e=>e.setPalette),i=H(e=>e.customColors),a=H(e=>e.setCustomColors),o=e=>t=>a({...i,[e]:t.target.value.toUpperCase()});return(0,U.jsxs)(`div`,{className:`settings-pane`,children:[(0,U.jsx)(`h2`,{className:`settings-pane-title`,children:`General`}),(0,U.jsxs)(`div`,{className:`settings-field`,children:[(0,U.jsx)(`span`,{className:`settings-label`,id:`appearance-label`,children:`Appearance`}),(0,U.jsx)(`div`,{className:`segmented`,role:`radiogroup`,"aria-labelledby":`appearance-label`,children:eO.map(n=>(0,U.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,U.jsx)(UD,{}),(0,U.jsx)($D,{}),(0,U.jsxs)(`div`,{className:`settings-field`,children:[(0,U.jsx)(`span`,{className:`settings-label`,id:`palette-label`,children:`Colors`}),(0,U.jsxs)(`div`,{className:`palette-grid`,role:`radiogroup`,"aria-labelledby":`palette-label`,children:[or.map(e=>(0,U.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,U.jsx)(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:e.swatch.map(e=>(0,U.jsx)(`i`,{style:{background:e}},e))}),e.name]},e.id)),(0,U.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":n===`custom`,className:`palette-tile${n===`custom`?` is-active`:``}`,onClick:()=>r(`custom`),children:[(0,U.jsxs)(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:[(0,U.jsx)(`i`,{style:{background:i.base}}),(0,U.jsx)(`i`,{style:{background:i.accent}})]}),`Custom`]})]}),n===`custom`&&(0,U.jsxs)(`div`,{className:`palette-custom`,children:[(0,U.jsxs)(`label`,{className:`palette-color`,htmlFor:`custom-accent`,children:[(0,U.jsx)(`input`,{id:`custom-accent`,type:`color`,value:i.accent,onChange:o(`accent`)}),(0,U.jsxs)(`span`,{children:[`Accent`,(0,U.jsx)(`small`,{children:`Buttons, links and focus`})]})]}),(0,U.jsxs)(`label`,{className:`palette-color`,htmlFor:`custom-base`,children:[(0,U.jsx)(`input`,{id:`custom-base`,type:`color`,value:i.base,onChange:o(`base`)}),(0,U.jsxs)(`span`,{children:[`Background tint`,(0,U.jsx)(`small`,{children:`The color the grays lean toward`})]})]}),(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>a(cr),children:`Reset`}),(0,U.jsx)(`p`,{className:`settings-hint`,children:`Text colors adjust on their own so everything stays readable in light and dark.`})]})]}),(0,U.jsxs)(`div`,{className:`settings-field`,children:[(0,U.jsx)(`span`,{className:`settings-label`,children:`Keyboard shortcuts`}),(0,U.jsx)(`dl`,{className:`shortcut-list`,children:tO.map(([e,t])=>(0,U.jsxs)(`div`,{className:`shortcut-row`,children:[(0,U.jsx)(`dt`,{children:(0,U.jsx)(`kbd`,{children:wc(e)})}),(0,U.jsx)(`dd`,{children:t})]},e))})]})]})}var rO=`auto`;function iO({model:e}){let[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(null);(0,V.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,V.useCallback)(async t=>{o(!0),i(null),c(null);try{let r=await Ta(e,t===rO?null:Number(t));n(r);let i=r.chosen?Os(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,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r});if(!t)return(0,U.jsxs)(`p`,{className:`settings-hint`,children:[(0,U.jsx)(B,{size:13,className:`spin`}),` Checking context sizes…`]});let u=t.chosen==null?rO:String(t.chosen),d=t.chosen!=null&&t.loaded_ctx!=null&&t.loaded_ctx!==t.chosen;return(0,U.jsxs)(`div`,{className:`settings-field`,children:[(0,U.jsx)(`label`,{className:`settings-label`,htmlFor:`ctx-size`,children:`Context size`}),(0,U.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,U.jsxs)(`option`,{value:rO,children:[`Automatic`,t.automatic?` (${Os(t.automatic)})`:``]}),t.options.map(e=>(0,U.jsxs)(`option`,{value:String(e),children:[Os(e),` tokens`]},e))]}),(0,U.jsxs)(`span`,{className:`settings-hint`,children:[t.note??(t.max_fit?`Up to ${Os(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 ${Os(t.loaded_ctx)}.`]}),a&&(0,U.jsxs)(`span`,{className:`settings-hint`,children:[(0,U.jsx)(B,{size:13,className:`spin`}),` Applying…`]}),s&&(0,U.jsx)(`p`,{className:`settings-ok`,role:`status`,children:s}),r&&(0,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r})]})}function aO({onAdded:e}){let[t,n]=(0,V.useState)(``),[r,i]=(0,V.useState)(``),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(null),d=(0,V.useRef)(``),f=(0,V.useCallback)(async e=>{let n=t.trim();d.current=n,c(`check`),u(null);try{let t=await ka(n,e);if(d.current!==n)return;o(t),i(t.file??e)}catch(e){if(d.current!==n)return;o(null),u(e instanceof Error?e.message:String(e))}finally{c(null)}},[t]),p=(0,V.useCallback)(async()=>{c(`add`),u(null);try{let{report:a}=await Aa(t.trim(),r);n(``),i(``),o(null),e(a.display_name??a.model_id??`The model`)}catch(e){u(e instanceof Error?e.message:String(e))}finally{c(null)}},[e,r,t]);return(0,U.jsxs)(`form`,{className:`settings-field custom-model-add`,onSubmit:e=>{e.preventDefault(),f(``)},children:[(0,U.jsx)(`label`,{className:`settings-label`,htmlFor:`custom-model-url`,children:`Add a model from Hugging Face`}),(0,U.jsx)(`span`,{className:`settings-hint`,children:`Paste the link to a GGUF model. GAIA checks that it is a chat model your model server can run and that it fits this PC before adding it. It downloads when you choose Download.`}),(0,U.jsxs)(`div`,{className:`settings-row`,children:[(0,U.jsx)(`input`,{id:`custom-model-url`,className:`settings-input`,type:`url`,inputMode:`url`,spellCheck:!1,autoComplete:`off`,value:t,readOnly:s!==null,onChange:e=>{n(e.target.value),o(null),i(``),d.current=``},placeholder:`https://huggingface.co/unsloth/Qwen3-4B-Instruct-2507-GGUF`}),(0,U.jsxs)(`button`,{type:`submit`,className:`btn-secondary`,disabled:s!==null||!t.trim(),children:[s===`check`?(0,U.jsx)(B,{size:13,className:`spin`}):null,` Check`]})]}),a&&(()=>{let e=(0,U.jsx)(`ul`,{className:`custom-model-checks`,"aria-label":`Checks`,children:a.checks.map(e=>(0,U.jsxs)(`li`,{className:e.ok?`is-ok`:`is-failed`,children:[e.ok?(0,U.jsx)(te,{size:13,"aria-label":`Passed`}):(0,U.jsx)(Bn,{size:13,"aria-label":`Failed`}),(0,U.jsxs)(`span`,{children:[(0,U.jsx)(`strong`,{children:e.label}),` — `,e.detail]})]},e.id))});return a.ok?(0,U.jsxs)(`details`,{className:`custom-model-checks-summary`,children:[(0,U.jsxs)(`summary`,{children:[(0,U.jsx)(te,{size:13,"aria-hidden":`true`}),` All `,a.checks.length,` checks passed`]}),e]}):e})(),a&&a.warnings.length>0&&(0,U.jsx)(`ul`,{className:`custom-model-checks`,"aria-label":`Warnings`,children:a.warnings.map(e=>(0,U.jsxs)(`li`,{className:`is-warning`,children:[(0,U.jsx)(An,{size:13,"aria-label":`Warning`}),` `,(0,U.jsx)(`span`,{children:e})]},e))}),a&&a.variants.length>1&&(0,U.jsxs)(`div`,{className:`settings-row`,children:[(0,U.jsx)(`label`,{className:`settings-hint`,htmlFor:`custom-model-quant`,children:`Quantization`}),(0,U.jsx)(`select`,{id:`custom-model-quant`,className:`settings-input`,value:r,onChange:e=>void f(e.target.value),disabled:s!==null,children:a.variants.map(e=>(0,U.jsxs)(`option`,{value:e.file,children:[e.quant,` · `,e.size_gb,` GB`,e.fits?``:` · too large for this PC`]},e.file))})]}),a?.ok&&(0,U.jsxs)(`div`,{className:`settings-row`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void p(),disabled:s!==null,children:[s===`add`?(0,U.jsx)(B,{size:13,className:`spin`}):null,` Add `,a.display_name]}),(0,U.jsxs)(`span`,{className:`settings-hint`,children:[a.size_gb,` GB download`]})]}),l&&(0,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:l})]})}function oO(){let[e,t]=(0,V.useState)(null),[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(``),[o,s]=(0,V.useState)(!1),c=(0,V.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,V.useEffect)(()=>{c(Na)},[c]),!e)return n?(0,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:n}):(0,U.jsxs)(`p`,{className:`settings-hint`,children:[(0,U.jsx)(B,{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,U.jsxs)(`section`,{className:`settings-field spending`,"aria-label":`Cloud spending`,children:[(0,U.jsx)(`span`,{className:`settings-label`,children:`Cloud spending this month`}),(0,U.jsxs)(`p`,{className:`spending-total`,children:[(0,U.jsx)(`strong`,{children:TC(e.total_usd)}),l!=null&&(0,U.jsxs)(U.Fragment,{children:[` of your `,TC(l),` limit`]}),(0,U.jsxs)(`span`,{className:`settings-hint`,children:[` · `,e.turns,` cloud `,e.turns===1?`chat turn`:`chat turns`,`, at list price`]})]}),e.unpriced_turns>0&&(0,U.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,U.jsxs)(`p`,{className:`spending-warning`,role:`status`,children:[(0,U.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,U.jsxs)(`div`,{className:`spending-warning`,role:`alert`,children:[(0,U.jsxs)(`p`,{children:[(0,U.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,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:o,onClick:()=>void c(Fa),children:`Allow more this month`})]}),e.state===`allowed_over`&&(0,U.jsx)(`p`,{className:`settings-hint`,children:`Over your limit; you allowed more for this month.`}),(0,U.jsxs)(`form`,{className:`settings-row`,onSubmit:e=>{e.preventDefault(),d&&f&&c(()=>Pa(u))},children:[(0,U.jsx)(`label`,{className:`spending-limit-label`,htmlFor:`spend-limit`,children:`Monthly limit ($)`}),(0,U.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,U.jsxs)(`button`,{type:`submit`,className:`btn-secondary`,disabled:o||!d||!f,children:[o?(0,U.jsx)(B,{size:13,className:`spin`}):null,` Save`]}),l!=null&&(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:o,onClick:()=>void c(()=>Pa(null)),children:`Remove limit`})]}),(0,U.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,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:n})]})}var sO=2e3;function cO(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 lO(e){return e.key_source===`environment`?`Blank uses the environment key`:e.key_source?`Blank keeps the saved key`:`Paste API key`}function uO(){let e=ps(e=>e.active),t=ps(e=>e.select),n=ps(e=>e.refresh),r=ps(e=>e.rememberNames),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(null),c=H(e=>e.settingsProvider),[l,u]=(0,V.useState)(c??e?.provider??`local`),[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(``),[_,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(``),[x,S]=(0,V.useState)({base_url:``,auth_header_name:``,auth_header_prefix:``}),[C,w]=(0,V.useState)(null),[T,E]=(0,V.useState)(null),[D,O]=(0,V.useState)(null),[k,A]=(0,V.useState)(null),ee=(0,V.useRef)(l);ee.current=l;let j=(0,V.useRef)(!0);(0,V.useEffect)(()=>()=>{j.current=!1},[]);let M=i?.find(e=>e.id===l)??null,N=e=>e?.network?.reachable===!1,P=!!M&&(!M.remote||!!M.models_discovered),ne=(0,V.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))}},[]),re=(0,V.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,V.useEffect)(()=>{ne()},[ne]);let ie=!!i?.some(e=>e.key_state===`waiting_for_os_permission`);(0,V.useEffect)(()=>{if(!ie)return;let e=setInterval(()=>{ne()},sO);return()=>clearInterval(e)},[ie,ne]);let F=e?.provider;(0,V.useEffect)(()=>{F&&!c&&u(F)},[F,c]),(0,V.useEffect)(()=>{b(``),O(null),g(``),v(!1)},[l]),(0,V.useEffect)(()=>{P?re(l):f(null)},[l,P,re]);let ae=(0,V.useCallback)(async()=>{if(M){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=()=>!j.current||ee.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 ne()}catch(e){j.current&&ee.current===l&&O({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{j.current&&w(null)}}},[x,l,y,ne,M]),oe=(0,V.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 ne(),await n()}catch(e){O({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{w(null)}},[l,ne,n]),se=(0,V.useCallback)(async e=>{w(e),O(null);try{await t(e),O({ok:!0,text:`New messages use ${gs(e)}. It is remembered across restarts.`})}catch(e){O({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{w(null)}},[t]),ce=(0,V.useCallback)(async e=>{w(`dl:${e}`),O(null);try{await ra(e),await re(`local`,!0)}catch(e){O({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{w(null)}},[re]),le=(0,V.useCallback)(async e=>{w(`rm:${e}`),O(null);try{let t=await ja(e);A(null);let r=t.cleared.includes(`last_model`)?` New messages use your default model.`:t.cleared.includes(`default_model`)?` It was your default model, so GAIA's own default takes its place.`:``;O({ok:!0,text:`Removed ${t.display_name} and its download.${r}`}),await re(`local`,!0),await n()}catch(e){O({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{w(null)}},[re,n]),ue=(0,V.useCallback)(async e=>{O({ok:!0,text:`Added ${e}. Choose Download to fetch it, then Use.`}),await re(`local`,!0)},[re]),de=!!d?.some(As);(0,V.useEffect)(()=>{if(l!==`local`||!de)return;let e=setInterval(()=>{re(`local`,!0)},sO);return()=>clearInterval(e)},[de,l,re]);let fe=(0,V.useMemo)(()=>{let e=h.trim().toLowerCase();return(d??[]).filter(t=>!e||t.id.toLowerCase().includes(e)||(t.display_name??``).toLowerCase().includes(e))},[d,h]),I=fe.filter(e=>e.available!==!1),pe=l===`fireworks`&&!_&&!h.trim()&&I.some(e=>e.rank!==null),L=t=>t.rank!==null||t.id===e?.model,R=pe?I.filter(L):I,me=pe?I.filter(e=>!L(e)):[],he=fe.filter(e=>e.available===!1),ge=ws(d??[]),ve=e&&!e.remote&&e.model?e.model:null,z=t=>{let n=hs(e?.model,t.id),r=As(t)?t.download_progress:null,i=[Ds(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,U.jsxs)(`li`,{className:`model-row${n?` is-current`:``}`,children:[(0,U.jsxs)(`div`,{className:`model-row-text`,children:[(0,U.jsxs)(`span`,{className:`model-row-name`,title:t.id,children:[ge[t.id],t.rank&&(0,U.jsxs)(`span`,{className:`model-row-rank`,children:[`#`,t.rank,` `,t.note]}),t.state===`loaded`&&(0,U.jsx)(`span`,{className:`model-badge is-loaded`,children:Es.loaded}),t.fits===!0&&t.available!==!1&&(0,U.jsx)(`span`,{className:`model-badge is-fit`,children:`Fits this PC`}),t.custom&&(0,U.jsx)(`span`,{className:`model-badge is-custom`,children:`Added by you`})]}),M?.remote&&(0,U.jsx)(`span`,{className:`model-row-meta${t.price?``:` is-unknown-price`}`,children:wC(t.price)}),t.display_name&&(0,U.jsx)(`span`,{className:`model-row-meta`,children:t.id}),i&&(0,U.jsx)(`span`,{className:`model-row-meta`,children:i}),t.placement?.warning&&(0,U.jsx)(`span`,{className:`model-row-meta is-warning`,role:`alert`,children:t.placement.warning}),t.unavailable_reason&&(0,U.jsxs)(`span`,{className:`model-row-meta`,children:[`Can't run here: `,t.unavailable_reason]}),t.evidence&&(0,U.jsxs)(`span`,{className:`model-row-meta`,children:[`Measured: `,t.evidence]}),r&&(0,U.jsx)(`progress`,{max:100,value:r.percent,"aria-label":`Downloading ${ge[t.id]}`}),t.custom&&t.source_url&&(0,U.jsxs)(`span`,{className:`model-row-meta`,children:[`From `,t.source_url]})]}),t.custom&&!n&&!r&&(k===t.id?(0,U.jsxs)(`span`,{className:`model-row-confirm`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`btn-danger`,onClick:()=>void le(t.id),disabled:C!==null,children:[C===`rm:${t.id}`?(0,U.jsx)(B,{size:13,className:`spin`}):null,t.downloaded?`Remove and delete download`:`Remove`]}),(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>A(null),disabled:C!==null,children:`Keep`})]}):(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>A(t.id),disabled:C!==null,"aria-label":`Remove ${ge[t.id]}`,children:`Remove`})),n?(0,U.jsxs)(`span`,{className:`model-row-current`,children:[(0,U.jsx)(te,{size:13,"aria-hidden":`true`}),` In use`]}):t.available===!1?null:r?(0,U.jsxs)(`span`,{className:`model-row-current`,children:[(0,U.jsx)(B,{size:13,className:`spin`}),` `,Math.round(r.percent),`%`]}):t.downloaded?(0,U.jsxs)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void se(t.id),disabled:C!==null,"aria-label":`Use ${ge[t.id]}`,children:[C===t.id?(0,U.jsx)(B,{size:13,className:`spin`}):null,` Use`]}):(0,U.jsxs)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void ce(t.id),disabled:C!==null,"aria-label":`Download ${ge[t.id]}`,children:[C===`dl:${t.id}`?(0,U.jsx)(B,{size:13,className:`spin`}):null,` Download`]})]},t.id)};return(0,U.jsxs)(`div`,{className:`settings-pane`,children:[(0,U.jsx)(`h2`,{className:`settings-pane-title`,children:`Model`}),(0,U.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,U.jsx)(`div`,{className:`provider-tabs`,role:`radiogroup`,"aria-label":`Where GAIA runs`,children:(i??[{id:`local`,name:`Local`,remote:!1}]).map(e=>(0,U.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":l===e.id,className:`provider-tab${l===e.id?` is-active`:``}${N(e)?` is-disabled`:``}`,onClick:()=>u(e.id),disabled:N(e)&&l!==e.id,title:N(e)?e.network?.detail??void 0:void 0,children:[e.remote?(0,U.jsx)(_e,{size:14,"aria-hidden":`true`}):(0,U.jsx)(we,{size:14,"aria-hidden":`true`}),(0,U.jsx)(`span`,{children:e.name}),e.remote&&e.models_discovered&&(0,U.jsx)(`span`,{className:`provider-tab-dot`,"aria-label":`connected`})]},e.id))}),o&&(0,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:o}),M&&(0,U.jsxs)(`section`,{className:`settings-card`,"aria-label":M.name,children:[(0,U.jsx)(`p`,{className:`settings-note`,children:M.privacy_notice}),M.id===`local`&&(0,U.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}.`]}),M.remote&&!P&&(0,U.jsxs)(`div`,{className:`settings-field`,children:[(0,U.jsx)(`span`,{className:`settings-label`,children:`Prices`}),(0,U.jsx)(SD,{provider:M.id})]}),N(M)&&(0,U.jsxs)(`div`,{className:`settings-field`,children:[(0,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:M.network?.detail}),(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void ne(),children:`Check again`})]}),M.remote&&!N(M)&&(0,U.jsxs)(`form`,{className:`settings-field`,onSubmit:e=>{e.preventDefault(),ae()},children:[(0,U.jsx)(`span`,{className:`settings-label`,children:`API key`}),(0,U.jsx)(`span`,{className:`settings-hint`,children:cO(M)}),M.id===`amd`&&(0,U.jsxs)(`div`,{className:`settings-grid`,children:[(0,U.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,U.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,U.jsxs)(`div`,{className:`settings-row`,children:[(0,U.jsx)(`input`,{className:`settings-input`,type:`password`,autoComplete:`off`,spellCheck:!1,value:y,onChange:e=>b(e.target.value),placeholder:lO(M),"aria-label":`${M.name} API key`}),(0,U.jsxs)(`button`,{type:`submit`,className:`btn-primary`,disabled:C!==null||!y&&!M.key_source,children:[C===`connect`?(0,U.jsx)(B,{size:13,className:`spin`}):null,M.models_discovered?`Reconnect`:`Connect`]}),(M.key_source===`lemonade`||M.key_source===`stored`)&&(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void oe(),disabled:C!==null,children:`Forget key`})]}),M.error&&(0,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:M.error})]}),D&&(0,U.jsx)(`p`,{className:D.ok?`settings-ok`:`settings-error`,role:D.ok?`status`:`alert`,children:D.text}),M.id===`local`&&ve&&e?.downloaded!==!1&&(0,U.jsx)(iO,{model:ve}),P&&(0,U.jsxs)(`div`,{className:`settings-field`,children:[(0,U.jsx)(`span`,{className:`settings-label`,children:`Models`}),(d?.length??0)>6&&(0,U.jsx)(`input`,{className:`settings-input`,type:`search`,value:h,onChange:e=>g(e.target.value),placeholder:`Search models`,"aria-label":`Search models`}),p&&(0,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:p}),!d&&!p&&(0,U.jsxs)(`p`,{className:`settings-hint`,children:[(0,U.jsx)(B,{size:13,className:`spin`}),` Loading…`]}),d&&fe.length===0&&(0,U.jsx)(`p`,{className:`settings-hint`,children:`No models match.`}),(0,U.jsx)(`ul`,{className:`model-list`,children:R.map(z)}),pe&&me.length>0&&(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>v(!0),children:`Show all models`}),l===`fireworks`&&_&&!h.trim()&&(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>v(!1),children:`Show recommended models`}),he.length>0&&(0,U.jsxs)(`details`,{className:`model-unavailable`,children:[(0,U.jsxs)(`summary`,{children:[`Not available on this PC (`,he.length,`)`]}),(0,U.jsx)(`ul`,{className:`model-list`,children:he.map(z)})]})]}),M.id===`local`&&P&&(0,U.jsx)(aO,{onAdded:e=>void ue(e)}),M.remote&&(0,U.jsx)(oO,{})]})]})}function dO(){let e=H(e=>e.sessions),[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(null),a=(0,V.useCallback)(async()=>{i(null);try{n((await Fi()).sessions)}catch(e){i(e instanceof Error?e.message:String(e))}},[]);(0,V.useEffect)(()=>{a()},[a]);let o=(0,V.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,U.jsxs)(`div`,{className:`settings-pane`,children:[(0,U.jsx)(`h2`,{className:`settings-pane-title`,children:`Permissions`}),(0,U.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,U.jsxs)(`p`,{className:`settings-hint`,children:[`New chats start in full access only when `,(0,U.jsx)(`code`,{children:`full_access`}),` is set in`,(0,U.jsx)(`code`,{children:` ~/.gaia/config.json`}),` (the TUI’s `,(0,U.jsx)(`code`,{children:`/full-access always`}),`).`]}),r&&(0,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r}),t&&t.length===0&&(0,U.jsx)(`p`,{className:`settings-hint`,children:`No chat has full access or anything allowed without asking.`}),t?.map(e=>(0,U.jsxs)(`section`,{className:`settings-card`,"aria-label":s(e.session_id),children:[(0,U.jsxs)(`div`,{className:`settings-row settings-row-between`,children:[(0,U.jsx)(`span`,{className:`settings-label`,children:s(e.session_id)}),e.mode===`full_access`&&(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>o(async()=>{let t=(await Ii(e.session_id,`ask`)).mode;GC(e.session_id,t)}),children:`Turn off full access`})]}),e.grants.length>0&&(0,U.jsx)(`ul`,{className:`grant-list`,children:e.grants.map(t=>(0,U.jsxs)(`li`,{className:`grant-row`,children:[(0,U.jsx)(`code`,{children:t.label}),(0,U.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,U.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>o(()=>Li(e.session_id)),children:`Revoke all in this chat`})]},e.session_id))]})}var fO=[{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 pO({onUseSkill:e}){let[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)({}),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(``);(0,V.useEffect)(()=>{let e=!1;return Ia().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,U.jsxs)(`li`,{className:`skill-row`,children:[(0,U.jsxs)(`div`,{className:`skill-row-text`,children:[(0,U.jsxs)(`span`,{className:`skill-row-name`,children:[t.name,t.version&&(0,U.jsxs)(`span`,{className:`skill-row-meta`,children:[` v`,t.version]}),t.always_on&&(0,U.jsx)(`span`,{className:`skill-row-meta`,children:` · Always on`})]}),(0,U.jsx)(`span`,{className:`skill-row-desc`,children:t.description})]}),!t.always_on&&(0,U.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,U.jsxs)(`div`,{className:`settings-pane`,children:[(0,U.jsx)(`h2`,{className:`settings-pane-title`,children:`Skills`}),(0,U.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,U.jsx)(`code`,{children:`~/.gaia/skills`}),`, one folder each with a `,(0,U.jsx)(`code`,{children:`SKILL.md`}),` file.`]}),a&&(0,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:a}),!t&&!a&&(0,U.jsxs)(`p`,{className:`settings-hint`,children:[(0,U.jsx)(B,{size:13,className:`spin`}),` Loading…`]}),t&&t.length>6&&(0,U.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,U.jsx)(`p`,{className:`settings-hint`,children:`No skills are installed.`}),d?fO.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,U.jsxs)(`section`,{className:`skill-group`,"aria-label":e.title,children:[(0,U.jsxs)(`h3`,{className:`skill-group-title`,children:[e.title,` `,(0,U.jsx)(`span`,{className:`skill-row-meta`,children:r})]}),(0,U.jsx)(`p`,{className:`settings-hint`,children:e.note}),n.length===0?(0,U.jsx)(`p`,{className:`settings-hint`,children:e.empty}):(0,U.jsx)(`ul`,{className:`skill-list`,children:n.map(f)})]},e.source)}):(0,U.jsx)(`ul`,{className:`skill-list`,children:u.map(f)}),Object.keys(r).length>0&&(0,U.jsxs)(`div`,{className:`settings-card`,role:`alert`,children:[(0,U.jsx)(`span`,{className:`settings-label`,children:`Skipped, could not be read`}),(0,U.jsx)(`ul`,{className:`grant-list`,children:Object.entries(r).map(([e,t])=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`code`,{children:e}),` — `,t]},e))})]})]})}function mO(){let e=H(e=>e.setShowMemoryDashboard),t=H(e=>e.closeSettings),[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(!1);(0,V.useEffect)(()=>{ZE().then(r).catch(e=>a(e instanceof Error?e.message:String(e)))},[]);let c=(0,V.useCallback)(async()=>{if(n){s(!0),a(null);try{r(await QE({memory_enabled:!n.memory_enabled}))}catch(e){a(e instanceof Error?e.message:String(e))}finally{s(!1)}}},[n]);return(0,U.jsxs)(`div`,{className:`settings-pane`,children:[(0,U.jsx)(`h2`,{className:`settings-pane-title`,children:`Memory`}),(0,U.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,U.jsxs)(`label`,{className:`setting-row`,children:[(0,U.jsx)(`span`,{children:`Remember across chats`}),(0,U.jsxs)(`span`,{className:`toggle-switch`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:!!n?.memory_enabled,onChange:()=>void c(),disabled:!n||o,"aria-label":`Remember across chats`}),(0,U.jsx)(`span`,{className:`toggle-track`})]})]}),i&&(0,U.jsx)(`p`,{className:`settings-error`,role:`alert`,children:i}),(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{t(),e(!0)},children:`Open the memory dashboard`}),(0,U.jsx)(`p`,{className:`settings-hint`,children:`Search, edit and forget what GAIA remembers.`})]})}var hO=`Keep for: enter a whole number of days from 1 to 365.`,gO=`Use at most: enter a whole number of MB from 10 to 100,000.`;function _O(e,t,n){if(!/^\d+$/.test(e.trim()))return!1;let r=Number(e);return r>=t&&r<=n}function vO(e){return e<1048576?`${Math.ceil(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function yO(){let[e,t]=(0,V.useState)(null),[n,r]=(0,V.useState)(``),[i,a]=(0,V.useState)(``),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(!1);(0,V.useEffect)(()=>{Wo().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,V.useState)({days:!1,mb:!1}),f=!_O(n,1,365)||u.days,p=!_O(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 Go(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,U.jsxs)(`div`,{className:`settings-field`,"aria-label":`Undo history`,children:[(0,U.jsx)(`span`,{className:`settings-label`,children:`Undo history`}),(0,U.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,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`setting-row`,children:[(0,U.jsx)(`label`,{htmlFor:`undo-days`,children:`Keep for (days)`}),(0,U.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,U.jsx)(`p`,{id:`undo-days-error`,className:`settings-error`,children:hO}),(0,U.jsxs)(`div`,{className:`setting-row`,children:[(0,U.jsx)(`label`,{htmlFor:`undo-mb`,children:`Use at most (MB)`}),(0,U.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,U.jsx)(`p`,{id:`undo-mb-error`,className:`settings-error`,children:gO}),(0,U.jsxs)(`div`,{className:`setting-row setting-row-path`,children:[(0,U.jsx)(`span`,{children:`In use`}),(0,U.jsxs)(`span`,{children:[vO(e.used_bytes),` for `,e.turns,` turn`,e.turns===1?``:`s`,` `,`in `,(0,U.jsx)(`code`,{className:`setting-path`,children:e.path})]})]}),(0,U.jsx)(`button`,{type:`button`,className:`btn-model-save`,onClick:()=>void h(),disabled:!m||c||f||p,children:c?`Saving…`:`Save`})]}),o&&(0,U.jsx)(`p`,{className:o.ok?`settings-ok`:`settings-error`,role:o.ok?`status`:`alert`,children:o.text})]})}function bO(){let e=H(e=>e.sessions),t=H(e=>e.removeSession),n=bs(),r=H(e=>e.systemStatus?.data_dir),[i,a]=(0,V.useState)(!1),[o,s]=(0,V.useState)(null),c=(0,V.useRef)(null);(0,V.useEffect)(()=>()=>{c.current&&clearTimeout(c.current)},[]);let l=(0,V.useCallback)(async()=>{if(!i){a(!0),c.current=setTimeout(()=>a(!1),4e3);return}a(!1);let n=[];for(let r of e)try{await Ba(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,U.jsxs)(`div`,{className:`settings-pane`,children:[(0,U.jsx)(`h2`,{className:`settings-pane-title`,children:`Privacy`}),(0,U.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,U.jsxs)(`div`,{className:`setting-row`,children:[(0,U.jsx)(`span`,{children:`Data folder`}),(0,U.jsx)(`code`,{className:`setting-path`,children:r})]}),(0,U.jsx)(yO,{}),(0,U.jsx)(`div`,{className:`danger-divider`}),(0,U.jsx)(`p`,{className:`danger-warning`,children:`Deletes every chat and its messages. Documents and memory are kept.`}),(0,U.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,U.jsx)(`p`,{className:o.ok?`settings-ok`:`settings-error`,role:o.ok?`status`:`alert`,children:o.text})]})}var xO=[{id:`needs_approval`,label:`Needs your approval`},{id:`question`,label:`Has a question`},{id:`finished`,label:`Finished`}],SO=[{value:`banner`,label:`Banner`},{value:`badge`,label:`Badge`},{value:`off`,label:`Off`}],CO=[0,10,20,30,50];function wO(){return typeof Notification>`u`?`unsupported`:Notification.permission}function TO(){let e=ic(),t=!!window.gaiaAPI,[n,r]=(0,V.useState)(wO),i=Object.values(e.modes).includes(`banner`);return(0,U.jsxs)(`div`,{className:`settings-pane`,children:[(0,U.jsx)(`h2`,{className:`settings-pane-title`,children:`Notifications`}),(0,U.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.`}),xO.map(t=>(0,U.jsxs)(`div`,{className:`setting-row`,children:[(0,U.jsx)(`span`,{id:`alert-${t.id}`,children:t.label}),(0,U.jsx)(`div`,{className:`segmented`,role:`radiogroup`,"aria-labelledby":`alert-${t.id}`,children:SO.map(n=>(0,U.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,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{Notification.requestPermission().then(r).catch(e=>{console.error(`[alerts] Notification permission request failed`,e),r(wO())})},children:`Allow banners in this browser`}):(0,U.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,U.jsxs)(`label`,{className:`setting-row`,children:[(0,U.jsx)(`span`,{children:`Play a sound`}),(0,U.jsxs)(`span`,{className:`toggle-switch`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:e.sound,onChange:()=>e.update({sound:!e.sound}),"aria-label":`Play a sound`}),(0,U.jsx)(`span`,{className:`toggle-track`})]})]}),t&&(0,U.jsxs)(`label`,{className:`setting-row`,children:[(0,U.jsx)(`span`,{children:`Flash the taskbar when GAIA isn't focused`}),(0,U.jsxs)(`span`,{className:`toggle-switch`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:e.flash,onChange:()=>e.update({flash:!e.flash}),"aria-label":`Flash the taskbar when GAIA isn't focused`}),(0,U.jsx)(`span`,{className:`toggle-track`})]})]}),(0,U.jsx)(`h3`,{className:`settings-label`,children:`Keep awake`}),t?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`label`,{className:`setting-row`,children:[(0,U.jsx)(`span`,{children:`Keep the PC awake while GAIA works`}),(0,U.jsxs)(`span`,{className:`toggle-switch`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:e.keepAwake,onChange:()=>e.update({keepAwake:!e.keepAwake}),"aria-label":`Keep the PC awake while GAIA works`}),(0,U.jsx)(`span`,{className:`toggle-track`})]})]}),(0,U.jsxs)(`div`,{className:`setting-row`,children:[(0,U.jsx)(`label`,{htmlFor:`battery-floor`,children:`On battery, let it sleep below`}),(0,U.jsx)(`select`,{id:`battery-floor`,value:e.batteryFloor,disabled:!e.keepAwake,onChange:t=>e.update({batteryFloor:Number(t.target.value)}),children:CO.map(e=>(0,U.jsx)(`option`,{value:e,children:e===0?`Never`:`${e}%`},e))})]}),(0,U.jsx)(`p`,{className:`settings-hint`,children:`The screen can still turn off; only sleep is held off.`})]}):(0,U.jsx)(`p`,{className:`settings-hint`,children:`Keep-awake needs the GAIA desktop app.`})]})}var EO=`modulepreload`,DO=function(e,t){return new URL(e,t).href},OO={},kO=function(e){return e.pathname.endsWith(`.css`)},AO=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},jO=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=DO(t,n);let r=s(t),i=kO(r);return AO(OO,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`:EO,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)})},MO=(0,V.lazy)(()=>jO(()=>import(`./ConnectorsPane-s0fFxmus.js`).then(e=>({default:e.ConnectorsPane})),__vite__mapDeps([0,1,2,3]),import.meta.url)),NO=(0,V.lazy)(()=>jO(()=>import(`./AdvancedSettings-DERzP9Jc.js`).then(e=>({default:e.AdvancedSettings})),__vite__mapDeps([4,1,2]),import.meta.url)),PO=[{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 FO({onUseSkill:e}){let t=H(e=>e.settingsSection),n=H(e=>e.openSettings),r=H(e=>e.closeSettings),i=(0,V.useRef)(null),a=(0,V.useRef)(null),o=t!==null;if(ei(o,r),Ox(i,o),(0,V.useEffect)(()=>{if(o)return a.current=document.activeElement,()=>{a.current?.focus?.()}},[o,r]),(0,V.useEffect)(()=>{o&&i.current?.querySelector(`.settings-nav-item.is-active`)?.focus()},[o]),!t)return null;let s=(()=>{switch(t){case`general`:return(0,U.jsx)(nO,{});case`model`:return(0,U.jsx)(uO,{});case`permissions`:return(0,U.jsx)(dO,{});case`skills`:return(0,U.jsx)(pO,{onUseSkill:t=>{r(),e(t)}});case`connectors`:return(0,U.jsx)(MO,{});case`memory`:return(0,U.jsx)(mO,{});case`notifications`:return(0,U.jsx)(TO,{});case`privacy`:return(0,U.jsx)(bO,{});case`advanced`:return(0,U.jsx)(NO,{})}})();return(0,U.jsx)(`div`,{className:`settings-overlay`,onMouseDown:e=>{e.target===e.currentTarget&&r()},children:(0,U.jsxs)(`div`,{ref:i,className:`settings-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Settings`,children:[(0,U.jsxs)(`nav`,{className:`settings-nav`,"aria-label":`Settings sections`,children:[(0,U.jsx)(`h1`,{className:`settings-nav-title`,children:`Settings`}),PO.map(e=>(0,U.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,U.jsxs)(`div`,{className:`settings-body`,children:[(0,U.jsx)(`button`,{type:`button`,className:`settings-close`,onClick:r,"aria-label":`Close settings`,children:(0,U.jsx)(Bn,{size:18})}),(0,U.jsx)(V.Suspense,{fallback:(0,U.jsxs)(`p`,{className:`settings-hint`,children:[(0,U.jsx)(B,{size:13,className:`spin`}),` Loading…`]}),children:s})]})]})})}function IO(e,t){let[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(!1),o=(0,V.useRef)(null),c=(0,V.useRef)(null),l=(0,V.useRef)(null),u=(0,V.useCallback)(()=>{o.current&&=(clearTimeout(o.current),null),c.current&&=(clearTimeout(c.current),null),l.current&&=(clearInterval(l.current),null)},[]);(0,V.useEffect)(()=>u,[u]);let d=(0,V.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{}},Mc)},[]),f=e??`Gemma-4-E4B-it-GGUF`;return{isLoadingModel:n,isDownloadingModel:i,loadModel:(0,V.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),Ac),d(n,`load`)}catch(e){s.system.error(`Failed to trigger model load`,e),r(!1)}},[f,t,d]),downloadModel:(0,V.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),jc),d(n,`download`)}catch(e){s.system.error(`Failed to trigger model download`,e),a(!1)}},[f,d])}}var LO=5e3,RO=2e3,zO=3e4,BO=6e4;function VO(e){return e.lemonade_running?`up`:e.lemonade_error?`unresponsive`:`down`}function HO(e){return e.kind===`slow`||e.kind===`error`||e.kind===`ok`&&VO(e.status)===`unresponsive`}function UO(e){let t=e.kind===`ok`?e.status.download_progress?.state:void 0;return t===`downloading`||t===`starting`}function WO(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(),BO);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=HO(t)?n+1:0,r=UO(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?RO:LO)*2**n,zO),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 GO({onRetry:e,label:t}){let[n,r]=(0,V.useState)(!1);return(0,U.jsx)(`button`,{className:`connection-banner__retry`,onClick:()=>{r(!0),Promise.resolve(e()).finally(()=>r(!1))},disabled:n,children:n?`Checking…`:t})}function KO({onRetry:e,backendSlow:t=!1,backendError:n=null}){let{backendConnected:r,systemStatus:i,currentSessionId:a,messages:o}=H(),[s,c]=(0,V.useState)(!1),l=!!a&&o.length>0,u=i?.default_model_name??`Gemma-4-E4B-it-GGUF`,{isDownloadingModel:d,downloadModel:f}=IO(u),p=(0,V.useRef)(i?.lemonade_running),m=(0,V.useRef)(i?.model_downloaded),h=(0,V.useRef)(i?.context_size_sufficient),g=(0,V.useRef)(i?.expected_model_loaded);(0,V.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,U.jsxs)(`div`,{className:`connection-banner ${t?`connection-banner--error`:`connection-banner--warning`}`,role:t?`alert`:`status`,children:[(0,U.jsx)(`div`,{className:`connection-banner__icon`,children:t?(0,U.jsx)(An,{size:16}):(0,U.jsx)(Oe,{size:16})}),(0,U.jsx)(`div`,{className:`connection-banner__text`,children:t?(0,U.jsxs)(U.Fragment,{children:[`Download of `,(0,U.jsx)(`strong`,{children:v}),` failed.`,` `,_?.message&&(0,U.jsx)(`span`,{className:`connection-banner__hint`,children:_.message})]}):(0,U.jsxs)(U.Fragment,{children:[`Downloading `,(0,U.jsx)(`strong`,{children:v}),` (`,e,`).`,_?.state===`downloading`&&_.file&&(0,U.jsxs)(U.Fragment,{children:[` `,(0,U.jsxs)(`span`,{className:`connection-banner__hint`,children:[`File `,_.file_index,` / `,_.total_files,`: `,(0,U.jsx)(`code`,{children:_.file})]})]})]})}),t?(0,U.jsx)(`button`,{className:`connection-banner__retry`,onClick:()=>f(!1,v),children:`Retry`}):(0,U.jsx)(`span`,{className:`connection-banner__loading connection-banner__progress`,children:_&&_.state===`downloading`&&_.total_bytes>0?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`connection-banner__progress-bar`,role:`progressbar`,"aria-valuenow":_.percent,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`Download progress`,children:(0,U.jsx)(`span`,{className:`connection-banner__progress-fill`,style:{width:`${_.percent}%`}})}),(0,U.jsxs)(`span`,{className:`connection-banner__progress-label`,children:[_.percent,`% ·`,` `,(_.downloaded_bytes/1e9).toFixed(2),` /`,` `,(_.total_bytes/1e9).toFixed(2),` GB`]})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(B,{size:13,className:`connection-banner__spinner`}),_?.state===`starting`?`Starting download…`:`Downloading…`]})}),t&&(0,U.jsx)(`button`,{className:`connection-banner__dismiss`,onClick:()=>c(!0),"aria-label":`Dismiss`,children:(0,U.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,U.jsxs)(`div`,{className:`connection-banner connection-banner--init`,role:`status`,children:[(0,U.jsx)(`div`,{className:`connection-banner__icon`,children:(0,U.jsx)(B,{size:16,className:`connection-banner__spinner`})}),(0,U.jsxs)(`div`,{className:`connection-banner__text`,children:[e,(0,U.jsxs)(`span`,{className:`thinking-dots`,children:[(0,U.jsx)(`span`,{children:`.`}),(0,U.jsx)(`span`,{children:`.`}),(0,U.jsx)(`span`,{children:`.`})]})]})]})}if(s||l)return null;if(!r)return(0,U.jsxs)(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[(0,U.jsx)(`div`,{className:`connection-banner__icon`,children:(0,U.jsx)(In,{size:16})}),(0,U.jsxs)(`div`,{className:`connection-banner__text`,children:[`Lost the connection to GAIA.`,` `,(0,U.jsx)(`span`,{className:`connection-banner__hint`,children:`Check that GAIA is still running, then retry.`})]}),e&&(0,U.jsx)(GO,{onRetry:e,label:`Retry`})]});if(n)return(0,U.jsxs)(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[(0,U.jsx)(`div`,{className:`connection-banner__icon`,children:(0,U.jsx)(An,{size:16})}),(0,U.jsxs)(`div`,{className:`connection-banner__text`,children:[`GAIA's backend answered with an error (`,n,`).`,` `,(0,U.jsx)(`span`,{className:`connection-banner__hint`,children:`It may be overloaded. GAIA keeps checking; if it lasts, restart GAIA.`})]}),e&&(0,U.jsx)(GO,{onRetry:e,label:`Check again`})]});if(t)return(0,U.jsxs)(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[(0,U.jsx)(`div`,{className:`connection-banner__icon`,children:(0,U.jsx)(An,{size:16})}),(0,U.jsxs)(`div`,{className:`connection-banner__text`,children:[`GAIA is slow to answer.`,` `,(0,U.jsx)(`span`,{className:`connection-banner__hint`,children:`It may be busy with another chat or app. GAIA keeps checking.`})]}),e&&(0,U.jsx)(GO,{onRetry:e,label:`Check again`})]});if(i?.config_error)return(0,U.jsxs)(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[(0,U.jsx)(`div`,{className:`connection-banner__icon`,children:(0,U.jsx)(An,{size:16})}),(0,U.jsxs)(`div`,{className:`connection-banner__text`,children:[`GAIA settings could not be loaded.`,` `,(0,U.jsx)(`span`,{className:`connection-banner__hint`,children:i.config_error})]}),e&&(0,U.jsx)(GO,{onRetry:e,label:`Check again`})]});if(i&&!i.lemonade_running){let t=VO(i)===`unresponsive`;return(0,U.jsxs)(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[(0,U.jsx)(`div`,{className:`connection-banner__icon`,children:(0,U.jsx)(An,{size:16})}),(0,U.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,U.jsxs)(`span`,{className:`connection-banner__hint`,children:[t?`If it stays this way, restart it: `:`To start it by hand, run `,(0,U.jsx)(`code`,{children:i.start_command})]}):i.start_instruction&&(0,U.jsx)(`span`,{className:`connection-banner__hint`,children:i.start_instruction})]}),e&&(0,U.jsx)(GO,{onRetry:e,label:`Check again`}),(0,U.jsx)(`button`,{className:`connection-banner__dismiss`,onClick:()=>c(!0),"aria-label":`Dismiss`,children:(0,U.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,U.jsxs)(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[(0,U.jsx)(`div`,{className:`connection-banner__icon`,children:(0,U.jsx)(vt,{size:16})}),(0,U.jsxs)(`div`,{className:`connection-banner__text`,children:[`LLM context window is too small (`,t.toLocaleString(),` tokens;`,` `,Oc.toLocaleString(),` required).`,` `,(0,U.jsx)(`span`,{className:`connection-banner__hint`,children:`Reload it with a larger context in Settings → Advanced.`})]}),e&&(0,U.jsx)(GO,{onRetry:e,label:`Check again`}),(0,U.jsx)(`button`,{className:`connection-banner__dismiss`,onClick:()=>c(!0),"aria-label":`Dismiss`,children:(0,U.jsx)(Bn,{size:14})})]})}return null}function qO(){let e=KD(),[t,n]=(0,V.useState)(!1),[r,i]=(0,V.useState)(null),a=(0,V.useCallback)(e=>{let t=WD();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,U.jsxs)(`div`,{className:`update-chip update-chip--downloading`,role:`status`,"aria-live":`polite`,title:`Downloading update${e.version?` ${e.version}`:``}…`,children:[(0,U.jsx)(Oe,{size:13,className:`update-chip__icon`}),(0,U.jsxs)(`span`,{className:`update-chip__label`,children:[`Downloading update… `,t,`%`]})]})}return e.status===`available`?(0,U.jsxs)(`div`,{className:`update-chip update-chip--available`,role:`status`,title:r||e.releaseNotes||`A new version is available.`,children:[(0,U.jsx)(Oe,{size:13,className:`update-chip__icon`}),(0,U.jsx)(`span`,{className:`update-chip__label`,children:r?`Update failed — try again`:`GAIA ${e.version??``} is available`}),!e.pinnedVersion&&(0,U.jsx)(`button`,{type:`button`,className:`update-chip__action`,onClick:()=>a(`downloadUpdate`),children:`Update now`}),(0,U.jsx)(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>n(!0),"aria-label":`Dismiss update notification`,children:(0,U.jsx)(Bn,{size:11})})]}):e.status===`downloaded`?(0,U.jsxs)(`div`,{className:`update-chip update-chip--ready`,role:`status`,"aria-live":`polite`,children:[(0,U.jsx)(tn,{size:13,className:`update-chip__icon`}),(0,U.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,U.jsxs)(`div`,{className:`update-chip update-chip--error`,role:`status`,title:e.error||`Update check failed.`,children:[(0,U.jsx)(An,{size:13,className:`update-chip__icon`}),(0,U.jsx)(`span`,{className:`update-chip__label`,children:`Update check failed`}),(0,U.jsx)(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>n(!0),"aria-label":`Dismiss update error`,children:(0,U.jsx)(Bn,{size:11})})]}):null}var JO={permission_request:{icon:(0,U.jsx)(un,{size:16}),colorClass:`notif-type-permission`,label:`Permission`},policy_alert:{icon:(0,U.jsx)(un,{size:16}),colorClass:`notif-type-policy`,label:`Policy`},security_alert:{icon:(0,U.jsx)(An,{size:16}),colorClass:`notif-type-security`,label:`Security`},status_change:{icon:(0,U.jsx)(ue,{size:16}),colorClass:`notif-type-status`,label:`Status`},info:{icon:(0,U.jsx)(mt,{size:16}),colorClass:`notif-type-info`,label:`Info`},error:{icon:(0,U.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 XO({onClose:e}){let t=qs(qn(Ys)),n=qs(Js),r=qs(e=>e.markRead),i=qs(e=>e.markAllRead),a=qs(e=>e.clearAll),o=qs(e=>e.dismiss),s=qs(e=>e.respondToPermission),c=qs(e=>e.typeFilter),l=qs(e=>e.setTypeFilter),u=(0,V.useCallback)(e=>{r(e)},[r]),d=(0,V.useCallback)(e=>{s(e.id,`allow`).catch(e=>console.error(`[NotificationCenter] allow failed:`,e))},[s]),f=(0,V.useCallback)(e=>{s(e.id,`deny`).catch(e=>console.error(`[NotificationCenter] deny failed:`,e))},[s]);return ei(!0,e),(0,U.jsxs)(`div`,{className:`notification-center`,role:`dialog`,"aria-label":`Notification Center`,children:[(0,U.jsxs)(`div`,{className:`notification-center-header`,children:[(0,U.jsxs)(`div`,{className:`notification-center-title-row`,children:[(0,U.jsx)(`h2`,{className:`notification-center-title`,children:`Notifications`}),n>0&&(0,U.jsx)(`span`,{className:`notification-center-badge`,children:n})]}),(0,U.jsx)(`button`,{className:`btn-icon notification-center-close`,onClick:e,"aria-label":`Close notification center`,children:(0,U.jsx)(Bn,{size:18})})]}),(0,U.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,U.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,U.jsx)(`div`,{className:`notification-list`,children:t.length===0?(0,U.jsxs)(`div`,{className:`notification-empty`,children:[(0,U.jsx)(w,{size:40,strokeWidth:1.2}),(0,U.jsx)(`span`,{children:`No notifications`})]}):t.map(e=>{let t=JO[e.type];return(0,U.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,U.jsx)(`span`,{className:`notification-unread-dot`}),(0,U.jsx)(`span`,{className:`notification-icon`,children:t.icon}),(0,U.jsxs)(`div`,{className:`notification-content`,children:[(0,U.jsxs)(`div`,{className:`notification-content-header`,children:[(0,U.jsx)(`span`,{className:`notification-agent`,children:e.agentName}),(0,U.jsx)(`span`,{className:`notification-time`,children:YO(e.timestamp)})]}),e.title&&(0,U.jsx)(`span`,{className:`notification-title`,children:e.title}),(0,U.jsx)(`span`,{className:`notification-message`,children:e.message}),e.type===`permission_request`&&e.tool&&e.tool!==`allow_path_access`&&(0,U.jsxs)(`span`,{className:`notification-tool`,children:[`Tool: `,(0,U.jsx)(`code`,{children:e.tool})]}),e.type===`policy_alert`&&(0,U.jsxs)(`div`,{className:`notification-policy-details`,children:[e.tool&&(0,U.jsxs)(`span`,{className:`notification-tool`,children:[`Tool: `,(0,U.jsx)(`code`,{children:e.tool})]}),e.reason&&(0,U.jsxs)(`span`,{className:`notification-policy-reason`,children:[`Reason: `,e.reason]}),e.ruleIds&&e.ruleIds.length>0&&(0,U.jsxs)(`span`,{className:`notification-tool`,children:[`Rules: `,(0,U.jsx)(`code`,{children:e.ruleIds.join(`, `)})]}),e.policyVersion&&(0,U.jsxs)(`span`,{className:`notification-tool`,children:[`Policy: `,(0,U.jsx)(`code`,{children:e.policyVersion})]}),(0,U.jsxs)(`span`,{className:`notification-tool`,children:[`Receipt:`,` `,e.receiptId?(0,U.jsx)(`code`,{children:e.receiptId}):(0,U.jsx)(`em`,{children:`Receipt unavailable`})]})]}),e.type===`permission_request`&&!e.response&&(0,U.jsxs)(`div`,{className:`notification-actions`,children:[(0,U.jsxs)(`button`,{className:`notification-action-btn notification-action-allow`,onClick:t=>{t.stopPropagation(),d(e)},children:[(0,U.jsx)(te,{size:14}),`Approve`]}),(0,U.jsxs)(`button`,{className:`notification-action-btn notification-action-deny`,onClick:t=>{t.stopPropagation(),f(e)},children:[(0,U.jsx)(Bn,{size:14}),`Deny`]})]}),e.type===`permission_request`&&e.response&&(0,U.jsx)(`span`,{className:`notification-response-badge ${e.response===`allow`?`response-allow`:`response-deny`}`,children:e.response===`allow`?`Approved`:`Denied`})]}),(0,U.jsx)(`button`,{className:`notification-dismiss`,onClick:t=>{t.stopPropagation(),o(e.id)},"aria-label":`Dismiss notification`,children:(0,U.jsx)(Bn,{size:14})})]},e.id)})}),t.length>0&&(0,U.jsxs)(`div`,{className:`notification-center-footer`,children:[(0,U.jsxs)(`button`,{className:`notification-footer-btn`,onClick:i,disabled:n===0,children:[(0,U.jsx)(te,{size:14}),`Mark All Read`]}),(0,U.jsxs)(`button`,{className:`notification-footer-btn notification-footer-clear`,onClick:a,children:[(0,U.jsx)(On,{size:14}),`Clear`]})]})]})}var ZO=1500,QO=e=>new Promise(t=>setTimeout(t,e));async function $O({onProgress:e,isCancelled:t=()=>!1,pollMs:n=ZO}={}){try{await aa(ZT)}catch(e){if(e?.httpStatus!==409)throw e;let t=await oa(ZT).catch(()=>null);if(!t||t.status===`completed`||t.status===`failed`)throw e}for(;!t();){let t=await oa(ZT);if(e?.(t),t.status===`completed`)return;if(t.status===`failed`)throw Error(t.error||`The GAIA agent could not be installed.`);await QO(n)}}function ek({onInstalled:e}){let[t,n]=(0,V.useState)({kind:`idle`}),r=(0,V.useRef)(!1);(0,V.useEffect)(()=>()=>{r.current=!0},[]);let i=(0,V.useCallback)(async()=>{n({kind:`installing`,percent:0});try{if(await $O({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,U.jsxs)(`div`,{className:`app-notice is-warning`,role:`status`,children:[t.kind===`installing`?(0,U.jsxs)(`span`,{children:[`Installing the GAIA agent… `,Math.round(t.percent),`%`]}):t.kind===`failed`?(0,U.jsxs)(`span`,{children:[`The GAIA agent could not be installed: `,t.error]}):(0,U.jsx)(`span`,{children:`The GAIA agent isn't installed, so new chats can't start yet.`}),t.kind!==`installing`&&(0,U.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>void i(),children:t.kind===`failed`?`Try again`:`Install GAIA agent`})]})}function tk(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 nk(e,t){let{addNotification:n}=qs.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 rk=$n((e,t)=>({schedules:[],loading:!1,error:null,actionError: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 Po()).schedules||[],r=t().errorCounts;r&&nk(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 Io(t,n,r);e(e=>({schedules:[...e.schedules,i],actionError:null}))}catch(e){throw s.api.error(`Failed to create schedule`,e),e}},updateScheduleStatus:async(t,n)=>{try{let r=await Lo(t,n);e(e=>({schedules:e.schedules.map(e=>e.name===t?r:e),actionError:null}))}catch(n){s.api.error(`Failed to update schedule "${t}"`,n),e({actionError:tk(n,`Failed to update schedule`)})}},runScheduleNow:async t=>{try{let n=await K(t);e(e=>({schedules:e.schedules.map(e=>e.name===t?n:e),actionError:null}))}catch(n){s.api.error(`Failed to run schedule "${t}" now`,n),e({actionError:tk(n,`Could not run the schedule now`)})}},deleteSchedule:async t=>{try{await Ro(t),e(e=>({schedules:e.schedules.filter(e=>e.name!==t),selectedSchedule:e.selectedSchedule===t?null:e.selectedSchedule,actionError:null}))}catch(n){s.api.error(`Failed to delete schedule "${t}"`,n),e({actionError:tk(n,`Failed to delete schedule`)})}},selectSchedule:n=>{e({selectedSchedule:n,results:[],resultsLoading:!1}),n&&t().loadResults(n)},loadResults:async n=>{e({resultsLoading:!0});try{let r=await zo(n);if(t().selectedSchedule!==n)return;e({results:r.results||[],resultsLoading:!1})}catch(r){if(s.api.error(`Failed to load results for "${n}"`,r),t().selectedSchedule!==n)return;e({results:[],resultsLoading:!1})}},dismissActionError:()=>e({actionError:null})})),ik=new Set([`loading_model`,`downloading_model`,`model_retry`,`waiting`]),ak=5;function ok(e,t){return{id:e,title:t.get(e)?.title??`Untitled chat`}}function sk(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=>({...ok(e,t),reason:`approval`}));n&&e.awaitingUser&&!a.has(e.currentSessionId)&&o.push({...ok(e.currentSessionId,t),reason:`answer`});for(let[n,r]of Object.entries(e.awaitingBySession))o.some(e=>e.id===n)||o.push({...ok(n,t),reason:r===`question`?`answer`:`approval`});let s=n&&!e.awaitingUser&&e.livePhase&&ik.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,ak).map(e=>ok(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=>ok(e,t)),needsYou:o,recent:u}}function ck(e){let t=(0,V.useRef)(e);t.current=e,(0,V.useEffect)(()=>{let e=window.gaiaAPI?.tray;if(!e)return;let n=``,r=null,i=()=>{let t=H.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:qs.getState().notifications},a=r;if(r=i,a&&Object.keys(i).every(e=>i[e]===a[e]))return;let o=sk(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=H.subscribe(i),o=qs.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`:H.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 lk(){(0,V.useEffect)(()=>{let e=window.gaiaAPI;if(!e)return;let t=qs.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=H.getState();n.currentSessionId!==t&&n.setMessages([]),n.setCurrentSession(t)})];return()=>n.forEach(e=>e())},[])}function uk(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(),H.getState().setCurrentSession(e)}}function dk(){let[e,t]=(0,V.useState)(null);return(0,V.useEffect)(()=>{let e=navigator;if(!e.getBattery)return;let n=null,r=()=>{n&&t({charging:n.charging,level:n.level})};return e.getBattery().then(e=>{n=e,r(),e.addEventListener(`levelchange`,r),e.addEventListener(`chargingchange`,r)}).catch(e=>s.system.warn(`Battery level unavailable; keep-awake ignores the battery policy.`,e)),()=>{n?.removeEventListener(`levelchange`,r),n?.removeEventListener(`chargingchange`,r)}},[]),e}function fk(){lk();let e=H(e=>e.runningSessionIds),t=H(e=>e.awaitingBySession),n=H(e=>e.sessions),r=H(e=>e.currentSessionId),i=qs(qn(Zs)),a=ic(),o=dk(),c=(0,V.useRef)(null),l=dc(e,t,i),u=JSON.stringify(l);(0,V.useEffect)(()=>{let e=JSON.parse(u),t=c.current;if(c.current=e,t===null)return;let{sessions:n,currentSessionId:r}=H.getState(),i=document.hasFocus(),o=!1;for(let{sessionId:c,event:l}of fc(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`||hc(c,r,i))&&(o=!0,t===`banner`)){if(l!==`finished`){let{title:t,body:n}=mc(l,e);uk(c,t,n)}else Va(c).then(e=>{H.getState().updateSessionInList(c,e);let{title:t,body:n}=mc(l,e);uk(c,t,n)}).catch(t=>{s.system.error(`Could not read how chat ${c} ended`,t);let{title:n,body:r}=mc(l,{...e,last_run_status:null});uk(c,n,r)})}}if(o){if(a.sound)try{vc()}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=gc(n,l,a.modes,r);(0,V.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&&_c(o,a.batteryFloor);(0,V.useEffect)(()=>{window.gaiaAPI?.power.setKeepAwake(f).catch(e=>s.system.error(`Could not change keep-awake`,e))},[f])}function pk(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 mk(e){return e.replace(/-/g,``).slice(0,7)}function hk(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 gk(e,t,n){return!e||t&&(e===t||e===mk(t))?null:n.some(t=>t.id===e)?e:hk(n,e)}function _k(e){return new URLSearchParams(e.search).get(`session`)||e.hash.replace(/^#/,``)||null}var vk=`gaia:last-session`;function yk(e){try{e?localStorage.setItem(vk,e):localStorage.removeItem(vk)}catch(e){s.ui.warn(`Could not save the open chat for the next launch`,e)}}function bk(){try{return localStorage.getItem(vk)}catch(e){return s.ui.warn(`Could not read the chat open at last launch`,e),null}}var xk=1e3,Sk=3e4;function Ck(e,{initialMs:t=xk,maxMs:n=Sk,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 wk=(0,V.lazy)(()=>jO(()=>import(`./MemoryDashboard-CP5wVWkY.js`).then(e=>({default:e.MemoryDashboard})),__vite__mapDeps([5,1,2,6,7]),import.meta.url)),Tk=(0,V.lazy)(()=>jO(()=>import(`./ScheduleManager-b0gTAf2R.js`).then(e=>({default:e.ScheduleManager})),__vite__mapDeps([8,1,2,6,9]),import.meta.url)),Ek=(0,V.lazy)(()=>jO(()=>import(`./DocumentLibrary-DqapN_Tr.js`).then(e=>({default:e.DocumentLibrary})),__vite__mapDeps([10,1,2,11]),import.meta.url)),Dk=(0,V.lazy)(()=>jO(()=>import(`./FileBrowser-vAJV41RT.js`).then(e=>({default:e.FileBrowser})),__vite__mapDeps([12,1,2,13]),import.meta.url)),Ok=(0,V.lazy)(()=>jO(()=>import(`./MobileAccessModal-B31mPs50.js`).then(e=>({default:e.MobileAccessModal})),__vite__mapDeps([14,1,2,15]),import.meta.url)),kk=3,Ak=3e5,jk=6e3,Mk=6e4,Nk=e=>e instanceof TypeError,Pk=e=>new Promise(t=>setTimeout(t,e));function Fk(){return(0,U.jsx)(`div`,{className:`loading-spinner`,role:`status`,"aria-label":`Loading`})}var Ik=e=>e===1||e%10==0;function Lk(){let e=H(e=>e.currentSessionId),t=H(e=>e.setSessions),n=H(e=>e.setCurrentSession),r=H(e=>e.addSession),a=H(e=>e.setMessages),o=H(e=>e.showDocLibrary),l=H(e=>e.showFileBrowser),u=H(e=>e.showMemoryDashboard),d=H(e=>e.showSchedules),f=H(e=>e.sidebarOpen),p=H(e=>e.setSidebarOpen),m=H(e=>e.setSystemStatus),h=H(e=>e.setBackendConnected),g=H(e=>e.setAgents),_=H(e=>e.agents),v=H(e=>e.setPendingPrompt),y=H(e=>e.setDefaultPermissionMode),b=H(e=>e.openSettings),x=H(e=>e.settingsSection),S=H(e=>e.syncSystemTheme),C=ps(e=>e.restoreNotice),w=ps(e=>e.dismissRestoreNotice),T=qs(e=>e.showPanel),E=H(e=>e.systemStatus?.initialized===!0),D=qs(e=>e.setShowPanel);(0,V.useEffect)(()=>{if(!C?.ok)return;let e=setTimeout(w,jk);return()=>clearTimeout(e)},[C,w]);let[O,k]=(0,V.useState)({state:`checking`}),A=(0,V.useRef)(O);A.current=O;let[ee,j]=(0,V.useState)(!1),M=(0,V.useRef)(ee);M.current=ee;let[N,P]=(0,V.useState)(!1),te=N||ee&&!QT(_),ne=(0,V.useRef)(te);ne.current=te;let[re,ie]=(0,V.useState)(null),[F,ae]=(0,V.useState)(``),[oe,se]=(0,V.useState)(0),[ce,le]=(0,V.useState)(!1),[ue,de]=(0,V.useState)(!1),[fe,I]=(0,V.useState)(null),pe=(0,V.useRef)(async()=>{}),L=(0,V.useRef)(async()=>{}),R=(0,V.useCallback)(async(e=!1,t=!1)=>{e||k({state:`checking`});let n=0;try{for(;;){await ps.getState().refresh();let e=ps.getState().active,r;try{r=await ca(!!e?.remote)}catch(e){if(!t||!Nk(e)||n>=Mk)throw e;await Pk(xk),n+=xk;continue}n>0&&await Promise.all([pe.current(),L.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})}},[]),me=(0,V.useRef)(0),he=(0,V.useCallback)(async()=>{let e=++me.current,t=(await ia()).agents||[];e===me.current&&(g(t),j(!0),QT(t)&&P(!1))},[g]),ge=(0,V.useCallback)(()=>{let e=M.current;j(!1),he().catch(t=>{s.api.warn(`Agent list unavailable after setup`,t),e&&j(!0)})},[he]);(0,V.useEffect)(()=>{let e=()=>{ne.current&&he().catch(e=>s.api.warn(`Agent list unavailable`,e))};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[he]);let _e=(0,V.useCallback)(async()=>{y((await Fi()).default_mode)},[y]),ve=(0,V.useRef)([]);(0,V.useEffect)(()=>{i(`0.25.3`),R(!1,!0);let e=[Ck(he,{onError:(e,t)=>{Ik(t)&&s.api.warn(`Agent list unavailable (attempt ${t}); retrying`,e)}}),Ck(_e,{onError:(e,t)=>{Ik(t)&&s.api.warn(`Default permission mode unavailable (attempt ${t}); retrying`,e)}})];return ve.current=e,()=>e.forEach(e=>e.stop())},[R,he,_e]);let z=(0,V.useCallback)(()=>{ve.current.forEach(e=>e.kick()),ps.getState().retryNow(),L.current(),A.current.state===`unknown`&&R(!0)},[R]),ye=(0,V.useRef)(z);ye.current=z;let be=(0,V.useRef)(0),xe=(0,V.useRef)(0),Se=(0,V.useRef)(null),Ce=(0,V.useRef)(!1),[we,Te]=(0,V.useState)(!1),[Ee,De]=(0,V.useState)(null),Oe=(0,V.useCallback)(e=>{if(e.kind===`unreachable`){s.system.warn(`System status check failed`,e.error),Ce.current=!0,xe.current=0,Se.current=null,Te(!1),De(null),h(!1),m(null);return}if(e.kind===`error`){s.system.warn(`System status answered HTTP ${e.httpStatus}`,e.message),Ce.current&&ye.current(),Ce.current=!1,xe.current=0,Se.current=null,Te(!1),De(`HTTP ${e.httpStatus}: ${e.message}`),h(!0);return}if(e.kind===`slow`){if(xe.current+=1,Se.current??=Date.now(),De(null),s.system.warn(`System status did not answer in time (${xe.current} in a row)`),Date.now()-Se.current>=Ak){Te(!1),h(!1),m(null);return}h(!0),(Ce.current||xe.current>=kk)&&Te(!0);return}let{status:t}=e;Ce.current&&ye.current(),Ce.current=!1,xe.current=0,Se.current=null,Te(!1),De(null),h(!0),be.current=t.lemonade_running?0:be.current+1;let n=H.getState().systemStatus;t.lemonade_running||be.current>=kk||!n?.lemonade_running?m(t):m({...n,download_progress:t.download_progress})},[h,m]),ke=(0,V.useRef)(Oe);ke.current=Oe;let[Ae]=(0,V.useState)(()=>WO(e=>ke.current(e))),je=Ae.check;pe.current=je,(0,V.useEffect)(()=>rE(Ae.start),[Ae]);let Me=(0,V.useRef)(``);(0,V.useEffect)(()=>{let e=e=>La().then(n=>{let r=n.sessions||[];if(!e&&r.length===0&&H.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===Me.current)return;Me.current=i,t(r);let a=ps.getState().active?.model;a&&r.some(e=>e.effective_model&&e.effective_model!==a)&&ps.getState().refresh()}).catch(t=>{e&&s.system.error(`Could not load chats`,t)});L.current=()=>e(!1),e(!0);let n=setInterval(()=>void e(!1),5e3);return()=>clearInterval(n)},[t]),(0,V.useEffect)(()=>PS(),[]),(0,V.useEffect)(()=>{let e=()=>{rk.getState().loadSchedules()};e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[]),(0,V.useEffect)(()=>tC(),[]),fk();let Ne=(0,V.useRef)(!1),Pe=(0,V.useRef)(!1);(0,V.useEffect)(()=>{let e=()=>{let e=_k(window.location),{currentSessionId:t,sessions:r}=H.getState(),i=gk(e,t,r);return i&&(n(i),a([])),i},t=()=>{if(Ne.current||(Ne.current=!0,e()||H.getState().currentSessionId))return;if(window.location.hash){window.history.replaceState(null,``,window.location.pathname+window.location.search);return}if(Pe.current||oi(`new-chat`))return;let{sessions:t}=H.getState(),r=gk(bk(),null,t);r&&(n(r),a([]))},r=H.subscribe(e=>{e.sessions.length>0&&t()});return H.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,V.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!==H.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,V.useEffect)(()=>{if(Ne.current&&yk(e),e){let t=mk(e);window.location.hash!==`#${t}`&&window.history.replaceState(null,``,`#${t}`)}else Ne.current&&window.location.hash&&window.history.replaceState(null,``,window.location.pathname+window.location.search)},[e]);let Fe=(0,V.useCallback)(async e=>{ie(null);let t=H.getState(),i;try{i=await Ra({title:`New Task`,agent_type:ZT,document_ids:t.draftDocumentIds,private:t.draftPrivate,folders:t.draftFolder?[t.draftFolder]:[]})}catch(e){throw $T(e)?(P(!0),Error(`The GAIA agent isn't installed. Install it from the notice above, then send again.`)):e}ne.current&&(P(!1),he().catch(e=>s.api.warn(`Agent list unavailable`,e))),t.defaultPermissionModeKnown||(await _e().catch(e=>s.api.warn(`Default permission mode unavailable; using the chip's mode`,e)),t=H.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,he,_e]),Ie=(0,V.useCallback)(()=>{let e=H.getState(),t=e.currentSessionId;t&&Ec(t,e)&&Dc(t),e.setShowMemoryDashboard(!1),e.setShowSchedules(!1),Pe.current=!0,n(null),a([]),se(e=>e+1)},[n,a]);ck({openChat:(0,V.useCallback)(e=>{let t=H.getState();t.closeSettings(),e!==t.currentSessionId&&(Dc(t.currentSessionId),a([])),n(e)},[n,a]),newChat:(0,V.useCallback)(()=>{H.getState().closeSettings(),Ie()},[Ie]),refreshStatus:()=>void je()});let Le=(0,V.useCallback)(e=>{Ie(),Fe(`Load the \`${e}\` skill, then tell me briefly what it lets you do.`).catch(e=>ie(e instanceof Error?e.message:String(e)))},[Ie,Fe]),Re=(0,V.useCallback)(e=>{k({state:`ready`}),ge(),je(),e&&(e.needs_input?ae(e.prompt):Fe(e.prompt).catch(e=>ie(e instanceof Error?e.message:String(e))))},[je,Fe,ge]);(0,V.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&(e.shiftKey&&e.key.toLowerCase()===`o`?(e.preventDefault(),Ie()):!e.shiftKey&&e.key.toLowerCase()===`k`?(e.preventDefault(),window.dispatchEvent(new CustomEvent(`gaia:focus-search`))):!e.shiftKey&&e.key.toLowerCase()===`b`?(e.preventDefault(),H.getState().toggleSidebarCollapsed()):!e.shiftKey&&e.key===`,`&&(e.preventDefault(),b()))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Ie,b]),(0,V.useEffect)(()=>{let e=window.matchMedia?.(`(max-width: 768px)`);if(!e)return;let t=()=>p(!e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[p]),(0,V.useEffect)(()=>{if(typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(prefers-color-scheme: light)`);return e.addEventListener(`change`,S),()=>e.removeEventListener(`change`,S)},[S]),(0,V.useEffect)(()=>{Mo().then(e=>de(e.active===!0)).catch(e=>s.system.debug(`Mobile access unavailable`,e))},[]);let ze=(0,V.useCallback)(async()=>{if(le(!0),I(null),!ue)try{let e=await Ao();e.error?I(e.error):de(!0)}catch(e){I(e instanceof Error?e.message:`Could not start mobile access`)}},[ue]),Be=(0,V.useCallback)(async()=>{try{await jo(),de(!1),le(!1)}catch(e){I(e instanceof Error?e.message:`Could not stop mobile access`)}},[]);rT(e=>{e?ze():Be()}),(0,V.useEffect)(()=>{tT(ue)},[ue]);let Ve=typeof window<`u`&&window.innerWidth<=768;if(O.state===`checking`&&!E)return(0,U.jsx)(`div`,{className:`app`,children:(0,U.jsxs)(`main`,{className:`startup`,role:`status`,"aria-label":`Starting GAIA`,children:[(0,U.jsx)(`div`,{className:`loading-spinner`,"aria-hidden":`true`}),(0,U.jsx)(`p`,{className:`startup-text`,children:`Starting GAIA…`})]})});if(O.state===`needed`)return(0,U.jsx)(`div`,{className:`app`,children:(0,U.jsx)(BD,{initial:O.check,onReady:Re})});let He=u?(0,U.jsx)(V.Suspense,{fallback:(0,U.jsx)(Fk,{}),children:(0,U.jsx)(wk,{})}):e?(0,U.jsx)(fE,{sessionId:e},e):(0,U.jsx)(bD,{onSend:Fe,initialText:F,focusRequest:oe},F);return(0,U.jsxs)(`div`,{className:`app`,children:[!f&&(0,U.jsx)(`button`,{className:`sidebar-toggle`,onClick:()=>p(!0),"aria-label":`Open sidebar`,children:(0,U.jsx)(jt,{size:18})}),(0,U.jsx)(`div`,{className:`sidebar-overlay ${f?`visible`:``}`,onClick:()=>p(!1),"aria-hidden":`true`}),(0,U.jsx)($c,{onNewChat:Ie,onMobileAccess:Ve?void 0:()=>void ze(),tunnelActive:ue}),(0,U.jsxs)(`div`,{className:`main-content`,children:[O.state===`ready`&&(0,U.jsx)(KO,{onRetry:je,backendSlow:we,backendError:Ee}),O.state===`unknown`&&(0,U.jsxs)(`div`,{className:`app-notice is-warning`,role:`status`,children:[(0,U.jsxs)(`span`,{children:[`Could not check whether GAIA is set up: `,O.error]}),(0,U.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>void R(),children:`Check again`})]}),te&&(0,U.jsx)(ek,{onInstalled:he}),C&&(0,U.jsxs)(`div`,{className:`app-notice${C.ok?``:` is-warning`}`,role:`status`,children:[(0,U.jsx)(`span`,{children:C.message}),!C.ok&&(0,U.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>{w(),b(`model`)},children:`Pick a model`}),(0,U.jsx)(`button`,{type:`button`,className:`app-notice-close`,onClick:w,"aria-label":`Dismiss`,children:(0,U.jsx)(Bn,{size:14})})]}),He]}),d&&(0,U.jsx)(V.Suspense,{fallback:null,children:(0,U.jsx)(Tk,{})}),o&&(0,U.jsx)(V.Suspense,{fallback:null,children:(0,U.jsx)(Ek,{})}),l&&(0,U.jsx)(V.Suspense,{fallback:null,children:(0,U.jsx)(Dk,{onStartChat:Fe})}),T&&(0,U.jsx)(`div`,{className:`notification-center-popover`,children:(0,U.jsx)(XO,{onClose:()=>D(!1)})}),ce&&(0,U.jsx)(V.Suspense,{fallback:null,children:(0,U.jsx)(Ok,{isOpen:ce,onClose:()=>le(!1),onStop:()=>void Be(),error:fe})}),x&&(0,U.jsx)(FO,{onUseSkill:Le}),(0,U.jsx)(qO,{}),re&&(0,U.jsx)(`div`,{className:`toast`,role:`alert`,children:re})]})}Ls(),ir();var Rk=localStorage.getItem(`gaia-chat-theme`);rr(tr(Rk===`light`||Rk===`dark`?Rk:`system`));var zk=H.getState();xr(zk.palette,zk.customColors,zk.theme),Vn.createRoot(document.getElementById(`root`)).render((0,U.jsx)(V.StrictMode,{children:(0,U.jsx)(Lk,{})}));export{_o as $,Je as $t,qE as A,xi as At,uC as B,An as Bt,AE as C,Ci as Ct,IE as D,ui as Dt,kE as E,hi as Et,KE as F,H as Ft,kc as G,tn as Gt,iC as H,bn as Ht,eD as I,Bn as It,gs as J,Ft as Jt,Oc as K,$t as Kt,aD as L,Rn as Lt,UE as M,li as Mt,GE as N,bi as Nt,BE as O,yi as Ot,WE as P,ei as Pt,go as Q,et as Qt,RE as R,Pn as Rt,jE as S,pi as St,ZE as T,mi as Tt,oC as U,vn as Ut,fC as V,On as Vt,Ox as W,on as Wt,So as X,Et as Xt,bo as Y,B as Yt,vo as Z,St as Zt,NE as _,te as _n,ho as _t,xD as a,Oe as an,Mo as at,FE as b,di as bt,oD as c,be as cn,na as ct,XE as d,fe as dn,ko as dt,Ke as en,ma as et,HE as f,ue as fn,yo as ft,PE as g,re as gn,ea as gt,sD as h,F as hn,$i as ht,jO as i,Ae as in,Yi as it,JE as j,vi as jt,nD as k,_i as kt,$E as l,he as ln,wo as lt,ME as m,oe as mn,ga as mt,rk as n,Ie as nn,Qi as nt,fD as o,Ee as on,Co as ot,rD as p,ce as pn,Oo as pt,xc as q,qt,IO as r,Me as rn,G as rt,iD as s,we as sn,po as st,pk as t,We as tn,No as tt,YE as u,R as un,Bo as ut,zE as v,O as vn,mo as vt,LE as w,gi as wt,tD as x,fi as xt,VE as y,S as yn,Si as yt,QE as z,Mn as zt};
|