@amd-gaia/agent-ui 0.27.0 → 0.27.1-rc.1

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.
Files changed (29) hide show
  1. package/dist/assets/AdvancedSettings-CJxSdclz.js +1 -0
  2. package/dist/assets/AutomationsSettings-DZP1wPWZ.js +1 -0
  3. package/dist/assets/ConnectorsPane-CtN8iyjY.js +1 -0
  4. package/dist/assets/DocumentLibrary-CC2YsO-O.js +5 -0
  5. package/dist/assets/{DocumentLibrary-Ctwq2m2t.css → DocumentLibrary-g7OCGegP.css} +1 -1
  6. package/dist/assets/FileBrowser-BhArokri.js +4 -0
  7. package/dist/assets/MemoryDashboard-gFulbynO.js +1 -0
  8. package/dist/assets/MessagingSettings-BrLW4gLV.js +1 -0
  9. package/dist/assets/MobileAccessModal-QheAv8eE.js +2 -0
  10. package/dist/assets/ScheduleManager-7tRAmOEB.js +1 -0
  11. package/dist/assets/{folderIndexResult-BIoxqF5I.js → folderIndexResult-_fe0ncI2.js} +1 -1
  12. package/dist/assets/index-DCyriNCc.css +1 -0
  13. package/dist/assets/index-DD59wPO3.js +230 -0
  14. package/dist/assets/useFocusTrap-DEJ5balb.js +6 -0
  15. package/dist/index.html +3 -3
  16. package/dist/sw.js +1 -1
  17. package/package.json +1 -1
  18. package/dist/assets/AdvancedSettings-R8_C2uBe.js +0 -1
  19. package/dist/assets/AutomationsSettings-B3zbjgZt.js +0 -1
  20. package/dist/assets/ConnectorsPane-BzcyOZRr.js +0 -1
  21. package/dist/assets/DocumentLibrary-o3Fy8URO.js +0 -5
  22. package/dist/assets/FileBrowser-_6Dx8AKt.js +0 -4
  23. package/dist/assets/MemoryDashboard-ao_en1zm.js +0 -1
  24. package/dist/assets/MessagingSettings-DJq0F5BO.js +0 -1
  25. package/dist/assets/MobileAccessModal-ld0MPTgk.js +0 -2
  26. package/dist/assets/ScheduleManager-px6Ly00O.js +0 -1
  27. package/dist/assets/index-DXyVxzzC.css +0 -1
  28. package/dist/assets/index-Qh2EUbOw.js +0 -226
  29. package/dist/assets/useFocusTrap-Cy_PGcml.js +0 -6
@@ -0,0 +1,230 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ConnectorsPane-CtN8iyjY.js","./rolldown-runtime-XKyaHtl9.js","./useFocusTrap-DEJ5balb.js","./ConnectorsPane-BxG6qzLb.css","./MessagingSettings-BrLW4gLV.js","./AutomationsSettings-DZP1wPWZ.js","./AdvancedSettings-CJxSdclz.js","./MemoryDashboard-gFulbynO.js","./MemoryDashboard-Bfy9g6TS.css","./ScheduleManager-7tRAmOEB.js","./ScheduleManager-CEBoBLPV.css","./DocumentLibrary-CC2YsO-O.js","./folderIndexResult-_fe0ncI2.js","./DocumentLibrary-g7OCGegP.css","./FileBrowser-BhArokri.js","./FileBrowser-DxS29ShT.css","./MobileAccessModal-QheAv8eE.js","./MobileAccessModal-DSFjH6di.css"])))=>i.map(i=>d[i]);
2
+ import{n as e,r as t,t as n}from"./rolldown-runtime-XKyaHtl9.js";import{$ as r,$n as i,$r as a,$t as o,A as s,An as c,At as l,B as u,Bn as d,Br as f,Bt as p,C as m,Ci as h,Cn as g,Cr as _,Ct as v,D as y,Di as b,Dn as x,Dr as S,Dt as C,E as w,Ei as T,En as E,Et as ee,F as D,Fn as O,Ft as te,G as k,Gn as A,Gr as ne,H as j,Hn as M,Ht as re,I as ie,In as ae,It as oe,J as se,Jn as ce,Jr as le,Jt as ue,K as de,Kn as fe,Kr as pe,Kt as me,L as he,Ln as ge,Lt as _e,M as ve,Mn as ye,Mt as be,N as xe,Nn as Se,Nt as Ce,O as we,Oi as N,On as Te,Ot as Ee,P as De,Pn as Oe,Pt as ke,Q as Ae,Qn as je,Qr as Me,Qt as Ne,R as Pe,Rn as Fe,S as Ie,Si as Le,Sr as Re,St as ze,T as Be,Ti as Ve,Tn as He,Tr as Ue,Tt as We,U as Ge,Un as Ke,Ut as qe,V as Je,Vn as Ye,Vt as Xe,W as Ze,Wn as Qe,Wr as $e,Wt as et,X as tt,Xr as nt,Xt as rt,Y as it,Yn as at,Yr as ot,Yt as st,Z as ct,Zn as lt,Zr as ut,Zt as dt,_ as ft,_i as pt,_n as mt,_r as ht,a as gt,ai as _t,ar as vt,at as yt,b as bt,bi as P,bn as xt,br as St,bt as Ct,c as F,ci as wt,cn as Tt,cr as Et,ct as Dt,d as Ot,di as kt,dn as At,dr as jt,dt as Mt,ei as Nt,en as Pt,er as Ft,et as It,f as Lt,fi as Rt,fn as zt,fr as Bt,ft as Vt,g as Ht,gi as Ut,gn as Wt,gr as Gt,gt as Kt,h as qt,hi as Jt,hn as Yt,hr as Xt,ht as Zt,i as Qt,ii as $t,in as en,ir as tn,it as nn,j as rn,jt as an,k as on,ki as sn,kn as cn,kt as ln,l as I,li as un,ln as dn,lr as fn,lt as pn,m as mn,mi as hn,mn as gn,mr as _n,mt as vn,n as yn,ni as bn,nn as xn,nr as Sn,nt as Cn,o as wn,oi as Tn,on as En,or as Dn,ot as On,p as kn,pi as An,pn as jn,pr as Mn,pt as Nn,qn as Pn,qr as Fn,qt as In,r as Ln,ri as Rn,rn as zn,rr as Bn,rt as Vn,s as L,si as Hn,sn as Un,sr as Wn,t as Gn,ti as Kn,tn as qn,tr as Jn,tt as Yn,u as R,ui as Xn,un as Zn,ur as Qn,ut as $n,v as er,vi as tr,vn as nr,vr as rr,vt as ir,w as ar,wi as or,wn as sr,wr as cr,wt as lr,x as z,xi as ur,xn as dr,xr as fr,y as pr,yi as mr,yn as hr,yr as gr,yt as _r,z as vr,zn as yr,zt as br}from"./useFocusTrap-DEJ5balb.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 xr=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,D());else{var t=n(l);t!==null&&k(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function ee(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&k(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?D():S=!1}}}var D;if(typeof y==`function`)D=function(){y(ee)};else if(typeof MessageChannel<`u`){var O=new MessageChannel,te=O.port2;O.port1.onmessage=ee,D=function(){te.postMessage(null)}}else D=function(){_(ee,0)};function k(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,k(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,D()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Sr=n(((e,t)=>{t.exports=xr()})),Cr=n((e=>{var t=sn();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.browser=function(e){return{$$typeof:o,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=u(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=u(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.1`})),wr=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=Cr()})),Tr=n((e=>{var t=Sr(),n=sn(),r=wr();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}function f(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&f(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function p(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function m(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function h(e){var t=[null,null],n=p(e);return n===null||g(t,e,n.child,{foundSelf:!1}),t}function g(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&g(e,t,n.child,r))return!0;n=n.sibling}return!1}function _(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var v=null,y=null;function b(e,t,n){return e===n||e===t&&(v=e,!0)}function x(e,t,n){return e===n?(y=e,!1):e===t&&(y!==null&&(v=e),!0)}function S(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function C(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var w=Object.assign,T=Symbol.for(`react.element`),E=Symbol.for(`react.transitional.element`),ee=Symbol.for(`react.portal`),D=Symbol.for(`react.fragment`),O=Symbol.for(`react.strict_mode`),te=Symbol.for(`react.profiler`),k=Symbol.for(`react.consumer`),A=Symbol.for(`react.context`),ne=Symbol.for(`react.forward_ref`),j=Symbol.for(`react.suspense`),M=Symbol.for(`react.suspense_list`),re=Symbol.for(`react.memo`),ie=Symbol.for(`react.lazy`),ae=Symbol.for(`react.activity`),oe=Symbol.for(`react.legacy_hidden`),se=Symbol.for(`react.memo_cache_sentinel`),ce=Symbol.for(`react.view_transition`),le=Symbol.for(`react.recoverable`),ue=Symbol.iterator;function de(e){return typeof e!=`object`||!e?null:(e=ue&&e[ue]||e[`@@iterator`],typeof e==`function`?e:null)}var fe=Symbol.for(`react.client.reference`);function pe(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===fe?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case D:return`Fragment`;case te:return`Profiler`;case O:return`StrictMode`;case j:return`Suspense`;case M:return`SuspenseList`;case ae:return`Activity`;case ce:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case ee:return`Portal`;case A:return e.displayName||`Context`;case k:return(e._context.displayName||`Context`)+`.Consumer`;case ne:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case re:return t=e.displayName||null,t===null?pe(e.type)||`Memo`:t;case ie:t=e._payload,e=e._init;try{return pe(e(t))}catch{}}return null}var me=Array.isArray,he=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ge=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_e={pending:!1,data:null,method:null,action:null},ve=[],ye=-1;function be(e){return{current:e}}function xe(e){0>ye||(e.current=ve[ye],ve[ye]=null,ye--)}function Se(e,t){ye++,ve[ye]=e.current,e.current=t}var Ce=be(null),we=be(null),N=be(null),Te=be(null);function Ee(e,t){switch(Se(N,t),Se(we,e),Se(Ce,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?xp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=xp(t),e=Sp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}xe(Ce),Se(Ce,e)}function De(){xe(Ce),xe(we),xe(N)}function Oe(e){var t=e.memoizedState;t!==null&&(vh._currentValue=t.memoizedState,Se(Te,e)),t=Ce.current;var n=Sp(t,e.type);t!==n&&(Se(we,e),Se(Ce,n))}function ke(e){we.current===e&&(xe(Ce),xe(we)),Te.current===e&&(xe(Te),vh._currentValue=_e)}var Ae,je;function Me(e){if(Ae===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Ae=t&&t[1]||``,je=-1<e.stack.indexOf(`
3
+ at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
+ `+Ae+e+je}var Ne=!1;function Pe(e,t){if(!e||Ne)return``;Ne=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
5
+ `),l=s.split(`
6
+ `);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
7
+ `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Ne=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Me(n):``}function Fe(e,t){switch(e.tag){case 26:case 27:case 5:return Me(e.type);case 16:return Me(`Lazy`);case 13:return e.child!==t&&t!==null?Me(`Suspense Fallback`):Me(`Suspense`);case 19:return Me(`SuspenseList`);case 0:case 15:return Pe(e.type,!1);case 11:return Pe(e.type.render,!1);case 1:return Pe(e.type,!0);case 31:return Me(`Activity`);case 30:return Me(`ViewTransition`);default:return``}}function Ie(e){try{var t=``,n=null;do t+=Fe(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
8
+ Error generating stack: `+e.message+`
9
+ `+e.stack}}var Le=Object.prototype.hasOwnProperty,Re=t.unstable_scheduleCallback,ze=t.unstable_cancelCallback,Be=t.unstable_shouldYield,Ve=t.unstable_requestPaint,He=t.unstable_now,Ue=t.unstable_getCurrentPriorityLevel,We=t.unstable_ImmediatePriority,Ge=t.unstable_UserBlockingPriority,Ke=t.unstable_NormalPriority,qe=t.unstable_LowPriority,Je=t.unstable_IdlePriority,Ye=t.log,Xe=t.unstable_setDisableYieldValue,Ze=null,Qe=null;function $e(e){if(typeof Ye==`function`&&Xe(e),Qe&&typeof Qe.setStrictMode==`function`)try{Qe.setStrictMode(Ze,e)}catch{}}var et=Math.clz32?Math.clz32:rt,tt=Math.log,nt=Math.LN2;function rt(e){return e>>>=0,e===0?32:31-(tt(e)/nt|0)|0}var it=256,at=262144,ot=4194304;function st(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function ct(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=st(n))):i=st(o):i=st(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=st(n))):i=st(o)):i=st(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function lt(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function ut(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0<n;){var r=31-et(n),i=1<<r;t|=e[r],n&=~i}return t}function dt(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ft(){var e=ot;return ot<<=1,!(ot&62914560)&&(ot=4194304),e}function pt(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function mt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ht(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-et(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&gt(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function gt(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-et(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function _t(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-et(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function vt(e,t){var n=t&-t;return n=n&42?1:yt(n),(n&(e.suspendedLanes|t))===0?n:0}function yt(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function bt(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function P(){var e=ge.p;return e===0?(e=window.event,e===void 0?32:Ph(e.type)):e}function xt(e,t){var n=ge.p;try{return ge.p=e,t()}finally{ge.p=n}}var St=Math.random().toString(36).slice(2),Ct=`__reactFiber$`+St,F=`__reactProps$`+St,wt=`__reactContainer$`+St,Tt=`__reactEvents$`+St,Et=`__reactListeners$`+St,Dt=`__reactHandles$`+St,Ot=`__reactResources$`+St,kt=`__reactMarker$`+St,At=`__reactLoad$`+St;function jt(e){delete e[Ct],delete e[F],delete e[Et],delete e[Dt]}function Mt(e){var t;if(t=e[Ct])return t;for(var n=e.parentNode;n;){if(t=n[wt]||n[Ct]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Cm(e);e!==null;){if(n=e[Ct])return n;e=Cm(e)}return t}e=n,n=e.parentNode}return null}function Nt(e){if(e=e[Ct]||e[wt]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function Pt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function Ft(e){var t=e[Ot];return t||=e[Ot]={hoistableStyles:new Map,hoistableScripts:new Map},t}function It(e){e[kt]=!0}function Lt(e){e[At]=void 0}var Rt=new Set,zt={};function Bt(e,t){Vt(e,t),Vt(e+`Capture`,t)}function Vt(e,t){for(zt[e]=t,e=0;e<t.length;e++)Rt.add(t[e])}var Ht=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),Ut={},Wt={};function Gt(e){return Le.call(Wt,e)?!0:Le.call(Ut,e)?!1:Ht.test(e)?Wt[e]=!0:(Ut[e]=!0,!1)}var Kt=!1;function qt(){var e=Kt;return Kt=!1,e}function Jt(e,t,n){if(Gt(t)){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,n)}}}function Yt(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,n)}}function Xt(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,r)}}function Zt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Qt(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function $t(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function en(e){if(!e._valueTracker){var t=Qt(e)?`checked`:`value`;e._valueTracker=$t(e,t,``+e[t])}}function tn(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Qt(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}var nn=/[\n"\\]/g;function rn(e){return e.replace(nn,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function an(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+Zt(t)):e.value!==``+Zt(t)&&(e.value=``+Zt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):cn(e,Zt(n)):o===`number`&&e.value==t?cn(e,Zt(e.value)):cn(e,Zt(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+Zt(s):e.removeAttribute(`name`)}function on(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){en(e);return}n=n==null?``:``+Zt(n),t=t==null?n:``+Zt(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),en(e)}function cn(e,t){e.defaultValue!==``+t&&(e.defaultValue=``+t)}function ln(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+Zt(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function I(e,t,n){t!=null&&(t=``+Zt(t),t!==e.value&&(e.value=t),n==null)?e.defaultValue!==t&&(e.defaultValue=t):e.defaultValue=n==null?``:``+Zt(n)}function un(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(me(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=Zt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),en(e)}function dn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var fn=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function pn(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||fn.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function mn(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``,Kt=!0);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&(pn(e,a,r),Kt=!0)}else for(var o in t)t.hasOwnProperty(o)&&pn(e,o,t[o])}function hn(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var gn=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`maskType`,`mask-type`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),_n=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function vn(e){return _n.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function yn(){}var bn=null;function xn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Sn=null,Cn=null;function wn(e){var t=Nt(e);if(t&&(e=t.stateNode)){var n=e[F]||null;a:switch(e=t.stateNode,t.type){case`input`:if(an(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+rn(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[F]||null;if(!a)throw Error(i(90));an(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&tn(r)}break a;case`textarea`:I(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&ln(e,!!n.multiple,t,!1)}}}var Tn=!1;function En(e,t,n){if(Tn)return e(t,n);Tn=!0;try{return e(t)}finally{if(Tn=!1,(Sn!==null||Cn!==null)&&(Jd(),Sn&&(t=Sn,e=Cn,Cn=Sn=null,wn(t),e)))for(t=0;t<e.length;t++)wn(e[t])}}function Dn(e,t){var n=e.stateNode;if(n===null)return null;var r=n[F]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=e!==`button`&&e!==`input`&&e!==`select`&&e!==`textarea`),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var On=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,kn=!1;if(On)try{var An={};Object.defineProperty(An,"passive",{get:function(){kn=!0}}),window.addEventListener(`test`,An,An),window.removeEventListener(`test`,An,An)}catch{kn=!1}var jn=null,Mn=null,Nn=null;function Pn(){if(Nn)return Nn;var e,t=Mn,n=t.length,r,i=`value`in jn?jn.value:jn.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return Nn=i.slice(e,1<r?1-r:void 0)}function Fn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function In(){return!0}function Ln(){return!1}function Rn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?In:Ln,this.isPropagationStopped=Ln,this}return w(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=In)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=In)},persist:function(){},isPersistent:In}),t}var zn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Bn=Rn(zn),Vn=w({},zn,{view:0,detail:0}),L=Rn(Vn),Hn,Un,Wn,Gn=w({},Vn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:tr,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==Wn&&(Wn&&e.type===`mousemove`?(Hn=e.screenX-Wn.screenX,Un=e.screenY-Wn.screenY):Un=Hn=0,Wn=e),Hn)},movementY:function(e){return`movementY`in e?e.movementY:Un}}),Kn=Rn(Gn),qn=Rn(w({},Gn,{dataTransfer:0})),Jn=Rn(w({},Vn,{relatedTarget:0})),Yn=Rn(w({},zn,{animationName:0,elapsedTime:0,pseudoElement:0})),R=Rn(w({},zn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Xn=Rn(w({},zn,{data:0})),Zn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Qn={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},$n={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function er(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=$n[e])?!!t[e]:!1}function tr(){return er}var nr=Rn(w({},Vn,{key:function(e){if(e.key){var t=Zn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=Fn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Qn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:tr,charCode:function(e){return e.type===`keypress`?Fn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?Fn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),rr=Rn(w({},Gn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),ir=Rn(w({},zn,{submitter:0})),ar=Rn(w({},Vn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:tr})),or=Rn(w({},zn,{propertyName:0,elapsedTime:0,pseudoElement:0})),sr=Rn(w({},Gn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),cr=Rn(w({},zn,{newState:0,oldState:0,source:0})),lr=[9,13,27,32],z=On&&`CompositionEvent`in window,ur=null;On&&`documentMode`in document&&(ur=document.documentMode);var dr=On&&`TextEvent`in window&&!ur,fr=On&&(!z||ur&&8<ur&&11>=ur),pr=` `,mr=!1;function hr(e,t){switch(e){case`keyup`:return lr.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function gr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var _r=!1;function vr(e,t){switch(e){case`compositionend`:return gr(t);case`keypress`:return t.which===32?(mr=!0,pr):null;case`textInput`:return e=t.data,e===pr&&mr?null:e;default:return null}}function yr(e,t){if(_r)return e===`compositionend`||!z&&hr(e,t)?(e=Pn(),Nn=Mn=jn=null,_r=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return fr&&t.locale!==`ko`?null:t.data;default:return null}}var br={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function xr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!br[e.type]:t===`textarea`}function Cr(e,t,n,r){Sn?Cn?Cn.push(r):Cn=[r]:Sn=r,t=ip(t,`onChange`),0<t.length&&(n=new Bn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var Tr=null,Er=null;function Dr(e){Xf(e,0)}function Or(e){if(tn(Pt(e)))return e}function kr(e,t){if(e===`change`)return t}var Ar=!1;if(On){var jr;if(On){var Mr=`oninput`in document;if(!Mr){var Nr=document.createElement(`div`);Nr.setAttribute(`oninput`,`return;`),Mr=typeof Nr.oninput==`function`}jr=Mr}else jr=!1;Ar=jr&&(!document.documentMode||9<document.documentMode)}function Pr(){Tr&&(Tr.detachEvent(`onpropertychange`,Fr),Er=Tr=null)}function Fr(e){if(e.propertyName===`value`&&Or(Er)){var t=[];Cr(t,Er,e,xn(e)),En(Dr,t)}}function Ir(e,t,n){e===`focusin`?(Pr(),Tr=t,Er=n,Tr.attachEvent(`onpropertychange`,Fr)):e===`focusout`&&Pr()}function Lr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return Or(Er)}function Rr(e,t){if(e===`click`)return Or(t)}function zr(e,t){if(e===`input`||e===`change`)return Or(t)}function Br(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var Vr=typeof Object.is==`function`?Object.is:Br;function Hr(e,t){if(Vr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Le.call(t,i)||!Vr(e[i],t[i]))return!1}return!0}function Ur(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function Wr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Gr(e,t){var n=Wr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Wr(n)}}function Kr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Kr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function qr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Ur(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ur(e.document)}return t}function Jr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Yr=On&&`documentMode`in document&&11>=document.documentMode,Xr=null,Zr=null,Qr=null,$r=!1;function ei(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;$r||Xr==null||Xr!==Ur(r)||(r=Xr,`selectionStart`in r&&Jr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Qr&&Hr(Qr,r)||(Qr=r,r=ip(Zr,`onSelect`),0<r.length&&(t=new Bn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Xr)))}function ti(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var ni={animationend:ti(`Animation`,`AnimationEnd`),animationiteration:ti(`Animation`,`AnimationIteration`),animationstart:ti(`Animation`,`AnimationStart`),transitionrun:ti(`Transition`,`TransitionRun`),transitionstart:ti(`Transition`,`TransitionStart`),transitioncancel:ti(`Transition`,`TransitionCancel`),transitionend:ti(`Transition`,`TransitionEnd`)},ri={},ii={};On&&(ii=document.createElement(`div`).style,`AnimationEvent`in window||(delete ni.animationend.animation,delete ni.animationiteration.animation,delete ni.animationstart.animation),`TransitionEvent`in window||delete ni.transitionend.transition);function ai(e){if(ri[e])return ri[e];if(!ni[e])return e;var t=ni[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in ii)return ri[e]=t[n];return e}var oi=ai(`animationend`),si=ai(`animationiteration`),ci=ai(`animationstart`),li=ai(`transitionrun`),ui=ai(`transitionstart`),di=ai(`transitioncancel`),fi=ai(`transitionend`),pi=new Map,mi=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error fullscreenChange fullscreenError gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);mi.push(`scrollEnd`);function hi(e,t){pi.set(e,t),Bt(t,[e])}var gi=0;function _i(e,t){if(e.name!=null&&e.name!==`auto`)return e.name;if(t.autoName!==null)return t.autoName;e=kd.identifierPrefix;var n=gi++;return e=`_`+e+`t_`+n.toString(32)+`_`,t.autoName=e}function vi(e){if(e==null||typeof e==`string`)return e;var t=null,n=Ld;if(n!==null)for(var r=0;r<n.length;r++){var i=e[n[r]];if(i!=null){if(i===`none`)return`none`;t=t==null?i:t+(` `+i)}}return t??e.default}function yi(e,t){return e=vi(e),t=vi(t),t==null?e===`auto`?null:e:t===`auto`?null:t}var bi=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},xi=[],Si=0,Ci=0;function wi(){for(var e=Si,t=Ci=Si=0;t<e;){var n=xi[t];xi[t++]=null;var r=xi[t];xi[t++]=null;var i=xi[t];xi[t++]=null;var a=xi[t];if(xi[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&Oi(n,i,a)}}function Ti(e,t,n,r){xi[Si++]=e,xi[Si++]=t,xi[Si++]=n,xi[Si++]=r,Ci|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Ei(e,t,n,r){return Ti(e,t,n,r),ki(e)}function Di(e,t){return Ti(e,null,null,t),ki(e)}function Oi(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-et(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function ki(e){if(50<Rd)throw Rd=0,zd=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Ai={};function ji(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Mi(e,t,n,r){return new ji(e,t,n,r)}function Ni(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Pi(e,t){var n=e.alternate;return n===null?(n=Mi(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&1206910976,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function Fi(e,t){e.flags&=1206910978;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Ii(e,t,n,r,a,o){var s=0;if(r=e,typeof r==`function`)Ni(r)&&(s=1);else if(typeof r==`string`)s=ih(e,n,Ce.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(r){case ae:return e=Mi(31,n,t,a),e.elementType=ae,e.lanes=o,e;case D:return Li(n.children,a,o,t);case O:s=8,a|=24;break;case te:return e=Mi(12,n,t,a|2),e.elementType=te,e.lanes=o,e;case j:return e=Mi(13,n,t,a),e.elementType=j,e.lanes=o,e;case M:return e=Mi(19,n,t,a),e.elementType=M,e.lanes=o,e;case oe:case ce:return e=a|32,e=Mi(30,n,t,e),e.elementType=ce,e.lanes=o,e.stateNode={autoName:null,paired:null,clones:null,ref:null},e;default:if(typeof r==`object`&&r)switch(r.$$typeof){case A:s=10;break a;case k:s=9;break a;case ne:s=11;break a;case re:s=14;break a;case ie:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=Mi(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function Li(e,t,n,r){return e=Mi(7,e,r,t),e.lanes=n,e}function Ri(e,t,n){return e=Mi(6,e,null,t),e.lanes=n,e}function zi(e){var t=Mi(18,null,null,0);return t.stateNode=e,t}function Bi(e,t,n){return t=Mi(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Vi=new WeakMap;function Hi(e,t){if(typeof e==`object`&&e){var n=Vi.get(e);return n===void 0?(t={value:e,source:t,stack:Ie(t)},Vi.set(e,t),t):n}return{value:e,source:t,stack:Ie(t)}}var Ui=[],Wi=0,Gi=null,Ki=0,qi=[],Ji=0,Yi=null,Xi=1,Zi=``;function Qi(e,t){Ui[Wi++]=Ki,Ui[Wi++]=Gi,Gi=e,Ki=t}function $i(e,t,n){qi[Ji++]=Xi,qi[Ji++]=Zi,qi[Ji++]=Yi,Yi=e;var r=Xi;e=Zi;var i=32-et(r)-1;r&=~(1<<i),n+=1;var a=32-et(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,Xi=1<<32-et(t)+i|n<<i|r,Zi=a+e}else Xi=1<<a|n<<i|r,Zi=e}function ea(e){e.return!==null&&(Qi(e,1),$i(e,1,0))}function ta(e){for(;e===Gi;)Gi=Ui[--Wi],Ui[Wi]=null,Ki=Ui[--Wi],Ui[Wi]=null;for(;e===Yi;)Yi=qi[--Ji],qi[Ji]=null,Zi=qi[--Ji],qi[Ji]=null,Xi=qi[--Ji],qi[Ji]=null}function na(e,t){qi[Ji++]=Xi,qi[Ji++]=Zi,qi[Ji++]=Yi,Xi=t.id,Zi=t.overflow,Yi=e}var ra=null,ia=null,aa=!1,oa=null,sa=!1,ca=Error(i(519));function la(e){throw ha(Hi(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),ca}function ua(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[Ct]=e,t[F]=r,n){case`dialog`:Zf(`cancel`,t),Zf(`close`,t);break;case`iframe`:case`object`:case`embed`:Zf(`load`,t);break;case`video`:case`audio`:for(n=0;n<Jf.length;n++)Zf(Jf[n],t);break;case`source`:Zf(`error`,t);break;case`img`:case`image`:case`link`:Zf(`error`,t),Zf(`load`,t);break;case`details`:Zf(`toggle`,t);break;case`input`:Zf(`invalid`,t),on(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:Zf(`invalid`,t);break;case`textarea`:Zf(`invalid`,t),un(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||up(t.textContent,n)?(r.popover!=null&&(Zf(`beforetoggle`,t),Zf(`toggle`,t)),r.onScroll!=null&&Zf(`scroll`,t),r.onScrollEnd!=null&&Zf(`scrollend`,t),r.onClick!=null&&(t.onclick=yn),t=!0):t=!1,t||la(e,!0)}function da(e){for(ra=e.return;ra;)switch(ra.tag){case 5:case 31:case 13:sa=!1;return;case 27:case 3:sa=!0;return;default:ra=ra.return}}function fa(e){if(e!==ra)return!1;if(!aa)return da(e),aa=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=n===`form`||n===`button`||wp(e.type,e.memoizedProps)),n=!n),n&&ia&&la(e),da(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));ia=Sm(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));ia=Sm(e)}else t===27?(t=ia,Np(e.type)?(e=xm,xm=null,ia=e):ia=t):ia=ra?bm(e.stateNode.nextSibling):null;return!0}function pa(){ia=ra=null,aa=!1}function ma(){var e=oa;return e!==null&&(xd===null?xd=e:xd.push.apply(xd,e),oa=null),e}function ha(e){oa===null?oa=[e]:oa.push(e)}var ga=be(null),_a=null,va=null;function ya(e,t,n){Se(ga,t._currentValue),t._currentValue=n}function ba(e){e._currentValue=ga.current,xe(ga)}function xa(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Sa(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),xa(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),xa(s,n,e),s=null}else a.tag===13&&a.memoizedState!==null&&a.memoizedState.dehydrated===null?(a.lanes|=n,s=a.alternate,s!==null&&(s.lanes|=n),xa(a.return,n,e),s=a.child,s=s===null?null:s.sibling):s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function Ca(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;Vr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===Te.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[vh]:e.push(vh))}a=a.return}return e!==null&&Sa(t,e,n,r),t.flags|=262144,e!==null}function wa(e){for(e=e.firstContext;e!==null;){if(!Vr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Ta(e){_a=e,va=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Ea(e){return Oa(_a,e)}function Da(e,t){return _a===null&&Ta(e),Oa(e,t)}function Oa(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},va===null){if(e===null)throw Error(i(308));va=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else va=va.next=t;return n}var ka=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Aa=t.unstable_scheduleCallback,ja=t.unstable_NormalPriority,Ma={$$typeof:A,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Na(){return{controller:new ka,data:new Map,refCount:0}}function Pa(e){e.refCount--,e.refCount===0&&Aa(ja,function(){e.controller.abort()})}function Fa(e,t){if(e.pendingLanes&4194048){var n=e.transitionTypes;for(n===null&&(n=e.transitionTypes=[]),e=0;e<t.length;e++){var r=t[e];n.indexOf(r)===-1&&n.push(r)}}}var Ia=null;function La(e){var t=e.transitionTypes;return e.transitionTypes=null,t}var Ra=null,za=0,Ba=0,Va=null;function Ha(e,t){if(Ra===null){var n=Ra=[];za=0,Ba=Uf(),Va={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return za++,t.then(Ua,Ua),t}function Ua(){if(--za===0&&(Ia=null,Ra!==null)){Va!==null&&(Va.status=`fulfilled`);var e=Ra;Ra=null,Ba=0,Va=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Wa(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var Ga=he.S;he.S=function(e,t){if(wd=He(),typeof t==`object`&&t&&typeof t.then==`function`&&Ha(e,t),Ia!==null)for(var n=Af;n!==null;)Fa(n,Ia),n=n.next;if(n=e.types,n!==null){for(var r=Af;r!==null;)Fa(r,n),r=r.next;if(Ba!==0){r=Ia,r===null&&(r=Ia=[]);for(var i=0;i<n.length;i++){var a=n[i];r.indexOf(a)===-1&&r.push(a)}}}Ga!==null&&Ga(e,t)};var Ka=be(null);function qa(){var e=Ka.current;return e===null?ad.pooledCache:e}function Ja(e,t){t===null?Se(Ka,Ka.current):Se(Ka,t.pool)}function Ya(){var e=qa();return e===null?null:{parent:Ma._currentValue,pool:e}}var Xa=Error(i(460)),Za=Error(i(474)),Qa=Error(i(542)),$a={then:function(){}};function eo(e){return e=e.status,e===`fulfilled`||e===`rejected`}function to(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(yn,yn),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,ao(e),e===void 0&&!(`reason`in t)?Error(i(600)):e;default:if(typeof t.status==`string`)t.then(yn,yn);else{if(e=ad,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,ao(e),e}throw ro=t,Xa}}function no(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(ro=e,Xa):e}}var ro=null;function io(){if(ro===null)throw Error(i(459));var e=ro;return ro=null,e}function ao(e){if(e===Xa||e===Qa)throw Error(i(483))}var oo=null,so=0;function co(e){var t=so;return so+=1,oo===null&&(oo=[]),to(oo,e,t)}function lo(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function uo(e,t){throw t.$$typeof===T?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function fo(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=Pi(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=134217730,n):(r=r.index,r<n?(t.flags|=2,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=134217730),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=Ri(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===D?(e=d(e,t,n.props.children,r,n.key),lo(e,n),e):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===ie&&no(i)===t.type)?(t=a(t,n.props),lo(t,n),t.return=e,t):(t=Ii(n.type,n.key,n.props,null,e.mode,r),lo(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=Bi(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=Li(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=Ri(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case E:return n=Ii(t.type,t.key,t.props,null,e.mode,n),lo(n,t),n.return=e,n;case ee:return t=Bi(t,e.mode,n),t.return=e,t;case ie:return t=no(t),f(e,t,n)}if(me(t)||de(t))return t=Li(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,co(t),n);if(t.$$typeof===A)return f(e,Da(e,t),n);uo(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case E:return n.key===i?l(e,t,n,r):null;case ee:return n.key===i?u(e,t,n,r):null;case ie:return n=no(n),p(e,t,n,r)}if(me(n)||de(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,co(n),r);if(n.$$typeof===A)return p(e,t,Da(e,n),r);uo(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case E:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case ee:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case ie:return r=no(r),m(e,t,n,r,i)}if(me(r)||de(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,co(r),i);if(r.$$typeof===A)return m(e,t,n,Da(t,r),i);uo(t,r)}return null}function h(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),aa&&Qi(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return aa&&Qi(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&(_=g.alternate,_!==null&&d.delete(_.key===null?h:_.key)),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),aa&&Qi(i,h),l}function g(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),aa&&Qi(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return aa&&Qi(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),aa&&Qi(a,g),u}function _(e,r,o,c){if(typeof o==`object`&&o&&o.type===D&&o.key===null&&o.props.ref===void 0&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case E:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===D){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),lo(c,o),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===ie&&no(l)===r.type){n(e,r.sibling),c=a(r,o.props),lo(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===D?(c=Li(o.props.children,e.mode,c,o.key),lo(c,o),c.return=e,e=c):(c=Ii(o.type,o.key,o.props,null,e.mode,c),lo(c,o),c.return=e,e=c)}return s(e);case ee:a:{for(l=o.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=Bi(o,e.mode,c),c.return=e,e=c}return s(e);case ie:return o=no(o),_(e,r,o,c)}if(me(o))return h(e,r,o,c);if(de(o)){if(l=de(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return _(e,r,co(o),c);if(o.$$typeof===A)return _(e,r,Da(e,o),c);uo(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=Ri(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{so=0;var i=_(e,t,n,r);return oo=null,i}catch(t){if(t===Xa||t===Qa)throw t;var a=Mi(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var B=fo(!0),po=fo(!1),mo=!1;function ho(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function go(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function _o(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function vo(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,id&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=ki(e),Oi(e,null,n),t}return Ti(e,r,t,n),ki(e)}function yo(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,_t(e,n)}}function bo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var xo=!1;function So(){if(xo){var e=Va;if(e!==null)throw e}}function Co(e,t,n,r){xo=!1;var i=e.updateQueue;mo=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(sd&f)===f:(r&f)===f){f!==0&&f===Ba&&(xo=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break a;d=w({},d,f);break a;case 2:mo=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),hd|=o,e.lanes=o,e.memoizedState=d}}function wo(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function To(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)wo(n[e],t)}var Eo=be(null),Do=be(0);function Oo(e,t){e=pd,Se(Do,e),Se(Eo,t),pd=e|t.baseLanes}function ko(){Se(Do,pd),Se(Eo,Eo.current)}function Ao(){pd=Do.current,xe(Eo),xe(Do)}var jo=be(null),Mo=null;function No(e){var t=e.alternate;Se(Ro,Ro.current&1),Se(jo,e),Mo===null&&(t===null||Eo.current!==null||t.memoizedState!==null)&&(Mo=e)}function Po(e){Se(Ro,Ro.current),Se(jo,e),Mo===null&&(Mo=e)}function Fo(e){e.tag===22?(Se(Ro,Ro.current),Se(jo,e),Mo===null&&(Mo=e)):Io()}function Io(){Se(Ro,Ro.current),Se(jo,jo.current)}function Lo(e){xe(jo),Mo===e&&(Mo=null),xe(Ro)}var Ro=be(0);function zo(e,t){Se(jo,jo.current),Se(Ro,t)}function Bo(e){xe(Ro),xe(jo),Mo===e&&(Mo=null)}function Vo(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||_m(n)||vm(n)))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==`independent`){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Ho=0,Uo=null,Wo=null,Go=null,Ko=!1,qo=!1,Jo=!1,Yo=0,Xo=0,Zo=null,Qo=0;function $o(){throw Error(i(321))}function es(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Vr(e[n],t[n]))return!1;return!0}function ts(e,t,n,r,i,a){return Ho=a,Uo=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,he.H=e===null||e.memoizedState===null?vc:yc,Jo=!1,a=n(r,i),Jo=!1,qo&&(a=rs(t,n,r,i)),ns(e),a}function ns(e){he.H=_c;var t=Wo!==null&&Wo.next!==null;if(Ho=0,Go=Wo=Uo=null,Ko=!1,Xo=0,Zo=null,t)throw Error(i(300));e===null||Fc||(e=e.dependencies,e!==null&&wa(e)&&(Fc=!0))}function rs(e,t,n,r){Uo=e;var a=0;do{if(qo&&(Zo=null),Xo=0,qo=!1,25<=a)throw Error(i(301));if(a+=1,Go=Wo=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}he.H=bc,o=t(n,r)}while(qo);return o}function is(){var e=he.H,t=e.useState()[0];return t=typeof t.then==`function`?ds(t):t,e=e.useState()[0],(Wo===null?null:Wo.memoizedState)!==e&&(Uo.flags|=1024),t}function as(){var e=Yo!==0;return Yo=0,e}function os(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function ss(e){if(Ko){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Ko=!1}Ho=0,Go=Wo=Uo=null,qo=!1,Xo=Yo=0,Zo=null}function cs(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Go===null?Uo.memoizedState=Go=e:Go=Go.next=e,Go}function ls(){if(Wo===null){var e=Uo.alternate;e=e===null?null:e.memoizedState}else e=Wo.next;var t=Go===null?Uo.memoizedState:Go.next;if(t!==null)Go=t,Wo=e;else{if(e===null)throw Uo.alternate===null?Error(i(467)):Error(i(310));Wo=e,e={memoizedState:Wo.memoizedState,baseState:Wo.baseState,baseQueue:Wo.baseQueue,queue:Wo.queue,next:null},Go===null?Uo.memoizedState=Go=e:Go=Go.next=e}return Go}function us(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ds(e){var t=Xo;return Xo+=1,Zo===null&&(Zo=[]),e=to(Zo,e,t),t=Uo,(Go===null?t.memoizedState:Go.next)===null&&(t=t.alternate,he.H=t===null||t.memoizedState===null?vc:yc),e}function fs(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return ds(e);if(e.$$typeof===le)return;if(e.$$typeof===A)return Ea(e)}throw Error(i(438,String(e)))}function ps(e){var t=null,n=Uo.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=Uo.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=us(),Uo.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=se;return t.index++,n}function ms(e,t){return typeof t==`function`?t(e):t}function hs(e){return gs(ls(),Wo,e)}function gs(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(Ho&f)===f:(sd&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===Ba&&(d=!0);else if((Ho&p)===p){u=u.next,p===Ba&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,Uo.lanes|=p,hd|=p;f=u.action,Jo&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,Uo.lanes|=f,hd|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!Vr(o,e.memoizedState)&&(Fc=!0,d&&(n=Va,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function _s(e){var t=ls(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);Vr(o,t.memoizedState)||(Fc=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function vs(e,t,n){var r=Uo,a=ls(),o=aa;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!Vr((Wo||a).memoizedState,n);if(s&&(a.memoizedState=n,Fc=!0),a=a.queue,Us(xs.bind(null,r,a,e),[e]),e=a.getSnapshot!==t||s||Go!==null&&!!(Go.memoizedState.tag&1),Rs(e?9:8,{destroy:void 0},bs.bind(null,r,a,n,t),null),e){if(r.flags|=2048,ad===null)throw Error(i(349));o||Ho&127||ys(r,t,n)}return n}function ys(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Uo.updateQueue,t===null?(t=us(),Uo.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function bs(e,t,n,r){t.value=n,t.getSnapshot=r,Ss(t)&&Cs(e)}function xs(e,t,n){return n(function(){Ss(t)&&Cs(e)})}function Ss(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Vr(e,n)}catch{return!0}}function Cs(e){var t=Di(e,2);t!==null&&Ud(t,e,2)}function ws(e){var t=cs();if(typeof e==`function`){var n=e;if(e=n(),Jo){$e(!0);try{n()}finally{$e(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ms,lastRenderedState:e},t}function Ts(e,t,n,r){return e.baseState=n,gs(e,Wo,typeof r==`function`?r:ms)}function Es(e,t,n,r,a){if(mc(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};he.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,Ds(t,o)):(o.next=n.next,t.pending=n.next=o)}}function Ds(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=he.T,o={};o.types=a===null?null:a.types,he.T=o;try{var s=n(i,r),c=he.S;c!==null&&c(o,s),Os(e,t,s)}catch(n){As(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),he.T=a}}else try{a=n(i,r),Os(e,t,a)}catch(n){As(e,t,n)}}function Os(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){ks(e,t,n)},function(n){return As(e,t,n)}):ks(e,t,n)}function ks(e,t,n){t.status=`fulfilled`,t.value=n,js(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Ds(e,n)))}function As(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,js(t),t=t.next;while(t!==r)}e.action=null}function js(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Ms(e,t){return t}function Ns(e,t){if(aa){var n=ad.formState;if(n!==null){a:{var r=Uo;if(aa){if(ia){b:{for(var i=ia,a=sa;i.nodeType!==8;)if(!a||(i=bm(i.nextSibling),i===null)){i=null;break b}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){ia=bm(i.nextSibling),r=i.data===`F!`;break a}}la(r)}r=!1}r&&(t=n[0])}}return n=cs(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ms,lastRenderedState:t},n.queue=r,n=dc.bind(null,Uo,r),r.dispatch=n,r=ws(!1),a=pc.bind(null,Uo,!1,r.queue),r=cs(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=Es.bind(null,Uo,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function Ps(e){return Fs(ls(),Wo,e)}function Fs(e,t,n){if(t=gs(e,t,Ms)[0],e=hs(ms)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=ds(t)}catch(e){throw e===Xa?Qa:e}else r=t;t=ls();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(Uo.flags|=2048,Rs(9,{destroy:void 0},Is.bind(null,i,n),null)),[r,a,e]}function Is(e,t){e.action=t}function Ls(e){var t=ls(),n=Wo;if(n!==null)return Fs(t,n,e);ls(),t=t.memoizedState,n=ls();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Rs(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=Uo.updateQueue,t===null&&(t=us(),Uo.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function zs(){return ls().memoizedState}function Bs(e,t,n,r){var i=cs();Uo.flags|=e,i.memoizedState=Rs(1|t,{destroy:void 0},n,r===void 0?null:r)}function Vs(e,t,n,r){var i=ls();r=r===void 0?null:r;var a=i.memoizedState.inst;Wo!==null&&r!==null&&es(r,Wo.memoizedState.deps)?i.memoizedState=Rs(t,a,n,r):(Uo.flags|=e,i.memoizedState=Rs(1|t,a,n,r))}function Hs(e,t){Bs(8390656,8,e,t)}function Us(e,t){Vs(2048,8,e,t)}function Ws(e){Uo.flags|=4;var t=Uo.updateQueue;if(t===null)t=us(),Uo.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Gs(e){var t=ls().memoizedState;return Ws({ref:t,nextImpl:e}),function(){if(id&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function Ks(e,t){return Vs(4,2,e,t)}function qs(e,t){return Vs(4,4,e,t)}function Js(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Ys(e,t,n){n=n==null?null:n.concat([e]),Vs(4,4,Js.bind(null,t,e),n)}function Xs(){}function Zs(e,t){var n=ls();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&es(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Qs(e,t){var n=ls();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&es(t,r[1]))return r[0];if(r=e(),Jo){$e(!0);try{e()}finally{$e(!1)}}return n.memoizedState=[r,t],r}function $s(e,t,n){return n===void 0||Ho&1073741824&&!(sd&261930)?e.memoizedState=t:(e.memoizedState=n,e=Vd(),Uo.lanes|=e,hd|=e,n)}function ec(e,t,n,r){return Vr(n,t)?n:Eo.current===null?!(Ho&106)||Ho&1073741824&&!(sd&261930)?(Fc=!0,e.memoizedState=n):(e=Vd(),Uo.lanes|=e,hd|=e,t):(e=$s(e,n,r),Vr(e,t)||(Fc=!0),e)}function tc(e,t,n,r,i){var a=ge.p;ge.p=a!==0&&8>a?a:8;var o=he.T,s={};s.types=o===null?null:o.types,he.T=s,pc(e,!1,t,n);try{var c=i(),l=he.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?fc(e,t,Wa(c,r),Bd(e)):fc(e,t,r,Bd(e))}catch(n){fc(e,t,{then:function(){},status:`rejected`,reason:n},Bd())}finally{ge.p=a,o!==null&&s.types!==null&&(o.types=s.types),he.T=o}}function nc(){}function rc(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=ic(e).queue;tc(e,a,t,_e,n===null?nc:function(){return ac(e),n(r)})}function ic(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:_e,baseState:_e,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ms,lastRenderedState:_e},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ms,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function ac(e){var t=ic(e);t.next===null&&(t=e.alternate.memoizedState),fc(e,t.next.queue,{},Bd())}function oc(){return Ea(vh)}function sc(){return ls().memoizedState}function cc(){return ls().memoizedState}function lc(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Bd();e=_o(n);var r=vo(t,e,n);r!==null&&(Ud(r,t,n),yo(r,t,n)),t={cache:Na()},e.payload=t;return}t=t.return}}function uc(e,t,n){var r=Bd();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},mc(e)?hc(t,n):(n=Ei(e,t,n,r),n!==null&&(Ud(n,e,r),gc(n,t,r)))}function dc(e,t,n){fc(e,t,n,Bd())}function fc(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(mc(e))hc(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Vr(s,o))return Ti(e,t,i,0),ad===null&&wi(),!1}catch{}if(n=Ei(e,t,i,r),n!==null)return Ud(n,e,r),gc(n,t,r),!0}return!1}function pc(e,t,n,r){if(r={lane:2,revertLane:Uf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},mc(e)){if(t)throw Error(i(479))}else t=Ei(e,n,r,2),t!==null&&Ud(t,e,2)}function mc(e){var t=e.alternate;return e===Uo||t!==null&&t===Uo}function hc(e,t){qo=Ko=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function gc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,_t(e,n)}}var _c={readContext:Ea,use:fs,useCallback:$o,useContext:$o,useEffect:$o,useImperativeHandle:$o,useLayoutEffect:$o,useInsertionEffect:$o,useMemo:$o,useReducer:$o,useRef:$o,useState:$o,useDebugValue:$o,useDeferredValue:$o,useTransition:$o,useSyncExternalStore:$o,useId:$o,useHostTransitionStatus:$o,useFormState:$o,useActionState:$o,useOptimistic:$o,useMemoCache:$o,useCacheRefresh:$o,useEffectEvent:$o},vc={readContext:Ea,use:fs,useCallback:function(e,t){return cs().memoizedState=[e,t===void 0?null:t],e},useContext:Ea,useEffect:Hs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Bs(4194308,4,Js.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Bs(4194308,4,e,t)},useInsertionEffect:function(e,t){Bs(4,2,e,t)},useMemo:function(e,t){var n=cs();t=t===void 0?null:t;var r=e();if(Jo){$e(!0);try{e()}finally{$e(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=cs();if(n!==void 0){var i=n(t);if(Jo){$e(!0);try{n(t)}finally{$e(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=uc.bind(null,Uo,e),[r.memoizedState,e]},useRef:function(e){var t=cs();return e={current:e},t.memoizedState=e},useState:function(e){e=ws(e);var t=e.queue,n=dc.bind(null,Uo,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Xs,useDeferredValue:function(e,t){return $s(cs(),e,t)},useTransition:function(){var e=ws(!1);return e=tc.bind(null,Uo,e.queue,!0,!1),cs().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=Uo,a=cs();if(aa){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),ad===null)throw Error(i(349));sd&127||ys(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,Hs(xs.bind(null,r,o,e),[e]),r.flags|=2048,Rs(9,{destroy:void 0},bs.bind(null,r,o,n,t),null),n},useId:function(){var e=cs(),t=ad.identifierPrefix;if(aa){var n=Zi,r=Xi;n=(r&~(1<<32-et(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=Yo++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=Qo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:oc,useFormState:Ns,useActionState:Ns,useOptimistic:function(e){var t=cs();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=pc.bind(null,Uo,!0,n),n.dispatch=t,[e,t]},useMemoCache:ps,useCacheRefresh:function(){return cs().memoizedState=lc.bind(null,Uo)},useEffectEvent:function(e){var t=cs(),n={impl:e};return t.memoizedState=n,function(){if(id&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},yc={readContext:Ea,use:fs,useCallback:Zs,useContext:Ea,useEffect:Us,useImperativeHandle:Ys,useInsertionEffect:Ks,useLayoutEffect:qs,useMemo:Qs,useReducer:hs,useRef:zs,useState:function(){return hs(ms)},useDebugValue:Xs,useDeferredValue:function(e,t){return ec(ls(),Wo.memoizedState,e,t)},useTransition:function(){var e=hs(ms)[0],t=ls().memoizedState;return[typeof e==`boolean`?e:ds(e),t]},useSyncExternalStore:vs,useId:sc,useHostTransitionStatus:oc,useFormState:Ps,useActionState:Ps,useOptimistic:function(e,t){return Ts(ls(),Wo,e,t)},useMemoCache:ps,useCacheRefresh:cc,useEffectEvent:Gs},bc={readContext:Ea,use:fs,useCallback:Zs,useContext:Ea,useEffect:Us,useImperativeHandle:Ys,useInsertionEffect:Ks,useLayoutEffect:qs,useMemo:Qs,useReducer:_s,useRef:zs,useState:function(){return _s(ms)},useDebugValue:Xs,useDeferredValue:function(e,t){var n=ls();return Wo===null?$s(n,e,t):ec(n,Wo.memoizedState,e,t)},useTransition:function(){var e=_s(ms)[0],t=ls().memoizedState;return[typeof e==`boolean`?e:ds(e),t]},useSyncExternalStore:vs,useId:sc,useHostTransitionStatus:oc,useFormState:Ls,useActionState:Ls,useOptimistic:function(e,t){var n=ls();return Wo===null?(n.baseState=e,[e,n.queue.dispatch]):Ts(n,Wo,e,t)},useMemoCache:ps,useCacheRefresh:cc,useEffectEvent:Gs};function xc(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:w({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Sc={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Bd(),i=_o(r);i.payload=t,n!=null&&(i.callback=n),t=vo(e,i,r),t!==null&&(Ud(t,e,r),yo(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Bd(),i=_o(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=vo(e,i,r),t!==null&&(Ud(t,e,r),yo(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Bd(),r=_o(n);r.tag=2,t!=null&&(r.callback=t),t=vo(e,r,n),t!==null&&(Ud(t,e,n),yo(t,e,n))}};function V(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!Hr(n,r)||!Hr(i,a):!0}function Cc(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Sc.enqueueReplaceState(t,t.state,null)}function wc(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=w({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function Tc(e){bi(e)}function Ec(e){console.error(e)}function Dc(e){bi(e)}function Oc(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function kc(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Ac(e,t,n){return n=_o(n),n.tag=3,n.payload={element:null},n.callback=function(){Oc(e,t)},n}function jc(e){return e=_o(e),e.tag=3,e}function Mc(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){kc(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){kc(t,n,r),typeof i!=`function`&&(Dd===null?Dd=new Set([this]):Dd.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function Nc(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&Ca(t,n,a,!0),n=jo.current,n!==null){switch(n.tag){case 31:case 13:case 19:return Mo===null?tf():n.alternate===null&&md===0&&(md=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===$a?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),wf(e,r,a)),!1;case 22:return n.flags|=65536,r===$a?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),wf(e,r,a)),!1}throw Error(i(435,n.tag))}return wf(e,r,a),tf(),!1}if(aa)return t=jo.current,t===null?(r!==ca&&(t=Error(i(423),{cause:r}),ha(Hi(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=Hi(r,n),a=Ac(e.stateNode,r,a),bo(e,a),md!==4&&(md=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==ca&&(e=Error(i(422),{cause:r}),ha(Hi(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=Hi(o,n),bd===null?bd=[o]:bd.push(o),md!==4&&(md=2),t===null)return!0;r=Hi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Ac(n.stateNode,r,e),bo(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(Dd===null||!Dd.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=jc(a),Mc(a,e,n,r),bo(n,a),!1;break;case 22:if(n.memoizedState!==null)return n.flags|=65536,!1}n=n.return}while(n!==null);return!1}var Pc=Error(i(461)),Fc=!1;function Ic(e,t,n,r){t.child=e===null?po(t,null,n,r):B(t,e.child,n,r)}function Lc(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Ta(t),r=ts(e,t,n,o,a,i),s=as(),e!==null&&!Fc?(os(e,t,i),dl(e,t,i)):(aa&&s&&ea(t),t.flags|=1,Ic(e,t,r,i),t.child)}function Rc(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Ni(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,zc(e,t,a,r,i)):(e=Ii(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!fl(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?Hr:n,n(o,r)&&e.ref===t.ref)return dl(e,t,i)}return t.flags|=1,e=Pi(a,r),e.ref=t.ref,e.return=t,t.child=e}function zc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Hr(a,r)&&e.ref===t.ref){if(Fc=!1,t.pendingProps=r=a,fl(e,i))e.flags&131072&&(Fc=!0);else return t.lanes=e.lanes,dl(e,t,i)}}return qc(e,t,n,r,i)}function Bc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return Hc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Ja(t,a===null?null:a.cachePool),a===null?ko():Oo(t,a),Fo(t);else return r=t.lanes=536870912,Hc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&Ja(t,null),ko(),Io()):(Ja(t,a.cachePool),Oo(t,a),Io(),t.memoizedState=null);return Ic(e,t,i,n),t.child}function Vc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Hc(e,t,n,r,i){var a=qa();return a=a===null?null:{parent:Ma._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&Ja(t,null),ko(),Fo(t),e!==null&&Ca(e,t,r,!0),t.childLanes=i,null}function Uc(e,t){return t=nl({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Wc(e,t,n){return B(t,e.child,null,n),e=Uc(t,t.pendingProps),e.flags|=2,Lo(t),t.memoizedState=null,e}function Gc(e,t,n){var r=t.pendingProps,a=!!(t.flags&128);if(t.flags&=-129,e===null){if(aa){if(r.mode===`hidden`)return e=Uc(t,r),t.lanes=536870912,e.memoizedState={baseLanes:0,cachePool:null},Vc(null,e);if(Po(t),(e=ia)?(e=gm(e,sa),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Yi===null?null:{id:Xi,overflow:Zi},retryLane:536870912,hydrationErrors:null},n=zi(e),n.return=t,t.child=n,ra=t,ia=null)):e=null,e===null)throw la(t);return t.lanes=536870912,null}return Uc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(Po(t),a){if(t.flags&256)t.flags&=-257,t=Wc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558))}else if(Fc||Ca(e,t,n,!1),a=(n&e.childLanes)!==0,Fc||a){if(Eo.current===null){if(r=ad,r!==null&&(s=vt(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,Di(e,s),Ud(r,e,s),Pc;tf()}t=Wc(e,t,n)}else e=o.treeContext,ia=bm(s.nextSibling),ra=t,aa=!0,oa=null,sa=!1,e!==null&&na(t,e),t=Uc(t,r),t.flags|=134221824;return t}return e=Pi(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Kc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function qc(e,t,n,r,i){return Ta(t),n=ts(e,t,n,r,void 0,i),r=as(),e!==null&&!Fc?(os(e,t,i),dl(e,t,i)):(aa&&r&&ea(t),t.flags|=1,Ic(e,t,n,i),t.child)}function Jc(e,t,n,r,i,a){return Ta(t),t.updateQueue=null,n=rs(t,r,n,i),ns(e),r=as(),e!==null&&!Fc?(os(e,t,a),dl(e,t,a)):(aa&&r&&ea(t),t.flags|=1,Ic(e,t,n,a),t.child)}function Yc(e,t,n,r,i){if(Ta(t),t.stateNode===null){var a=Ai,o=n.contextType;typeof o==`object`&&o&&(a=Ea(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Sc,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},ho(t),o=n.contextType,a.context=typeof o==`object`&&o?Ea(o):Ai,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(xc(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&Sc.enqueueReplaceState(a,a.state,null),Co(t,r,a,i),So(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=wc(n,s);a.props=c;var l=a.context,u=n.contextType;o=Ai,typeof u==`object`&&u&&(o=Ea(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Cc(t,a,r,o),mo=!1;var f=t.memoizedState;a.state=f,Co(t,r,a,i),So(),l=t.memoizedState,s||f!==l||mo?(typeof d==`function`&&(xc(t,n,d,r),l=t.memoizedState),(c=mo||V(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,go(e,t),o=t.memoizedProps,u=wc(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=Ai,typeof l==`object`&&l&&(c=Ea(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Cc(t,a,r,c),mo=!1,f=t.memoizedState,a.state=f,Co(t,r,a,i),So();var p=t.memoizedState;o!==d||f!==p||mo||e!==null&&e.dependencies!==null&&wa(e.dependencies)?(typeof s==`function`&&(xc(t,n,s,r),p=t.memoizedState),(u=mo||V(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&wa(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,Kc(e,t),r=!!(t.flags&128),a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=B(t,e.child,null,i),t.child=B(t,null,n,i)):Ic(e,t,n,i),t.memoizedState=a.state,e=t.child):e=dl(e,t,i),e}function Xc(e,t,n,r){return pa(),t.flags|=256,Ic(e,t,n,r),t.child}var Zc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Qc(e){return{baseLanes:e,cachePool:Ya()}}function $c(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=vd),e}function el(e,t,n){var r=t.pendingProps,i=!1,a=!!(t.flags&128),o;if((o=a)||(o=e!==null&&e.memoizedState===null?!1:!!(Ro.current&2)),o&&(i=!0,t.flags&=-129),o=!!(t.flags&32),t.flags&=-33,e===null){if(aa){if(i?No(t):Io(),(e=ia)?(e=gm(e,sa),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Yi===null?null:{id:Xi,overflow:Zi},retryLane:536870912,hydrationErrors:null},n=zi(e),n.return=t,t.child=n,ra=t,ia=null)):e=null,e===null)throw la(t);return t.lanes=vm(e)?32:536870912,null}return a=r.children,r=r.fallback,i?(Io(),i=t.mode,a=nl({mode:`hidden`,children:a},i),r=Li(r,i,n,null),a.return=t,r.return=t,a.sibling=r,t.child=a,r=t.child,r.memoizedState=Qc(n),r.childLanes=$c(e,o,n),t.memoizedState=Zc,Vc(null,r)):(No(t),tl(t,a))}var s=e.memoizedState;if(s!==null){var c=s.dehydrated;if(c!==null)return il(e,t,a,o,r,c,s,n)}return i?(Io(),i=r.fallback,a=t.mode,s=e.child,c=s.sibling,r=Pi(s,{mode:`hidden`,children:r.children}),r.subtreeFlags=s.subtreeFlags&1206910976,c===null?(i=Li(i,a,n,null),i.flags|=2):i=Pi(c,i),i.return=t,r.return=t,r.sibling=i,t.child=r,Vc(null,r),r=t.child,i=e.child.memoizedState,i===null?i=Qc(n):(a=i.cachePool,a===null?a=Ya():(s=Ma._currentValue,a=a.parent===s?a:{parent:s,pool:s}),i={baseLanes:i.baseLanes|n,cachePool:a}),r.memoizedState=i,r.childLanes=$c(e,o,n),t.memoizedState=Zc,Vc(e.child,r)):(No(t),n=e.child,e=n.sibling,n=Pi(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(o=t.deletions,o===null?(t.deletions=[e],t.flags|=16):o.push(e)),t.child=n,t.memoizedState=null,n)}function tl(e,t){return t=nl({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function nl(e,t){return e=Mi(22,e,null,t),e.lanes=0,e}function rl(e,t,n){return B(t,e.child,null,n),e=tl(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function il(e,t,n,r,a,o,s,c){if(n)return t.flags&256?(No(t),t.flags&=-257,rl(e,t,c)):t.memoizedState===null?(Io(),o=a.fallback,s=t.mode,a=nl({mode:`visible`,children:a.children},s),o=Li(o,s,c,null),o.flags|=2,a.return=t,o.return=t,a.sibling=o,t.child=a,B(t,e.child,null,c),a=t.child,a.memoizedState=Qc(c),a.childLanes=$c(e,r,c),t.memoizedState=Zc,Vc(null,a)):(Io(),t.child=e.child,t.flags|=128,null);if(No(t),vm(o)){if(r=o.nextSibling&&o.nextSibling.dataset,r)var l=r.dgst;return r=l,r!==``&&(a=Error(i(419)),a.stack=``,a.digest=r,ha({value:a,source:null,stack:null})),rl(e,t,c)}if(Fc||Ca(e,t,c,!1),r=(c&e.childLanes)!==0,Fc||r){if(Eo.current!==null)return rl(e,t,c);if(r=ad,r!==null&&(a=vt(r,c),a!==0&&a!==s.retryLane))throw s.retryLane=a,Di(e,a),Ud(r,e,a),Pc;return _m(o)||tf(),rl(e,t,c)}return _m(o)?(t.flags|=192,t.child=e.child,null):(e=s.treeContext,ia=bm(o.nextSibling),ra=t,aa=!0,oa=null,sa=!1,e!==null&&na(t,e),t=tl(t,a.children),t.flags|=134221824,t)}function al(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),xa(e.return,t,n)}function ol(e){for(var t=null;e!==null;){var n=e.alternate;n!==null&&Vo(n)===null&&(t=e),e=e.sibling}return t}function sl(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function cl(e){var t=e.child;for(e.child=null;t!==null;){var n=t.sibling;t.sibling=e.child,e.child=t,t=n}}function ll(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=Ro.current;if(t.flags&128)return zo(t,o),null;var s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,zo(t,o),i===`backwards`&&e!==null?(cl(e),Ic(e,t,r,n),cl(e)):Ic(e,t,r,n),r=aa?Ki:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&al(e,n,t);else if(e.tag===19)al(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`backwards`:n=ol(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null,cl(t)),sl(t,!0,i,null,a,r);break;case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&Vo(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}sl(t,!0,n,null,a,r);break;case`together`:sl(t,!1,null,null,void 0,r);break;case`independent`:t.memoizedState=null;break;default:n=ol(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),sl(t,!1,i,n,a,r)}return t.child}function ul(e,t,n){var r=t.pendingProps;return ya(t,t.type,r.value),Ic(e,t,r.children,n),t.child}function dl(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),hd|=t.lanes,(n&t.childLanes)===0){if(e!==null){if(Ca(e,t,n,!1),(n&t.childLanes)===0)return null}else return null}if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=Pi(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Pi(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function fl(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&wa(e)))}function pl(e,t,n){switch(t.tag){case 3:Ee(t,t.stateNode.containerInfo),ya(t,Ma,e.memoizedState.cache),pa();break;case 27:case 5:Oe(t);break;case 4:Ee(t,t.stateNode.containerInfo);break;case 10:ya(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Po(t),null;break;case 13:var r=t.memoizedState;if(r!==null){if(r.dehydrated!==null)return No(t),t.flags|=128,null;r=Ca(e,t,n,!1);var i=t.child.childLanes;return r||(n&i)!==0?el(e,t,n):(No(t),e=dl(e,t,n),e===null?null:e.sibling)}No(t);break;case 19:if(t.flags&128)return ll(e,t,n);if(i=!!(e.flags&128),r=(n&t.childLanes)!==0,r||=(Ca(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return ll(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),zo(t,Ro.current),r)break;return null;case 22:return t.lanes=0,Bc(e,t,n,t.pendingProps);case 24:ya(t,Ma,e.memoizedState.cache)}return dl(e,t,n)}function ml(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps)Fc=!0;else{if(!fl(e,n)&&!(t.flags&128))return Fc=!1,pl(e,t,n);Fc=!!(e.flags&131072)}}else Fc=!1,aa&&t.flags&1048576&&$i(t,Ki,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=no(t.elementType),t.type=e,typeof e==`function`)Ni(e)?(r=wc(e,r),t.tag=1,t=Yc(null,t,e,r,n)):(t.tag=0,t=qc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===ne){t.tag=11,t=Lc(null,t,e,r,n);break a}if(a===re){t.tag=14,t=Rc(null,t,e,r,n);break a}if(a===A){t.tag=10,t.type=e,t=ul(null,t,n);break a}}throw t=pe(e)||e,Error(i(306,t,``))}}return t;case 0:return qc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=wc(r,t.pendingProps),Yc(e,t,r,a,n);case 3:a:{if(Ee(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,go(e,t),Co(t,r,null,n);var s=t.memoizedState;if(r=s.cache,ya(t,Ma,r),r!==o.cache&&Sa(t,[Ma],n,!0),So(),r=s.element,o.isDehydrated){if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=Xc(e,t,r,n);break a}if(r!==a){a=Hi(Error(i(424)),t),ha(a),t=Xc(e,t,r,n);break a}switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(ia=bm(e.firstChild),ra=t,aa=!0,oa=null,sa=!0,n=po(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|134221824,n=n.sibling}else{if(pa(),r===a){t=dl(e,t,n);break a}Ic(e,t,r,n)}t=t.child}return t;case 26:return Kc(e,t),e===null?(n=Wm(t.type,null,t.pendingProps,null))?t.memoizedState=n:aa||(t.stateNode=Cp(t.type,t.pendingProps,N.current,t)):t.memoizedState=Wm(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return Oe(t),e===null&&aa&&(r=t.stateNode=Em(t.type,t.pendingProps,N.current),ra=t,sa=!0,a=ia,Np(t.type)?(xm=a,ia=bm(r.firstChild)):ia=a),Ic(e,t,t.pendingProps.children,n),Kc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&aa&&((a=r=ia)&&(r=mm(r,t.type,t.pendingProps,sa),r===null?a=!1:(t.stateNode=r,ra=t,ia=bm(r.firstChild),sa=!1,a=!0)),a||la(t)),Oe(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,wp(a,o)?r=null:s!==null&&wp(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=ts(e,t,is,null,null,n),vh._currentValue=a),Kc(e,t),Ic(e,t,r,n),t.child;case 6:return e===null&&aa&&((e=n=ia)&&(n=hm(n,t.pendingProps,sa),n===null?e=!1:(t.stateNode=n,ra=t,ia=null,e=!0)),e||la(t)),null;case 13:return el(e,t,n);case 4:return Ee(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=B(t,null,r,n):Ic(e,t,r,n),t.child;case 11:return Lc(e,t,t.type,t.pendingProps,n);case 7:return r=t.pendingProps,Kc(e,t),Ic(e,t,r,n),t.child;case 8:return Ic(e,t,t.pendingProps.children,n),t.child;case 12:return Ic(e,t,t.pendingProps.children,n),t.child;case 10:return ul(e,t,n);case 9:return a=t.type._context,r=t.pendingProps.children,Ta(t),a=Ea(a),r=r(a),t.flags|=1,Ic(e,t,r,n),t.child;case 14:return Rc(e,t,t.type,t.pendingProps,n);case 15:return zc(e,t,t.type,t.pendingProps,n);case 19:return ll(e,t,n);case 31:return Gc(e,t,n);case 22:return Bc(e,t,n,t.pendingProps);case 24:return Ta(t),r=Ea(Ma),e===null?(a=qa(),a===null&&(a=ad,o=Na(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},ho(t),ya(t,Ma,a)):((e.lanes&n)!==0&&(go(e,t),Co(t,null,null,n),So()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,ya(t,Ma,r),r!==a.cache&&Sa(t,[Ma],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),ya(t,Ma,r))),Ic(e,t,t.pendingProps.children,n),t.child;case 30:return t.stateNode===null&&(t.stateNode={autoName:null,paired:null,clones:null,ref:null}),r=t.pendingProps,r.name!=null&&r.name!==`auto`?t.flags|=e===null?18882560:18874368:aa&&ea(t),e!==null&&e.memoizedProps.name!==r.name?t.flags|=4194816:Kc(e,t),Ic(e,t,r.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function hl(e){e.flags|=4}function gl(e,t,n,r,i){var a;if((a=!!(e.mode&32))&&(a=n===null?ah(t,r):ah(t,r)&&(r.src!==n.src||r.srcSet!==n.srcSet)),a){if(e.flags|=16777216,(i&335544128)===i){if(e.stateNode.complete)e.flags|=8192;else if(Qd())e.flags|=8192;else throw ro=$a,Za}}else e.flags&=-16777217}function _l(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!oh(t)){if(Qd())e.flags|=8192;else throw ro=$a,Za}}function vl(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:ft(),e.lanes|=t,yd|=t)}function yl(e,t){if(!aa)switch(e.tailMode){case`visible`:break;case`collapsed`:for(var n=e.tail,r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null;break;default:for(t=e.tail,n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null}}function bl(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&1206910976,r|=i.flags&1206910976,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function xl(e,t,n){var r=t.pendingProps;switch(ta(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return bl(t),null;case 1:return bl(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),ba(Ma),De(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(fa(t)?hl(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ma())),bl(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(hl(t),o===null?(bl(t),gl(t,a,null,r,n)):(bl(t),_l(t,o))):o?o===e.memoizedState?(bl(t),t.flags&=-16777217):(hl(t),bl(t),_l(t,o)):(e=e.memoizedProps,e!==r&&hl(t),bl(t),gl(t,a,e,r,n)),null;case 27:if(ke(t),n=N.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&hl(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return bl(t),t.subtreeFlags&=-33554433,null}e=Ce.current,fa(t)?ua(t,e):(e=Em(a,r,n),t.stateNode=e,hl(t))}return bl(t),t.subtreeFlags&=-33554433,null;case 5:if(ke(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&hl(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return bl(t),t.subtreeFlags&=-33554433,null}if(o=Ce.current,fa(t))ua(t,o);else{var s=bp(N.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[Ct]=t,o[F]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(pp(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&hl(t)}}return bl(t),t.subtreeFlags&=-33554433,gl(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&hl(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=N.current,fa(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=ra,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[Ct]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||up(e.nodeValue,n)),e||la(t,!0)}else e=bp(e).createTextNode(r),e[Ct]=t,t.stateNode=e}return bl(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=fa(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[Ct]=t}else pa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;bl(t),e=!1}else n=ma(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Lo(t),t):(Lo(t),null);if(t.flags&128)throw Error(i(558))}return bl(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=fa(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[Ct]=t}else pa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;bl(t),a=!1}else a=ma(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Lo(t),t):(Lo(t),null)}return Lo(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),vl(t,t.updateQueue),bl(t),null);case 4:return De(),e===null&&ep(t.stateNode.containerInfo),t.flags|=67108864,bl(t),null;case 10:return ba(t.type),bl(t),null;case 19:if(Bo(t),r=t.memoizedState,r===null)return bl(t),null;if(a=!!(t.flags&128),o=r.rendering,o===null){if(a)yl(r,!1);else{if(md!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Vo(e),o!==null){for(t.flags|=128,yl(r,!1),e=o.updateQueue,t.updateQueue=e,vl(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Fi(n,e),n=n.sibling;return zo(t,Ro.current&1|2),aa&&Qi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&He()>Td&&(t.flags|=128,a=!0,yl(r,!1),t.lanes=4194304)}}else{if(!a){if(e=Vo(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,vl(t,e),yl(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!o.alternate&&!aa)return bl(t),null}else 2*He()-r.renderingStartTime>Td&&n!==536870912&&(t.flags|=128,a=!0,yl(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=He(),e.sibling=null,o=Ro.current,o=a?o&1|2:o&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||aa?zo(t,o):(n=o,Se(jo,t),Se(Ro,n),Mo===null&&(Mo=t)),aa&&Qi(t,r.treeForkCount),e}return bl(t),null;case 22:case 23:return Lo(t),Ao(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(bl(t),t.subtreeFlags&6&&(t.flags|=8192)):bl(t),n=t.updateQueue,n!==null&&vl(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&xe(Ka),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),ba(Ma),bl(t),null;case 25:return null;case 30:return t.flags|=33554432,bl(t),null}throw Error(i(156,t.tag))}function Sl(e,t){switch(ta(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ba(Ma),De(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ke(t),null;case 31:if(t.memoizedState!==null){if(Lo(t),t.alternate===null)throw Error(i(340));pa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Lo(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));pa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Bo(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return De(),null;case 10:return ba(t.type),null;case 22:case 23:return Lo(t),Ao(),e!==null&&xe(Ka),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return ba(Ma),null;case 25:return null;default:return null}}function Cl(e,t){switch(ta(t),t.tag){case 3:ba(Ma),De();break;case 26:case 27:case 5:ke(t);break;case 4:De();break;case 31:t.memoizedState!==null&&Lo(t);break;case 13:Lo(t);break;case 19:Bo(t);break;case 10:ba(t.type);break;case 22:case 23:Lo(t),Ao(),e!==null&&xe(Ka);break;case 24:ba(Ma)}}function wl(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Cf(t,t.return,e)}}function Tl(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Cf(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Cf(t,t.return,e)}}function El(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{To(t,n)}catch(t){Cf(e,e.return,t)}}}function Dl(e,t,n){n.props=wc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Cf(e,t,n)}}function Ol(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=_i(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Gp(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Kp(e);f(e.child,!1,lm,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Cf(e,t,n)}}function kl(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){Cf(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Cf(e,t,n)}else n.current=null}}function Al(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n<t.length;n++)dm(e.stateNode,t[n])}function jl(e){for(var t=e.return;t!==null&&(Pl(t)&&dm(e.stateNode,t.stateNode),!Nl(t));)t=t.return}function Ml(e){for(var t=e.return;t!==null&&(Pl(t)&&fm(e.stateNode,t.stateNode),!Nl(t));)t=t.return}function Nl(e){return e.tag===5||e.tag===3||e.tag===27}function Pl(e){return e&&e.tag===7&&e.stateNode!==null}function Fl(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Cf(e,e.return,t)}}function Il(e,t,n){try{var r=e.stateNode;hp(r,e.type,n,t),r[F]=t}catch(t){Cf(e,e.return,t)}}function Ll(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Np(e.type)||e.tag===4}function Rl(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Ll(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Np(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function zl(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(i,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(i),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=yn)),Al(e,r),Kt=!0;else if(i!==4&&(i===27&&(Al(e,r),r=null,Np(e.type)&&(n=e.stateNode,t=null)),e=e.child,e!==null))for(zl(e,t,n,r),e=e.sibling;e!==null;)zl(e,t,n,r),e=e.sibling}function Bl(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?n.insertBefore(i,t):n.appendChild(i),Al(e,r),Kt=!0;else if(i!==4&&(i===27&&(Al(e,r),r=null,Np(e.type)&&(n=e.stateNode)),e=e.child,e!==null))for(Bl(e,t,n,r),e=e.sibling;e!==null;)Bl(e,t,n,r),e=e.sibling}function Vl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);pp(t,r,n),t[Ct]=e,t[F]=n}catch(t){Cf(e,e.return,t)}}var Hl=!1,Ul=null;function Wl(e){(e.tag===30||e.subtreeFlags&33554432)&&(Hl=!0)}var Gl=null;function Kl(){var e=Gl;return Gl=null,e}var ql=0;function Jl(e,t,n,r,i){return ql=0,Yl(e.child,t,n,r,i)}function Yl(e,t,n,r,i){for(var a=!1;e!==null;){if(e.tag===5){var o=e.stateNode;if(r!==null){var s=zp(o);r.push(s),s.view&&(a=!0)}else a||zp(o).view&&(a=!0);Hl=!0,Ip(o,ql===0?t:t+`_`+ql,n),ql++}else e.tag===22&&e.memoizedState!==null||e.tag===30&&i||Yl(e.child,t,n,r,i)&&(a=!0);e=e.sibling}return a}function Xl(e,t){for(;e!==null;)e.tag===5?Lp(e.stateNode,e.memoizedProps):e.tag===22&&e.memoizedState!==null||e.tag===30&&t||Xl(e.child,t),e=e.sibling}function Zl(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if((e.tag!==22||e.memoizedState===null)&&(Zl(e),e.tag===30&&e.flags&18874368&&e.stateNode.paired)){var t=e.memoizedProps;if(t.name==null||t.name===`auto`)throw Error(i(544));var n=t.name;t=yi(t.default,t.share),t!==`none`&&(Jl(e,n,t,null,!1)||Xl(e.child,!1))}e=e.sibling}}function Ql(e,t){if(e.tag===30){var n=e.stateNode,r=e.memoizedProps,i=_i(r,n),a=yi(r.default,n.paired?r.share:r.enter);a===`none`?Zl(e):Jl(e,i,a,null,!1)?(Zl(e),n.paired||t||Hd(e,r.onEnter)):Xl(e.child,!1)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Ql(e,t),e=e.sibling;else Zl(e)}function $l(e){if(Ul!==null&&Ul.size!==0){var t=Ul;if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var n=e.memoizedProps,r=n.name;if(r!=null&&r!==`auto`){var i=t.get(r);if(i!==void 0){var a=yi(n.default,n.share);if(a!==`none`&&(Jl(e,r,a,null,!1)?(a=e.stateNode,i.paired=a,a.paired=i,Hd(e,n.onShare)):Xl(e.child,!1)),t.delete(r),t.size===0)break}}}$l(e)}e=e.sibling}}}function eu(e){if(e.tag===30){var t=e.memoizedProps,n=_i(t,e.stateNode),r=Ul===null?void 0:Ul.get(n),i=yi(t.default,r===void 0?t.exit:t.share);i!==`none`&&(Jl(e,n,i,null,!1)?r===void 0?Hd(e,t.onExit):(i=e.stateNode,r.paired=i,i.paired=r,Ul.delete(n),Hd(e,t.onShare)):Xl(e.child,!1)),Ul!==null&&$l(e)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)eu(e),e=e.sibling;else Ul!==null&&$l(e)}function tu(e){for(e=e.child;e!==null;){if(e.tag===30){var t=e.memoizedProps,n=_i(t,e.stateNode);t=yi(t.default,t.update),e.flags&=-5,t!==`none`&&Jl(e,n,t,e.memoizedState=[],!1)}else e.subtreeFlags&33554432&&tu(e);e=e.sibling}}function nu(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var t=e.stateNode;t.paired!==null&&(t.paired=null,Xl(e.child,!1))}nu(e)}e=e.sibling}}function ru(e){if(e.tag===30)e.stateNode.paired=null,Xl(e.child,!1),nu(e);else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)ru(e),e=e.sibling;else nu(e)}function iu(e){for(e=e.child;e!==null;)e.tag===30?Xl(e.child,!1):e.subtreeFlags&33554432&&iu(e),e=e.sibling}function au(e,t,n,r,i,a,o){for(var s=!1;t!==null;){if(t.tag===5){var c=t.stateNode;if(a!==null&&ql<a.length){var l=a[ql],u=zp(c);(l.view||u.view)&&(s=!0);var d;if(d=!(e.flags&4)){if(u.clip)d=!0;else{d=l.rect;var f=u.rect;d=d.y!==f.y||d.x!==f.x||d.height!==f.height||d.width!==f.width}}d&&(e.flags|=4),u.abs?u=!l.abs:(l=l.rect,u=u.rect,u=l.height!==u.height||l.width!==u.width),u&&(e.flags|=32)}else e.flags|=32;e.flags&4&&Ip(c,ql===0?n:n+`_`+ql,i),s&&e.flags&4||(Gl===null&&(Gl=[]),Gl.push(c,ql===0?r:r+`_`+ql,t.memoizedProps)),ql++}else(t.tag!==22||t.memoizedState===null)&&(t.tag===30&&o?e.flags|=t.flags&32:au(e,t.child,n,r,i,a,o)&&(s=!0));t=t.sibling}return s}function ou(e,t){for(e=e.child;e!==null;){if(e.tag===30){var n=e.memoizedProps,r=e.stateNode,i=_i(n,r),a=yi(n.default,n.update);if(t){r=r.clones;var o=r===null?null:r.map(Bp)}else o=e.memoizedState,e.memoizedState=null;r=e;var s=e.child;ql=0,i=au(r,s,i,i,a,o,!1),e.flags&4&&i&&(t||Hd(e,n.onUpdate))}else e.subtreeFlags&33554432&&ou(e,t);e=e.sibling}}var su=!1,cu=!1,lu=!1,uu=!1,du=typeof WeakSet==`function`?WeakSet:Set,fu=null,pu=!1,mu=!1,hu=!1,gu=!1;function _u(e,t,n){if(e=e.containerInfo,vp=Dh,e=qr(e),Jr(e)){if(`selectionStart`in e)var r={start:e.selectionStart,end:e.selectionEnd};else a:{r=(r=e.ownerDocument)&&r.defaultView||window;var i=r.getSelection&&r.getSelection();if(i&&i.rangeCount!==0){r=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{r.nodeType,o.nodeType}catch{r=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==r||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===r&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}r=c===-1||l===-1?null:{start:c,end:l}}else r=null}r||={start:0,end:0}}else r=null;for(yp={focusedElem:e,selectionRange:r},Dh=!1,n=(n&335544064)===n,fu=t,t=n?9270:1024;fu!==null;){if(e=fu,n&&(r=e.deletions,r!==null))for(a=0;a<r.length;a++)n&&eu(r[a]);if(e.alternate===null&&e.flags&2)n&&Wl(e),vu(n);else{if(e.tag===22){if(r=e.alternate,e.memoizedState!==null){r!==null&&r.memoizedState===null&&n&&eu(r),vu(n);continue}if(r!==null&&r.memoizedState!==null){n&&Wl(e),vu(n);continue}}r=e.child,(e.subtreeFlags&t)!==0&&r!==null?(r.return=e,fu=r):(n&&tu(e),vu(n))}}Ul=null}function vu(e){for(;fu!==null;){var t=fu,n=e,r=t.alternate,a=t.flags;switch(t.tag){case 0:case 11:case 15:break;case 1:if(a&1024&&r!==null){n=void 0,a=r.memoizedProps,r=r.memoizedState;var o=t.stateNode;try{var s=wc(t.type,a);n=o.getSnapshotBeforeUpdate(s,r),o.__reactInternalSnapshotBeforeUpdate=n}catch(e){Cf(t,t.return,e)}}break;case 3:if(a&1024){if(r=t.stateNode.containerInfo,n=r.nodeType,n===9)pm(r);else if(n===1)switch(r.nodeName){case`HEAD`:case`HTML`:case`BODY`:pm(r);break;default:r.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;case 30:n&&r!==null&&(n=_i(r.memoizedProps,r.stateNode),a=t.memoizedProps,a=yi(a.default,a.update),a!==`none`&&Jl(r,n,a,r.memoizedState=[],!0));break;default:if(a&1024)throw Error(i(163))}if(r=t.sibling,r!==null){r.return=t.return,fu=r;break}fu=t.return}}function yu(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:zu(e,n),r&4&&wl(5,n);break;case 1:if(zu(e,n),r&4){if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Cf(n,n.return,e)}else{var i=wc(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Cf(n,n.return,e)}}}r&64&&El(n),r&512&&Ol(n,n.return);break;case 3:if(zu(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{To(e,t)}catch(e){Cf(n,n.return,e)}}break;case 27:t===null&&r&4&&Vl(n);case 26:case 5:zu(e,n),t===null&&r&4&&Fl(n),r&512&&Ol(n,n.return);break;case 12:zu(e,n);break;case 31:zu(e,n),r&4&&Ou(e,n);break;case 13:zu(e,n),r&4&&ku(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=Df.bind(null,n),ym(e,n))));break;case 22:if(r=n.memoizedState!==null||su,!r){var a=t!==null&&t.memoizedState!==null||cu;t=su,i=cu,su=r,(cu=a)&&!i?(r=2,n.subtreeFlags&8772&&(r|=1),Vu(e,n,r)):zu(e,n),su=t,cu=i}break;case 30:zu(e,n),r&512&&Ol(n,n.return);break;case 7:r&512&&Ol(n,n.return);default:zu(e,n)}}function bu(e,t){for(e=e.child;e!==null;)xu(e,t),e=e.sibling}function xu(e,t){switch(e.tag){case 5:case 26:try{var n=e.stateNode;if(t){var r=n.style;typeof r.setProperty==`function`?r.setProperty(`display`,`none`,`important`):r.display=`none`}else{var i=e.stateNode,a=e.memoizedProps.style,o=a!=null&&a.hasOwnProperty(`display`)?a.display:null;i.style.display=o==null||typeof o==`boolean`?``:(``+o).trim()}}catch(t){Cf(e,e.return,t)}Su(e,t);break;case 6:try{e.stateNode.nodeValue=t?``:e.memoizedProps,Kt=!0}catch(t){Cf(e,e.return,t)}break;case 18:try{var s=e.stateNode;t?Fp(s,!0):Fp(e.stateNode,!1)}catch(t){Cf(e,e.return,t)}break;case 22:case 23:e.memoizedState===null&&bu(e,t);break;default:bu(e,t)}}function Su(e,t){if(e.subtreeFlags&67108864)for(e=e.child;e!==null;){a:{var n=e,r=t;switch(n.tag){case 4:xu(n,r);break a;case 22:n.memoizedState===null&&Su(n,r);break a;default:Su(n,r)}}e=e.sibling}}function Cu(e){var t=e.alternate;t!==null&&(e.alternate=null,Cu(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&jt(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var wu=null,Tu=!1;function Eu(e,t,n){for(n=n.child;n!==null;)Du(e,t,n),n=n.sibling}function Du(e,t,n){if(Qe&&typeof Qe.onCommitFiberUnmount==`function`)try{Qe.onCommitFiberUnmount(Ze,n)}catch{}switch(n.tag){case 26:cu||kl(n,t),Eu(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&!cu&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:cu||kl(n,t),Ml(n);var r=wu,i=Tu;Np(n.type)&&(wu=n.stateNode,Tu=!1),Eu(e,t,n),Dm(n.stateNode,n.type,n.memoizedProps),wu=r,Tu=i;break;case 5:cu||kl(n,t),Ml(n);case 6:if(n.tag===6&&Ml(n),r=wu,i=Tu,wu=null,Eu(e,t,n),wu=r,Tu=i,wu!==null){if(Tu)try{(wu.nodeType===9?wu.body:wu.nodeName===`HTML`?wu.ownerDocument.body:wu).removeChild(n.stateNode),Kt=!0}catch(e){Cf(n,t,e)}else try{wu.removeChild(n.stateNode),Kt=!0}catch(e){Cf(n,t,e)}}break;case 18:wu!==null&&(Tu?(e=wu,Pp(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),$h(e)):Pp(wu,n.stateNode));break;case 4:r=wu,i=Tu,wu=n.stateNode.containerInfo,Tu=!0,Eu(e,t,n),wu=r,Tu=i;break;case 0:case 11:case 14:case 15:Tl(2,n,t),cu||Tl(4,n,t),Eu(e,t,n);break;case 1:cu||(kl(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Dl(n,t,r)),Eu(e,t,n);break;case 21:Eu(e,t,n);break;case 22:cu=(r=cu)||n.memoizedState!==null,Eu(e,t,n),cu=r;break;case 30:kl(n,t),Eu(e,t,n);break;case 7:cu||kl(n,t),Eu(e,t,n);break;default:Eu(e,t,n)}}function Ou(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{$h(e)}catch(e){Cf(t,t.return,e)}}}function ku(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{$h(e)}catch(e){Cf(t,t.return,e)}}function Au(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new du),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new du),t;default:throw Error(i(435,e.tag))}}function ju(e,t){var n=Au(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=Of.bind(null,e,t);t.then(r,r)}})}function Mu(e,t,n){var r=t.deletions;if(r!==null)for(var a=0;a<r.length;a++){var o=r[a],s=e,c=t,l=c;a:for(;l!==null;){switch(l.tag){case 27:if(Np(l.type)){wu=l.stateNode,Tu=!1;break a}break;case 5:wu=l.stateNode,Tu=!1;break a;case 3:case 4:wu=l.stateNode.containerInfo,Tu=!0;break a}l=l.return}if(wu===null)throw Error(i(160));Du(s,c,o),wu=null,Tu=!1,s=o.alternate,s!==null&&(s.return=null),o.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Pu(t,e,n),t=t.sibling}var Nu=null;function Pu(e,t,n){var r=e.alternate,a=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(a&4&&(r=e.updateQueue,r=r===null?null:r.events,r!==null))for(var o=0;o<r.length;o++){var s=r[o];s.ref.impl=s.nextImpl}Mu(t,e,n),Fu(e),a&4&&(Tl(3,e,e.return),wl(3,e),Tl(5,e,e.return));break;case 1:Mu(t,e,n),Fu(e),a&512&&(cu||r===null||kl(r,r.return)),a&64&&su&&(e=e.updateQueue,e!==null&&(t=e.callbacks,t!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?t:n.concat(t))));break;case 26:if(o=Nu,Mu(t,e,n),Fu(e),a&512&&(cu||r===null||kl(r,r.return)),a&4){if(a=r===null?null:r.memoizedState,n=e.memoizedState,r===null){if(n===null){if(e.stateNode===null){if(su)e.stateNode=Cp(e.type,e.memoizedProps,t.containerInfo,e);else{a:{t=e.type,n=e.memoizedProps,a=o.ownerDocument||o;b:switch(t){case`title`:r=a.getElementsByTagName(`title`)[0],(!r||r[kt]||r[Ct]||r.namespaceURI===`http://www.w3.org/2000/svg`||r.hasAttribute(`itemprop`))&&(r=a.createElement(t),a.head.insertBefore(r,a.querySelector(`head > title`))),pp(r,t,n),r[Ct]=e,It(r),t=r;break a;case`link`:if(o=nh(`link`,`href`,a).get(t+(n.href||``))){for(s=0;s<o.length;s++)if(r=o[s],r.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&r.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&r.getAttribute(`title`)===(n.title==null?null:n.title)&&r.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){o.splice(s,1);break b}}r=a.createElement(t),pp(r,t,n),a.head.appendChild(r);break;case`meta`:if(o=nh(`meta`,`content`,a).get(t+(n.content||``))){for(s=0;s<o.length;s++)if(r=o[s],r.getAttribute(`content`)===(n.content==null?null:``+n.content)&&r.getAttribute(`name`)===(n.name==null?null:n.name)&&r.getAttribute(`property`)===(n.property==null?null:n.property)&&r.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&r.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){o.splice(s,1);break b}}r=a.createElement(t),pp(r,t,n),a.head.appendChild(r);break;default:throw Error(i(468,t))}r[Ct]=e,It(r),t=r}e.stateNode=t}}else su||rh(o,e.type,e.stateNode)}else e.stateNode=Zm(o,n,e.memoizedProps)}else a===n?n===null&&e.stateNode!==null&&Il(e,e.memoizedProps,r.memoizedProps):(a===null?(t=r.stateNode,t===null||cu||t.parentNode.removeChild(t)):a.count--,n===null?su||rh(o,e.type,e.stateNode):Zm(o,n,e.memoizedProps))}break;case 27:Mu(t,e,n),Fu(e),a&512&&(cu||r===null||kl(r,r.return)),r!==null&&a&4&&Il(e,e.memoizedProps,r.memoizedProps);break;case 5:if(o=lu,lu=!1,Mu(t,e,n),lu=o,Fu(e),a&512&&(cu||r===null||kl(r,r.return)),e.flags&32){t=e.stateNode;try{dn(t,``),Kt=!0}catch(t){Cf(e,e.return,t)}}a&4&&e.stateNode!=null&&(t=e.memoizedProps,Il(e,t,r===null?t:r.memoizedProps)),a&1024&&(uu=!0);break;case 6:if(Mu(t,e,n),Fu(e),a&4){if(e.stateNode===null)throw Error(i(162));t=e.memoizedProps,n=e.stateNode;try{n.nodeValue=t,Kt=!0}catch(t){Cf(e,e.return,t)}}break;case 3:if(Kt=!1,th=null,o=Nu,Nu=jm(t.containerInfo),Mu(t,e,n),Nu=o,Fu(e),a&4&&r!==null&&r.memoizedState.isDehydrated)try{$h(t.containerInfo)}catch(t){Cf(e,e.return,t)}uu&&(uu=!1,Iu(e)),Kt=!1;break;case 4:a=lu,lu=su,r=qt(),o=Nu,Nu=jm(e.stateNode.containerInfo),Mu(t,e,n),Fu(e),Nu=o,Kt&&mu&&(hu=!0),Kt=r,lu=a;break;case 12:Mu(t,e,n),Fu(e);break;case 31:Mu(t,e,n),Fu(e),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,ju(e,t)));break;case 13:Mu(t,e,n),Fu(e),e.child.flags&8192&&e.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(Cd=He()),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,ju(e,t)));break;case 22:o=e.memoizedState!==null,s=r!==null&&r.memoizedState!==null;var c=su,l=cu,u=lu;su=c||o,lu=u||o,cu=l||s,Mu(t,e,n),cu=l,lu=u,su=c,Fu(e),a&8192&&(t=e.stateNode,t._visibility=o?t._visibility&-2:t._visibility|1,!o||r===null||s||su||cu||(t=s||cu,n=su,r=cu,su=o||su,cu=t,Bu(e,2),su=n,cu=r),!o&&lu||bu(e,o)),a&4&&(t=e.updateQueue,t!==null&&(n=t.retryQueue,n!==null&&(t.retryQueue=null,ju(e,n))));break;case 19:Mu(t,e,n),Fu(e),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,ju(e,t)));break;case 30:a&512&&(cu||r===null||kl(r,r.return)),a=qt(),o=mu,s=(n&335544064)===n,c=e.memoizedProps,mu=s&&yi(c.default,c.update)!==`none`,Mu(t,e,n),Fu(e),s&&r!==null&&Kt&&(e.flags|=4),mu=o,Kt=a;break;case 21:break;case 7:a&512&&(cu||r===null||kl(r,r.return)),r&&r.stateNode!==null&&(r.stateNode._fragmentFiber=e);default:Mu(t,e,n),Fu(e)}}function Fu(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Ll(r)){n=r;break}r=r.return}r=null;for(var a=e.return;a!==null;){if(Pl(a)){var o=a.stateNode;r===null?r=[o]:r.push(o)}if(Nl(a))break;a=a.return}var s=r;if(n==null)throw Error(i(160));switch(n.tag){case 27:var c=n.stateNode;Bl(e,Rl(e),c,s);break;case 5:var l=n.stateNode;n.flags&32&&(dn(l,``),n.flags&=-33),Bl(e,Rl(e),l,s);break;case 3:case 4:var u=n.stateNode.containerInfo;zl(e,Rl(e),u,s);break;default:throw Error(i(161))}}catch(t){Cf(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Iu(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Iu(t),t.tag===5&&t.flags&1024&&(t=t.stateNode,Dh=!0,t.reset(),Dh=!1),e=e.sibling}}function Lu(e,t){if(t.subtreeFlags&9270)for(t=t.child;t!==null;)Ru(t,e),t=t.sibling;else ou(t,!1)}function Ru(e,t){var n=e.alternate;if(n===null)Ql(e,!1);else switch(e.tag){case 3:if(gu=pu=!1,Kl(),Lu(t,e),!pu&&!hu){if(e=Gl,e!==null)for(var r=0;r<e.length;r+=3){n=e[r];var i=e[r+1];Lp(n,e[r+2]),n=n.ownerDocument.documentElement,n!==null&&n.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(`+i+`)`})}e=t.containerInfo,e=e.nodeType===9?e.documentElement:e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===``&&(e.style.viewTransitionName=`none`,e.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(root)`}),e.animate({width:[0,0],height:[0,0]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition`})),gu=!0}Gl=null;break;case 5:Lu(t,e);break;case 4:r=pu,pu=!1,Lu(t,e),pu&&(hu=!0),pu=r;break;case 22:e.memoizedState===null&&(n.memoizedState===null?Lu(t,e):Ql(e,!1));break;case 30:r=pu,i=Kl(),pu=!1,Lu(t,e),pu&&(e.flags|=4);var a=e.memoizedProps,o=e.stateNode;t=_i(a,o),o=_i(n.memoizedProps,o);var s=yi(a.default,a.update);s===`none`?t=!1:(a=n.memoizedState,n.memoizedState=null,n=e.child,ql=0,t=au(e,n,t,o,s,a,!0),ql!==(a===null?0:a.length)&&(e.flags|=32)),e.flags&4&&t?(Hd(e,e.memoizedProps.onUpdate),Gl=i):i!==null&&(i.push.apply(i,Gl),Gl=i),pu=e.flags&32?!0:r;break;default:Lu(t,e)}}function zu(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)yu(e,t.alternate,t),t=t.sibling}function Bu(e,t){for(e=e.child;e!==null;){var n=e,r=t;switch(n.tag){case 0:case 11:case 14:case 15:Tl(4,n,n.return),Bu(n,r);break;case 1:kl(n,n.return);var i=n.stateNode;typeof i.componentWillUnmount==`function`&&Dl(n,n.return,i),Bu(n,r);break;case 27:r&2&&Dm(n.stateNode,n.type,n.memoizedProps);case 5:kl(n,n.return),n.tag!==5&&n.tag!==27||Ml(n),Bu(n,r);break;case 6:Ml(n);break;case 26:kl(n,n.return),i=n.stateNode,n.memoizedState!==null||i===null||cu||i.parentNode.removeChild(i),Bu(n,r);break;case 22:n.memoizedState===null&&Bu(n,r);break;case 30:kl(n,n.return),Bu(n,r);break;case 7:kl(n,n.return);default:Bu(n,r)}e=e.sibling}}function Vu(e,t,n){for(n=t.subtreeFlags&8772?n:n&-2,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags,s=!!(n&1);switch(a.tag){case 0:case 11:case 15:Vu(i,a,n),wl(4,a);break;case 1:if(Vu(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Cf(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var c=r.stateNode;try{var l=i.shared.hiddenCallbacks;if(l!==null)for(i.shared.hiddenCallbacks=null,i=0;i<l.length;i++)wo(l[i],c)}catch(e){Cf(r,r.return,e)}}s&&o&64&&El(a),Ol(a,a.return);break;case 27:n&2&&Vl(a);case 5:a.tag!==5&&a.tag!==27||jl(a),Vu(i,a,n),s&&r===null&&o&4&&Fl(a),Ol(a,a.return);break;case 6:jl(a);break;case 26:c=a.stateNode,a.memoizedState!==null||c===null||su||rh(jm(c.ownerDocument),a.type,c),Vu(i,a,n),s&&r===null&&o&4&&Fl(a),Ol(a,a.return);break;case 12:Vu(i,a,n);break;case 31:Vu(i,a,n),s&&o&4&&Ou(i,a);break;case 13:Vu(i,a,n),s&&o&4&&ku(i,a);break;case 22:a.memoizedState===null&&Vu(i,a,n),Ol(a,a.return);break;case 30:Vu(i,a,n),Ol(a,a.return);break;case 7:Ol(a,a.return);default:Vu(i,a,n)}t=t.sibling}}function Hu(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&Pa(n))}function Uu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Pa(e))}function Wu(e,t,n,r){var i=(n&335544064)===n;if(t.subtreeFlags&(i?10262:10256))for(t=t.child;t!==null;)Gu(e,t,n,r),t=t.sibling;else i&&iu(t)}function Gu(e,t,n,r){var i=(n&335544064)===n;i&&t.alternate===null&&t.return!==null&&t.return.alternate!==null&&ru(t);var a=t.flags;switch(t.tag){case 0:case 11:case 15:Wu(e,t,n,r),a&2048&&wl(9,t);break;case 1:Wu(e,t,n,r);break;case 3:Wu(e,t,n,r),i&&gu&&(e=e.containerInfo,e=e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,e.style.viewTransitionName===`root`&&(e.style.viewTransitionName=``),e=e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===`none`&&(e.style.viewTransitionName=``)),a&2048&&(a=null,t.alternate!==null&&(a=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==a&&(t.refCount++,a!=null&&Pa(a)));break;case 12:if(a&2048){Wu(e,t,n,r),a=t.stateNode;try{var o=t.memoizedProps,s=o.id,c=o.onPostCommit;typeof c==`function`&&c(s,t.alternate===null?`mount`:`update`,a.passiveEffectDuration,-0)}catch(e){Cf(t,t.return,e)}}else Wu(e,t,n,r);break;case 31:Wu(e,t,n,r);break;case 13:Wu(e,t,n,r);break;case 23:break;case 22:o=t.stateNode,s=t.alternate,t.memoizedState===null?(i&&s!==null&&s.memoizedState!==null&&ru(t),o._visibility&2?Wu(e,t,n,r):(o._visibility|=2,Ku(e,t,n,r,!!(t.subtreeFlags&10256)||!1))):(i&&s!==null&&s.memoizedState===null&&ru(s),o._visibility&2?Wu(e,t,n,r):qu(e,t)),a&2048&&Hu(s,t);break;case 24:Wu(e,t,n,r),a&2048&&Uu(t.alternate,t);break;case 30:i&&(a=t.alternate,a!==null&&(Xl(a.child,!0),Xl(t.child,!0))),Wu(e,t,n,r);break;default:Wu(e,t,n,r)}}function Ku(e,t,n,r,i){for(i&&=!!(t.subtreeFlags&10256)||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:Ku(a,o,s,c,i),wl(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Ku(a,o,s,c,i)):u._visibility&2?Ku(a,o,s,c,i):qu(a,o),i&&l&2048&&Hu(o.alternate,o);break;case 24:Ku(a,o,s,c,i),i&&l&2048&&Uu(o.alternate,o);break;default:Ku(a,o,s,c,i)}t=t.sibling}}function qu(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:qu(n,r),i&2048&&Hu(r.alternate,r);break;case 24:qu(n,r),i&2048&&Uu(r.alternate,r);break;default:qu(n,r)}t=t.sibling}}var Ju=8192;function Yu(e,t,n){if(e.subtreeFlags&Ju)for(e=e.child;e!==null;)Xu(e,t,n),e=e.sibling}function Xu(e,t,n){switch(e.tag){case 26:Yu(e,t,n),e.flags&Ju&&(e.memoizedState===null?(e=e.stateNode,(t&335544128)===t&&ch(n,e)):lh(n,Nu,e.memoizedState,e.memoizedProps));break;case 5:Yu(e,t,n),e.flags&Ju&&(e=e.stateNode,(t&335544128)===t&&ch(n,e));break;case 3:case 4:var r=Nu;Nu=jm(e.stateNode.containerInfo),Yu(e,t,n),Nu=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Ju,Ju=16777216,Yu(e,t,n),Ju=r):Yu(e,t,n));break;case 30:if((e.flags&Ju)!==0&&(r=e.memoizedProps.name,r!=null&&r!==`auto`)){var i=e.stateNode;i.paired=null,Ul===null&&(Ul=new Map),Ul.set(r,i)}Yu(e,t,n);break;default:Yu(e,t,n)}}function Zu(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Qu(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];fu=r,td(r,e)}Zu(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)$u(e),e=e.sibling}function $u(e){switch(e.tag){case 0:case 11:case 15:Qu(e),e.flags&2048&&Tl(9,e,e.return);break;case 3:Qu(e);break;case 12:Qu(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,ed(e)):Qu(e);break;default:Qu(e)}}function ed(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];fu=r,td(r,e)}Zu(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Tl(8,t,t.return),ed(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,ed(t));break;default:ed(t)}e=e.sibling}}function td(e,t){for(;fu!==null;){var n=fu;switch(n.tag){case 0:case 11:case 15:Tl(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:Pa(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,fu=r;else a:for(n=e;fu!==null;){r=fu;var i=r.sibling,a=r.return;if(Cu(r),r===n){fu=null;break a}if(i!==null){i.return=a,fu=i;break a}fu=a}}}var nd={getCacheForType:function(e){var t=Ea(Ma),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Ea(Ma).controller.signal}},rd=typeof WeakMap==`function`?WeakMap:Map,id=0,ad=null,od=null,sd=0,cd=0,ld=null,ud=!1,dd=!1,fd=!1,pd=0,md=0,hd=0,gd=0,_d=0,vd=0,yd=0,bd=null,xd=null,Sd=!1,Cd=0,wd=0,Td=1/0,Ed=null,Dd=null,Od=0,kd=null,Ad=null,jd=0,Md=0,Nd=null,Pd=null,Fd=null,Id=null,Ld=null,Rd=0,zd=null;function Bd(){return id&2&&sd!==0?sd&-sd:he.T===null?P():Uf()}function Vd(){if(vd===0){if(!(sd&536870912)||aa){var e=at;at<<=1,!(at&3932160)&&(at=262144),vd=e}else vd=536870912}return e=jo.current,e!==null&&(e.flags|=32),vd}function Hd(e,t){if(t!=null){var n=e.stateNode,r=n.ref;r===null&&(r=n.ref=Gp(_i(e.memoizedProps,n))),Id===null&&(Id=[]),Id.push(t.bind(null,r))}}function Ud(e,t,n){(e===ad&&(cd===2||cd===9)||e.cancelPendingCommit!==null)&&(Xd(e,0),qd(e,sd,vd,!1)),mt(e,n),id&2&&e===ad||(e===ad&&(!(id&2)&&(gd|=n),md===4&&qd(e,sd,vd,!1)),If(e))}function Wd(e,t,n){if(id&6)throw Error(i(327));var r=!n&&!(t&127)&&(t&e.expiredLanes)===0||lt(e,t),a=r?af(e,t):nf(e,t,!0),o=r;do{if(a===0){dd&&!r&&qd(e,t,0,!1);break}if(n=e.current.alternate,o&&!Kd(n))a=nf(e,t,!1),o=!1;else{if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=bd;var l=c.current.memoizedState.isDehydrated;if(l&&(Xd(c,s).flags|=256),s=nf(c,s,!1),s!==2&&s!==6){if(fd&&!l){c.errorRecoveryDisabledLanes|=o,gd|=o,a=4;break a}o=xd,xd=a,o!==null&&(xd===null?xd=o:xd.push.apply(xd,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){Xd(e,0),qd(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t&&(t&62914560)!==t)break;case 6:qd(r,t,vd,!ud);break a;case 2:xd=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=Cd+300-He(),10<a)){if(qd(r,t,vd,!ud),ct(r,0,!0)!==0)break a;jd=t,r.timeoutHandle=Dp(Gd.bind(null,r,n,xd,Ed,Sd,t,vd,gd,yd,ud,o,`Throttled`,-0,0),a);break a}Gd(r,n,xd,Ed,Sd,t,vd,gd,yd,ud,o,null,-0,0)}break}}while(1);If(e)}function Gd(e,t,n,r,i,a,o,s,c,l,u,d,f,p){e.timeoutHandle=-1;var m=t.subtreeFlags,h=(a&335544064)===a;d=null,(h||m&8192||(m&16785408)==16785408)&&(d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:yn},Ul=null,Xu(t,a,d),h&&(m=d,h=e.containerInfo,h=(h.nodeType===9?h:h.ownerDocument).__reactViewTransition,h!=null&&(m.count++,m.waitingForViewTransition=!0,m=ph.bind(m),h.finished.then(m,m))),m=(a&62914560)===a?Cd-He():(a&4194048)===a?wd-He():0,m=dh(d,m),m!==null)?(jd=a,e.cancelPendingCommit=m(ff.bind(null,e,t,a,n,r,i,o,s,c,l,u,d,null,f,p)),qd(e,a,o,!l)):ff(e,t,a,n,r,i,o,s,c,l,u,d)}function Kd(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!Vr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function qd(e,t,n,r){t=ut(e,t),t&=~_d,t&=~gd,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-et(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&gt(e,n,t)}function Jd(){return id&6?!0:(Lf(0,!1),!1)}function Yd(){if(od!==null){if(cd===0)var e=od.return;else e=od,va=_a=null,ss(e),oo=null,so=0,e=od;for(;e!==null;)Cl(e.alternate,e),e=e.return;od=null}}function Xd(e,t){var n=e.timeoutHandle;return n!==-1&&(e.timeoutHandle=-1,Op(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),jd=0,Yd(),ad=e,od=n=Pi(e.current,null),sd=t,cd=0,ld=null,ud=!1,dd=lt(e,t),fd=!1,yd=vd=_d=gd=hd=md=0,xd=bd=null,Sd=!1,pd=ut(e,t),wi(),n}function Zd(e,t){Uo=null,he.H=_c,t===Xa||t===Qa?(t=io(),cd=3):t===Za?(t=io(),cd=4):cd=t===Pc?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,ld=t,od===null&&(md=1,Oc(e,Hi(t,e.current)))}function Qd(){var e=jo.current;return e===null?!0:(sd&4194048)===sd?Mo===null:(sd&62914560)===sd||sd&536870912?e===Mo:!1}function $d(){var e=he.H;return he.H=_c,e===null?_c:e}function ef(){var e=he.A;return he.A=nd,e}function tf(){md=4,ud||(sd&4194048)!==sd&&jo.current!==null||(dd=!0),!(hd&134217727)&&!(gd&134217727)||ad===null||qd(ad,sd,vd,!1)}function nf(e,t,n){var r=id;id|=2;var i=$d(),a=ef();(ad!==e||sd!==t)&&(Ed=null,Xd(e,t)),t=!1;var o=md;a:do try{if(cd!==0&&od!==null){var s=od,c=ld;switch(cd){case 8:Yd(),o=6;break a;case 3:case 2:case 9:case 6:jo.current===null&&(t=!0);var l=cd;if(cd=0,ld=null,lf(e,s,c,l),n&&dd){o=0;break a}break;default:l=cd,cd=0,ld=null,lf(e,s,c,l)}}rf(),o=md;break}catch(t){Zd(e,t)}while(1);return t&&e.shellSuspendCounter++,va=_a=null,id=r,he.H=i,he.A=a,od===null&&(ad=null,sd=0,wi()),o}function rf(){for(;od!==null;)sf(od)}function af(e,t){var n=id;id|=2;var r=$d(),a=ef();ad!==e||sd!==t?(Ed=null,Td=He()+500,Xd(e,t)):dd=lt(e,t);a:do try{if(cd!==0&&od!==null){t=od;var o=ld;b:switch(cd){case 1:cd=0,ld=null,lf(e,t,o,1);break;case 2:case 9:if(eo(o)){cd=0,ld=null,cf(t);break}t=function(){cd!==2&&cd!==9||ad!==e||(cd=7),If(e)},o.then(t,t);break a;case 3:cd=7;break a;case 4:cd=5;break a;case 7:eo(o)?(cd=0,ld=null,cf(t)):(cd=0,ld=null,lf(e,t,o,7));break;case 5:var s=null;switch(od.tag){case 26:s=od.memoizedState;case 5:case 27:var c=od;if(s?oh(s):c.stateNode.complete){cd=0,ld=null;var l=c.sibling;if(l!==null)od=l;else{var u=c.return;u===null?od=null:(od=u,uf(u))}break b}}cd=0,ld=null,lf(e,t,o,5);break;case 6:cd=0,ld=null,lf(e,t,o,6);break;case 8:Yd(),md=6;break a;default:throw Error(i(462))}}of();break}catch(t){Zd(e,t)}while(1);return va=_a=null,he.H=r,he.A=a,id=n,od===null?(ad=null,sd=0,wi(),md):0}function of(){for(;od!==null&&!Be();)sf(od)}function sf(e){var t=ml(e.alternate,e,pd);e.memoizedProps=e.pendingProps,t===null?uf(e):od=t}function cf(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Jc(n,t,t.pendingProps,t.type,void 0,sd);break;case 11:t=Jc(n,t,t.pendingProps,t.type.render,t.ref,sd);break;case 5:ss(t);var r=t;r===ra&&(aa?(da(r),r.tag===5&&r.stateNode!=null&&(ia=r.stateNode)):(da(r),aa=!0));default:Cl(n,t),t=od=Fi(t,pd),t=ml(n,t,pd)}e.memoizedProps=e.pendingProps,t===null?uf(e):od=t}function lf(e,t,n,r){va=_a=null,ss(t),oo=null,so=0;var i=t.return;try{if(Nc(e,i,t,n,sd)){md=1,Oc(e,Hi(n,e.current)),od=null;return}}catch(t){if(i!==null)throw od=i,t;md=1,Oc(e,Hi(n,e.current)),od=null;return}t.flags&32768?(aa||r===1?e=!0:dd||sd&536870912?e=!1:(ud=e=!0,(r===2||r===9||r===3||r===6)&&(r=jo.current,r!==null&&r.tag===13&&(r.flags|=16384))),df(t,e)):uf(t)}function uf(e){var t=e;do{if(t.flags&32768){df(t,ud);return}e=t.return;var n=xl(t.alternate,t,pd);if(n!==null){od=n;return}if(t=t.sibling,t!==null){od=t;return}od=t=e}while(t!==null);md===0&&(md=5)}function df(e,t){do{var n=Sl(e.alternate,e);if(n!==null){n.flags&=32767,od=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){od=e;return}od=e=n}while(e!==null);md=6,od=null}function ff(e,t,n,r,a,o,s,c,l,u,d,f){e.cancelPendingCommit=null;do bf();while(Od!==0);if(id&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));e===ad&&(od=ad=null,sd=0),Ad=t,kd=e,jd=n,Nd=a,Pd=r,pf(e,t,n,s,c,l,f)}}function pf(e,t,n,r,i,a,o){var s=t.lanes|t.childLanes;if(Md=s,s|=Ci,ht(e,n,s,r,i,a),Id=null,(n&335544064)===n?(Ld=La(e),r=10262):(Ld=null,r=10256),(t.subtreeFlags&r)!==0||(t.flags&r)!==0?(e.callbackNode=null,e.callbackPriority=0,kf(Ke,function(){return xf(),null})):(e.callbackNode=null,e.callbackPriority=0),Hl=!1,r=!!(t.flags&13878),t.subtreeFlags&13878||r){r=he.T,he.T=null,i=ge.p,ge.p=2,a=id,id|=4;try{_u(e,t,n)}finally{id=a,ge.p=i,he.T=r}}Od=1,Hl?Fd=Up(o,e.containerInfo,Ld,gf,_f,hf,vf,xf,mf,null,null):(gf(),_f(),vf())}function mf(e){if(Od!==0){var t=kd.onRecoverableError;t(e,{componentStack:null})}}function hf(){Od===3&&(Od=0,Ru(Ad,kd),Od=4)}function gf(){if(Od===1){Od=0;var e=kd,t=Ad,n=jd,r=!!(t.flags&13878);if(t.subtreeFlags&13878||r){r=he.T,he.T=null;var i=ge.p;ge.p=2;var a=id;id|=4;try{mu=hu=!1,Pu(t,e,n),n=yp;var o=qr(e.containerInfo),s=n.focusedElem,c=n.selectionRange;if(o!==s&&s&&s.ownerDocument&&Kr(s.ownerDocument.documentElement,s)){if(c!==null&&Jr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=Gr(s,h),v=Gr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}Dh=!!vp,yp=vp=null}finally{id=a,ge.p=i,he.T=r}}e.current=t,Od=2}}function _f(){if(Od===2){Od=0;var e=kd,t=Ad,n=!!(t.flags&8772);if(t.subtreeFlags&8772||n){n=he.T,he.T=null;var r=ge.p;ge.p=2;var i=id;id|=4;try{yu(e,t.alternate,t)}finally{id=i,ge.p=r,he.T=n}}Od=3}}function vf(){if(Od===4||Od===3){Od=0;var e=Fd;Fd=null,Ve();var t=kd,n=Ad,r=jd,i=Pd,a=(r&335544064)===r?10262:10256;if((n.subtreeFlags&a)!==0||(n.flags&a)!==0?Od=5:(Od=0,Ad=kd=null,yf(t,t.pendingLanes)),a=t.pendingLanes,a===0&&(Dd=null),bt(r),n=n.stateNode,Qe&&typeof Qe.onCommitFiberRoot==`function`)try{Qe.onCommitFiberRoot(Ze,n,void 0,(n.current.flags&128)==128)}catch{}if(i!==null){n=he.T,a=ge.p,ge.p=2,he.T=null;try{for(var o=t.onRecoverableError,s=0;s<i.length;s++){var c=i[s];o(c.value,{componentStack:c.stack})}}finally{he.T=n,ge.p=a}}if(i=Id,o=Ld,Ld=null,i!==null&&(Id=null,o===null&&(o=[]),e!==null))for(c=0;c<i.length;c++)n=(0,i[c])(o),n!==void 0&&e.finished.finally(n);jd&3&&bf(),If(t),a=t.pendingLanes,r&261930&&a&42?t===zd?Rd++:(Rd=0,zd=t):(Rd=0,zd=null),Lf(0,!1)}}function yf(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Pa(t)))}function bf(){return Fd!==null&&(Fd.skipTransition(),Fd=null),gf(),_f(),vf(),xf()}function xf(){if(Od!==5)return!1;var e=kd,t=Md;Md=0;var n=bt(jd),r=he.T,a=ge.p;try{ge.p=32>n?32:n,he.T=null,n=Nd,Nd=null;var o=kd,s=jd;if(Od=0,Ad=kd=null,jd=0,id&6)throw Error(i(331));var c=id;if(id|=4,$u(o.current),Gu(o,o.current,s,n),id=c,Lf(0,!1),Qe&&typeof Qe.onPostCommitFiberRoot==`function`)try{Qe.onPostCommitFiberRoot(Ze,o)}catch{}return!0}finally{ge.p=a,he.T=r,yf(e,t)}}function Sf(e,t,n){t=Hi(n,t),t=Ac(e.stateNode,t,2),e=vo(e,t,2),e!==null&&(mt(e,2),If(e))}function Cf(e,t,n){if(e.tag===3)Sf(e,e,n);else for(;t!==null;){if(t.tag===3){Sf(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(Dd===null||!Dd.has(r))){e=Hi(n,e),n=jc(2),r=vo(t,n,2),r!==null&&(Mc(n,r,t,e),mt(r,2),If(r));break}}t=t.return}}function wf(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new rd;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(fd=!0,i.add(n),e=Tf.bind(null,e,t,n),t.then(e,e))}function Tf(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,ad===e&&(sd&n)===n&&(md===4||md===3&&(sd&62914560)===sd&&300>He()-Cd?id&2?_d|=n:Xd(e,0):_d|=n,yd===sd&&(yd=0)),If(e)}function Ef(e,t){t===0&&(t=ft()),e=Di(e,t),e!==null&&(mt(e,t),If(e))}function Df(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ef(e,n)}function Of(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),Ef(e,n)}function kf(e,t){return Re(e,t)}var Af=null,jf=null,Mf=!1,Nf=!1,Pf=!1,Ff=0;function If(e){e!==jf&&e.next===null&&(jf===null?Af=jf=e:jf=jf.next=e),Nf=!0,Mf||(Mf=!0,Hf())}function Lf(e,t){if(!Pf&&Nf){Pf=!0;do for(var n=!1,r=Af;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-et(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,Vf(r,a))}else a=sd,a=ct(r,r===ad?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||lt(r,a)||(n=!0,Vf(r,a))}r=r.next}while(n);Pf=!1}}function Rf(){zf()}function zf(){Nf=Mf=!1;var e=0;Ff!==0&&Ep()&&(e=Ff);for(var t=He(),n=null,r=Af;r!==null;){var i=r.next,a=H(r,t);a===0?(r.next=null,n===null?Af=i:n.next=i,i===null&&(jf=n)):(n=r,(e!==0||a&3)&&(Nf=!0)),r=i}Od!==0&&Od!==5||Lf(e,!1),Ff!==0&&(Ff=0)}function H(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-et(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=dt(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=ad,n=sd,n=ct(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(cd===2||cd===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&ze(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||lt(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&ze(r),bt(n)){case 2:case 8:n=Ge;break;case 32:n=Ke;break;case 268435456:n=Je;break;default:n=Ke}return r=Bf.bind(null,e),n=Re(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&ze(r),e.callbackPriority=2,e.callbackNode=null,2}function Bf(e,t){if(Od!==0&&Od!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(bf()&&e.callbackNode!==n)return null;var r=sd;return r=ct(e,e===ad?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(Wd(e,r,t),H(e,He()),e.callbackNode!=null&&e.callbackNode===n?Bf.bind(null,e):null)}function Vf(e,t){if(bf())return null;Wd(e,t,!0)}function Hf(){jp(function(){id&6?Re(We,Rf):zf()})}function Uf(){if(Ff===0){var e=Ba;e===0&&(e=it,it<<=1,!(it&261888)&&(it=256)),Ff=e}return Ff}function Wf(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:vn(e)}function Gf(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=Wf((i[F]||null).action),o=r.submitter;o&&(t=(t=o[F]||null)?Wf(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new Bn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(Ff!==0){var e=new FormData(i,o);rc(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=new FormData(i,o),rc(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var Kf=0;Kf<mi.length;Kf++){var qf=mi[Kf];hi(qf.toLowerCase(),`on`+(qf[0].toUpperCase()+qf.slice(1)))}hi(oi,`onAnimationEnd`),hi(si,`onAnimationIteration`),hi(ci,`onAnimationStart`),hi(`dblclick`,`onDoubleClick`),hi(`focusin`,`onFocus`),hi(`focusout`,`onBlur`),hi(li,`onTransitionRun`),hi(ui,`onTransitionStart`),hi(di,`onTransitionCancel`),hi(fi,`onTransitionEnd`),Vt(`onMouseEnter`,[`mouseout`,`mouseover`]),Vt(`onMouseLeave`,[`mouseout`,`mouseover`]),Vt(`onPointerEnter`,[`pointerout`,`pointerover`]),Vt(`onPointerLeave`,[`pointerout`,`pointerover`]),Bt(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),Bt(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),Bt(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),Bt(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),Bt(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),Bt(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var Jf=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),Yf=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(Jf));function Xf(e,t){t=!!(t&4);for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){bi(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){bi(e)}i.currentTarget=null,a=c}}}}function Zf(e,t){var n=t[Tt];n===void 0&&(n=t[Tt]=new Set);var r=e+`__bubble`;n.has(r)||(tp(t,e,2,!1),n.add(r))}function Qf(e,t,n){var r=0;t&&(r|=4),tp(n,e,r,t)}var $f=`_reactListening`+Math.random().toString(36).slice(2);function ep(e){if(!e[$f]){e[$f]=!0,Rt.forEach(function(t){t!==`selectionchange`&&(Yf.has(t)||Qf(t,!1,e),Qf(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[$f]||(t[$f]=!0,Qf(`selectionchange`,!1,t))}}function tp(e,t,n,r){switch(Ph(t)){case 2:var i=Oh;break;case 8:i=kh;break;default:i=Ah}n=i.bind(null,t,n,e),i=void 0,!kn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function np(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=Mt(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}En(function(){var r=a,i=xn(n),s=[];a:{var c=pi.get(e);if(c!==void 0){var l=Bn,u=e;switch(e){case`keypress`:if(Fn(n)===0)break a;case`keydown`:case`keyup`:l=nr;break;case`focusin`:u=`focus`,l=Jn;break;case`focusout`:u=`blur`,l=Jn;break;case`beforeblur`:case`afterblur`:l=Jn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=Kn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=qn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=ar;break;case oi:case si:case ci:l=Yn;break;case fi:l=or;break;case`scroll`:case`scrollend`:l=L;break;case`wheel`:l=sr;break;case`copy`:case`cut`:case`paste`:l=R;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=rr;break;case`submit`:l=ir;break;case`toggle`:case`beforetoggle`:l=cr}var d=!!(t&4),f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=Dn(m,p),g!=null&&d.push(rp(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(l=e===`mouseover`||e===`pointerover`,c=e===`mouseout`||e===`pointerout`,l&&n!==bn&&(u=n.relatedTarget||n.fromElement)&&(Mt(u)||u[wt]))break a;(c||l)&&(u=i.window===i?i:(l=i.ownerDocument)?l.defaultView||l.parentWindow:window,c?(l=n.relatedTarget||n.toElement,c=r,l=l?Mt(l):null,l!==null&&(f=o(l),d=l.tag,l!==f||d!==5&&d!==27&&d!==6)&&(l=null)):(c=null,l=r),c!==l&&(d=Kn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=rr,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=c==null?u:Pt(c),h=l==null?u:Pt(l),u=new d(g,m+`leave`,c,n,i),u.target=f,u.relatedTarget=h,g=null,Mt(i)===r&&(d=new d(p,m+`enter`,l,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,d=c&&l?C(c,l,ap):null,c!==null&&op(s,u,c,d,!1),l!==null&&f!==null&&op(s,f,l,d,!0)))}a:{if(c=r?Pt(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var _=kr;else if(xr(c)){if(Ar)_=zr;else{_=Lr;var v=Ir}}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&hn(r.elementType)&&(_=kr):_=Rr;if(_&&=_(e,r)){Cr(s,_,n,i);break a}v&&v(e,c,r)}switch(v=r?Pt(r):window,e){case`focusin`:(xr(v)||v.contentEditable===`true`)&&(Xr=v,Zr=r,Qr=null);break;case`focusout`:Qr=Zr=Xr=null;break;case`mousedown`:$r=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:$r=!1,ei(s,n,i);break;case`selectionchange`:if(Yr)break;case`keydown`:case`keyup`:ei(s,n,i)}var y;if(z)b:{switch(e){case`compositionstart`:var b=`onCompositionStart`;break b;case`compositionend`:b=`onCompositionEnd`;break b;case`compositionupdate`:b=`onCompositionUpdate`;break b}b=void 0}else _r?hr(e,n)&&(b=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(b=`onCompositionStart`);b&&(fr&&n.locale!==`ko`&&(_r||b!==`onCompositionStart`?b===`onCompositionEnd`&&_r&&(y=Pn()):(jn=i,Mn=`value`in jn?jn.value:jn.textContent,_r=!0)),v=ip(r,b),0<v.length&&(b=new Xn(b,e,null,n,i),s.push({event:b,listeners:v}),y?b.data=y:(y=gr(n),y!==null&&(b.data=y)))),(y=dr?vr(e,n):yr(e,n))&&(b=ip(r,`onBeforeInput`),0<b.length&&(v=new Xn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:v,listeners:b}),v.data=y)),Gf(s,e,r,n,i)}Xf(s,t)})}function rp(e,t,n){return{instance:e,listener:t,currentTarget:n}}function ip(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=Dn(e,n),i!=null&&r.unshift(rp(e,i,a)),i=Dn(e,t),i!=null&&r.push(rp(e,i,a))),e.tag===3)return r;e=e.return}return[]}function ap(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function op(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=Dn(n,a),l!=null&&o.unshift(rp(n,l,c))):i||(l=Dn(n,a),l!=null&&o.push(rp(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var sp=/\r\n?/g,cp=/\u0000|\uFFFD/g;function lp(e){return(typeof e==`string`?e:``+e).replace(sp,`
10
+ `).replace(cp,``)}function up(e,t){return t=lp(t),lp(e)===t}function dp(e,t,n,r,a,o){switch(n){case`children`:if(typeof r==`string`)t===`body`||t===`textarea`&&r===``||dn(e,r);else if(typeof r==`number`||typeof r==`bigint`)t!==`body`&&dn(e,``+r);else return;break;case`className`:Yt(e,`class`,r);break;case`tabIndex`:Yt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Yt(e,n,r);break;case`style`:mn(e,r,o);return;case`data`:if(t!==`object`){Yt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)||r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=vn(r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}if(typeof o==`function`&&(n===`formAction`?(t!==`input`&&dp(e,t,`name`,a.name,a,null),dp(e,t,`formEncType`,a.formEncType,a,null),dp(e,t,`formMethod`,a.formMethod,a,null),dp(e,t,`formTarget`,a.formTarget,a,null)):(dp(e,t,`encType`,a.encType,a,null),dp(e,t,`method`,a.method,a,null),dp(e,t,`target`,a.target,a,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=vn(r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=yn);return;case`onScroll`:r!=null&&Zf(`scroll`,e);return;case`onScrollEnd`:r!=null&&Zf(`scrollend`,e);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=vn(r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`credentialless`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Zf(`beforetoggle`,e),Zf(`toggle`,e),Jt(e,`popover`,r);break;case`xlinkActuate`:Xt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Xt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Xt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Xt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Xt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Xt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Xt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Xt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Xt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Jt(e,`is`,r);break;case`innerText`:case`textContent`:return;default:if(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)n=gn.get(n)||n,Jt(e,n,r);else return}Kt=!0}function fp(e,t,n,r,a,o){switch(n){case`style`:mn(e,r,o);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`children`:if(typeof r==`string`)dn(e,r);else if(typeof r==`number`||typeof r==`bigint`)dn(e,``+r);else return;break;case`onScroll`:r!=null&&Zf(`scroll`,e);return;case`onScrollEnd`:r!=null&&Zf(`scrollend`,e);return;case`onClick`:r!=null&&(e.onclick=yn);return;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:return;case`innerText`:case`textContent`:return;default:if(!zt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),o=n.slice(2,a?n.length-7:void 0),t=e[F]||null,t=t==null?null:t[n],typeof t==`function`&&e.removeEventListener(o,t,a),typeof r==`function`)){typeof t!=`function`&&t!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(o,r,a);break a}Kt=!0,n in e?e[n]=r:!0===r?e.setAttribute(n,``):Jt(e,n,r)}return}Kt=!0}function pp(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Zf(`error`,e),Zf(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:dp(e,t,o,s,n,null)}}a&&dp(e,t,`srcSet`,n.srcSet,n,null),r&&dp(e,t,`src`,n.src,n,null);return;case`input`:Zf(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:dp(e,t,r,d,n,null)}}on(e,o,c,l,u,s,a,!1);return;case`select`:for(a in Zf(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:dp(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&ln(e,!!r,n,!0):ln(e,!!r,t,!1);return;case`textarea`:for(s in Zf(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:dp(e,t,s,c,n,null)}un(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:dp(e,t,l,r,n,null)}return;case`dialog`:Zf(`beforetoggle`,e),Zf(`toggle`,e),Zf(`cancel`,e),Zf(`close`,e);break;case`iframe`:case`object`:Zf(`load`,e);break;case`video`:case`audio`:for(r=0;r<Jf.length;r++)Zf(Jf[r],e);break;case`image`:Zf(`error`,e),Zf(`load`,e);break;case`details`:Zf(`toggle`,e);break;case`embed`:case`source`:case`link`:Zf(`error`,e),Zf(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:dp(e,t,u,r,n,null)}return;default:if(hn(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&fp(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&dp(e,t,c,r,n,null))}var mp={};function hp(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||dp(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:m!==f&&(Kt=!0),o=m;break;case`name`:m!==f&&(Kt=!0),a=m;break;case`checked`:m!==f&&(Kt=!0),u=m;break;case`defaultChecked`:m!==f&&(Kt=!0),d=m;break;case`value`:m!==f&&(Kt=!0),s=m;break;case`defaultValue`:m!==f&&(Kt=!0),c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&dp(e,t,p,m,r,f)}}an(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||dp(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:o!==l&&(Kt=!0),p=o;break;case`defaultValue`:o!==l&&(Kt=!0),c=o;break;case`multiple`:o!==l&&(Kt=!0),s=o;default:o!==l&&dp(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?ln(e,!!n,n?[]:``,!1):ln(e,!!n,t,!0)):ln(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:dp(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:a!==o&&(Kt=!0),p=a;break;case`defaultValue`:a!==o&&(Kt=!0),m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&dp(e,t,s,a,r,o)}I(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:dp(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:p!==m&&(Kt=!0),e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:dp(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&dp(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:dp(e,t,u,p,r,m)}return;default:if(hn(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&fp(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||fp(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&dp(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||dp(e,t,f,p,r,m)}function gp(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function _p(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&gp(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&gp(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var vp=null,yp=null;function bp(e){return e.nodeType===9?e:e.ownerDocument}function xp(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Sp(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Cp(e,t,n,r){return n=bp(n).createElement(e),n[Ct]=r,n[F]=t,pp(n,e,t),It(n),n}function wp(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Tp=null;function Ep(){var e=window.event;return e&&e.type===`popstate`?e!==Tp&&(Tp=e,!0):(Tp=null,!1)}var Dp=typeof setTimeout==`function`?setTimeout:void 0,Op=typeof clearTimeout==`function`?clearTimeout:void 0,kp=typeof Promise==`function`?Promise:void 0,Ap=typeof requestAnimationFrame==`function`?requestAnimationFrame:Dp,jp=typeof queueMicrotask==`function`?queueMicrotask:kp===void 0?Dp:function(e){return kp.resolve(null).then(e).catch(Mp)};function Mp(e){setTimeout(function(){throw e})}function Np(e){return e===`head`}function Pp(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),$h(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)Om(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,Om(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[kt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&Om(e.ownerDocument.body)}n=i}while(n);$h(t)}function Fp(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8){if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++}n=r}while(n)}function Ip(e,t,n){if(t=CSS.escape(t)===t?t:`r-`+btoa(t).replace(/=/g,``),e.style.viewTransitionName=t,n!=null&&(e.style.viewTransitionClass=n),n=getComputedStyle(e),n.display===`inline`){if(t=e.getClientRects(),t.length===1)var r=1;else for(var i=r=0;i<t.length;i++){var a=t[i];0<a.width&&0<a.height&&r++}r===1&&(e=e.style,e.display=t.length===1?`inline-block`:`block`,e.marginTop=`-`+n.paddingTop,e.marginBottom=`-`+n.paddingBottom)}}function Lp(e,t){e=e.style,t=t.style;var n=t==null?null:t.hasOwnProperty(`viewTransitionName`)?t.viewTransitionName:t.hasOwnProperty(`view-transition-name`)?t[`view-transition-name`]:null;e.viewTransitionName=n==null||typeof n==`boolean`?``:(``+n).trim(),n=t==null?null:t.hasOwnProperty(`viewTransitionClass`)?t.viewTransitionClass:t.hasOwnProperty(`view-transition-class`)?t[`view-transition-class`]:null,e.viewTransitionClass=n==null||typeof n==`boolean`?``:(``+n).trim(),e.display===`inline-block`&&(t==null?e.display=e.margin=``:(n=t.display,e.display=n==null||typeof n==`boolean`?``:n,n=t.margin,n==null?(n=t.hasOwnProperty(`marginTop`)?t.marginTop:t[`margin-top`],e.marginTop=n==null||typeof n==`boolean`?``:n,t=t.hasOwnProperty(`marginBottom`)?t.marginBottom:t[`margin-bottom`],e.marginBottom=t==null||typeof t==`boolean`?``:t):e.margin=n))}function Rp(e,t,n){return n=n.ownerDocument.defaultView,{rect:e,abs:t.position===`absolute`||t.position===`fixed`,clip:t.clipPath!==`none`||t.overflow!==`visible`||t.filter!==`none`||t.mask!==`none`||t.mask!==`none`||t.borderRadius!==`0px`,view:0<=e.bottom&&0<=e.right&&e.top<=n.innerHeight&&e.left<=n.innerWidth}}function zp(e){return Rp(e.getBoundingClientRect(),getComputedStyle(e),e)}function Bp(e){var t=e.getBoundingClientRect();t=new DOMRect(t.x+2e4,t.y+2e4,t.width,t.height);var n=getComputedStyle(e);return Rp(t,n,e)}function Vp(e){return e.documentElement.clientHeight}function Hp(e){this.addEventListener(`load`,e),this.addEventListener(`error`,e)}function Up(e,t,n,r,i,a,o,s,c){var l=t.nodeType===9?t:t.ownerDocument;try{var u=l.startViewTransition({update:function(){var t=l.defaultView,n=t.navigation&&t.navigation.transition,o=l.fonts.status;r();var s=[];if(o===`loaded`&&(Vp(l),l.fonts.status===`loading`&&s.push(l.fonts.ready)),o=s.length,e!==null)for(var c=e.suspenseyImages,u=0,d=0;d<c.length;d++){var f=c[d];if(!f.complete){var p=f.getBoundingClientRect();if(0<p.bottom&&0<p.right&&p.top<t.innerHeight&&p.left<t.innerWidth){if(u+=sh(f),u>uh){s.length=o;break}f=new Promise(Hp.bind(f)),s.push(f)}}}if(0<s.length)return t=Promise.race([Promise.all(s),new Promise(function(e){return setTimeout(e,500)})]).then(i,i),(n?Promise.allSettled([n.finished,t]):t).then(a,a);if(i(),n)return n.finished.then(a,a);a()},types:n});l.__reactViewTransition=u;var d=[];return u.ready.then(function(){for(var e=l.documentElement.getAnimations({subtree:!0}),t=0;t<e.length;t++){var n=e[t],r=n.effect,i=r.pseudoElement;if(i!=null&&i.startsWith(`::view-transition`)){d.push(n),n=r.getKeyframes();for(var a=i=void 0,s=!0,c=0;c<n.length;c++){var u=n[c],f=u.width;if(i===void 0)i=f;else if(i!==f){s=!1;break}if(f=u.height,a===void 0)a=f;else if(a!==f){s=!1;break}delete u.width,delete u.height,u.transform===`none`&&delete u.transform}s&&i!==void 0&&a!==void 0&&(r.setKeyframes(n),s=getComputedStyle(r.target,r.pseudoElement),s.width!==i||s.height!==a)&&(s=n[0],s.width=i,s.height=a,s=n[n.length-1],s.width=i,s.height=a,r.setKeyframes(n))}}o()},function(e){l.__reactViewTransition===u&&(l.__reactViewTransition=null);try{if(typeof e==`object`&&e)switch(e.name){case`InvalidStateError`:(e.message===`View transition was skipped because document visibility state is hidden.`||e.message===`Skipping view transition because document visibility state has become hidden.`||e.message===`Skipping view transition because viewport size changed.`||e.message===`Transition was aborted because of invalid state`)&&(e=null)}e!==null&&c(e)}finally{r(),i(),o()}}),u.finished.finally(function(){for(var e=0;e<d.length;e++)d[e].cancel();l.__reactViewTransition===u&&(l.__reactViewTransition=null),s()}),u}catch{return r(),i(),o(),null}}function Wp(e,t){this._scope=document.documentElement,this._selector=`::view-transition-`+e+`(`+t+`)`}Wp.prototype.animate=function(e,t){return t=typeof t==`number`?{duration:t}:w({},t),t.pseudoElement=this._selector,this._scope.animate(e,t)},Wp.prototype.getAnimations=function(){for(var e=this._scope,t=this._selector,n=e.getAnimations({subtree:!0}),r=[],i=0;i<n.length;i++){var a=n[i].effect;a!==null&&a.target===e&&a.pseudoElement===t&&r.push(n[i])}return r},Wp.prototype.getComputedStyle=function(){return getComputedStyle(this._scope,this._selector)};function Gp(e){return{name:e,group:new Wp(`group`,e),imagePair:new Wp(`image-pair`,e),old:new Wp(`old`,e),new:new Wp(`new`,e)}}function Kp(e){this._fragmentFiber=e,this._observers=this._eventListeners=null}Kp.prototype.addEventListener=function(e,t,n){var r=null,i=null;if(!(n!=null&&typeof n!=`boolean`&&(r=n.signal||null,r!==null&&r.aborted))){this._eventListeners===null&&(this._eventListeners=[]);var a=this._eventListeners;if(Zp(a,e,t,n)===-1){var o=this,s=t;n!=null&&typeof n!=`boolean`&&!0===n.once&&(s=function(r){o.removeEventListener(e,t,n),typeof t==`function`?t.call(this,r):t.handleEvent(r)}),r!==null&&(i=o.removeEventListener.bind(o,e,t,n),r.addEventListener(`abort`,i,{once:!0}),i=r.removeEventListener.bind(r,`abort`,i)),r=Yp(n),a.push({type:e,listener:t,optionsOrUseCapture:n,attachedListener:s,cleanup:i}),f(this._fragmentFiber.child,!1,qp,e,s,r)}this._eventListeners=a}};function qp(e,t,n,r){return _(e).addEventListener(t,n,r),!1}Kp.prototype.removeEventListener=function(e,t,n){var r=this._eventListeners;if(r!==null&&(t=Zp(r,e,t,n),t!==-1)){var i=r[t];n=i.attachedListener;var a=i.cleanup;i=Yp(i.optionsOrUseCapture),f(this._fragmentFiber.child,!1,Jp,e,n,i),r.splice(t,1),a!==null&&a()}};function Jp(e,t,n,r){return _(e).removeEventListener(t,n,r),!1}function Yp(e){return e!=null&&typeof e!=`boolean`&&(!0===e.once||e.signal instanceof AbortSignal)?{capture:e.capture,passive:e.passive}:e}function Xp(e){return e==null?`c=0`:typeof e==`boolean`?`c=`+(e?`1`:`0`):`c=`+(e.capture?`1`:`0`)}function Zp(e,t,n,r){if(e.length===0)return-1;r=Xp(r);for(var i=0;i<e.length;i++){var a=e[i];if(a.type===t&&a.listener===n&&Xp(a.optionsOrUseCapture)===r)return i}return-1}Kp.prototype.dispatchEvent=function(e){var t=p(this._fragmentFiber);if(t===null)return!0;t=_(t);var n=this._eventListeners;if(n!==null&&0<n.length||!e.bubbles){var r=t.nodeType===9?t.createComment(``):document.createTextNode(``);if(n)for(var i=0;i<n.length;i++){var a=n[i];r.addEventListener(a.type,a.attachedListener,Yp(a.optionsOrUseCapture))}if(t.appendChild(r),e=r.dispatchEvent(e),n)for(i=0;i<n.length;i++)a=n[i],r.removeEventListener(a.type,a.attachedListener,Yp(a.optionsOrUseCapture));return t.removeChild(r),e}return t.dispatchEvent(e)},Kp.prototype.focus=function(e){f(this._fragmentFiber.child,!0,Qp,e,void 0,void 0)};function Qp(e,t){return e.tag!==6&&(e=_(e),wm(e,t))}Kp.prototype.focusLast=function(e){var t=[];f(this._fragmentFiber.child,!0,$p,t,void 0,void 0);for(var n=t.length-1;0<=n&&!Qp(t[n],e);n--);};function $p(e,t){return t.push(e),!1}Kp.prototype.blur=function(){var e=p(this._fragmentFiber);e!==null&&(e=_(e),e=bp(e).activeElement,e!==null&&f(this._fragmentFiber.child,!1,em,e,void 0,void 0))};function em(e,t){return e.tag!==6&&(e=_(e),e===t||e.contains(t)?(t.blur(),!0):!1)}Kp.prototype.observeUsing=function(e){this._observers===null&&(this._observers=new Set),this._observers.add(e),f(this._fragmentFiber.child,!1,tm,e,void 0,void 0)};function tm(e,t){return e.tag===6||(e=_(e),t.observe(e)),!1}Kp.prototype.unobserveUsing=function(e){var t=this._observers;if(t!==null&&t.has(e)){t.delete(e),f(this._fragmentFiber.child,!1,nm,e,void 0,void 0);for(var n=t=0;n<rm.length;n++){var r=rm[n];r.fragmentInstance===this&&r.observer===e?e.unobserve(r.instance):rm[t++]=r}rm.length=t}};function nm(e,t){return e.tag===6||(e=_(e),t.unobserve(e)),!1}var rm=[],im=!1;function am(e,t,n){rm.push({fragmentInstance:e,observer:t,instance:n}),im||(im=!0,Tm(function(){im=!1;var e=rm;rm=[];for(var t=0;t<e.length;t++){var n=e[t];n.observer.unobserve(n.instance)}}))}Kp.prototype.getClientRects=function(){var e=[];return f(this._fragmentFiber.child,!1,om,e,void 0,void 0),e};function om(e,t){if(e.tag===6){e=e.stateNode;var n=e.ownerDocument.createRange();n.selectNodeContents(e),t.push.apply(t,n.getClientRects())}else e=_(e),t.push.apply(t,e.getClientRects());return!1}Kp.prototype.getRootNode=function(e){var t=p(this._fragmentFiber);return t===null?this:_(t).getRootNode(e)},Kp.prototype.compareDocumentPosition=function(e){var t=p(this._fragmentFiber);if(t===null)return Node.DOCUMENT_POSITION_DISCONNECTED;var n=[];f(this._fragmentFiber.child,!1,$p,n,void 0,void 0);var r=_(t);if(n.length===0){if(n=r,m(this._fragmentFiber)){a:{for(t=this._fragmentFiber.return;t!==null;){if(t.tag===4){t=t.stateNode.containerInfo;break a}if(t.tag===3||t.tag===5||t.tag===27)break;t=t.return}t=null}t!=null&&(n=t)}t=this._fragmentFiber;var i=r=n.compareDocumentPosition(e);return n===e?i=Node.DOCUMENT_POSITION_CONTAINS:r&Node.DOCUMENT_POSITION_CONTAINED_BY&&(n=h(t)[1],n===null?i=Node.DOCUMENT_POSITION_PRECEDING:(e=_(n).compareDocumentPosition(e),i=e===0||e&Node.DOCUMENT_POSITION_FOLLOWING?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING)),i|=Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC}t=_(n[0]),i=_(n[n.length-1]);var a=m(this._fragmentFiber)?t.parentElement:r;if(a==null)return Node.DOCUMENT_POSITION_DISCONNECTED;r=a.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY,a=a.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_CONTAINED_BY;var o=t.compareDocumentPosition(e),s=i.compareDocumentPosition(e),c=o&Node.DOCUMENT_POSITION_CONTAINED_BY||s&Node.DOCUMENT_POSITION_CONTAINED_BY;return s=r&&a&&o&Node.DOCUMENT_POSITION_FOLLOWING&&s&Node.DOCUMENT_POSITION_PRECEDING,t=r&&t===e||a&&i===e||c||s?Node.DOCUMENT_POSITION_CONTAINED_BY:!r&&t===e||!a&&i===e?Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:o,t&Node.DOCUMENT_POSITION_DISCONNECTED||t&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC||sm(t,this._fragmentFiber,n[0],n[n.length-1],e)?t:Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC};function sm(e,t,n,r,i){var a=Mt(i);if(e&Node.DOCUMENT_POSITION_CONTAINED_BY){if(n=!!a)a:{for(;a!==null;){if(a.tag===7&&(a===t||a.alternate===t)){n=!0;break a}a=a.return}n=!1}return n}if(e&Node.DOCUMENT_POSITION_CONTAINS){if(a===null)return a=i.ownerDocument,i===a||i===a.documentElement||i===a.body;a:{for(a=t,t=p(t);a!==null;){if(!(a.tag!==5&&a.tag!==3&&a.tag!==27||a!==t&&a.alternate!==t)){a=!0;break a}a=a.return}a=!1}return a}return e&Node.DOCUMENT_POSITION_PRECEDING?((t=!!a)&&!(t=a===n)&&(t=C(n,a,S),t===null?t=!1:(f(t,!0,b,a,n),a=v,v=null,t=a!==null)),t):e&Node.DOCUMENT_POSITION_FOLLOWING?((t=!!a)&&!(t=a===r)&&(t=C(r,a,S),t===null?t=!1:(f(t,!0,x,a,r),a=v,y=v=null,t=a!==null)),t):!1}function cm(e,t){var n=e.ownerDocument.createRange();n.selectNodeContents(e),e=n.getBoundingClientRect(),window.scrollTo(window.scrollX+e.left,t?window.scrollY+e.top:window.scrollY+e.bottom-window.innerHeight)}Kp.prototype.scrollIntoView=function(e){if(typeof e==`object`)throw Error(i(566));var t=[];f(this._fragmentFiber.child,!1,$p,t,void 0,void 0);var n=!1!==e;if(t.length===0){var r=h(this._fragmentFiber);if(r=n?r[1]||r[0]||p(this._fragmentFiber):r[0]||r[1],r===null)return;if(r.tag===6){e=_(r),cm(e,n);return}if(r=_(r),r.nodeType!==9){if(r.nodeType===11){n=`host`in r?r.host:null,n!==null&&n.scrollIntoView(e);return}r.scrollIntoView(e)}}for(r=n?t.length-1:0;r!==(n?-1:t.length);){var a=t[r];a.tag===6?(a=_(a),cm(a,n)):_(a).scrollIntoView(e),r+=n?-1:1}};function lm(e,t){return e=_(e),um(e,t),!1}function um(e,t){e.reactFragments??=new Set,e.reactFragments.add(t)}function dm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.addEventListener(i.type,i.attachedListener,Yp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){for(var r=0,i=0;i<rm.length;i++){var a=rm[i];(a.fragmentInstance!==t||a.observer!==n||a.instance!==e)&&(rm[r++]=a)}rm.length=r,n.observe(e)}),um(e,t))}function fm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.removeEventListener(i.type,i.attachedListener,Yp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){typeof n.rootMargin==`string`?am(t,n,e):n.unobserve(e)}),e.reactFragments!=null&&e.reactFragments.delete(t))}function pm(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:pm(n),jt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function mm(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r){if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e}else if(!e[kt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=bm(e.nextSibling),e===null)break}return null}function hm(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=bm(e.nextSibling),e===null))return null;return e}function gm(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=bm(e.nextSibling),e===null))return null;return e}function _m(e){return e.data===`$?`||e.data===`$~`}function vm(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function ym(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function bm(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var xm=null;function Sm(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return bm(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function Cm(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function wm(e,t){function n(){r=!0}if(e.ownerDocument.activeElement===e)return!0;var r=!1;try{e.ownerDocument.addEventListener(`focus`,n,!0),(e.focus||HTMLElement.prototype.focus).call(e,t)}finally{e.ownerDocument.removeEventListener(`focus`,n,!0)}return r}function Tm(e){Ap(function(){Ap(function(t){return e(t)})})}function Em(e,t,n){switch(t=bp(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function Dm(e,t,n){for(var r in n){var i=n[r];n.hasOwnProperty(r)&&i!=null&&dp(e,t,r,null,mp,i)}n.dangerouslySetInnerHTML!=null&&(e.textContent=``),e.onclick===yn&&(e.onclick=null),jt(e)}function Om(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);jt(e)}var km=new Map,Am=new Set;function jm(e){if(typeof e.getRootNode==`function`){var t=e.getRootNode();if(t.nodeType===9||t.nodeType===11)return t}return e.nodeType===9?e:e.ownerDocument}var Mm=ge.d;ge.d={f:Nm,r:Pm,D:Lm,C:Rm,L:zm,m:Bm,X:Hm,S:Vm,M:Um};function Nm(){var e=Mm.f(),t=Jd();return e||t}function Pm(e){var t=Nt(e);t!==null&&t.tag===5&&t.type===`form`?ac(t):Mm.r(e)}var Fm=typeof document>`u`?null:document;function Im(e,t,n){var r=Fm;if(r&&typeof t==`string`&&t){var i=rn(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),Am.has(i)||(Am.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),pp(t,`link`,e),It(t),r.head.appendChild(t)))}}function Lm(e){Mm.D(e),Im(`dns-prefetch`,e,null)}function Rm(e,t){Mm.C(e,t),Im(`preconnect`,e,t)}function zm(e,t,n){Mm.L(e,t,n);var r=Fm;if(r&&e&&t){var i=`link[rel="preload"][as="`+rn(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+rn(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+rn(n.imageSizes)+`"]`)):i+=`[href="`+rn(e)+`"]`;var a=i;switch(t){case`style`:a=Gm(e);break;case`script`:a=Ym(e)}if(!(km.has(a)||(e=w({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),km.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Km(a))||t===`script`&&r.querySelector(Xm(a))))){var o=r.createElement(`link`);pp(o,`link`,e),t===`style`&&(o[At]=!0,o.onload=o.onerror=function(){Lt(o)}),It(o),r.head.appendChild(o)}}}function Bm(e,t){Mm.m(e,t);var n=Fm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+rn(r)+`"][href="`+rn(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Ym(e)}if(!km.has(a)&&(e=w({rel:`modulepreload`,href:e},t),km.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Xm(a)))return}r=n.createElement(`link`),pp(r,`link`,e),It(r),n.head.appendChild(r)}}}function Vm(e,t,n){Mm.S(e,t,n);var r=Fm;if(r&&e){var i=Ft(r).hoistableStyles,a=Gm(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Km(a)))s.loading=5;else{e=w({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=km.get(a))&&$m(e,n);var c=o=r.createElement(`link`);It(c),pp(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Qm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Hm(e,t){Mm.X(e,t);var n=Fm;if(n&&e){var r=Ft(n).hoistableScripts,i=Ym(e),a=r.get(i);a||(a=n.querySelector(Xm(i)),a||(e=w({src:e,async:!0},t),(t=km.get(i))&&eh(e,t),a=n.createElement(`script`),It(a),pp(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Um(e,t){Mm.M(e,t);var n=Fm;if(n&&e){var r=Ft(n).hoistableScripts,i=Ym(e),a=r.get(i);a||(a=n.querySelector(Xm(i)),a||(e=w({src:e,async:!0,type:`module`},t),(t=km.get(i))&&eh(e,t),a=n.createElement(`script`),It(a),pp(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Wm(e,t,n,r){var a=(a=N.current)?jm(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Gm(n.href),t=Ft(a).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Gm(n.href);var o=Ft(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Km(e)))?o._p||(s.instance=o,s.state.loading=5):(o=km.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},km.set(e,o)),Jm(a,e,o,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Ym(n),t=Ft(a).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Gm(e){return`href="`+rn(e)+`"`}function Km(e){return`link[rel="stylesheet"][`+e+`]`}function qm(e){return w({},e,{"data-precedence":e.precedence,precedence:null})}function Jm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[At]){r.loading=1;return}}else t=e.createElement(`link`),t[At]=!0,t.onload=t.onerror=Lt.bind(null,t),pp(t,`link`,n),It(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Ym(e){return`[src="`+rn(e)+`"]`}function Xm(e){return`script[async]`+e}function Zm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+rn(n.href)+`"]`);if(r)return t.instance=r,It(r),r;var a=w({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),It(r),pp(r,`style`,a),Qm(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Gm(n.href);var o=e.querySelector(Km(a));if(o)return t.state.loading|=4,t.instance=o,It(o),o;r=qm(n),(a=km.get(a))&&$m(r,a),o=(e.ownerDocument||e).createElement(`link`),It(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),pp(o,`link`,r),t.state.loading|=4,Qm(o,n.precedence,e),t.instance=o;case`script`:return o=Ym(n.src),(a=e.querySelector(Xm(o)))?(t.instance=a,It(a),a):(r=n,(a=km.get(o))&&(r=w({},n),eh(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),It(a),pp(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Qm(r,n.precedence,e));return t.instance}function Qm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function $m(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function eh(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var th=null;function nh(e,t,n){if(th===null){var r=new Map,i=th=new Map;i.set(n,r)}else i=th,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[kt]||a[Ct]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function rh(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function ih(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function ah(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function oh(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function sh(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function ch(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=sh(t),e.suspenseyImages.push(t)),e=mh.bind(e),t.decode().then(e,e))}function lh(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Gm(r.href),a=t.querySelector(Km(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=ph.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,It(a);return}a=t.ownerDocument||t,r=qm(r),(i=km.get(i))&&$m(r,i),a=a.createElement(`link`),It(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),pp(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=ph.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var uh=0;function dh(e,t){return e.stylesheets&&e.count===0&&gh(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&gh(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&uh===0&&(uh=62500*_p());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&gh(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>uh?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function fh(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)gh(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function ph(){this.count--,fh(this)}function mh(){this.imgCount--,fh(this)}var hh=null;function gh(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,hh=new Map,t.forEach(_h,e),hh=null,ph.call(e))}function _h(e,t){if(!(t.state.loading&4)){var n=hh.get(e);if(n)var r=n.get(null);else{n=new Map,hh.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=ph.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var vh={$$typeof:A,Provider:null,Consumer:null,_currentValue:_e,_currentValue2:_e,_threadCount:0};function yh(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=pt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pt(0),this.hiddenUpdates=pt(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.transitionTypes=null,this.incompleteTransitions=new Map}function bh(e,t,n,r,i,a,o,s,c,l,u,d){return e=new yh(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=Mi(3,null,null,t),e.current=a,a.stateNode=e,t=Na(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},ho(a),e}function xh(e){return e?(e=Ai,e):Ai}function Sh(e,t,n,r,i,a){i=xh(i),r.context===null?r.context=i:r.pendingContext=i,r=_o(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=vo(e,r,t),n!==null&&(Ud(n,e,t),yo(n,e,t))}function Ch(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function wh(e,t){Ch(e,t),(e=e.alternate)&&Ch(e,t)}function Th(e){if(e.tag===13||e.tag===31){var t=Di(e,67108864);t!==null&&Ud(t,e,67108864),wh(e,67108864)}}function Eh(e){if(e.tag===13||e.tag===31){var t=Bd();t=yt(t);var n=Di(e,t);n!==null&&Ud(n,e,t),wh(e,t)}}var Dh=!0;function Oh(e,t,n,r){var i=he.T;he.T=null;var a=ge.p;try{ge.p=2,Ah(e,t,n,r)}finally{ge.p=a,he.T=i}}function kh(e,t,n,r){var i=he.T;he.T=null;var a=ge.p;try{ge.p=8,Ah(e,t,n,r)}finally{ge.p=a,he.T=i}}function Ah(e,t,n,r){if(Dh){var i=jh(r);if(i===null)np(e,t,r,Mh,n),Uh(e,r);else if(Gh(i,e,t,n,r))r.stopPropagation();else if(Uh(e,r),t&4&&-1<Hh.indexOf(e)){for(;i!==null;){var a=Nt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=st(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-et(o);s.entanglements[1]|=c,o&=~c}If(a),!(id&6)&&(Td=He()+500,Lf(0,!1))}}break;case 31:case 13:s=Di(a,2),s!==null&&Ud(s,a,2),Jd(),wh(a,2)}if(a=jh(r),a===null&&np(e,t,r,Mh,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else np(e,t,r,null,n)}}function jh(e){return e=xn(e),Nh(e)}var Mh=null;function Nh(e){if(Mh=null,e=Mt(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Mh=e,null}function Ph(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`fullscreenerror`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`resize`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(Ue()){case We:return 2;case Ge:return 8;case Ke:case qe:return 32;case Je:return 268435456;default:return 32}default:return 32}}var Fh=!1,Ih=null,Lh=null,Rh=null,zh=new Map,Bh=new Map,Vh=[],Hh=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Uh(e,t){switch(e){case`focusin`:case`focusout`:Ih=null;break;case`dragenter`:case`dragleave`:Lh=null;break;case`mouseover`:case`mouseout`:Rh=null;break;case`pointerover`:case`pointerout`:zh.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:Bh.delete(t.pointerId)}}function Wh(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=Nt(t),t!==null&&Th(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Gh(e,t,n,r,i){switch(t){case`focusin`:return Ih=Wh(Ih,e,t,n,r,i),!0;case`dragenter`:return Lh=Wh(Lh,e,t,n,r,i),!0;case`mouseover`:return Rh=Wh(Rh,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return zh.set(a,Wh(zh.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,Bh.set(a,Wh(Bh.get(a)||null,e,t,n,r,i)),!0}return!1}function Kh(e){var t=Mt(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,xt(e.priority,function(){Eh(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,xt(e.priority,function(){Eh(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function qh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=jh(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);bn=r,n.target.dispatchEvent(r),bn=null}else return t=Nt(n),t!==null&&Th(t),e.blockedOn=n,!1;t.shift()}return!0}function Jh(e,t,n){qh(e)&&n.delete(t)}function Yh(){Fh=!1,Ih!==null&&qh(Ih)&&(Ih=null),Lh!==null&&qh(Lh)&&(Lh=null),Rh!==null&&qh(Rh)&&(Rh=null),zh.forEach(Jh),Bh.forEach(Jh)}function Xh(e,n){e.blockedOn===n&&(e.blockedOn=null,Fh||(Fh=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Yh)))}var Zh=null;function Qh(e){Zh!==e&&(Zh=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Zh===e&&(Zh=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(Nh(r||n)===null)continue;break}var a=Nt(n);a!==null&&(e.splice(t,3),t-=3,rc(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function $h(e){function t(t){return Xh(t,e)}Ih!==null&&Xh(Ih,e),Lh!==null&&Xh(Lh,e),Rh!==null&&Xh(Rh,e),zh.forEach(t),Bh.forEach(t);for(var n=0;n<Vh.length;n++){var r=Vh[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Vh.length&&(n=Vh[0],n.blockedOn===null);)Kh(n),n.blockedOn===null&&Vh.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[F]||null;if(typeof a==`function`)o||Qh(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[F]||null)s=o.formAction;else if(Nh(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Qh(n)}}}function eg(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function tg(e){this._internalRoot=e}ng.prototype.render=tg.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;Sh(n,Bd(),e,t,null,null)},ng.prototype.unmount=tg.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Sh(e.current,2,null,e,null,null),Jd(),t[wt]=null}};function ng(e){this._internalRoot=e}ng.prototype.unstable_scheduleHydration=function(e){if(e){var t=P();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Vh.length&&t!==0&&t<Vh[n].priority;n++);Vh.splice(n,0,e),n===0&&Kh(e)}};var rg=n.version;if(rg!==`19.3.1`)throw Error(i(527,rg,`19.3.1`));ge.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:d(e),e=e===null?null:e.stateNode,e};var ig={bundleType:0,version:`19.3.1`,rendererPackageName:`react-dom`,currentDispatcherRef:he,reconcilerVersion:`19.3.1`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var ag=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ag.isDisabled&&ag.supportsFiber)try{Ze=ag.inject(ig),Qe=ag}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=Tc,s=Ec,c=Dc;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=bh(e,1,!1,null,null,n,r,null,o,s,c,eg),e[wt]=t.current,ep(e),new tg(t)}})),Er=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=Tr()})),Dr={name:`activity`,size:24,node:[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]};Dr.node;var Or=N(Dr),kr={name:`archive`,size:24,node:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]};kr.node;var Ar=N(kr),jr={name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]};jr.node;var Mr=N(jr),Nr={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};Nr.node;var Pr=N(Nr),Fr={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};Fr.node;var Ir=N(Fr),Lr={name:`arrow-up-right`,size:24,node:[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]};Lr.node;var Rr=N(Lr),zr={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};zr.node;var Br=N(zr),Vr={name:`audio-lines`,size:24,node:[[`path`,{d:`M2 10v3`,key:`1fnikh`}],[`path`,{d:`M6 6v11`,key:`11sgs0`}],[`path`,{d:`M10 3v18`,key:`yhl04a`}],[`path`,{d:`M14 8v7`,key:`3a1oy3`}],[`path`,{d:`M18 5v13`,key:`123xd1`}],[`path`,{d:`M22 10v3`,key:`154ddg`}]]};Vr.node;var Hr=N(Vr),Ur={name:`ban`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]};Ur.node;var Wr=N(Ur),Gr={name:`bell`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]};Gr.node;var Kr=N(Gr),qr={name:`book-open`,size:24,node:[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}]]};qr.node;var Jr=N(qr),Yr={name:`brain`,size:24,node:[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 01-3-4 4.17 4.17 0 01-3 4`,key:`5nuw1p`}],[`path`,{d:`M17.707 6.294A3 3 0 1012 5a3 3 0 10-5.707 1.294`,key:`18ldcf`}],[`path`,{d:`M17.996 5.125a4 4 0 012.526 5.77`,key:`1sdu8q`}],[`path`,{d:`M18 18a4 4 0 002-7.465`,key:`7xqqvr`}],[`path`,{d:`M19.967 17.482a4 4 0 11-7.967.517 4 4 0 11-7.967-.517`,key:`t46ysz`}],[`path`,{d:`M6 18a4 4 0 01-2-7.465`,key:`1y2m15`}],[`path`,{d:`M6.004 5.125a4 4 0 00-2.526 5.77`,key:`3cw1ss`}]]};Yr.node;var Xr=N(Yr),Zr={name:`bug`,size:24,node:[[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`,key:`uouzyp`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M21 21a4 4 0 0 0-3.81-4`,key:`1b0z45`}],[`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`,key:`5cxbf6`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M3 21a4 4 0 0 1 3.81-4`,key:`1fjd4g`}],[`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`,key:`1d7oge`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`,key:`1vgav8`}]]};Zr.node;var Qr=N(Zr),$r={name:`calculator`,size:24,node:[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,key:`1nb95v`}],[`line`,{x1:`8`,x2:`16`,y1:`6`,y2:`6`,key:`x4nwl0`}],[`line`,{x1:`16`,x2:`16`,y1:`14`,y2:`18`,key:`wjye3r`}],[`path`,{d:`M16 10h.01`,key:`1m94wz`}],[`path`,{d:`M12 10h.01`,key:`1nrarc`}],[`path`,{d:`M8 10h.01`,key:`19clt8`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M8 18h.01`,key:`lrp35t`}]]};$r.node;var ei=N($r),ti={name:`calendar-clock`,size:24,node:[[`path`,{d:`M16 2v3`,key:`otl347`}],[`path`,{d:`M17 15.5v1.7l1 .625`,key:`100ewj`}],[`path`,{d:`M21 8.936V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h3.935`,key:`g2sirp`}],[`path`,{d:`M3 9h9.873`,key:`7y8bi6`}],[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`circle`,{cx:`17`,cy:`17`,r:`5`,key:`1op1d2`}]]};ti.node;var ni=N(ti),ri={name:`captions`,size:24,node:[[`rect`,{width:`18`,height:`14`,x:`3`,y:`5`,rx:`2`,ry:`2`,key:`12ruh7`}],[`path`,{d:`M7 15h4M15 15h2M7 11h2M13 11h4`,key:`1ueiar`}]],aliases:[`subtitles`]};ri.node;var ii=N(ri),ai={name:`chart-column`,size:24,node:[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]],aliases:[`bar-chart-3`]};ai.node;var oi=N(ai),si={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};si.node;var ci=N(si),li={name:`chef-hat`,size:24,node:[[`path`,{d:`M10 11v5`,key:`urfl79`}],[`path`,{d:`M14 11v5`,key:`w9lfkh`}],[`path`,{d:`M6 12.65c0-.457-.316-.844-.727-1.041A4 4 0 017.52 4.034a1.53 1.53 0 001.367-.547 4 4 0 016.225 0 1.53 1.53 0 001.367.547 4 4 0 012.248 7.575c-.411.197-.727.584-.727 1.04V19a2 2 0 01-2 2H8a2 2 0 01-2-2z`,key:`1dq1bt`}],[`path`,{d:`M6 16h12`,key:`u522kt`}]]};li.node;var ui=N(li),di={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};di.node;var fi=N(di),pi={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};pi.node;var mi=N(pi),hi={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};hi.node;var gi=N(hi),_i={name:`chevron-up`,size:24,node:[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]};_i.node;var vi=N(_i),yi={name:`circle-check-big`,size:24,node:[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]],aliases:[`check-circle`]};yi.node;var bi=N(yi),xi={name:`circle-check`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`check-circle-2`]};xi.node;var Si=N(xi),Ci={name:`circle-exclamation-point`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]],aliases:[`alert-circle`,`circle-alert`]};Ci.node;var wi=N(Ci),Ti={name:`circle-question-mark`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9 9.5a3 2.5 0 016 0c0 2-2 2-3 3.5`,key:`1awbb0`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`help-circle`,`circle-help`]};Ti.node;var Ei=N(Ti),Di={name:`circle-stop`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]],aliases:[`stop-circle`]};Di.node;var Oi=N(Di),ki={name:`circle`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};ki.node;var Ai=N(ki),ji={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};ji.node;var Mi=N(ji),Ni={name:`cloud`,size:24,node:[[`path`,{d:`M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z`,key:`p7xjir`}]]};Ni.node;var Pi=N(Ni),Fi={name:`code-xml`,size:24,node:[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]],aliases:[`code-2`]};Fi.node;var Ii=N(Fi),Li={name:`code`,size:24,node:[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]};Li.node;var Ri=N(Li),zi={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};zi.node;var Bi=N(zi),Vi={name:`corner-down-right`,size:24,node:[[`path`,{d:`m15 10 5 5-5 5`,key:`qqa56n`}],[`path`,{d:`M4 4v7a4 4 0 0 0 4 4h12`,key:`z08zvw`}]]};Vi.node;var Hi=N(Vi),Ui={name:`cpu`,size:24,node:[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]};Ui.node;var Wi=N(Ui),Gi={name:`database`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]};Gi.node;var Ki=N(Gi),qi={name:`download`,size:24,node:[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]};qi.node;var Ji=N(qi),Yi={name:`eighth-notes`,size:24,node:[[`path`,{d:`M21 16V3a1 1 0 0 0-1.28-.96l-10 2.917a1 1 0 0 0-.72.96V19`,key:`uy6ho8`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}],[`circle`,{cx:`6`,cy:`19`,r:`3`,key:`1kj8tv`}]],aliases:[`music`]};Yi.node;var Xi=N(Yi),Zi={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};Zi.node;var Qi=N(Zi),$i={name:`eraser`,size:24,node:[[`path`,{d:`M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21`,key:`g5wo59`}],[`path`,{d:`m5.082 11.09 8.828 8.828`,key:`1wx5vj`}]]};$i.node;var ea=N($i),ta={name:`external-link`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]};ta.node;var na=N(ta),ra={name:`eye-off`,size:24,node:[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};ra.node;var ia=N(ra),aa={name:`eye`,size:24,node:[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};aa.node;var oa=N(aa),sa={name:`feather`,size:24,node:[[`path`,{d:`M14.086 18.412A2 2 0 0112.67 19H5v-7.672a2 2 0 01.586-1.414L11.75 3.75a6 6 0 118.49 8.49z`,key:`1nq9jb`}],[`path`,{d:`M16 8 2 22`,key:`vp34q`}],[`path`,{d:`M17.488 15H9`,key:`16yirz`}]]};sa.node;var ca=N(sa),la={name:`file-diff`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M9 10h6`,key:`9gxzsh`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`path`,{d:`M9 17h6`,key:`r8uit2`}]]};la.node;var ua=N(la),da={name:`file-down`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}],[`path`,{d:`m9 15 3 3 3-3`,key:`1npd3o`}]]};da.node;var fa=N(da),pa={name:`file-headphone`,size:24,node:[[`path`,{d:`M4 6.835V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-.343`,key:`1vfytu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M2 19a2 2 0 0 1 4 0v1a2 2 0 0 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 0 1-4 0v-1a2 2 0 0 1 4 0`,key:`1etmh7`}]],aliases:[`file-audio`,`file-audio-2`]};pa.node;var ma=N(pa),ha={name:`file-output`,size:24,node:[[`path`,{d:`M4.226 20.925A2 2 0 0 0 6 22h12a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v3.127`,key:`wfxp4w`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 11-3 3`,key:`1dgrs4`}],[`path`,{d:`m5 17-3-3h10`,key:`1mvvaf`}]]};ha.node;var ga=N(ha),_a={name:`file-play`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M15.033 13.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56v-4.704a.645.645 0 0 1 .967-.56z`,key:`1tzo1f`}]],aliases:[`file-video`]};_a.node;var va=N(_a),ya={name:`file-pen`,size:24,node:[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]],aliases:[`file-edit`]};ya.node;var ba=N(ya),xa={name:`file-text`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]};xa.node;var Sa=N(xa),Ca={name:`file`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]};Ca.node;var wa=N(Ca),Ta={name:`folder-open`,size:24,node:[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]};Ta.node;var Ea=N(Ta),Da={name:`folder-plus`,size:24,node:[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};Da.node;var Oa=N(Da),ka={name:`folder-search`,size:24,node:[[`path`,{d:`M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1`,key:`1bw5m7`}],[`path`,{d:`m21 21-1.9-1.9`,key:`1g2n9r`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}]]};ka.node;var Aa=N(ka),ja={name:`folder`,size:24,node:[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};ja.node;var Ma=N(ja),Na={name:`gauge`,size:24,node:[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]};Na.node;var Pa=N(Na),Fa={name:`git-commit-horizontal`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]],aliases:[`git-commit`]};Fa.node;var Ia=N(Fa),La={name:`git-branch`,size:24,node:[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]};La.node;var Ra=N(La),za={name:`git-pull-request`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]};za.node;var Ba=N(za),Va={name:`globe`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]};Va.node;var Ha=N(Va),Ua={name:`hard-drive`,size:24,node:[[`path`,{d:`M10 16h.01`,key:`1bzywj`}],[`path`,{d:`M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`18tbho`}],[`path`,{d:`M21.946 12.013H2.054`,key:`zqlbp7`}],[`path`,{d:`M6 16h.01`,key:`1pmjb7`}]]};Ua.node;var Wa=N(Ua),Ga={name:`image`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]};Ga.node;var Ka=N(Ga),qa={name:`info`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]};qa.node;var Ja=N(qa),Ya={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};Ya.node;var Xa=N(Ya),Za={name:`languages`,size:24,node:[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]};Za.node;var Qa=N(Za),$a={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};$a.node;var eo=N($a),to={name:`library`,size:24,node:[[`path`,{d:`m16 6 4 14`,key:`ji33uf`}],[`path`,{d:`M12 6v14`,key:`1n7gus`}],[`path`,{d:`M8 8v12`,key:`1gg7y9`}],[`path`,{d:`M4 4v16`,key:`6qkkli`}]]};to.node;var no=N(to),ro={name:`lightbulb`,size:24,node:[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]};ro.node;var io=N(ro),ao={name:`link-2`,size:24,node:[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]};ao.node;var oo=N(ao),so={name:`link`,size:24,node:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]};so.node;var co=N(so),lo={name:`list-checks`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]};lo.node;var uo=N(lo),fo={name:`loader-circle`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]],aliases:[`loader-2`]};fo.node;var B=N(fo),po={name:`lock-open`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 9.9-1`,key:`1mm8w8`}]],aliases:[`unlock`]};po.node;var mo=N(po),ho={name:`lock`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]};ho.node;var go=N(ho),_o={name:`mail`,size:24,node:[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]};_o.node;var vo=N(_o),yo={name:`menu`,size:24,node:[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]};yo.node;var bo=N(yo),xo={name:`message-circle-question-mark`,size:24,node:[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M9 9.5a3 2.5 0 016 0c0 2-2 2-3 3.5`,key:`1awbb0`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`message-circle-question`]};xo.node;var So=N(xo),Co={name:`message-square`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]};Co.node;var wo=N(Co),To={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};To.node;var Eo=N(To),Do={name:`monitor-smartphone`,size:24,node:[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]};Do.node;var Oo=N(Do),ko={name:`monitor`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]};ko.node;var Ao=N(ko),jo={name:`mouse-pointer-click`,size:24,node:[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]};jo.node;var Mo=N(jo),No={name:`panel-left-close`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]],aliases:[`sidebar-close`]};No.node;var Po=N(No),Fo={name:`panel-left-open`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]],aliases:[`sidebar-open`]};Fo.node;var Io=N(Fo),Lo={name:`panel-right-close`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m8 9 3 3-3 3`,key:`12hl5m`}]]};Lo.node;var Ro=N(Lo),zo={name:`panel-right-open`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]};zo.node;var Bo=N(zo),Vo={name:`panel-right`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]};Vo.node;var Ho=N(Vo),Uo={name:`panel-top-open`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`m15 14-3 3-3-3`,key:`g215vf`}]]};Uo.node;var Wo=N(Uo),Go={name:`pause`,size:24,node:[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]};Go.node;var Ko=N(Go),qo={name:`pen-line`,size:24,node:[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]],aliases:[`edit-3`]};qo.node;var Jo=N(qo),Yo={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};Yo.node;var Xo=N(Yo),Zo={name:`pin-off`,size:24,node:[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]};Zo.node;var Qo=N(Zo),$o={name:`pin`,size:24,node:[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]};$o.node;var es=N($o),ts={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};ts.node;var ns=N(ts),rs={name:`plug`,size:24,node:[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]};rs.node;var is=N(rs),as={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};as.node;var os=N(as),ss={name:`printer`,size:24,node:[[`path`,{d:`M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2`,key:`143wyd`}],[`path`,{d:`M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6`,key:`1itne7`}],[`rect`,{x:`6`,y:`14`,width:`12`,height:`8`,rx:`1`,key:`1ue0tg`}]]};ss.node;var cs=N(ss),ls={name:`receipt`,size:24,node:[[`path`,{d:`M12 17V7`,key:`pyj7ub`}],[`path`,{d:`M16 8h-6a2 2 0 0 0 0 4h4a2 2 0 0 1 0 4H8`,key:`1elt7d`}],[`path`,{d:`M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z`,key:`ycz6yz`}]]};ls.node;var us=N(ls),ds={name:`refresh-cw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]};ds.node;var fs=N(ds),ps={name:`rotate-ccw-clock`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]],aliases:[`history`]};ps.node;var ms=N(ps),hs={name:`rotate-ccw-square`,size:24,node:[[`path`,{d:`M20 9V7a2 2 0 0 0-2-2h-6`,key:`19z8uc`}],[`path`,{d:`m15 2-3 3 3 3`,key:`177bxs`}],[`path`,{d:`M20 13v5a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h2`,key:`d36hnl`}]]};hs.node;var gs=N(hs),_s={name:`rotate-ccw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]};_s.node;var vs=N(_s),ys={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};ys.node;var bs=N(ys),xs={name:`ruler`,size:24,node:[[`path`,{d:`M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z`,key:`icamh8`}],[`path`,{d:`m14.5 12.5 2-2`,key:`inckbg`}],[`path`,{d:`m11.5 9.5 2-2`,key:`fmmyf7`}],[`path`,{d:`m8.5 6.5 2-2`,key:`vc6u1g`}],[`path`,{d:`m17.5 15.5 2-2`,key:`wo5hmg`}]]};xs.node;var Ss=N(xs),Cs={name:`scroll-text`,size:24,node:[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]};Cs.node;var ws=N(Cs),Ts={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};Ts.node;var Es=N(Ts),Ds={name:`server`,size:24,node:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]};Ds.node;var Os=N(Ds),ks={name:`settings`,size:24,node:[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};ks.node;var As=N(ks),js={name:`share-2`,size:24,node:[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]};js.node;var Ms=N(js),Ns={name:`shield-check`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]};Ns.node;var Ps=N(Ns),Fs={name:`shield-exclamation-point`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]],aliases:[`shield-alert`]};Fs.node;var Is=N(Fs),Ls={name:`shield-question-mark`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 01-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 011-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 011.52 0C14.51 3.81 17 5 19 5a1 1 0 011 1z`,key:`1buusj`}],[`path`,{d:`M9 9.5a3 2.5 0 016 0c0 2-2 2-3 3.5`,key:`1awbb0`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`shield-question`]};Ls.node;var Rs=N(Ls),zs={name:`shuffle`,size:24,node:[[`path`,{d:`m18 14 4 4-4 4`,key:`10pe0f`}],[`path`,{d:`m18 2 4 4-4 4`,key:`pucp1d`}],[`path`,{d:`M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22`,key:`1ailkh`}],[`path`,{d:`M2 6h1.972a4 4 0 0 1 3.6 2.2`,key:`km57vx`}],[`path`,{d:`M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45`,key:`os18l9`}]]};zs.node;var Bs=N(zs),Vs={name:`sliders-horizontal`,size:24,node:[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]};Vs.node;var Hs=N(Vs),Us={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};Us.node;var Ws=N(Us),Gs={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};Gs.node;var Ks=N(Gs),qs={name:`square-code`,size:24,node:[[`path`,{d:`m10 9-3 3 3 3`,key:`1oro0q`}],[`path`,{d:`m14 15 3-3-3-3`,key:`bz13h7`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]],aliases:[`code-square`]};qs.node;var Js=N(qs),Ys={name:`square-dashed-mouse-pointer`,size:24,node:[[`path`,{d:`M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z`,key:`xwnzip`}],[`path`,{d:`M5 3a2 2 0 0 0-2 2`,key:`y57alp`}],[`path`,{d:`M19 3a2 2 0 0 1 2 2`,key:`18rm91`}],[`path`,{d:`M5 21a2 2 0 0 1-2-2`,key:`sbafld`}],[`path`,{d:`M9 3h1`,key:`1yesri`}],[`path`,{d:`M9 21h2`,key:`1qve2z`}],[`path`,{d:`M14 3h1`,key:`1ec4yj`}],[`path`,{d:`M3 9v1`,key:`1r0deq`}],[`path`,{d:`M21 9v2`,key:`p14lih`}],[`path`,{d:`M3 14v1`,key:`vnatye`}]],aliases:[`mouse-pointer-square-dashed`]};Ys.node;var Xs=N(Ys),Zs={name:`square-pen`,size:24,node:[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]],aliases:[`pen-box`,`edit`,`pen-square`]};Zs.node;var Qs=N(Zs),$s={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};$s.node;var ec=N($s),tc={name:`telescope`,size:24,node:[[`path`,{d:`m10.065 12.493-6.18 1.318a.934.934 0 0 1-1.108-.702l-.537-2.15a1.07 1.07 0 0 1 .691-1.265l13.504-4.44`,key:`k4qptu`}],[`path`,{d:`m13.56 11.747 4.332-.924`,key:`19l80z`}],[`path`,{d:`m16 21-3.105-6.21`,key:`7oh9d`}],[`path`,{d:`M16.485 5.94a2 2 0 0 1 1.455-2.425l1.09-.272a1 1 0 0 1 1.212.727l1.515 6.06a1 1 0 0 1-.727 1.213l-1.09.272a2 2 0 0 1-2.425-1.455z`,key:`m7xp4m`}],[`path`,{d:`m6.158 8.633 1.114 4.456`,key:`74o979`}],[`path`,{d:`m8 21 3.105-6.21`,key:`1fvxut`}],[`circle`,{cx:`12`,cy:`13`,r:`2`,key:`1c1ljs`}]]};tc.node;var nc=N(tc),rc={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};rc.node;var ic=N(rc),ac={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};ac.node;var oc=N(ac),sc={name:`triangle-exclamation-point`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`,`triangle-alert`]};sc.node;var cc=N(sc),lc={name:`undo-2`,size:24,node:[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]};lc.node;var uc=N(lc),dc={name:`upload`,size:24,node:[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]};dc.node;var fc=N(dc),pc={name:`volume-2`,size:24,node:[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`,key:`ijwkga`}]]};pc.node;var mc=N(pc),hc={name:`wifi-off`,size:24,node:[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};hc.node;var gc=N(hc),_c={name:`wrench`,size:24,node:[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]};_c.node;var vc=N(_c),yc={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};yc.node;var bc=N(yc),xc={name:`zap`,size:24,node:[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]};xc.node;var Sc=N(xc),V=t(sn(),1),Cc=t(Er(),1),wc=e=>Symbol.iterator in e,Tc=e=>`entries`in e,Ec=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},Dc=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function Oc(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:wc(e)&&wc(t)?Tc(e)&&Tc(t)?Ec(e,t):Dc(e,t):Ec({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function kc(e){let t=V.useRef(void 0);return n=>{let r=e(n);return Oc(t.current,r)?t.current:t.current=r}}var Ac=14;function jc(e){for(let t=e.parentElement;t&&t!==document.body;t=t.parentElement)if(getComputedStyle(t).overflowY!==`visible`)return t.getBoundingClientRect();return null}function Mc({open:e,onClose:t,anchor:n,label:r,placement:i=`above`,align:a=`start`,className:o,children:s}){let c=(0,V.useRef)(null),[l,u]=(0,V.useState)(i),[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)(0);return(0,V.useLayoutEffect)(()=>{if(!e)return;let t=()=>{let e=n.current?.getBoundingClientRect(),t=c.current;if(!e||!t)return;let r=jc(t),a=e.top-Math.max(0,r?.top??0)-Ac,o=Math.min(window.innerHeight,r?.bottom??window.innerHeight)-e.bottom-Ac,s=i===`above`?a:o,l=i===`above`?o:a,d=t.scrollHeight>s&&l>s;u(d?i===`above`?`below`:`above`:i),f(Math.max(0,Math.floor(d?l:s)));let p=t.offsetParent;if(!p)return;let h=p.getBoundingClientRect().left+p.clientLeft-p.scrollLeft+t.offsetLeft,g=t.offsetWidth,_=window.innerWidth-28,v=getComputedStyle(t).direction===`rtl`,y=g>_?v?window.innerWidth-Ac-g:Ac:Math.min(Math.max(h,Ac),window.innerWidth-Ac-g);m(y-h)};t();let r=new MutationObserver(t);c.current&&r.observe(c.current,{childList:!0,subtree:!0});let a=typeof ResizeObserver>`u`?null:new ResizeObserver(t);for(let e of[c.current,n.current,c.current?.offsetParent])e&&a?.observe(e);return window.addEventListener(`resize`,t),()=>{r.disconnect(),a?.disconnect(),window.removeEventListener(`resize`,t)}},[e,i,n]),ft(e),(0,V.useEffect)(()=>{if(!e)return;(c.current?.querySelector(`button:not(:disabled), input, [tabindex="0"]`))?.focus({preventScroll:!0});let r=e=>{let r=e.target;c.current?.contains(r)||n.current?.contains(r)||t()},i=e=>{e.key===`Escape`&&(e.stopPropagation(),e.preventDefault(),t(),n.current?.focus())};return document.addEventListener(`mousedown`,r),document.addEventListener(`keydown`,i,!0),()=>{document.removeEventListener(`mousedown`,r),document.removeEventListener(`keydown`,i,!0)}},[e,t,n]),e?I(`div`,{ref:c,className:`popover popover-${l} popover-${a}${o?` ${o}`:``}`,style:{...d===null?{}:{"--popover-room":`${d}px`},...p?{transform:`translateX(${p}px)`}:{}},role:`dialog`,"aria-label":r,children:s}):null}var Nc=[`model_server`,`gaia`,`service`,`agent`,`desktop`,`other`],Pc=or(e=>({open:!1,source:`model_server`,show:(t=`model_server`)=>e({open:!0,source:t}),hide:()=>e({open:!1})})),Fc=8e3,Ic=[],Lc=new Set,Rc=e=>Lc.has(e),zc=()=>Lc.clear(),Bc=or((e,t)=>({need:null,ensure:async n=>{if(Lc.has(n))return!0;let r=t().need;if(r)return r.job===n&&new Promise(e=>{Ic.push(e)});let i,a;try{i=await Promise.race([Kn(n),new Promise((e,t)=>{a=setTimeout(()=>t(Error(`the check timed out`)),Fc)})])}catch(e){return console.warn(`[modelNeeded] could not check the model for ${n}`,e),!0}finally{clearTimeout(a)}if(!i?.needed&&!i?.off)return Lc.add(n),!0;let o=t().need;return o&&o.job!==n?!1:new Promise(t=>{Ic.push(t),o||e({need:i})})},settle:t=>{let n=Ic;Ic=[],e({need:null});for(let e of n)e(t)}})),Vc=e=>Bc.getState().ensure(e),Hc=1e3,Uc=5e3,Wc=24,Gc=1e3,Kc=3e4,qc=0,Jc=null,Yc=!1,Xc=null,Zc=Gc,Qc=0;function $c(){Jc&&clearTimeout(Jc),Jc=null}function el(){Xc&&clearTimeout(Xc),Xc=null}function tl(e,t){return!e.model||sl(e.model,t)}function nl(e,t){let n=++Qc;t({pickLoad:{model:e,seconds:0,error:null}});let r=async()=>{let a=await en();if(n!==Qc)return;let o=Math.floor(a.elapsed_seconds??0);a.state===`warming`?(t({pickLoad:{model:e,seconds:tl(a,e)?o:0,error:null}}),setTimeout(()=>{r().catch(i)},Hc)):a.state===`failed`&&tl(a,e)?t({pickLoad:{model:e,seconds:o,error:a.error?{reason:a.error}:{key:`banner.pickLoad.noReason`,reason:``}}}):t({pickLoad:null})},i=r=>{n===Qc&&(P.system.warn(`Lost track of loading ${e}`,r),t({pickLoad:{model:e,seconds:0,error:{key:`banner.pickLoad.lostTrack`,reason:r instanceof Error?r.message:String(r)}}}))};r().catch(i)}async function rl(e){try{let t=await Zn(`local`);t?.models&&e(t.models)}catch(e){Yc=!1,P.system.warn(`Model names unavailable; raw model ids show until the model list loads`,e)}}var il=or((e,t)=>({active:null,error:null,restoreNotice:null,queued:null,queueError:null,names:{},pickLoad:null,refresh:async()=>{Yc||(Yc=!0,rl(t().rememberNames));try{let n=await an();el(),Zc=Gc;let r=n.restore;(r?.status===`pending`||r?.status===`failed`&&r.retry)&&!Jc&&qc<Wc&&(qc+=1,Jc=setTimeout(()=>{Jc=null,t().refresh()},Uc));let i=(r?.status===`restored`||r?.status===`none`)&&!r.message&&t().restoreNotice?.ok===!1;e({active:n,error:null,...r&&r.status!==`none`&&r.message?{restoreNotice:{ok:r.status===`restored`,message:r.message,model:r.model,reason:r.reason,reasonCode:r.reason_code}}:i?{restoreNotice:null}:{}})}catch(n){e({error:n instanceof Error?n.message:String(n)}),Xc||(Xc=setTimeout(()=>{Xc=null,t().refresh()},Zc),Zc=Math.min(Zc*2,Kc))}},retryNow:()=>{Xc&&(el(),t().refresh())},select:async t=>{zc(),$c();let n=await Se(t),r=null;try{r=(await zt()).sessions}catch(e){P.system.error(`Could not refresh chats after a model switch; the next poll will`,e)}e({active:n,error:null,restoreNotice:null}),n.remote?(Qc+=1,e({pickLoad:null})):nl(t,e),r?.length&&z.getState().setSessions(r)},queue:n=>{e({queued:n,queueError:null}),n&&!z.getState().isStreaming&&t().applyQueued()},applyQueued:async()=>{let n=t().queued;if(n)try{await t().select(n),e({queued:null})}catch(t){e({queued:null,queueError:`Couldn't switch to ${cl(n)}: ${t instanceof Error?t.message:String(t)}`})}},rememberNames:n=>{let r={...t().names};for(let e of n)e.display_name&&(r[e.id]=e.display_name);e({names:r})},dismissRestoreNotice:()=>e({restoreNotice:null}),retryPickLoad:async()=>{let n=t().pickLoad?.model;if(n){try{await x(!0)}catch(t){e({pickLoad:{model:n,seconds:0,error:{key:`banner.pickLoad.startFailed`,reason:t instanceof Error?t.message:String(t)}}});return}nl(n,e)}},dismissPickLoad:()=>{Qc+=1,e({pickLoad:null})}}));async function al(e){zc(),await il.getState().refresh();let t=il.getState().active;t?.model&&!t.remote&&!sl(t.model,e)&&nl(t.model,il.setState);try{let e=(await zt()).sessions;e.length&&z.getState().setSessions(e)}catch(e){P.system.error(`Could not refresh chats after a model setting change; the next poll will`,e)}}z.subscribe((e,t)=>{t.isStreaming&&!e.isStreaming&&il.getState().queued&&il.getState().applyQueued()});function ol(){return il(e=>e.names)}function sl(e,t){if(!e||!t)return!1;let n=e=>e.toLowerCase().replace(/^user\./,``);return n(e)===n(t)}function cl(e){let t=il.getState();return t.names[e]?t.names[e]:t.active?.model===e&&t.active.display_name?t.active.display_name:hl(e)}function ll(e,t){return e.find(e=>e.id===t)??e[0]}function ul(e,t,n=gt){let r=r=>{let i=t?.effective_model||e?.model;return{remote:!1,label:n.bare(`modelStatus.local`),description:r&&i?n.bare(`modelStatus.localNotice`,{model:cl(i)}):null}},i=!!t?.effective_model&&!!e?.model&&t.effective_model!==e.model;return e?.remote&&!(i&&t?.inference_remote!==void 0)?{remote:!0,label:e.provider_name||`a cloud provider`,description:null}:t?.inference_remote===!0?{remote:!0,label:t.inference_provider_name||`a cloud provider`,description:t.inference_description??null}:t?.inference_remote===!1?r(t.inference_description):t===void 0&&e?.inference_remote===!1?r(e.inference_description):null}var dl=`GAIA can't tell whether this chat is answered on this PC or by a cloud provider, so it isn't claiming either.`;function fl(){return ul(il(e=>e.active),z(e=>ll(e.sessions,e.currentSessionId)),L())}function pl(e,t,n){return t.find(e=>e.id===n)?.effective_model||e?.model||null}function ml(e){return/^(fireworks|amd)\./.test(e)?e.slice(e.indexOf(`.`)+1):e}function hl(e){let t=ml(e);return t.slice(t.lastIndexOf(`/`)+1)}function gl(e){let t={};for(let n of e)t[n.id]=n.display_name||cl(n.id);let n=new Map;for(let r of e)n.set(t[r.id],[...n.get(t[r.id])??[],r.id]);for(let e of n.values()){if(e.length<2)continue;let n=e.map(e=>ml(e).split(`/`)),r=e;for(let e=1;e<=Math.max(...n.map(e=>e.length));e++){let t=n.map(t=>t.slice(-e).join(`/`));if(new Set(t).size===t.length){r=t;break}}e.forEach((e,n)=>{t[e]=r[n]})}return t}function _l(e){return e===`fireworks`?`Fireworks AI`:e===`amd`?`AMD LLM Gateway`:e}var vl={loaded:`Loaded`,downloaded:`Downloaded, ready to load`,not_downloaded:`Not downloaded`},yl={"best overall, fastest":`settings.model.note.bestFastest`,cheapest:`settings.model.note.cheapest`,"most truthful":`settings.model.note.mostTruthful`};function bl(e,t=gt){return e?.label?e.source===`expected`?t(`settings.model.expected`,{label:e.label}):e.label:null}function xl(e){return e?`${Math.round(e/1024)}K`:`unknown`}function Sl(e){return e>=1024&&e%1024==0&&e<1048576?xl(e):e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(+(e<1e4))}K`:`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`}function Cl(e){return e.state??(e.downloaded?`downloaded`:`not_downloaded`)}function wl(e,t){if(!e)return!1;if(sl(e,t))return!0;let n=/^(fireworks|amd)\./,r=e=>e.slice(e.lastIndexOf(`/`)+1).replace(n,``);return n.test(e)&&n.test(t)&&e.split(`.`)[0]===t.split(`.`)[0]&&r(e)===r(t)}function Tl(e){let t=e.download_progress?.state;return t===`starting`||t===`downloading`}var El=e=>`${e}`,Dl=/([^]*)/;function Ol({text:e}){return I(F.Fragment,{children:e.split(Dl).map((e,t)=>t%2?I(`bdi`,{dir:`ltr`,children:e},t):e)})}function kl({text:e}){let[t,n]=u(e);return n===void 0?I(Ol,{text:t}):R(F.Fragment,{children:[I(Ol,{text:t}),` `,I(`small`,{className:`i18n-gloss`,lang:`en`,children:I(Ol,{text:n})})]})}function Al({status:e}){let t=L();if(e.error_cause===`model_server_down`&&e.base_url){let n=e.owner===`gaia`?`modelStatus.serverDown.gaia`:`modelStatus.serverDown.notOurs`;return I(kl,{text:t(n,{url:El(e.base_url)})})}return I(F.Fragment,{children:e.error})}function jl(e,t){let n=()=>typeof document<`u`&&document.visibilityState===`hidden`,r=setInterval(()=>{n()||e()},t),i=()=>{n()||e()};return document.addEventListener(`visibilitychange`,i),()=>{clearInterval(r),document.removeEventListener(`visibilitychange`,i)}}function Ml(e){let t=()=>typeof document<`u`&&document.visibilityState===`hidden`,n=t()?null:e(),r=()=>{t()?(n?.(),n=null):n||=e()};return document.addEventListener(`visibilitychange`,r),()=>{document.removeEventListener(`visibilitychange`,r),n?.(),n=null}}var Nl=3e3,Pl={loaded:`modelStatus.state.loaded`,warming:`modelStatus.state.warming`,idle:`modelStatus.state.idle`,stopped:`modelStatus.state.stopped`},Fl={loaded:`modelStatus.pillAria.loaded`,warming:`modelStatus.pillAria.warming`,idle:`modelStatus.pillAria.idle`,stopped:`modelStatus.pillAria.stopped`};function Il(e,t){let n=e.memory;return n?!n.model_gb&&n.free_gb==null?t(`modelStatus.memoryTotal`,{size:`${n.total_gb} GB`,source:n.source}):t.compose(e=>[n.model_gb?e(`modelStatus.memoryUsed`,{size:`~${n.model_gb} GB`}):null,n.free_gb==null?null:e(`modelStatus.memoryFree`,{size:`${n.free_gb} GB`})].filter(Boolean).join(` ·\xA0`)):e.memory_error}function Ll(e,t){return e.label?e.source===`expected`?t(`modelStatus.expected`,{label:e.label}):e.label:null}function Rl(){let e=L(),t=il(e=>e.active);il(e=>e.names);let n=fl(),r=z(e=>e.systemStatus),i=z(e=>e.openSettings),a=Pc(e=>e.show),o=(0,V.useRef)(null),[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(null),[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)(!1),[h,g]=(0,V.useState)(!1),_=(0,V.useCallback)(async()=>{try{u(await re()),f(null)}catch(e){f(e instanceof Error?e.message:String(e))}},[]);(0,V.useEffect)(()=>{if(s)return _(),jl(()=>{_()},Nl)},[s,_]);let v=(0,V.useCallback)(async e=>{g(!1),m(!0),f(null);try{await cn(e),await _()}catch(e){f(e instanceof Error?e.message:String(e))}finally{m(!1)}},[_]),y=r?r.lemonade_running?sl(r.model_loaded,t?.model)?`loaded`:`idle`:`stopped`:`idle`,b=n?.remote?Pi:n?Wi:Ei,x=t?.model?cl(t.model):null,S=[n?.label,x].filter(Boolean).join(` · `)||e(`modelStatus.fallbackName`),C=n?n.description??(n.remote?e(`modelStatus.sentTo`,{name:n.label}):e(`modelStatus.runsHere`)):dl,w=l,T=p||!!w?.restarting,E=!!w&&w.owner!==`gaia`,ee=!!w&&!(E&&w.state===`stopped`);return R(`div`,{className:`sb-location-wrap`,children:[R(`button`,{ref:o,type:`button`,className:`sb-location`,onClick:()=>c(e=>!e),"aria-haspopup":`dialog`,"aria-expanded":s,"aria-label":n?.remote?S:e(Fl[y],{text:S}),title:x?`${S}. ${C}`:C,children:[I(b,{size:13,"aria-hidden":`true`}),R(`span`,{className:`sb-location-text`,children:[n?.label&&x&&I(`span`,{className:`sb-location-place`,children:n.label}),I(`span`,{className:`sb-location-name`,dir:`auto`,children:x??n?.label??e(`modelStatus.fallbackName`)})]}),!n?.remote&&I(`span`,{className:`sb-location-dot is-${y}`,"aria-hidden":`true`})]}),I(Mc,{open:s,onClose:()=>c(!1),anchor:o,label:e(`modelStatus.label`),placement:`above`,children:R(`div`,{className:`model-status`,children:[!w&&!d&&R(`span`,{children:[I(B,{size:13,className:`spin`}),` `,e(`modelStatus.checking`)]}),w&&R(F.Fragment,{children:[R(`div`,{className:`model-status-head`,children:[I(`span`,{className:`model-status-dot is-${w.state}`,"aria-hidden":`true`}),I(`span`,{role:`status`,children:w.state===`loaded`&&w.busy_reason===`request`?e(`modelStatus.state.loadedAnswering`):e(Pl[w.state])})]}),w.active_remote&&I(`span`,{className:`settings-hint`,children:e(`modelStatus.cloudLine`,{name:w.active_display_name??w.active_model??`—`})}),R(`dl`,{className:`model-status-grid`,children:[I(`dt`,{children:e(`modelStatus.model`)}),I(`dd`,{title:w.model??w.active_model??void 0,children:I(`bdi`,{children:w.display_name??(w.active_remote?`—`:w.active_display_name)??`—`})}),w.placement&&R(F.Fragment,{children:[I(`dt`,{children:e(`modelStatus.runsOn`)}),I(`dd`,{children:I(`bdi`,{children:Ll(w.placement,e)})})]}),w.state!==`stopped`&&R(F.Fragment,{children:[I(`dt`,{children:e(`modelStatus.memory`)}),I(`dd`,{children:Il(w,e)??e(`modelStatus.unknown`)})]}),w.ctx_size!=null&&R(F.Fragment,{children:[I(`dt`,{children:e(`modelStatus.context`)}),I(`dd`,{children:e(`settings.ctx.tokens`,{size:xl(w.ctx_size)})})]})]}),w.placement?.warning&&I(`span`,{className:`model-status-warning`,role:`alert`,children:w.placement.warning}),w.error&&I(`span`,{className:`settings-error`,role:`alert`,title:w.error_detail??void 0,children:I(Al,{status:w})}),w.restart_error&&I(`span`,{className:`settings-error`,role:`alert`,children:w.restart_error})]}),d&&I(`span`,{className:`settings-error`,role:`alert`,children:d}),h&&w&&R(`div`,{className:`model-status-confirm`,role:`alert`,children:[I(`span`,{children:e(`modelStatus.confirm`,{name:w.display_name??de(`modelStatus.theModel`),url:w.base_url??`—`})}),R(`div`,{className:`model-status-actions`,children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>g(!1),children:e(`modelStatus.cancel`)}),I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void v(!0),children:e(`modelStatus.reloadIt`)})]})]}),R(`div`,{className:`model-status-actions`,children:[R(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{c(!1),i(`model`)},children:[I(As,{size:13,"aria-hidden":`true`}),` `,e(`modelStatus.settings`)]}),!w?.active_remote&&R(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{c(!1),a(`model_server`)},children:[I(ws,{size:13,"aria-hidden":`true`}),` `,e(`logs.serverLog`)]}),ee&&R(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>E?g(!0):void v(!1),disabled:T||!w||w.busy||w.active_remote&&w.state!==`loaded`,title:w?.busy?w.busy_reason===`warm_up`?e(`modelStatus.busyWarmUp`):e(`modelStatus.busyRequest`):w?.state===`stopped`?e(`modelStatus.startServer`):e(`modelStatus.reload`),children:[T?I(B,{size:13,className:`spin`}):I(bs,{size:13,"aria-hidden":`true`}),e(T?`modelStatus.restarting`:`modelStatus.restart`)]})]})]})})]})}var zl=1e3;function Bl(e){return e?e.state===`running`||e.state===`verifying`||!!e.models?.some(e=>e.state===`downloading`||e.state===`verifying`):!1}function Vl(e,t){if(!e)return null;if(e.state===`running`||e.state===`verifying`)return e;let n=(e.models??[]).filter(e=>t.includes(e.id)||e.state===`downloading`||e.state===`failed`||e.state===`cancelled`),r=n.filter(e=>e.state!==`skipped`),i=r.reduce((e,t)=>e+Math.min(t.bytes_done,t.bytes_total),0),a=r.reduce((e,t)=>e+t.bytes_total,0),o=r.filter(e=>e.state===`downloading`).reduce((e,t)=>e+t.speed_bps,0);return{...e,models:n,overall:{bytes_done:i,bytes_total:a,speed_bps:o,eta_s:o>0?Math.round((a-i)/o):null,percent:a?Math.floor(i*100/a):null,failed:r.filter(e=>e.state===`failed`).length}}}var Hl=null;function Ul(e){return e instanceof Error?e.message:String(e)}var Wl=or((e,t)=>{let n=()=>{let e=Bl(t().status)||t().queue.length>0;e&&!Hl&&(Hl=setInterval(()=>{t().refresh()},zl)),!e&&Hl&&(clearInterval(Hl),Hl=null)},r=async()=>{let{status:n,queue:r}=t();if(r.length===0||Bl(n))return;let[i,...a]=r;e({queue:a});try{e({status:await ut(i.id,i),error:null})}catch(t){e({error:Ul(t)})}};return{status:null,error:null,queue:[],started:[],refresh:async()=>{try{e({status:await $t(),error:null})}catch(t){e({error:`Lost contact with GAIA: ${Ul(t)}`})}await r(),n()},enqueue:async(t,i={})=>{let a=t.map(e=>({id:e,acknowledgeLowDisk:!!i.acknowledgeLowDisk,keepTrying:!!i.keepTrying}));e(e=>({queue:[...e.queue.filter(e=>!t.includes(e.id)),...a],started:[...new Set([...e.started,...t])],error:null})),await r(),n()},cancel:async n=>{e(e=>({queue:n?e.queue.filter(e=>e.id!==n):[]}));try{await ne(n)}catch(t){e({error:Ul(t)})}await t().refresh()}}});function Gl({placement:e=`sidebar`}){let t=L(),n=Wl(e=>e.status),r=Wl(e=>e.started),i=Wl(e=>e.queue),a=Vl(n,r),o=Wl(e=>e.refresh),s=z(e=>e.openSettings),c=z(e=>e.dismissDownloadFailure),l=z(e=>e.systemStatus?.download_progress??null);(0,V.useEffect)(()=>{o()},[o]);let u=(a?.models??[]).filter(e=>e.state!==`skipped`),d=Bl(a)||i.length>0,f=l?.state===`starting`||l?.state===`downloading`,p=d||f,m=u.some(e=>e.state===`failed`)&&a?.state!==`running`,h=!p&&(m||l?.state===`error`);if(!p&&!h)return null;let g=u.filter(e=>e.state!==`failed`&&e.state!==`cancelled`),_=g.length+i.length,v=g.filter(e=>e.state===`ready`||e.state===`verifying`||e.state===`unchecked`).length,y=d?a?.overall?.percent??0:l?.percent??0,b=d?Math.min(_,v+1):1,x=d?_:1,S=!p&&l?.state===`error`&&!!l.model_name;return R(`div`,{className:`download-chip-row is-${e}`,children:[R(`button`,{type:`button`,className:`download-chip is-${e}${h&&!p?` is-failed`:``}`,onClick:()=>s(`model`),"aria-label":t(`download.chipAria`),title:t(`download.chipAria`),children:[I(h?wi:Ji,{size:13,"aria-hidden":`true`}),I(`span`,{children:h?t(`download.chipFailed`):t(`download.chip`,{done:String(b),count:String(x),pct:String(y)})}),p&&I(`span`,{className:`download-chip-bar`,"aria-hidden":`true`,children:I(`span`,{style:{inlineSize:`${y}%`}})})]}),S&&I(`button`,{type:`button`,className:`download-chip-dismiss`,onClick:()=>{let e=l?.model_name;e&&c(e).catch(()=>{})},"aria-label":t(`download.dismissFailed`),title:t(`download.dismissFailed`),children:I(bc,{size:12,"aria-hidden":`true`})})]})}var Kl=500,ql=`gaia_always_allow_tools`;function Jl(){try{localStorage.getItem(`gaia_always_allow_tools`)!==null&&(localStorage.removeItem(ql),console.warn(`[notificationStore] Discarded a persisted "always allow" tool list from an earlier version. Grants now cover one call in one chat and are listed in Settings → Permissions.`))}catch(e){console.error(`[notificationStore] Could not clear the legacy always-allow list:`,e)}}var Yl=`allow_path_access`;function Xl(e){let{path:t,kind:n}=e??{};return{target:typeof t==`string`&&t.trim()?t:null,kind:n}}function Zl(e,t=!1,n=gt,r=e=>e){let{target:i,kind:a}=Xl(e),o=i?de(a===`folder`?`prompt.path.what.folder`:a===`file`?`prompt.path.what.file`:`prompt.path.what.new`,{path:r(i)}):de(`prompt.path.what.unknown`);return n(t?`prompt.path.askAlso`:`prompt.path.ask`,{what:o})}function Ql(e,t=!1,n=gt){let{kind:r}=Xl(e);return n(`prompt.path.${t?`titleAlso`:`title`}.${r===`folder`?`folder`:r===`file`?`file`:`location`}`)}var $l={run_python:`prompt.title.python`,execute_python_file:`prompt.title.pythonFile`,run_shell_command:`prompt.title.command`};function eu(e,t=gt,n=e=>e){let r=e.toolArgs??{};if(e.tool===`allow_path_access`)return{heading:Ql(r,e.pathFollowUp,t),question:Zl(r,e.pathFollowUp,t,n)};if(e.tool===`trust_project_folder`)return{heading:t(`prompt.trust.title`),question:t(`prompt.trust.ask`)};let i=tu(e,t)??n(e.toolLabel??e.tool??``),a=$l[e.tool??``];return{heading:a?t(a):t(e.toolLabel?`prompt.title.tool`:`prompt.title.toolId`,{tool:i}),question:t(`prompt.needsOk`,{tool:i})}}function tu(e,t){let n=`tool.${e.tool}.active`;if(!e.toolLabel||!j(n))return null;let r=t.bare(n);return r.charAt(0).toLowerCase()+r.slice(1)}var nu=`changes to files in `,ru=`bash_execute:exact:`,iu=`bash_execute:cmd:`;function au(e,t=e=>e){if(e?.startsWith(ru)){let n=e.slice(19);if(n)return de(`prompt.always.command`,{command:t(n)})}if(e?.startsWith(iu)){let n=e.slice(17);if(n)return de(`prompt.always.commands`,{command:t(n)})}return null}function ou(e,t){let n=au(e.alwaysScope);if(n)return t.bare(n.ref,n.params);if(e.alwaysScope?.startsWith(nu))return t.bare(`prompt.always.changes`,{folder:e.alwaysScope.slice(20)});let r=tu(e,t),i=`${e.tool} `;if(!r||!e.alwaysScope?.startsWith(i))return null;let a=e.alwaysScope.slice(i.length);return a.startsWith(`on files in `)?t.bare(`prompt.always.folder`,{action:r,folder:a.slice(12)}):t.bare(`prompt.always.file`,{action:r,name:a.startsWith(`on `)?a.slice(3):a})}function su(e){return e.trim().replace(/\\/g,`/`).replace(/\/+$/,``).toLowerCase()}function cu(e){let t=[`file_path`,`path`,`directory`,`dir_path`,`destination`].map(t=>e?.[t]).find(e=>typeof e==`string`&&e.trim());return typeof t==`string`?t:null}function lu(e,t,n){let r=e.find(e=>e.type===`permission_request`&&e.sessionId===t);if(!r||r.response!==`allow`||r.tool===`allow_path_access`)return!1;let i=cu(r.toolArgs),{path:a}=n??{};if(!i||typeof a!=`string`||!a.trim())return!1;let o=su(i),s=su(a);return o===s||o.startsWith(`${s}/`)?!0:!/^([a-z]:)?\//.test(o)&&!o.startsWith(`~`)&&s.endsWith(`/${o.replace(/^\.\//,``)}`)}function uu(e){return e===`share_engineering_context`||e===`append_engineering_context`||e===`approve_engineering_code`||e===`allow_path_access`||e===`trust_project_folder`}function du(e,t){return!t.alwaysScope||!t.sessionId||uu(t.tool)||t.risk===`destructive`?0:e.filter(e=>e.id!==t.id&&e.type===`permission_request`&&e.sessionId===t.sessionId&&e.response===`allow`&&e.tool===t.tool&&e.alwaysScope===t.alwaysScope&&e.risk===t.risk).length}var fu=or((e,t)=>({notifications:[],showPanel:!1,typeFilter:null,addNotification:t=>e(e=>{let n=e.notifications.find(e=>e.id===t.id);return n?n.response?e:{notifications:e.notifications.map(e=>e.id===t.id?{...t,read:n.read}:e)}:{notifications:[t,...e.notifications].slice(0,Kl)}}),dismiss:t=>e(e=>({notifications:e.notifications.map(e=>e.id===t?{...e,dismissed:!0}:e)})),markRead:t=>e(e=>({notifications:e.notifications.map(e=>e.id===t?{...e,read:!0}:e)})),markAllRead:()=>e(e=>({notifications:e.notifications.map(e=>({...e,read:!0}))})),clearAll:()=>e({notifications:[]}),setShowPanel:t=>e({showPanel:t}),setTypeFilter:t=>e({typeFilter:t}),dismissSessionPrompts:t=>e(e=>({notifications:e.notifications.map(e=>e.type===`permission_request`&&e.sessionId===t&&!e.response?{...e,dismissed:!0}:e)})),respondToPermission:async(n,r)=>{let i=t().notifications.find(e=>e.id===n);if(!i)throw Error(`That permission request is no longer pending.`);let a=r!==`deny`,o=r===`always`&&!uu(i.tool),s=window.gaiaAPI;if(i.sessionId)await Mn(i.sessionId,a,{always:o,confirmId:i.confirmId});else if(s?.notification?.respondPermission)await s.notification.respondPermission(n,a?`allow`:`deny`,o);else throw Error(`No agent is waiting for this answer any more.`);e(e=>({notifications:e.notifications.map(e=>e.id===n?{...e,response:a?`allow`:`deny`,respondedAt:Date.now(),read:!0}:e)}));let c=z.getState();i.sessionId&&i.sessionId===c.currentSessionId&&c.awaitingUser&&c.setAwaitingUser(!1)}})),pu=e=>e.notifications.filter(e=>!e.read&&!e.dismissed).length,mu=e=>{let t=e.notifications.filter(e=>!e.dismissed);return e.typeFilter?t.filter(t=>t.type===e.typeFilter):t},hu=e=>[...new Set(e.notifications.filter(e=>!e.dismissed).map(e=>e.type))],gu=e=>t=>t.notifications.find(t=>t.type===`permission_request`&&t.sessionId===e&&!t.response&&!t.dismissed)??null,_u=e=>[...new Set(e.notifications.filter(e=>e.type===`permission_request`&&e.sessionId&&!e.response&&!e.dismissed).map(e=>e.sessionId))].sort(),vu=`gaia_alert_settings`,yu={modes:{needs_approval:`banner`,question:`banner`,finished:`banner`},sound:!1,flash:!0,keepAwake:!0,batteryFloor:20},bu=[`banner`,`badge`,`off`];function xu(){let e=null;try{e=localStorage.getItem(vu)}catch(e){return console.warn(`[alerts] Notification settings unreadable (site data blocked); using defaults.`,e),yu}if(!e)return yu;let t;try{t=JSON.parse(e)}catch(e){return console.warn(`[alerts] Saved notification settings are corrupt; using defaults.`,e),yu}let n={...yu.modes};for(let e of Object.keys(n)){let r=t.modes?.[e];r!==void 0&&bu.includes(r)?n[e]=r:r!==void 0&&console.warn(`[alerts] Ignored unknown mode ${String(r)} for ${e}.`)}let r=(e,t)=>typeof e==`boolean`?e:t,i=t.batteryFloor;return{modes:n,sound:r(t.sound,yu.sound),flash:r(t.flash,yu.flash),keepAwake:r(t.keepAwake,yu.keepAwake),batteryFloor:typeof i==`number`&&i>=0&&i<=100?i:yu.batteryFloor}}function Su(e){try{localStorage.setItem(vu,JSON.stringify(e))}catch(e){console.warn(`[alerts] Notification settings not saved; they will reset on reload.`,e)}}var Cu=e=>({modes:e.modes,sound:e.sound,flash:e.flash,keepAwake:e.keepAwake,batteryFloor:e.batteryFloor}),wu=or((e,t)=>({...xu(),setMode:(n,r)=>{e({modes:{...t().modes,[n]:r}}),Su(Cu(t()))},update:n=>{e(n),Su(Cu(t()))}}));function Tu(e){let t=new Date(e.updated_at).getTime();return Number.isNaN(t)?0:t}function Eu(e,t=new Date){let n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=864e5,i=[{label:`Today`,sessions:[]},{label:`Yesterday`,sessions:[]},{label:`Previous 7 days`,sessions:[]},{label:`Previous 30 days`,sessions:[]},{label:`Older`,sessions:[]}],a=[...e].sort((e,t)=>Tu(t)-Tu(e));for(let e of a){let t=Tu(e);i[t>=n?0:t>=n-r?1:t>=n-7*r?2:t>=n-30*r?3:4].sessions.push(e)}return i.filter(e=>e.sessions.length>0)}function Du(e,t){return t.awaiting[e.id]||t.prompting.includes(e.id)?`waiting`:t.queued.includes(e.id)?`queued`:t.running.includes(e.id)?`running`:e.last_run_status===`failed`?`failed`:e.last_run_status===`done`||e.last_run_status===`stopped`?`done`:null}function Ou(e){return e.kind===`eval`||e.kind===`scheduled`}function ku(e,t,{showAutomated:n=!1,now:r=new Date}={}){let i=n?e:e.filter(e=>!Ou(e)),a=(e,t)=>Tu(t)-Tu(e),o=i.filter(e=>Du(e,t)===`waiting`).sort(a),s=i.filter(e=>e.pinned&&!o.includes(e)).sort(a),c=i.filter(e=>!o.includes(e)&&!s.includes(e)),l=[];return o.length&&l.push({label:`Needs you`,sessions:o}),s.length&&l.push({label:`Pinned`,sessions:s}),[...l,...Eu(c,r)]}function Au(e){return e.filter(Ou).length}function ju(e,t,n){let r={};for(let t of e)r[t]=`running`;for(let[e,n]of Object.entries(t))r[e]=n;for(let e of n)r[e]=`permission`;return r}function Mu(e,t){let n=[];for(let[r,i]of Object.entries(t))i!==e[r]&&(i===`permission`?n.push({sessionId:r,event:`needs_approval`}):i===`question`&&n.push({sessionId:r,event:`question`}));for(let r of Object.keys(e))r in t||n.push({sessionId:r,event:`finished`});return n}var Nu={needs_approval:`GAIA needs your approval`,question:`GAIA has a question`,finished:`GAIA finished`};function Pu(e,t){let n=t?.title||`A chat`;if(e!==`finished`)return{title:Nu[e],body:n};switch(t?.last_run_status){case`done`:return{title:Nu.finished,body:n};case`failed`:return{title:`GAIA hit a problem`,body:n};case`stopped`:return{title:`GAIA stopped`,body:n};default:return{title:`A chat stopped running`,body:n}}}function Fu(e,t,n){return n&&e===t}function Iu(e,t,n,r){let i=0;for(let a of e){if(a.kind===`eval`||a.kind===`scheduled`)continue;let e=t[a.id];(e===`permission`&&n.needs_approval!==`off`||e===`question`&&n.question!==`off`||!e&&a.unread&&a.id!==r&&n.finished!==`off`)&&i++}return i}function Lu(e,t){return!e||e.charging||t<=0?!0:e.level*100>=t}function Ru(){let e=window.AudioContext??window.webkitAudioContext;if(!e)throw Error(`This browser has no Web Audio, so GAIA cannot play the alert sound.`);let t=new e,n=t.currentTime;[660,880].forEach((e,r)=>{let i=t.createOscillator(),a=t.createGain();i.frequency.value=e,a.gain.setValueAtTime(1e-4,n+r*.12),a.gain.exponentialRampToValueAtTime(.15,n+r*.12+.02),a.gain.exponentialRampToValueAtTime(1e-4,n+r*.12+.18),i.connect(a).connect(t.destination),i.start(n+r*.12),i.stop(n+r*.12+.2)}),setTimeout(()=>void t.close(),600)}function zu(e,t,n){return e.compose((e,r)=>e(t,{place:r===he?Bu(n):n}))}function Bu(e){let t=e%100;return`${e}${t>=11&&t<=13?`th`:{1:`st`,2:`nd`,3:`rd`}[e%10]??`th`}`}function Vu(){return typeof navigator<`u`&&/Mac/i.test(navigator.platform)}function Hu(e=typeof navigator<`u`?navigator.platform:``){return/Mac/i.test(e)?`/Users/you/Documents/a.pdf`:/Win/i.test(e)?`C:\\Users\\you\\Documents\\manual.pdf`:`/home/you/Documents/manual.pdf`}var Uu={Ctrl:`⌃`,Alt:`⌥`,Shift:`⇧`,Mod:`⌘`},Wu=[`Ctrl`,`Alt`,`Shift`,`Mod`];function Gu(e,t=Vu()){let n=e.split(`+`),r=n.pop(),i=n.filter(e=>!(e in Uu));if(i.length)throw Error(`formatShortcut: unknown modifier(s) ${i.join(`, `)} in "${e}"; use Ctrl, Alt, Shift or Mod`);return t?Wu.filter(e=>n.includes(e)).map(e=>Uu[e]).join(``)+r:[...n.map(e=>e===`Mod`?`Ctrl`:e),r].join(`+`)}var Ku=new Set([`New chat`,`New Task`]);function qu(e,t){let n=t.sessions.find(t=>t.id===e);return!(!n||!Ku.has(n.title)||(n.message_count??0)!==0||t.runningSessionIds.includes(e)||t.messageQueues?.[e]?.length||t.pendingPrompt?.sessionId===e||t.currentSessionId===e&&(t.messages.length!==0||t.isStreaming))}async function Ju(e){if(!e)return!1;let t=z.getState();if(!qu(e,{sessions:t.sessions,currentSessionId:t.currentSessionId,messages:t.messages,isStreaming:t.isStreaming,runningSessionIds:t.runningSessionIds,messageQueues:t.messageQueues,pendingPrompt:t.pendingPrompt}))return!1;P.chat.info(`Removing abandoned draft session ${e}`),t.addPendingDelete(e),t.removeSession(e);try{return await lr(e),!0}catch(t){return P.chat.warn(`Failed to delete abandoned draft ${e}`,t),!1}finally{t.removePendingDelete(e)}}var Yu=32768,Xu=`Gemma-4-E4B-it-GGUF`,Zu=3e5,Qu=18e5,$u=1e4,ed=`GAIA is starting…`,td=new Set([`calendar/create_calendar_event`,`calendar/update_calendar_event`,`calendar/cancel_calendar_event`]),nd=/^(\d{4})-(\d{2})-(\d{2})$/,rd={year:`numeric`,month:`short`,day:`numeric`},id={hour:`numeric`,minute:`2-digit`,timeZoneName:`short`},ad=new Map;function od(e){let t=ad.get(e);return t||(t={time:new Intl.DateTimeFormat(e,{...rd,...id}),timeOnly:new Intl.DateTimeFormat(e,id),date:new Intl.DateTimeFormat(e,rd)},ad.set(e,t)),t}var sd=new Set([` `,`
11
+ `,`‌`,`‍`,`‎`,`‏`]),cd=new Set([`͏`,`ᅟ`,`ᅠ`,`⠀`,`ㅤ`,`ᅠ`]),ld=[[173,173],[847,847],[1564,1564],[4447,4448],[6068,6069],[6155,6159],[8203,8207],[8234,8238],[8288,8303],[12644,12644],[65024,65039],[65279,65279],[65440,65440],[65520,65528],[113824,113827],[119155,119162],[917504,921599]],ud=[[65024,65039],[917760,917999]],dd=[[169,169],[174,174],[8252,8252],[8265,8265],[8482,8482],[8505,8505],[8596,8601],[8617,8618],[8986,8987],[9e3,9e3],[9167,9167],[9193,9203],[9208,9210],[9410,9410],[9642,9643],[9654,9654],[9664,9664],[9723,9726],[9728,9732],[9742,9742],[9745,9745],[9748,9749],[9752,9752],[9757,9757],[9760,9760],[9762,9763],[9766,9766],[9770,9770],[9774,9775],[9784,9786],[9792,9792],[9794,9794],[9800,9811],[9823,9824],[9827,9827],[9829,9830],[9832,9832],[9851,9851],[9854,9855],[9874,9879],[9881,9881],[9883,9884],[9888,9889],[9895,9895],[9898,9899],[9904,9905],[9917,9918],[9924,9925],[9928,9928],[9934,9935],[9937,9937],[9939,9940],[9961,9962],[9968,9973],[9975,9978],[9981,9981],[9986,9986],[9989,9989],[9992,9997],[9999,9999],[10002,10002],[10004,10004],[10006,10006],[10013,10013],[10017,10017],[10024,10024],[10035,10036],[10052,10052],[10055,10055],[10060,10060],[10062,10062],[10067,10069],[10071,10071],[10083,10084],[10133,10135],[10145,10145],[10160,10160],[10175,10175],[10548,10549],[11013,11015],[11035,11036],[11088,11088],[11093,11093],[12336,12336],[12349,12349],[12951,12951],[12953,12953],[126980,126980],[127020,127023],[127124,127135],[127151,127152],[127168,127168],[127183,127184],[127222,127231],[127344,127345],[127358,127359],[127374,127374],[127377,127386],[127406,127461],[127489,127503],[127514,127514],[127535,127535],[127538,127546],[127548,127551],[127561,127583],[127590,127777],[127780,127891],[127894,127895],[127897,127899],[127902,127984],[127987,127989],[127991,127994],[128e3,128253],[128255,128317],[128329,128334],[128336,128359],[128367,128368],[128371,128378],[128391,128391],[128394,128397],[128400,128400],[128405,128406],[128420,128421],[128424,128424],[128433,128434],[128444,128444],[128450,128452],[128465,128467],[128476,128478],[128481,128481],[128483,128483],[128488,128488],[128495,128495],[128499,128499],[128506,128591],[128640,128709],[128715,128722],[128725,128741],[128745,128745],[128747,128752],[128755,128767],[128986,129023],[129036,129039],[129096,129103],[129114,129119],[129160,129167],[129198,129199],[129212,129215],[129218,129231],[129241,129279],[129292,129338],[129340,129349],[129351,129535],[129624,129631],[129646,129791],[130048,131069]],fd=[[13312,19903],[19968,40959],[63744,64255],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[191472,192095],[194560,195103],[196608,201551],[201552,205743]],pd=new Set([...`0123456789#*`]),md=/^[\p{Cf}\p{Cc}\p{Zl}\p{Zp}]$/u;function hd(e,t){let n=t.codePointAt(0)??-1;return e.some(([e,t])=>e<=n&&n<=t)}var gd=e=>hd(ud,e);function _d(e,t){return t.has(e)||gd(e)?!1:cd.has(e)||md.test(e)||hd(ld,e)}function vd(e,t){let n=e[t],r=t>0?e[t-1]:``;if(!r)return!1;if(n===`︎`||n===`️`)return hd(dd,r)?!0:n===`️`&&pd.has(r)&&e[t+1]===`⃣`;let i=n.codePointAt(0)??0;return i>=917760&&i<=917999&&hd(fd,r)}function yd(e,t,n){let r=[...t.replace(/\r\n/g,`
12
+ `)],i=r.map((t,n)=>(gd(t)?!vd(r,n):_d(t,e))?`[U+${t.codePointAt(0).toString(16).toUpperCase().padStart(4,`0`)}]`:t).join(``);return n?i:i.replace(/\n/g,`[U+000A]`)}function bd(e,t){return yd(sd,e,t)}var xd=new Set,Sd=new Set([` `,`
13
+ `]),Cd=e=>`[U+${e.codePointAt(0).toString(16).toUpperCase().padStart(4,`0`)}]`,wd=(e,t)=>gd(e)||_d(e,t);function Td(e){return[...e].map(e=>wd(e,xd)?Cd(e):e).join(``)}function Ed(e){return[...e.replace(/\r\n/g,`
14
+ `)].map(e=>wd(e,Sd)?Cd(e):e).join(``)}function Dd(e){return typeof e==`string`&&[...e].some(e=>wd(e,xd))}function Od(e){return typeof e==`string`&&[...e.replace(/\r\n/g,`
15
+ `)].some(e=>wd(e,Sd))}function kd(e){return bd(e,!1)}var Ad=/[\u202A-\u202E]/,jd=/[\u2066-\u2068]/,Md=`⁩`;function Nd(e){return e.split(`
16
+ `).map(e=>{let t=[...e],n=new Set,r=[];return t.forEach((e,t)=>{Ad.test(e)?n.add(t):jd.test(e)?r.push(t):e===Md&&r.pop()===void 0&&n.add(t)}),r.forEach(e=>n.add(e)),t.map((e,t)=>n.has(t)?bd(e,!1):e).join(``)}).join(`
17
+ `)}var Pd=`This text holds characters that don't show. Those that hide or reorder text appear as [U+XXXX]; ideograph variant marks are kept as written. They are saved as written.`;function Fd(e,t){if(typeof t!=`string`)return!1;let n=[...t.replace(/\r\n/g,`
18
+ `)];return n.some((t,r)=>{let i=t.codePointAt(0)??0;return i>=917760&&i<=917999?!0:gd(t)?!vd(n,r):_d(t,e)})}function Id(e){return Fd(sd,e)}var Ld=`<<<UNTRUSTED_TEXT>>>`,Rd=`<<<END_UNTRUSTED_TEXT>>>`;function zd(e){if(e===`<`||e===`>`)return e;let t=e.normalize(`NFKC`);return t===`<`||t===`>`?t:``}function Bd(e){if(typeof e!=`string`)return``;let t=e,n=``;for(;n!==t;)n=t,t=t.split(Ld).join(``).split(Rd).join(``);let r=[...t],i=``,a=0;for(;a<r.length;){let e=zd(r[a]);if(!e){i+=r[a],a+=1;continue}let t=0,n=a;for(let i=a;i<r.length;i++)if(zd(r[i])===e)t+=1,n=i;else if(!_d(r[i],sd))break;i+=t>=3?e+e:r.slice(a,n+1).join(``),a=n+1}return i}function Vd(e,t=!1){return yd(sd,Bd(e),t)}function Hd(e){let t=nd.exec(e);return t?new Date(Number(t[1]),Number(t[2])-1,Number(t[3])):null}function Ud({start:e,end:t}){let n=L(),{time:r,timeOnly:i,date:a}=od(n.locale),o=Hd(e);if(o){let e=Hd(t),r=e&&e>o?`${a.format(o)} – ${a.format(e)}`:a.format(o);return R(F.Fragment,{children:[I(`bdi`,{dir:`auto`,children:r}),` (`,n(`permission.calendar.allDay`),`)`]})}let s=new Date(e),c=new Date(t);if(Number.isNaN(s.getTime()))return I(`bdi`,{dir:`ltr`,children:e});let l=r.format(s);if(!Number.isNaN(c.getTime())&&c>s){let e=a.format(s)===a.format(c);l+=` – ${(e?i:r).format(c)}`}return I(`bdi`,{dir:`auto`,children:l})}function Wd({value:e}){return I(`bdi`,{dir:`auto`,children:e})}function Gd({tool:e,args:t}){let n=L(),r=Array.isArray(t.notify_attendees)?t.notify_attendees.map(e=>Vd(e)).filter(Boolean):[],i=[],a=(e,t,n=!1)=>{let r=Vd(t,n);r&&i.push([e,I(Wd,{value:r})])},o=()=>{let e=Vd(t.calendar_account);e&&i.push([n(`permission.calendar.account`),I(`bdi`,{dir:`ltr`,children:e})])};e===`calendar/create_calendar_event`?(a(n(`permission.calendar.title`),t.title),i.push([n(`permission.calendar.when`),I(Ud,{start:Vd(t.start),end:Vd(t.end)})]),o(),a(n(`permission.calendar.location`),t.location),a(n(`permission.calendar.description`),t.description,!0)):(a(n(`permission.calendar.event`),t.expected_title),i.push([n(`permission.calendar.when`),I(Ud,{start:Vd(t.expected_start),end:``})]),o(),a(n(`permission.calendar.newTitle`),t.new_title),Vd(t.new_start)&&i.push([n(`permission.calendar.newTime`),I(Ud,{start:Vd(t.new_start),end:Vd(t.new_end)})]),a(n(`permission.calendar.newLocation`),t.new_location),a(n(`permission.calendar.newDescription`),t.new_description,!0));let s=[...Object.values(t),...Array.isArray(t.notify_attendees)?t.notify_attendees:[]],c=typeof t._risk_note!=`string`&&s.some(e=>Fd(sd,e))?Pd:``;return R(F.Fragment,{children:[R(`dl`,{className:`perm-card-facts`,"data-testid":`perm-calendar`,children:[i.map(([e,t])=>R(V.Fragment,{children:[I(`dt`,{children:e}),I(`dd`,{children:t})]},e)),I(`dt`,{children:r.length?n.plural(`permission.calendar.notifies`,r.length):n(`permission.calendar.noOne`)}),I(`dd`,{children:r.length>0&&I(`div`,{className:`perm-card-people`,tabIndex:0,children:r.map(e=>I(Wd,{value:e},e))})})]}),c&&I(`p`,{className:`perm-card-risk`,role:`note`,"data-testid":`perm-calendar-unseen`,children:c})]})}var Kd=new Set([``,`new chat`,`new task`,`untitled`,`untitled session`,`chat`]);function qd(e){return Kd.has((e??``).trim().toLowerCase())}function Jd(e,t){let n=Nd(t?.title??``);if(t?.kind!==`scheduled`)return n;if(n===gt(`chat.title.goals`))return e(`chat.title.goals`);let r=gt(`chat.title.schedule`,{name:``});return n.startsWith(r)&&n.length>r.length?e(`chat.title.schedule`,{name:n.slice(r.length)}):n}function Yd(e){let[t,n]=(0,V.useState)(()=>typeof window.matchMedia==`function`&&window.matchMedia(e).matches);return(0,V.useEffect)(()=>{if(typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),r=()=>n(t.matches);return r(),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}var Xd=e=>`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`;function Zd(){let[e,t]=(0,V.useState)(()=>new Date);return(0,V.useEffect)(()=>{let e,n=()=>t(e=>Xd(e)===Xd(new Date)?e:new Date),r=()=>{let t=new Date,i=new Date(t.getFullYear(),t.getMonth(),t.getDate()+1).getTime();e=setTimeout(()=>{n(),r()},i-t.getTime()+1e3)};return r(),document.addEventListener(`visibilitychange`,n),window.addEventListener(`focus`,n),()=>{clearTimeout(e),document.removeEventListener(`visibilitychange`,n),window.removeEventListener(`focus`,n)}},[]),e}var Qd=new URL(`gaia-robot-NKaQnEIp.png`,import.meta.url).href,$d=16,ef=`gaia-chat-sidebar-width`,tf=e=>Math.round(Math.max(200,Math.min(420,e)));function nf(){try{let e=Number(localStorage.getItem(ef));return e?tf(e):260}catch(e){return P.system.warn(`Saved sidebar width unreadable; using the default.`,e),260}}function rf(e){try{localStorage.setItem(ef,String(e))}catch(e){P.system.warn(`Sidebar width not saved; it resets on reload.`,e)}}function af(e){return getComputedStyle(e).direction===`rtl`}function of(e){let t=L(),[n,r]=(0,V.useState)(nf),[i,a]=(0,V.useState)(null),o=(0,V.useCallback)(e=>{let t=tf(e);r(t),rf(t)},[]),s=(0,V.useCallback)(t=>{if(t.button!==0)return;t.preventDefault();let r=t.clientX,i=n,s=t.currentTarget,c=af(s)?-1:1;s.setPointerCapture?.(t.pointerId);let l=i,u=e=>{l=i+c*(e.clientX-r),a(l<150?l:tf(l))},d=()=>{s.removeEventListener(`pointermove`,u),s.removeEventListener(`pointerup`,d),s.removeEventListener(`pointercancel`,d),a(null),l<150?e():o(l)};s.addEventListener(`pointermove`,u),s.addEventListener(`pointerup`,d),s.addEventListener(`pointercancel`,d)},[e,o,n]),c=(0,V.useCallback)(e=>{let t=af(e.currentTarget)?-16:$d,r={ArrowLeft:n-t,ArrowRight:n+t,Home:200,End:420}[e.key];r!==void 0&&(e.preventDefault(),o(r))},[o,n]),l=I(`div`,{className:`sb-resize${i==null?``:` is-dragging`}`,role:`separator`,"aria-orientation":`vertical`,"aria-label":t(`sidebar.resize`),"aria-valuemin":200,"aria-valuemax":420,"aria-valuenow":Math.round(i??n),tabIndex:0,title:t(`sidebar.resizeTitle`),onPointerDown:s,onKeyDown:c,onDoubleClick:()=>o(260)});return{width:i??n,resizing:i!=null,handle:l}}function sf(e){return e.normalize(`NFKD`).replace(/\p{Mn}/gu,``).toLowerCase().replace(/ß/g,`ss`)}function cf(e){return Array.from(e,sf).join(``)}function lf(e,t){let n=cf(t.trim());if(!n)return null;let r=``,i=[],a=0;for(let t of e){let e=sf(t);r+=e;for(let t=0;t<e.length;t++)i.push(a);a+=t.length}let o=r.indexOf(n);if(o<0)return null;let s=i[o],c=i[o+n.length-1],l=c+String.fromCodePoint(e.codePointAt(c)).length;return{before:e.slice(0,s),match:e.slice(s,l),after:e.slice(l)}}var uf={running:`row.status.running`,queued:`row.status.queued`,waiting:`row.status.waiting`,done:`row.status.done`,failed:`row.status.failed`},df={"Needs you":`sidebar.group.needsYou`,Pinned:`sidebar.group.pinned`,Today:`sidebar.group.today`,Yesterday:`sidebar.group.yesterday`,"Previous 7 days":`sidebar.group.prev7`,"Previous 30 days":`sidebar.group.prev30`,Older:`sidebar.group.older`},ff=`gaia-show-automated-runs`,pf=200,mf=new Map;function hf({parts:e}){return R(F.Fragment,{children:[Nd(e.before),I(`mark`,{className:`sb-hit`,children:Nd(e.match)}),Nd(e.after)]})}function gf(){try{return localStorage.getItem(ff)===`1`}catch(e){return P.system.warn(`Chat-list filter unreadable (site data blocked); hiding eval and scheduled runs.`,e),!1}}var _f=e=>`sb-result-${e}`;function vf({session:e,active:t,phone:n,moved:r,focusPin:i,status:a,queuePlace:o,unsent:s,failed:c,onSelect:l,onDelete:u,onPin:d,onRename:f,rowId:p,kbdActive:m,titleMatch:h,snippet:g}){let _=L(),[v,y]=(0,V.useState)(!1),[b,x]=(0,V.useState)(!1),S=(0,V.useRef)(null),C=(0,V.useCallback)(()=>{x(!1),y(!1)},[]),[w,T]=(0,V.useState)(null),E=w!==null,ee=(0,V.useRef)(!1),D=()=>{ee.current=!1,T(e.title)},O=(0,V.useRef)(null),te=(0,V.useRef)(null),A=(0,V.useRef)(!1),ne=(t,n=!1)=>{w===null||ee.current||(ee.current=!0,A.current=n,T(null),t&&f(e.id,w))},[j,M]=(0,V.useState)(!1);(0,V.useEffect)(()=>{if(!v||j)return;let e=setTimeout(()=>y(!1),3e3);return()=>clearTimeout(e)},[v,j]),(0,V.useEffect)(()=>{!E&&A.current&&(A.current=!1,O.current?.focus())},[E]),(0,V.useEffect)(()=>{i&&te.current?.focus()},[i]);let re=(0,V.useRef)(null);(0,V.useEffect)(()=>{r&&re.current?.scrollIntoView?.({block:`nearest`})},[r]);let ie=e=>e.preventDefault(),ae=!!e.unread&&!t,oe=a===`done`&&!ae?null:a,se=o>0?zu(_,`row.queuePlace`,o):null,ce=oe?[_(uf[oe]),se].filter(Boolean).join(`, `):void 0,le=c>0?_.plural(`row.notSent`,c):s>0?_.plural(`row.toSend`,s):null,ue=[se,le].filter(Boolean).join(` · `),fe=g?`${g.before}${g.match}${g.after}`:null,pe=Jd(_,e),me=I(`span`,{className:`sb-row-title`,dir:`auto`,children:h?I(hf,{parts:h}):pe});return R(`li`,{ref:re,className:`sb-row${t?` is-active`:``}${ae?` is-unread`:``}${r?` is-moved`:``}${m?` is-kbd-active`:``}`,"data-status":oe??void 0,children:[E?I(`input`,{className:`sb-row-edit`,value:w,maxLength:200,onChange:e=>T(e.target.value),onBlur:()=>ne(!0),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),ne(!0,!0)),e.key===`Escape`&&(e.preventDefault(),ne(!1,!0))},...Lt,autoFocus:!0,onFocus:e=>e.currentTarget.select(),"aria-label":_(`row.renameAria`,{title:pe}),dir:`auto`}):R(`button`,{ref:O,type:`button`,id:p,className:`sb-row-main`,onClick:()=>l(e.id),onDoubleClick:D,"aria-current":t?`page`:void 0,"aria-label":[pe,ce,le,ae?_(`row.unread`):null,fe&&Nd(fe)].filter(Boolean).join(`, `),title:pe,children:[oe&&I(`span`,{className:`sb-dot is-${oe}`,"aria-hidden":`true`,title:ce}),e.private&&I(ia,{size:12,className:`sb-row-icon`,"aria-label":_(`row.private`)}),g||ue?R(`span`,{className:`sb-row-text`,children:[me,g&&I(`span`,{className:`sb-row-snippet`,dir:`auto`,children:I(hf,{parts:g})}),ue&&R(`span`,{className:`sb-row-queue${c>0?` is-failed`:``}`,title:ue,children:[se&&I(`span`,{className:`sb-row-note`,children:se}),le&&I(`span`,{className:`sb-row-note`,children:le})]})]}):me]}),n&&E&&R(F.Fragment,{children:[I(`button`,{type:`button`,className:`sb-row-edit-btn is-save`,onPointerDown:ie,onMouseDown:ie,onClick:()=>ne(!0),"aria-label":_(`row.saveName`),children:I(ci,{size:18,"aria-hidden":`true`})}),I(`button`,{type:`button`,className:`sb-row-edit-btn`,onPointerDown:ie,onMouseDown:ie,onClick:()=>ne(!1),"aria-label":_(`row.cancelRename`),children:I(bc,{size:18,"aria-hidden":`true`})})]}),n?!E&&R(F.Fragment,{children:[I(`button`,{ref:S,type:`button`,className:`sb-row-more`,onClick:()=>b?C():x(!0),"aria-haspopup":`dialog`,"aria-expanded":b,"aria-label":_(`row.moreActions`,{title:pe}),children:I(Qi,{size:18,"aria-hidden":`true`})}),I(Mc,{open:b,onClose:C,anchor:S,label:_(`row.actions`),placement:`below`,align:`end`,children:R(`div`,{className:`sb-row-menu`,children:[R(`button`,{type:`button`,className:`popover-item`,onClick:()=>{C(),D()},children:[I(Xo,{size:15,"aria-hidden":`true`}),_(`row.rename`)]}),R(`button`,{type:`button`,className:`popover-item`,onClick:()=>{C(),d(e.id,!e.pinned,!0)},children:[e.pinned?I(Qo,{size:15,"aria-hidden":`true`}):I(es,{size:15,"aria-hidden":`true`}),e.pinned?_(`row.unpin`):_(`row.pin`)]}),R(`button`,{type:`button`,className:`popover-item sb-row-menu-delete`,onClick:()=>v?u(e.id):y(!0),children:[I(oc,{size:15,"aria-hidden":`true`}),v?_(`row.tapAgain`,{label:s>0?de(k(`row.deleteUnsent`,s),{n:s}):de(`row.deleteConfirm`)}):_(`row.delete`)]}),v&&I(`p`,{className:`sb-row-menu-note`,children:_(`row.deleteMemoryNote`)})]})})]}):R(`span`,{className:`sb-row-actions${E?` is-editing`:``}`,children:[!E&&I(`button`,{type:`button`,className:`sb-row-rename`,onClick:D,"aria-label":_(`row.renameAria`,{title:pe}),title:_(`row.rename`),children:I(Xo,{size:13})}),I(`button`,{ref:te,type:`button`,className:`sb-row-pin${e.pinned?` is-pinned`:``}`,onClick:t=>d(e.id,!e.pinned,!1,t.detail===0),"aria-label":_(e.pinned?`row.unpinAria`:`row.pinAria`,{title:pe}),"aria-pressed":!!e.pinned,title:e.pinned?_(`row.unpin`):_(`row.pinToTop`),children:e.pinned?I(Qo,{size:13}):I(es,{size:13})}),I(`button`,{type:`button`,className:`sb-row-delete${v?` is-confirm`:``}`,onClick:()=>v?u(e.id):y(!0),onPointerEnter:()=>M(!0),onPointerLeave:()=>M(!1),"aria-label":v?s>0?_.plural(`row.confirmDeleteUnsentAria`,s,{title:pe}):_(`row.confirmDeleteAria`,{title:pe}):_(`row.deleteAria`,{title:pe}),title:v?`${s>0?_.plural(`row.clickAgainUnsent`,s):_(`row.clickAgain`)}\n${_(`row.deleteMemoryNote`)}`:_(`row.delete`),children:v?I(`span`,{className:`sb-row-delete-label`,children:s>0?_.plural(`row.deleteUnsent`,s):_(`row.deleteConfirm`)}):I(oc,{size:13})})]})]})}function yf({onNewChat:e,onMobileAccess:t,tunnelActive:n}){let r=L(),i=z(e=>e.sessions),a=z(e=>e.currentSessionId),o=z(e=>e.runningSessionIds),s=z(e=>e.queuedSessionIds),c=z(e=>e.awaitingBySession),l=z(e=>e.messageQueues),u=z(e=>e.updateSessionInList),d=fu(kc(_u)),f=z(e=>e.sidebarOpen),p=z(e=>e.sidebarCollapsed),m=z(e=>e.toggleSidebarCollapsed),h=z(e=>e.setSidebarOpen),g=z(e=>e.setCurrentSession),_=z(e=>e.setMessages),v=z(e=>e.removeSession),y=z(e=>e.addPendingDelete),b=z(e=>e.removePendingDelete),x=z(e=>e.openSettings),S=z(e=>e.settingsSection===`skills`),C=z(e=>e.setShowMemoryDashboard),w=z(e=>e.setShowSchedules),T=z(e=>e.setShowDocLibrary),E=z(e=>e.showMemoryDashboard),ee=z(e=>e.showSchedules),D=fu(pu),O=fu(e=>e.showPanel),te=fu(e=>e.setShowPanel),[k,A]=(0,V.useState)(``),[ne,j]=(0,V.useState)(null),[M,re]=(0,V.useState)(null),[ie,ae]=(0,V.useState)(-1),[oe,se]=(0,V.useState)(null),[ce,le]=(0,V.useState)(null),[ue,de]=(0,V.useState)(gf),pe=Yd(`(max-width: 768px)`),me=(0,V.useRef)(null),he=(0,V.useRef)(null);(0,V.useEffect)(()=>A(``),[a]),(0,V.useEffect)(()=>{let e=()=>{let e=document.activeElement;e instanceof HTMLElement&&e!==me.current&&(he.current=e),p&&m(),requestAnimationFrame(()=>me.current?.focus())};return window.addEventListener(`gaia:focus-search`,e),()=>window.removeEventListener(`gaia:focus-search`,e)},[p,m]);let ge=(0,V.useMemo)(()=>({running:o,queued:s,awaiting:c,prompting:d}),[o,s,c,d]),_e=k.trim();(0,V.useEffect)(()=>{if(ae(-1),re(null),!_e){j(null);return}let e=new AbortController,t=setTimeout(()=>{ye(_e,ue,e.signal).then(({results:e,truncated:t})=>j({query:_e,results:e,truncated:!!t})).catch(t=>{e.signal.aborted||(P.chat.error(`Chat search failed`,t),re(`Could not search inside chats: ${t instanceof Error?t.message:t}`),j({query:_e,results:[],truncated:!1}))})},pf);return()=>{clearTimeout(t),e.abort()}},[_e,ue]);let ve=!!_e&&ne?.query!==_e,be=(0,V.useMemo)(()=>ne&&ne.query===_e?new Map(ne.results.map(e=>[e.session_id,e])):mf,[ne,_e]),xe=Au(i),Se=Zd(),Ce=(0,V.useMemo)(()=>{let e=cf(_e);return ku(_e?i.filter(t=>cf(t.title).includes(e)||be.has(t.id)):i,ge,{showAutomated:ue,now:Se})},[i,_e,be,ge,ue,Se]),we=(0,V.useMemo)(()=>_e?Ce.flatMap(e=>e.sessions):[],[_e,Ce]),N=ie>=0&&we.length>0?we[Math.min(ie,we.length-1)]:void 0;(0,V.useEffect)(()=>{N&&document.getElementById(_f(N.id))?.scrollIntoView?.({block:`nearest`})},[N]);let Te=(0,V.useCallback)(()=>{de(e=>{try{localStorage.setItem(ff,e?`0`:`1`)}catch(e){P.system.warn(`Chat-list filter not saved; it will reset on reload.`,e)}return!e})},[]),Ee=(0,V.useCallback)(e=>{u(e,{unread:!1}),Wt(e).catch(t=>{P.chat.error(`Could not mark chat ${e} read`,t),le(`Could not mark the chat read: ${t instanceof Error?t.message:t}`)})},[u]),De=i.find(e=>e.id===a)?.unread;(0,V.useEffect)(()=>{if(!a||!De)return;if(document.hasFocus()){Ee(a);return}let e=()=>Ee(a);return window.addEventListener(`focus`,e,{once:!0}),()=>window.removeEventListener(`focus`,e)},[a,De,Ee]);let[Oe,ke]=(0,V.useState)(null),[Ae,je]=(0,V.useState)(null);(0,V.useEffect)(()=>{Ae&&je(null)},[Ae]),(0,V.useEffect)(()=>{if(!Oe)return;let e=setTimeout(()=>ke(null),1200);return()=>clearTimeout(e)},[Oe]);let Me=(0,V.useCallback)(async(e,t)=>{le(null),u(e,{pinned:t});try{await dr(e,t)}catch(n){P.chat.error(`Could not ${t?`pin`:`unpin`} chat ${e}`,n),u(e,{pinned:!t}),le(n instanceof Error?n.message:`Could not ${t?`pin`:`unpin`} the chat.`)}},[u]),Ne=(0,V.useCallback)(async(e,t)=>{let n=t.trim().slice(0,200).trim(),r=z.getState().sessions.find(t=>t.id===e)?.title;if(n&&t!==r&&n!==r){le(null),u(e,{title:n});try{await fe(e,{title:n,title_is_custom:!0})}catch(t){P.chat.error(`Could not rename chat ${e}`,t),r!==void 0&&u(e,{title:r}),le(t instanceof Error?t.message:`Could not rename the chat.`)}}},[u]),Pe=(0,V.useCallback)(()=>{window.innerWidth<=768&&h(!1)},[h]),Fe=(0,V.useCallback)(e=>{e===a?(g(e),Pe()):(Ju(a),g(e),_([]),Pe())},[a,g,_,Pe]),Ie=e=>{if(e.key===`Escape`){e.preventDefault(),A(``);let t=he.current;he.current=null;let n=t?.isConnected&&t!==document.body?t:document.querySelector(`.composer-input`);n?n.focus():me.current?.blur();return}if(!_e||we.length===0||e.nativeEvent.isComposing)return;let t=N?we.indexOf(N):-1;e.key===`ArrowDown`?(e.preventDefault(),ae(Math.min(t+1,we.length-1))):e.key===`ArrowUp`?(e.preventDefault(),ae(Math.max(t-1,0))):e.key===`Enter`&&(e.preventDefault(),Fe((N??we[0]).id))},Le=(0,V.useCallback)(async e=>{se(null),y(e);try{await lr(e),v(e)}catch(t){P.chat.error(`Delete failed for session ${e}`,t),se(t instanceof Error?t.message:`Could not delete the chat.`)}finally{b(e)}},[y,b,v]),Re=p&&!pe,ze=z(e=>e.setSidebarCollapsed),Be=of((0,V.useCallback)(()=>ze(!0),[ze])),Ve=!pe&&!Re,He=[{key:`memory`,label:r(`sidebar.memory`),icon:Xr,on:E,onClick:()=>{C(!0),Pe()}},{key:`schedules`,label:r(`sidebar.schedules`),icon:Mi,on:ee,onClick:()=>{w(!0),Pe()}},{key:`connectors`,label:r(`settings.section.connectors`),icon:is,on:!1,onClick:()=>{x(`connectors`),Pe()}},{key:`documents`,label:r(`sidebar.documents`),icon:Sa,on:!1,onClick:()=>{T(!0),Pe()}},{key:`skills`,label:r(`settings.section.skills`),icon:Ks,on:S,onClick:()=>{x(`skills`),Pe()}}];return R(`aside`,{className:`sb${f?` is-open`:``}${Re?` is-collapsed`:``}${Be.resizing?` is-resizing`:``}`,style:Ve?{width:Be.width,minWidth:Be.width}:void 0,"aria-label":r(`sidebar.label`),children:[Ve&&Be.handle,R(`div`,{className:`sb-top`,children:[R(`div`,{className:`sb-brand`,children:[I(`img`,{src:Qd,alt:``,width:22,height:22}),!Re&&I(`span`,{children:`GAIA`})]}),I(`button`,{type:`button`,className:`sb-icon-btn`,onClick:pe?()=>h(!1):m,"aria-label":r(Re?`sidebar.expand`:`sidebar.collapse`),title:r.hint(r(Re?`sidebar.expand`:`sidebar.collapse`),Gu(`Mod+B`)),children:I(pe?bc:Re?Io:Po,{size:17})})]}),R(`div`,{className:`sb-actions`,children:[Re?I(`button`,{type:`button`,className:`sb-nav-item`,onClick:()=>window.dispatchEvent(new CustomEvent(`gaia:focus-search`)),"aria-label":r(`sidebar.search`),children:I(Es,{size:16,"aria-hidden":`true`})}):R(`label`,{className:`sb-search`,children:[I(Es,{size:14,"aria-hidden":`true`}),I(`input`,{ref:me,type:`search`,value:k,onChange:e=>A(e.target.value),onKeyDown:Ie,onFocus:e=>{e.relatedTarget instanceof HTMLElement&&(he.current=e.relatedTarget)},...Lt,placeholder:r.bare(`sidebar.search`),"aria-label":r.hint(r(`sidebar.search`),Gu(`Mod+K`)),"aria-controls":`sb-chat-list`,"aria-activedescendant":N?_f(N.id):void 0})]}),I(`p`,{className:`sb-sr-only`,role:`status`,"aria-live":`polite`,children:_e&&!ve?we.length===0?r(`sidebar.noMatch`):r.plural(`sidebar.matchCount`,we.length):``}),R(`button`,{type:`button`,className:`sb-nav-item`,onClick:()=>{e(),Pe()},title:r.hint(r(`sidebar.newChat`),Gu(`Mod+Shift+O`)),children:[I(Qs,{size:16,"aria-hidden":`true`}),!Re&&I(`span`,{children:r(`sidebar.newChat`)})]}),He.map(({key:e,label:t,icon:n,on:r,onClick:i})=>R(`button`,{type:`button`,className:`sb-nav-item${r?` is-active`:``}`,onClick:i,"aria-current":r?`page`:void 0,"aria-label":t,title:Re?t:void 0,children:[I(n,{size:16,"aria-hidden":`true`}),!Re&&I(`span`,{children:t})]},e))]}),!Re&&R(`nav`,{className:`sb-list`,id:`sb-chat-list`,"aria-label":r(`sidebar.recent`),children:[Ce.length===0&&I(`p`,{className:`sb-empty`,children:r(_e?ve?`sidebar.searching`:`sidebar.noMatch`:`sidebar.empty`)}),Ce.map(e=>R(`section`,{className:`sb-group${e.label===`Needs you`?` is-needs-you`:``}`,children:[I(`h2`,{className:`sb-group-label`,children:r(df[e.label])}),I(`ul`,{children:e.sessions.map(e=>I(vf,{session:e,active:e.id===a&&!E,phone:pe,moved:e.id===Oe,focusPin:e.id===Ae,status:Du(e,ge),queuePlace:s.indexOf(e.id)+1,unsent:l[e.id]?.length??0,failed:l[e.id]?.filter(e=>e.state===`failed`).length??0,onSelect:Fe,onDelete:Le,onPin:(e,t,n,r)=>{n&&ke(e),r&&je(e),Me(e,t)},onRename:(e,t)=>void Ne(e,t),rowId:_e?_f(e.id):void 0,kbdActive:N?.id===e.id,titleMatch:_e?lf(e.title,_e):null,snippet:be.get(e.id)?.field===`message`?be.get(e.id).snippet:null},e.id))})]},e.label)),xe>0&&I(`button`,{type:`button`,className:`sb-filter`,onClick:Te,"aria-pressed":ue,children:ue?r(`sidebar.hideBackground`):r.plural(`sidebar.showBackground`,xe)}),_e&&ne?.query===_e&&ne.truncated&&I(`p`,{className:`sb-empty`,children:r(`sidebar.searchCapped`,{n:ne.results.length})}),M&&I(`p`,{className:`sb-error`,role:`alert`,children:M}),oe&&I(`p`,{className:`sb-error`,role:`alert`,children:oe}),ce&&I(`p`,{className:`sb-error`,role:`alert`,children:ce})]}),!Re&&I(Gl,{}),R(`div`,{className:`sb-bottom`,children:[!Re&&I(Rl,{}),R(`div`,{className:`sb-bottom-actions`,children:[R(`button`,{type:`button`,className:`sb-icon-btn${O?` is-active`:``}`,onClick:()=>te(!O),"aria-label":D>0?r(`sidebar.notificationsUnread`,{n:D}):r(`sidebar.notifications`),"aria-expanded":O,title:r(`sidebar.notifications`),children:[I(Kr,{size:16}),D>0&&I(`span`,{className:`sb-badge`,"aria-hidden":`true`,children:D>99?`99+`:D})]}),t&&I(`button`,{type:`button`,className:`sb-icon-btn${n?` is-active`:``}`,onClick:t,"aria-label":r(n?`sidebar.mobileAccessOn`:`sidebar.mobileAccess`),title:r(`sidebar.mobileAccess`),children:I(Ws,{size:16})}),I(`button`,{type:`button`,className:`sb-icon-btn`,onClick:()=>x(),"aria-label":r(`sidebar.settings`),title:r.hint(r(`sidebar.settings`),Gu(`Mod+,`)),children:I(As,{size:16})})]})]})]})}function bf(e,t){let n=(0,V.useRef)(e),r=(0,V.useRef)(t);r.current=t,(0,V.useEffect)(()=>{let t=n.current&&!e;n.current=e,t&&r.current()},[e])}var xf=2e3;function Sf(e,t,n){let r=(0,V.useRef)(n);r.current=n;let[i,a]=(0,V.useState)(0);(0,V.useEffect)(()=>{if(!e||!t)return;let n=window.setTimeout(()=>{r.current(),a(e=>e+1)},xf);return()=>window.clearTimeout(n)},[e,t,i])}function Cf(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var wf=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Tf=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ef={};function Df(e,t){return((t||Ef).jsx?Tf:wf).test(e)}var Of=/[ \t\n\f\r]/g;function kf(e){return typeof e==`object`?e.type===`text`&&Af(e.value):Af(e)}function Af(e){return e.replace(Of,``)===``}var jf=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};jf.prototype.normal={},jf.prototype.property={},jf.prototype.space=void 0;function Mf(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new jf(n,r,t)}function Nf(e){return e.toLowerCase()}var Pf=class{constructor(e,t){this.attribute=t,this.property=e}};Pf.prototype.attribute=``,Pf.prototype.booleanish=!1,Pf.prototype.boolean=!1,Pf.prototype.commaOrSpaceSeparated=!1,Pf.prototype.commaSeparated=!1,Pf.prototype.defined=!1,Pf.prototype.mustUseProperty=!1,Pf.prototype.number=!1,Pf.prototype.overloadedBoolean=!1,Pf.prototype.property=``,Pf.prototype.spaceSeparated=!1,Pf.prototype.space=void 0;var Ff=e({boolean:()=>Lf,booleanish:()=>Rf,commaOrSpaceSeparated:()=>Hf,commaSeparated:()=>Vf,number:()=>H,overloadedBoolean:()=>zf,spaceSeparated:()=>Bf}),If=0,Lf=Uf(),Rf=Uf(),zf=Uf(),H=Uf(),Bf=Uf(),Vf=Uf(),Hf=Uf();function Uf(){return 2**++If}var Wf=Object.keys(Ff),Gf=class extends Pf{constructor(e,t,n,r){let i=-1;if(super(e,t),Kf(this,`space`,r),typeof n==`number`)for(;++i<Wf.length;){let e=Wf[i];Kf(this,Wf[i],(n&Ff[e])===Ff[e])}}};Gf.prototype.defined=!0;function Kf(e,t,n){n&&(e[t]=n)}function qf(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new Gf(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[Nf(r)]=r,n[Nf(a.attribute)]=r}return new jf(t,n,e.space)}var Jf=qf({properties:{ariaActiveDescendant:null,ariaAtomic:Rf,ariaAutoComplete:null,ariaBusy:Rf,ariaChecked:Rf,ariaColCount:H,ariaColIndex:H,ariaColSpan:H,ariaControls:Bf,ariaCurrent:null,ariaDescribedBy:Bf,ariaDetails:null,ariaDisabled:Rf,ariaDropEffect:Bf,ariaErrorMessage:null,ariaExpanded:Rf,ariaFlowTo:Bf,ariaGrabbed:Rf,ariaHasPopup:null,ariaHidden:Rf,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Bf,ariaLevel:H,ariaLive:null,ariaModal:Rf,ariaMultiLine:Rf,ariaMultiSelectable:Rf,ariaOrientation:null,ariaOwns:Bf,ariaPlaceholder:null,ariaPosInSet:H,ariaPressed:Rf,ariaReadOnly:Rf,ariaRelevant:null,ariaRequired:Rf,ariaRoleDescription:Bf,ariaRowCount:H,ariaRowIndex:H,ariaRowSpan:H,ariaSelected:Rf,ariaSetSize:H,ariaSort:null,ariaValueMax:H,ariaValueMin:H,ariaValueNow:H,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function Yf(e,t){return t in e?e[t]:t}function Xf(e,t){return Yf(e,t.toLowerCase())}var Zf=qf({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:Vf,acceptCharset:Bf,accessKey:Bf,action:null,allow:null,allowFullScreen:Lf,allowPaymentRequest:Lf,allowUserMedia:Lf,alt:null,as:null,async:Lf,autoCapitalize:null,autoComplete:Bf,autoFocus:Lf,autoPlay:Lf,blocking:Bf,capture:null,charSet:null,checked:Lf,cite:null,className:Bf,cols:H,colSpan:null,content:null,contentEditable:Rf,controls:Lf,controlsList:Bf,coords:H|Vf,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Lf,defer:Lf,dir:null,dirName:null,disabled:Lf,download:zf,draggable:Rf,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Lf,formTarget:null,headers:Bf,height:H,hidden:zf,high:H,href:null,hrefLang:null,htmlFor:Bf,httpEquiv:Bf,id:null,imageSizes:null,imageSrcSet:null,inert:Lf,inputMode:null,integrity:null,is:null,isMap:Lf,itemId:null,itemProp:Bf,itemRef:Bf,itemScope:Lf,itemType:Bf,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Lf,low:H,manifest:null,max:null,maxLength:H,media:null,method:null,min:null,minLength:H,multiple:Lf,muted:Lf,name:null,nonce:null,noModule:Lf,noValidate:Lf,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Lf,optimum:H,pattern:null,ping:Bf,placeholder:null,playsInline:Lf,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Lf,referrerPolicy:null,rel:Bf,required:Lf,reversed:Lf,rows:H,rowSpan:H,sandbox:Bf,scope:null,scoped:Lf,seamless:Lf,selected:Lf,shadowRootClonable:Lf,shadowRootDelegatesFocus:Lf,shadowRootMode:null,shape:null,size:H,sizes:null,slot:null,span:H,spellCheck:Rf,src:null,srcDoc:null,srcLang:null,srcSet:null,start:H,step:null,style:null,tabIndex:H,target:null,title:null,translate:null,type:null,typeMustMatch:Lf,useMap:null,value:Rf,width:H,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Bf,axis:null,background:null,bgColor:null,border:H,borderColor:null,bottomMargin:H,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Lf,declare:Lf,event:null,face:null,frame:null,frameBorder:null,hSpace:H,leftMargin:H,link:null,longDesc:null,lowSrc:null,marginHeight:H,marginWidth:H,noResize:Lf,noHref:Lf,noShade:Lf,noWrap:Lf,object:null,profile:null,prompt:null,rev:null,rightMargin:H,rules:null,scheme:null,scrolling:Rf,standby:null,summary:null,text:null,topMargin:H,valueType:null,version:null,vAlign:null,vLink:null,vSpace:H,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Lf,disableRemotePlayback:Lf,prefix:null,property:null,results:H,security:null,unselectable:null},space:`html`,transform:Xf}),Qf=qf({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:Hf,accentHeight:H,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:H,amplitude:H,arabicForm:null,ascent:H,attributeName:null,attributeType:null,azimuth:H,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:H,by:null,calcMode:null,capHeight:H,className:Bf,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:H,diffuseConstant:H,direction:null,display:null,dur:null,divisor:H,dominantBaseline:null,download:Lf,dx:null,dy:null,edgeMode:null,editable:null,elevation:H,enableBackground:null,end:null,event:null,exponent:H,externalResourcesRequired:null,fill:null,fillOpacity:H,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Vf,g2:Vf,glyphName:Vf,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:H,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:H,horizOriginX:H,horizOriginY:H,id:null,ideographic:H,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:H,k:H,k1:H,k2:H,k3:H,k4:H,kernelMatrix:Hf,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:H,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:H,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:H,overlineThickness:H,paintOrder:null,panose1:null,path:null,pathLength:H,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Bf,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:H,pointsAtY:H,pointsAtZ:H,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Hf,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Hf,rev:Hf,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Hf,requiredFeatures:Hf,requiredFonts:Hf,requiredFormats:Hf,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:H,specularExponent:H,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:H,strikethroughThickness:H,string:null,stroke:null,strokeDashArray:Hf,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:H,strokeOpacity:H,strokeWidth:null,style:null,surfaceScale:H,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Hf,tabIndex:H,tableValues:null,target:null,targetX:H,targetY:H,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Hf,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:H,underlineThickness:H,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:H,values:null,vAlphabetic:H,vMathematical:H,vectorEffect:null,vHanging:H,vIdeographic:H,version:null,vertAdvY:H,vertOriginX:H,vertOriginY:H,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:H,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:Yf}),$f=qf({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),ep=qf({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:Xf}),tp=qf({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),np={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},rp=/[A-Z]/g,ip=/-[a-z]/g,ap=/^data[-\w.:]+$/i;function op(e,t){let n=Nf(t),r=t,i=Pf;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&ap.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(ip,cp);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!ip.test(e)){let n=e.replace(rp,sp);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=Gf}return new i(r,t)}function sp(e){return`-`+e.toLowerCase()}function cp(e){return e.charAt(1).toUpperCase()}var lp=Mf([Jf,Zf,$f,ep,tp],`html`),up=Mf([Jf,Qf,$f,ep,tp],`svg`);function dp(e){return e.join(` `).trim()}var fp=n(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
19
+ `);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),pp=n(((e,t,n)=>{var r=n&&n.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=a;var i=r(fp());function a(e,t){let n=null;if(!e||typeof e!=`string`)return n;let r=(0,i.default)(e),a=typeof t==`function`;return r.forEach(e=>{if(e.type!==`declaration`)return;let{property:r,value:i}=e;a?t(r,i,e):i&&(n||={},n[r]=i)}),n}})),mp=n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),hp=n(((e,t,n)=>{var r=(n&&n.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(pp()),i=mp();function a(e,t){var n={};return!e||typeof e!=`string`||(0,r.default)(e,function(e,r){e&&r&&(n[(0,i.camelCase)(e,t)]=r)}),n}a.default=a,t.exports=a})),gp=vp(`end`),_p=vp(`start`);function vp(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function yp(e){let t=_p(e),n=gp(e);if(t&&n)return{start:t,end:n}}function bp(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?Sp(e.position):`start`in e||`end`in e?Sp(e):`line`in e||`column`in e?xp(e):``}function xp(e){return Cp(e&&e.line)+`:`+Cp(e&&e.column)}function Sp(e){return xp(e&&e.start)+`-`+xp(e&&e.end)}function Cp(e){return e&&typeof e==`number`?e:1}var wp=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=bp(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};wp.prototype.file=``,wp.prototype.name=``,wp.prototype.reason=``,wp.prototype.message=``,wp.prototype.stack=``,wp.prototype.column=void 0,wp.prototype.line=void 0,wp.prototype.ancestors=void 0,wp.prototype.cause=void 0,wp.prototype.fatal=void 0,wp.prototype.place=void 0,wp.prototype.ruleId=void 0,wp.prototype.source=void 0;var Tp=t(hp(),1),Ep={}.hasOwnProperty,Dp=new Map,Op=/[A-Z]/g,kp=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),Ap=new Set([`td`,`th`]),jp=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function Mp(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=Up(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=Hp(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?up:lp,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=Np(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function Np(e,t,n){if(t.type===`element`)return Pp(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return Fp(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return Lp(e,t,n);if(t.type===`mdxjsEsm`)return Ip(e,t);if(t.type===`root`)return Rp(e,t,n);if(t.type===`text`)return zp(e,t)}function Pp(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=up,e.schema=i),e.ancestors.push(t);let a=Yp(e,t.tagName,!1),o=Wp(e,t),s=Kp(e,t);return kp.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!kf(e)})),Bp(e,o,a,t),Vp(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Fp(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}Xp(e,t.position)}function Ip(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Xp(e,t.position)}function Lp(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=up,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:Yp(e,t.name,!0),o=Gp(e,t),s=Kp(e,t);return Bp(e,o,a,t),Vp(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Rp(e,t,n){let r={};return Vp(r,Kp(e,t)),e.create(t,e.Fragment,r,n)}function zp(e,t){return t.value}function Bp(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Vp(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function Hp(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function Up(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=_p(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function Wp(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&Ep.call(t.properties,i)){let a=qp(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&Ap.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function Gp(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else Xp(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else Xp(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function Kp(e,t){let n=[],r=-1,i=e.passKeys?new Map:Dp;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=Np(e,a,o);s!==void 0&&n.push(s)}return n}function qp(e,t,n){let r=op(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Cf(n):dp(n)),r.property===`style`){let t=typeof n==`object`?n:Jp(e,String(n));return e.stylePropertyNameCase===`css`&&(t=Zp(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?np[r.property]||r.property:r.attribute,n]}}function Jp(e,t){try{return(0,Tp.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new wp("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=jp+`#cannot-parse-style-attribute`,r}}function Yp(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=Df(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=Df(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return Ep.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);Xp(e)}function Xp(e,t){let n=new wp("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=jp+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function Zp(e){let t={},n;for(n in e)Ep.call(e,n)&&(t[Qp(n)]=e[n]);return t}function Qp(e){let t=e.replace(Op,$p);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function $p(e){return`-`+e.toLowerCase()}var em={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},tm={};function nm(e,t){let n=t||tm;return rm(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function rm(e,t,n){if(am(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return im(e.children,t,n)}return Array.isArray(e)?im(e,t,n):``}function im(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=rm(e[i],t,n);return r.join(``)}function am(e){return!!(e&&typeof e==`object`)}var om=document.createElement(`i`);function sm(e){let t=`&`+e+`;`;om.innerHTML=t;let n=om.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function cm(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function lm(e,t){return e.length>0?(cm(e,e.length,0,t),e):t}var um={}.hasOwnProperty;function dm(e){let t={},n=-1;for(;++n<e.length;)fm(t,e[n]);return t}function fm(e,t){let n;for(n in t){let r=(um.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){um.call(r,a)||(r[a]=[]);let e=i[a];pm(r[a],Array.isArray(e)?e:e?[e]:[])}}}function pm(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);cm(e,0,0,r)}function mm(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function hm(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var gm=Om(/[A-Za-z]/),_m=Om(/[\dA-Za-z]/),vm=Om(/[#-'*+\--9=?A-Z^-~]/);function ym(e){return e!==null&&(e<32||e===127)}var bm=Om(/\d/),xm=Om(/[\dA-Fa-f]/),Sm=Om(/[!-/:-@[-`{-~]/);function Cm(e){return e!==null&&e<-2}function wm(e){return e!==null&&(e<0||e===32)}function Tm(e){return e===-2||e===-1||e===32}var Em=Om(/\p{P}|\p{S}/u),Dm=Om(/\s/);function Om(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function km(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&_m(e.charCodeAt(n+1))&&_m(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function Am(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return Tm(r)?(e.enter(n),s(r)):t(r)}function s(r){return Tm(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var jm={tokenize:Mm};function Mm(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null)e.consume(n);else return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Am(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null)e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);else return Cm(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var Nm={tokenize:Fm},Pm={tokenize:Im};function Fm(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return cm(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Pm,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(Pm,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null)i&&v(),_(0),e.consume(n);else return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null)g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);else return Cm(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;cm(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Im(e,t,n){return Am(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function Lm(e){if(e===null||wm(e)||Dm(e))return 1;if(Em(e))return 2}function Rm(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var zm={name:`attention`,resolveAll:Bm,tokenize:Vm};function Bm(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};Hm(d,-c),Hm(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=lm(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=lm(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=lm(l,Rm(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=lm(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=lm(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,cm(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function Vm(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Lm(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=Lm(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function Hm(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Um={name:`autolink`,tokenize:Wm};function Wm(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return gm(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||_m(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||_m(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||ym(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):vm(t)?(e.consume(t),l):n(t)}function u(e){return _m(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||_m(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var Gm={partial:!0,tokenize:Km};function Km(e,t,n){return r;function r(t){return Tm(t)?Am(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||Cm(e)?t(e):n(e)}}var qm={continuation:{tokenize:Ym},exit:Xm,name:`blockQuote`,tokenize:Jm};function Jm(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return Tm(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function Ym(e,t,n){let r=this;return i;function i(t){return Tm(t)?Am(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(qm,t,n)(r)}}function Xm(e){e.exit(`blockQuote`)}var Zm={name:`characterEscape`,tokenize:Qm};function Qm(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return Sm(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var $m={name:`characterReference`,tokenize:eh};function eh(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=_m,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=xm,u):(e.enter(`characterReferenceValue`),a=7,o=bm,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===_m&&!sm(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var th={partial:!0,tokenize:ih},nh={concrete:!0,name:`codeFenced`,tokenize:rh};function rh(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),Tm(t)?Am(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||Cm(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(th,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||Cm(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):Tm(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),Am(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||Cm(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||Cm(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&Tm(t)?Am(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||Cm(t)?e.check(th,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||Cm(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),Tm(t)?Am(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),Tm(t)?Am(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||Cm(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function ih(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var ah={name:`codeIndented`,tokenize:sh},oh={partial:!0,tokenize:ch};function sh(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),Am(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):Cm(t)?e.attempt(oh,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||Cm(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function ch(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):Cm(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):Am(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):Cm(e)?i(e):n(e)}}var lh={name:`codeText`,previous:dh,resolve:uh,tokenize:fh};function uh(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function dh(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function fh(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):Cm(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||Cm(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var ph=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&mh(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),mh(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),mh(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);mh(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);mh(this.left,t.reverse())}}}};function mh(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function hh(e){let t={},n=-1,r,i,a,o,s,c,l,u=new ph(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,gh(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return cm(e,0,1/0,u.slice(0)),!l}function gh(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var _h={resolve:yh,tokenize:bh},vh={partial:!0,tokenize:xh};function yh(e){return hh(e),e}function bh(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):Cm(t)?e.check(vh,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function xh(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),Am(e,a,`linePrefix`)}function a(i){if(i===null||Cm(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function Sh(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||ym(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||Cm(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||wm(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||ym(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function Ch(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):Cm(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||Cm(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!Tm(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function wh(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):Cm(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),Am(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||Cm(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function Th(e,t){let n;return r;function r(i){return Cm(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):Tm(i)?Am(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var Eh={name:`definition`,tokenize:Oh},Dh={partial:!0,tokenize:kh};function Oh(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return Ch.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=hm(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return wm(t)?Th(e,l)(t):l(t)}function l(t){return Sh(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(Dh,d,d)(t)}function d(t){return Tm(t)?Am(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||Cm(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function kh(e,t,n){return r;function r(t){return wm(t)?Th(e,i)(t):n(t)}function i(t){return wh(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return Tm(t)?Am(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||Cm(e)?t(e):n(e)}}var Ah={name:`hardBreakEscape`,tokenize:jh};function jh(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return Cm(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var Mh={name:`headingAtx`,resolve:Nh,tokenize:Ph};function Nh(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},cm(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Ph(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||wm(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||Cm(n)?(e.exit(`atxHeading`),t(n)):Tm(n)?Am(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||wm(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var Fh=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),Ih=[`pre`,`script`,`style`,`textarea`],Lh={concrete:!0,name:`htmlFlow`,resolveTo:Bh,tokenize:Vh},Rh={partial:!0,tokenize:Uh},zh={partial:!0,tokenize:Hh};function Bh(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Vh(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:re):gm(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):gm(a)?(e.consume(a),i=4,r.interrupt?t:re):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:re):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:D:m):n(i)}function h(t){return gm(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||wm(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&Ih.includes(l)?(i=1,r.interrupt?t(s):D(s)):Fh.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):D(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||_m(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:D):n(i)}function v(t){return Tm(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||gm(t)?(e.consume(t),b):Tm(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||_m(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):Tm(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):Tm(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||Cm(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||wm(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||Tm(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),ee):n(t)}function ee(t){return t===null||Cm(t)?D(t):Tm(t)?(e.consume(t),ee):n(t)}function D(t){return t===45&&i===2?(e.consume(t),A):t===60&&i===1?(e.consume(t),ne):t===62&&i===4?(e.consume(t),ie):t===63&&i===3?(e.consume(t),re):t===93&&i===5?(e.consume(t),M):Cm(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Rh,ae,O)(t)):t===null||Cm(t)?(e.exit(`htmlFlowData`),O(t)):(e.consume(t),D)}function O(t){return e.check(zh,te,ae)(t)}function te(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),k}function k(t){return t===null||Cm(t)?O(t):(e.enter(`htmlFlowData`),D(t))}function A(t){return t===45?(e.consume(t),re):D(t)}function ne(t){return t===47?(e.consume(t),o=``,j):D(t)}function j(t){if(t===62){let n=o.toLowerCase();return Ih.includes(n)?(e.consume(t),ie):D(t)}return gm(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),j):D(t)}function M(t){return t===93?(e.consume(t),re):D(t)}function re(t){return t===62?(e.consume(t),ie):t===45&&i===2?(e.consume(t),re):D(t)}function ie(t){return t===null||Cm(t)?(e.exit(`htmlFlowData`),ae(t)):(e.consume(t),ie)}function ae(n){return e.exit(`htmlFlow`),t(n)}}function Hh(e,t,n){let r=this;return i;function i(t){return Cm(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function Uh(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(Gm,t,n)}}var Wh={name:`htmlText`,tokenize:Gh};function Gh(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):gm(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):gm(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):Cm(t)?(o=d,ne(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?A(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):Cm(t)?(o=h,ne(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?A(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?A(t):Cm(t)?(o=v,ne(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):Cm(t)?(o=y,ne(t)):(e.consume(t),y)}function b(e){return e===62?A(e):y(e)}function x(t){return gm(t)?(e.consume(t),S):n(t)}function S(t){return t===45||_m(t)?(e.consume(t),S):C(t)}function C(t){return Cm(t)?(o=C,ne(t)):Tm(t)?(e.consume(t),C):A(t)}function w(t){return t===45||_m(t)?(e.consume(t),w):t===47||t===62||wm(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),A):t===58||t===95||gm(t)?(e.consume(t),E):Cm(t)?(o=T,ne(t)):Tm(t)?(e.consume(t),T):A(t)}function E(t){return t===45||t===46||t===58||t===95||_m(t)?(e.consume(t),E):ee(t)}function ee(t){return t===61?(e.consume(t),D):Cm(t)?(o=ee,ne(t)):Tm(t)?(e.consume(t),ee):T(t)}function D(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,O):Cm(t)?(o=D,ne(t)):Tm(t)?(e.consume(t),D):(e.consume(t),te)}function O(t){return t===i?(e.consume(t),i=void 0,k):t===null?n(t):Cm(t)?(o=O,ne(t)):(e.consume(t),O)}function te(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||wm(t)?T(t):(e.consume(t),te)}function k(e){return e===47||e===62||wm(e)?T(e):n(e)}function A(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function ne(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return Tm(t)?Am(e,M,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):M(t)}function M(t){return e.enter(`htmlTextData`),o(t)}}var Kh={name:`labelEnd`,resolveAll:Xh,resolveTo:Zh,tokenize:Qh},qh={tokenize:$h},Jh={tokenize:eg},Yh={tokenize:tg};function Xh(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&cm(e,0,e.length,n),e}function Zh(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=lm(s,e.slice(a+1,a+r+3)),s=lm(s,[[`enter`,u,t]]),s=lm(s,Rm(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=lm(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=lm(s,e.slice(o+1)),s=lm(s,[[`exit`,c,t]]),cm(e,a,e.length,s),e}function Qh(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(hm(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(qh,u,o?u:d)(t):t===91?e.attempt(Jh,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Yh,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function $h(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return wm(t)?Th(e,a)(t):a(t)}function a(t){return t===41?u(t):Sh(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return wm(t)?Th(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?wh(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return wm(t)?Th(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function eg(e,t,n){let r=this;return i;function i(t){return Ch.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(hm(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function tg(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var ng={name:`labelStartImage`,resolveAll:Kh.resolveAll,tokenize:rg};function rg(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var ig={name:`labelStartLink`,resolveAll:Kh.resolveAll,tokenize:ag};function ag(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var og={name:`lineEnding`,tokenize:sg};function sg(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Am(e,t,`linePrefix`)}}var cg={name:`thematicBreak`,tokenize:lg};function lg(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||Cm(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),Tm(t)?Am(e,s,`whitespace`)(t):s(t))}}var ug={continuation:{tokenize:mg},exit:gg,name:`list`,tokenize:pg},dg={partial:!0,tokenize:_g},fg={partial:!0,tokenize:hg};function pg(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:bm(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(cg,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return bm(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(Gm,r.interrupt?n:u,e.attempt(dg,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return Tm(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function mg(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Gm,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Am(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!Tm(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(fg,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,Am(e,e.attempt(ug,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function hg(e,t,n){let r=this;return Am(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function gg(e){e.exit(this.containerState.type)}function _g(e,t,n){let r=this;return Am(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!Tm(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var vg={name:`setextUnderline`,resolveTo:yg,tokenize:bg};function yg(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function bg(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),Tm(t)?Am(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||Cm(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var xg={tokenize:Sg};function Sg(e){let t=this,n=e.attempt(Gm,r,e.attempt(this.parser.constructs.flowInitial,i,Am(e,e.attempt(this.parser.constructs.flow,i,e.attempt(_h,i)),`linePrefix`)));return n;function r(r){if(r===null)e.consume(r);else return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null)e.consume(r);else return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var Cg={resolveAll:Dg()},wg=Eg(`string`),Tg=Eg(`text`);function Eg(e){return{resolveAll:Dg(e===`text`?Og:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null)t.consume(e);else return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function Dg(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):t[r]&&t[r][1].type===`data`||(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function Og(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var kg=e({attentionMarkers:()=>Lg,contentInitial:()=>jg,disable:()=>Rg,document:()=>Ag,flow:()=>Ng,flowInitial:()=>Mg,insideSpan:()=>Ig,string:()=>Pg,text:()=>Fg}),Ag={42:ug,43:ug,45:ug,48:ug,49:ug,50:ug,51:ug,52:ug,53:ug,54:ug,55:ug,56:ug,57:ug,62:qm},jg={91:Eh},Mg={[-2]:ah,[-1]:ah,32:ah},Ng={35:Mh,42:cg,45:[vg,cg],60:Lh,61:vg,95:cg,96:nh,126:nh},Pg={38:$m,92:Zm},Fg={[-5]:og,[-4]:og,[-3]:og,33:ng,38:$m,42:zm,60:[Um,Wh],91:ig,92:[Ah,Zm],93:Kh,95:zm,96:lh},Ig={null:[zm,Cg]},Lg={null:[42,95]},Rg={null:[]};function zg(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=lm(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=Rm(a,l.events,l),l.events):[]}function f(e,t){return Vg(p(e),t)}function p(e){return Bg(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){Cm(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&cm(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Bg(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Vg(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
20
+ `;break;case-3:o=`\r
21
+ `;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function Hg(e){let t={constructs:dm([kg,...(e||{}).extensions||[]]),content:n(jm),defined:[],document:n(Nm),flow:n(xg),lazy:{},string:n(wg),text:n(Tg)};return t;function n(e){return n;function n(n){return zg(t,e,n)}}}function Ug(e){for(;!hh(e););return e}var Wg=/[\0\t\n\r]/g;function Gg(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(Wg.lastIndex=u,c=Wg.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var Kg=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function qg(e){return e.replace(Kg,Jg)}function Jg(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return mm(n.slice(t?2:1),t?16:10)}return sm(n)||e}var Yg={}.hasOwnProperty;function Xg(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),Zg(n)(Ug(Hg(n).document().write(Gg()(e,t,!0))))}function Zg(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(Se),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(ve),blockQuote:a(pe),characterEscape:T,characterReference:T,codeFenced:a(me),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(me,o),codeText:a(he,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(ge),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(_e),hardBreakEscape:a(ye),hardBreakTrailing:a(ye),htmlFlow:a(be,o),htmlFlowData:T,htmlText:a(be,o),htmlTextData:T,image:a(xe),label:o,link:a(Se),listItem:a(we),listItemValue:f,listOrdered:a(Ce,d),listUnordered:a(Ce),paragraph:a(N),reference:oe,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(ve),strong:a(Te),thematicBreak:a(De)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:fe,autolinkProtocol:de,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:ce,characterReferenceMarkerNumeric:ce,characterReferenceValue:le,characterReference:ue,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(k),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(D),hardBreakTrailing:c(D),htmlFlow:c(O),htmlFlowData:E,htmlText:c(te),htmlTextData:E,image:c(ne),label:M,labelText:j,lineEnding:ee,link:c(A),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:se,resourceDestinationString:re,resourceTitleString:ie,resource:ae,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};$g(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];Yg.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||t_).call(a,void 0,e[0])}for(r.position={start:Qg(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:Qg(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:Qg(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||t_).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+bp({start:e.start,end:e.end})+`): it’s not open`);n.position.end=Qg(e.end)}function u(){return nm(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=hm(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];n&&n.type===`text`||(n=Ee(),n.position={start:Qg(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=Qg(e.end)}function ee(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=Qg(e.end),this.data.atHardBreak=void 0}else!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function D(){this.data.atHardBreak=!0}function O(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function te(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function ne(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function j(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=qg(t),n.identifier=hm(t).toLowerCase()}function M(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function re(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function ie(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ae(){this.data.inReference=void 0}function oe(){this.data.referenceType=`collapsed`}function se(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=hm(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function ce(e){this.data.characterReferenceType=e.type}function le(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=mm(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=sm(t);let i=this.stack[this.stack.length-1];i.value+=r}function ue(e){let t=this.stack.pop();t.position.end=Qg(e.end)}function de(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function fe(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function pe(){return{type:`blockquote`,children:[]}}function me(){return{type:`code`,lang:null,meta:null,value:``}}function he(){return{type:`inlineCode`,value:``}}function ge(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function _e(){return{type:`emphasis`,children:[]}}function ve(){return{type:`heading`,depth:0,children:[]}}function ye(){return{type:`break`}}function be(){return{type:`html`,value:``}}function xe(){return{type:`image`,title:null,url:``,alt:null}}function Se(){return{type:`link`,title:null,url:``,children:[]}}function Ce(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function we(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function N(){return{type:`paragraph`,children:[]}}function Te(){return{type:`strong`,children:[]}}function Ee(){return{type:`text`,value:``}}function De(){return{type:`thematicBreak`}}}function Qg(e){return{line:e.line,column:e.column,offset:e.offset}}function $g(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?$g(e,r):e_(e,r)}}function e_(e,t){let n;for(n in t)if(Yg.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function t_(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+bp({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+bp({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+bp({start:t.start,end:t.end})+`) is still open`)}function n_(e){let t=this;t.parser=n;function n(n){return Xg(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function r_(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function i_(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
22
+ `}]}function a_(e,t){let n=t.value?t.value+`
23
+ `:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function o_(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function s_(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function c_(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=km(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function l_(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function u_(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function d_(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function f_(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return d_(e,t);let i={src:km(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function p_(e,t){let n={src:km(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function m_(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function h_(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return d_(e,t);let i={href:km(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function g_(e,t){let n={href:km(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function __(e,t,n){let r=e.all(t),i=n?v_(n):y_(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
24
+ `}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
25
+ `});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function v_(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=y_(n[r])}return t}function y_(e){return e.spread??e.children.length>1}function b_(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function x_(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function S_(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function C_(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function w_(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=_p(t.children[1]),o=gp(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function T_(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function E_(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var D_=9,O_=32;function k_(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(A_(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(A_(t.slice(i),i>0,!1)),a.join(``)}function A_(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===D_||t===O_;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===D_||t===O_;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function j_(e,t){let n={type:`text`,value:k_(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function M_(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var N_={blockquote:r_,break:i_,code:a_,delete:o_,emphasis:s_,footnoteReference:c_,heading:l_,html:u_,imageReference:f_,image:p_,inlineCode:m_,linkReference:h_,link:g_,listItem:__,list:b_,paragraph:x_,root:S_,strong:C_,table:w_,tableCell:E_,tableRow:T_,text:j_,thematicBreak:M_,toml:P_,yaml:P_,definition:P_,footnoteDefinition:P_};function P_(){}var F_=typeof self==`object`?self:globalThis,I_=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o)e[r(t)]=r(n);return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(new F_[e](t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}}return n(new F_[a](o),i)};return r},L_=e=>I_(new Map,e)(0),R_=``,{toString:z_}={},{keys:B_}=Object,V_=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=z_.call(e).slice(8,-1);switch(n){case`Array`:return[1,R_];case`Object`:return[2,R_];case`Date`:return[3,R_];case`RegExp`:return[4,R_];case`Map`:return[5,R_];case`Set`:return[6,R_];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:n.includes(`Error`)?[7,n]:[2,n]},H_=([e,t])=>e===0&&(t===`function`||t===`symbol`),U_=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=r=>{if(n.has(r))return n.get(r);let[o,s]=V_(r);switch(o){case 0:{let t=r;switch(s){case`bigint`:o=8,t=r.toString();break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+s);t=null;break;case`undefined`:return i([-1],r)}return i([o,t],r)}case 1:{if(s){let e=r;return s===`DataView`?e=new Uint8Array(r.buffer):s===`ArrayBuffer`&&(e=new Uint8Array(r)),i([s,[...e]],r)}let e=[],t=i([o,e],r);for(let t of r)e.push(a(t));return t}case 2:{if(s)switch(s){case`BigInt`:return i([s,r.toString()],r);case`Boolean`:case`Number`:case`String`:return i([s,r.valueOf()],r)}if(t&&`toJSON`in r)return a(r.toJSON());let n=[],c=i([o,n],r);for(let t of B_(r))(e||!H_(V_(r[t])))&&n.push([a(t),a(r[t])]);return c}case 3:return i([o,r.toISOString()],r);case 4:{let{source:e,flags:t}=r;return i([o,{source:e,flags:t}],r)}case 5:{let t=[],n=i([o,t],r);for(let[n,i]of r)(e||!(H_(V_(n))||H_(V_(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!H_(V_(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},W_=(e,{json:t,lossy:n}={})=>{let r=[];return U_(!(t||n),!!t,new Map,r)(e),r},G_=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?L_(W_(e,t)):structuredClone(e):(e,t)=>L_(W_(e,t));function K_(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function q_(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function J_(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||K_,r=e.options.footnoteBackLabel||q_,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=km(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...G_(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
26
+ `},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
27
+ `}]}}var Y_=(function(e){if(e==null)return ev;if(typeof e==`function`)return $_(e);if(typeof e==`object`)return Array.isArray(e)?X_(e):Z_(e);if(typeof e==`string`)return Q_(e);throw Error(`Expected function, string, or object as test`)});function X_(e){let t=[],n=-1;for(;++n<e.length;)t[n]=Y_(e[n]);return $_(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function Z_(e){let t=e;return $_(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function Q_(e){return $_(t);function t(t){return t&&t.type===e}}function $_(e){return t;function t(t,n,r){return!!(tv(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function ev(){return!0}function tv(e){return typeof e==`object`&&!!e&&`type`in e}function nv(e){return e}var rv=[];function iv(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=Y_(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,"name",{value:`node (`+nv(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=rv,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=av(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function av(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?rv:[e]}function ov(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),iv(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var sv={}.hasOwnProperty,cv={};function lv(e,t){let n=t||cv,r=new Map,i=new Map,a={all:s,applyData:dv,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...N_,...n.handlers},one:o,options:n,patch:uv,wrap:pv};return ov(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(sv.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=G_(n);return r.children=a.all(e),r}return G_(e)}return(a.options.unknownHandler||fv)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=mv(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=mv(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function uv(e,t){e.position&&(t.position=yp(e))}function dv(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,G_(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function fv(e,t){let n=t.data||{},r=`value`in t&&!(sv.call(n,`hProperties`)||sv.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function pv(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
28
+ `});++r<e.length;)r&&n.push({type:`text`,value:`
29
+ `}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
30
+ `}),n}function mv(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function hv(e,t){let n=lv(e,t),r=n.one(e,void 0),i=J_(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
31
+ `},i)),a}function gv(e,t){return e&&`run`in e?async function(n,r){let i=hv(n,{file:r,...t});await e.run(i,r)}:function(n,r){return hv(n,{file:r,...e||t})}}function _v(e){if(e)throw e}var vv=n(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function yv(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function bv(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a)r(a);else{for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?xv(s,i)(...o):r(null,...o)}}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function xv(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var Sv={basename:Cv,dirname:wv,extname:Tv,join:Ev,sep:`/`};function Cv(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);kv(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function wv(e){if(kv(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function Tv(e){kv(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}}else n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function Ev(...e){let t=-1,n;for(;++t<e.length;)kv(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:Dv(n)}function Dv(e){kv(e);let t=e.codePointAt(0)===47,n=Ov(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function Ov(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(i!==o-1&&a!==1){if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1}i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function kv(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var Av={cwd:jv};function jv(){return`/`}function Mv(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function Nv(e){if(typeof e==`string`)e=new URL(e);else if(!Mv(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return Pv(e)}function Pv(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var Fv=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],Iv=class{constructor(e){let t;t=e?Mv(e)?{path:e}:typeof e==`string`||Bv(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:Av.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<Fv.length;){let e=Fv[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)Fv.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?Sv.basename(this.path):void 0}set basename(e){Rv(e,`basename`),Lv(e,`basename`),this.path=Sv.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?Sv.dirname(this.path):void 0}set dirname(e){zv(this.basename,`dirname`),this.path=Sv.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?Sv.extname(this.path):void 0}set extname(e){if(Lv(e,`extname`),zv(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=Sv.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){Mv(e)&&(e=Nv(e)),Rv(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?Sv.basename(this.path,this.extname):void 0}set stem(e){Rv(e,`stem`),Lv(e,`stem`),this.path=Sv.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new wp(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function Lv(e,t){if(e&&e.includes(Sv.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+Sv.sep+"`")}function Rv(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function zv(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function Bv(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var Vv=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),Hv=t(vv(),1),Uv={}.hasOwnProperty,Wv=new class e extends Vv{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=bv()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,Hv.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(qv(`data`,this.frozen),this.namespace[e]=t,this):Uv.call(this.namespace,e)&&this.namespace[e]||void 0:e?(qv(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=Xv(e),n=this.parser||this.Parser;return Gv(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),Gv(`process`,this.parser||this.Parser),Kv(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=Xv(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);Qv(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),Gv(`processSync`,this.parser||this.Parser),Kv(`processSync`,this.compiler||this.Compiler),this.process(e,r),Yv(`processSync`,`process`,t),n;function r(e,r){t=!0,_v(e),n=r}}run(e,t,n){Jv(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=Xv(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),Yv(`runSync`,`run`,n),r;function i(e,t){_v(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=Xv(t),r=this.compiler||this.Compiler;return Kv(`stringify`,r),Jv(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(qv(`use`,this.frozen),e!=null){if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`")}return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`){if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e)}else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,Hv.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null){if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];yv(o)&&yv(r)&&(r=(0,Hv.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function Gv(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function Kv(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function qv(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Jv(e){if(!yv(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function Yv(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function Xv(e){return Zv(e)?e:new Iv(e)}function Zv(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function Qv(e){return typeof e==`string`||$v(e)}function $v(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var ey=Ot(),ty=[],ny={allowDangerousHtml:!0},ry=/^(https?|ircs?|mailto|xmpp)$/i,iy=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function ay(e){let t=oy(e),n=sy(e);return cy(t.runSync(t.parse(n),n),e)}function oy(e){let t=e.rehypePlugins||ty,n=e.remarkPlugins||ty,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...ny}:ny;return Wv().use(n_).use(n).use(gv,r).use(t)}function sy(e){let t=e.children||``,n=new Iv;return typeof t==`string`?n.value=t:``+t,n}function cy(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||ly;for(let e of iy)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return ov(e,l),Mp(e,{Fragment:ey.Fragment,components:i,ignoreInvalidStyle:!0,jsx:ey.jsx,jsxs:ey.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in em)if(Object.hasOwn(em,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=em[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function ly(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||ry.test(e.slice(0,t))?e:``}var uy=[`script`,`iframe`,`object`,`embed`,`style`],dy=String.raw`(?:[A-Za-z0-9._~-]|%[0-9A-Fa-f]{2})+`,fy=RegExp(`^/api/files/uploads/(${dy})$`),py=RegExp(`^!?\\[([^\\]\\n]*)\\]\\((/api/files/uploads/${dy})\\)$`);function my(e){let t=fy.exec(e);if(!t)return null;let n;try{n=decodeURIComponent(t[1])}catch{return null}return!n||n.startsWith(`.`)||n!==n.replace(/^[ .]+|[ .]+$/g,``)||/[/\\:\u0000-\u001f\u007f]/.test(n)?null:t[1]}function hy(e){let t=py.exec(e);return!t||my(t[2])===null?null:{name:t[1],markdown:e}}function gy(e){let t=e.split(`
32
+ `),n=t.length;for(;n>0&&hy(t[n-1])!==null;)n--;if(n===t.length||n>0&&t[n-1]!==``)return{text:e,links:[]};let r=t.slice(n).map(e=>hy(e));return{text:t.slice(0,Math.max(0,n-1)).join(`
33
+ `),links:r}}function _y(e,t){if(t.length===0)return e;let n=t.map(e=>e.markdown).join(`
34
+ `);return e?`${e}\n\n${n}`:n}function vy(e){return!!e&&e.startsWith(`${Le()}/files/uploads/`)}function yy(e){if(!e)return``;if(e.startsWith(`#`))return e;let t=my(e);if(t!==null)return`${Le()}/files/uploads/${t}`;let n=e.indexOf(`:`);if(n===-1)return``;let r=e.slice(0,n).toLowerCase();return r===`https`||r===`http`||r===`mailto`?e:``}var by=wr(),xy=/\.(png|jpe?g|gif|webp|bmp|svg)$/i,Sy=2e5;function Cy(e){let t=e.split(`/`).pop()??e;try{return decodeURIComponent(t)}catch{return t}}function wy({href:e,name:t,onClose:n}){let r=L(),i=(0,V.useRef)(null),a=(0,V.useRef)(null),[o,s]=(0,V.useState)({kind:`loading`});return er(!0,n),yn(i,!0),(0,V.useEffect)(()=>{a.current?.focus()},[]),(0,V.useEffect)(()=>{let t=new AbortController,n=null;return(async()=>{try{let r=await fetch(e,{headers:pn,signal:t.signal});if(!r.ok)throw Error(`HTTP ${r.status}`);let i=new Uint8Array(await r.arrayBuffer());if(xy.test(e)){n=URL.createObjectURL(new Blob([i],{type:r.headers.get(`content-type`)??void 0})),s({kind:`image`,src:n});return}let a=i.length>Sy,o=new TextDecoder(`utf-8`).decode(i.subarray(0,Sy),{stream:!0});s(/[\u0000�]/.test(o)?{kind:`none`}:{kind:`text`,text:o,cut:a})}catch{t.signal.aborted||s({kind:`failed`})}})(),()=>{t.abort(),n&&URL.revokeObjectURL(n)}},[e]),(0,by.createPortal)(I(`div`,{className:`modal-overlay`,role:`dialog`,"aria-modal":`true`,"aria-label":r(`attachment.dialog`),onClick:n,children:R(`div`,{ref:i,className:`modal-panel attachment-preview`,onClick:e=>e.stopPropagation(),children:[R(`div`,{className:`modal-header`,children:[I(`h3`,{dir:`auto`,children:I(`bdi`,{children:t})}),I(`button`,{ref:a,type:`button`,className:`btn-icon`,onClick:n,"aria-label":r(`imageViewer.close`),children:I(bc,{size:18,"aria-hidden":`true`})})]}),R(`div`,{className:`modal-body attachment-preview-body`,children:[o.kind===`loading`&&I(`p`,{role:`status`,children:r(`attachment.loading`,{name:t})}),o.kind===`failed`&&I(`p`,{role:`alert`,children:r(`attachment.failed`,{name:t})}),o.kind===`none`&&I(`p`,{children:r(`attachment.noPreview`,{name:t})}),o.kind===`image`&&I(`img`,{className:`attachment-preview-image`,src:o.src,alt:t}),o.kind===`text`&&R(F.Fragment,{children:[I(`pre`,{className:`attachment-preview-text`,dir:`auto`,children:Nd(o.text)}),o.cut&&I(`p`,{className:`attachment-preview-note`,children:r(`attachment.cut`)})]})]})]})}),document.body)}function Ty({href:e,children:t}){let[n,r]=(0,V.useState)(!1),i=V.Children.toArray(t).filter(e=>typeof e==`string`).join(``).trim()||Cy(e);return R(F.Fragment,{children:[I(`button`,{type:`button`,className:`md-link attachment-link`,onClick:()=>r(!0),children:t}),n&&I(wy,{href:e,name:i,onClose:()=>r(!1)})]})}function Ey(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function Dy(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function Oy(e,t,n){let r=Y_((n||{}).ignore||[]),i=ky(t),a=-1;for(;++a<i.length;)iv(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function ky(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([Ay(e[0]),jy(e[1])])}return t}function Ay(e){return typeof e==`string`?new RegExp(Dy(e),`g`):e}function jy(e){return typeof e==`function`?e:function(){return e}}var My=`phrasing`,Ny=[`autolink`,`link`,`image`,`label`];function Py(){return{transforms:[Hy],enter:{literalAutolink:Iy,literalAutolinkEmail:Ly,literalAutolinkHttp:Ly,literalAutolinkWww:Ly},exit:{literalAutolink:Vy,literalAutolinkEmail:By,literalAutolinkHttp:Ry,literalAutolinkWww:zy}}}function Fy(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:My,notInConstruct:Ny},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:My,notInConstruct:Ny},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:My,notInConstruct:Ny}]}}function Iy(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function Ly(e){this.config.enter.autolinkProtocol.call(this,e)}function Ry(e){this.config.exit.autolinkProtocol.call(this,e)}function zy(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function By(e){this.config.exit.autolinkEmail.call(this,e)}function Vy(e){this.exit(e)}function Hy(e){Oy(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Uy],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,Wy]],{ignore:[`link`,`linkReference`]})}function Uy(e,t,n,r,i){let a=``;if(!qy(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!Gy(n)))return!1;let o=Ky(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function Wy(e,t,n,r){return!qy(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function Gy(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function Ky(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=Ey(e,`(`),a=Ey(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function qy(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||Dm(n)||Em(n))&&(!t||n!==47)}rb.peek=nb;function Jy(){this.buffer()}function Yy(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function Xy(){this.buffer()}function Zy(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function Qy(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=hm(this.sliceSerialize(e)).toLowerCase(),n.label=t}function $y(e){this.exit(e)}function eb(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=hm(this.sliceSerialize(e)).toLowerCase(),n.label=t}function tb(e){this.exit(e)}function nb(){return`[`}function rb(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function ib(){return{enter:{gfmFootnoteCallString:Jy,gfmFootnoteCall:Yy,gfmFootnoteDefinitionLabelString:Xy,gfmFootnoteDefinition:Zy},exit:{gfmFootnoteCallString:Qy,gfmFootnoteCall:$y,gfmFootnoteDefinitionLabelString:eb,gfmFootnoteDefinition:tb}}}function ab(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:rb},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
35
+ `:` `)+r.indentLines(r.containerFlow(e,a.current()),t?sb:ob))),s(),o}}function ob(e,t,n){return t===0?e:sb(e,t,n)}function sb(e,t,n){return(n?``:` `)+e}var cb=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];pb.peek=mb;function lb(){return{canContainEols:[`delete`],enter:{strikethrough:db},exit:{strikethrough:fb}}}function ub(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:cb}],handlers:{delete:pb}}}function db(e){this.enter({type:`delete`,children:[]},e)}function fb(e){this.exit(e)}function pb(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function mb(){return`~`}function hb(e){return e.length}function gb(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||hb,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=_b(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=vb(r[d]);else{let e=vb(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding===!1||n.alignDelimiters===!1&&i===``||n.delimiterStart===!1&&!d||r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
36
+ `)}function _b(e){return e==null?``:String(e)}function vb(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function yb(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),bb);return i(),o}function bb(e,t,n){return`>`+(n?``:` `)+e}function xb(e,t){return Sb(e,t.inConstruct,!0)&&!Sb(e,t.notInConstruct,!1)}function Sb(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function Cb(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
37
+ `&&xb(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
38
+ `}function wb(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function Tb(e,t){return!(t.options.fences!==!1||!e.value||e.lang||!/[^ \r\n]/.test(e.value)||/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function Eb(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function Db(e,t,n,r){let i=Eb(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(Tb(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,Ob);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(wb(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
39
+ `,encode:["`"],...s.current()})),t()}return u+=s.move(`
40
+ `),a&&(u+=s.move(a+`
41
+ `)),u+=s.move(c),l(),u}function Ob(e,t,n){return(n?``:` `)+e}function kb(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function Ab(e,t,n,r){let i=kb(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
42
+ `,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function jb(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Mb(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function Nb(e,t,n){let r=Lm(e),i=Lm(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}Pb.peek=Fb;function Pb(e,t,n,r){let i=jb(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=Nb(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=Mb(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=Nb(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+Mb(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function Fb(e,t,n){return n.options.emphasis||`*`}function Ib(e,t){let n=!1;return ov(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&nm(e)&&(t.options.setext||n))}function Lb(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(Ib(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
43
+ `,after:`
44
+ `});return r(),t(),o+`
45
+ `+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
46
+ `))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
47
+ `,...a.current()});return/^[\t ]/.test(l)&&(l=Mb(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}Rb.peek=zb;function Rb(e){return e.value||``}function zb(){return`<`}Bb.peek=Vb;function Bb(e,t,n,r){let i=kb(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function Vb(){return`!`}Hb.peek=Ub;function Hb(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Ub(){return`!`}Wb.peek=Gb;function Wb(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function Gb(){return"`"}function Kb(e,t){let n=nm(e);return!(t.options.resourceLink||!e.url||e.title||!e.children||e.children.length!==1||e.children[0].type!==`text`||n!==e.url&&`mailto:`+n!==e.url||!/^[a-z][a-z+.-]+:/i.test(e.url)||/[\0- <>\u007F]/.test(e.url))}qb.peek=Jb;function qb(e,t,n,r){let i=kb(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(Kb(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function Jb(e,t,n){return Kb(e,n)?`<`:`[`}Yb.peek=Xb;function Yb(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Xb(){return`[`}function Zb(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Qb(e){let t=Zb(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function $b(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function ex(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function tx(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?$b(n):Zb(n),s=e.ordered?o===`.`?`)`:`.`:Qb(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if(o!==`*`&&o!==`-`||!t||t.children&&t.children[0]||n.stack[n.stack.length-1]!==`list`||n.stack[n.stack.length-2]!==`listItem`||n.stack[n.stack.length-3]!==`list`||n.stack[n.stack.length-4]!==`listItem`||n.indexStack[n.indexStack.length-1]!==0||n.indexStack[n.indexStack.length-2]!==0||n.indexStack[n.indexStack.length-3]!==0||(c=!0),ex(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function nx(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function rx(e,t,n,r){let i=nx(n),a=n.bulletCurrent||Zb(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function ix(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var ax=Y_([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function ox(e,t,n,r){return(e.children.some(function(e){return ax(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function sx(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}cx.peek=lx;function cx(e,t,n,r){let i=sx(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=Nb(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=Mb(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=Nb(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+Mb(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function lx(e,t,n){return n.options.strong||`*`}function ux(e,t,n,r){return n.safe(e.value,r)}function dx(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function fx(e,t,n){let r=(ex(n)+(n.options.ruleSpaces?` `:``)).repeat(dx(n));return n.options.ruleSpaces?r.slice(0,-1):r}var px={blockquote:yb,break:Cb,code:Db,definition:Ab,emphasis:Pb,hardBreak:Cb,heading:Lb,html:Rb,image:Bb,imageReference:Hb,inlineCode:Wb,link:qb,linkReference:Yb,list:tx,listItem:rx,paragraph:ix,root:ox,strong:cx,text:ux,thematicBreak:fx};function mx(){return{enter:{table:hx,tableData:yx,tableHeader:yx,tableRow:_x},exit:{codeText:bx,table:gx,tableData:vx,tableHeader:vx,tableRow:vx}}}function hx(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function gx(e){this.exit(e),this.data.inTable=void 0}function _x(e){this.enter({type:`tableRow`,children:[]},e)}function vx(e){this.exit(e)}function yx(e){this.enter({type:`tableCell`,children:[]},e)}function bx(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,xx));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function xx(e,t){return t===`|`?t:e}function Sx(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
48
+ `,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
49
+ `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return gb(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=px.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function Cx(){return{exit:{taskListCheckValueChecked:Tx,taskListCheckValueUnchecked:Tx,paragraph:Ex}}}function wx(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:Dx}}}function Tx(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function Ex(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function Dx(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=px.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function Ox(){return[Py(),ib(),lb(),mx(),Cx()]}function kx(e){return{extensions:[Fy(),ab(e),ub(),Sx(e),wx()]}}var Ax={tokenize:Wx,partial:!0},jx={tokenize:Gx,partial:!0},Mx={tokenize:Kx,partial:!0},Nx={tokenize:qx,partial:!0},Px={tokenize:Jx,partial:!0},Fx={name:`wwwAutolink`,tokenize:Hx,previous:Yx},Ix={name:`protocolAutolink`,tokenize:Ux,previous:Xx},Lx={name:`emailAutolink`,tokenize:Vx,previous:Zx},Rx={};function zx(){return{text:Rx}}for(var Bx=48;Bx<123;)Rx[Bx]=Lx,Bx++,Bx===58?Bx=65:Bx===91&&(Bx=97);Rx[43]=Lx,Rx[45]=Lx,Rx[46]=Lx,Rx[95]=Lx,Rx[72]=[Lx,Ix],Rx[104]=[Lx,Ix],Rx[87]=[Lx,Fx],Rx[119]=[Lx,Fx];function Vx(e,t,n){let r=this,i,a;return o;function o(t){return!Qx(t)||!Zx.call(r,r.previous)||$x(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return Qx(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Px,u,l)(t):t===45||t===95||_m(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&gm(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function Hx(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!Yx.call(r,r.previous)||$x(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(Ax,e.attempt(jx,e.attempt(Mx,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function Ux(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&Xx.call(r,r.previous)&&!$x(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(gm(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||ym(t)||wm(t)||Dm(t)||Em(t)?n(t):e.attempt(jx,e.attempt(Mx,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function Wx(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function Gx(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(Nx,c,s)(t):t===null||wm(t)||Dm(t)||t!==45&&Em(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function Kx(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(Nx,t,a)(o):o===null||wm(o)||Dm(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function qx(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||wm(o)||Dm(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||wm(e)||Dm(e)?t(e):r(e)}function a(e){return gm(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):gm(t)?(e.consume(t),o):n(t)}}function Jx(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return _m(e)?n(e):t(e)}}function Yx(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||wm(e)}function Xx(e){return!gm(e)}function Zx(e){return!(e===47||Qx(e))}function Qx(e){return e===43||e===45||e===46||e===95||_m(e)}function $x(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var eS={tokenize:cS,partial:!0};function tS(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:aS,continuation:{tokenize:oS},exit:sS}},text:{91:{name:`gfmFootnoteCall`,tokenize:iS},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:nS,resolveTo:rS}}}}function nS(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=hm(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function rS(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function iS(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||wm(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(hm(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return wm(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function aS(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||wm(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=hm(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return wm(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),Am(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function oS(e,t,n){return e.check(Gm,t,e.attempt(eS,t,n))}function sS(e){e.exit(`gfmFootnoteDefinition`)}function cS(e,t,n){let r=this;return Am(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function lS(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&cm(o,o.length,0,Rm(s,e.slice(r+1,n),t)),cm(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),cm(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=Lm(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=Lm(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var uS=class{constructor(){this.map=[]}add(e,t,n){dS(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function dS(e,t,n,r){let i=0;if(n!==0||r.length!==0){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function fS(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function pS(){return{flow:{null:{name:`table`,tokenize:mS,resolveAll:hS}}}}function mS(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124||(o=!0,a+=1),u(e)}function u(t){return t===null?n(t):Cm(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Tm(t)?Am(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||wm(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Tm(t)?Am(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Tm(t)?Am(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||Cm(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Tm(t)?Am(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||Cm(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||Cm(n)?(e.exit(`tableRow`),t(n)):Tm(n)?Am(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||wm(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function hS(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new uS;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(_S(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=gS(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=gS(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=gS(f,t,o,i,n,d)):(o[0]=o[1],d=gS(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&_S(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=fS(t.events,n))}return e}function gS(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},vS(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=vS(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=vS(t.events,n[2]),a=vS(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},vS(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function _S(e,t,n,r,i){let a=[],o=vS(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function vS(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var yS={name:`tasklistCheck`,tokenize:xS};function bS(){return{text:{91:yS}}}function xS(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return wm(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return Cm(r)?t(r):Tm(r)?e.check({tokenize:SS},t,n)(r):n(r)}}function SS(e,t,n){return Am(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function CS(e){return dm([zx(),tS(),lS(e),pS(),bS()])}var wS={};function TS(e){let t=this,n=e||wS,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(CS(n)),a.push(Ox()),o.push(kx(n))}function ES(){return{enter:{mathFlow:e,mathFlowFenceMeta:t,mathText:a},exit:{mathFlow:i,mathFlowFence:r,mathFlowFenceMeta:n,mathFlowValue:s,mathText:o,mathTextData:s}};function e(e){this.enter({type:`math`,meta:null,value:``,data:{hName:`pre`,hChildren:[{type:`element`,tagName:`code`,properties:{className:[`language-math`,`math-display`]},children:[]}]}},e)}function t(){this.buffer()}function n(){let e=this.resume(),t=this.stack[this.stack.length-1];t.type,t.meta=e}function r(){this.data.mathFlowInside||(this.buffer(),this.data.mathFlowInside=!0)}function i(e){let t=this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),n=this.stack[this.stack.length-1];n.type,this.exit(e),n.value=t;let r=n.data.hChildren[0];r.type,r.tagName,r.children.push({type:`text`,value:t}),this.data.mathFlowInside=void 0}function a(e){this.enter({type:`inlineMath`,value:``,data:{hName:`code`,hProperties:{className:[`language-math`,`math-inline`]},hChildren:[]}},e),this.buffer()}function o(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,this.exit(e),n.value=t,n.data.hChildren.push({type:`text`,value:t})}function s(e){this.config.enter.data.call(this,e),this.config.exit.data.call(this,e)}}function DS(e){let t=(e||{}).singleDollarTextMath;return t??=!0,r.peek=i,{unsafe:[{character:`\r`,inConstruct:`mathFlowMeta`},{character:`
50
+ `,inConstruct:`mathFlowMeta`},{character:`$`,after:t?void 0:`\\$`,inConstruct:`phrasing`},{character:`$`,inConstruct:`mathFlowMeta`},{atBreak:!0,character:`$`,after:`\\$`}],handlers:{math:n,inlineMath:r}};function n(e,t,n,r){let i=e.value||``,a=n.createTracker(r),o=`$`.repeat(Math.max(wb(i,`$`)+1,2)),s=n.enter(`mathFlow`),c=a.move(o);if(e.meta){let t=n.enter(`mathFlowMeta`);c+=a.move(n.safe(e.meta,{after:`
51
+ `,before:c,encode:[`$`],...a.current()})),t()}return c+=a.move(`
52
+ `),i&&(c+=a.move(i+`
53
+ `)),c+=a.move(o),s(),c}function r(e,n,r){let i=e.value||``,a=1;for(t||a++;RegExp(`(^|[^$])`+`\\$`.repeat(a)+`([^$]|$)`).test(i);)a++;let o=`$`.repeat(a);/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^\$|\$$/.test(i))&&(i=` `+i+` `);let s=-1;for(;++s<r.unsafe.length;){let e=r.unsafe[s];if(!e.atBreak)continue;let t=r.compilePattern(e),n;for(;n=t.exec(i);){let e=n.index;i.codePointAt(e)===10&&i.codePointAt(e-1)===13&&e--,i=i.slice(0,e)+` `+i.slice(n.index+1)}}return o+i+o}function i(){return`$`}}var OS={tokenize:AS,concrete:!0,name:`mathFlow`},kS={tokenize:jS,partial:!0};function AS(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){return e.enter(`mathFlow`),e.enter(`mathFlowFence`),e.enter(`mathFlowFenceSequence`),c(t)}function c(t){return t===36?(e.consume(t),o++,c):o<2?n(t):(e.exit(`mathFlowFenceSequence`),Am(e,l,`whitespace`)(t))}function l(t){return t===null||Cm(t)?d(t):(e.enter(`mathFlowFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===null||Cm(t)?(e.exit(`chunkString`),e.exit(`mathFlowFenceMeta`),d(t)):t===36?n(t):(e.consume(t),u)}function d(n){return e.exit(`mathFlowFence`),r.interrupt?t(n):e.attempt(kS,f,g)(n)}function f(t){return e.attempt({tokenize:_,partial:!0},g,p)(t)}function p(t){return(a?Am(e,m,`linePrefix`,a+1):m)(t)}function m(t){return t===null?g(t):Cm(t)?e.attempt(kS,f,g)(t):(e.enter(`mathFlowValue`),h(t))}function h(t){return t===null||Cm(t)?(e.exit(`mathFlowValue`),m(t)):(e.consume(t),h)}function g(n){return e.exit(`mathFlow`),t(n)}function _(e,t,n){let i=0;return Am(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4);function a(t){return e.enter(`mathFlowFence`),e.enter(`mathFlowFenceSequence`),s(t)}function s(t){return t===36?(i++,e.consume(t),s):i<o?n(t):(e.exit(`mathFlowFenceSequence`),Am(e,c,`whitespace`)(t))}function c(r){return r===null||Cm(r)?(e.exit(`mathFlowFence`),t(r)):n(r)}}}function jS(e,t,n){let r=this;return i;function i(n){return n===null?t(n):(e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function MS(e){let t=(e||{}).singleDollarTextMath;return t??=!0,{tokenize:n,resolve:NS,previous:PS,name:`mathText`};function n(e,n,r){let i=0,a,o;return s;function s(t){return e.enter(`mathText`),e.enter(`mathTextSequence`),c(t)}function c(n){return n===36?(e.consume(n),i++,c):i<2&&!t?r(n):(e.exit(`mathTextSequence`),l(n))}function l(t){return t===null?r(t):t===36?(o=e.enter(`mathTextSequence`),a=0,d(t)):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),l):Cm(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),l):(e.enter(`mathTextData`),u(t))}function u(t){return t===null||t===32||t===36||Cm(t)?(e.exit(`mathTextData`),l(t)):(e.consume(t),u)}function d(t){return t===36?(e.consume(t),a++,d):a===i?(e.exit(`mathTextSequence`),e.exit(`mathText`),n(t)):(o.type=`mathTextData`,u(t))}}}function NS(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`mathTextData`){e[t][1].type=`mathTextPadding`,e[n][1].type=`mathTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`mathTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function PS(e){return e!==36||this.events[this.events.length-1][1].type===`characterEscape`}function FS(e){return{flow:{36:OS},text:{36:MS(e)}}}var IS={};function LS(e){let t=this,n=e||IS,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(FS(n)),a.push(ES()),o.push(DS(n))}var U=class e{constructor(t,n){let r=` `+t,i,a=n&&n.loc;if(a&&a.start<=a.end){let e=a.lexer.input;i=a.start;let t=a.end;i===e.length?r+=` at end of input: `:r+=` at position `+(i+1)+`:
54
+ `;let n=e.slice(i,t).replace(/[^]/g,`$&̲`),o;o=i>15?`…`+e.slice(i-15,i):e.slice(0,i);let s;s=t+15<e.length?e.slice(t,t+15)+`…`:e.slice(t),r+=o+n+s}let o=Error(r);return o.name=`ParseError`,o.__proto__=e.prototype,o.position=i,o}};U.prototype.__proto__=Error.prototype;var RS=function(e,t,n){if(!Object.prototype.hasOwnProperty.call(e,t))return n;let r=e[t];return r===void 0?n:r},zS=/([A-Z])/g,BS=function(e){return e.replace(zS,`-$1`).toLowerCase()},VS={"&":`&amp;`,">":`&gt;`,"<":`&lt;`,'"':`&quot;`,"'":`&#x27;`},HS=/[&><"']/g;function US(e){return String(e).replace(HS,e=>VS[e])}var WS=function(e){return e.type===`ordgroup`||e.type===`color`?e.body.length===1?WS(e.body[0]):e:e.type===`font`?WS(e.body):e},GS=function(e){let t=WS(e);return t.type===`mathord`||t.type===`textord`||t.type===`atom`},KS=function(e){if(!e)throw Error(`Expected non-null, but got `+String(e));return e},qS=function(e){let t=/^[\x00-\x20]*([^\\/#?]*?)(:|&#0*58|&#x0*3a|&colon)/i.exec(e);return t?t[2]!==`:`||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?null:t[1].toLowerCase():`_relative`},JS=function(e){return+e.toFixed(4)},YS=`acegıȷmnopqrsuvwxyzαγεηικμνοπρςστυχωϕ𝐚𝐜𝐞𝐠𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐮𝐯𝐰𝐱𝐲𝐳`,XS=[`__proto__`,`prototype`,`constructor`],ZS=e=>{if(typeof e!=`object`||!e)return Object.create(null);for(let t of XS)Object.prototype.hasOwnProperty.call(e,t)&&delete e[t];return Object.setPrototypeOf(e,null)},QS=class{constructor(e){e||={},this.displayMode=RS(e,`displayMode`,!1),this.annotate=RS(e,`annotate`,!1),this.leqno=RS(e,`leqno`,!1),this.throwOnError=RS(e,`throwOnError`,!1),this.errorColor=RS(e,`errorColor`,`#b22222`),this.macros=ZS(Object.prototype.hasOwnProperty.call(e,`macros`)?e.macros:void 0),this.wrap=RS(e,`wrap`,`none`),this.xml=RS(e,`xml`,!1),this.colorIsTextColor=RS(e,`colorIsTextColor`,!1),this.strict=RS(e,`strict`,!1),this.trust=RS(e,`trust`,!1);let t=Object.prototype.hasOwnProperty.call(e,`maxSize`)?e.maxSize:void 0;this.maxSize=t===void 0?[1/0,1/0]:Array.isArray(t)?t:[1/0,1/0],this.maxExpand=Math.max(0,RS(e,`maxExpand`,1e3)),this.wrapDelimiterPairs=!0}isTrusted(e){if(e.url&&!e.protocol){let t=qS(e.url);if(t==null)return!1;e.protocol=t}return!!(typeof this.trust==`function`?this.trust(e):this.trust)}},$S={},eC={};function tC({type:e,names:t,props:n,handler:r,mathmlBuilder:i}){let a={type:e,numArgs:n.numArgs,argTypes:n.argTypes,allowedInArgument:!!n.allowedInArgument,allowedInText:!!n.allowedInText,allowedInMath:n.allowedInMath===void 0||n.allowedInMath,numOptionalArgs:n.numOptionalArgs||0,infix:!!n.infix,primitive:!!n.primitive,handler:r};for(let e=0;e<t.length;++e)$S[t[e]]=a;e&&i&&(eC[e]=i)}function nC({type:e,mathmlBuilder:t}){tC({type:e,names:[],props:{numArgs:0},handler(){throw Error(`Should never be called.`)},mathmlBuilder:t})}var rC=function(e){return e.type===`ordgroup`&&e.body.length===1?e.body[0]:e},iC=function(e){return e.type===`ordgroup`?e.body:[e]},aC=class{constructor(e){this.children=e,this.classes=[],this.style={}}hasClass(e){return this.classes.includes(e)}toNode(){let e=document.createDocumentFragment();for(let t=0;t<this.children.length;t++)e.appendChild(this.children[t].toNode());return e}toMarkup(){let e=``;for(let t=0;t<this.children.length;t++)e+=this.children[t].toMarkup();return e}toText(){return this.children.map(e=>e.toText()).join(``)}},oC=function(e){return e.filter(e=>e).join(` `)},sC=function(e,t){this.classes=e||[],this.attributes={},this.style=t||{}},cC=function(e){let t=document.createElement(e);t.className=oC(this.classes);for(let e in this.style)Object.prototype.hasOwnProperty.call(this.style,e)&&(t.style[e]=this.style[e]);for(let e in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,e)&&t.setAttribute(e,this.attributes[e]);for(let e=0;e<this.children.length;e++)t.appendChild(this.children[e].toNode());return t},lC=function(e){let t=`<${e}`;this.classes.length&&(t+=` class="${US(oC(this.classes))}"`);let n=``;for(let e in this.style)Object.prototype.hasOwnProperty.call(this.style,e)&&(n+=`${BS(e)}:${this.style[e]};`);n&&(t+=` style="${n}"`);for(let e in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,e)&&(t+=` ${e}="${US(this.attributes[e])}"`);t+=`>`;for(let e=0;e<this.children.length;e++)t+=this.children[e].toMarkup();return t+=`</${e}>`,t},uC=class{constructor(e,t,n){sC.call(this,e,n),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}toNode(){return cC.call(this,`span`)}toMarkup(){return lC.call(this,`span`)}},dC=class{constructor(e){this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return US(this.text)}},fC=class{constructor(e,t,n){this.href=e,this.classes=t,this.children=n||[]}toNode(){let e=document.createElement(`a`);e.setAttribute(`href`,this.href),this.classes.length>0&&(e.className=oC(this.classes));for(let t=0;t<this.children.length;t++)e.appendChild(this.children[t].toNode());return e}toMarkup(){let e=`<a href='${US(this.href)}'`;this.classes.length>0&&(e+=` class="${US(oC(this.classes))}"`),e+=`>`;for(let t=0;t<this.children.length;t++)e+=this.children[t].toMarkup();return e+=`</a>`,e}},pC=class{constructor(e,t,n){this.alt=t,this.src=e,this.classes=[`mord`],this.style=n}hasClass(e){return this.classes.includes(e)}toNode(){let e=document.createElement(`img`);e.src=this.src,e.alt=this.alt,e.className=`mord`;for(let t in this.style)Object.prototype.hasOwnProperty.call(this.style,t)&&(e.style[t]=this.style[t]);return e}toMarkup(){let e=`<img src='${this.src}' alt='${this.alt}'`,t=``;for(let e in this.style)Object.prototype.hasOwnProperty.call(this.style,e)&&(t+=`${BS(e)}:${this.style[e]};`);return t&&(e+=` style="${US(t)}"`),e+=`>`,e}};function mC(e){return new aC(e)}var W=class{constructor(e,t,n,r){this.type=e,this.attributes={},this.children=t||[],this.classes=n||[],this.style=r||{},this.label=``}setAttribute(e,t){this.attributes[e]=t}getAttribute(e){return this.attributes[e]}setLabel(e){this.label=e}toNode(){let e=document.createElementNS(`http://www.w3.org/1998/Math/MathML`,this.type);for(let t in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,t)&&e.setAttribute(t,this.attributes[t]);this.classes.length>0&&(e.className=oC(this.classes));for(let t in this.style)Object.prototype.hasOwnProperty.call(this.style,t)&&(e.style[t]=this.style[t]);for(let t=0;t<this.children.length;t++)e.appendChild(this.children[t].toNode());return e}toMarkup(){let e=`<`+this.type;for(let t in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,t)&&(e+=` `+t+`="`,e+=US(this.attributes[t]),e+=`"`);this.classes.length>0&&(e+=` class="${US(oC(this.classes))}"`);let t=``;for(let e in this.style)Object.prototype.hasOwnProperty.call(this.style,e)&&(t+=`${BS(e)}:${this.style[e]};`);t&&(e+=` style="${t}"`),e+=`>`;for(let t=0;t<this.children.length;t++)e+=this.children[t].toMarkup();return e+=`</`+this.type+`>`,e}toText(){return this.children.map(e=>e.toText()).join(``)}},hC=class{constructor(e){this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return US(this.toText())}toText(){return this.text}},gC=e=>{let t;return e.length===1&&e[0].type===`mrow`?(t=e.pop(),t.type=`mstyle`):t=new W(`mstyle`,e),t},_C=e=>{let t=0;if(e.body&&Array.isArray(e.body))for(let n of e.body)t+=_C(n);else if(e.body)t+=_C(e.body);else if(e.type===`supsub`)t+=_C(e.base),e.sub&&(t+=.7*_C(e.sub)),e.sup&&(t+=.7*_C(e.sup));else if(e.type===`mathord`||e.type===`textord`)for(let n of e.text.split(``)){let e=n.codePointAt(0);t+=96<e&&e<123||944<e&&e<970?.56:47<e&&e<58?.5:.92}else t+=1;return t},vC={widehat:`ˆ`,widecheck:`ˇ`,widetilde:`~`,wideparen:`⏜`,utilde:`~`,overleftarrow:`←`,underleftarrow:`←`,xleftarrow:`←`,overrightarrow:`→`,underrightarrow:`→`,xrightarrow:`→`,underbrace:`⏟`,overbrace:`⏞`,overbracket:`⎴`,underbracket:`⎵`,overgroup:`⏠`,overparen:`⏜`,undergroup:`⏡`,underparen:`⏝`,overleftrightarrow:`↔`,underleftrightarrow:`↔`,xleftrightarrow:`↔`,Overrightarrow:`⇒`,xRightarrow:`⇒`,overleftharpoon:`↼`,xleftharpoonup:`↼`,overrightharpoon:`⇀`,xrightharpoonup:`⇀`,xLeftarrow:`⇐`,xLeftrightarrow:`⇔`,xhookleftarrow:`↩`,xhookrightarrow:`↪`,xmapsto:`↦`,xrightharpoondown:`⇁`,xleftharpoondown:`↽`,xtwoheadleftarrow:`↞`,xtwoheadrightarrow:`↠`,xlongequal:`=`,xrightleftarrows:`⇄`,xtofrom:`⇄`,xleftrightharpoons:`⇋`,xrightleftharpoons:`⇌`,yields:`→`,yieldsLeft:`←`,mesomerism:`↔`,longrightharpoonup:`⇀`,longleftharpoondown:`↽`,eqrightharpoonup:`⇀`,eqleftharpoondown:`↽`,"\\cdrightarrow":`→`,"\\cdleftarrow":`←`,"\\cdlongequal":`=`,yieldsLeftRight:`⇄`,chemequilibrium:`⇌`},yC=function(e){let t=new W(`mo`,[new hC(vC[e.slice(1)])]);return t.setAttribute(`stretchy`,`true`),t},bC=[`\\widehat`,`\\widecheck`],xC=e=>{let t=yC(e.label);if(e.label.indexOf(`tilde`)>-1){let n=_C(e.base);1<n&&n<1.6?t.classes.push(`tml-tilde-2`):1.6<=n&&n<2.5?t.classes.push(`tml-tilde-3`):2.5<=n&&t.classes.push(`tml-tilde-4`)}else if(bC.includes(e.label)){let n=_C(e.base);0<n&&n<=1?t.classes.push(`tml-hat-1`):1<n&&n<1.6?t.classes.push(`tml-hat-2`):1.6<=n&&n<2.5?t.classes.push(`tml-hat-3`):2.5<=n&&t.classes.push(`tml-hat-4`)}return t},SC={bin:1,close:1,inner:1,open:1,punct:1,rel:1},CC={"accent-token":1,mathord:1,"op-token":1,spacing:1,textord:1},wC=Object.create(null);wC.math=Object.create(null),wC.text=Object.create(null);function G(e,t,n,r,i){if(e!==`math`&&e!==`text`)throw TypeError(`Invalid mode: ${e} called in defineSymbol`);let a={group:t,replace:n};wC[e][r]=a,i&&n&&(wC[e][n]=a)}var K=`math`,q=`text`,TC=`accent-token`,J=`bin`,EC=`close`,DC=`inner`,Y=`mathord`,OC=`op-token`,kC=`open`,AC=`punct`,X=`rel`,jC=`spacing`,Z=`textord`;G(K,X,`≡`,`\\equiv`,!0),G(K,X,`≺`,`\\prec`,!0),G(K,X,`≻`,`\\succ`,!0),G(K,X,`∼`,`\\sim`,!0),G(K,X,`⟂`,`\\perp`,!0),G(K,X,`⪯`,`\\preceq`,!0),G(K,X,`⪰`,`\\succeq`,!0),G(K,X,`≃`,`\\simeq`,!0),G(K,X,`≌`,`\\backcong`,!0),G(K,X,`|`,`\\mid`,!0),G(K,X,`≪`,`\\ll`,!0),G(K,X,`≫`,`\\gg`,!0),G(K,X,`≍`,`\\asymp`,!0),G(K,X,`∥`,`\\parallel`),G(K,X,`⌣`,`\\smile`,!0),G(K,X,`⊑`,`\\sqsubseteq`,!0),G(K,X,`⊒`,`\\sqsupseteq`,!0),G(K,X,`≐`,`\\doteq`,!0),G(K,X,`⌢`,`\\frown`,!0),G(K,X,`∋`,`\\ni`,!0),G(K,X,`∌`,`\\notni`,!0),G(K,X,`∝`,`\\propto`,!0),G(K,X,`⊢`,`\\vdash`,!0),G(K,X,`⊣`,`\\dashv`,!0),G(K,X,`∋`,`\\owns`),G(K,X,`≘`,`\\arceq`,!0),G(K,X,`≙`,`\\wedgeq`,!0),G(K,X,`≚`,`\\veeeq`,!0),G(K,X,`≛`,`\\stareq`,!0),G(K,X,`≝`,`\\eqdef`,!0),G(K,X,`≞`,`\\measeq`,!0),G(K,X,`≟`,`\\questeq`,!0),G(K,X,`≠`,`\\ne`,!0),G(K,X,`≠`,`\\neq`),G(K,X,`⩵`,`\\eqeq`,!0),G(K,X,`⩶`,`\\eqeqeq`,!0),G(K,X,`∷`,`\\dblcolon`,!0),G(K,X,`≔`,`\\coloneqq`,!0),G(K,X,`≕`,`\\eqqcolon`,!0),G(K,X,`∹`,`\\eqcolon`,!0),G(K,X,`⩴`,`\\Coloneqq`,!0),G(K,AC,`.`,`\\ldotp`),G(K,AC,`·`,`\\cdotp`),G(K,Z,`#`,`\\#`),G(q,Z,`#`,`\\#`),G(K,Z,`&`,`\\&`),G(q,Z,`&`,`\\&`),G(K,Z,`ℵ`,`\\aleph`,!0),G(K,Z,`∀`,`\\forall`,!0),G(K,Z,`ℏ`,`\\hbar`,!0),G(K,Z,`∃`,`\\exists`,!0),G(K,kC,`∇`,`\\nabla`,!0),G(K,Z,`♭`,`\\flat`,!0),G(K,Z,`ℓ`,`\\ell`,!0),G(K,Z,`♮`,`\\natural`,!0),G(K,Z,`Å`,`\\Angstrom`,!0),G(q,Z,`Å`,`\\Angstrom`,!0),G(K,Z,`♣`,`\\clubsuit`,!0),G(K,Z,`♧`,`\\varclubsuit`,!0),G(K,Z,`℘`,`\\wp`,!0),G(K,Z,`♯`,`\\sharp`,!0),G(K,Z,`♢`,`\\diamondsuit`,!0),G(K,Z,`♦`,`\\vardiamondsuit`,!0),G(K,Z,`ℜ`,`\\Re`,!0),G(K,Z,`♡`,`\\heartsuit`,!0),G(K,Z,`♥`,`\\varheartsuit`,!0),G(K,Z,`ℑ`,`\\Im`,!0),G(K,Z,`♠`,`\\spadesuit`,!0),G(K,Z,`♤`,`\\varspadesuit`,!0),G(K,Z,`♀`,`\\female`,!0),G(K,Z,`♂`,`\\male`,!0),G(K,Z,`§`,`\\S`,!0),G(q,Z,`§`,`\\S`),G(K,Z,`¶`,`\\P`,!0),G(q,Z,`¶`,`\\P`),G(q,Z,`☺`,`\\smiley`,!0),G(K,Z,`☺`,`\\smiley`,!0),G(K,Z,`†`,`\\dag`),G(q,Z,`†`,`\\dag`),G(q,Z,`†`,`\\textdagger`),G(K,Z,`‡`,`\\ddag`),G(q,Z,`‡`,`\\ddag`),G(q,Z,`‡`,`\\textdaggerdbl`),G(K,EC,`⎱`,`\\rmoustache`,!0),G(K,kC,`⎰`,`\\lmoustache`,!0),G(K,EC,`⟯`,`\\rgroup`,!0),G(K,kC,`⟮`,`\\lgroup`,!0),G(K,J,`∓`,`\\mp`,!0),G(K,J,`⊖`,`\\ominus`,!0),G(K,J,`⊎`,`\\uplus`,!0),G(K,J,`⊓`,`\\sqcap`,!0),G(K,J,`∗`,`\\ast`),G(K,J,`⊔`,`\\sqcup`,!0),G(K,J,`◯`,`\\bigcirc`,!0),G(K,J,`∙`,`\\bullet`,!0),G(K,J,`‡`,`\\ddagger`),G(K,J,`≀`,`\\wr`,!0),G(K,J,`⨿`,`\\amalg`),G(K,J,`&`,`\\And`),G(K,J,`⫽`,`\\sslash`,!0),G(K,X,`⟵`,`\\longleftarrow`,!0),G(K,X,`⇐`,`\\Leftarrow`,!0),G(K,X,`⟸`,`\\Longleftarrow`,!0),G(K,X,`⟶`,`\\longrightarrow`,!0),G(K,X,`⇒`,`\\Rightarrow`,!0),G(K,X,`⟹`,`\\Longrightarrow`,!0),G(K,X,`↔`,`\\leftrightarrow`,!0),G(K,X,`⟷`,`\\longleftrightarrow`,!0),G(K,X,`⇔`,`\\Leftrightarrow`,!0),G(K,X,`⟺`,`\\Longleftrightarrow`,!0),G(K,X,`↤`,`\\mapsfrom`,!0),G(K,X,`↦`,`\\mapsto`,!0),G(K,X,`⟼`,`\\longmapsto`,!0),G(K,X,`↗`,`\\nearrow`,!0),G(K,X,`↩`,`\\hookleftarrow`,!0),G(K,X,`↪`,`\\hookrightarrow`,!0),G(K,X,`↘`,`\\searrow`,!0),G(K,X,`↼`,`\\leftharpoonup`,!0),G(K,X,`⇀`,`\\rightharpoonup`,!0),G(K,X,`↙`,`\\swarrow`,!0),G(K,X,`↽`,`\\leftharpoondown`,!0),G(K,X,`⇁`,`\\rightharpoondown`,!0),G(K,X,`↖`,`\\nwarrow`,!0),G(K,X,`⇌`,`\\rightleftharpoons`,!0),G(K,Y,`↯`,`\\lightning`,!0),G(K,Y,`∎`,`\\QED`,!0),G(K,Y,`‰`,`\\permil`,!0),G(q,Z,`‰`,`\\permil`),G(K,Y,`☉`,`\\astrosun`,!0),G(K,Y,`☼`,`\\sun`,!0),G(K,Y,`☾`,`\\leftmoon`,!0),G(K,Y,`☽`,`\\rightmoon`,!0),G(K,Y,`⊕`,`\\Earth`),G(K,X,`≮`,`\\nless`,!0),G(K,X,`⪇`,`\\lneq`,!0),G(K,X,`≨`,`\\lneqq`,!0),G(K,X,`≨︀`,`\\lvertneqq`),G(K,X,`⋦`,`\\lnsim`,!0),G(K,X,`⪉`,`\\lnapprox`,!0),G(K,X,`⊀`,`\\nprec`,!0),G(K,X,`⋠`,`\\npreceq`,!0),G(K,X,`⋨`,`\\precnsim`,!0),G(K,X,`⪹`,`\\precnapprox`,!0),G(K,X,`≁`,`\\nsim`,!0),G(K,X,`∤`,`\\nmid`,!0),G(K,X,`∤`,`\\nshortmid`),G(K,X,`⊬`,`\\nvdash`,!0),G(K,X,`⊭`,`\\nvDash`,!0),G(K,X,`⋪`,`\\ntriangleleft`),G(K,X,`⋬`,`\\ntrianglelefteq`,!0),G(K,X,`⊄`,`\\nsubset`,!0),G(K,X,`⊅`,`\\nsupset`,!0),G(K,X,`⊊`,`\\subsetneq`,!0),G(K,X,`⊊︀`,`\\varsubsetneq`),G(K,X,`⫋`,`\\subsetneqq`,!0),G(K,X,`⫋︀`,`\\varsubsetneqq`),G(K,X,`≯`,`\\ngtr`,!0),G(K,X,`⪈`,`\\gneq`,!0),G(K,X,`≩`,`\\gneqq`,!0),G(K,X,`≩︀`,`\\gvertneqq`),G(K,X,`⋧`,`\\gnsim`,!0),G(K,X,`⪊`,`\\gnapprox`,!0),G(K,X,`⊁`,`\\nsucc`,!0),G(K,X,`⋡`,`\\nsucceq`,!0),G(K,X,`⋩`,`\\succnsim`,!0),G(K,X,`⪺`,`\\succnapprox`,!0),G(K,X,`≆`,`\\ncong`,!0),G(K,X,`∦`,`\\nparallel`,!0),G(K,X,`∦`,`\\nshortparallel`),G(K,X,`⊯`,`\\nVDash`,!0),G(K,X,`⋫`,`\\ntriangleright`),G(K,X,`⋭`,`\\ntrianglerighteq`,!0),G(K,X,`⊋`,`\\supsetneq`,!0),G(K,X,`⊋`,`\\varsupsetneq`),G(K,X,`⫌`,`\\supsetneqq`,!0),G(K,X,`⫌︀`,`\\varsupsetneqq`),G(K,X,`⊮`,`\\nVdash`,!0),G(K,X,`⪵`,`\\precneqq`,!0),G(K,X,`⪶`,`\\succneqq`,!0),G(K,J,`⊴`,`\\unlhd`),G(K,J,`⊵`,`\\unrhd`),G(K,X,`↚`,`\\nleftarrow`,!0),G(K,X,`↛`,`\\nrightarrow`,!0),G(K,X,`⇍`,`\\nLeftarrow`,!0),G(K,X,`⇏`,`\\nRightarrow`,!0),G(K,X,`↮`,`\\nleftrightarrow`,!0),G(K,X,`⇎`,`\\nLeftrightarrow`,!0),G(K,X,`△`,`\\vartriangle`),G(K,Z,`ℏ`,`\\hslash`),G(K,Z,`▽`,`\\triangledown`),G(K,Z,`◊`,`\\lozenge`),G(K,Z,`Ⓢ`,`\\circledS`),G(K,Z,`®`,`\\circledR`,!0),G(q,Z,`®`,`\\circledR`),G(q,Z,`®`,`\\textregistered`),G(K,Z,`∡`,`\\measuredangle`,!0),G(K,Z,`∄`,`\\nexists`),G(K,Z,`℧`,`\\mho`),G(K,Z,`Ⅎ`,`\\Finv`,!0),G(K,Z,`⅁`,`\\Game`,!0),G(K,Z,`‵`,`\\backprime`),G(K,Z,`‶`,`\\backdprime`),G(K,Z,`‷`,`\\backtrprime`),G(K,Z,`▲`,`\\blacktriangle`),G(K,Z,`▼`,`\\blacktriangledown`),G(K,Z,`■`,`\\blacksquare`),G(K,Z,`⧫`,`\\blacklozenge`),G(K,Z,`★`,`\\bigstar`),G(K,Z,`∢`,`\\sphericalangle`,!0),G(K,Z,`∁`,`\\complement`,!0),G(K,Z,`╱`,`\\diagup`),G(K,Z,`╲`,`\\diagdown`),G(K,Z,`□`,`\\square`),G(K,Z,`□`,`\\Box`),G(K,Z,`◊`,`\\Diamond`),G(K,Z,`¥`,`\\yen`,!0),G(q,Z,`¥`,`\\yen`,!0),G(K,Z,`✓`,`\\checkmark`,!0),G(q,Z,`✓`,`\\checkmark`),G(K,Z,`✗`,`\\ballotx`,!0),G(q,Z,`✗`,`\\ballotx`),G(q,Z,`•`,`\\textbullet`),G(K,Z,`ℶ`,`\\beth`,!0),G(K,Z,`ℸ`,`\\daleth`,!0),G(K,Z,`ℷ`,`\\gimel`,!0),G(K,Z,`ϝ`,`\\digamma`,!0),G(K,Z,`ϰ`,`\\varkappa`),G(K,kC,`⌜`,`\\ulcorner`,!0),G(K,EC,`⌝`,`\\urcorner`,!0),G(K,kC,`⌞`,`\\llcorner`,!0),G(K,EC,`⌟`,`\\lrcorner`,!0),G(K,X,`≦`,`\\leqq`,!0),G(K,X,`⩽`,`\\leqslant`,!0),G(K,X,`⪕`,`\\eqslantless`,!0),G(K,X,`≲`,`\\lesssim`,!0),G(K,X,`⪅`,`\\lessapprox`,!0),G(K,X,`≊`,`\\approxeq`,!0),G(K,J,`⋖`,`\\lessdot`),G(K,X,`⋘`,`\\lll`,!0),G(K,X,`≶`,`\\lessgtr`,!0),G(K,X,`⋚`,`\\lesseqgtr`,!0),G(K,X,`⪋`,`\\lesseqqgtr`,!0),G(K,X,`≑`,`\\doteqdot`),G(K,X,`≓`,`\\risingdotseq`,!0),G(K,X,`≒`,`\\fallingdotseq`,!0),G(K,X,`∽`,`\\backsim`,!0),G(K,X,`⋍`,`\\backsimeq`,!0),G(K,X,`⫅`,`\\subseteqq`,!0),G(K,X,`⋐`,`\\Subset`,!0),G(K,X,`⊏`,`\\sqsubset`,!0),G(K,X,`≼`,`\\preccurlyeq`,!0),G(K,X,`⋞`,`\\curlyeqprec`,!0),G(K,X,`≾`,`\\precsim`,!0),G(K,X,`⪷`,`\\precapprox`,!0),G(K,X,`⊲`,`\\vartriangleleft`),G(K,X,`⊴`,`\\trianglelefteq`),G(K,X,`⊨`,`\\vDash`,!0),G(K,X,`⊫`,`\\VDash`,!0),G(K,X,`⊪`,`\\Vvdash`,!0),G(K,X,`⌣`,`\\smallsmile`),G(K,X,`⌢`,`\\smallfrown`),G(K,X,`≏`,`\\bumpeq`,!0),G(K,X,`≎`,`\\Bumpeq`,!0),G(K,X,`≧`,`\\geqq`,!0),G(K,X,`⩾`,`\\geqslant`,!0),G(K,X,`⪖`,`\\eqslantgtr`,!0),G(K,X,`≳`,`\\gtrsim`,!0),G(K,X,`⪆`,`\\gtrapprox`,!0),G(K,J,`⋗`,`\\gtrdot`),G(K,X,`⋙`,`\\ggg`,!0),G(K,X,`≷`,`\\gtrless`,!0),G(K,X,`⋛`,`\\gtreqless`,!0),G(K,X,`⪌`,`\\gtreqqless`,!0),G(K,X,`≖`,`\\eqcirc`,!0),G(K,X,`≗`,`\\circeq`,!0),G(K,X,`≜`,`\\triangleq`,!0),G(K,X,`∼`,`\\thicksim`),G(K,X,`≈`,`\\thickapprox`),G(K,X,`⫆`,`\\supseteqq`,!0),G(K,X,`⋑`,`\\Supset`,!0),G(K,X,`⊐`,`\\sqsupset`,!0),G(K,X,`≽`,`\\succcurlyeq`,!0),G(K,X,`⋟`,`\\curlyeqsucc`,!0),G(K,X,`≿`,`\\succsim`,!0),G(K,X,`⪸`,`\\succapprox`,!0),G(K,X,`⊳`,`\\vartriangleright`),G(K,X,`⊵`,`\\trianglerighteq`),G(K,X,`⊩`,`\\Vdash`,!0),G(K,X,`∣`,`\\shortmid`),G(K,X,`∥`,`\\shortparallel`),G(K,X,`≬`,`\\between`,!0),G(K,X,`⋔`,`\\pitchfork`,!0),G(K,X,`∝`,`\\varpropto`),G(K,X,`◀`,`\\blacktriangleleft`),G(K,X,`∴`,`\\therefore`,!0),G(K,X,`∍`,`\\backepsilon`),G(K,X,`▶`,`\\blacktriangleright`),G(K,X,`∵`,`\\because`,!0),G(K,X,`⋘`,`\\llless`),G(K,X,`⋙`,`\\gggtr`),G(K,J,`⊲`,`\\lhd`),G(K,J,`⊳`,`\\rhd`),G(K,X,`≂`,`\\eqsim`,!0),G(K,X,`≑`,`\\Doteq`,!0),G(K,X,`⥽`,`\\strictif`,!0),G(K,X,`⥼`,`\\strictfi`,!0),G(K,J,`∔`,`\\dotplus`,!0),G(K,J,`∖`,`\\smallsetminus`),G(K,J,`⋒`,`\\Cap`,!0),G(K,J,`⋓`,`\\Cup`,!0),G(K,J,`⩞`,`\\doublebarwedge`,!0),G(K,J,`⊟`,`\\boxminus`,!0),G(K,J,`⊞`,`\\boxplus`,!0),G(K,J,`⧄`,`\\boxslash`,!0),G(K,J,`⋇`,`\\divideontimes`,!0),G(K,J,`⋉`,`\\ltimes`,!0),G(K,J,`⋊`,`\\rtimes`,!0),G(K,J,`⋋`,`\\leftthreetimes`,!0),G(K,J,`⋌`,`\\rightthreetimes`,!0),G(K,J,`⋏`,`\\curlywedge`,!0),G(K,J,`⋎`,`\\curlyvee`,!0),G(K,J,`⊝`,`\\circleddash`,!0),G(K,J,`⊛`,`\\circledast`,!0),G(K,J,`⊺`,`\\intercal`,!0),G(K,J,`⋒`,`\\doublecap`),G(K,J,`⋓`,`\\doublecup`),G(K,J,`⊠`,`\\boxtimes`,!0),G(K,J,`⋈`,`\\bowtie`,!0),G(K,J,`⋈`,`\\Join`),G(K,J,`⟕`,`\\leftouterjoin`,!0),G(K,J,`⟖`,`\\rightouterjoin`,!0),G(K,J,`⟗`,`\\fullouterjoin`,!0),G(K,J,`∸`,`\\dotminus`,!0),G(K,J,`⟑`,`\\wedgedot`,!0),G(K,J,`⟇`,`\\veedot`,!0),G(K,J,`⩢`,`\\doublebarvee`,!0),G(K,J,`⩣`,`\\veedoublebar`,!0),G(K,J,`⩟`,`\\wedgebar`,!0),G(K,J,`⩠`,`\\wedgedoublebar`,!0),G(K,J,`⩔`,`\\Vee`,!0),G(K,J,`⩓`,`\\Wedge`,!0),G(K,J,`⩃`,`\\barcap`,!0),G(K,J,`⩂`,`\\barcup`,!0),G(K,J,`⩈`,`\\capbarcup`,!0),G(K,J,`⩀`,`\\capdot`,!0),G(K,J,`⩇`,`\\capovercup`,!0),G(K,J,`⩆`,`\\cupovercap`,!0),G(K,J,`⩍`,`\\closedvarcap`,!0),G(K,J,`⩌`,`\\closedvarcup`,!0),G(K,J,`⨪`,`\\minusdot`,!0),G(K,J,`⨫`,`\\minusfdots`,!0),G(K,J,`⨬`,`\\minusrdots`,!0),G(K,J,`⊻`,`\\Xor`,!0),G(K,J,`⊼`,`\\Nand`,!0),G(K,J,`⊽`,`\\Nor`,!0),G(K,J,`⊽`,`\\barvee`),G(K,J,`⫴`,`\\interleave`,!0),G(K,J,`⧢`,`\\shuffle`,!0),G(K,J,`⫶`,`\\threedotcolon`,!0),G(K,J,`⦂`,`\\typecolon`,!0),G(K,J,`∾`,`\\invlazys`,!0),G(K,J,`⩋`,`\\twocaps`,!0),G(K,J,`⩊`,`\\twocups`,!0),G(K,J,`⩎`,`\\Sqcap`,!0),G(K,J,`⩏`,`\\Sqcup`,!0),G(K,J,`⩖`,`\\veeonvee`,!0),G(K,J,`⩕`,`\\wedgeonwedge`,!0),G(K,J,`⧗`,`\\blackhourglass`,!0),G(K,J,`⧆`,`\\boxast`,!0),G(K,J,`⧈`,`\\boxbox`,!0),G(K,J,`⧇`,`\\boxcircle`,!0),G(K,J,`⊜`,`\\circledequal`,!0),G(K,J,`⦷`,`\\circledparallel`,!0),G(K,J,`⦶`,`\\circledvert`,!0),G(K,J,`⦵`,`\\circlehbar`,!0),G(K,J,`⟡`,`\\concavediamond`,!0),G(K,J,`⟢`,`\\concavediamondtickleft`,!0),G(K,J,`⟣`,`\\concavediamondtickright`,!0),G(K,J,`⋄`,`\\diamond`,!0),G(K,J,`⧖`,`\\hourglass`,!0),G(K,J,`⟠`,`\\lozengeminus`,!0),G(K,J,`⌽`,`\\obar`,!0),G(K,J,`⦸`,`\\obslash`,!0),G(K,J,`⨸`,`\\odiv`,!0),G(K,J,`⧁`,`\\ogreaterthan`,!0),G(K,J,`⧀`,`\\olessthan`,!0),G(K,J,`⦹`,`\\operp`,!0),G(K,J,`⨷`,`\\Otimes`,!0),G(K,J,`⨶`,`\\otimeshat`,!0),G(K,J,`⋆`,`\\star`,!0),G(K,J,`△`,`\\triangle`,!0),G(K,J,`⨺`,`\\triangleminus`,!0),G(K,J,`⨹`,`\\triangleplus`,!0),G(K,J,`⨻`,`\\triangletimes`,!0),G(K,J,`⟤`,`\\whitesquaretickleft`,!0),G(K,J,`⟥`,`\\whitesquaretickright`,!0),G(K,J,`⨳`,`\\smashtimes`,!0),G(K,X,`⇢`,`\\dashrightarrow`,!0),G(K,X,`⇠`,`\\dashleftarrow`,!0),G(K,X,`⇇`,`\\leftleftarrows`,!0),G(K,X,`⇆`,`\\leftrightarrows`,!0),G(K,X,`⇚`,`\\Lleftarrow`,!0),G(K,X,`↞`,`\\twoheadleftarrow`,!0),G(K,X,`↢`,`\\leftarrowtail`,!0),G(K,X,`↫`,`\\looparrowleft`,!0),G(K,X,`⇋`,`\\leftrightharpoons`,!0),G(K,X,`↶`,`\\curvearrowleft`,!0),G(K,X,`↺`,`\\circlearrowleft`,!0),G(K,X,`↰`,`\\Lsh`,!0),G(K,X,`⇈`,`\\upuparrows`,!0),G(K,X,`↿`,`\\upharpoonleft`,!0),G(K,X,`⇃`,`\\downharpoonleft`,!0),G(K,X,`⊶`,`\\origof`,!0),G(K,X,`⊷`,`\\imageof`,!0),G(K,X,`⊸`,`\\multimap`,!0),G(K,X,`↭`,`\\leftrightsquigarrow`,!0),G(K,X,`⇉`,`\\rightrightarrows`,!0),G(K,X,`⇄`,`\\rightleftarrows`,!0),G(K,X,`↠`,`\\twoheadrightarrow`,!0),G(K,X,`↣`,`\\rightarrowtail`,!0),G(K,X,`↬`,`\\looparrowright`,!0),G(K,X,`↷`,`\\curvearrowright`,!0),G(K,X,`↻`,`\\circlearrowright`,!0),G(K,X,`↱`,`\\Rsh`,!0),G(K,X,`⇊`,`\\downdownarrows`,!0),G(K,X,`↾`,`\\upharpoonright`,!0),G(K,X,`⇂`,`\\downharpoonright`,!0),G(K,X,`⇝`,`\\rightsquigarrow`,!0),G(K,X,`⇝`,`\\leadsto`),G(K,X,`⇛`,`\\Rrightarrow`,!0),G(K,X,`↾`,`\\restriction`),G(K,Z,`‘`,"`"),G(K,Z,`$`,`\\$`),G(q,Z,`$`,`\\$`),G(q,Z,`$`,`\\textdollar`),G(K,Z,`¢`,`\\cent`),G(q,Z,`¢`,`\\cent`),G(K,Z,`%`,`\\%`),G(q,Z,`%`,`\\%`),G(K,Z,`_`,`\\_`),G(q,Z,`_`,`\\_`),G(q,Z,`_`,`\\textunderscore`),G(q,Z,`␣`,`\\textvisiblespace`,!0),G(K,Z,`∠`,`\\angle`,!0),G(K,Z,`∞`,`\\infty`,!0),G(K,Z,`′`,`\\prime`),G(K,Z,`″`,`\\dprime`),G(K,Z,`‴`,`\\trprime`),G(K,Z,`⁗`,`\\qprime`),G(K,Z,`△`,`\\triangle`),G(q,Z,`Α`,`\\Alpha`,!0),G(q,Z,`Β`,`\\Beta`,!0),G(q,Z,`Γ`,`\\Gamma`,!0),G(q,Z,`Δ`,`\\Delta`,!0),G(q,Z,`Ε`,`\\Epsilon`,!0),G(q,Z,`Ζ`,`\\Zeta`,!0),G(q,Z,`Η`,`\\Eta`,!0),G(q,Z,`Θ`,`\\Theta`,!0),G(q,Z,`Ι`,`\\Iota`,!0),G(q,Z,`Κ`,`\\Kappa`,!0),G(q,Z,`Λ`,`\\Lambda`,!0),G(q,Z,`Μ`,`\\Mu`,!0),G(q,Z,`Ν`,`\\Nu`,!0),G(q,Z,`Ξ`,`\\Xi`,!0),G(q,Z,`Ο`,`\\Omicron`,!0),G(q,Z,`Π`,`\\Pi`,!0),G(q,Z,`Ρ`,`\\Rho`,!0),G(q,Z,`Σ`,`\\Sigma`,!0),G(q,Z,`Τ`,`\\Tau`,!0),G(q,Z,`Υ`,`\\Upsilon`,!0),G(q,Z,`Φ`,`\\Phi`,!0),G(q,Z,`Χ`,`\\Chi`,!0),G(q,Z,`Ψ`,`\\Psi`,!0),G(q,Z,`Ω`,`\\Omega`,!0),G(K,Y,`Α`,`\\Alpha`,!0),G(K,Y,`Β`,`\\Beta`,!0),G(K,Y,`Γ`,`\\Gamma`,!0),G(K,Y,`Δ`,`\\Delta`,!0),G(K,Y,`Ε`,`\\Epsilon`,!0),G(K,Y,`Ζ`,`\\Zeta`,!0),G(K,Y,`Η`,`\\Eta`,!0),G(K,Y,`Θ`,`\\Theta`,!0),G(K,Y,`Ι`,`\\Iota`,!0),G(K,Y,`Κ`,`\\Kappa`,!0),G(K,Y,`Λ`,`\\Lambda`,!0),G(K,Y,`Μ`,`\\Mu`,!0),G(K,Y,`Ν`,`\\Nu`,!0),G(K,Y,`Ξ`,`\\Xi`,!0),G(K,Y,`Ο`,`\\Omicron`,!0),G(K,Y,`Π`,`\\Pi`,!0),G(K,Y,`Ρ`,`\\Rho`,!0),G(K,Y,`Σ`,`\\Sigma`,!0),G(K,Y,`Τ`,`\\Tau`,!0),G(K,Y,`Υ`,`\\Upsilon`,!0),G(K,Y,`Φ`,`\\Phi`,!0),G(K,Y,`Χ`,`\\Chi`,!0),G(K,Y,`Ψ`,`\\Psi`,!0),G(K,Y,`Ω`,`\\Omega`,!0),G(K,kC,`¬`,`\\neg`,!0),G(K,kC,`¬`,`\\lnot`),G(K,Z,`⊤`,`\\top`),G(K,Z,`⊥`,`\\bot`),G(K,Z,`∅`,`\\emptyset`),G(K,Z,`⌀`,`\\varnothing`),G(K,Y,`α`,`\\alpha`,!0),G(K,Y,`β`,`\\beta`,!0),G(K,Y,`γ`,`\\gamma`,!0),G(K,Y,`δ`,`\\delta`,!0),G(K,Y,`ϵ`,`\\epsilon`,!0),G(K,Y,`ζ`,`\\zeta`,!0),G(K,Y,`η`,`\\eta`,!0),G(K,Y,`θ`,`\\theta`,!0),G(K,Y,`ι`,`\\iota`,!0),G(K,Y,`κ`,`\\kappa`,!0),G(K,Y,`λ`,`\\lambda`,!0),G(K,Y,`μ`,`\\mu`,!0),G(K,Y,`ν`,`\\nu`,!0),G(K,Y,`ξ`,`\\xi`,!0),G(K,Y,`ο`,`\\omicron`,!0),G(K,Y,`π`,`\\pi`,!0),G(K,Y,`ρ`,`\\rho`,!0),G(K,Y,`σ`,`\\sigma`,!0),G(K,Y,`τ`,`\\tau`,!0),G(K,Y,`υ`,`\\upsilon`,!0),G(K,Y,`ϕ`,`\\phi`,!0),G(K,Y,`χ`,`\\chi`,!0),G(K,Y,`ψ`,`\\psi`,!0),G(K,Y,`ω`,`\\omega`,!0),G(K,Y,`ε`,`\\varepsilon`,!0),G(K,Y,`ϑ`,`\\vartheta`,!0),G(K,Y,`ϖ`,`\\varpi`,!0),G(K,Y,`ϱ`,`\\varrho`,!0),G(K,Y,`ς`,`\\varsigma`,!0),G(K,Y,`φ`,`\\varphi`,!0),G(K,Y,`Ϙ`,`\\Coppa`,!0),G(K,Y,`ϙ`,`\\coppa`,!0),G(K,Y,`ϙ`,`\\varcoppa`,!0),G(K,Y,`Ϟ`,`\\Koppa`,!0),G(K,Y,`ϟ`,`\\koppa`,!0),G(K,Y,`Ϡ`,`\\Sampi`,!0),G(K,Y,`ϡ`,`\\sampi`,!0),G(K,Y,`Ϛ`,`\\Stigma`,!0),G(K,Y,`ϛ`,`\\stigma`,!0),G(K,Y,`⫫`,`\\Bot`),G(K,Z,`ð`,`\\eth`,!0),G(q,Z,`ð`,`ð`),G(K,Z,`Å`,`\\AA`),G(q,Z,`Å`,`\\AA`,!0),G(K,Z,`Æ`,`\\AE`,!0),G(q,Z,`Æ`,`\\AE`,!0),G(K,Z,`Ð`,`\\DH`,!0),G(q,Z,`Ð`,`\\DH`,!0),G(K,Z,`Þ`,`\\TH`,!0),G(q,Z,`Þ`,`\\TH`,!0),G(K,Z,`ß`,`\\ss`,!0),G(q,Z,`ß`,`\\ss`,!0),G(K,Z,`å`,`\\aa`),G(q,Z,`å`,`\\aa`,!0),G(K,Z,`æ`,`\\ae`,!0),G(q,Z,`æ`,`\\ae`,!0),G(K,Z,`ð`,`\\dh`),G(q,Z,`ð`,`\\dh`,!0),G(K,Z,`þ`,`\\th`,!0),G(q,Z,`þ`,`\\th`,!0),G(K,Z,`Đ`,`\\DJ`,!0),G(q,Z,`Đ`,`\\DJ`,!0),G(K,Z,`đ`,`\\dj`,!0),G(q,Z,`đ`,`\\dj`,!0),G(K,Z,`Ł`,`\\L`,!0),G(q,Z,`Ł`,`\\L`,!0),G(K,Z,`Ł`,`\\l`,!0),G(q,Z,`Ł`,`\\l`,!0),G(K,Z,`Ŋ`,`\\NG`,!0),G(q,Z,`Ŋ`,`\\NG`,!0),G(K,Z,`ŋ`,`\\ng`,!0),G(q,Z,`ŋ`,`\\ng`,!0),G(K,Z,`Œ`,`\\OE`,!0),G(q,Z,`Œ`,`\\OE`,!0),G(K,Z,`œ`,`\\oe`,!0),G(q,Z,`œ`,`\\oe`,!0),G(K,J,`∗`,`∗`,!0),G(K,J,`+`,`+`),G(K,J,`∗`,`*`),G(K,J,`⁄`,`/`,!0),G(K,J,`⁄`,`⁄`),G(K,J,`−`,`-`,!0),G(K,J,`⋅`,`\\cdot`,!0),G(K,J,`∘`,`\\circ`,!0),G(K,J,`÷`,`\\div`,!0),G(K,J,`±`,`\\pm`,!0),G(K,J,`×`,`\\times`,!0),G(K,J,`∩`,`\\cap`,!0),G(K,J,`∪`,`\\cup`,!0),G(K,J,`∖`,`\\setminus`,!0),G(K,J,`∧`,`\\land`),G(K,J,`∨`,`\\lor`),G(K,J,`∧`,`\\wedge`,!0),G(K,J,`∨`,`\\vee`,!0),G(K,kC,`⟦`,`\\llbracket`,!0),G(K,EC,`⟧`,`\\rrbracket`,!0),G(K,kC,`⟨`,`\\langle`,!0),G(K,kC,`⟪`,`\\lAngle`,!0),G(K,kC,`⦉`,`\\llangle`,!0),G(K,kC,`|`,`\\lvert`),G(K,kC,`‖`,`\\lVert`,!0),G(K,Z,`!`,`\\oc`),G(K,Z,`?`,`\\wn`),G(K,Z,`↓`,`\\shpos`),G(K,Z,`↕`,`\\shift`),G(K,Z,`↑`,`\\shneg`),G(K,EC,`?`,`?`),G(K,EC,`!`,`!`),G(K,EC,`‼`,`‼`),G(K,EC,`⟩`,`\\rangle`,!0),G(K,EC,`⟫`,`\\rAngle`,!0),G(K,EC,`⦊`,`\\rrangle`,!0),G(K,EC,`|`,`\\rvert`),G(K,EC,`‖`,`\\rVert`),G(K,kC,`⦃`,`\\lBrace`,!0),G(K,EC,`⦄`,`\\rBrace`,!0),G(K,X,`=`,`\\equal`,!0),G(K,X,`:`,`:`),G(K,X,`≈`,`\\approx`,!0),G(K,X,`≅`,`\\cong`,!0),G(K,X,`≥`,`\\ge`),G(K,X,`≥`,`\\geq`,!0),G(K,X,`←`,`\\gets`),G(K,X,`>`,`\\gt`,!0),G(K,X,`∈`,`\\in`,!0),G(K,X,`∉`,`\\notin`,!0),G(K,X,``,`\\@not`),G(K,X,`⊂`,`\\subset`,!0),G(K,X,`⊃`,`\\supset`,!0),G(K,X,`⊆`,`\\subseteq`,!0),G(K,X,`⊇`,`\\supseteq`,!0),G(K,X,`⊈`,`\\nsubseteq`,!0),G(K,X,`⊈`,`\\nsubseteqq`),G(K,X,`⊉`,`\\nsupseteq`,!0),G(K,X,`⊉`,`\\nsupseteqq`),G(K,X,`⊨`,`\\models`),G(K,X,`←`,`\\leftarrow`,!0),G(K,X,`≤`,`\\le`),G(K,X,`≤`,`\\leq`,!0),G(K,X,`<`,`\\lt`,!0),G(K,X,`→`,`\\rightarrow`,!0),G(K,X,`→`,`\\to`),G(K,X,`≱`,`\\ngeq`,!0),G(K,X,`≱`,`\\ngeqq`),G(K,X,`≱`,`\\ngeqslant`),G(K,X,`≰`,`\\nleq`,!0),G(K,X,`≰`,`\\nleqq`),G(K,X,`≰`,`\\nleqslant`),G(K,X,`⫫`,`\\Perp`,!0),G(K,jC,`\xA0`,`\\ `),G(K,jC,`\xA0`,`\\space`),G(K,jC,`\xA0`,`\\nobreakspace`),G(q,jC,`\xA0`,`\\ `),G(q,jC,`\xA0`,` `),G(q,jC,`\xA0`,`\\space`),G(q,jC,`\xA0`,`\\nobreakspace`),G(K,jC,null,`\\nobreak`),G(K,jC,null,`\\allowbreak`),G(K,AC,`,`,`,`),G(q,AC,`:`,`:`),G(K,AC,`;`,`;`),G(K,J,`⊼`,`\\barwedge`),G(K,J,`⊻`,`\\veebar`),G(K,J,`⊙`,`\\odot`,!0),G(K,J,`⊕︎`,`\\oplus`),G(K,J,`⊗`,`\\otimes`,!0),G(K,Z,`∂`,`\\partial`,!0),G(K,J,`⊘`,`\\oslash`,!0),G(K,J,`⊚`,`\\circledcirc`,!0),G(K,J,`⊡`,`\\boxdot`,!0),G(K,J,`△`,`\\bigtriangleup`),G(K,J,`▽`,`\\bigtriangledown`),G(K,J,`†`,`\\dagger`),G(K,J,`⋄`,`\\diamond`),G(K,J,`◃`,`\\triangleleft`),G(K,J,`▹`,`\\triangleright`),G(K,kC,`{`,`\\{`),G(q,Z,`{`,`\\{`),G(q,Z,`{`,`\\textbraceleft`),G(K,EC,`}`,`\\}`),G(q,Z,`}`,`\\}`),G(q,Z,`}`,`\\textbraceright`),G(K,kC,`{`,`\\lbrace`),G(K,EC,`}`,`\\rbrace`),G(K,kC,`[`,`\\lbrack`,!0),G(q,Z,`[`,`\\lbrack`,!0),G(K,EC,`]`,`\\rbrack`,!0),G(q,Z,`]`,`\\rbrack`,!0),G(K,kC,`(`,`\\lparen`,!0),G(K,EC,`)`,`\\rparen`,!0),G(K,kC,`⦇`,`\\llparenthesis`,!0),G(K,EC,`⦈`,`\\rrparenthesis`,!0),G(q,Z,`<`,`\\textless`,!0),G(q,Z,`>`,`\\textgreater`,!0),G(K,kC,`⌊`,`\\lfloor`,!0),G(K,EC,`⌋`,`\\rfloor`,!0),G(K,kC,`⌈`,`\\lceil`,!0),G(K,EC,`⌉`,`\\rceil`,!0),G(K,Z,`\\`,`\\backslash`),G(K,Z,`|`,`|`),G(K,Z,`|`,`\\vert`),G(q,Z,`|`,`\\textbar`,!0),G(K,Z,`‖`,`\\|`),G(K,Z,`‖`,`\\Vert`),G(q,Z,`‖`,`\\textbardbl`),G(q,Z,`~`,`\\textasciitilde`),G(q,Z,`\\`,`\\textbackslash`),G(q,Z,`^`,`\\textasciicircum`),G(K,X,`↑`,`\\uparrow`,!0),G(K,X,`⇑`,`\\Uparrow`,!0),G(K,X,`↓`,`\\downarrow`,!0),G(K,X,`⇓`,`\\Downarrow`,!0),G(K,X,`↕`,`\\updownarrow`,!0),G(K,X,`⇕`,`\\Updownarrow`,!0),G(K,OC,`∐`,`\\coprod`),G(K,OC,`⋁`,`\\bigvee`),G(K,OC,`⋀`,`\\bigwedge`),G(K,OC,`⨄`,`\\biguplus`),G(K,OC,`⨄`,`\\bigcupplus`),G(K,OC,`⨃`,`\\bigcupdot`),G(K,OC,`⨇`,`\\bigdoublevee`),G(K,OC,`⨈`,`\\bigdoublewedge`),G(K,OC,`⋂`,`\\bigcap`),G(K,OC,`⋃`,`\\bigcup`),G(K,OC,`∫`,`\\int`),G(K,OC,`∫`,`\\intop`),G(K,OC,`∬`,`\\iint`),G(K,OC,`∭`,`\\iiint`),G(K,OC,`∏`,`\\prod`),G(K,OC,`∑`,`\\sum`),G(K,OC,`⨂`,`\\bigotimes`),G(K,OC,`⨁`,`\\bigoplus`),G(K,OC,`⨀`,`\\bigodot`),G(K,OC,`⨉`,`\\bigtimes`),G(K,OC,`∮`,`\\oint`),G(K,OC,`∯`,`\\oiint`),G(K,OC,`∰`,`\\oiiint`),G(K,OC,`∱`,`\\intclockwise`),G(K,OC,`∲`,`\\varointclockwise`),G(K,OC,`⨌`,`\\iiiint`),G(K,OC,`⨍`,`\\intbar`),G(K,OC,`⨎`,`\\intBar`),G(K,OC,`⨏`,`\\fint`),G(K,OC,`⨒`,`\\rppolint`),G(K,OC,`⨓`,`\\scpolint`),G(K,OC,`⨕`,`\\pointint`),G(K,OC,`⨖`,`\\sqint`),G(K,OC,`⨗`,`\\intlarhk`),G(K,OC,`⨘`,`\\intx`),G(K,OC,`⨙`,`\\intcap`),G(K,OC,`⨚`,`\\intcup`),G(K,OC,`⨅`,`\\bigsqcap`),G(K,OC,`⨆`,`\\bigsqcup`),G(K,OC,`∫`,`\\smallint`),G(q,DC,`…`,`\\textellipsis`),G(K,DC,`…`,`\\mathellipsis`),G(q,DC,`…`,`\\ldots`,!0),G(K,DC,`…`,`\\dotso`),G(K,DC,`…`,`\\dotsc`),G(K,DC,`…`,`\\ldots`,!0),G(K,DC,`⋰`,`\\iddots`,!0),G(K,DC,`⋯`,`\\cdots`,!0),G(K,DC,`⋱`,`\\ddots`,!0),G(K,Z,`⋮`,`\\varvdots`),G(q,Z,`⋮`,`\\varvdots`),G(K,TC,`´`,`\\acute`),G(K,TC,"`",`\\grave`),G(K,TC,`¨`,`\\ddot`),G(K,TC,`…`,`\\dddot`),G(K,TC,`….`,`\\ddddot`),G(K,TC,`~`,`\\tilde`),G(K,TC,`‾`,`\\bar`),G(K,TC,`˘`,`\\breve`),G(K,TC,`ˇ`,`\\check`),G(K,TC,`ˆ`,`\\hat`),G(K,TC,`→`,`\\vec`),G(K,TC,`˙`,`\\dot`),G(K,TC,`˚`,`\\mathring`),G(K,Y,`ı`,`\\imath`,!0),G(K,Y,`ȷ`,`\\jmath`,!0),G(K,Z,`ı`,`ı`),G(K,Z,`ȷ`,`ȷ`),G(q,Z,`ı`,`\\i`,!0),G(q,Z,`ȷ`,`\\j`,!0),G(q,Z,`ø`,`\\o`,!0),G(K,Y,`ø`,`\\o`,!0),G(q,Z,`Ø`,`\\O`,!0),G(K,Y,`Ø`,`\\O`,!0),G(q,TC,`ˊ`,`\\'`),G(q,TC,`ˋ`,"\\`"),G(q,TC,`ˆ`,`\\^`),G(q,TC,`~`,`\\~`),G(q,TC,`ˉ`,`\\=`),G(q,TC,`˘`,`\\u`),G(q,TC,`˙`,`\\.`),G(q,TC,`¸`,`\\c`),G(q,TC,`˚`,`\\r`),G(q,TC,`ˇ`,`\\v`),G(q,TC,`¨`,`\\"`),G(q,TC,`˝`,`\\H`),G(K,TC,`ˊ`,`\\'`),G(K,TC,`ˋ`,"\\`"),G(K,TC,`ˆ`,`\\^`),G(K,TC,`~`,`\\~`),G(K,TC,`ˉ`,`\\=`),G(K,TC,`˘`,`\\u`),G(K,TC,`˙`,`\\.`),G(K,TC,`¸`,`\\c`),G(K,TC,`˚`,`\\r`),G(K,TC,`ˇ`,`\\v`),G(K,TC,`¨`,`\\"`),G(K,TC,`˝`,`\\H`);var MC={"--":!0,"---":!0,"``":!0,"''":!0};G(q,Z,`–`,`--`,!0),G(q,Z,`–`,`\\textendash`),G(q,Z,`—`,`---`,!0),G(q,Z,`—`,`\\textemdash`),G(q,Z,`‘`,"`",!0),G(q,Z,`‘`,`\\textquoteleft`),G(q,Z,`’`,`'`,!0),G(q,Z,`’`,`\\textquoteright`),G(q,Z,`“`,"``",!0),G(q,Z,`“`,`\\textquotedblleft`),G(q,Z,`”`,`''`,!0),G(q,Z,`”`,`\\textquotedblright`),G(K,Z,`°`,`\\degree`,!0),G(q,Z,`°`,`\\degree`),G(q,Z,`°`,`\\textdegree`,!0),G(K,Z,`£`,`\\pounds`),G(K,Z,`£`,`\\mathsterling`,!0),G(q,Z,`£`,`\\pounds`),G(q,Z,`£`,`\\textsterling`,!0),G(K,Z,`✠`,`\\maltese`),G(q,Z,`✠`,`\\maltese`),G(K,Z,`€`,`\\euro`,!0),G(q,Z,`€`,`\\euro`,!0),G(q,Z,`€`,`\\texteuro`),G(K,Z,`©`,`\\copyright`,!0),G(q,Z,`©`,`\\textcopyright`),G(K,Z,`⌀`,`\\diameter`,!0),G(q,Z,`⌀`,`\\diameter`),G(K,Z,`𝛤`,`\\varGamma`),G(K,Z,`𝛥`,`\\varDelta`),G(K,Z,`𝛩`,`\\varTheta`),G(K,Z,`𝛬`,`\\varLambda`),G(K,Z,`𝛯`,`\\varXi`),G(K,Z,`𝛱`,`\\varPi`),G(K,Z,`𝛴`,`\\varSigma`),G(K,Z,`𝛶`,`\\varUpsilon`),G(K,Z,`𝛷`,`\\varPhi`),G(K,Z,`𝛹`,`\\varPsi`),G(K,Z,`𝛺`,`\\varOmega`),G(q,Z,`𝛤`,`\\varGamma`),G(q,Z,`𝛥`,`\\varDelta`),G(q,Z,`𝛩`,`\\varTheta`),G(q,Z,`𝛬`,`\\varLambda`),G(q,Z,`𝛯`,`\\varXi`),G(q,Z,`𝛱`,`\\varPi`),G(q,Z,`𝛴`,`\\varSigma`),G(q,Z,`𝛶`,`\\varUpsilon`),G(q,Z,`𝛷`,`\\varPhi`),G(q,Z,`𝛹`,`\\varPsi`),G(q,Z,`𝛺`,`\\varOmega`);var NC=`0123456789/@."`;for(let e=0;e<14;e++){let t=NC.charAt(e);G(K,Z,t,t)}var PC=`0123456789!@*()-=+";:?/.,`;for(let e=0;e<25;e++){let t=PC.charAt(e);G(q,Z,t,t)}var FC=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`;for(let e=0;e<52;e++){let t=FC.charAt(e);G(K,Y,t,t),G(q,Z,t,t)}var IC=`ÇÐÞçþℂℍℕℙℚℝℤℎℏℊℋℌℐℑℒℓ℘ℛℜℬℰℱℳℭℨ`;for(let e=0;e<30;e++){let t=IC.charAt(e);G(K,Y,t,t),G(q,Z,t,t)}var LC=``;for(let e=0;e<52;e++){LC=String.fromCharCode(55349,56320+e),G(K,Y,LC,LC),G(q,Z,LC,LC),LC=String.fromCharCode(55349,56372+e),G(K,Y,LC,LC),G(q,Z,LC,LC),LC=String.fromCharCode(55349,56424+e),G(K,Y,LC,LC),G(q,Z,LC,LC),LC=String.fromCharCode(55349,56580+e),G(K,Y,LC,LC),G(q,Z,LC,LC),LC=String.fromCharCode(55349,56736+e),G(K,Y,LC,LC),G(q,Z,LC,LC),LC=String.fromCharCode(55349,56788+e),G(K,Y,LC,LC),G(q,Z,LC,LC),LC=String.fromCharCode(55349,56840+e),G(K,Y,LC,LC),G(q,Z,LC,LC),LC=String.fromCharCode(55349,56944+e),G(K,Y,LC,LC),G(q,Z,LC,LC),LC=String.fromCharCode(55349,56632+e),G(K,Y,LC,LC),G(q,Z,LC,LC);let t=FC.charAt(e);LC=String.fromCharCode(55349,56476+e),G(K,Y,t,LC),G(q,Z,t,LC)}for(let e=0;e<10;e++)LC=String.fromCharCode(55349,57294+e),G(K,Y,LC,LC),G(q,Z,LC,LC),LC=String.fromCharCode(55349,57314+e),G(K,Y,LC,LC),G(q,Z,LC,LC),LC=String.fromCharCode(55349,57324+e),G(K,Y,LC,LC),G(q,Z,LC,LC),LC=String.fromCharCode(55349,57334+e),G(K,Y,LC,LC),G(q,Z,LC,LC);function RC(e,t,n){let r=[],i=[],a=[],o=0,s=0;for(;s<e.length;){for(;e[s]instanceof aC;)e.splice(s,1,...e[s].children);let n=e[s];if(n.attributes&&n.attributes.linebreak&&n.attributes.linebreak===`newline`){a.length>0&&i.push(new W(`mrow`,a)),i.push(n),a=[];let e=new W(`mtd`,i);e.style.textAlign=`left`,r.push(new W(`mtr`,[e])),i=[],s+=1}else{if(a.push(n),n.type&&n.type===`mo`&&n.children.length===1&&!(n.attributes.form&&n.attributes.form===`prefix`)&&!Object.prototype.hasOwnProperty.call(n.attributes,`movablelimits`)){let r=n.children[0].text;if(t===`=`&&r===`=`){if(o+=1,o>1){a.pop();let e=new W(`mrow`,a);i.push(e),a=[n]}}else if(t===`tex`){let t=s<e.length-1?e[s+1]:null,n=!0;if(!(t&&t.type===`mtext`&&t.attributes.linebreak&&t.attributes.linebreak===`nobreak`))for(let t=s+1;t<e.length;t++){let r=e[t];if(r.type&&r.type===`mspace`&&!(r.attributes.linebreak&&r.attributes.linebreak===`newline`))a.push(r),s+=1,r.attributes&&r.attributes.linebreak&&r.attributes.linebreak===`nobreak`&&(n=!1);else break}if(n){let e=new W(`mrow`,a);i.push(e),a=[]}}}s+=1}}if(a.length>0){let e=new W(`mrow`,a);i.push(e)}if(r.length>0){let e=new W(`mtd`,i);e.style.textAlign=`left`;let t=new W(`mtr`,[e]);r.push(t);let a=new W(`mtable`,r);return n||(a.setAttribute(`columnalign`,`left`),a.setAttribute(`rowspacing`,`0em`)),a}return mC(i)}var zC=function(e,t,n){return wC[t][e]&&wC[t][e].replace&&e.charCodeAt(0)!==55349&&!(Object.prototype.hasOwnProperty.call(MC,e)&&n&&(n.fontFamily&&n.fontFamily.slice(4,6)===`tt`||n.font&&n.font.slice(4,6)===`tt`))&&(e=wC[t][e].replace),new hC(e)},BC=(e,t)=>{if(e.children.length===0||e.children[e.children.length-1].type!==`mtext`){let n=new W(`mtext`,[new hC(t.children[0].text)]);e.children.push(n)}else e.children[e.children.length-1].children[0].text+=t.children[0].text},VC=e=>{if(e.type!==`mrow`&&e.type!==`mstyle`||e.children.length===0)return e;let t=new W(`mrow`);for(let n=0;n<e.children.length;n++){let r=e.children[n];if(r.type===`mtext`&&Object.keys(r.attributes).length===0)BC(t,r);else if(r.type===`mrow`){let e=!0;for(let t=0;t<r.children.length;t++)if(r.children[t].type!==`mtext`||Object.keys(r.attributes).length!==0){e=!1;break}if(e)for(let e=0;e<r.children.length;e++){let n=r.children[e];BC(t,n)}else t.children.push(r)}else t.children.push(r)}for(let n=0;n<t.children.length;n++)if(t.children[n].type===`mtext`){let r=t.children[n];r.children[0].text.charAt(0)===` `&&(r.children[0].text=`\xA0`+r.children[0].text.slice(1));let i=r.children[0].text.length;i>0&&r.children[0].text.charAt(i-1)===` `&&(r.children[0].text=r.children[0].text.slice(0,-1)+`\xA0`);for(let[t,n]of Object.entries(e.attributes))r.attributes[t]=n}return t.children.length===1&&t.children[0].type===`mtext`?t.children[0]:t},HC=function(e,t=!1){if(e.length===1&&!(e[0]instanceof aC))return e[0];if(!t){e[0]instanceof W&&e[0].type===`mo`&&!e[0].attributes.fence&&(e[0].attributes.lspace=`0em`,e[0].attributes.rspace=`0em`);let t=e.length-1;e[t]instanceof W&&e[t].type===`mo`&&!e[t].attributes.fence&&(e[t].attributes.lspace=`0em`,e[t].attributes.rspace=`0em`)}return new W(`mrow`,e)};function UC(e){if(!e)return!1;if(e.type===`mi`&&e.children.length===1){let t=e.children[0];return t instanceof hC&&t.text===`.`}if(e.type===`mtext`&&e.children.length===1){let t=e.children[0];return t instanceof hC&&t.text===` `}if(e.type===`mo`&&e.children.length===1&&e.getAttribute(`separator`)===`true`&&e.getAttribute(`lspace`)===`0em`&&e.getAttribute(`rspace`)===`0em`){let t=e.children[0];return t instanceof hC&&t.text===`,`}return!1}var WC=(e,t)=>{let n=e[t],r=e[t+1];return n.type===`atom`&&n.text===`,`&&n.loc&&r.loc&&n.loc.end===r.loc.start},GC=e=>e.type===`atom`&&e.family===`rel`||e.type===`mclass`&&e.mclass===`mrel`,KC=function(e,t,n=!1){if(!n&&e.length===1){let n=JC(e[0],t);return n instanceof W&&n.type===`mo`&&(n.setAttribute(`lspace`,`0em`),n.setAttribute(`rspace`,`0em`)),[n]}let r=[],i=[],a;for(let n=0;n<e.length;n++)i.push(JC(e[n],t));for(let t=0;t<i.length;t++){let n=i[t];if(t<e.length-1&&GC(e[t])&&GC(e[t+1])&&n.setAttribute(`rspace`,`0em`),t>0&&GC(e[t])&&GC(e[t-1])&&n.setAttribute(`lspace`,`0em`),n.type===`mn`&&a&&a.type===`mn`)a.children.push(...n.children);else if(UC(n)&&a&&a.type===`mn`)a.children.push(...n.children);else if(a&&a.type===`mn`&&t<i.length-1&&i[t+1].type===`mn`&&WC(e,t))a.children.push(...n.children);else{if(n.type===`mn`&&UC(a))n.children=[...a.children,...n.children],r.pop();else if((n.type===`msup`||n.type===`msub`)&&n.children.length>=1&&a&&(a.type===`mn`||UC(a))){let e=n.children[0];e instanceof W&&e.type===`mn`&&a&&(e.children=[...a.children,...e.children],r.pop())}r.push(n),a=n}}return r},qC=function(e,t,n=!1){return HC(KC(e,t,n),n)},JC=function(e,t){if(!e)return new W(`mrow`);if(eC[e.type])return eC[e.type](e,t);throw new U(`Got group of unknown type: '`+e.type+`'`)},YC=e=>new W(`mtd`,[],[],{padding:`0`,width:`50%`}),XC=[`mrow`,`mtd`,`mtable`,`mtr`],ZC=e=>{for(let t of e.children)if(t.type&&XC.includes(t.type)){if(t.classes&&t.classes[0]===`tml-label`)return t.label;{let e=ZC(t);if(e)return e}}else if(!t.type){let e=ZC(t);if(e)return e}},QC=(e,t,n,r)=>{t=qC(t[0].body,n),t=VC(t),t.classes.push(`tml-tag`);let i=ZC(e);e=new W(`mtd`,[e]);let a=[YC(),e,YC()];a[r?0:2].children.push(t);let o=new W(`mtr`,a,[`tml-tageqn`]);i&&o.setAttribute(`id`,i);let s=new W(`mtable`,[o]);return s.style.width=`100%`,s.setAttribute(`displaystyle`,`true`),s};function $C(e,t,n,r){let i=null;e.length===1&&e[0].type===`tag`&&(i=e[0].tag,e=e[0].body);let a=KC(e,n);if(a.length===1&&a[0]instanceof fC)return a[0];let o=r.displayMode||r.annotate?`none`:r.wrap,s=a.length===0?null:a[0],c=a.length===1&&i===null&&s instanceof W?a[0]:RC(a,o,r.displayMode);if(i&&(c=QC(c,i,n,r.leqno)),r.annotate){let e=new W(`annotation`,[new hC(t)]);e.setAttribute(`encoding`,`application/x-tex`),c=new W(`semantics`,[c,e])}let l=new W(`math`,[c]);return r.xml&&l.setAttribute(`xmlns`,`http://www.w3.org/1998/Math/MathML`),r.displayMode&&(l.setAttribute(`display`,`block`),l.style.display=`block math`,l.classes=[`tml-display`]),l}var ew=`DHKLUcegorsuvxyzΠΥΨαδηιμνοτυχϵ`,tw=`BCEGIMNOPQRSTXZlpqtwΓΘΞΣΦΩβεζθξρςφψϑϕϱ`,nw=`AFJdfΔΛ`,rw=(e,t)=>{let n=e.isStretchy?xC(e):new W(`mo`,[zC(e.label,e.mode)]);e.isStretchy||n.setAttribute(`stretchy`,`false`),e.label!==`\\vec`&&(n.style.mathDepth=`0`);let r=e.label===`\\c`?`munder`:`mover`,i=aw.has(e.label);if(r===`mover`&&e.mode===`math`&&!e.isStretchy&&e.base.text&&e.base.text.length===1){let t=e.base.text,r=e.label===`\\vec`,a=r===`\\vec`?`-vec`:``;r&&n.classes.push(`tml-vec`);let o=r?`-vec`:i?`-acc`:``;ew.indexOf(t)>-1?(n.classes.push(`chr-sml${a}`),n.classes.push(`wbk-sml${o}`)):tw.indexOf(t)>-1?(n.classes.push(`chr-med${a}`),n.classes.push(`wbk-med${o}`)):nw.indexOf(t)>-1?(n.classes.push(`chr-lrg${a}`),n.classes.push(`wbk-lrg${o}`)):r?n.classes.push(`wbk-vec`):i&&n.classes.push(`wbk-acc`)}else i&&n.classes.push(`wbk-acc`);return new W(r,[JC(e.base,t),n])},iw=new Set([`\\acute`,`\\check`,`\\grave`,`\\ddot`,`\\dddot`,`\\ddddot`,`\\tilde`,`\\bar`,`\\breve`,`\\check`,`\\hat`,`\\vec`,`\\dot`,`\\mathring`]),aw=new Set([`\\acute`,`\\bar`,`\\breve`,`\\check`,`\\dot`,`\\ddot`,`\\grave`,`\\hat`,`\\mathring`,"\\`",`\\'`,`\\^`,`\\=`,`\\u`,`\\.`,`\\"`,`\\r`,`\\H`,`\\v`]),ow={"\\`":`̀`,"\\'":`́`,"\\^":`̂`,"\\~":`̃`,"\\=":`̄`,"\\u":`̆`,"\\.":`̇`,'\\"':`̈`,"\\r":`̊`,"\\H":`̋`,"\\v":`̌`,"\\c":`̧`};tC({type:`accent`,names:[`\\acute`,`\\grave`,`\\ddot`,`\\dddot`,`\\ddddot`,`\\tilde`,`\\bar`,`\\breve`,`\\check`,`\\hat`,`\\vec`,`\\dot`,`\\mathring`,`\\overparen`,`\\widecheck`,`\\widehat`,`\\wideparen`,`\\widetilde`,`\\overrightarrow`,`\\overleftarrow`,`\\Overrightarrow`,`\\overleftrightarrow`,`\\overgroup`,`\\overleftharpoon`,`\\overrightharpoon`],props:{numArgs:1},handler:(e,t)=>{let n=rC(t[0]),r=!iw.has(e.funcName);return{type:`accent`,mode:e.parser.mode,label:e.funcName,isStretchy:r,base:n}},mathmlBuilder:rw}),tC({type:`accent`,names:[`\\'`,"\\`",`\\^`,`\\~`,`\\=`,`\\c`,`\\u`,`\\.`,`\\"`,`\\r`,`\\H`,`\\v`],props:{numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:[`primitive`]},handler:(e,t)=>{let n=rC(t[0]),r=e.parser.mode;return r===`math`&&e.parser.settings.strict&&console.log(`Temml parse error: Command ${e.funcName} is invalid in math mode.`),r===`text`&&n.text&&n.text.length===1&&e.funcName in ow&&YS.indexOf(n.text)>-1?{type:`textord`,mode:`text`,text:n.text+ow[e.funcName]}:e.funcName===`\\c`&&r===`text`&&n.text&&n.text.length===1?{type:`textord`,mode:`text`,text:n.text+`̧`}:{type:`accent`,mode:r,label:e.funcName,isStretchy:!1,base:n}},mathmlBuilder:rw}),tC({type:`accentUnder`,names:[`\\underleftarrow`,`\\underrightarrow`,`\\underleftrightarrow`,`\\undergroup`,`\\underparen`,`\\utilde`],props:{numArgs:1},handler:({parser:e,funcName:t},n)=>{let r=n[0];return{type:`accentUnder`,mode:e.mode,label:t,base:r}},mathmlBuilder:(e,t)=>{let n=xC(e);return n.style[`math-depth`]=0,new W(`munder`,[JC(e.base,t),n])}});var sw={pt:800/803,pc:9600/803,dd:1238/1157*800/803,cc:14856/1157*800/803,nd:685/642*800/803,nc:1370/107*800/803,sp:1/65536*800/803,mm:25.4/72,cm:2.54/72,in:1/72,px:96/72},cw=[`em`,`ex`,`mu`,`pt`,`mm`,`cm`,`in`,`px`,`bp`,`pc`,`dd`,`cc`,`nd`,`nc`,`sp`],lw=function(e){return typeof e!=`string`&&(e=e.unit),cw.indexOf(e)>-1},uw=e=>[1,.7,.5][Math.max(e-1,0)],dw=function(e,t){let n=e.number;if(t.maxSize[0]<0&&n>0)return{number:0,unit:`em`};let r=e.unit;switch(r){case`mm`:case`cm`:case`in`:case`px`:return n*sw[r]>t.maxSize[1]?{number:t.maxSize[1],unit:`pt`}:{number:n,unit:r};case`em`:case`ex`:return r===`ex`&&(n*=.431),n=Math.min(n/uw(t.level),t.maxSize[0]),{number:JS(n),unit:`em`};case`bp`:return n>t.maxSize[1]&&(n=t.maxSize[1]),{number:n,unit:`pt`};case`pt`:case`pc`:case`dd`:case`cc`:case`nd`:case`nc`:case`sp`:return n=Math.min(n*sw[r],t.maxSize[1]),{number:JS(n),unit:`pt`};case`mu`:return n=Math.min(n/18,t.maxSize[0]),{number:JS(n),unit:`em`};default:throw new U(`Invalid unit: '`+r+`'`)}},fw=e=>{let t=new W(`mspace`);return t.setAttribute(`width`,e+`em`),t},pw=(e,t=.3,n=0,r=!1)=>{if(e==null&&n===0)return fw(t);let i=e?[e]:[];if(t!==0&&i.unshift(fw(t)),n>0&&i.push(fw(n)),r){let e=new W(`mpadded`,i);return e.setAttribute(`height`,`0.1px`),e}return new W(`mrow`,i)},mw=(e,t)=>Number(e)/uw(t),hw=(e,t,n,r)=>{let i=yC(e),a=e.slice(1,3)===`eq`,o=e.charAt(1)===`x`?`1.75`:e.slice(2,4)===`cd`?`3.0`:a?`1.0`:`2.0`;i.setAttribute(`lspace`,`0`),i.setAttribute(`rspace`,a?`0.5em`:`0`);let s=r.withLevel(r.level<2?2:3),c=mw(o,s.level),l=mw(o,3),u=pw(null,c.toFixed(4),0),d=pw(null,l.toFixed(4),0),f=mw(a?0:.3,s.level).toFixed(4),p,m,h=t&&t.body&&(t.body.body||t.body.length>0);if(h){let n=JC(t,s);n=pw(n,f,f,e===`\\\\cdrightarrow`||e===`\\\\cdleftarrow`),p=new W(`mover`,[n,d])}let g=n&&n.body&&(n.body.body||n.body.length>0);if(g){let e=JC(n,s);e=pw(e,f,f),m=new W(`munder`,[e,d])}let _;return _=!h&&!g?new W(`mover`,[i,u]):h&&g?new W(`munderover`,[i,m,p]):h?new W(`mover`,[i,p]):new W(`munder`,[i,m]),o===`3.0`&&(_.style.height=`1em`),_.setAttribute(`accent`,`false`),_};tC({type:`xArrow`,names:`\\xleftarrow.\\xrightarrow.\\xLeftarrow.\\xRightarrow.\\xleftrightarrow.\\xLeftrightarrow.\\xhookleftarrow.\\xhookrightarrow.\\xmapsto.\\xrightharpoondown.\\xrightharpoonup.\\xleftharpoondown.\\xleftharpoonup.\\xlongequal.\\xtwoheadrightarrow.\\xtwoheadleftarrow.\\xtofrom.\\xleftrightharpoons.\\xrightleftharpoons.\\yields.\\yieldsLeft.\\mesomerism.\\longrightharpoonup.\\longleftharpoondown.\\yieldsLeftRight.\\chemequilibrium.\\\\cdrightarrow.\\\\cdleftarrow.\\\\cdlongequal`.split(`.`),props:{numArgs:1,numOptionalArgs:1},handler({parser:e,funcName:t},n,r){return{type:`xArrow`,mode:e.mode,name:t,body:n[0],below:r[0]}},mathmlBuilder(e,t){let n=[hw(e.name,e.body,e.below,t)];return n.unshift(fw(.2778)),n.push(fw(.2778)),new W(`mrow`,n)}});var gw={"\\equilibriumRight":[`\\longrightharpoonup`,`\\eqleftharpoondown`],"\\equilibriumLeft":[`\\eqrightharpoonup`,`\\longleftharpoondown`]};tC({type:`stackedArrow`,names:[`\\equilibriumRight`,`\\equilibriumLeft`],props:{numArgs:1,numOptionalArgs:1},handler({parser:e,funcName:t},n,r){let i=n[0]?{type:`hphantom`,mode:e.mode,body:n[0]}:null,a=r[0]?{type:`hphantom`,mode:e.mode,body:r[0]}:null;return{type:`stackedArrow`,mode:e.mode,name:t,body:n[0],upperArrowBelow:a,lowerArrowBody:i,below:r[0]}},mathmlBuilder(e,t){let n=gw[e.name][0],r=gw[e.name][1],i=hw(n,e.body,e.upperArrowBelow,t),a=hw(r,e.lowerArrowBody,e.below,t),o,s=new W(`mpadded`,[i]);if(s.setAttribute(`voffset`,`0.3em`),s.setAttribute(`height`,`+0.3em`),s.setAttribute(`depth`,`-0.3em`),e.name===`\\equilibriumLeft`){let e=new W(`mpadded`,[a]);e.setAttribute(`width`,`0.5em`),o=new W(`mpadded`,[fw(.2778),e,s,fw(.2778)])}else s.setAttribute(`width`,e.name===`\\equilibriumRight`?`0.5em`:`0`),o=new W(`mpadded`,[fw(.2778),s,a,fw(.2778)]);return o.setAttribute(`voffset`,`-0.18em`),o.setAttribute(`height`,`-0.18em`),o.setAttribute(`depth`,`+0.18em`),o}});var _w={};function vw({type:e,names:t,props:n,handler:r,mathmlBuilder:i}){let a={type:e,numArgs:n.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:r};for(let e=0;e<t.length;++e)_w[t[e]]=a;i&&(eC[e]=i)}function yw(e,t){if(!e||e.type!==t)throw Error(`Expected node of type ${t}, but got `+(e?`node of type ${e.type}`:String(e)));return e}function bw(e){let t=xw(e);if(!t)throw Error(`Expected node of symbol group type, but got `+(e?`node of type ${e.type}`:String(e)));return t}function xw(e){return e&&(e.type===`atom`||e.type===`delimiter`||Object.prototype.hasOwnProperty.call(CC,e.type))?e:null}var Sw={">":`\\\\cdrightarrow`,"<":`\\\\cdleftarrow`,"=":`\\\\cdlongequal`,A:`\\uparrow`,V:`\\downarrow`,"|":`\\Vert`,".":`no arrow`},Cw=()=>({type:`styling`,body:[],mode:`math`,scriptLevel:`display`}),ww=e=>e.type===`textord`&&e.text===`@`,Tw=(e,t)=>(e.type===`mathord`||e.type===`atom`)&&e.text===t;function Ew(e,t,n){let r=Sw[e];switch(r){case`\\\\cdrightarrow`:case`\\\\cdleftarrow`:return n.callFunction(r,[t[0]],[t[1]]);case`\\uparrow`:case`\\downarrow`:{let e=n.callFunction(`\\\\cdleft`,[t[0]],[]),i={type:`atom`,text:r,mode:`math`,family:`rel`},a={type:`ordgroup`,mode:`math`,body:[e,n.callFunction(`\\Big`,[i],[]),n.callFunction(`\\\\cdright`,[t[1]],[])],semisimple:!0};return n.callFunction(`\\\\cdparent`,[a],[])}case`\\\\cdlongequal`:return n.callFunction(`\\\\cdlongequal`,[],[]);case`\\Vert`:return n.callFunction(`\\Big`,[{type:`textord`,text:`\\Vert`,mode:`math`}],[]);default:return{type:`textord`,text:` `,mode:`math`}}}function Dw(e){let t=[];for(e.gullet.beginGroup(),e.gullet.macros.set(`\\cr`,`\\\\\\relax`),e.gullet.beginGroup();;){t.push(e.parseExpression(!1,`\\\\`)),e.gullet.endGroup(),e.gullet.beginGroup();let n=e.fetch().text;if(n===`&`||n===`\\\\`)e.consume();else if(n===`\\end`){t[t.length-1].length===0&&t.pop();break}else throw new U(`Expected \\\\ or \\cr or \\end`,e.nextToken)}let n=[],r=[n];for(let i=0;i<t.length;i++){let a=t[i],o=Cw();for(let t=0;t<a.length;t++)if(!ww(a[t]))o.body.push(a[t]);else{n.push(o),t+=1;let r=bw(a[t]).text,i=[,,];if(i[0]={type:`ordgroup`,mode:`math`,body:[]},i[1]={type:`ordgroup`,mode:`math`,body:[]},!(`=|.`.indexOf(r)>-1)){if(`<>AV`.indexOf(r)>-1)for(let e=0;e<2;e++){let n=!0;for(let o=t+1;o<a.length;o++){if(Tw(a[o],r)){n=!1,t=o;break}if(ww(a[o]))throw new U(`Missing a `+r+` character to complete a CD arrow.`,a[o]);i[e].body.push(a[o])}if(n)throw new U(`Missing a `+r+` character to complete a CD arrow.`,a[t])}else throw new U(`Expected one of "<>AV=|." after @.`)}let s=Ew(r,i,e);n.push(s),o=Cw()}i%2==0?n.push(o):n.shift(),n=[],r.push(n)}return r.pop(),e.gullet.endGroup(),e.gullet.endGroup(),{type:`array`,mode:`math`,body:r,tags:null,labels:Array(r.length+1).fill(``),envClasses:[`jot`,`cd`],cols:[],hLinesBeforeRow:Array(r.length+1).fill([])}}tC({type:`cdlabel`,names:[`\\\\cdleft`,`\\\\cdright`],props:{numArgs:1},handler({parser:e,funcName:t},n){return{type:`cdlabel`,mode:e.mode,side:t.slice(4),label:n[0]}},mathmlBuilder(e,t){if(e.label.body.length===0)return new W(`mrow`,t);let n=JC(e.label,t);e.side===`left`&&n.classes.push(`tml-shift-left`);let r=new W(`mtd`,[n]);r.style.padding=`0`;let i=new W(`mpadded`,[new W(`mtable`,[new W(`mtr`,[r])])]);return i.setAttribute(`width`,`0.1px`),i.setAttribute(`displaystyle`,`false`),i.setAttribute(`scriptlevel`,`1`),i}}),tC({type:`cdlabelparent`,names:[`\\\\cdparent`],props:{numArgs:1},handler({parser:e},t){return{type:`cdlabelparent`,mode:e.mode,fragment:t[0]}},mathmlBuilder(e,t){return new W(`mrow`,[JC(e.fragment,t)])}});var Ow=e=>({type:`ordgroup`,mode:`math`,body:e,semisimple:!0}),kw=(e,t)=>({type:t,mode:`math`,body:Ow(e)}),Aw=(e,t)=>{let n=e.body;n[0].shift();let r=Array(n.length-1).fill().map(()=>[]);for(let e=1;e<n.length;e++){r[e-1].push(n[e].shift());let t=[];for(let r=0;r<n[e].length;r++)t.push(n[e][r]);r[e-1].push(kw(t,`vphantom`))}let i=Array(n.length).fill().map(()=>[]);for(let e=0;e<n[0].length;e++)i[0].push(n[0][e]);for(let e=1;e<n.length;e++)for(let t=0;t<n[0].length;t++)i[e].push(kw(n[e][t].body,`hphantom`));for(let e=0;e<n[0].length;e++)n[0][e]=kw(n[0][e].body,`hphantom`);let a={type:`array`,mode:`math`,body:r,cols:[{type:`align`,align:`c`}],rowGaps:Array(r.length-1).fill(null),hLinesBeforeRow:Array(r.length+1).fill().map(()=>[]),envClasses:[],scriptLevel:`text`,arraystretch:1,labels:Array(r.length).fill(``),arraycolsep:{number:.04,unit:`em`}},o={type:`styling`,mode:`math`,scriptLevel:`text`,body:[{type:`array`,mode:`math`,body:i,cols:Array(i.length).fill({type:`align`,align:`c`}),rowGaps:Array(i.length-1).fill(null),hLinesBeforeRow:Array(i.length+1).fill().map(()=>[]),envClasses:[],scriptLevel:`text`,arraystretch:1,labels:Array(i.length).fill(``),arraycolsep:null}]};return Ow([a,{type:`supsub`,mode:`math`,stack:!0,base:{type:`op`,mode:`math`,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!0,symbol:!1,suppressBaseShift:!0,body:[{type:`leftright`,mode:`math`,body:[e],left:t?t[0]:`(`,right:t?t[1]:`)`,rightColor:void 0}]},sup:o,sub:null}])},jw=class e{constructor(e,t,n){this.lexer=e,this.start=t,this.end=n}static range(t,n){return n?!t||!t.loc||!n.loc||t.loc.lexer!==n.loc.lexer?null:new e(t.loc.lexer,t.loc.start,n.loc.end):t&&t.loc}},Mw=class e{constructor(e,t){this.text=e,this.loc=t}range(t,n){return new e(n,jw.range(this,t))}},Nw={DISPLAY:0,TEXT:1,SCRIPT:2,SCRIPTSCRIPT:3},Pw=Object.create(null);function Q(e,t){Pw[e]=t}var Fw=Pw;Q(`\\noexpand`,function(e){let t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}}),Q(`\\expandafter`,function(e){let t=e.popToken();return e.expandOnce(!0),{tokens:[t],numArgs:0}}),Q(`\\@firstoftwo`,function(e){return{tokens:e.consumeArgs(2)[0],numArgs:0}}),Q(`\\@secondoftwo`,function(e){return{tokens:e.consumeArgs(2)[1],numArgs:0}}),Q(`\\@ifnextchar`,function(e){let t=e.consumeArgs(3);e.consumeSpaces();let n=e.future();return t[0].length===1&&t[0][0].text===n.text?{tokens:t[1],numArgs:0}:{tokens:t[2],numArgs:0}}),Q(`\\@ifstar`,`\\@ifnextchar *{\\@firstoftwo{#1}}`),Q(`\\TextOrMath`,function(e){let t=e.consumeArgs(2);return e.mode===`text`?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}});var Iw=e=>{let t=``;for(let n=e.length-1;n>-1;n--)t+=e[n].text;return t},Lw={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15},Rw=e=>{let t=e.future().text;return t===`EOF`?[null,``]:[Lw[t.charAt(0)],t]},zw=(e,t,n)=>{for(let r=1;r<t.length;r++){let i=Lw[t.charAt(r)];e*=n,e+=i}return e};Q(`\\char`,function(e){let t=e.popToken(),n,r=``;if(t.text===`'`)n=8,t=e.popToken();else if(t.text===`"`)n=16,t=e.popToken();else if(t.text==="`"){if(t=e.popToken(),t.text[0]===`\\`)r=t.text.charCodeAt(1);else if(t.text===`EOF`)throw new U("\\char` missing argument");else r=t.text.charCodeAt(0)}else n=10;if(n){let i=t.text;if(r=Lw[i.charAt(0)],r==null||r>=n)throw new U(`Invalid base-${n} digit ${t.text}`);r=zw(r,i,n);let a;for([a,i]=Rw(e);a!=null&&a<n;)r*=n,r+=a,r=zw(r,i,n),e.popToken(),[a,i]=Rw(e)}return`\\@char{${r}}`});function Bw(e){let t=e.consumeArgs(1)[0],n=``,r=t[t.length-1].loc.start;for(let e=t.length-1;e>=0;e--){let i=t[e].loc.start;i>r&&(n+=` `,r=i),n+=t[e].text,r+=t[e].text.length}return n}Q(`\\surd`,`\\sqrt{\\vphantom{|}}`),Q(`⊕`,`\\oplus`),Q(`\\long`,``),Q(`\\bgroup`,`{`),Q(`\\egroup`,`}`),Q(`~`,`\\nobreakspace`),Q(`\\lq`,"`"),Q(`\\rq`,`'`),Q(`\\aa`,`\\r a`),Q(`\\Bbbk`,`\\Bbb{k}`),Q(`\\mathstrut`,`\\vphantom{(}`),Q(`\\underbar`,`\\underline{\\text{#1}}`),Q(`\\vdots`,`{\\varvdots\\rule{0pt}{15pt}}`),Q(`⋮`,`\\vdots`),Q(`\\arraystretch`,`1`),Q(`\\arraycolsep`,`6pt`),Q(`\\substack`,`\\begin{subarray}{c}#1\\end{subarray}`),Q(`\\iff`,`\\DOTSB\\;\\Longleftrightarrow\\;`),Q(`\\implies`,`\\DOTSB\\;\\Longrightarrow\\;`),Q(`\\impliedby`,`\\DOTSB\\;\\Longleftarrow\\;`);var Vw={",":`\\dotsc`,"\\not":`\\dotsb`,"+":`\\dotsb`,"=":`\\dotsb`,"<":`\\dotsb`,">":`\\dotsb`,"-":`\\dotsb`,"*":`\\dotsb`,":":`\\dotsb`,"\\DOTSB":`\\dotsb`,"\\coprod":`\\dotsb`,"\\bigvee":`\\dotsb`,"\\bigwedge":`\\dotsb`,"\\biguplus":`\\dotsb`,"\\bigcap":`\\dotsb`,"\\bigcup":`\\dotsb`,"\\prod":`\\dotsb`,"\\sum":`\\dotsb`,"\\bigotimes":`\\dotsb`,"\\bigoplus":`\\dotsb`,"\\bigodot":`\\dotsb`,"\\bigsqcap":`\\dotsb`,"\\bigsqcup":`\\dotsb`,"\\bigtimes":`\\dotsb`,"\\And":`\\dotsb`,"\\longrightarrow":`\\dotsb`,"\\Longrightarrow":`\\dotsb`,"\\longleftarrow":`\\dotsb`,"\\Longleftarrow":`\\dotsb`,"\\longleftrightarrow":`\\dotsb`,"\\Longleftrightarrow":`\\dotsb`,"\\mapsto":`\\dotsb`,"\\longmapsto":`\\dotsb`,"\\hookrightarrow":`\\dotsb`,"\\doteq":`\\dotsb`,"\\mathbin":`\\dotsb`,"\\mathrel":`\\dotsb`,"\\relbar":`\\dotsb`,"\\Relbar":`\\dotsb`,"\\xrightarrow":`\\dotsb`,"\\xleftarrow":`\\dotsb`,"\\DOTSI":`\\dotsi`,"\\int":`\\dotsi`,"\\oint":`\\dotsi`,"\\iint":`\\dotsi`,"\\iiint":`\\dotsi`,"\\iiiint":`\\dotsi`,"\\DOTSX":`\\dotsx`};Q(`\\dots`,function(e){let t=`\\dotso`,n=e.expandAfterFuture().text;return n in Vw?t=Vw[n]:(n.slice(0,4)===`\\not`||n in wC.math&&[`bin`,`rel`].includes(wC.math[n].group))&&(t=`\\dotsb`),t}),Q(`\\dotsb`,`\\cdots`),Q(`\\dotsm`,`\\cdots`),Q(`\\dotsi`,`\\!\\cdots`),Q(`\\idotsint`,`\\int\\!\\cdots\\!\\int`),Q(`\\dotsx`,`\\ldots\\,`),Q(`\\DOTSI`,`\\relax`),Q(`\\DOTSB`,`\\relax`),Q(`\\DOTSX`,`\\relax`),Q(`\\tmspace`,`\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax`),Q(`\\,`,`{\\tmspace+{3mu}{.1667em}}`),Q(`\\thinspace`,`\\,`),Q(`\\>`,`\\mskip{4mu}`),Q(`\\:`,`{\\tmspace+{4mu}{.2222em}}`),Q(`\\medspace`,`\\:`),Q(`\\;`,`{\\tmspace+{5mu}{.2777em}}`),Q(`\\thickspace`,`\\;`),Q(`\\!`,`{\\tmspace-{3mu}{.1667em}}`),Q(`\\negthinspace`,`\\!`),Q(`\\negmedspace`,`{\\tmspace-{4mu}{.2222em}}`),Q(`\\negthickspace`,`{\\tmspace-{5mu}{.277em}}`),Q(`\\enspace`,`\\kern.5em `),Q(`\\enskip`,`\\hskip.5em\\relax`),Q(`\\quad`,`\\hskip1em\\relax`),Q(`\\qquad`,`\\hskip2em\\relax`),Q(`\\AA`,`\\TextOrMath{\\Angstrom}{\\mathring{A}}\\relax`),Q(`\\tag`,`\\@ifstar\\tag@literal\\tag@paren`),Q(`\\tag@paren`,`\\tag@literal{({#1})}`),Q(`\\tag@literal`,e=>{if(e.macros.get(`\\df@tag`))throw new U(`Multiple \\tag`);return`\\gdef\\df@tag{\\text{#1}}`}),Q(`\\notag`,`\\nonumber`),Q(`\\nonumber`,`\\gdef\\@eqnsw{0}`),Q(`\\bmod`,`\\mathbin{\\text{mod}}`),Q(`\\pod`,`\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)`),Q(`\\pmod`,`\\pod{{\\rm mod}\\mkern6mu#1}`),Q(`\\mod`,`\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1`),Q(`\\newline`,`\\\\\\relax`),Q(`\\TeX`,`\\textrm{T}\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125em\\textrm{X}`),Q(`\\LaTeX`,`\\textrm{L}\\kern-.35em\\raisebox{0.2em}{\\scriptstyle A}\\kern-.15em\\TeX`),Q(`\\Temml`,`\\textrm{T}\\kern-0.2em\\lower{0.2em}{\\textrm{E}}\\kern-0.08em{\\textrm{M}\\kern-0.08em\\raise{0.2em}\\textrm{M}\\kern-0.08em\\textrm{L}}`),Q(`\\hspace`,`\\@ifstar\\@hspacer\\@hspace`),Q(`\\@hspace`,`\\hskip #1\\relax`),Q(`\\@hspacer`,`\\rule{0pt}{0pt}\\hskip #1\\relax`),Q(`\\colon`,`\\mathpunct{\\char"3a}`),Q(`\\prescript`,`\\pres@cript{^{#1}_{#2}}{}{#3}`),Q(`\\ordinarycolon`,`\\char"3a`),Q(`\\vcentcolon`,`\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}}`),Q(`\\coloneq`,`\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"2212}`),Q(`\\Coloneq`,`\\mathrel{\\char"2237\\char"2212}`),Q(`\\Eqqcolon`,`\\mathrel{\\char"3d\\char"2237}`),Q(`\\Eqcolon`,`\\mathrel{\\char"2212\\char"2237}`),Q(`\\colonapprox`,`\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"2248}`),Q(`\\Colonapprox`,`\\mathrel{\\char"2237\\char"2248}`),Q(`\\colonsim`,`\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"223c}`),Q(`\\Colonsim`,`\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"223c}`),Q(`\\ratio`,`\\vcentcolon`),Q(`\\coloncolon`,`\\dblcolon`),Q(`\\colonequals`,`\\coloneqq`),Q(`\\coloncolonequals`,`\\Coloneqq`),Q(`\\equalscolon`,`\\eqqcolon`),Q(`\\equalscoloncolon`,`\\Eqqcolon`),Q(`\\colonminus`,`\\coloneq`),Q(`\\coloncolonminus`,`\\Coloneq`),Q(`\\minuscolon`,`\\eqcolon`),Q(`\\minuscoloncolon`,`\\Eqcolon`),Q(`\\coloncolonapprox`,`\\Colonapprox`),Q(`\\coloncolonsim`,`\\Colonsim`),Q(`\\notni`,"\\mathrel{\\char`∌}"),Q(`\\limsup`,`\\DOTSB\\operatorname*{lim\\,sup}`),Q(`\\liminf`,`\\DOTSB\\operatorname*{lim\\,inf}`),Q(`\\injlim`,`\\DOTSB\\operatorname*{inj\\,lim}`),Q(`\\projlim`,`\\DOTSB\\operatorname*{proj\\,lim}`),Q(`\\varlimsup`,`\\DOTSB\\operatorname*{\\overline{\\text{lim}}}`),Q(`\\varliminf`,`\\DOTSB\\operatorname*{\\underline{\\text{lim}}}`),Q(`\\varinjlim`,`\\DOTSB\\operatorname*{\\underrightarrow{\\text{lim}}}`),Q(`\\varprojlim`,`\\DOTSB\\operatorname*{\\underleftarrow{\\text{lim}}}`),Q(`\\centerdot`,`{\\medspace\\rule{0.167em}{0.189em}\\medspace}`),Q(`\\argmin`,`\\DOTSB\\operatorname*{arg\\,min}`),Q(`\\argmax`,`\\DOTSB\\operatorname*{arg\\,max}`),Q(`\\plim`,`\\DOTSB\\operatorname*{plim}`),Q(`\\leftmodels`,`\\mathop{\\reflectbox{$\\models$}}`),Q(`\\bra`,`\\mathinner{\\langle{#1}|}`),Q(`\\ket`,`\\mathinner{|{#1}\\rangle}`),Q(`\\braket`,`\\mathinner{\\langle{#1}\\rangle}`),Q(`\\Bra`,`\\left\\langle#1\\right|`),Q(`\\Ket`,`\\left|#1\\right\\rangle`);var Hw=(e,t)=>{let n=`}\\,\\middle${t[0]===`|`?`\\vert`:`\\Vert`}\\,{`;return e.slice(0,t.index)+n+e.slice(t.index+t[0].length)};Q(`\\Braket`,function(e){let t=Bw(e),n=/\|\||\||\\\|/g,r;for(;(r=n.exec(t))!==null;)t=Hw(t,r);return`\\left\\langle{`+t+`}\\right\\rangle`}),Q(`\\Set`,function(e){let t=Bw(e),n=/\|\||\||\\\|/.exec(t);return n&&(t=Hw(t,n)),`\\left\\{\\:{`+t+`}\\:\\right\\}`}),Q(`\\set`,function(e){return`\\{{`+Bw(e).replace(/\|/,`}\\mid{`)+`}\\}`}),Q(`\\angln`,`{\\angl n}`),Q(`\\odv`,`\\@ifstar\\odv@next\\odv@numerator`),Q(`\\odv@numerator`,`\\frac{\\mathrm{d}#1}{\\mathrm{d}#2}`),Q(`\\odv@next`,`\\frac{\\mathrm{d}}{\\mathrm{d}#2}#1`),Q(`\\pdv`,`\\@ifstar\\pdv@next\\pdv@numerator`);var Uw=e=>{let t=e[0][0].text,n=Iw(e[1]).split(`,`),r=String(n.length),i=r===`1`?`\\partial`:`\\partial^${r}`,a=``;return n.map(e=>{a+=`\\partial `+e.trim()+`\\,`}),[t,i,a.replace(/\\,$/,``)]};Q(`\\pdv@numerator`,function(e){let[t,n,r]=Uw(e.consumeArgs(2));return`\\frac{${n} ${t}}{${r}}`}),Q(`\\pdv@next`,function(e){let[t,n,r]=Uw(e.consumeArgs(2));return`\\frac{${n}}{${r}} ${t}`}),Q(`\\upalpha`,`\\up@greek{\\alpha}`),Q(`\\upbeta`,`\\up@greek{\\beta}`),Q(`\\upgamma`,`\\up@greek{\\gamma}`),Q(`\\updelta`,`\\up@greek{\\delta}`),Q(`\\upepsilon`,`\\up@greek{\\epsilon}`),Q(`\\upzeta`,`\\up@greek{\\zeta}`),Q(`\\upeta`,`\\up@greek{\\eta}`),Q(`\\uptheta`,`\\up@greek{\\theta}`),Q(`\\upiota`,`\\up@greek{\\iota}`),Q(`\\upkappa`,`\\up@greek{\\kappa}`),Q(`\\uplambda`,`\\up@greek{\\lambda}`),Q(`\\upmu`,`\\up@greek{\\mu}`),Q(`\\upnu`,`\\up@greek{\\nu}`),Q(`\\upxi`,`\\up@greek{\\xi}`),Q(`\\upomicron`,`\\up@greek{\\omicron}`),Q(`\\uppi`,`\\up@greek{\\pi}`),Q(`\\upalpha`,`\\up@greek{\\alpha}`),Q(`\\uprho`,`\\up@greek{\\rho}`),Q(`\\upsigma`,`\\up@greek{\\sigma}`),Q(`\\uptau`,`\\up@greek{\\tau}`),Q(`\\upupsilon`,`\\up@greek{\\upsilon}`),Q(`\\upphi`,`\\up@greek{\\phi}`),Q(`\\upchi`,`\\up@greek{\\chi}`),Q(`\\uppsi`,`\\up@greek{\\psi}`),Q(`\\upomega`,`\\up@greek{\\omega}`),Q(`\\invamp`,`\\mathbin{\\char"214b}`),Q(`\\parr`,`\\mathbin{\\char"214b}`),Q(`\\upand`,`\\mathbin{\\char"214b}`),Q(`\\with`,`\\mathbin{\\char"26}`),Q(`\\multimapinv`,`\\mathrel{\\char"27dc}`),Q(`\\multimapboth`,`\\mathrel{\\char"29df}`),Q(`\\scoh`,`{\\mkern5mu\\char"2322\\mkern5mu}`),Q(`\\sincoh`,`{\\mkern5mu\\char"2323\\mkern5mu}`),Q(`\\coh`,`{\\mkern5mu\\rule{}{0.7em}\\mathrlap{\\smash{\\raise2mu{\\char"2322}}}
55
+ {\\smash{\\lower4mu{\\char"2323}}}\\mkern5mu}`),Q(`\\incoh`,`{\\mkern5mu\\rule{}{0.7em}\\mathrlap{\\smash{\\raise2mu{\\char"2323}}}
56
+ {\\smash{\\lower4mu{\\char"2322}}}\\mkern5mu}`),Q(`\\standardstate`,"\\text{\\tiny\\char`⦵}"),Q(`\\ce`,function(e){return Ww(e.consumeArgs(1)[0],`ce`)}),Q(`\\pu`,function(e){return Ww(e.consumeArgs(1)[0],`pu`)}),Q(`\\uniDash`,`{\\rule{0.672em}{0.06em}}`),Q(`\\triDash`,`{\\rule{0.15em}{0.06em}\\kern2mu\\rule{0.15em}{0.06em}\\kern2mu\\rule{0.15em}{0.06em}}`),Q(`\\tripleDash`,`\\kern0.075em\\raise0.25em{\\triDash}\\kern0.075em`),Q(`\\tripleDashOverLine`,`\\kern0.075em\\mathrlap{\\raise0.125em{\\uniDash}}\\raise0.34em{\\triDash}\\kern0.075em`),Q(`\\tripleDashOverDoubleLine`,`\\kern0.075em\\mathrlap{\\mathrlap{\\raise0.48em{\\triDash}}\\raise0.27em{\\uniDash}}{\\raise0.05em{\\uniDash}}\\kern0.075em`),Q(`\\tripleDashBetweenDoubleLine`,`\\kern0.075em\\mathrlap{\\mathrlap{\\raise0.48em{\\uniDash}}\\raise0.27em{\\triDash}}{\\raise0.05em{\\uniDash}}\\kern0.075em`);var Ww=function(e,t){for(var n=``,r=e.length&&e[e.length-1].loc.start,i=e.length-1;i>=0;i--)e[i].loc.start>r&&(n+=` `,r=e[i].loc.start),n+=e[i].text,r+=e[i].text.length;return Gw.go($.go(n,t))},$={go:function(e,t){if(!e)return[];t===void 0&&(t=`ce`);var n=`0`,r={};r.parenthesisLevel=0,e=e.replace(/\n/g,` `),e=e.replace(/[\u2212\u2013\u2014\u2010]/g,`-`),e=e.replace(/[\u2026]/g,`...`);for(var i,a=10,o=[];;){i===e?a--:(a=10,i=e);var s=$.stateMachines[t],c=s.transitions[n]||s.transitions[`*`];iterateTransitions:for(var l=0;l<c.length;l++){var u=$.patterns.match_(c[l].pattern,e);if(u){for(var d=c[l].task,f=0;f<d.action_.length;f++){var p;if(s.actions[d.action_[f].type_])p=s.actions[d.action_[f].type_](r,u.match_,d.action_[f].option);else if($.actions[d.action_[f].type_])p=$.actions[d.action_[f].type_](r,u.match_,d.action_[f].option);else throw[`MhchemBugA`,`mhchem bug A. Please report. (`+d.action_[f].type_+`)`];$.concatArray(o,p)}if(n=d.nextState||n,e.length>0){if(d.revisit||(e=u.remainder),!d.toContinue)break iterateTransitions}else return o}}if(a<=0)throw[`MhchemBugU`,`mhchem bug U. Please report.`]}},concatArray:function(e,t){if(t){if(Array.isArray(t))for(var n=0;n<t.length;n++)e.push(t[n]);else e.push(t)}},patterns:{patterns:{empty:/^$/,else:/^./,else2:/^./,space:/^\s/,"space A":/^\s(?=[A-Z\\$])/,space$:/^\s$/,"a-z":/^[a-z]/,x:/^x/,x$:/^x$/,i$:/^i$/,letters:/^(?:[a-zA-Z\u03B1-\u03C9\u0391-\u03A9?@]|(?:\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))))+/,"\\greek":/^\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))/,"one lowercase latin letter $":/^(?:([a-z])(?:$|[^a-zA-Z]))$/,"$one lowercase latin letter$ $":/^\$(?:([a-z])(?:$|[^a-zA-Z]))\$$/,"one lowercase greek letter $":/^(?:\$?[\u03B1-\u03C9]\$?|\$?\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega)\s*\$?)(?:\s+|\{\}|(?![a-zA-Z]))$/,digits:/^[0-9]+/,"-9.,9":/^[+\-]?(?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))/,"-9.,9 no missing 0":/^[+\-]?[0-9]+(?:[.,][0-9]+)?/,"(-)(9.,9)(e)(99)":function(e){var t=e.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))?(\((?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))\))?(?:([eE]|\s*(\*|x|\\times|\u00D7)\s*10\^)([+\-]?[0-9]+|\{[+\-]?[0-9]+\}))?/);return t&&t[0]?{match_:t.splice(1),remainder:e.substr(t[0].length)}:null},"(-)(9)^(-9)":function(e){var t=e.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+)?)\^([+\-]?[0-9]+|\{[+\-]?[0-9]+\})/);return t&&t[0]?{match_:t.splice(1),remainder:e.substr(t[0].length)}:null},"state of aggregation $":function(e){var t=$.patterns.findObserveGroups(e,``,/^\([a-z]{1,3}(?=[\),])/,`)`,``);if(t&&t.remainder.match(/^($|[\s,;\)\]\}])/))return t;var n=e.match(/^(?:\((?:\\ca\s?)?\$[amothc]\$\))/);return n?{match_:n[0],remainder:e.substr(n[0].length)}:null},"_{(state of aggregation)}$":/^_\{(\([a-z]{1,3}\))\}/,"{[(":/^(?:\\\{|\[|\()/,")]}":/^(?:\)|\]|\\\})/,", ":/^[,;]\s*/,",":/^[,;]/,".":/^[.]/,". ":/^([.\u22C5\u00B7\u2022])\s*/,"...":/^\.\.\.(?=$|[^.])/,"* ":/^([*])\s*/,"^{(...)}":function(e){return $.patterns.findObserveGroups(e,`^{`,``,``,`}`)},"^($...$)":function(e){return $.patterns.findObserveGroups(e,`^`,`$`,`$`,``)},"^a":/^\^([0-9]+|[^\\_])/,"^\\x{}{}":function(e){return $.patterns.findObserveGroups(e,`^`,/^\\[a-zA-Z]+\{/,`}`,``,``,`{`,`}`,``,!0)},"^\\x{}":function(e){return $.patterns.findObserveGroups(e,`^`,/^\\[a-zA-Z]+\{/,`}`,``)},"^\\x":/^\^(\\[a-zA-Z]+)\s*/,"^(-1)":/^\^(-?\d+)/,"'":/^'/,"_{(...)}":function(e){return $.patterns.findObserveGroups(e,`_{`,``,``,`}`)},"_($...$)":function(e){return $.patterns.findObserveGroups(e,`_`,`$`,`$`,``)},_9:/^_([+\-]?[0-9]+|[^\\])/,"_\\x{}{}":function(e){return $.patterns.findObserveGroups(e,`_`,/^\\[a-zA-Z]+\{/,`}`,``,``,`{`,`}`,``,!0)},"_\\x{}":function(e){return $.patterns.findObserveGroups(e,`_`,/^\\[a-zA-Z]+\{/,`}`,``)},"_\\x":/^_(\\[a-zA-Z]+)\s*/,"^_":/^(?:\^(?=_)|\_(?=\^)|[\^_]$)/,"{}":/^\{\}/,"{...}":function(e){return $.patterns.findObserveGroups(e,``,`{`,`}`,``)},"{(...)}":function(e){return $.patterns.findObserveGroups(e,`{`,``,``,`}`)},"$...$":function(e){return $.patterns.findObserveGroups(e,``,`$`,`$`,``)},"${(...)}$":function(e){return $.patterns.findObserveGroups(e,"${",``,``,`}$`)},"$(...)$":function(e){return $.patterns.findObserveGroups(e,`$`,``,``,`$`)},"=<>":/^[=<>]/,"#":/^[#\u2261]/,"+":/^\+/,"-$":/^-(?=[\s_},;\]/]|$|\([a-z]+\))/,"-9":/^-(?=[0-9])/,"- orbital overlap":/^-(?=(?:[spd]|sp)(?:$|[\s,;\)\]\}]))/,"-":/^-/,"pm-operator":/^(?:\\pm|\$\\pm\$|\+-|\+\/-)/,operator:/^(?:\+|(?:[\-=<>]|<<|>>|\\approx|\$\\approx\$)(?=\s|$|-?[0-9]))/,arrowUpDown:/^(?:v|\(v\)|\^|\(\^\))(?=$|[\s,;\)\]\}])/,"\\bond{(...)}":function(e){return $.patterns.findObserveGroups(e,`\\bond{`,``,``,`}`)},"->":/^(?:<->|<-->|->|<-|<=>>|<<=>|<=>|[\u2192\u27F6\u21CC])/,CMT:/^[CMT](?=\[)/,"[(...)]":function(e){return $.patterns.findObserveGroups(e,`[`,``,``,`]`)},"1st-level escape":/^(&|\\\\|\\hline)\s*/,"\\,":/^(?:\\[,\ ;:])/,"\\x{}{}":function(e){return $.patterns.findObserveGroups(e,``,/^\\[a-zA-Z]+\{/,`}`,``,``,`{`,`}`,``,!0)},"\\x{}":function(e){return $.patterns.findObserveGroups(e,``,/^\\[a-zA-Z]+\{/,`}`,``)},"\\ca":/^\\ca(?:\s+|(?![a-zA-Z]))/,"\\x":/^(?:\\[a-zA-Z]+\s*|\\[_&{}%])/,orbital:/^(?:[0-9]{1,2}[spdfgh]|[0-9]{0,2}sp)(?=$|[^a-zA-Z])/,others:/^[\/~|]/,"\\frac{(...)}":function(e){return $.patterns.findObserveGroups(e,`\\frac{`,``,``,`}`,`{`,``,``,`}`)},"\\overset{(...)}":function(e){return $.patterns.findObserveGroups(e,`\\overset{`,``,``,`}`,`{`,``,``,`}`)},"\\underset{(...)}":function(e){return $.patterns.findObserveGroups(e,`\\underset{`,``,``,`}`,`{`,``,``,`}`)},"\\underbrace{(...)}":function(e){return $.patterns.findObserveGroups(e,`\\underbrace{`,``,``,`}_`,`{`,``,``,`}`)},"\\color{(...)}0":function(e){return $.patterns.findObserveGroups(e,`\\color{`,``,``,`}`)},"\\color{(...)}{(...)}1":function(e){return $.patterns.findObserveGroups(e,`\\color{`,``,``,`}`,`{`,``,``,`}`)},"\\color(...){(...)}2":function(e){return $.patterns.findObserveGroups(e,`\\color`,`\\`,``,/^(?=\{)/,`{`,``,``,`}`)},"\\ce{(...)}":function(e){return $.patterns.findObserveGroups(e,`\\ce{`,``,``,`}`)},oxidation$:/^(?:[+-][IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,"d-oxidation$":/^(?:[+-]?\s?[IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,"roman numeral":/^[IVX]+/,"1/2$":/^[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+(?:\$[a-z]\$|[a-z])?$/,amount:function(e){var t=e.match(/^(?:(?:(?:\([+\-]?[0-9]+\/[0-9]+\)|[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+|[+\-]?[0-9]+[.,][0-9]+|[+\-]?\.[0-9]+|[+\-]?[0-9]+)(?:[a-z](?=\s*[A-Z]))?)|[+\-]?[a-z](?=\s*[A-Z])|\+(?!\s))/);if(t)return{match_:t[0],remainder:e.substr(t[0].length)};var n=$.patterns.findObserveGroups(e,``,`$`,`$`,``);return n&&(t=n.match_.match(/^\$(?:\(?[+\-]?(?:[0-9]*[a-z]?[+\-])?[0-9]*[a-z](?:[+\-][0-9]*[a-z]?)?\)?|\+|-)\$$/),t)?{match_:t[0],remainder:e.substr(t[0].length)}:null},amount2:function(e){return this.amount(e)},"(KV letters),":/^(?:[A-Z][a-z]{0,2}|i)(?=,)/,formula$:function(e){if(e.match(/^\([a-z]+\)$/))return null;var t=e.match(/^(?:[a-z]|(?:[0-9\ \+\-\,\.\(\)]+[a-z])+[0-9\ \+\-\,\.\(\)]*|(?:[a-z][0-9\ \+\-\,\.\(\)]+)+[a-z]?)$/);return t?{match_:t[0],remainder:e.substr(t[0].length)}:null},uprightEntities:/^(?:pH|pOH|pC|pK|iPr|iBu)(?=$|[^a-zA-Z])/,"/":/^\s*(\/)\s*/,"//":/^\s*(\/\/)\s*/,"*":/^\s*[*.]\s*/},findObserveGroups:function(e,t,n,r,i,a,o,s,c,l){var u=function(e,t){if(typeof t==`string`)return e.indexOf(t)===0?t:null;var n=e.match(t);return n?n[0]:null},d=function(e,t,n){for(var r=0;t<e.length;){var i=e.charAt(t),a=u(e.substr(t),n);if(a!==null&&r===0)return{endMatchBegin:t,endMatchEnd:t+a.length};if(i===`{`)r++;else if(i===`}`){if(r===0)throw[`ExtraCloseMissingOpen`,`Extra close brace or missing open brace`];r--}t++}return null},f=u(e,t);if(f===null||(e=e.substr(f.length),f=u(e,n),f===null))return null;var p=d(e,f.length,r||i);if(p===null)return null;var m=e.substring(0,r?p.endMatchEnd:p.endMatchBegin);if(a||o){var h=this.findObserveGroups(e.substr(p.endMatchEnd),a,o,s,c);if(h===null)return null;var g=[m,h.match_];return{match_:l?g.join(``):g,remainder:h.remainder}}return{match_:m,remainder:e.substr(p.endMatchEnd)}},match_:function(e,t){var n=$.patterns.patterns[e];if(n===void 0)throw[`MhchemBugP`,`mhchem bug P. Please report. (`+e+`)`];if(typeof n==`function`)return $.patterns.patterns[e](t);var r=t.match(n);return r?{match_:r[2]?[r[1],r[2]]:r[1]?r[1]:r[0],remainder:t.substr(r[0].length)}:null}},actions:{"a=":function(e,t){e.a=(e.a||``)+t},"b=":function(e,t){e.b=(e.b||``)+t},"p=":function(e,t){e.p=(e.p||``)+t},"o=":function(e,t){e.o=(e.o||``)+t},"q=":function(e,t){e.q=(e.q||``)+t},"d=":function(e,t){e.d=(e.d||``)+t},"rm=":function(e,t){e.rm=(e.rm||``)+t},"text=":function(e,t){e.text_=(e.text_||``)+t},insert:function(e,t,n){return{type_:n}},"insert+p1":function(e,t,n){return{type_:n,p1:t}},"insert+p1+p2":function(e,t,n){return{type_:n,p1:t[0],p2:t[1]}},copy:function(e,t){return t},rm:function(e,t){return{type_:`rm`,p1:t||``}},text:function(e,t){return $.go(t,`text`)},"{text}":function(e,t){var n=[`{`];return $.concatArray(n,$.go(t,`text`)),n.push(`}`),n},"tex-math":function(e,t){return $.go(t,`tex-math`)},"tex-math tight":function(e,t){return $.go(t,`tex-math tight`)},bond:function(e,t,n){return{type_:`bond`,kind_:n||t}},"color0-output":function(e,t){return{type_:`color0`,color:t[0]}},ce:function(e,t){return $.go(t)},"1/2":function(e,t){var n=[];t.match(/^[+\-]/)&&(n.push(t.substr(0,1)),t=t.substr(1));var r=t.match(/^([0-9]+|\$[a-z]\$|[a-z])\/([0-9]+)(\$[a-z]\$|[a-z])?$/);return r[1]=r[1].replace(/\$/g,``),n.push({type_:`frac`,p1:r[1],p2:r[2]}),r[3]&&(r[3]=r[3].replace(/\$/g,``),n.push({type_:`tex-math`,p1:r[3]})),n},"9,9":function(e,t){return $.go(t,`9,9`)}},createTransitions:function(e){var t,n,r,i,a={};for(t in e)for(n in e[t])for(r=n.split(`|`),e[t][n].stateArray=r,i=0;i<r.length;i++)a[r[i]]=[];for(t in e)for(n in e[t])for(r=e[t][n].stateArray||[],i=0;i<r.length;i++){var o=e[t][n];if(o.action_){o.action_=[].concat(o.action_);for(var s=0;s<o.action_.length;s++)typeof o.action_[s]==`string`&&(o.action_[s]={type_:o.action_[s]})}else o.action_=[];for(var c=t.split(`|`),l=0;l<c.length;l++)if(r[i]===`*`)for(var u in a)a[u].push({pattern:c[l],task:o});else a[r[i]].push({pattern:c[l],task:o})}return a},stateMachines:{}};$.stateMachines={ce:{transitions:$.createTransitions({empty:{"*":{action_:`output`}},else:{"0|1|2":{action_:`beginsWithBond=false`,revisit:!0,toContinue:!0}},oxidation$:{0:{action_:`oxidation-output`}},CMT:{r:{action_:`rdt=`,nextState:`rt`},rd:{action_:`rqt=`,nextState:`rdt`}},arrowUpDown:{"0|1|2|as":{action_:[`sb=false`,`output`,`operator`],nextState:`1`}},uprightEntities:{"0|1|2":{action_:[`o=`,`output`],nextState:`1`}},orbital:{"0|1|2|3":{action_:`o=`,nextState:`o`}},"->":{"0|1|2|3":{action_:`r=`,nextState:`r`},"a|as":{action_:[`output`,`r=`],nextState:`r`},"*":{action_:[`output`,`r=`],nextState:`r`}},"+":{o:{action_:`d= kv`,nextState:`d`},"d|D":{action_:`d=`,nextState:`d`},q:{action_:`d=`,nextState:`qd`},"qd|qD":{action_:`d=`,nextState:`qd`},dq:{action_:[`output`,`d=`],nextState:`d`},3:{action_:[`sb=false`,`output`,`operator`],nextState:`0`}},amount:{"0|2":{action_:`a=`,nextState:`a`}},"pm-operator":{"0|1|2|a|as":{action_:[`sb=false`,`output`,{type_:`operator`,option:`\\pm`}],nextState:`0`}},operator:{"0|1|2|a|as":{action_:[`sb=false`,`output`,`operator`],nextState:`0`}},"-$":{"o|q":{action_:[`charge or bond`,`output`],nextState:`qd`},d:{action_:`d=`,nextState:`d`},D:{action_:[`output`,{type_:`bond`,option:`-`}],nextState:`3`},q:{action_:`d=`,nextState:`qd`},qd:{action_:`d=`,nextState:`qd`},"qD|dq":{action_:[`output`,{type_:`bond`,option:`-`}],nextState:`3`}},"-9":{"3|o":{action_:[`output`,{type_:`insert`,option:`hyphen`}],nextState:`3`}},"- orbital overlap":{o:{action_:[`output`,{type_:`insert`,option:`hyphen`}],nextState:`2`},d:{action_:[`output`,{type_:`insert`,option:`hyphen`}],nextState:`2`}},"-":{"0|1|2":{action_:[{type_:`output`,option:1},`beginsWithBond=true`,{type_:`bond`,option:`-`}],nextState:`3`},3:{action_:{type_:`bond`,option:`-`}},a:{action_:[`output`,{type_:`insert`,option:`hyphen`}],nextState:`2`},as:{action_:[{type_:`output`,option:2},{type_:`bond`,option:`-`}],nextState:`3`},b:{action_:`b=`},o:{action_:{type_:`- after o/d`,option:!1},nextState:`2`},q:{action_:{type_:`- after o/d`,option:!1},nextState:`2`},"d|qd|dq":{action_:{type_:`- after o/d`,option:!0},nextState:`2`},"D|qD|p":{action_:[`output`,{type_:`bond`,option:`-`}],nextState:`3`}},amount2:{"1|3":{action_:`a=`,nextState:`a`}},letters:{"0|1|2|3|a|as|b|p|bp|o":{action_:`o=`,nextState:`o`},"q|dq":{action_:[`output`,`o=`],nextState:`o`},"d|D|qd|qD":{action_:`o after d`,nextState:`o`}},digits:{o:{action_:`q=`,nextState:`q`},"d|D":{action_:`q=`,nextState:`dq`},q:{action_:[`output`,`o=`],nextState:`o`},a:{action_:`o=`,nextState:`o`}},"space A":{"b|p|bp":{}},space:{a:{nextState:`as`},0:{action_:`sb=false`},"1|2":{action_:`sb=true`},"r|rt|rd|rdt|rdq":{action_:`output`,nextState:`0`},"*":{action_:[`output`,`sb=true`],nextState:`1`}},"1st-level escape":{"1|2":{action_:[`output`,{type_:`insert+p1`,option:`1st-level escape`}]},"*":{action_:[`output`,{type_:`insert+p1`,option:`1st-level escape`}],nextState:`0`}},"[(...)]":{"r|rt":{action_:`rd=`,nextState:`rd`},"rd|rdt":{action_:`rq=`,nextState:`rdq`}},"...":{"o|d|D|dq|qd|qD":{action_:[`output`,{type_:`bond`,option:`...`}],nextState:`3`},"*":{action_:[{type_:`output`,option:1},{type_:`insert`,option:`ellipsis`}],nextState:`1`}},". |* ":{"*":{action_:[`output`,{type_:`insert`,option:`addition compound`}],nextState:`1`}},"state of aggregation $":{"*":{action_:[`output`,`state of aggregation`],nextState:`1`}},"{[(":{"a|as|o":{action_:[`o=`,`output`,`parenthesisLevel++`],nextState:`2`},"0|1|2|3":{action_:[`o=`,`output`,`parenthesisLevel++`],nextState:`2`},"*":{action_:[`output`,`o=`,`output`,`parenthesisLevel++`],nextState:`2`}},")]}":{"0|1|2|3|b|p|bp|o":{action_:[`o=`,`parenthesisLevel--`],nextState:`o`},"a|as|d|D|q|qd|qD|dq":{action_:[`output`,`o=`,`parenthesisLevel--`],nextState:`o`}},", ":{"*":{action_:[`output`,`comma`],nextState:`0`}},"^_":{"*":{}},"^{(...)}|^($...$)":{"0|1|2|as":{action_:`b=`,nextState:`b`},p:{action_:`b=`,nextState:`bp`},"3|o":{action_:`d= kv`,nextState:`D`},q:{action_:`d=`,nextState:`qD`},"d|D|qd|qD|dq":{action_:[`output`,`d=`],nextState:`D`}},"^a|^\\x{}{}|^\\x{}|^\\x|'":{"0|1|2|as":{action_:`b=`,nextState:`b`},p:{action_:`b=`,nextState:`bp`},"3|o":{action_:`d= kv`,nextState:`d`},q:{action_:`d=`,nextState:`qd`},"d|qd|D|qD":{action_:`d=`},dq:{action_:[`output`,`d=`],nextState:`d`}},"_{(state of aggregation)}$":{"d|D|q|qd|qD|dq":{action_:[`output`,`q=`],nextState:`q`}},"_{(...)}|_($...$)|_9|_\\x{}{}|_\\x{}|_\\x":{"0|1|2|as":{action_:`p=`,nextState:`p`},b:{action_:`p=`,nextState:`bp`},"3|o":{action_:`q=`,nextState:`q`},"d|D":{action_:`q=`,nextState:`dq`},"q|qd|qD|dq":{action_:[`output`,`q=`],nextState:`q`}},"=<>":{"0|1|2|3|a|as|o|q|d|D|qd|qD|dq":{action_:[{type_:`output`,option:2},`bond`],nextState:`3`}},"#":{"0|1|2|3|a|as|o":{action_:[{type_:`output`,option:2},{type_:`bond`,option:`#`}],nextState:`3`}},"{}":{"*":{action_:{type_:`output`,option:1},nextState:`1`}},"{...}":{"0|1|2|3|a|as|b|p|bp":{action_:`o=`,nextState:`o`},"o|d|D|q|qd|qD|dq":{action_:[`output`,`o=`],nextState:`o`}},"$...$":{a:{action_:`a=`},"0|1|2|3|as|b|p|bp|o":{action_:`o=`,nextState:`o`},"as|o":{action_:`o=`},"q|d|D|qd|qD|dq":{action_:[`output`,`o=`],nextState:`o`}},"\\bond{(...)}":{"*":{action_:[{type_:`output`,option:2},`bond`],nextState:`3`}},"\\frac{(...)}":{"*":{action_:[{type_:`output`,option:1},`frac-output`],nextState:`3`}},"\\overset{(...)}":{"*":{action_:[{type_:`output`,option:2},`overset-output`],nextState:`3`}},"\\underset{(...)}":{"*":{action_:[{type_:`output`,option:2},`underset-output`],nextState:`3`}},"\\underbrace{(...)}":{"*":{action_:[{type_:`output`,option:2},`underbrace-output`],nextState:`3`}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:[{type_:`output`,option:2},`color-output`],nextState:`3`}},"\\color{(...)}0":{"*":{action_:[{type_:`output`,option:2},`color0-output`]}},"\\ce{(...)}":{"*":{action_:[{type_:`output`,option:2},`ce`],nextState:`3`}},"\\,":{"*":{action_:[{type_:`output`,option:1},`copy`],nextState:`1`}},"\\x{}{}|\\x{}|\\x":{"0|1|2|3|a|as|b|p|bp|o|c0":{action_:[`o=`,`output`],nextState:`3`},"*":{action_:[`output`,`o=`,`output`],nextState:`3`}},others:{"*":{action_:[{type_:`output`,option:1},`copy`],nextState:`3`}},else2:{a:{action_:`a to o`,nextState:`o`,revisit:!0},as:{action_:[`output`,`sb=true`],nextState:`1`,revisit:!0},"r|rt|rd|rdt|rdq":{action_:[`output`],nextState:`0`,revisit:!0},"*":{action_:[`output`,`copy`],nextState:`3`}}}),actions:{"o after d":function(e,t){var n;if((e.d||``).match(/^[0-9]+$/)){var r=e.d;e.d=void 0,n=this.output(e),e.b=r}else n=this.output(e);return $.actions[`o=`](e,t),n},"d= kv":function(e,t){e.d=t,e.dType=`kv`},"charge or bond":function(e,t){if(e.beginsWithBond){var n=[];return $.concatArray(n,this.output(e)),$.concatArray(n,$.actions.bond(e,t,`-`)),n}e.d=t},"- after o/d":function(e,t,n){var r=$.patterns.match_(`orbital`,e.o||``),i=$.patterns.match_(`one lowercase greek letter $`,e.o||``),a=$.patterns.match_(`one lowercase latin letter $`,e.o||``),o=$.patterns.match_(`$one lowercase latin letter$ $`,e.o||``),s=t===`-`&&(r&&r.remainder===``||i||a||o);!s||e.a||e.b||e.p||e.d||e.q||r||!a||(e.o=`$`+e.o+`$`);var c=[];return s?($.concatArray(c,this.output(e)),c.push({type_:`hyphen`})):(r=$.patterns.match_(`digits`,e.d||``),n&&r&&r.remainder===``?($.concatArray(c,$.actions[`d=`](e,t)),$.concatArray(c,this.output(e))):($.concatArray(c,this.output(e)),$.concatArray(c,$.actions.bond(e,t,`-`)))),c},"a to o":function(e){e.o=e.a,e.a=void 0},"sb=true":function(e){e.sb=!0},"sb=false":function(e){e.sb=!1},"beginsWithBond=true":function(e){e.beginsWithBond=!0},"beginsWithBond=false":function(e){e.beginsWithBond=!1},"parenthesisLevel++":function(e){e.parenthesisLevel++},"parenthesisLevel--":function(e){e.parenthesisLevel--},"state of aggregation":function(e,t){return{type_:`state of aggregation`,p1:$.go(t,`o`)}},comma:function(e,t){var n=t.replace(/\s*$/,``);return n!==t&&e.parenthesisLevel===0?{type_:`comma enumeration L`,p1:n}:{type_:`comma enumeration M`,p1:n}},output:function(e,t,n){var r;if(!e.r)r=[],(e.a||e.b||e.p||e.o||e.q||e.d||n)&&(e.sb&&r.push({type_:`entitySkip`}),!e.o&&!e.q&&!e.d&&!e.b&&!e.p&&n!==2?(e.o=e.a,e.a=void 0):!e.o&&!e.q&&!e.d&&(e.b||e.p)?(e.o=e.a,e.d=e.b,e.q=e.p,e.a=e.b=e.p=void 0):e.o&&e.dType===`kv`&&$.patterns.match_(`d-oxidation$`,e.d||``)?e.dType=`oxidation`:e.o&&e.dType===`kv`&&!e.q&&(e.dType=void 0),r.push({type_:`chemfive`,a:$.go(e.a,`a`),b:$.go(e.b,`bd`),p:$.go(e.p,`pq`),o:$.go(e.o,`o`),q:$.go(e.q,`pq`),d:$.go(e.d,e.dType===`oxidation`?`oxidation`:`bd`),dType:e.dType}));else{var i=e.rdt===`M`?$.go(e.rd,`tex-math`):e.rdt===`T`?[{type_:`text`,p1:e.rd||``}]:$.go(e.rd),a=e.rqt===`M`?$.go(e.rq,`tex-math`):e.rqt===`T`?[{type_:`text`,p1:e.rq||``}]:$.go(e.rq);r={type_:`arrow`,r:e.r,rd:i,rq:a}}for(var o in e)o!==`parenthesisLevel`&&o!==`beginsWithBond`&&delete e[o];return r},"oxidation-output":function(e,t){var n=[`{`];return $.concatArray(n,$.go(t,`oxidation`)),n.push(`}`),n},"frac-output":function(e,t){return{type_:`frac-ce`,p1:$.go(t[0]),p2:$.go(t[1])}},"overset-output":function(e,t){return{type_:`overset`,p1:$.go(t[0]),p2:$.go(t[1])}},"underset-output":function(e,t){return{type_:`underset`,p1:$.go(t[0]),p2:$.go(t[1])}},"underbrace-output":function(e,t){return{type_:`underbrace`,p1:$.go(t[0]),p2:$.go(t[1])}},"color-output":function(e,t){return{type_:`color`,color1:t[0],color2:$.go(t[1])}},"r=":function(e,t){e.r=t},"rdt=":function(e,t){e.rdt=t},"rd=":function(e,t){e.rd=t},"rqt=":function(e,t){e.rqt=t},"rq=":function(e,t){e.rq=t},operator:function(e,t,n){return{type_:`operator`,kind_:n||t}}}},a:{transitions:$.createTransitions({empty:{"*":{}},"1/2$":{0:{action_:`1/2`}},else:{0:{nextState:`1`,revisit:!0}},"$(...)$":{"*":{action_:`tex-math tight`,nextState:`1`}},",":{"*":{action_:{type_:`insert`,option:`commaDecimal`}}},else2:{"*":{action_:`copy`}}}),actions:{}},o:{transitions:$.createTransitions({empty:{"*":{}},"1/2$":{0:{action_:`1/2`}},else:{0:{nextState:`1`,revisit:!0}},letters:{"*":{action_:`rm`}},"\\ca":{"*":{action_:{type_:`insert`,option:`circa`}}},"\\x{}{}|\\x{}|\\x":{"*":{action_:`copy`}},"${(...)}$|$(...)$":{"*":{action_:`tex-math`}},"{(...)}":{"*":{action_:`{text}`}},else2:{"*":{action_:`copy`}}}),actions:{}},text:{transitions:$.createTransitions({empty:{"*":{action_:`output`}},"{...}":{"*":{action_:`text=`}},"${(...)}$|$(...)$":{"*":{action_:`tex-math`}},"\\greek":{"*":{action_:[`output`,`rm`]}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:[`output`,`copy`]}},else:{"*":{action_:`text=`}}}),actions:{output:function(e){if(e.text_){var t={type_:`text`,p1:e.text_};for(var n in e)delete e[n];return t}}}},pq:{transitions:$.createTransitions({empty:{"*":{}},"state of aggregation $":{"*":{action_:`state of aggregation`}},i$:{0:{nextState:`!f`,revisit:!0}},"(KV letters),":{0:{action_:`rm`,nextState:`0`}},formula$:{0:{nextState:`f`,revisit:!0}},"1/2$":{0:{action_:`1/2`}},else:{0:{nextState:`!f`,revisit:!0}},"${(...)}$|$(...)$":{"*":{action_:`tex-math`}},"{(...)}":{"*":{action_:`text`}},"a-z":{f:{action_:`tex-math`}},letters:{"*":{action_:`rm`}},"-9.,9":{"*":{action_:`9,9`}},",":{"*":{action_:{type_:`insert+p1`,option:`comma enumeration S`}}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:`color-output`}},"\\color{(...)}0":{"*":{action_:`color0-output`}},"\\ce{(...)}":{"*":{action_:`ce`}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:`copy`}},else2:{"*":{action_:`copy`}}}),actions:{"state of aggregation":function(e,t){return{type_:`state of aggregation subscript`,p1:$.go(t,`o`)}},"color-output":function(e,t){return{type_:`color`,color1:t[0],color2:$.go(t[1],`pq`)}}}},bd:{transitions:$.createTransitions({empty:{"*":{}},x$:{0:{nextState:`!f`,revisit:!0}},formula$:{0:{nextState:`f`,revisit:!0}},else:{0:{nextState:`!f`,revisit:!0}},"-9.,9 no missing 0":{"*":{action_:`9,9`}},".":{"*":{action_:{type_:`insert`,option:`electron dot`}}},"a-z":{f:{action_:`tex-math`}},x:{"*":{action_:{type_:`insert`,option:`KV x`}}},letters:{"*":{action_:`rm`}},"'":{"*":{action_:{type_:`insert`,option:`prime`}}},"${(...)}$|$(...)$":{"*":{action_:`tex-math`}},"{(...)}":{"*":{action_:`text`}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:`color-output`}},"\\color{(...)}0":{"*":{action_:`color0-output`}},"\\ce{(...)}":{"*":{action_:`ce`}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:`copy`}},else2:{"*":{action_:`copy`}}}),actions:{"color-output":function(e,t){return{type_:`color`,color1:t[0],color2:$.go(t[1],`bd`)}}}},oxidation:{transitions:$.createTransitions({empty:{"*":{}},"roman numeral":{"*":{action_:`roman-numeral`}},"${(...)}$|$(...)$":{"*":{action_:`tex-math`}},else:{"*":{action_:`copy`}}}),actions:{"roman-numeral":function(e,t){return{type_:`roman numeral`,p1:t||``}}}},"tex-math":{transitions:$.createTransitions({empty:{"*":{action_:`output`}},"\\ce{(...)}":{"*":{action_:[`output`,`ce`]}},"{...}|\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:`o=`}},else:{"*":{action_:`o=`}}}),actions:{output:function(e){if(e.o){var t={type_:`tex-math`,p1:e.o};for(var n in e)delete e[n];return t}}}},"tex-math tight":{transitions:$.createTransitions({empty:{"*":{action_:`output`}},"\\ce{(...)}":{"*":{action_:[`output`,`ce`]}},"{...}|\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:`o=`}},"-|+":{"*":{action_:`tight operator`}},else:{"*":{action_:`o=`}}}),actions:{"tight operator":function(e,t){e.o=(e.o||``)+`{`+t+`}`},output:function(e){if(e.o){var t={type_:`tex-math`,p1:e.o};for(var n in e)delete e[n];return t}}}},"9,9":{transitions:$.createTransitions({empty:{"*":{}},",":{"*":{action_:`comma`}},else:{"*":{action_:`copy`}}}),actions:{comma:function(){return{type_:`commaDecimal`}}}},pu:{transitions:$.createTransitions({empty:{"*":{action_:`output`}},space$:{"*":{action_:[`output`,`space`]}},"{[(|)]}":{"0|a":{action_:`copy`}},"(-)(9)^(-9)":{0:{action_:`number^`,nextState:`a`}},"(-)(9.,9)(e)(99)":{0:{action_:`enumber`,nextState:`a`}},space:{"0|a":{}},"pm-operator":{"0|a":{action_:{type_:`operator`,option:`\\pm`},nextState:`0`}},operator:{"0|a":{action_:`copy`,nextState:`0`}},"//":{d:{action_:`o=`,nextState:`/`}},"/":{d:{action_:`o=`,nextState:`/`}},"{...}|else":{"0|d":{action_:`d=`,nextState:`d`},a:{action_:[`space`,`d=`],nextState:`d`},"/|q":{action_:`q=`,nextState:`q`}}}),actions:{enumber:function(e,t){var n=[];return t[0]===`+-`||t[0]===`+/-`?n.push(`\\pm `):t[0]&&n.push(t[0]),t[1]&&($.concatArray(n,$.go(t[1],`pu-9,9`)),t[2]&&(t[2].match(/[,.]/)?$.concatArray(n,$.go(t[2],`pu-9,9`)):n.push(t[2])),t[3]=t[4]||t[3],t[3]&&(t[3]=t[3].trim(),t[3]===`e`||t[3].substr(0,1)===`*`?n.push({type_:`cdot`}):n.push({type_:`times`}))),t[3]&&n.push(`10^{`+t[5]+`}`),n},"number^":function(e,t){var n=[];return t[0]===`+-`||t[0]===`+/-`?n.push(`\\pm `):t[0]&&n.push(t[0]),$.concatArray(n,$.go(t[1],`pu-9,9`)),n.push(`^{`+t[2]+`}`),n},operator:function(e,t,n){return{type_:`operator`,kind_:n||t}},space:function(){return{type_:`pu-space-1`}},output:function(e){var t,n=$.patterns.match_(`{(...)}`,e.d||``);n&&n.remainder===``&&(e.d=n.match_);var r=$.patterns.match_(`{(...)}`,e.q||``);if(r&&r.remainder===``&&(e.q=r.match_),e.d&&=(e.d=e.d.replace(/\u00B0C|\^oC|\^{o}C/g,`{}^{\\circ}C`),e.d.replace(/\u00B0F|\^oF|\^{o}F/g,`{}^{\\circ}F`)),e.q){e.q=e.q.replace(/\u00B0C|\^oC|\^{o}C/g,`{}^{\\circ}C`),e.q=e.q.replace(/\u00B0F|\^oF|\^{o}F/g,`{}^{\\circ}F`);var i={d:$.go(e.d,`pu`),q:$.go(e.q,`pu`)};e.o===`//`?t={type_:`pu-frac`,p1:i.d,p2:i.q}:(t=i.d,i.d.length>1||i.q.length>1?t.push({type_:` / `}):t.push({type_:`/`}),$.concatArray(t,i.q))}else t=$.go(e.d,`pu-2`);for(var a in e)delete e[a];return t}}},"pu-2":{transitions:$.createTransitions({empty:{"*":{action_:`output`}},"*":{"*":{action_:[`output`,`cdot`],nextState:`0`}},"\\x":{"*":{action_:`rm=`}},space:{"*":{action_:[`output`,`space`],nextState:`0`}},"^{(...)}|^(-1)":{1:{action_:`^(-1)`}},"-9.,9":{0:{action_:`rm=`,nextState:`0`},1:{action_:`^(-1)`,nextState:`0`}},"{...}|else":{"*":{action_:`rm=`,nextState:`1`}}}),actions:{cdot:function(){return{type_:`tight cdot`}},"^(-1)":function(e,t){e.rm+=`^{`+t+`}`},space:function(){return{type_:`pu-space-2`}},output:function(e){var t=[];if(e.rm){var n=$.patterns.match_(`{(...)}`,e.rm||``);t=n&&n.remainder===``?$.go(n.match_,`pu`):{type_:`rm`,p1:e.rm}}for(var r in e)delete e[r];return t}}},"pu-9,9":{transitions:$.createTransitions({empty:{0:{action_:`output-0`},o:{action_:`output-o`}},",":{0:{action_:[`output-0`,`comma`],nextState:`o`}},".":{0:{action_:[`output-0`,`copy`],nextState:`o`}},else:{"*":{action_:`text=`}}}),actions:{comma:function(){return{type_:`commaDecimal`}},"output-0":function(e){var t=[];if(e.text_=e.text_||``,e.text_.length>4){var n=e.text_.length%3;n===0&&(n=3);for(var r=e.text_.length-3;r>0;r-=3)t.push(e.text_.substr(r,3)),t.push({type_:`1000 separator`});t.push(e.text_.substr(0,n)),t.reverse()}else t.push(e.text_);for(var i in e)delete e[i];return t},"output-o":function(e){var t=[];if(e.text_=e.text_||``,e.text_.length>4){for(var n=e.text_.length-3,r=0;r<n;r+=3)t.push(e.text_.substr(r,3)),t.push({type_:`1000 separator`});t.push(e.text_.substr(r))}else t.push(e.text_);for(var i in e)delete e[i];return t}}}};var Gw={go:function(e,t){if(!e)return``;for(var n=``,r=!1,i=0;i<e.length;i++){var a=e[i];typeof a==`string`?n+=a:(n+=Gw._go2(a),a.type_===`1st-level escape`&&(r=!0))}return!t&&!r&&n&&(n=`{`+n+`}`),n},_goInner:function(e){return e&&Gw.go(e,!0)},_go2:function(e){var t;switch(e.type_){case`chemfive`:t=``;var n={a:Gw._goInner(e.a),b:Gw._goInner(e.b),p:Gw._goInner(e.p),o:Gw._goInner(e.o),q:Gw._goInner(e.q),d:Gw._goInner(e.d)};n.a&&(n.a.match(/^[+\-]/)&&(n.a=`{`+n.a+`}`),t+=n.a+`\\,`),(n.b||n.p)&&(t+=`{\\vphantom{X}}`,t+=`^{\\hphantom{`+(n.b||``)+`}}_{\\hphantom{`+(n.p||``)+`}}`,t+=`{\\vphantom{X}}`,t+=`^{\\vphantom{2}\\mathllap{`+(n.b||``)+`}}`,t+=`_{\\vphantom{2}\\mathllap{`+(n.p||``)+`}}`),n.o&&(n.o.match(/^[+\-]/)&&(n.o=`{`+n.o+`}`),t+=n.o),e.dType===`kv`?((n.d||n.q)&&(t+=`{\\vphantom{X}}`),n.d&&(t+=`^{`+n.d+`}`),n.q&&(t+=`_{`+n.q+`}`)):e.dType===`oxidation`?(n.d&&(t+=`{\\vphantom{X}}`,t+=`^{`+n.d+`}`),n.q&&(t+=`{{}}`,t+=`_{`+n.q+`}`)):(n.q&&(t+=`{{}}`,t+=`_{`+n.q+`}`),n.d&&(t+=`{{}}`,t+=`^{`+n.d+`}`));break;case`rm`:t=`\\mathrm{`+e.p1+`}`;break;case`text`:e.p1.match(/[\^_]/)?(e.p1=e.p1.replace(` `,`~`).replace(`-`,`\\text{-}`),t=`\\mathrm{`+e.p1+`}`):t=`\\text{`+e.p1+`}`;break;case`roman numeral`:t=`\\mathrm{`+e.p1+`}`;break;case`state of aggregation`:t=`\\mskip2mu `+Gw._goInner(e.p1);break;case`state of aggregation subscript`:t=`\\mskip1mu `+Gw._goInner(e.p1);break;case`bond`:if(t=Gw._getBond(e.kind_),!t)throw[`MhchemErrorBond`,`mhchem Error. Unknown bond type (`+e.kind_+`)`];break;case`frac`:var r=`\\frac{`+e.p1+`}{`+e.p2+`}`;t=`\\mathchoice{\\textstyle`+r+`}{`+r+`}{`+r+`}{`+r+`}`;break;case`pu-frac`:var i=`\\frac{`+Gw._goInner(e.p1)+`}{`+Gw._goInner(e.p2)+`}`;t=`\\mathchoice{\\textstyle`+i+`}{`+i+`}{`+i+`}{`+i+`}`;break;case`tex-math`:t=e.p1+` `;break;case`frac-ce`:t=`\\frac{`+Gw._goInner(e.p1)+`}{`+Gw._goInner(e.p2)+`}`;break;case`overset`:t=`\\overset{`+Gw._goInner(e.p1)+`}{`+Gw._goInner(e.p2)+`}`;break;case`underset`:t=`\\underset{`+Gw._goInner(e.p1)+`}{`+Gw._goInner(e.p2)+`}`;break;case`underbrace`:t=`\\underbrace{`+Gw._goInner(e.p1)+`}_{`+Gw._goInner(e.p2)+`}`;break;case`color`:t=`{\\color{`+e.color1+`}{`+Gw._goInner(e.color2)+`}}`;break;case`color0`:t=`\\color{`+e.color+`}`;break;case`arrow`:var a={rd:Gw._goInner(e.rd),rq:Gw._goInner(e.rq)},o=Gw._getArrow(e.r);a.rq&&(o+=`[{\\rm `+a.rq+`}]`),a.rd?o+=`{\\rm `+a.rd+`}`:o+=`{}`,t=o;break;case`operator`:t=Gw._getOperator(e.kind_);break;case`1st-level escape`:t=e.p1+` `;break;case`space`:t=` `;break;case`entitySkip`:t=`~`;break;case`pu-space-1`:t=`~`;break;case`pu-space-2`:t=`\\mkern3mu `;break;case`1000 separator`:t=`\\mkern2mu `;break;case`commaDecimal`:t=`{,}`;break;case`comma enumeration L`:t=`{`+e.p1+`}\\mkern6mu `;break;case`comma enumeration M`:t=`{`+e.p1+`}\\mkern3mu `;break;case`comma enumeration S`:t=`{`+e.p1+`}\\mkern1mu `;break;case`hyphen`:t=`\\text{-}`;break;case`addition compound`:t=`\\,{\\cdot}\\,`;break;case`electron dot`:t=`\\mkern1mu \\text{\\textbullet}\\mkern1mu `;break;case`KV x`:t=`{\\times}`;break;case`prime`:t=`\\prime `;break;case`cdot`:t=`\\cdot `;break;case`tight cdot`:t=`\\mkern1mu{\\cdot}\\mkern1mu `;break;case`times`:t=`\\times `;break;case`circa`:t=`{\\sim}`;break;case`^`:t=`uparrow`;break;case`v`:t=`downarrow`;break;case`ellipsis`:t=`\\ldots `;break;case`/`:t=`/`;break;case` / `:t=`\\,/\\,`;break;default:throw[`MhchemBugT`,`mhchem bug T. Please report.`]}return t},_getArrow:function(e){switch(e){case`->`:return`\\yields`;case`→`:return`\\yields`;case`⟶`:return`\\yields`;case`<-`:return`\\yieldsLeft`;case`<->`:return`\\mesomerism`;case`<-->`:return`\\yieldsLeftRight`;case`<=>`:return`\\chemequilibrium`;case`⇌`:return`\\chemequilibrium`;case`<=>>`:return`\\equilibriumRight`;case`<<=>`:return`\\equilibriumLeft`;default:throw[`MhchemBugT`,`mhchem bug T. Please report.`]}},_getBond:function(e){switch(e){case`-`:return`{-}`;case`1`:return`{-}`;case`=`:return`{=}`;case`2`:return`{=}`;case`#`:return`{\\equiv}`;case`3`:return`{\\equiv}`;case`~`:return`{\\tripleDash}`;case`~-`:return`{\\tripleDashOverLine}`;case`~=`:return`{\\tripleDashOverDoubleLine}`;case`~--`:return`{\\tripleDashOverDoubleLine}`;case`-~-`:return`{\\tripleDashBetweenDoubleLine}`;case`...`:return`{{\\cdot}{\\cdot}{\\cdot}}`;case`....`:return`{{\\cdot}{\\cdot}{\\cdot}{\\cdot}}`;case`->`:return`{\\rightarrow}`;case`<-`:return`{\\leftarrow}`;case`<`:return`{<}`;case`>`:return`{>}`;default:throw[`MhchemBugT`,`mhchem bug T. Please report.`]}},_getOperator:function(e){switch(e){case`+`:return` {}+{} `;case`-`:return` {}-{} `;case`=`:return` {}={} `;case`<`:return` {}<{} `;case`>`:return` {}>{} `;case`<<`:return` {}\\ll{} `;case`>>`:return` {}\\gg{} `;case`\\pm`:return` {}\\pm{} `;case`\\approx`:return` {}\\approx{} `;case`$\\approx$`:return` {}\\approx{} `;case`v`:return` \\downarrow{} `;case`(v)`:return` \\downarrow{} `;case`^`:return` \\uparrow{} `;case`(^)`:return` \\uparrow{} `;default:throw[`MhchemBugT`,`mhchem bug T. Please report.`]}}};Q(`\\darr`,`\\downarrow`),Q(`\\dArr`,`\\Downarrow`),Q(`\\Darr`,`\\Downarrow`),Q(`\\lang`,`\\langle`),Q(`\\rang`,`\\rangle`),Q(`\\uarr`,`\\uparrow`),Q(`\\uArr`,`\\Uparrow`),Q(`\\Uarr`,`\\Uparrow`),Q(`\\N`,`\\mathbb{N}`),Q(`\\R`,`\\mathbb{R}`),Q(`\\Z`,`\\mathbb{Z}`),Q(`\\alef`,`\\aleph`),Q(`\\alefsym`,`\\aleph`),Q(`\\bull`,`\\bullet`),Q(`\\clubs`,`\\clubsuit`),Q(`\\cnums`,`\\mathbb{C}`),Q(`\\Complex`,`\\mathbb{C}`),Q(`\\Dagger`,`\\ddagger`),Q(`\\diamonds`,`\\diamondsuit`),Q(`\\empty`,`\\emptyset`),Q(`\\exist`,`\\exists`),Q(`\\harr`,`\\leftrightarrow`),Q(`\\hArr`,`\\Leftrightarrow`),Q(`\\Harr`,`\\Leftrightarrow`),Q(`\\hearts`,`\\heartsuit`),Q(`\\image`,`\\Im`),Q(`\\infin`,`\\infty`),Q(`\\isin`,`\\in`),Q(`\\larr`,`\\leftarrow`),Q(`\\lArr`,`\\Leftarrow`),Q(`\\Larr`,`\\Leftarrow`),Q(`\\lrarr`,`\\leftrightarrow`),Q(`\\lrArr`,`\\Leftrightarrow`),Q(`\\Lrarr`,`\\Leftrightarrow`),Q(`\\natnums`,`\\mathbb{N}`),Q(`\\plusmn`,`\\pm`),Q(`\\rarr`,`\\rightarrow`),Q(`\\rArr`,`\\Rightarrow`),Q(`\\Rarr`,`\\Rightarrow`),Q(`\\real`,`\\Re`),Q(`\\reals`,`\\mathbb{R}`),Q(`\\Reals`,`\\mathbb{R}`),Q(`\\sdot`,`\\cdot`),Q(`\\sect`,`\\S`),Q(`\\spades`,`\\spadesuit`),Q(`\\sub`,`\\subset`),Q(`\\sube`,`\\subseteq`),Q(`\\supe`,`\\supseteq`),Q(`\\thetasym`,`\\vartheta`),Q(`\\weierp`,`\\wp`),Q(`\\quantity`,`{\\left\\{ #1 \\right\\}}`),Q(`\\qty`,`{\\left\\{ #1 \\right\\}}`),Q(`\\pqty`,`{\\left( #1 \\right)}`),Q(`\\bqty`,`{\\left[ #1 \\right]}`),Q(`\\vqty`,`{\\left\\vert #1 \\right\\vert}`),Q(`\\Bqty`,`{\\left\\{ #1 \\right\\}}`),Q(`\\absolutevalue`,`{\\left\\vert #1 \\right\\vert}`),Q(`\\abs`,`{\\left\\vert #1 \\right\\vert}`),Q(`\\norm`,`{\\left\\Vert #1 \\right\\Vert}`),Q(`\\evaluated`,`{\\left.#1 \\right\\vert}`),Q(`\\eval`,`{\\left.#1 \\right\\vert}`),Q(`\\order`,`{\\mathcal{O} \\left( #1 \\right)}`),Q(`\\commutator`,`{\\left[ #1 , #2 \\right]}`),Q(`\\comm`,`{\\left[ #1 , #2 \\right]}`),Q(`\\anticommutator`,`{\\left\\{ #1 , #2 \\right\\}}`),Q(`\\acomm`,`{\\left\\{ #1 , #2 \\right\\}}`),Q(`\\poissonbracket`,`{\\left\\{ #1 , #2 \\right\\}}`),Q(`\\pb`,`{\\left\\{ #1 , #2 \\right\\}}`),Q(`\\vectorbold`,`{\\boldsymbol{ #1 }}`),Q(`\\vb`,`{\\boldsymbol{ #1 }}`),Q(`\\vectorarrow`,`{\\vec{\\boldsymbol{ #1 }}}`),Q(`\\va`,`{\\vec{\\boldsymbol{ #1 }}}`),Q(`\\vectorunit`,`{{\\boldsymbol{\\hat{ #1 }}}}`),Q(`\\vu`,`{{\\boldsymbol{\\hat{ #1 }}}}`),Q(`\\dotproduct`,`\\mathbin{\\boldsymbol\\cdot}`),Q(`\\vdot`,`{\\boldsymbol\\cdot}`),Q(`\\crossproduct`,`\\mathbin{\\boldsymbol\\times}`),Q(`\\cross`,`\\mathbin{\\boldsymbol\\times}`),Q(`\\cp`,`\\mathbin{\\boldsymbol\\times}`),Q(`\\gradient`,`{\\boldsymbol\\nabla}`),Q(`\\grad`,`{\\boldsymbol\\nabla}`),Q(`\\divergence`,`{\\grad\\vdot}`),Q(`\\curl`,`{\\grad\\cross}`),Q(`\\laplacian`,`\\nabla^2`),Q(`\\tr`,`{\\operatorname{tr}}`),Q(`\\Tr`,`{\\operatorname{Tr}}`),Q(`\\rank`,`{\\operatorname{rank}}`),Q(`\\erf`,`{\\operatorname{erf}}`),Q(`\\Res`,`{\\operatorname{Res}}`),Q(`\\principalvalue`,`{\\mathcal{P}}`),Q(`\\pv`,`{\\mathcal{P}}`),Q(`\\PV`,`{\\operatorname{P.V.}}`),Q(`\\qqtext`,`{\\quad\\text{ #1 }\\quad}`),Q(`\\qq`,`{\\quad\\text{ #1 }\\quad}`),Q(`\\qcomma`,`{\\text{,}\\quad}`),Q(`\\qc`,`{\\text{,}\\quad}`),Q(`\\qcc`,`{\\quad\\text{c.c.}\\quad}`),Q(`\\qif`,`{\\quad\\text{if}\\quad}`),Q(`\\qthen`,`{\\quad\\text{then}\\quad}`),Q(`\\qelse`,`{\\quad\\text{else}\\quad}`),Q(`\\qotherwise`,`{\\quad\\text{otherwise}\\quad}`),Q(`\\qunless`,`{\\quad\\text{unless}\\quad}`),Q(`\\qgiven`,`{\\quad\\text{given}\\quad}`),Q(`\\qusing`,`{\\quad\\text{using}\\quad}`),Q(`\\qassume`,`{\\quad\\text{assume}\\quad}`),Q(`\\qsince`,`{\\quad\\text{since}\\quad}`),Q(`\\qlet`,`{\\quad\\text{let}\\quad}`),Q(`\\qfor`,`{\\quad\\text{for}\\quad}`),Q(`\\qall`,`{\\quad\\text{all}\\quad}`),Q(`\\qeven`,`{\\quad\\text{even}\\quad}`),Q(`\\qodd`,`{\\quad\\text{odd}\\quad}`),Q(`\\qinteger`,`{\\quad\\text{integer}\\quad}`),Q(`\\qand`,`{\\quad\\text{and}\\quad}`),Q(`\\qor`,`{\\quad\\text{or}\\quad}`),Q(`\\qas`,`{\\quad\\text{as}\\quad}`),Q(`\\qin`,`{\\quad\\text{in}\\quad}`),Q(`\\differential`,`{\\text{d}}`),Q(`\\dd`,`{\\text{d}}`),Q(`\\derivative`,`{\\frac{\\text{d}{ #1 }}{\\text{d}{ #2 }}}`),Q(`\\dv`,`{\\frac{\\text{d}{ #1 }}{\\text{d}{ #2 }}}`),Q(`\\partialderivative`,`{\\frac{\\partial{ #1 }}{\\partial{ #2 }}}`),Q(`\\variation`,`{\\delta}`),Q(`\\var`,`{\\delta}`),Q(`\\functionalderivative`,`{\\frac{\\delta{ #1 }}{\\delta{ #2 }}}`),Q(`\\fdv`,`{\\frac{\\delta{ #1 }}{\\delta{ #2 }}}`),Q(`\\innerproduct`,`{\\left\\langle {#1} \\mid { #2} \\right\\rangle}`),Q(`\\outerproduct`,`{\\left\\vert { #1 } \\right\\rangle\\left\\langle { #2} \\right\\vert}`),Q(`\\dyad`,`{\\left\\vert { #1 } \\right\\rangle\\left\\langle { #2} \\right\\vert}`),Q(`\\ketbra`,`{\\left\\vert { #1 } \\right\\rangle\\left\\langle { #2} \\right\\vert}`),Q(`\\op`,`{\\left\\vert { #1 } \\right\\rangle\\left\\langle { #2} \\right\\vert}`),Q(`\\expectationvalue`,`{\\left\\langle {#1 } \\right\\rangle}`),Q(`\\expval`,`{\\left\\langle {#1 } \\right\\rangle}`),Q(`\\ev`,`{\\left\\langle {#1 } \\right\\rangle}`),Q(`\\matrixelement`,`{\\left\\langle{ #1 }\\right\\vert{ #2 }\\left\\vert{#3}\\right\\rangle}`),Q(`\\matrixel`,`{\\left\\langle{ #1 }\\right\\vert{ #2 }\\left\\vert{#3}\\right\\rangle}`),Q(`\\mel`,`{\\left\\langle{ #1 }\\right\\vert{ #2 }\\left\\vert{#3}\\right\\rangle}`);function Kw(e){let t=[];e.consumeSpaces();let n=e.fetch().text;for(n===`\\relax`&&(e.consume(),e.consumeSpaces(),n=e.fetch().text);n===`\\hline`||n===`\\hdashline`;)e.consume(),t.push(n===`\\hdashline`),e.consumeSpaces(),n=e.fetch().text;return t}var qw=e=>{if(!e.parser.settings.displayMode)throw new U(`{${e.envName}} can be used only in display mode.`)},Jw=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/,Yw=e=>{let t=e.get(`\\arraystretch`);typeof t!=`string`&&(t=Iw(t.tokens)),t=isNaN(t)?null:Number(t);let n=e.get(`\\arraycolsep`);typeof n!=`string`&&(n=Iw(n.tokens));let r=Jw.exec(n),i=r?{number:+(r[1]+r[2]),unit:r[3]}:null;return[t,i]},Xw=e=>{let t=``;for(let n=0;n<e.length;n++)if(e[n].type===`label`){if(t)throw new U(`Multiple \\labels in one row`);t=e[n].string}return t};function Zw(e){if(e.indexOf(`ed`)===-1)return e.indexOf(`*`)===-1}function Qw(e,{cols:t,envClasses:n,autoTag:r,singleRow:i,emptySingleRow:a,maxNumCols:o,leqno:s,arraystretch:c,arraycolsep:l},u){let d=n&&n.includes(`bordermatrix`)?`}`:`\\end`;e.gullet.beginGroup(),i||e.gullet.macros.set(`\\cr`,`\\\\\\relax`),e.gullet.beginGroup();let f=[],p=[f],m=[],h=[],g=[],_=r==null?void 0:[];function v(){r&&e.gullet.macros.set(`\\@eqnsw`,`1`,!0)}function y(){_&&(e.gullet.macros.get(`\\df@tag`)?(_.push(e.subparse([new Mw(`\\df@tag`)])),e.gullet.macros.set(`\\df@tag`,void 0,!0)):_.push(!!r&&e.gullet.macros.get(`\\@eqnsw`)===`1`))}for(v(),g.push(Kw(e));;){let t=e.parseExpression(!1,i?`\\end`:`\\\\`);e.gullet.endGroup(),e.gullet.beginGroup(),t={type:`ordgroup`,mode:e.mode,body:t,semisimple:!0},f.push(t);let r=e.fetch().text;if(r===`&`){if(o&&f.length===o){if(n.includes(`array`)){if(e.settings.strict)throw new U(`Too few columns specified in the {array} column argument.`,e.nextToken)}else if(o===2)throw new U(`The split environment accepts no more than two columns`,e.nextToken);else throw new U(`The equation environment accepts only one column`,e.nextToken)}e.consume()}else if(r===d){y(),f.length===1&&t.body.length===0&&(p.length>1||!a)&&p.pop(),h.push(Xw(t.body)),g.length<p.length+1&&g.push([]);break}else if(r===`\\\\`){e.consume();let n;e.gullet.future().text!==` `&&(n=e.parseSizeGroup(!0)),m.push(n?n.value:null),y(),h.push(Xw(t.body)),g.push(Kw(e)),f=[],p.push(f),v()}else throw new U(`Expected & or \\\\ or \\cr or `+d,e.nextToken)}return e.gullet.endGroup(),e.gullet.endGroup(),{type:`array`,mode:e.mode,body:p,cols:t,rowGaps:m,hLinesBeforeRow:g,envClasses:n,autoTag:r,scriptLevel:u,tags:_,labels:h,leqno:s,arraystretch:c,arraycolsep:l}}function $w(e){return e.slice(0,1)===`d`?`display`:`text`}var eT={c:`center `,l:`left `,r:`right `},tT=e=>{let t=new W(`mtd`,[]);return t.style={padding:`0`,width:`50%`},e.envClasses.includes(`multline`)&&(t.style.width=`7.5%`),t},nT=function(e,t){let n=[],r=e.body.length,i=e.hLinesBeforeRow,a=e.tags&&e.tags.some(e=>e);for(let o=0;o<r;o++){let s=e.body[o],c=[],l=e.scriptLevel===`text`?Nw.TEXT:e.scriptLevel===`script`?Nw.SCRIPT:Nw.DISPLAY;for(let n=0;n<s.length;n++){let i=new W(`mtd`,[JC(s[n],t.withLevel(l))]);if(e.envClasses.includes(`multline`)){let e=o===0?`left`:o===r-1?`right`:`center`;e!==`center`&&i.classes.push(`tml-`+e)}c.push(i)}let u=e.body[0].length;for(let e=0;e<u-s.length;e++)c.push(new W(`mtd`,[],[],t));if(a){let n=e.tags[o],r;n===!0?r=new W(`mtext`,[new uC([`tml-eqn`])]):n===!1?r=new W(`mtext`,[],[]):(r=qC(n[0].body,t.withLevel(l),!0),r=VC(r),r.classes=[`tml-tag`]),r&&(c.unshift(tT(e)),c.push(tT(e)),e.leqno?c[0].children.push(r):c[c.length-1].children.push(r))}let d=new W(`mtr`,c,[]),f=e.labels.shift();f&&e.tags&&e.tags[o]&&(d.setAttribute(`id`,f),Array.isArray(e.tags[o])&&d.classes.push(`tml-tageqn`)),o===0&&i[0].length>0&&(i[0].length===2?d.children.forEach(e=>{e.style.borderTop=`0.15em double`}):d.children.forEach(e=>{e.style.borderTop=i[0][0]?`0.06em dashed`:`0.06em solid`})),i[o+1].length>0&&(i[o+1].length===2?d.children.forEach(e=>{e.style.borderBottom=`0.15em double`}):d.children.forEach(e=>{e.style.borderBottom=i[o+1][0]?`0.06em dashed`:`0.06em solid`}));let p=!0;for(let e=0;e<d.children.length;e++){let t=d.children[e].children[0];if(!(t&&t.type===`mpadded`&&t.attributes.height===`0px`)){p=!1;break}}if(p){d.classes.push(`ff-squash`);for(let e=0;e<d.children.length;e++)d.children[e].style.paddingTop=`0`,d.children[e].style.paddingBottom=`0`}n.push(d)}if(e.arraystretch&&e.arraystretch!==1){let t=String(1.4*e.arraystretch-.8)+`ex`;for(let e=0;e<n.length;e++)for(let r=0;r<n[e].children.length;r++)n[e].children[r].style.paddingTop=t,n[e].children[r].style.paddingBottom=t}let o,s;if(e.envClasses.length>0&&(o=e.envClasses.includes(`abut`)||e.envClasses.includes(`cases`)?`0`:e.envClasses.includes(`small`)?`0.1389`:e.envClasses.includes(`cd`)?`0.25`:`0.4`,s=`em`),e.arraycolsep){let n=dw(e.arraycolsep,t);o=n.number.toFixed(4),s=n.unit}if(o){let t=n.length===0?0:n[0].children.length,r=(n,r)=>n===0&&r===0||n===t-1&&r===1?`0`:e.envClasses[0]===`align`?r===1?`0`:a?n%2?`1`:`0`:n%2?`0`:`1`:o;for(let e=0;e<n.length;e++)for(let t=0;t<n[e].children.length;t++)n[e].children[t].style.paddingLeft=`${r(t,0)}${s}`,n[e].children[t].style.paddingRight=`${r(t,1)}${s}`}if(e.envClasses.length===0)for(let e=0;e<n.length;e++)n[e].children[0].style.paddingLeft=`0em`,n[e].children.length===n[0].children.length&&(n[e].children[n[e].children.length-1].style.paddingRight=`0em`);if(e.envClasses.length>0){let t=e.envClasses.includes(`align`)||e.envClasses.includes(`alignat`);for(let r=0;r<n.length;r++){let i=n[r];if(t){for(let e=0;e<i.children.length;e++)i.children[e].classes=[`tml-`+(e%2?`left`:`right`)];if(a){let t=e.leqno?0:i.children.length-1;i.children[t].classes=[]}}if(i.children.length>1&&e.envClasses.includes(`cases`)&&(i.children[1].style.paddingLeft=`1em`),e.envClasses.includes(`cases`)||e.envClasses.includes(`subarray`))for(let e of i.children)e.classes.push(`tml-left`)}}let c=new W(`mtable`,n);if(e.envClasses.length>0&&(e.envClasses.includes(`jot`)?c.classes.push(`tml-jot`):e.envClasses.includes(`small`)&&c.classes.push(`tml-small`)),e.scriptLevel===`display`&&c.setAttribute(`displaystyle`,`true`),(e.autoTag||e.envClasses.includes(`multline`))&&(c.style.width=`100%`),e.cols&&e.cols.length>0){let t=e.cols,n=!1,r=0,i=t.length;for(;t[r].type===`separator`;)r+=1;for(;t[i-1].type===`separator`;)--i;if(t[0].type===`separator`){let e=t[1].type===`separator`?`0.15em double`:t[0].separator===`|`?`0.06em solid `:`0.06em dashed `;for(let t of c.children)t.children[0].style.borderLeft=e}let o=a?0:-1;for(let e=r;e<i;e++)if(t[e].type===`align`){let r=eT[t[e].align];o+=1;for(let e of c.children)r.trim()!==`center`&&o<e.children.length&&(e.children[o].classes=[`tml-`+r.trim()]);n=!0}else if(t[e].type===`separator`){if(n){let n=t[e+1].type===`separator`?`0.15em double`:t[e].separator===`|`?`0.06em solid`:`0.06em dashed`;for(let e of c.children)o<e.children.length&&(e.children[o].style.borderRight=n)}n=!1}if(t[t.length-1].type===`separator`){let e=t[t.length-2].type===`separator`?`0.15em double`:t[t.length-1].separator===`|`?`0.06em solid`:`0.06em dashed`;for(let t of c.children)t.children[t.children.length-1].style.borderRight=e,t.children[t.children.length-1].style.paddingRight=`0.4em`}}return e.envClasses.includes(`small`)&&(c=new W(`mstyle`,[c]),c.setAttribute(`scriptlevel`,`1`)),c},rT=function(e,t){e.envName.indexOf(`ed`)===-1&&qw(e);let n=e.envName===`split`,r=[],i=Qw(e.parser,{cols:r,emptySingleRow:!0,autoTag:n?void 0:Zw(e.envName),envClasses:[`abut`,`jot`],maxNumCols:e.envName===`split`?2:void 0,leqno:e.parser.settings.leqno},`display`),a,o=0,s=e.envName.indexOf(`at`)>-1;if(t[0]&&s){let e=``;for(let n=0;n<t[0].body.length;n++){let r=yw(t[0].body[n],`textord`);e+=r.text}if(isNaN(e))throw new U(`The alignat enviroment requires a numeric first argument.`);a=Number(e),o=a*2}i.body.forEach(function(e){if(s){let t=e.length/2;if(a<t)throw new U(`Too many math in a row: expected ${a}, but got ${t}`,e[0])}else o<e.length&&(o=e.length)});for(let e=0;e<o;++e){let t=`r`;e%2==1&&(t=`l`),r[e]={type:`align`,align:t}}return e.envName===`split`||(s?i.envClasses.push(`alignat`):i.envClasses[0]=`align`),i};vw({type:`array`,names:[`array`,`darray`],props:{numArgs:1},handler(e,t){let n=(xw(t[0])?[t[0]]:yw(t[0],`ordgroup`).body).map(function(e){let t=bw(e).text;if(`lcr`.indexOf(t)!==-1)return{type:`align`,align:t};if(t===`|`)return{type:`separator`,separator:`|`};if(t===`:`)return{type:`separator`,separator:`:`};throw new U(`Unknown column alignment: `+t,e)}),[r,i]=Yw(e.parser.gullet.macros),a={cols:n,envClasses:[`array`],maxNumCols:n.length,arraystretch:r,arraycolsep:i};return Qw(e.parser,a,$w(e.envName))},mathmlBuilder:nT}),vw({type:`array`,names:[`matrix`,`pmatrix`,`bmatrix`,`Bmatrix`,`vmatrix`,`Vmatrix`,`matrix*`,`pmatrix*`,`bmatrix*`,`Bmatrix*`,`vmatrix*`,`Vmatrix*`],props:{numArgs:0},handler(e){let t={matrix:null,pmatrix:[`(`,`)`],bmatrix:[`[`,`]`],Bmatrix:[`\\{`,`\\}`],vmatrix:[`|`,`|`],Vmatrix:[`\\Vert`,`\\Vert`]}[e.envName.replace(`*`,``)],n=`c`,r={envClasses:[],cols:[]};if(e.envName.charAt(e.envName.length-1)===`*`){let t=e.parser;if(t.consumeSpaces(),t.fetch().text===`[`){if(t.consume(),t.consumeSpaces(),n=t.fetch().text,`lcr`.indexOf(n)===-1)throw new U(`Expected l or c or r`,t.nextToken);t.consume(),t.consumeSpaces(),t.expect(`]`),t.consume(),r.cols=[]}}let i=Qw(e.parser,r,`text`);i.cols=i.body.length>0?Array(i.body[0].length).fill({type:`align`,align:n}):[];let[a,o]=Yw(e.parser.gullet.macros);return i.arraystretch=a,o&&(o!==6||o!==`pt`)&&(i.arraycolsep=o),t?{type:`leftright`,mode:e.mode,body:[i],left:t[0],right:t[1],rightColor:void 0}:i},mathmlBuilder:nT}),vw({type:`array`,names:[`bordermatrix`],props:{numArgs:0},handler(e){let t=Qw(e.parser,{cols:[],envClasses:[`bordermatrix`]},`text`);return t.cols=t.body.length>0?Array(t.body[0].length).fill({type:`align`,align:`c`}):[],t.envClasses=[],t.arraystretch=1,e.envName===`matrix`?t:Aw(t,e.delimiters)},mathmlBuilder:nT}),vw({type:`array`,names:[`smallmatrix`],props:{numArgs:0},handler(e){return Qw(e.parser,{envClasses:[`small`]},`script`)},mathmlBuilder:nT}),vw({type:`array`,names:[`subarray`],props:{numArgs:1},handler(e,t){let n=(xw(t[0])?[t[0]]:yw(t[0],`ordgroup`).body).map(function(e){let t=bw(e).text;if(`lc`.indexOf(t)!==-1)return{type:`align`,align:t};throw new U(`Unknown column alignment: `+t,e)});if(n.length>1)throw new U(`{subarray} can contain only one column`);let r={cols:n,envClasses:[`small`]};if(r=Qw(e.parser,r,`script`),r.body.length>0&&r.body[0].length>1)throw new U(`{subarray} can contain only one column`);return r},mathmlBuilder:nT}),vw({type:`array`,names:[`cases`,`dcases`,`rcases`,`drcases`],props:{numArgs:0},handler(e){let t=Qw(e.parser,{cols:[],envClasses:[`cases`]},$w(e.envName));return{type:`leftright`,mode:e.mode,body:[t],left:e.envName.indexOf(`r`)>-1?`.`:`\\{`,right:e.envName.indexOf(`r`)>-1?`\\}`:`.`,rightColor:void 0}},mathmlBuilder:nT}),vw({type:`array`,names:[`align`,`align*`,`aligned`,`split`],props:{numArgs:0},handler:rT,mathmlBuilder:nT}),vw({type:`array`,names:[`alignat`,`alignat*`,`alignedat`],props:{numArgs:1},handler:rT,mathmlBuilder:nT}),vw({type:`array`,names:[`gathered`,`gather`,`gather*`],props:{numArgs:0},handler(e){e.envName!==`gathered`&&qw(e);let t={cols:[],envClasses:[`abut`,`jot`],autoTag:Zw(e.envName),emptySingleRow:!0,leqno:e.parser.settings.leqno};return Qw(e.parser,t,`display`)},mathmlBuilder:nT}),vw({type:`array`,names:[`equation`,`equation*`],props:{numArgs:0},handler(e){qw(e);let t={autoTag:Zw(e.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,envClasses:[`align`],leqno:e.parser.settings.leqno};return Qw(e.parser,t,`display`)},mathmlBuilder:nT}),vw({type:`array`,names:[`multline`,`multline*`],props:{numArgs:0},handler(e){qw(e);let t={autoTag:e.envName===`multline`,maxNumCols:1,envClasses:[`jot`,`multline`],leqno:e.parser.settings.leqno};return Qw(e.parser,t,`display`)},mathmlBuilder:nT}),vw({type:`array`,names:[`CD`],props:{numArgs:0},handler(e){return qw(e),Dw(e.parser)},mathmlBuilder:nT}),tC({type:`text`,names:[`\\hline`,`\\hdashline`],props:{numArgs:0,allowedInText:!0,allowedInMath:!0},handler(e,t){throw new U(`${e.funcName} valid only within array environment`)}});var iT=_w;tC({type:`bordermatrix`,names:[`\\bordermatrix`,`\\matrix`],props:{numArgs:0,numOptionalArgs:1},handler:({parser:e,funcName:t},n,r)=>{let i=[`(`,`)`];if(t===`\\bordermatrix`&&r[0]&&r[0].body){let e=r[0].body;e.length===1&&e[0].type===`delimiter`&&(i=[e[0].left,e[0].right])}e.consumeSpaces(),e.consume();let a=iT.bordermatrix,o={mode:e.mode,envName:t.slice(1),delimiters:i,parser:e},s=a.handler(o);return e.expect(`}`,!0),s}}),tC({type:`cancelto`,names:[`\\cancelto`],props:{numArgs:2},handler({parser:e},t){let n=t[0],r=t[1];return{type:`cancelto`,mode:e.mode,body:r,to:n,isCharacterBox:GS(r)}},mathmlBuilder(e,t){let n=new W(`mrow`,[JC(e.body,t)],[`ff-narrow`]),r=new W(`mphantom`,[JC(e.body,t)]),i=new W(`mrow`,[r],[`tml-cancelto`]);i.style.color=t.color,e.isCharacterBox&&YS.indexOf(e.body.body[0].text)>-1&&(i.style.left=`0.1em`,i.style.width=`90%`);let a=new W(`mrow`,[n,i],[`menclose`]);if(!e.isCharacterBox||/[f∫∑]/.test(e.body.body[0].text))r.style.paddingRight=`0.2em`;else{r.style.padding=`0.5ex 0.1em 0 0`;let e=new W(`mspace`,[]);e.setAttribute(`height`,`0.85em`),n.children.push(e)}let o;if(e.isCharacterBox)o=new W(`mspace`,[]),o.setAttribute(`height`,`1em`);else{let n=new W(`mpadded`,[JC(e.body,t)]);n.setAttribute(`width`,`0.1px`),o=new W(`mphantom`,[n])}let s=JC(e.to,t);s.style.color=t.color;let c=new W(`mpadded`,[s]);if(!e.isCharacterBox||/[f∫∑]/.test(e.body.body[0].text)){let e=new W(`mspace`,[]);e.setAttribute(`width`,`0.2em`),c.children.unshift(e)}c.setAttribute(`width`,`0.1px`);let l=new W(`mover`,[o,c]),u=new W(`mrow`,[],[`ff-nudge-left`]);return mC([HC([a,l]),u])}}),tC({type:`textord`,names:[`\\@char`],props:{numArgs:1,allowedInText:!0},handler({parser:e,token:t},n){let r=yw(n[0],`ordgroup`).body,i=``;for(let e=0;e<r.length;e++){let t=yw(r[e],`textord`);i+=t.text}let a=parseInt(i);if(isNaN(a))throw new U(`\\@char has non-numeric argument ${i}`,t);return{type:`textord`,mode:e.mode,text:String.fromCodePoint(a)}}});var aT=/^(#[a-f0-9]{3}|#?[a-f0-9]{6})$/i,oT=/^(#[a-f0-9]{3}|#?[a-f0-9]{6}|[a-z]+)$/i,sT=/^ *\d{1,3} *(?:, *\d{1,3} *){2}$/,cT=/^ *[10](?:\.\d*)? *(?:, *[10](?:\.\d*)? *){2}$/,lT=/^[a-f0-9]{6}$/i,uT=e=>{let t=e.toString(16);return t.length===1&&(t=`0`+t),t},dT=JSON.parse(`{
57
+ "Apricot": "#ffb484",
58
+ "Aquamarine": "#08b4bc",
59
+ "Bittersweet": "#c84c14",
60
+ "blue": "#0000FF",
61
+ "Blue": "#303494",
62
+ "BlueGreen": "#08b4bc",
63
+ "BlueViolet": "#503c94",
64
+ "BrickRed": "#b8341c",
65
+ "brown": "#BF8040",
66
+ "Brown": "#802404",
67
+ "BurntOrange": "#f8941c",
68
+ "CadetBlue": "#78749c",
69
+ "CarnationPink": "#f884b4",
70
+ "Cerulean": "#08a4e4",
71
+ "CornflowerBlue": "#40ace4",
72
+ "cyan": "#00FFFF",
73
+ "Cyan": "#08acec",
74
+ "Dandelion": "#ffbc44",
75
+ "darkgray": "#404040",
76
+ "DarkOrchid": "#a8548c",
77
+ "Emerald": "#08ac9c",
78
+ "ForestGreen": "#089c54",
79
+ "Fuchsia": "#90348c",
80
+ "Goldenrod": "#ffdc44",
81
+ "gray": "#808080",
82
+ "Gray": "#98949c",
83
+ "green": "#00FF00",
84
+ "Green": "#08a44c",
85
+ "GreenYellow": "#e0e474",
86
+ "JungleGreen": "#08ac9c",
87
+ "Lavender": "#f89cc4",
88
+ "lightgray": "#c0c0c0",
89
+ "lime": "#BFFF00",
90
+ "LimeGreen": "#90c43c",
91
+ "magenta": "#FF00FF",
92
+ "Magenta": "#f0048c",
93
+ "Mahogany": "#b0341c",
94
+ "Maroon": "#b03434",
95
+ "Melon": "#f89c7c",
96
+ "MidnightBlue": "#086494",
97
+ "Mulberry": "#b03c94",
98
+ "NavyBlue": "#086cbc",
99
+ "olive": "#7F7F00",
100
+ "OliveGreen": "#407c34",
101
+ "orange": "#FF8000",
102
+ "Orange": "#f8843c",
103
+ "OrangeRed": "#f0145c",
104
+ "Orchid": "#b074ac",
105
+ "Peach": "#f8945c",
106
+ "Periwinkle": "#8074bc",
107
+ "PineGreen": "#088c74",
108
+ "pink": "#ff7f7f",
109
+ "Plum": "#98248c",
110
+ "ProcessBlue": "#08b4ec",
111
+ "purple": "#BF0040",
112
+ "Purple": "#a0449c",
113
+ "RawSienna": "#983c04",
114
+ "red": "#ff0000",
115
+ "Red": "#f01c24",
116
+ "RedOrange": "#f86434",
117
+ "RedViolet": "#a0246c",
118
+ "Rhodamine": "#f0549c",
119
+ "Royallue": "#0874bc",
120
+ "RoyalPurple": "#683c9c",
121
+ "RubineRed": "#f0047c",
122
+ "Salmon": "#f8948c",
123
+ "SeaGreen": "#30bc9c",
124
+ "Sepia": "#701404",
125
+ "SkyBlue": "#48c4dc",
126
+ "SpringGreen": "#c8dc64",
127
+ "Tan": "#e09c74",
128
+ "teal": "#007F7F",
129
+ "TealBlue": "#08acb4",
130
+ "Thistle": "#d884b4",
131
+ "Turquoise": "#08b4cc",
132
+ "violet": "#800080",
133
+ "Violet": "#60449c",
134
+ "VioletRed": "#f054a4",
135
+ "WildStrawberry": "#f0246c",
136
+ "yellow": "#FFFF00",
137
+ "Yellow": "#fff404",
138
+ "YellowGreen": "#98cc6c",
139
+ "YellowOrange": "#ffa41c"
140
+ }`),fT=(e,t)=>{let n=``;if(e===`HTML`){if(!aT.test(t))throw new U(`Invalid HTML input.`);n=t}else if(e===`RGB`){if(!sT.test(t))throw new U(`Invalid RGB input.`);t.split(`,`).map(e=>{n+=uT(Number(e.trim()))})}else{if(!cT.test(t))throw new U(`Invalid rbg input.`);t.split(`,`).map(e=>{let t=Number(e.trim());if(t>1)throw new U(`Color rgb input must be < 1.`);n+=uT(Number((t*255).toFixed(0)))})}return n.charAt(0)!==`#`&&(n=`#`+n),n},pT=(e,t,n)=>{let r=`\\\\color@${e}`;if(!oT.exec(e))throw new U(`Invalid color: '`+e+`'`,n);return lT.test(e)?`#`+e:(e.charAt(0)===`#`||(t.has(r)?e=t.get(r).tokens[0].text:dT[e]&&(e=dT[e])),e)},mT=(e,t)=>{let n=KC(e.body,t.withColor(e.color));return n.length===0&&n.push(new W(`mrow`)),n=n.map(t=>(t.style.color=e.color,t)),mC(n)};tC({type:`color`,names:[`\\textcolor`],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,argTypes:[`raw`,`raw`,`original`]},handler({parser:e,token:t},n,r){let i=r[0]&&yw(r[0],`raw`).string,a=``;if(i){let e=yw(n[0],`raw`).string;a=fT(i,e)}else a=pT(yw(n[0],`raw`).string,e.gullet.macros,t);let o=n[1];return{type:`color`,mode:e.mode,color:a,isTextColor:!0,body:iC(o)}},mathmlBuilder:mT}),tC({type:`color`,names:[`\\color`],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0,argTypes:[`raw`,`raw`]},handler({parser:e,breakOnTokenText:t,token:n},r,i){let a=i[0]&&yw(i[0],`raw`).string,o=``;if(a){let e=yw(r[0],`raw`).string;o=fT(a,e)}else o=pT(yw(r[0],`raw`).string,e.gullet.macros,n);let s=e.parseExpression(!0,t,!0);return{type:`color`,mode:e.mode,color:o,isTextColor:!1,body:s}},mathmlBuilder:mT}),tC({type:`color`,names:[`\\definecolor`],props:{numArgs:3,allowedInText:!0,argTypes:[`raw`,`raw`,`raw`]},handler({parser:e,funcName:t,token:n},r){let i=yw(r[0],`raw`).string;if(!/^[A-Za-z]+$/.test(i))throw new U(`Color name must be latin letters.`,n);let a=yw(r[1],`raw`).string;if(![`HTML`,`RGB`,`rgb`].includes(a))throw new U(`Color model must be HTML, RGB, or rgb.`,n);let o=yw(r[2],`raw`).string,s=fT(a,o);return e.gullet.macros.set(`\\\\color@${i}`,{tokens:[{text:s}],numArgs:0}),{type:`internal`,mode:e.mode}}}),tC({type:`cr`,names:[`\\\\`],props:{numArgs:0,numOptionalArgs:0,allowedInText:!0},handler({parser:e},t,n){let r=e.gullet.future().text===`[`?e.parseSizeGroup(!0):null,i=!e.settings.displayMode;return{type:`cr`,mode:e.mode,newLine:i,size:r&&yw(r,`size`).value}},mathmlBuilder(e,t){let n=new W(`mo`);if(e.newLine&&(n.setAttribute(`linebreak`,`newline`),e.size)){let r=dw(e.size,t);n.setAttribute(`height`,r.number+r.unit)}return n}});var hT={"\\global":`\\global`,"\\long":`\\\\globallong`,"\\\\globallong":`\\\\globallong`,"\\def":`\\gdef`,"\\gdef":`\\gdef`,"\\edef":`\\xdef`,"\\xdef":`\\xdef`,"\\let":`\\\\globallet`,"\\futurelet":`\\\\globalfuture`},gT=e=>{let t=e.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(t))throw new U(`Expected a control sequence`,e);return t},_T=e=>{let t=e.gullet.popToken();return t.text===`=`&&(t=e.gullet.popToken(),t.text===` `&&(t=e.gullet.popToken())),t},vT=(e,t,n,r)=>{let i=e.gullet.macros.get(n.text);i??=(n.noexpand=!0,{tokens:[n],numArgs:0,unexpandable:!e.gullet.isExpandable(n.text)}),e.gullet.macros.set(t,i,r)};tC({type:`internal`,names:[`\\global`,`\\long`,`\\\\globallong`],props:{numArgs:0,allowedInText:!0},handler({parser:e,funcName:t}){e.consumeSpaces();let n=e.fetch();if(hT[n.text])return(t===`\\global`||t===`\\\\globallong`)&&(n.text=hT[n.text]),yw(e.parseFunction(),`internal`);throw new U(`Invalid token after macro prefix`,n)}}),tC({type:`internal`,names:[`\\def`,`\\gdef`,`\\edef`,`\\xdef`],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){let n=e.gullet.popToken(),r=n.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(r))throw new U(`Expected a control sequence`,n);let i=0,a,o=[[]];for(;e.gullet.future().text!==`{`;)if(n=e.gullet.popToken(),n.text===`#`){if(e.gullet.future().text===`{`){a=e.gullet.future(),o[i].push(`{`);break}if(n=e.gullet.popToken(),!/^[1-9]$/.test(n.text))throw new U(`Invalid argument number "${n.text}"`);if(parseInt(n.text)!==i+1)throw new U(`Argument number "${n.text}" out of order`);i++,o.push([])}else if(n.text===`EOF`)throw new U(`Expected a macro definition`);else o[i].push(n.text);let{tokens:s}=e.gullet.consumeArg();if(a&&s.unshift(a),t===`\\edef`||t===`\\xdef`){if(s=e.gullet.expandTokens(s),s.length>e.gullet.settings.maxExpand)throw new U(`Too many expansions in an `+t);s.reverse()}return e.gullet.macros.set(r,{tokens:s,numArgs:i,delimiters:o},t===hT[t]),{type:`internal`,mode:e.mode}}}),tC({type:`internal`,names:[`\\let`,`\\\\globallet`],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){let n=gT(e.gullet.popToken());return e.gullet.consumeSpaces(),vT(e,n,_T(e),t===`\\\\globallet`),{type:`internal`,mode:e.mode}}}),tC({type:`internal`,names:[`\\futurelet`,`\\\\globalfuture`],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){let n=gT(e.gullet.popToken()),r=e.gullet.popToken(),i=e.gullet.popToken();return vT(e,n,i,t===`\\\\globalfuture`),e.gullet.pushToken(i),e.gullet.pushToken(r),{type:`internal`,mode:e.mode}}}),tC({type:`internal`,names:[`\\newcommand`,`\\renewcommand`,`\\providecommand`],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){let n=``,r=e.gullet.popToken();r.text===`{`?(n=gT(e.gullet.popToken()),e.gullet.popToken()):n=gT(r);let i=e.gullet.isDefined(n);if(i&&t===`\\newcommand`)throw new U(`\\newcommand{${n}} attempting to redefine ${n}; use \\renewcommand`);if(!i&&t===`\\renewcommand`)throw new U(`\\renewcommand{${n}} when command ${n} does not yet exist; use \\newcommand`);let a=0;if(e.gullet.future().text===`[`){let t=e.gullet.popToken();if(t=e.gullet.popToken(),!/^[0-9]$/.test(t.text))throw new U(`Invalid number of arguments: "${t.text}"`);if(a=parseInt(t.text),t=e.gullet.popToken(),t.text!==`]`)throw new U(`Invalid argument "${t.text}"`)}let{tokens:o}=e.gullet.consumeArg();return t===`\\providecommand`&&e.gullet.macros.has(n)||e.gullet.macros.set(n,{tokens:o,numArgs:a}),{type:`internal`,mode:e.mode}}});var yT={"\\bigl":{mclass:`mopen`,size:1},"\\Bigl":{mclass:`mopen`,size:2},"\\biggl":{mclass:`mopen`,size:3},"\\Biggl":{mclass:`mopen`,size:4},"\\bigr":{mclass:`mclose`,size:1},"\\Bigr":{mclass:`mclose`,size:2},"\\biggr":{mclass:`mclose`,size:3},"\\Biggr":{mclass:`mclose`,size:4},"\\bigm":{mclass:`mrel`,size:1},"\\Bigm":{mclass:`mrel`,size:2},"\\biggm":{mclass:`mrel`,size:3},"\\Biggm":{mclass:`mrel`,size:4},"\\big":{mclass:`mord`,size:1},"\\Big":{mclass:`mord`,size:2},"\\bigg":{mclass:`mord`,size:3},"\\Bigg":{mclass:`mord`,size:4}},bT={"(":`)`,"\\lparen":`\\rparen`,"[":`]`,"\\lbrack":`\\rbrack`,"\\{":`\\}`,"\\lbrace":`\\rbrace`,"⦇":`⦈`,"\\llparenthesis":`\\rrparenthesis`,"\\lfloor":`\\rfloor`,"⌊":`⌋`,"\\lceil":`\\rceil`,"⌈":`⌉`,"\\langle":`\\rangle`,"⟨":`⟩`,"\\lAngle":`\\rAngle`,"⟪":`⟫`,"\\llangle":`\\rrangle`,"⦉":`⦊`,"\\lvert":`\\rvert`,"\\lVert":`\\rVert`,"\\lgroup":`\\rgroup`,"⟮":`⟯`,"\\lmoustache":`\\rmoustache`,"⎰":`⎱`,"\\llbracket":`\\rrbracket`,"⟦":`⟧`,"\\lBrace":`\\rBrace`,"⦃":`⦄`},xT=new Set(Object.keys(bT));new Set(Object.values(bT));var ST=new Set(`(,\\lparen,),\\rparen,[,\\lbrack,],\\rbrack,\\{,\\lbrace,\\},\\rbrace,⦇,\\llparenthesis,⦈,\\rrparenthesis,\\lfloor,\\rfloor,⌊,⌋,\\lceil,\\rceil,⌈,⌉,<,>,\\langle,⟨,\\rangle,⟩,\\lAngle,⟪,\\rAngle,⟫,\\llangle,⦉,\\rrangle,⦊,\\lt,\\gt,\\lvert,\\rvert,\\lVert,\\rVert,\\lgroup,\\rgroup,⟮,⟯,\\lmoustache,\\rmoustache,⎰,⎱,\\llbracket,\\rrbracket,⟦,⟧,\\lBrace,\\rBrace,⦃,⦄,/,\\backslash,|,\\vert,\\|,\\Vert,‖,\\uparrow,\\Uparrow,\\downarrow,\\Downarrow,\\updownarrow,\\Updownarrow,.`.split(`,`)),CT=new Set([`}`,`\\left`,`\\middle`,`\\right`]),wT=e=>e.length>0&&(ST.has(e)||yT[e]||CT.has(e)),TT=[0,1.2,1.8,2.4,3];function ET(e,t){e.type===`ordgroup`&&e.body.length===1&&(e=e.body[0]);let n=xw(e);if(n&&ST.has(n.text))return(n.text===`<`||n.text===`\\lt`)&&(n.text=`⟨`),(n.text===`>`||n.text===`\\gt`)&&(n.text=`⟩`),n;throw n?new U(`Invalid delimiter '${n.text}' after '${t.funcName}'`,e):new U(`Invalid delimiter type '${e.type}'`,e)}var DT=new Set([`/`,`\\`,`\\backslash`,`∖`,`\\vert`,`|`]),OT=(e,t,n,r)=>{let i=new W(`mo`,[zC(e===`.`?``:e,t)]);return i.setAttribute(`fence`,`true`),i.setAttribute(`form`,n),i.setAttribute(`stretchy`,r?`true`:`false`),i};tC({type:`delimsizing`,names:[`\\bigl`,`\\Bigl`,`\\biggl`,`\\Biggl`,`\\bigr`,`\\Bigr`,`\\biggr`,`\\Biggr`,`\\bigm`,`\\Bigm`,`\\biggm`,`\\Biggm`,`\\big`,`\\Big`,`\\bigg`,`\\Bigg`],props:{numArgs:1,argTypes:[`primitive`]},handler:(e,t)=>{let n=ET(t[0],e),r={type:`delimsizing`,mode:e.parser.mode,size:yT[e.funcName].size,mclass:yT[e.funcName].mclass,delim:n.text},i=e.parser.fetch().text;return i!==`^`&&i!==`_`?r:{type:`ordgroup`,mode:`math`,body:[r,{type:`ordgroup`,mode:`math`,body:[]}]}},mathmlBuilder:e=>{let t=[],n=e.delim===`.`?``:e.delim;t.push(zC(n,e.mode));let r=new W(`mo`,t);return e.mclass===`mopen`||e.mclass===`mclose`?r.setAttribute(`fence`,`true`):r.setAttribute(`fence`,`false`),(DT.has(n)||n.indexOf(`arrow`)>-1)&&r.setAttribute(`stretchy`,`true`),r.setAttribute(`symmetric`,`true`),r.setAttribute(`minsize`,TT[e.size]+`em`),r.setAttribute(`maxsize`,TT[e.size]+`em`),r}});function kT(e){if(!e.body)throw Error(`Bug: The delim ParseNode wasn't fully parsed.`)}tC({type:`leftright-right`,names:[`\\right`],props:{numArgs:1,argTypes:[`primitive`]},handler:(e,t)=>({type:`leftright-right`,mode:e.parser.mode,delim:ET(t[0],e).text})}),tC({type:`leftright`,names:[`\\left`],props:{numArgs:1,argTypes:[`primitive`]},handler:(e,t)=>{let n=ET(t[0],e),r=e.parser;++r.leftrightDepth;let i=r.parseExpression(!1,`\\right`,!0),a=r.fetch();for(;a.text===`\\middle`;){r.consume();let e=r.fetch().text;if(!wC.math[e])throw new U(`Invalid delimiter '${e}' after '\\middle'`);ET({type:`atom`,mode:`math`,text:e},{funcName:`\\middle`}),i.push({type:`middle`,mode:`math`,delim:e}),r.consume(),i=i.concat(r.parseExpression(!1,`\\right`,!0)),a=r.fetch()}--r.leftrightDepth,r.expect(`\\right`,!1);let o=yw(r.parseFunction(),`leftright-right`);return{type:`leftright`,mode:r.mode,body:i,left:n.text,right:o.delim,isStretchy:!0}},mathmlBuilder:(e,t)=>{kT(e);let n=KC(e.body,t),r=OT(e.left,e.mode,`prefix`,!0);n.unshift(r);let i=OT(e.right,e.mode,`postfix`,!0);if(e.body.length>0){let t=e.body[e.body.length-1];t.type===`color`&&!t.isTextColor&&i.setAttribute(`mathcolor`,t.color)}return n.push(i),HC(n)}}),tC({type:`delimiter`,names:Array.from(xT),props:{numArgs:0,allowedInText:!0,allowedInMath:!0,allowedInArgument:!0},handler:({parser:e,funcName:t,token:n})=>{if(e.mode===`text`)return{type:`textord`,mode:`text`,text:t,loc:n.loc};if(!e.settings.wrapDelimiterPairs)return{type:`atom`,mode:`math`,family:`open`,loc:n.loc,text:t};let r=bT[t],i=e.parseExpression(!1,r,!1);if(e.fetch().text!==r)throw new U(`Unmatched delimiter`);return e.consume(),{type:`delimiter`,mode:e.mode,body:i,left:t,right:r}},mathmlBuilder:(e,t)=>{kT(e);let n=KC(e.body,t),r=OT(e.left,e.mode,`prefix`,!1);n.unshift(r);let i=OT(e.right,e.mode,`postfix`,!1);if(e.body.length>0){let t=e.body[e.body.length-1];t.type===`color`&&!t.isTextColor&&i.setAttribute(`mathcolor`,t.color)}return n.push(i),HC(n)}}),tC({type:`middle`,names:[`\\middle`],props:{numArgs:1,argTypes:[`primitive`]},handler:(e,t)=>{let n=ET(t[0],e);if(!e.parser.leftrightDepth)throw new U(`\\middle without preceding \\left`,n);return{type:`middle`,mode:e.parser.mode,delim:n.text}},mathmlBuilder:e=>{let t=zC(e.delim,e.mode),n=new W(`mo`,[t]);return n.setAttribute(`stretchy`,`true`),n.setAttribute(`form`,`infix`),t.text!==`/`&&(n.setAttribute(`lspace`,`0.05em`),n.setAttribute(`rspace`,`0.05em`)),n}});var AT=[`\\boxed`,`\\fcolorbox`,`\\colorbox`],jT=(e,t)=>{let n=new W(AT.includes(e.label)?`mrow`:`menclose`,[JC(e.body,t)]);switch(e.label){case`\\overline`:n.setAttribute(`notation`,`top`),n.classes.push(`tml-overline`);break;case`\\underline`:n.setAttribute(`notation`,`bottom`),n.classes.push(`tml-underline`);break;case`\\cancel`:n.setAttribute(`notation`,`updiagonalstrike`),n.children.push(new W(`mrow`,[],[`tml-cancel`,`upstrike`]));break;case`\\bcancel`:n.setAttribute(`notation`,`downdiagonalstrike`),n.children.push(new W(`mrow`,[],[`tml-cancel`,`downstrike`]));break;case`\\sout`:n.setAttribute(`notation`,`horizontalstrike`),n.children.push(new W(`mrow`,[],[`tml-cancel`,`sout`]));break;case`\\xcancel`:n.setAttribute(`notation`,`updiagonalstrike downdiagonalstrike`),n.children.push(new W(`mrow`,[],[`tml-cancel`,`tml-xcancel`]));break;case`\\longdiv`:n.setAttribute(`notation`,`longdiv`),n.classes.push(`longdiv-top`),n.children.push(new W(`mrow`,[],[`longdiv-arc`]));break;case`\\phase`:n.setAttribute(`notation`,`phasorangle`),n.classes.push(`phasor-bottom`),n.children.push(new W(`mrow`,[],[`phasor-angle`]));break;case`\\textcircled`:n.setAttribute(`notation`,`circle`),n.classes.push(`circle-pad`),n.children.push(new W(`mrow`,[],[`textcircle`]));break;case`\\angl`:n.setAttribute(`notation`,`actuarial`),n.classes.push(`actuarial`);break;case`\\boxed`:n.style.padding=`3pt`,n.style.border=`1px solid`,n.setAttribute(`scriptlevel`,`0`),n.setAttribute(`displaystyle`,`true`);break;case`\\fbox`:n.setAttribute(`notation`,`box`),n.classes.push(`tml-fbox`);break;case`\\fcolorbox`:case`\\colorbox`:n.style.padding=`0.3em`,e.label===`\\fcolorbox`&&(n.style.border=`0.0667em solid `+String(e.borderColor))}return e.backgroundColor&&n.setAttribute(`mathbackground`,e.backgroundColor),n};tC({type:`enclose`,names:[`\\colorbox`],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,argTypes:[`raw`,`raw`,`text`]},handler({parser:e,funcName:t},n,r){let i=r[0]&&yw(r[0],`raw`).string,a=``;if(i){let e=yw(n[0],`raw`).string;a=fT(i,e)}else a=pT(yw(n[0],`raw`).string,e.gullet.macros);let o=n[1];return{type:`enclose`,mode:e.mode,label:t,backgroundColor:a,body:o}},mathmlBuilder:jT}),tC({type:`enclose`,names:[`\\fcolorbox`],props:{numArgs:3,numOptionalArgs:1,allowedInText:!0,argTypes:[`raw`,`raw`,`raw`,`text`]},handler({parser:e,funcName:t},n,r){let i=r[0]&&yw(r[0],`raw`).string,a=``,o;if(i){let e=yw(n[0],`raw`).string,t=yw(n[0],`raw`).string;a=fT(i,e),o=fT(i,t)}else a=pT(yw(n[0],`raw`).string,e.gullet.macros),o=pT(yw(n[1],`raw`).string,e.gullet.macros);let s=n[2];return{type:`enclose`,mode:e.mode,label:t,backgroundColor:o,borderColor:a,body:s}},mathmlBuilder:jT}),tC({type:`enclose`,names:[`\\fbox`],props:{numArgs:1,argTypes:[`hbox`],allowedInText:!0},handler({parser:e},t){return{type:`enclose`,mode:e.mode,label:`\\fbox`,body:t[0]}}}),tC({type:`enclose`,names:[`\\angl`,`\\cancel`,`\\bcancel`,`\\xcancel`,`\\overline`,`\\boxed`,`\\longdiv`,`\\phase`],props:{numArgs:1},handler({parser:e,funcName:t},n){let r=n[0];return{type:`enclose`,mode:e.mode,label:t,body:r}},mathmlBuilder:jT}),tC({type:`enclose`,names:[`\\sout`],props:{numArgs:1,allowedInText:!0},handler({parser:e,funcName:t},n){let r=n[0];return{type:`enclose`,mode:e.mode,label:t,body:r}},mathmlBuilder:jT}),tC({type:`enclose`,names:[`\\underline`],props:{numArgs:1,allowedInText:!0},handler({parser:e,funcName:t},n){let r=n[0];return{type:`enclose`,mode:e.mode,label:t,body:r}},mathmlBuilder:jT}),tC({type:`enclose`,names:[`\\textcircled`],props:{numArgs:1,argTypes:[`text`],allowedInArgument:!0,allowedInText:!0},handler({parser:e,funcName:t},n){let r=n[0];return{type:`enclose`,mode:e.mode,label:t,body:r}},mathmlBuilder:jT}),tC({type:`environment`,names:[`\\begin`,`\\end`],props:{numArgs:1,argTypes:[`text`]},handler({parser:e,funcName:t},n){let r=n[0];if(r.type!==`ordgroup`)throw new U(`Invalid environment name`,r);let i=``;for(let e=0;e<r.body.length;++e)i+=yw(r.body[e],`textord`).text;if(t===`\\begin`){if(!Object.prototype.hasOwnProperty.call(iT,i))throw new U(`No such environment: `+i,r);let t=iT[i],{args:n,optArgs:a}=e.parseArguments(`\\begin{`+i+`}`,t),o={mode:e.mode,envName:i,parser:e},s=t.handler(o,n,a);e.expect(`\\end`,!1);let c=e.nextToken,l=yw(e.parseFunction(),`environment`);if(l.name!==i)throw new U(`Mismatch: \\begin{${i}} matched by \\end{${l.name}}`,c);return s}return{type:`environment`,mode:e.mode,name:i,nameGroup:r}}}),tC({type:`envTag`,names:[`\\env@tag`],props:{numArgs:1,argTypes:[`math`]},handler({parser:e},t){return{type:`envTag`,mode:e.mode,body:t[0]}},mathmlBuilder(e,t){return new W(`mrow`)}}),tC({type:`noTag`,names:[`\\env@notag`],props:{numArgs:0},handler({parser:e}){return{type:`noTag`,mode:e.mode}},mathmlBuilder(e,t){return new W(`mrow`)}});var MT=Object.freeze({B:8426,E:8427,F:8427,H:8387,I:8391,L:8390,M:8422,R:8393,e:8394,g:8355,o:8389}),NT=Object.freeze({C:8426,H:8388,I:8392,R:8394,Z:8398}),PT=Object.freeze({C:8383,H:8389,N:8391,P:8393,Q:8393,R:8395,Z:8394}),FT=Object.freeze({ϵ:119527,ϑ:119564,ϰ:119534,φ:119577,ϱ:119535,ϖ:119563}),IT=Object.freeze({ϵ:119643,ϑ:119680,ϰ:119650,φ:119693,ϱ:119651,ϖ:119679}),LT=Object.freeze({ϵ:119701,ϑ:119738,ϰ:119708,φ:119751,ϱ:119709,ϖ:119737}),RT=Object.freeze({ϵ:119759,ϑ:119796,ϰ:119766,φ:119809,ϱ:119767,ϖ:119795}),zT=Object.freeze({upperCaseLatin:{normal:e=>0,bold:e=>119743,italic:e=>119795,"bold-italic":e=>119847,script:e=>MT[e]||119899,"script-bold":e=>119951,fraktur:e=>NT[e]||120003,"fraktur-bold":e=>120107,"double-struck":e=>PT[e]||120055,"sans-serif":e=>120159,"sans-serif-bold":e=>120211,"sans-serif-italic":e=>120263,"sans-serif-bold-italic":e=>120380,monospace:e=>120367},lowerCaseLatin:{normal:e=>0,bold:e=>119737,italic:e=>e===`h`?8358:119789,"bold-italic":e=>119841,script:e=>MT[e]||119893,"script-bold":e=>119945,fraktur:e=>119997,"fraktur-bold":e=>120101,"double-struck":e=>120049,"sans-serif":e=>120153,"sans-serif-bold":e=>120205,"sans-serif-italic":e=>120257,"sans-serif-bold-italic":e=>120309,monospace:e=>120361},upperCaseGreek:{normal:e=>0,bold:e=>119575,italic:e=>119633,"bold-italic":e=>119575,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>0,"sans-serif":e=>119749,"sans-serif-bold":e=>119749,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>119807,monospace:e=>0},lowerCaseGreek:{normal:e=>0,bold:e=>119569,italic:e=>119627,"bold-italic":e=>e===`ϕ`?119678:119685,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>0,"sans-serif":e=>119743,"sans-serif-bold":e=>119743,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>119801,monospace:e=>0},varGreek:{normal:e=>0,bold:e=>FT[e]||-51,italic:e=>0,"bold-italic":e=>IT[e]||58,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>0,"sans-serif":e=>LT[e]||116,"sans-serif-bold":e=>LT[e]||116,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>RT[e]||174,monospace:e=>0},numeral:{normal:e=>0,bold:e=>120734,italic:e=>0,"bold-italic":e=>0,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>120744,"sans-serif":e=>120754,"sans-serif-bold":e=>120764,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>0,monospace:e=>120774}}),BT=(e,t)=>{let n=e.codePointAt(0),r=64<n&&n<91?`upperCaseLatin`:96<n&&n<123?`lowerCaseLatin`:912<n&&n<938?`upperCaseGreek`:944<n&&n<970||e===`ϕ`?`lowerCaseGreek`:120545<n&&n<120572||FT[e]?`varGreek`:47<n&&n<58?`numeral`:`other`;return r===`other`?e:String.fromCodePoint(n+zT[r][t](e))},VT=Object.freeze({a:`ᴀ`,b:`ʙ`,c:`ᴄ`,d:`ᴅ`,e:`ᴇ`,f:`ꜰ`,g:`ɢ`,h:`ʜ`,i:`ɪ`,j:`ᴊ`,k:`ᴋ`,l:`ʟ`,m:`ᴍ`,n:`ɴ`,o:`ᴏ`,p:`ᴘ`,q:`ǫ`,r:`ʀ`,s:`s`,t:`ᴛ`,u:`ᴜ`,v:`ᴠ`,w:`ᴡ`,x:`x`,y:`ʏ`,z:`ᴢ`}),HT=[`mathrm`,`mathit`],UT=(e,t)=>{if(!HT.includes(t)||!e.body||e.body.type!==`ordgroup`||e.body.body.length===1||e.body.body[0].type!==`mathord`)return!1;for(let t=1;t<e.body.body.length;t++){let n=e.body.body[t].type;if(!(n===`mathord`||n===`textord`&&!isNaN(e.body.body[t].text)))return!1}return!0},WT=(e,t)=>{let n=e.font,r=t.withFont(n),i=JC(e.body,r);if(i.children.length===0)return i;if(n===`boldsymbol`&&[`mo`,`mpadded`,`mrow`].includes(i.type))return i.style.fontWeight=`bold`,i;if(UT(e,n)){let e=i.children[0].children[0].children?i.children[0].children[0]:i.children[0];delete e.attributes.mathvariant;for(let t=1;t<i.children.length;t++)e.children[0].text+=i.children[t].children[0].children?i.children[t].children[0].children[0].text:i.children[t].children[0].text;if(n===`mathit`)return e.children[0].text=e.children[0].text.split(``).map(e=>BT(e,`italic`)).join(``),e;let t=new W(`mpadded`,[e]);return t.setAttribute(`lspace`,`0`),t}let a=i.children[0].type===`mo`;for(let e=1;e<i.children.length;e++)i.children[e].type===`mo`&&n===`boldsymbol`&&(i.children[e].style.fontWeight=`bold`),i.children[e].type!==`mi`&&(a=!1),(i.children[e].attributes&&i.children[e].attributes.mathvariant||``)!==`normal`&&(a=!1);if(!a)return i;let o=i.children[0];for(let e=1;e<i.children.length;e++)o.children.push(i.children[e].children[0]);return o.attributes.mathvariant&&o.attributes.mathvariant===`normal`?new W(`mrow`,[new W(`mtext`,new hC(`​`)),o]):o},GT={"\\Bbb":`\\mathbb`,"\\bold":`\\mathbf`,"\\frak":`\\mathfrak`,"\\bm":`\\boldsymbol`};tC({type:`font`,names:[`\\mathrm`,`\\mathit`,`\\mathbf`,`\\mathnormal`,`\\up@greek`,`\\boldsymbol`,`\\mathbb`,`\\mathcal`,`\\mathfrak`,`\\mathscr`,`\\mathsf`,`\\mathsfit`,`\\mathtt`,`\\Bbb`,`\\bm`,`\\bold`,`\\frak`],props:{numArgs:1,allowedInArgument:!0},handler:({parser:e,funcName:t},n)=>{let r=rC(n[0]),i=t;return i in GT&&(i=GT[i]),{type:`font`,mode:e.mode,font:i.slice(1),body:r}},mathmlBuilder:WT}),tC({type:`font`,names:[`\\rm`,`\\sf`,`\\tt`,`\\bf`,`\\it`,`\\cal`],props:{numArgs:0,allowedInText:!0},handler:({parser:e,funcName:t,breakOnTokenText:n},r)=>{let{mode:i}=e,a=e.parseExpression(!0,n,!0);return{type:`font`,mode:i,font:`math${t.slice(1)}`,body:{type:`ordgroup`,mode:e.mode,body:a}}},mathmlBuilder:WT});var KT=[`display`,`text`,`script`,`scriptscript`],qT={auto:-1,display:0,text:0,script:1,scriptscript:2},JT=(e,t)=>{let n=t;if(e===`display`){let e=n.level>=Nw.SCRIPT?Nw.TEXT:Nw.DISPLAY;n=n.withLevel(e)}else e===`text`&&n.level===Nw.DISPLAY?n=n.withLevel(Nw.TEXT):e===`auto`?n=n.incrementLevel():e===`script`?n=n.withLevel(Nw.SCRIPT):e===`scriptscript`&&(n=n.withLevel(Nw.SCRIPTSCRIPT));return n},YT=(e,t)=>{t=JT(e.scriptLevel,t);let n=JC(e.numer,t),r=JC(e.denom,t);t.level===3&&(n.style.mathDepth=`2`,n.setAttribute(`scriptlevel`,`2`),r.style.mathDepth=`2`,r.setAttribute(`scriptlevel`,`2`));let i=new W(`mfrac`,[n,r]);if(!e.hasBarLine)i.setAttribute(`linethickness`,`0px`);else if(e.barSize){let n=dw(e.barSize,t);i.setAttribute(`linethickness`,n.number+n.unit)}if(e.leftDelim!=null||e.rightDelim!=null){let t=[];if(e.leftDelim!=null){let n=new W(`mo`,[new hC(e.leftDelim.replace(`\\`,``))]);n.setAttribute(`fence`,`true`),t.push(n)}if(t.push(i),e.rightDelim!=null){let n=new W(`mo`,[new hC(e.rightDelim.replace(`\\`,``))]);n.setAttribute(`fence`,`true`),t.push(n)}i=HC(t)}return e.scriptLevel!==`auto`&&(i=new W(`mstyle`,[i]),i.setAttribute(`displaystyle`,String(e.scriptLevel===`display`)),i.setAttribute(`scriptlevel`,qT[e.scriptLevel])),i};tC({type:`genfrac`,names:[`\\cfrac`,`\\dfrac`,`\\frac`,`\\tfrac`,`\\dbinom`,`\\binom`,`\\tbinom`,`\\\\atopfrac`,`\\\\bracefrac`,`\\\\brackfrac`],props:{numArgs:2,allowedInArgument:!0},handler:({parser:e,funcName:t},n)=>{let r=n[0],i=n[1],a=!1,o=null,s=null,c=`auto`;switch(t){case`\\cfrac`:case`\\dfrac`:case`\\frac`:case`\\tfrac`:a=!0;break;case`\\\\atopfrac`:a=!1;break;case`\\dbinom`:case`\\binom`:case`\\tbinom`:o=`(`,s=`)`;break;case`\\\\bracefrac`:o=`\\{`,s=`\\}`;break;case`\\\\brackfrac`:o=`[`,s=`]`;break;default:throw Error(`Unrecognized genfrac command`)}return t===`\\cfrac`||t.startsWith(`\\d`)?c=`display`:t.startsWith(`\\t`)&&(c=`text`),{type:`genfrac`,mode:e.mode,continued:!1,numer:r,denom:i,hasBarLine:a,leftDelim:o,rightDelim:s,scriptLevel:c,barSize:null}},mathmlBuilder:YT}),tC({type:`infix`,names:[`\\over`,`\\choose`,`\\atop`,`\\brace`,`\\brack`],props:{numArgs:0,infix:!0},handler({parser:e,funcName:t,token:n}){let r;switch(t){case`\\over`:r=`\\frac`;break;case`\\choose`:r=`\\binom`;break;case`\\atop`:r=`\\\\atopfrac`;break;case`\\brace`:r=`\\\\bracefrac`;break;case`\\brack`:r=`\\\\brackfrac`;break;default:throw Error(`Unrecognized infix genfrac command`)}return{type:`infix`,mode:e.mode,replaceWith:r,token:n}}});var XT=function(e){let t=null;return e.length>0&&(t=e,t=t===`.`?null:t),t};tC({type:`genfrac`,names:[`\\genfrac`],props:{numArgs:6,allowedInArgument:!0,argTypes:[`math`,`math`,`size`,`text`,`math`,`math`]},handler({parser:e},t){let n=t[4],r=t[5],i=rC(t[0]),a=i.type===`atom`&&i.family===`open`?XT(i.text):null,o=rC(t[1]),s=o.type===`atom`&&o.family===`close`?XT(o.text):null,c=yw(t[2],`size`),l,u=null;c.isBlank?l=!0:(u=c.value,l=u.number>0);let d=`auto`,f=t[3];if(f.type===`ordgroup`){if(f.body.length>0){let e=yw(f.body[0],`textord`);d=KT[Number(e.text)]}}else f=yw(f,`textord`),d=KT[Number(f.text)];return{type:`genfrac`,mode:e.mode,numer:n,denom:r,continued:!1,hasBarLine:l,barSize:u,leftDelim:a,rightDelim:s,scriptLevel:d}},mathmlBuilder:YT}),tC({type:`infix`,names:[`\\above`],props:{numArgs:1,argTypes:[`size`],infix:!0},handler({parser:e,funcName:t,token:n},r){return{type:`infix`,mode:e.mode,replaceWith:`\\\\abovefrac`,barSize:yw(r[0],`size`).value,token:n}}}),tC({type:`genfrac`,names:[`\\\\abovefrac`],props:{numArgs:3,argTypes:[`math`,`size`,`math`]},handler:({parser:e,funcName:t},n)=>{let r=n[0],i=KS(yw(n[1],`infix`).barSize),a=n[2],o=i.number>0;return{type:`genfrac`,mode:e.mode,numer:r,denom:a,continued:!1,hasBarLine:o,barSize:i,leftDelim:null,rightDelim:null,scriptLevel:`auto`}},mathmlBuilder:YT}),tC({type:`hbox`,names:[`\\hbox`],props:{numArgs:1,argTypes:[`hbox`],allowedInArgument:!0,allowedInText:!1},handler({parser:e},t){return{type:`hbox`,mode:e.mode,body:iC(t[0])}},mathmlBuilder(e,t){let n=t.withLevel(Nw.TEXT);return VC(qC(e.body,n))}}),tC({type:`horizBracket`,names:[`\\overbrace`,`\\underbrace`,`\\overbracket`,`\\underbracket`],props:{numArgs:1},handler({parser:e,funcName:t},n){return{type:`horizBracket`,mode:e.mode,label:t,isOver:/^\\over/.test(t),base:n[0]}},mathmlBuilder:(e,t)=>{let n=yC(e.label);return n.style[`math-depth`]=0,new W(e.isOver?`mover`:`munder`,[JC(e.base,t),n])}}),tC({type:`html`,names:[`\\class`,`\\id`,`\\style`,`\\data`],props:{numArgs:2,argTypes:[`raw`,`original`],allowedInText:!0},handler:({parser:e,funcName:t,token:n},r)=>{let i=yw(r[0],`raw`).string,a=r[1];if(e.settings.strict)throw new U(`Function "${t}" is disabled in strict mode`,n);let o,s={};switch(t){case`\\class`:s.class=i,o={command:`\\class`,class:i};break;case`\\id`:s.id=i,o={command:`\\id`,id:i};break;case`\\style`:s.style=i,o={command:`\\style`,style:i};break;case`\\data`:{let e=i.split(`,`);for(let t=0;t<e.length;t++){let n=e[t].split(`=`);if(n.length!==2)throw new U(`Error parsing key-value for \\data`);s[`data-`+n[0].trim()]=n[1].trim()}o={command:`\\data`,attributes:s};break}default:throw Error(`Unrecognized html command`)}if(!e.settings.isTrusted(o))throw new U(`Function "${t}" is not trusted`,n);return{type:`html`,mode:e.mode,attributes:s,body:iC(a)}},mathmlBuilder:(e,t)=>{let n=qC(e.body,t),r=[];e.attributes.class&&r.push(...e.attributes.class.trim().split(/\s+/)),n.classes=r;for(let t in e.attributes)t!==`class`&&Object.prototype.hasOwnProperty.call(e.attributes,t)&&n.setAttribute(t,e.attributes[t]);return n}});var ZT=function(e){if(/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(e))return{number:+e,unit:`bp`};{let t=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(e);if(!t)throw new U(`Invalid size: '`+e+`' in \\includegraphics`);let n={number:+(t[1]+t[2]),unit:t[3]};if(!lw(n))throw new U(`Invalid unit: '`+n.unit+`' in \\includegraphics.`);return n}};tC({type:`includegraphics`,names:[`\\includegraphics`],props:{numArgs:1,numOptionalArgs:1,argTypes:[`raw`,`url`],allowedInText:!1},handler:({parser:e,token:t},n,r)=>{let i={number:0,unit:`em`},a={number:.9,unit:`em`},o={number:0,unit:`em`},s=``;if(r[0]){let e=yw(r[0],`raw`).string.split(`,`);for(let t=0;t<e.length;t++){let n=e[t].split(`=`);if(n.length===2){let e=n[1].trim();switch(n[0].trim()){case`alt`:s=e;break;case`width`:i=ZT(e);break;case`height`:a=ZT(e);break;case`totalheight`:o=ZT(e);break;default:throw new U(`Invalid key: '`+n[0]+`' in \\includegraphics.`)}}}}let c=yw(n[0],`url`).url;if(s===``&&(s=c,s=s.replace(/^.*[\\/]/,``),s=s.substring(0,s.lastIndexOf(`.`))),!e.settings.isTrusted({command:`\\includegraphics`,url:c}))throw new U(`Function "\\includegraphics" is not trusted`,t);return{type:`includegraphics`,mode:e.mode,alt:s,width:i,height:a,totalheight:o,src:c}},mathmlBuilder:(e,t)=>{let n=dw(e.height,t),r={number:0,unit:`em`};e.totalheight.number>0&&e.totalheight.unit===n.unit&&e.totalheight.number>n.number&&(r.number=e.totalheight.number-n.number,r.unit=n.unit);let i=0;e.width.number>0&&(i=dw(e.width,t));let a={height:n.number+r.number+`em`};i.number>0&&(a.width=i.number+i.unit),r.number>0&&(a.verticalAlign=-r.number+r.unit);let o=new pC(e.src,e.alt,a);return o.height=n,o.depth=r,new W(`mtext`,[o])}}),tC({type:`kern`,names:[`\\kern`,`\\mkern`,`\\hskip`,`\\mskip`],props:{numArgs:1,argTypes:[`size`],primitive:!0,allowedInText:!0},handler({parser:e,funcName:t,token:n},r){let i=yw(r[0],`size`);if(e.settings.strict){let r=t[1]===`m`,a=i.value.unit===`mu`;if(r){if(!a)throw new U(`LaTeX's ${t} supports only mu units, not ${i.value.unit} units`,n);if(e.mode!==`math`)throw new U(`LaTeX's ${t} works only in math mode`,n)}else if(a)throw new U(`LaTeX's ${t} doesn't support mu units`,n)}return{type:`kern`,mode:e.mode,dimension:i.value}},mathmlBuilder(e,t){let n=dw(e.dimension,t),r=n.number>0&&n.unit===`em`?QT(n.number):``;if(e.mode===`text`&&r.length>0)return new W(`mtext`,[new hC(r)]);if(n.number>=0){let e=new W(`mspace`);return e.setAttribute(`width`,n.number+n.unit),e}{let e=new W(`mrow`);return e.style.marginLeft=n.number+n.unit,e}}});var QT=function(e){return e>=.05555&&e<=.05556?` `:e>=.1666&&e<=.1667?` `:e>=.2222&&e<=.2223?` `:e>=.2777&&e<=.2778?`  `:``},$T=/[^A-Za-z_0-9-]/g;tC({type:`label`,names:[`\\label`],props:{numArgs:1,argTypes:[`raw`]},handler({parser:e},t){return{type:`label`,mode:e.mode,string:t[0].string.replace($T,``)}},mathmlBuilder(e,t){let n=new W(`mrow`,[],[`tml-label`]);return e.string.length>0&&n.setLabel(e.string),n}});var eE=[`\\clap`,`\\llap`,`\\rlap`];tC({type:`lap`,names:[`\\mathllap`,`\\mathrlap`,`\\mathclap`,`\\clap`,`\\llap`,`\\rlap`],props:{numArgs:1,allowedInText:!0},handler:({parser:e,funcName:t,token:n},r)=>{if(eE.includes(t)){if(e.settings.strict&&e.mode!==`text`)throw new U(`{${t}} can be used only in text mode.
141
+ Try \\math${t.slice(1)}`,n);t=t.slice(1)}else t=t.slice(5);let i=r[0];return{type:`lap`,mode:e.mode,alignment:t,body:i}},mathmlBuilder:(e,t)=>{let n;e.alignment===`llap`&&(n=new W(`mpadded`,[new W(`mphantom`,KC(iC(e.body),t))]),n.setAttribute(`width`,`0.1px`));let r=JC(e.body,t),i;if(e.alignment===`llap`?(r.style.position=`absolute`,r.style.right=`0`,r.style.bottom=`0`,i=new W(`mpadded`,[n,r])):i=new W(`mpadded`,[r]),e.alignment===`rlap`)e.body.body.length>0&&e.body.body[0].type===`genfrac`&&i.setAttribute(`lspace`,`0.16667em`);else{let t=e.alignment===`llap`?`-1`:`-0.5`;i.setAttribute(`lspace`,t+`width`),e.alignment===`llap`?i.style.position=`relative`:(i.style.display=`flex`,i.style.justifyContent=`center`)}return i.setAttribute(`width`,`0.1px`),i}}),tC({type:`ordgroup`,names:[`\\(`,`$`],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler({funcName:e,parser:t},n){let r=t.mode;t.switchMode(`math`);let i=e===`\\(`?`\\)`:`$`,a=t.parseExpression(!1,i);return t.expect(i),t.switchMode(r),{type:`ordgroup`,mode:t.mode,body:a}}}),tC({type:`text`,names:[`\\)`,`\\]`],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(e,t){throw new U(`Mismatched ${e.funcName}`,t)}});var tE=(e,t)=>{switch(t.level){case Nw.DISPLAY:return e.display;case Nw.TEXT:return e.text;case Nw.SCRIPT:return e.script;case Nw.SCRIPTSCRIPT:return e.scriptscript;default:return e.text}};tC({type:`mathchoice`,names:[`\\mathchoice`],props:{numArgs:4,primitive:!0},handler:({parser:e},t)=>({type:`mathchoice`,mode:e.mode,display:iC(t[0]),text:iC(t[1]),script:iC(t[2]),scriptscript:iC(t[3])}),mathmlBuilder:(e,t)=>qC(tE(e,t),t)});var nE=[`text`,`textord`,`mathord`,`atom`];function rE(e,t){let n,r=KC(e.body,t);if(e.mclass===`minner`)n=new W(`mpadded`,r);else if(e.mclass===`mord`)e.isCharacterBox||r[0].type===`mathord`?(n=r[0],n.type=`mi`,n.children.length===1&&n.children[0].text&&n.children[0].text===`∇`&&n.setAttribute(`mathvariant`,`normal`)):n=new W(`mi`,r);else{n=new W(`mrow`,r),e.mustPromote?(n=r[0],n.type=`mo`,e.isCharacterBox&&e.body[0].text&&/[A-Za-z]/.test(e.body[0].text)&&n.setAttribute(`mathvariant`,`italic`)):n=new W(`mrow`,r);let i=t.level<2;n.type===`mrow`?i&&(e.mclass===`mbin`?(n.children.unshift(fw(.2222)),n.children.push(fw(.2222))):e.mclass===`mrel`?(n.children.unshift(fw(.2778)),n.children.push(fw(.2778))):e.mclass===`mpunct`?n.children.push(fw(.1667)):e.mclass===`minner`&&(n.children.unshift(fw(.0556)),n.children.push(fw(.0556)))):e.mclass===`mbin`?(n.attributes.lspace=i?`0.2222em`:`0`,n.attributes.rspace=i?`0.2222em`:`0`):e.mclass===`mrel`?(n.attributes.lspace=i?`0.2778em`:`0`,n.attributes.rspace=i?`0.2778em`:`0`):e.mclass===`mpunct`?(n.attributes.lspace=`0em`,n.attributes.rspace=i?`0.1667em`:`0`):e.mclass===`mopen`||e.mclass===`mclose`?(n.attributes.lspace=`0em`,n.attributes.rspace=`0em`):e.mclass===`minner`&&i&&(n.attributes.lspace=`0.0556em`,n.attributes.width=`+0.1111em`),e.mclass!==`mopen`&&e.mclass!==`mclose`&&(delete n.attributes.stretchy,delete n.attributes.form)}return n}tC({type:`mclass`,names:[`\\mathord`,`\\mathbin`,`\\mathrel`,`\\mathopen`,`\\mathclose`,`\\mathpunct`,`\\mathinner`],props:{numArgs:1,primitive:!0},handler({parser:e,funcName:t},n){let r=n[0],i=GS(r),a=!0,o={type:`mathord`,text:``,mode:e.mode},s=r.body?r.body:[r];for(let t of s)if(nE.includes(t.type))wC[e.mode][t.text]?o.text+=wC[e.mode][t.text].replace:t.text?o.text+=t.text:t.body&&t.body.map(e=>{o.text+=e.text});else{a=!1;break}return a&&t===`\\mathord`&&o.type===`mathord`&&o.text.length>1?o:{type:`mclass`,mode:e.mode,mclass:`m`+t.slice(5),body:iC(a?o:r),isCharacterBox:i,mustPromote:a}},mathmlBuilder:rE});var iE=e=>{let t=e.type===`ordgroup`&&e.body.length&&e.body.length===1?e.body[0]:e;if(t.type===`atom`){let n=e.body.length>0&&e.body[0].text&&wC.math[e.body[0].text]?wC.math[e.body[0].text].group:t.family;return n===`bin`||n===`rel`?`m`+n:`mord`}return`mord`};tC({type:`mclass`,names:[`\\@binrel`],props:{numArgs:2},handler({parser:e},t){return{type:`mclass`,mode:e.mode,mclass:iE(t[0]),body:iC(t[1]),isCharacterBox:GS(t[1])}}}),tC({type:`mclass`,names:[`\\stackrel`,`\\overset`,`\\underset`],props:{numArgs:2},handler({parser:e,funcName:t},n){let r=n[1],i=n[0],a;a=t===`\\stackrel`?`mrel`:iE(r);let o={type:a===`mrel`||a===`mbin`?`op`:`ordgroup`,mode:r.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:t!==`\\stackrel`,body:iC(r)};return{type:`supsub`,mode:i.mode,stack:!0,base:o,sup:t===`\\underset`?null:i,sub:t===`\\underset`?i:null}},mathmlBuilder:rE});var aE=(e,t,n)=>{if(!e)return n;let r=JC(e,t);return r.type===`mrow`&&r.children.length===0?n:r};tC({type:`multiscript`,names:[`\\sideset`,`\\pres@cript`],props:{numArgs:3},handler({parser:e,funcName:t,token:n},r){if(r[2].body.length===0)throw new U(t+`cannot parse an empty base.`);let i=r[2].body[0];if(e.settings.strict&&t===`\\sideset`&&!i.symbol)throw new U(`The base of \\sideset must be a big operator. Try \\prescript.`);if(r[0].body.length>0&&r[0].body[0].type!==`supsub`||r[1].body.length>0&&r[1].body[0].type!==`supsub`)throw new U(`\\sideset can parse only subscripts and superscripts in its first two arguments`,n);let a=r[0].body.length>0?r[0].body[0]:null,o=r[1].body.length>0?r[1].body[0]:null;return!a&&!o?i:a?{type:`multiscript`,mode:e.mode,isSideset:t===`\\sideset`,prescripts:a,postscripts:o,base:i}:{type:`styling`,mode:e.mode,scriptLevel:`text`,body:[{type:`supsub`,mode:e.mode,base:i,sup:o.sup,sub:o.sub}]}},mathmlBuilder(e,t){let n=JC(e.base,t),r=new W(`mprescripts`),i=new W(`none`),a=[],o=aE(e.prescripts.sub,t,i),s=aE(e.prescripts.sup,t,i);return e.isSideset&&(o.setAttribute(`style`,`text-align: left;`),s.setAttribute(`style`,`text-align: left;`)),a=e.postscripts?[n,aE(e.postscripts.sub,t,i),aE(e.postscripts.sup,t,i),r,o,s]:[n,r,o,s],new W(`mmultiscripts`,a)}}),tC({type:`not`,names:[`\\not`],props:{numArgs:1,primitive:!0,allowedInText:!1},handler({parser:e},t){let n=GS(t[0]),r;return n?(r=iC(t[0]),r[0].text.charAt(0)===`\\`&&(r[0].text=wC.math[r[0].text].replace),r[0].text=r[0].text.slice(0,1)+`̸`+r[0].text.slice(1)):r=[{type:`textord`,mode:`math`,text:`̸`},{type:`kern`,mode:`math`,dimension:{number:-.6,unit:`em`}},t[0]],{type:`not`,mode:e.mode,body:r,isCharacterBox:n}},mathmlBuilder(e,t){return e.isCharacterBox?KC(e.body,t,!0)[0]:qC(e.body,t)}});var oE=[`textord`,`mathord`,`atom`],sE=[`\\smallint`],cE=[`textord`,`mathord`,`ordgroup`,`close`,`leftright`,`font`],lE=e=>{e.attributes.lspace=`0.1667em`,e.attributes.rspace=`0.1667em`},uE=(e,t)=>{let n;if(e.symbol)n=new W(`mo`,[zC(e.name,e.mode)]),sE.includes(e.name)?n.setAttribute(`largeop`,`false`):n.setAttribute(`movablelimits`,`false`),e.fromMathOp&&lE(n);else if(e.body)n=new W(`mo`,KC(e.body,t)),e.fromMathOp&&lE(n);else if(n=new W(`mi`,[new hC(e.name.slice(1))]),!e.parentIsSupSub){let t=new W(`mo`,[zC(`⁡`,`text`)]),r=[n,t];if(e.needsLeadingSpace){let e=new W(`mspace`);e.setAttribute(`width`,`0.1667em`),r.unshift(e)}if(!e.isFollowedByDelimiter){let e=new W(`mspace`);e.setAttribute(`width`,`0.1667em`),r.push(e)}n=new W(`mrow`,r)}return n},dE={"∏":`\\prod`,"∐":`\\coprod`,"∑":`\\sum`,"⋀":`\\bigwedge`,"⋁":`\\bigvee`,"⋂":`\\bigcap`,"⋃":`\\bigcup`,"⨀":`\\bigodot`,"⨁":`\\bigoplus`,"⨂":`\\bigotimes`,"⨄":`\\biguplus`,"⨅":`\\bigsqcap`,"⨆":`\\bigsqcup`,"⨃":`\\bigcupdot`,"⨇":`\\bigdoublevee`,"⨈":`\\bigdoublewedge`,"⨉":`\\bigtimes`};tC({type:`op`,names:`\\coprod.\\bigvee.\\bigwedge.\\biguplus.\\bigcupplus.\\bigcupdot.\\bigcap.\\bigcup.\\bigdoublevee.\\bigdoublewedge.\\intop.\\prod.\\sum.\\bigotimes.\\bigoplus.\\bigodot.\\bigsqcap.\\bigsqcup.\\bigtimes.\\smallint.∏.∐.∑.⋀.⋁.⋂.⋃.⨀.⨁.⨂.⨃.⨄.⨅.⨆.⨇.⨈.⨉`.split(`.`),props:{numArgs:0},handler:({parser:e,funcName:t},n)=>{let r=t;return r.length===1&&(r=dE[r]),{type:`op`,mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:!0,stack:!1,name:r}},mathmlBuilder:uE}),tC({type:`op`,names:[`\\mathop`],props:{numArgs:1,primitive:!0},handler:({parser:e},t)=>{let n=t[0],r=n.body?n.body:[n],i=r.length===1&&oE.includes(r[0].type);return{type:`op`,mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:i,fromMathOp:!0,stack:!1,name:i?r[0].text:null,body:i?null:iC(n)}},mathmlBuilder:uE});var fE={"∫":`\\int`,"∬":`\\iint`,"∭":`\\iiint`,"∮":`\\oint`,"∯":`\\oiint`,"∰":`\\oiiint`,"∱":`\\intclockwise`,"∲":`\\varointclockwise`,"⨌":`\\iiiint`,"⨍":`\\intbar`,"⨎":`\\intBar`,"⨏":`\\fint`,"⨒":`\\rppolint`,"⨓":`\\scpolint`,"⨕":`\\pointint`,"⨖":`\\sqint`,"⨗":`\\intlarhk`,"⨘":`\\intx`,"⨙":`\\intcap`,"⨚":`\\intcup`};tC({type:`op`,names:`\\arcsin.\\arccos.\\arctan.\\arctg.\\arcctg.\\arg.\\ch.\\cos.\\cosec.\\cosh.\\cot.\\cotg.\\coth.\\csc.\\ctg.\\cth.\\deg.\\dim.\\exp.\\hom.\\ker.\\lg.\\ln.\\log.\\sec.\\sin.\\sinh.\\sh.\\sgn.\\tan.\\tanh.\\tg.\\th`.split(`.`),props:{numArgs:0},handler({parser:e,funcName:t}){let n=e.prevAtomType,r=e.gullet.future().text;return{type:`op`,mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!1,stack:!1,isFollowedByDelimiter:wT(r),needsLeadingSpace:n.length>0&&cE.includes(n),name:t}},mathmlBuilder:uE}),tC({type:`op`,names:[`\\det`,`\\gcd`,`\\inf`,`\\lim`,`\\max`,`\\min`,`\\Pr`,`\\sup`],props:{numArgs:0},handler({parser:e,funcName:t}){let n=e.prevAtomType,r=e.gullet.future().text;return{type:`op`,mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:!1,stack:!1,isFollowedByDelimiter:wT(r),needsLeadingSpace:n.length>0&&cE.includes(n),name:t}},mathmlBuilder:uE}),tC({type:`op`,names:`\\int.\\iint.\\iiint.\\iiiint.\\oint.\\oiint.\\oiiint.\\intclockwise.\\varointclockwise.\\intbar.\\intBar.\\fint.\\rppolint.\\scpolint.\\pointint.\\sqint.\\intlarhk.\\intx.\\intcap.\\intcup.∫.∬.∭.∮.∯.∰.∱.∲.⨌.⨍.⨎.⨏.⨒.⨓.⨕.⨖.⨗.⨘.⨙.⨚`.split(`.`),props:{numArgs:0,allowedInArgument:!0},handler({parser:e,funcName:t}){let n=t;return n.length===1&&(n=fE[n]),{type:`op`,mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!0,stack:!1,name:n}},mathmlBuilder:uE}),tC({type:`operatorname`,names:[`\\operatorname@`,`\\operatornamewithlimits`],props:{numArgs:1,allowedInArgument:!0},handler:({parser:e,funcName:t},n)=>{let r=n[0],i=e.prevAtomType,a=e.gullet.future().text;return{type:`operatorname`,mode:e.mode,body:iC(r),alwaysHandleSupSub:t===`\\operatornamewithlimits`,limits:!1,parentIsSupSub:!1,isFollowedByDelimiter:wT(a),needsLeadingSpace:i.length>0&&cE.includes(i)}},mathmlBuilder:(e,t)=>{let n=KC(e.body,t.withFont(`mathrm`)),r=!0;for(let e=0;e<n.length;e++){let t=n[e];if(t instanceof W)switch(((t.type===`mrow`||t.type===`mpadded`)&&t.children.length===1&&t.children[0]instanceof W||t.type===`mrow`&&t.children.length===2&&t.children[0]instanceof W&&t.children[1]instanceof W&&t.children[1].type===`mspace`&&!t.children[1].attributes.width&&t.children[1].children.length===0)&&(t=t.children[0]),t.type){case`mi`:case`mn`:case`ms`:case`mtext`:break;case`mspace`:if(t.attributes.width){let i=t.attributes.width.replace(`em`,``),a=QT(Number(i));a===``?r=!1:n[e]=new W(`mtext`,[new hC(a)])}break;case`mo`:{let e=t.children[0];t.children.length===1&&e instanceof hC?e.text=e.text.replace(/\u2212/,`-`).replace(/\u2217/,`*`):r=!1;break}default:r=!1}else r=!1}if(r)n=[new hC(n.map(e=>e.toText()).join(``))];else if(n.length===1&&[`mover`,`munder`].includes(n[0].type)&&(n[0].children[0].type===`mi`||n[0].children[0].type===`mtext`)){if(n[0].children[0].type=`mi`,e.parentIsSupSub)return new W(`mrow`,n);{let e=new W(`mo`,[zC(`⁡`,`text`)]);return mC([n[0],e])}}let i;if(r?(i=new W(`mi`,n),n[0].text.length===1&&i.setAttribute(`mathvariant`,`normal`)):i=new W(`mrow`,n),!e.parentIsSupSub){let t=new W(`mo`,[zC(`⁡`,`text`)]),n=[i,t];if(e.needsLeadingSpace){let e=new W(`mspace`);e.setAttribute(`width`,`0.1667em`),n.unshift(e)}if(!e.isFollowedByDelimiter){let e=new W(`mspace`);e.setAttribute(`width`,`0.1667em`),n.push(e)}return mC(n)}return i}}),Q(`\\operatorname`,`\\@ifstar\\operatornamewithlimits\\operatorname@`),nC({type:`ordgroup`,mathmlBuilder(e,t){return qC(e.body,t,e.semisimple)}}),tC({type:`phantom`,names:[`\\phantom`],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>{let n=t[0];return{type:`phantom`,mode:e.mode,body:iC(n)}},mathmlBuilder:(e,t)=>new W(`mphantom`,KC(e.body,t))}),tC({type:`hphantom`,names:[`\\hphantom`],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>{let n=t[0];return{type:`hphantom`,mode:e.mode,body:n}},mathmlBuilder:(e,t)=>{let n=new W(`mpadded`,[new W(`mphantom`,KC(iC(e.body),t))]);return n.setAttribute(`height`,`0px`),n.setAttribute(`depth`,`0px`),n}}),tC({type:`vphantom`,names:[`\\vphantom`],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>{let n=t[0];return{type:`vphantom`,mode:e.mode,body:n}},mathmlBuilder:(e,t)=>{let n=new W(`mpadded`,[new W(`mphantom`,KC(iC(e.body),t))]);return n.setAttribute(`width`,`0.1px`),n}}),tC({type:`pmb`,names:[`\\pmb`],props:{numArgs:1,allowedInText:!0},handler({parser:e},t){return{type:`pmb`,mode:e.mode,body:iC(t[0])}},mathmlBuilder(e,t){let n=gC(KC(e.body,t));return n.setAttribute(`style`,`font-weight:bold`),n}});var pE=(e,t)=>{let n=t.withLevel(Nw.TEXT),r=new W(`mpadded`,[JC(e.body,n)]),i=dw(e.dy,t);return r.setAttribute(`voffset`,i.number+i.unit),i.number>0?r.style.padding=i.number+i.unit+` 0 0 0`:r.style.padding=`0 0 `+Math.abs(i.number)+i.unit+` 0`,r};tC({type:`raise`,names:[`\\raise`,`\\lower`],props:{numArgs:2,argTypes:[`size`,`primitive`],primitive:!0},handler({parser:e,funcName:t},n){let r=yw(n[0],`size`).value;t===`\\lower`&&(r.number*=-1);let i=n[1];return{type:`raise`,mode:e.mode,dy:r,body:i}},mathmlBuilder:pE}),tC({type:`raise`,names:[`\\raisebox`],props:{numArgs:2,argTypes:[`size`,`hbox`],allowedInText:!0},handler({parser:e,funcName:t},n){let r=yw(n[0],`size`).value,i=n[1];return{type:`raise`,mode:e.mode,dy:r,body:i}},mathmlBuilder:pE}),tC({type:`ref`,names:[`\\ref`,`\\eqref`],props:{numArgs:1,argTypes:[`raw`]},handler({parser:e,funcName:t},n){return{type:`ref`,mode:e.mode,funcName:t,string:n[0].string.replace($T,``)}},mathmlBuilder(e,t){let n=e.funcName===`\\ref`?[`tml-ref`]:[`tml-ref`,`tml-eqref`];return new fC(`#`+e.string,n,null)}}),tC({type:`reflect`,names:[`\\reflectbox`],props:{numArgs:1,argTypes:[`hbox`],allowedInText:!0},handler({parser:e},t){return{type:`reflect`,mode:e.mode,body:t[0]}},mathmlBuilder(e,t){let n=JC(e.body,t);return n.style.transform=`scaleX(-1)`,n}}),tC({type:`internal`,names:[`\\relax`],props:{numArgs:0,allowedInText:!0,allowedInArgument:!0},handler({parser:e}){return{type:`internal`,mode:e.mode}}}),tC({type:`rule`,names:[`\\rule`],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:[`size`,`size`,`size`]},handler({parser:e},t,n){let r=n[0],i=yw(t[0],`size`),a=yw(t[1],`size`);return{type:`rule`,mode:e.mode,shift:r&&yw(r,`size`).value,width:i.value,height:a.value}},mathmlBuilder(e,t){let n=dw(e.width,t),r=dw(e.height,t),i=e.shift?dw(e.shift,t):{number:0,unit:`em`},a=t.color&&t.getColor()||`black`,o=new W(`mspace`);if(n.number>0&&r.number>0&&o.setAttribute(`mathbackground`,a),o.setAttribute(`width`,n.number+n.unit),o.setAttribute(`height`,r.number+r.unit),i.number===0)return o;let s=new W(`mpadded`,[o]);return i.number>=0?s.setAttribute(`height`,`+`+i.number+i.unit):(s.setAttribute(`height`,i.number+i.unit),s.setAttribute(`depth`,`+`+-i.number+i.unit)),s.setAttribute(`voffset`,i.number+i.unit),s}});var mE=/^[0-9]$/,hE={0:`₀`,1:`₁`,2:`₂`,3:`₃`,4:`₄`,5:`₅`,6:`₆`,7:`₇`,8:`₈`,9:`₉`},gE={0:`⁰`,1:`¹`,2:`²`,3:`³`,4:`⁴`,5:`⁵`,6:`⁶`,7:`⁷`,8:`⁸`,9:`⁹`};tC({type:`sfrac`,names:[`\\sfrac`],props:{numArgs:2,allowedInText:!0,allowedInMath:!0},handler({parser:e},t){let n=``;for(let e of t[0].body){if(e.type!==`textord`||!mE.test(e.text))throw new U(`Numerator must be an integer.`,e);n+=e.text}let r=``;for(let e of t[1].body){if(e.type!==`textord`||!mE.test(e.text))throw new U(`Denominator must be an integer.`,e);r+=e.text}return{type:`sfrac`,mode:e.mode,numerator:n,denominator:r}},mathmlBuilder(e,t){let n=e.numerator.split(``).map(e=>gE[e]).join(``),r=e.denominator.split(``).map(e=>hE[e]).join(``);return new W(`mn`,[new hC(n+`⁄`+r,e.mode,t)],[`special-fraction`])}});var _E={"\\tiny":.5,"\\sixptsize":.6,"\\Tiny":.6,"\\scriptsize":.7,"\\footnotesize":.8,"\\small":.9,"\\normalsize":1,"\\large":1.2,"\\Large":1.44,"\\LARGE":1.728,"\\huge":2.074,"\\Huge":2.488};tC({type:`sizing`,names:[`\\tiny`,`\\sixptsize`,`\\Tiny`,`\\scriptsize`,`\\footnotesize`,`\\small`,`\\normalsize`,`\\large`,`\\Large`,`\\LARGE`,`\\huge`,`\\Huge`],props:{numArgs:0,allowedInText:!0},handler:({breakOnTokenText:e,funcName:t,parser:n},r)=>{n.settings.strict&&n.mode===`math`&&console.log(`Temml strict-mode warning: Command ${t} is invalid in math mode.`);let i=n.parseExpression(!1,e,!0);return{type:`sizing`,mode:n.mode,funcName:t,body:i}},mathmlBuilder:(e,t)=>{let n=t.withFontSize(_E[e.funcName]),r=gC(KC(e.body,n)),i=(_E[e.funcName]/t.fontSize).toFixed(4);return r.setAttribute(`mathsize`,i+`em`),r}}),tC({type:`smash`,names:[`\\smash`],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0},handler:({parser:e},t,n)=>{let r=!1,i=!1,a=n[0]&&yw(n[0],`ordgroup`);if(a){let e=``;for(let t=0;t<a.body.length;++t)if(e=a.body[t].text,e===`t`)r=!0;else if(e===`b`)i=!0;else{r=!1,i=!1;break}}else r=!0,i=!0;let o=t[0];return{type:`smash`,mode:e.mode,body:o,smashHeight:r,smashDepth:i}},mathmlBuilder:(e,t)=>{let n=new W(`mpadded`,[JC(e.body,t)]);return e.smashHeight&&n.setAttribute(`height`,`0px`),e.smashDepth&&n.setAttribute(`depth`,`0px`),n}});var vE=`a.c.e.ı.m.n.o.r.s.u.v.w.x.z.α.ε.ι.κ.ν.ο.π.σ.τ.υ.ω.\\alpha.\\epsilon.\\iota.\\kappa.\\nu.\\omega.\\pi.\\tau.\\omega`.split(`.`);tC({type:`sqrt`,names:[`\\sqrt`],props:{numArgs:1,numOptionalArgs:1},handler({parser:e},t,n){let r=n[0],i=t[0];return i.body&&i.body.length===1&&i.body[0].text&&vE.includes(i.body[0].text)&&i.body.push({type:`rule`,mode:`math`,shift:null,width:{number:0,unit:`pt`},height:{number:.5,unit:`em`}}),{type:`sqrt`,mode:e.mode,body:i,index:r}},mathmlBuilder(e,t){let{body:n,index:r}=e;return r?new W(`mroot`,[JC(n,t),JC(r,t.incrementLevel())]):new W(`msqrt`,[JC(n,t)])}});var yE={display:0,text:1,script:2,scriptscript:3},bE={display:[`0`,`true`],text:[`0`,`false`],script:[`1`,`false`],scriptscript:[`2`,`false`]};tC({type:`styling`,names:[`\\displaystyle`,`\\textstyle`,`\\scriptstyle`,`\\scriptscriptstyle`],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({breakOnTokenText:e,funcName:t,parser:n},r){let i=n.parseExpression(!0,e,!0),a=t.slice(1,t.length-5);return{type:`styling`,mode:n.mode,scriptLevel:a,body:i}},mathmlBuilder(e,t){let n=t.withLevel(yE[e.scriptLevel]),r=gC(KC(e.body,n)),i=bE[e.scriptLevel];return r.setAttribute(`scriptlevel`,i[0]),r.setAttribute(`displaystyle`,i[1]),r}});var xE=/^m(over|under|underover)$/,SE=`DHKLUcegorsuvxyzΠΥΨαδηιμνοτυχϵ`,CE=`BCEFGIMNOPQRSTXZlpqtwΓΘΞΣΦΩβεζθξρςφψϑϕϱ`,wE=`AJdfΔΛ`;nC({type:`supsub`,mathmlBuilder(e,t){let n=!1,r,i,a=!1,o=!1,s=!1;e.base&&e.base.type===`horizBracket`&&(i=!!e.sup,i===e.base.isOver&&(n=!0,r=e.base.isOver)),e.base&&!e.stack&&(e.base.type===`op`||e.base.type===`operatorname`)&&(e.base.parentIsSupSub=!0,a=!e.base.symbol,o=a&&!e.isFollowedByDelimiter,s=e.base.needsLeadingSpace);let c=e.stack&&e.base.body.length===1?[JC(e.base.body[0],t)]:[JC(e.base,t)],l=t.inSubOrSup();if(e.sub){let n=JC(e.sub,l);t.level===3&&n.setAttribute(`scriptlevel`,`2`),c.push(n)}if(e.sup){let n=JC(e.sup,l);if(t.level===3&&n.setAttribute(`scriptlevel`,`2`),e.base&&e.base.text&&e.base.text.length===1){let t=e.base.text;SE.indexOf(t)>-1?n.classes.push(`tml-sml-pad`):CE.indexOf(t)>-1?n.classes.push(`tml-med-pad`):wE.indexOf(t)>-1&&n.classes.push(`tml-lrg-pad`)}c.push(n)}let u;if(n)u=r?`mover`:`munder`;else if(!e.sub){let n=e.base;u=n&&n.type===`op`&&n.limits&&(t.level===Nw.DISPLAY||n.alwaysHandleSupSub)||n&&n.type===`operatorname`&&n.alwaysHandleSupSub&&(n.limits||t.level===Nw.DISPLAY)?`mover`:`msup`}else if(e.sup){let n=e.base;u=n&&(n.type===`op`&&n.limits||n.type===`multiscript`)&&(t.level===Nw.DISPLAY||n.alwaysHandleSupSub)||n&&n.type===`operatorname`&&n.alwaysHandleSupSub&&(t.level===Nw.DISPLAY||n.limits)?`munderover`:`msubsup`}else{let n=e.base;u=e.stack||n&&n.type===`op`&&n.limits&&(t.level===Nw.DISPLAY||n.alwaysHandleSupSub)||n&&n.type===`operatorname`&&n.alwaysHandleSupSub&&(n.limits||t.level===Nw.DISPLAY)?`munder`:`msub`}let d=new W(u,c);if(a){let e=new W(`mo`,[zC(`⁡`,`text`)]);if(s){let t=new W(`mspace`);t.setAttribute(`width`,`0.1667em`),d=mC([t,d,e])}else d=mC([d,e]);if(o){let e=new W(`mspace`);e.setAttribute(`width`,`0.1667em`),d.children.push(e)}}else xE.test(u)&&(d=new W(`mrow`,[d]));return d}});var TE=[`\\shortmid`,`\\nshortmid`,`\\shortparallel`,`\\nshortparallel`,`\\smallsetminus`],EE=[`\\Rsh`,`\\Lsh`,`\\restriction`],DE=e=>{if(e.length===1){let t=e.codePointAt(0);return 8591<t&&t<8704}return e.indexOf(`arrow`)>-1||e.indexOf(`harpoon`)>-1||EE.includes(e)};nC({type:`atom`,mathmlBuilder(e,t){if(e.family===`inner`)return new W(e.mode===`text`?`mtext`:`mi`,[zC(e.text,e.mode)]);let n=new W(`mo`,[zC(e.text,e.mode)]);if(e.family===`punct`)n.setAttribute(`separator`,`true`);else if(e.family===`open`||e.family===`close`)e.family===`open`?(n.setAttribute(`form`,`prefix`),n.setAttribute(`stretchy`,`false`)):e.family===`close`&&(n.setAttribute(`form`,`postfix`),n.setAttribute(`stretchy`,`false`));else if(e.text===`\\mid`)n.setAttribute(`lspace`,`0.22em`),n.setAttribute(`rspace`,`0.22em`),n.setAttribute(`stretchy`,`false`);else if(e.family===`rel`&&DE(e.text))n.setAttribute(`stretchy`,`false`);else if(TE.includes(e.text))n.setAttribute(`mathsize`,`70%`);else if(e.text===`:`)n.attributes.lspace=`0.2222em`,n.attributes.rspace=`0.2222em`;else if(e.needsSpacing)return e.family===`bin`?new W(`mrow`,[fw(.222),n,fw(.222)]):new W(`mrow`,[fw(.2778),n,fw(.2778)]);return n}});var OE={mathbf:`bold`,mathrm:`normal`,textit:`italic`,mathit:`italic`,mathnormal:`italic`,mathbb:`double-struck`,mathcal:`script`,mathfrak:`fraktur`,mathscr:`script`,mathsf:`sans-serif`,mathtt:`monospace`},kE=function(e,t){if(t.fontFamily===`texttt`)return`monospace`;if(t.fontFamily===`textsc`)return`normal`;if(t.fontFamily===`textsf`)return t.fontShape===`textit`&&t.fontWeight===`textbf`?`sans-serif-bold-italic`:t.fontShape===`textit`?`sans-serif-italic`:t.fontWeight===`textbf`?`sans-serif-bold`:`sans-serif`;if(t.fontShape===`textit`&&t.fontWeight===`textbf`)return`bold-italic`;if(t.fontShape===`textit`)return`italic`;if(t.fontWeight===`textbf`)return`bold`;let n=t.font;if(!n||n===`mathnormal`)return null;let r=e.mode;switch(n){case`mathit`:return`italic`;case`mathrm`:{let t=e.text.codePointAt(0);return 939<t&&t<975?`italic`:`normal`}case`greekItalic`:return`italic`;case`up@greek`:return`normal`;case`boldsymbol`:case`mathboldsymbol`:return`bold-italic`;case`mathbf`:return`bold`;case`mathbb`:return`double-struck`;case`mathfrak`:return`fraktur`;case`mathscr`:case`mathcal`:return`script`;case`mathsf`:return`sans-serif`;case`mathsfit`:return`sans-serif-italic`;case`mathtt`:return`monospace`}let i=e.text;return wC[r][i]&&wC[r][i].replace&&(i=wC[r][i].replace),Object.prototype.hasOwnProperty.call(OE,n)?OE[n]:null},AE=/^\d(?:[\d,.]*\d)?$/,jE=/[A-Ba-z]/,ME=new Set([`\\prime`,`\\dprime`,`\\trprime`,`\\qprime`,`\\backprime`,`\\backdprime`,`\\backtrprime`]),NE=(e,t,n)=>{let r=new W(`mstyle`,[new W(n,[e])]);return r.style[`font-style`]=`italic`,r.style[`font-family`]=`Cambria, 'Times New Roman', serif`,t===`bold-italic`&&(r.style[`font-weight`]=`bold`),r};nC({type:`mathord`,mathmlBuilder(e,t){let n=zC(e.text,e.mode,t),r=n.text.codePointAt(0),i=912<r&&r<938?`normal`:`italic`,a=kE(e,t)||i;if(a===`script`)return n.text=BT(n.text,a),new W(`mi`,[n],[t.font]);a!==`italic`&&(n.text=BT(n.text,a));let o=new W(`mi`,[n]);if(a===`normal`&&(o.setAttribute(`mathvariant`,`normal`),n.text.length===1)){let e=new W(`mspace`,[]);o=new W(`mrow`,[o,e])}return o}}),nC({type:`textord`,mathmlBuilder(e,t){let n=e.text,r=n.codePointAt(0);t.fontFamily===`textsc`&&96<r&&r<123&&(n=VT[n]);let i=zC(n,e.mode,t),a=kE(e,t)||`normal`,o;if(AE.test(e.text)){let t=e.mode===`text`?`mtext`:`mn`;if(a===`italic`||a===`bold-italic`)return NE(i,a,t);a!==`normal`&&(i.text=i.text.split(``).map(e=>BT(e,a)).join(``)),o=new W(t,[i])}else if(e.mode===`text`)a!==`normal`&&(i.text=BT(i.text,a)),o=new W(`mtext`,[i]);else if(ME.has(e.text))o=new W(`mo`,[i]),o.classes.push(`tml-prime`);else{let e=i.text;a!==`italic`&&(i.text=BT(i.text,a)),o=new W(`mi`,[i]),i.text===e&&jE.test(e)&&o.setAttribute(`mathvariant`,`italic`)}return o}});var PE={"\\nobreak":`nobreak`,"\\allowbreak":`allowbreak`},FE={" ":{},"\\ ":{},"~":{className:`nobreak`},"\\space":{},"\\nobreakspace":{className:`nobreak`}};nC({type:`spacing`,mathmlBuilder(e,t){let n;if(Object.prototype.hasOwnProperty.call(FE,e.text))n=new W(`mtext`,[new hC(`\xA0`)]);else if(Object.prototype.hasOwnProperty.call(PE,e.text))n=new W(`mo`),e.text===`\\nobreak`&&n.setAttribute(`linebreak`,`nobreak`);else throw new U(`Unknown type of space "${e.text}"`);return n}}),nC({type:`tag`});var IE={"\\text":void 0,"\\textrm":`textrm`,"\\textsf":`textsf`,"\\texttt":`texttt`,"\\textnormal":`textrm`,"\\textsc":`textsc`},LE={"\\textbf":`textbf`,"\\textmd":`textmd`},RE={"\\textit":`textit`,"\\textup":`textup`},zE=(e,t)=>{let n=e.font;return n?IE[n]?t.withTextFontFamily(IE[n]):LE[n]?t.withTextFontWeight(LE[n]):n===`\\emph`?t.fontShape===`textit`?t.withTextFontShape(`textup`):t.withTextFontShape(`textit`):t.withTextFontShape(RE[n]):t};tC({type:`text`,names:[`\\text`,`\\textrm`,`\\textsf`,`\\texttt`,`\\textnormal`,`\\textsc`,`\\textbf`,`\\textmd`,`\\textit`,`\\textup`,`\\emph`],props:{numArgs:1,argTypes:[`text`],allowedInArgument:!0,allowedInText:!0},handler({parser:e,funcName:t},n){let r=n[0];return{type:`text`,mode:e.mode,body:iC(r),font:t}},mathmlBuilder(e,t){let n=zE(e,t);return VC(qC(e.body,n))}}),tC({type:`vcenter`,names:[`\\vcenter`],props:{numArgs:1,argTypes:[`original`],allowedInText:!1},handler({parser:e},t){return{type:`vcenter`,mode:e.mode,body:t[0]}},mathmlBuilder(e,t){let n=new W(`mtd`,[JC(e.body,t)]);return n.style.padding=`0`,new W(`mtable`,[new W(`mtr`,[n])])}}),tC({type:`verb`,names:[`\\verb`],props:{numArgs:0,allowedInText:!0},handler(e,t,n){throw new U(`\\verb ended by end of line instead of matching delimiter`)},mathmlBuilder(e,t){let n=new W(`mtext`,[new hC(BE(e))]);return n.setAttribute(`mathvariant`,`monospace`),n}});var BE=e=>e.body.replace(/ /g,e.star?`␣`:`\xA0`),VE=$S,HE=`[ \r
142
+ ]`,UE=`\\\\[a-zA-Z@]+`,WE=`\\\\[^\ud800-\udfff]`,GE=`(${UE})${HE}*`,KE=`\\\\(
143
+ |[ \r ]+
144
+ ?)[ \r ]*`,qE=`[̀-ͯ]`,JE=RegExp(`${qE}+$`),YE=`(${HE}+)|${KE}|([!-\\[\\]-‧‪-퟿豈-￿]${qE}*|[\ud800-\udbff][\udc00-\udfff]${qE}*|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5|${GE}|${WE})`,XE=class{constructor(e,t){this.input=e,this.settings=t,this.tokenRegex=new RegExp(YE,`g`),this.catcodes={"%":14,"~":13}}setCatcode(e,t){this.catcodes[e]=t}lex(){let e=this.input,t=this.tokenRegex.lastIndex;if(t===e.length)return new Mw(`EOF`,new jw(this,t,t));let n=this.tokenRegex.exec(e);if(n===null||n.index!==t)throw new U(`Unexpected character: '${e[t]}'`,new Mw(e[t],new jw(this,t,t+1)));let r=n[6]||n[3]||(n[2]?`\\ `:` `);if(this.catcodes[r]===14){let t=e.indexOf(`
145
+ `,this.tokenRegex.lastIndex);if(t===-1){if(this.tokenRegex.lastIndex=e.length,this.settings.strict)throw new U(`% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode`)}else this.tokenRegex.lastIndex=t+1;return this.lex()}return new Mw(r,new jw(this,t,this.tokenRegex.lastIndex))}},ZE=class{constructor(e=Object.create(null),t=Object.create(null)){this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push(Object.create(null))}endGroup(){if(this.undefStack.length===0)throw new U(`Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug`);let e=this.undefStack.pop();for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(e[t]===void 0?delete this.current[t]:this.current[t]=e[t])}has(e){return Object.prototype.hasOwnProperty.call(this.current,e)||Object.prototype.hasOwnProperty.call(this.builtins,e)}get(e){return Object.prototype.hasOwnProperty.call(this.current,e)?this.current[e]:this.builtins[e]}set(e,t,n=!1){if(n){for(let t=0;t<this.undefStack.length;t++)delete this.undefStack[t][e];this.undefStack.length>0&&(this.undefStack[this.undefStack.length-1][e]=t)}else{let t=this.undefStack[this.undefStack.length-1];t&&!Object.prototype.hasOwnProperty.call(t,e)&&(t[e]=this.current[e])}this.current[e]=t}},QE={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0},$E=class{constructor(e,t,n){this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new ZE(Fw,t.macros),this.mode=n,this.stack=[]}feed(e){this.lexer=new XE(e,this.settings)}switchMode(e){this.mode=e}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}future(){return this.stack.length===0&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(e){this.stack.push(e)}pushTokens(e){this.stack.push(...e)}scanArgument(e){let t,n,r;if(e){if(this.consumeSpaces(),this.future().text!==`[`)return null;t=this.popToken(),{tokens:r,end:n}=this.consumeArg([`]`])}else({tokens:r,start:t,end:n}=this.consumeArg());return this.pushToken(new Mw(`EOF`,n.loc)),this.pushTokens(r),new Mw(``,jw.range(t,n))}consumeSpaces(){for(;this.future().text===` `;)this.stack.pop()}consumeArg(e){let t=[],n=e&&e.length>0;n||this.consumeSpaces();let r=this.future(),i,a=0,o=0;do{if(i=this.popToken(),t.push(i),i.text===`{`)++a;else if(i.text===`}`){if(--a,a===-1)throw new U(`Extra }`,i)}else if(i.text===`EOF`)throw new U(`Unexpected end of input in a macro argument, expected '`+(e&&n?e[o]:`}`)+`'`,i);if(e&&n){if((a===0||a===1&&e[o]===`{`)&&i.text===e[o]){if(++o,o===e.length){t.splice(-o,o);break}}else o=0}}while(a!==0||n);return r.text===`{`&&t[t.length-1].text===`}`&&(t.pop(),t.shift()),t.reverse(),{tokens:t,start:r,end:i}}consumeArgs(e,t){if(t){if(t.length!==e+1)throw new U(`The length of delimiters doesn't match the number of args!`);let n=t[0];for(let e=0;e<n.length;e++){let t=this.popToken();if(n[e]!==t.text)throw new U(`Use of the macro doesn't match its definition`,t)}}let n=[];for(let r=0;r<e;r++)n.push(this.consumeArg(t&&t[r+1]).tokens);return n}expandOnce(e){let t=this.popToken(),n=t.text,r=t.noexpand?null:this._getExpansion(n);if(r==null||e&&r.unexpandable){if(e&&r==null&&n[0]===`\\`&&!this.isDefined(n))throw new U(`Undefined control sequence: `+n);return this.pushToken(t),!1}if(this.expansionCount++,this.expansionCount>this.settings.maxExpand)throw new U(`Too many expansions: infinite loop or need to increase maxExpand setting`);let i=r.tokens,a=this.consumeArgs(r.numArgs,r.delimiters);if(r.numArgs){i=i.slice();for(let e=i.length-1;e>=0;--e){let t=i[e];if(t.text===`#`){if(e===0)throw new U(`Incomplete placeholder at end of macro body`,t);if(t=i[--e],t.text===`#`)i.splice(e+1,1);else if(/^[1-9]$/.test(t.text))i.splice(e,2,...a[t.text-1]);else throw new U(`Not a valid argument number`,t)}}}return this.pushTokens(i),i.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(this.expandOnce()===!1){let e=this.stack.pop();return e.treatAsRelax&&(e.text=`\\relax`),e}throw Error()}expandMacro(e){return this.macros.has(e)?this.expandTokens([new Mw(e)]):void 0}expandTokens(e){let t=[],n=this.stack.length;for(this.pushTokens(e);this.stack.length>n;)if(this.expandOnce(!0)===!1){let e=this.stack.pop();e.treatAsRelax&&=(e.noexpand=!1,!1),t.push(e)}return t}expandMacroAsText(e){let t=this.expandMacro(e);return t&&t.map(e=>e.text).join(``)}_getExpansion(e){let t=this.macros.get(e);if(t==null)return t;if(e.length===1){let t=this.lexer.catcodes[e];if(t!=null&&t!==13)return}let n=typeof t==`function`?t(this):t;if(typeof n==`string`){let e=0;if(n.indexOf(`#`)!==-1){let t=n.replace(/##/g,``);for(;t.indexOf(`#`+(e+1))!==-1;)++e}let t=new XE(n,this.settings),r=[],i=t.lex();for(;i.text!==`EOF`;)r.push(i),i=t.lex();return r.reverse(),{tokens:r,numArgs:e}}return n}isDefined(e){return this.macros.has(e)||Object.prototype.hasOwnProperty.call(VE,e)||Object.prototype.hasOwnProperty.call(wC.math,e)||Object.prototype.hasOwnProperty.call(wC.text,e)||Object.prototype.hasOwnProperty.call(QE,e)}isExpandable(e){let t=this.macros.get(e);return t==null?Object.prototype.hasOwnProperty.call(VE,e)&&!VE[e].primitive:typeof t==`string`||typeof t==`function`||!t.unexpandable}},eD=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,tD=Object.freeze({"₊":`+`,"₋":`-`,"₌":`=`,"₍":`(`,"₎":`)`,"₀":`0`,"₁":`1`,"₂":`2`,"₃":`3`,"₄":`4`,"₅":`5`,"₆":`6`,"₇":`7`,"₈":`8`,"₉":`9`,ₐ:`a`,ₑ:`e`,ₕ:`h`,ᵢ:`i`,ⱼ:`j`,ₖ:`k`,ₗ:`l`,ₘ:`m`,ₙ:`n`,ₒ:`o`,ₚ:`p`,ᵣ:`r`,ₛ:`s`,ₜ:`t`,ᵤ:`u`,ᵥ:`v`,ₓ:`x`,ᵦ:`β`,ᵧ:`γ`,ᵨ:`ρ`,ᵩ:`ϕ`,ᵪ:`χ`,"⁺":`+`,"⁻":`-`,"⁼":`=`,"⁽":`(`,"⁾":`)`,"⁰":`0`,"¹":`1`,"²":`2`,"³":`3`,"⁴":`4`,"⁵":`5`,"⁶":`6`,"⁷":`7`,"⁸":`8`,"⁹":`9`,ᴬ:`A`,ᴮ:`B`,ᴰ:`D`,ᴱ:`E`,ᴳ:`G`,ᴴ:`H`,ᴵ:`I`,ᴶ:`J`,ᴷ:`K`,ᴸ:`L`,ᴹ:`M`,ᴺ:`N`,ᴼ:`O`,ᴾ:`P`,ᴿ:`R`,ᵀ:`T`,ᵁ:`U`,ⱽ:`V`,ᵂ:`W`,ᵃ:`a`,ᵇ:`b`,ᶜ:`c`,ᵈ:`d`,ᵉ:`e`,ᶠ:`f`,ᵍ:`g`,ʰ:`h`,ⁱ:`i`,ʲ:`j`,ᵏ:`k`,ˡ:`l`,ᵐ:`m`,ⁿ:`n`,ᵒ:`o`,ᵖ:`p`,ʳ:`r`,ˢ:`s`,ᵗ:`t`,ᵘ:`u`,ᵛ:`v`,ʷ:`w`,ˣ:`x`,ʸ:`y`,ᶻ:`z`,ᵝ:`β`,ᵞ:`γ`,ᵟ:`δ`,ᵠ:`ϕ`,ᵡ:`χ`,ᶿ:`θ`}),nD=Object.freeze({𝒜:`A`,ℬ:`B`,𝒞:`C`,𝒟:`D`,ℰ:`E`,ℱ:`F`,𝒢:`G`,ℋ:`H`,ℐ:`I`,𝒥:`J`,𝒦:`K`,ℒ:`L`,ℳ:`M`,𝒩:`N`,𝒪:`O`,𝒫:`P`,𝒬:`Q`,ℛ:`R`,𝒮:`S`,𝒯:`T`,𝒰:`U`,𝒱:`V`,𝒲:`W`,𝒳:`X`,𝒴:`Y`,𝒵:`Z`}),rD={"́":{text:`\\'`,math:`\\acute`},"̀":{text:"\\`",math:`\\grave`},"̈":{text:`\\"`,math:`\\ddot`},"̃":{text:`\\~`,math:`\\tilde`},"̄":{text:`\\=`,math:`\\bar`},"̆":{text:`\\u`,math:`\\breve`},"̌":{text:`\\v`,math:`\\check`},"̂":{text:`\\^`,math:`\\hat`},"̇":{text:`\\.`,math:`\\dot`},"̊":{text:`\\r`,math:`\\mathring`},"̋":{text:`\\H`},"̧":{text:`\\c`}},iD={á:`á`,à:`à`,ä:`ä`,ǟ:`ǟ`,ã:`ã`,ā:`ā`,ă:`ă`,ắ:`ắ`,ằ:`ằ`,ẵ:`ẵ`,ǎ:`ǎ`,â:`â`,ấ:`ấ`,ầ:`ầ`,ẫ:`ẫ`,ȧ:`ȧ`,ǡ:`ǡ`,å:`å`,ǻ:`ǻ`,ḃ:`ḃ`,ć:`ć`,č:`č`,ĉ:`ĉ`,ċ:`ċ`,ď:`ď`,ḋ:`ḋ`,é:`é`,è:`è`,ë:`ë`,ẽ:`ẽ`,ē:`ē`,ḗ:`ḗ`,ḕ:`ḕ`,ĕ:`ĕ`,ě:`ě`,ê:`ê`,ế:`ế`,ề:`ề`,ễ:`ễ`,ė:`ė`,ḟ:`ḟ`,ǵ:`ǵ`,ḡ:`ḡ`,ğ:`ğ`,ǧ:`ǧ`,ĝ:`ĝ`,ġ:`ġ`,ḧ:`ḧ`,ȟ:`ȟ`,ĥ:`ĥ`,ḣ:`ḣ`,í:`í`,ì:`ì`,ï:`ï`,ḯ:`ḯ`,ĩ:`ĩ`,ī:`ī`,ĭ:`ĭ`,ǐ:`ǐ`,î:`î`,ǰ:`ǰ`,ĵ:`ĵ`,ḱ:`ḱ`,ǩ:`ǩ`,ĺ:`ĺ`,ľ:`ľ`,ḿ:`ḿ`,ṁ:`ṁ`,ń:`ń`,ǹ:`ǹ`,ñ:`ñ`,ň:`ň`,ṅ:`ṅ`,ó:`ó`,ò:`ò`,ö:`ö`,ȫ:`ȫ`,õ:`õ`,ṍ:`ṍ`,ṏ:`ṏ`,ȭ:`ȭ`,ō:`ō`,ṓ:`ṓ`,ṑ:`ṑ`,ŏ:`ŏ`,ǒ:`ǒ`,ô:`ô`,ố:`ố`,ồ:`ồ`,ỗ:`ỗ`,ȯ:`ȯ`,ȱ:`ȱ`,ő:`ő`,ṕ:`ṕ`,ṗ:`ṗ`,ŕ:`ŕ`,ř:`ř`,ṙ:`ṙ`,ś:`ś`,ṥ:`ṥ`,š:`š`,ṧ:`ṧ`,ŝ:`ŝ`,ṡ:`ṡ`,ẗ:`ẗ`,ť:`ť`,ṫ:`ṫ`,ú:`ú`,ù:`ù`,ü:`ü`,ǘ:`ǘ`,ǜ:`ǜ`,ǖ:`ǖ`,ǚ:`ǚ`,ũ:`ũ`,ṹ:`ṹ`,ū:`ū`,ṻ:`ṻ`,ŭ:`ŭ`,ǔ:`ǔ`,û:`û`,ů:`ů`,ű:`ű`,ṽ:`ṽ`,ẃ:`ẃ`,ẁ:`ẁ`,ẅ:`ẅ`,ŵ:`ŵ`,ẇ:`ẇ`,ẘ:`ẘ`,ẍ:`ẍ`,ẋ:`ẋ`,ý:`ý`,ỳ:`ỳ`,ÿ:`ÿ`,ỹ:`ỹ`,ȳ:`ȳ`,ŷ:`ŷ`,ẏ:`ẏ`,ẙ:`ẙ`,ź:`ź`,ž:`ž`,ẑ:`ẑ`,ż:`ż`,Á:`Á`,À:`À`,Ä:`Ä`,Ǟ:`Ǟ`,Ã:`Ã`,Ā:`Ā`,Ă:`Ă`,Ắ:`Ắ`,Ằ:`Ằ`,Ẵ:`Ẵ`,Ǎ:`Ǎ`,Â:`Â`,Ấ:`Ấ`,Ầ:`Ầ`,Ẫ:`Ẫ`,Ȧ:`Ȧ`,Ǡ:`Ǡ`,Å:`Å`,Ǻ:`Ǻ`,Ḃ:`Ḃ`,Ć:`Ć`,Č:`Č`,Ĉ:`Ĉ`,Ċ:`Ċ`,Ď:`Ď`,Ḋ:`Ḋ`,É:`É`,È:`È`,Ë:`Ë`,Ẽ:`Ẽ`,Ē:`Ē`,Ḗ:`Ḗ`,Ḕ:`Ḕ`,Ĕ:`Ĕ`,Ě:`Ě`,Ê:`Ê`,Ế:`Ế`,Ề:`Ề`,Ễ:`Ễ`,Ė:`Ė`,Ḟ:`Ḟ`,Ǵ:`Ǵ`,Ḡ:`Ḡ`,Ğ:`Ğ`,Ǧ:`Ǧ`,Ĝ:`Ĝ`,Ġ:`Ġ`,Ḧ:`Ḧ`,Ȟ:`Ȟ`,Ĥ:`Ĥ`,Ḣ:`Ḣ`,Í:`Í`,Ì:`Ì`,Ï:`Ï`,Ḯ:`Ḯ`,Ĩ:`Ĩ`,Ī:`Ī`,Ĭ:`Ĭ`,Ǐ:`Ǐ`,Î:`Î`,İ:`İ`,Ĵ:`Ĵ`,Ḱ:`Ḱ`,Ǩ:`Ǩ`,Ĺ:`Ĺ`,Ľ:`Ľ`,Ḿ:`Ḿ`,Ṁ:`Ṁ`,Ń:`Ń`,Ǹ:`Ǹ`,Ñ:`Ñ`,Ň:`Ň`,Ṅ:`Ṅ`,Ó:`Ó`,Ò:`Ò`,Ö:`Ö`,Ȫ:`Ȫ`,Õ:`Õ`,Ṍ:`Ṍ`,Ṏ:`Ṏ`,Ȭ:`Ȭ`,Ō:`Ō`,Ṓ:`Ṓ`,Ṑ:`Ṑ`,Ŏ:`Ŏ`,Ǒ:`Ǒ`,Ô:`Ô`,Ố:`Ố`,Ồ:`Ồ`,Ỗ:`Ỗ`,Ȯ:`Ȯ`,Ȱ:`Ȱ`,Ő:`Ő`,Ṕ:`Ṕ`,Ṗ:`Ṗ`,Ŕ:`Ŕ`,Ř:`Ř`,Ṙ:`Ṙ`,Ś:`Ś`,Ṥ:`Ṥ`,Š:`Š`,Ṧ:`Ṧ`,Ŝ:`Ŝ`,Ṡ:`Ṡ`,Ť:`Ť`,Ṫ:`Ṫ`,Ú:`Ú`,Ù:`Ù`,Ü:`Ü`,Ǘ:`Ǘ`,Ǜ:`Ǜ`,Ǖ:`Ǖ`,Ǚ:`Ǚ`,Ũ:`Ũ`,Ṹ:`Ṹ`,Ū:`Ū`,Ṻ:`Ṻ`,Ŭ:`Ŭ`,Ǔ:`Ǔ`,Û:`Û`,Ů:`Ů`,Ű:`Ű`,Ṽ:`Ṽ`,Ẃ:`Ẃ`,Ẁ:`Ẁ`,Ẅ:`Ẅ`,Ŵ:`Ŵ`,Ẇ:`Ẇ`,Ẍ:`Ẍ`,Ẋ:`Ẋ`,Ý:`Ý`,Ỳ:`Ỳ`,Ÿ:`Ÿ`,Ỹ:`Ỹ`,Ȳ:`Ȳ`,Ŷ:`Ŷ`,Ẏ:`Ẏ`,Ź:`Ź`,Ž:`Ž`,Ẑ:`Ẑ`,Ż:`Ż`,ά:`ά`,ὰ:`ὰ`,ᾱ:`ᾱ`,ᾰ:`ᾰ`,έ:`έ`,ὲ:`ὲ`,ή:`ή`,ὴ:`ὴ`,ί:`ί`,ὶ:`ὶ`,ϊ:`ϊ`,ΐ:`ΐ`,ῒ:`ῒ`,ῑ:`ῑ`,ῐ:`ῐ`,ό:`ό`,ὸ:`ὸ`,ύ:`ύ`,ὺ:`ὺ`,ϋ:`ϋ`,ΰ:`ΰ`,ῢ:`ῢ`,ῡ:`ῡ`,ῠ:`ῠ`,ώ:`ώ`,ὼ:`ὼ`,Ύ:`Ύ`,Ὺ:`Ὺ`,Ϋ:`Ϋ`,Ῡ:`Ῡ`,Ῠ:`Ῠ`,Ώ:`Ώ`,Ὼ:`Ὼ`},aD=[`bin`,`op`,`open`,`punct`,`rel`],oD=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/,sD=/^ *\\text/,cD=class e{constructor(e,t,n=!1){this.mode=`math`,this.gullet=new $E(e,t,this.mode),this.settings=t,this.isPreamble=n,this.leftrightDepth=0,this.prevAtomType=``}expect(e,t=!0){if(this.fetch().text!==e)throw new U(`Expected '${e}', got '${this.fetch().text}'`,this.fetch());t&&this.consume()}consume(){this.nextToken=null}fetch(){return this.nextToken??=this.gullet.expandNextToken(),this.nextToken}switchMode(e){this.mode=e,this.gullet.switchMode(e)}parse(){this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set(`\\color`,`\\textcolor`);let e=this.parseExpression(!1);if(this.expect(`EOF`),this.isPreamble){let e=Object.create(null);return Object.entries(this.gullet.macros.current).forEach(([t,n])=>{e[t]=n}),this.gullet.endGroup(),e}let t=this.gullet.macros.get(`\\df@tag`);return this.gullet.endGroup(),t&&(this.gullet.macros.current[`\\df@tag`]=t),e}static get endOfExpression(){return[`}`,`\\endgroup`,`\\end`,`\\right`,`\\endtoggle`,`&`]}subparse(e){let t=this.nextToken;this.consume(),this.gullet.pushToken(new Mw(`}`)),this.gullet.pushTokens(e);let n=this.parseExpression(!1);return this.expect(`}`),this.nextToken=t,n}parseExpression(t,n,r){let i=[];for(this.prevAtomType=``;;){this.mode===`math`&&this.consumeSpaces();let a=this.fetch();if(e.endOfExpression.indexOf(a.text)!==-1||n&&a.text===n||r&&a.text===`\\middle`||t&&VE[a.text]&&VE[a.text].infix)break;let o=this.parseAtom(n);if(!o)break;o.type!==`internal`&&(i.push(o),this.prevAtomType=o.type===`atom`?o.family:o.type)}return this.mode===`text`&&this.formLigatures(i),this.handleInfixNodes(i)}handleInfixNodes(e){let t=-1,n;for(let r=0;r<e.length;r++)if(e[r].type===`infix`){if(t!==-1)throw new U(`only one infix operator per group`,e[r].token);t=r,n=e[r].replaceWith}if(t!==-1&&n){let r,i,a=e.slice(0,t),o=e.slice(t+1);r=a.length===1&&a[0].type===`ordgroup`?a[0]:{type:`ordgroup`,mode:this.mode,body:a},i=o.length===1&&o[0].type===`ordgroup`?o[0]:{type:`ordgroup`,mode:this.mode,body:o};let s;return s=n===`\\\\abovefrac`?this.callFunction(n,[r,e[t],i],[]):this.callFunction(n,[r,i],[]),[s]}return e}handleSupSubscript(e){let t=this.fetch(),n=t.text;this.consume(),this.consumeSpaces();let r;do r=this.parseGroup(e);while(r.type&&r.type===`internal`);if(!r)throw new U(`Expected group after '`+n+`'`,t);return r}formatUnsupportedCmd(e){let t=[];for(let n=0;n<e.length;n++)t.push({type:`textord`,mode:`text`,text:e[n]});let n={type:`text`,mode:this.mode,body:t};return{type:`color`,mode:this.mode,color:this.settings.errorColor,body:[n]}}parseAtom(e){let t=this.parseGroup(`atom`,e);if(t&&t.type===`internal`||this.mode===`text`)return t;let n,r;for(;;){this.consumeSpaces();let e=this.fetch();if(e.text===`\\limits`||e.text===`\\nolimits`){if(t&&t.type===`op`)t.limits=e.text===`\\limits`,t.alwaysHandleSupSub=!0;else if(t&&t.type===`operatorname`)t.alwaysHandleSupSub&&(t.limits=e.text===`\\limits`);else throw new U(`Limit controls must follow a math operator`,e);this.consume()}else if(e.text===`^`){if(n)throw new U(`Double superscript`,e);n=this.handleSupSubscript(`superscript`)}else if(e.text===`_`){if(r)throw new U(`Double subscript`,e);r=this.handleSupSubscript(`subscript`)}else if(e.text===`'`){if(n)throw new U(`Double superscript`,e);let t={type:`textord`,mode:this.mode,text:`\\prime`},r=[t];for(this.consume();this.fetch().text===`'`;)r.push(t),this.consume();this.fetch().text===`^`&&r.push(this.handleSupSubscript(`superscript`)),n={type:`ordgroup`,mode:this.mode,body:r}}else if(tD[e.text]){let t=eD.test(e.text),i=[];for(i.push(new Mw(tD[e.text])),this.consume();;){let e=this.fetch().text;if(!tD[e]||eD.test(e)!==t)break;i.unshift(new Mw(tD[e])),this.consume()}let a=this.subparse(i);t?r={type:`ordgroup`,mode:`math`,body:a}:n={type:`ordgroup`,mode:`math`,body:a}}else break}if(n||r){if(t&&t.type===`multiscript`&&!t.postscripts)return t.postscripts={sup:n,sub:r},t;{let e=!t||t.type!==`op`&&t.type!==`operatorname`?void 0:wT(this.nextToken.text);return{type:`supsub`,mode:this.mode,base:t,sup:n,sub:r,isFollowedByDelimiter:e}}}return t}parseFunction(e,t){let n=this.fetch(),r=n.text,i=VE[r];if(!i)return null;if(this.consume(),t&&t!==`atom`&&!i.allowedInArgument)throw new U(`Got function '`+r+`' with no arguments`+(t?` as `+t:``),n);if(this.mode===`text`&&!i.allowedInText)throw new U(`Can't use function '`+r+`' in text mode`,n);if(this.mode===`math`&&i.allowedInMath===!1)throw new U(`Can't use function '`+r+`' in math mode`,n);let a=this.prevAtomType,{args:o,optArgs:s}=this.parseArguments(r,i);return this.prevAtomType=a,this.callFunction(r,o,s,n,e)}callFunction(e,t,n,r,i){let a={funcName:e,parser:this,token:r,breakOnTokenText:i},o=VE[e];if(o&&o.handler)return o.handler(a,t,n);throw new U(`No function handler for ${e}`)}parseArguments(e,t){let n=t.numArgs+t.numOptionalArgs;if(n===0)return{args:[],optArgs:[]};let r=[],i=[];for(let a=0;a<n;a++){let n=t.argTypes&&t.argTypes[a],o=a<t.numOptionalArgs;(t.primitive&&n==null||t.type===`sqrt`&&a===1&&i[0]==null)&&(n=`primitive`);let s=this.parseGroupOfType(`argument to '${e}'`,n,o);if(o)i.push(s);else if(s!=null)r.push(s);else throw new U(`Null argument, please report this as a bug`)}return{args:r,optArgs:i}}parseGroupOfType(e,t,n){switch(t){case`size`:return this.parseSizeGroup(n);case`url`:return this.parseUrlGroup(n);case`math`:case`text`:return this.parseArgumentGroup(n,t);case`hbox`:{let e=this.parseArgumentGroup(n,`text`);return e==null?null:{type:`styling`,mode:e.mode,body:[e],scriptLevel:`text`}}case`raw`:{let e=this.parseStringGroup(`raw`,n);return e==null?null:{type:`raw`,mode:`text`,string:e.text}}case`primitive`:{if(n)throw new U(`A primitive argument cannot be optional`);let t=this.parseGroup(e);if(t==null)throw new U(`Expected group as `+e,this.fetch());return t}case`original`:case null:case void 0:return this.parseArgumentGroup(n);default:throw new U(`Unknown group type as `+e,this.fetch())}}consumeSpaces(){for(;;){let e=this.fetch().text;if(e===` `||e===`\xA0`||e===`︎`)this.consume();else break}}parseStringGroup(e,t){let n=this.gullet.scanArgument(t);if(n==null)return null;let r=``,i;for(;(i=this.fetch()).text!==`EOF`;)r+=i.text,this.consume();return this.consume(),n.text=r,n}parseRegexGroup(e,t){let n=this.fetch(),r=n,i=``,a;for(;(a=this.fetch()).text!==`EOF`&&e.test(i+a.text);)r=a,i+=r.text,this.consume();if(i===``)throw new U(`Invalid `+t+`: '`+n.text+`'`,n);return n.range(r,i)}parseSizeGroup(e){let t,n=!1;if(this.gullet.consumeSpaces(),t=!e&&this.gullet.future().text!==`{`?this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/,`size`):this.parseStringGroup(`size`,e),!t)return null;!e&&t.text.length===0&&(t.text=`0pt`,n=!0);let r=oD.exec(t.text);if(!r)throw new U(`Invalid size: '`+t.text+`'`,t);let i={number:+(r[1]+r[2]),unit:r[3]};if(!lw(i))throw new U(`Invalid unit: '`+i.unit+`'`,t);return{type:`size`,mode:this.mode,value:i,isBlank:n}}parseUrlGroup(e){this.gullet.lexer.setCatcode(`%`,13),this.gullet.lexer.setCatcode(`~`,12);let t=this.parseStringGroup(`url`,e);if(this.gullet.lexer.setCatcode(`%`,14),this.gullet.lexer.setCatcode(`~`,13),t==null)return null;let n=t.text.replace(/\\([#$%&~_^{}])/g,`$1`);return n=t.text.replace(/{\u2044}/g,`/`),{type:`url`,mode:this.mode,url:n}}parseArgumentGroup(e,t){let n=this.gullet.scanArgument(e);if(n==null)return null;let r=this.mode;t&&this.switchMode(t),this.gullet.beginGroup();let i=this.parseExpression(!1,`EOF`);this.expect(`EOF`),this.gullet.endGroup();let a={type:`ordgroup`,mode:this.mode,loc:n.loc,body:i};return t&&this.switchMode(r),a}parseGroup(e,t){let n=this.fetch(),r=n.text;if(e===`argument to '\\left'`)return this.parseSymbol();let i;if(r===`{`||r===`\\begingroup`||r===`\\toggle`){this.consume();let e=r===`{`?`}`:r===`\\begingroup`?`\\endgroup`:`\\endtoggle`;this.gullet.beginGroup();let t=this.parseExpression(!1,e),a=this.fetch();this.expect(e),this.gullet.endGroup(),i={type:a.text===`\\endtoggle`?`toggle`:`ordgroup`,mode:this.mode,loc:jw.range(n,a),body:t,semisimple:r===`\\begingroup`||void 0}}else if(i=this.parseFunction(t,e)||this.parseSymbol(),i==null&&r[0]===`\\`&&!Object.prototype.hasOwnProperty.call(QE,r)){if(this.settings.throwOnError)throw new U(`Unsupported function name: `+r,n);i=this.formatUnsupportedCmd(r),this.consume()}return i}formLigatures(e){let t=e.length-1;for(let n=0;n<t;++n){let r=e[n],i=r.text;i===`-`&&e[n+1].text===`-`&&(n+1<t&&e[n+2].text===`-`?(e.splice(n,3,{type:`textord`,mode:`text`,loc:jw.range(r,e[n+2]),text:`---`}),t-=2):(e.splice(n,2,{type:`textord`,mode:`text`,loc:jw.range(r,e[n+1]),text:`--`}),--t)),(i===`'`||i==="`")&&e[n+1].text===i&&(e.splice(n,2,{type:`textord`,mode:`text`,loc:jw.range(r,e[n+1]),text:i+i}),--t)}}parseSymbol(){let e=this.fetch(),t=e.text;if(/^\\verb[^a-zA-Z]/.test(t)){this.consume();let e=t.slice(5),n=e.charAt(0)===`*`;if(n&&(e=e.slice(1)),e.length<2||e.charAt(0)!==e.slice(-1))throw new U(`\\verb assertion failed --
146
+ please report what input caused this bug`);return e=e.slice(1,-1),{type:`verb`,mode:`text`,body:e,star:n}}if(Object.prototype.hasOwnProperty.call(iD,t[0])&&this.mode===`math`&&!wC[this.mode][t[0]]){if(this.settings.strict&&this.mode===`math`)throw new U(`Accented Unicode text character "${t[0]}" used in math mode`,e);t=iD[t[0]]+t.slice(1)}let n=this.mode===`math`?JE.exec(t):null;n&&(t=t.substring(0,n.index),t===`i`?t=`ı`:t===`j`&&(t=`ȷ`));let r;if(wC[this.mode][t]){let n=wC[this.mode][t].group;n===`bin`&&(aD.includes(this.prevAtomType)||this.prevAtomType===``)&&(n=`open`);let i=jw.range(e),a;if(Object.prototype.hasOwnProperty.call(SC,n)){let e=n;a={type:`atom`,mode:this.mode,family:e,loc:i,text:t},(e===`rel`||e===`bin`)&&this.prevAtomType===`text`&&sD.test(i.lexer.input.slice(i.end))&&(a.needsSpacing=!0)}else{if(nD[t]){this.consume();let e=this.fetch().text.charCodeAt(0),n=e===65025?`mathscr`:`mathcal`;return(e===65024||e===65025)&&this.consume(),{type:`font`,mode:`math`,font:n,body:{type:`mathord`,mode:`math`,loc:i,text:nD[t]}}}a={type:n,mode:this.mode,loc:i,text:t}}r=a}else if(t.charCodeAt(0)>=128||JE.exec(t)){if(this.settings.strict&&this.mode===`math`)throw new U(`Unicode text character "${t[0]}" used in math mode`,e);r={type:`textord`,mode:`text`,loc:jw.range(e),text:t}}else return null;if(this.consume(),n)for(let t=0;t<n[0].length;t++){let i=n[0][t];if(!rD[i])throw new U(`Unknown accent ' ${i}'`,e);let a=rD[i][this.mode]||rD[i].text;if(!a)throw new U(`Accent ${i} unsupported in ${this.mode} mode`,e);r={type:`accent`,mode:this.mode,loc:jw.range(e),label:a,isStretchy:!1,base:r}}return r}},lD=function(e,t){if(!(typeof e==`string`||e instanceof String))throw TypeError(`Temml can only parse string typed expression`);let n,r;try{r=new cD(e,t),delete r.gullet.macros.current[`\\df@tag`],n=r.parse()}catch(i){if(i.toString()===`ParseError: Unmatched delimiter`)t.wrapDelimiterPairs=!1,r=new cD(e,t),delete r.gullet.macros.current[`\\df@tag`],n=r.parse();else throw i}if(!(n.length>0&&n[0].type&&n[0].type===`array`&&n[0].addEqnNum)&&r.gullet.macros.get(`\\df@tag`)){if(!t.displayMode)throw new U(`\\tag works only in display mode`);r.gullet.feed(`\\df@tag`),n=[{type:`tag`,mode:`text`,body:n,tag:r.parse()}]}return n},uD=[2,2,3,3],dD=class e{constructor(e){this.level=e.level,this.color=e.color,this.font=e.font||``,this.fontFamily=e.fontFamily||``,this.fontSize=e.fontSize||1,this.fontWeight=e.fontWeight||``,this.fontShape=e.fontShape||``,this.maxSize=e.maxSize}extend(t){let n={level:this.level,color:this.color,font:this.font,fontFamily:this.fontFamily,fontSize:this.fontSize,fontWeight:this.fontWeight,fontShape:this.fontShape,maxSize:this.maxSize};for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return new e(n)}withLevel(e){return this.extend({level:e})}incrementLevel(){return this.extend({level:Math.min(this.level+1,3)})}inSubOrSup(){return this.extend({level:uD[this.level]})}withColor(e){return this.extend({color:e})}withFont(e){return this.extend({font:e})}withTextFontFamily(e){return this.extend({fontFamily:e,font:``})}withFontSize(e){return this.extend({fontSize:e})}withTextFontWeight(e){return this.extend({fontWeight:e,font:``})}withTextFontShape(e){return this.extend({fontShape:e,font:``})}getColor(){return this.color}},fD=`0.14.0`;function pD(e){let t={},n=0,r=document.getElementsByClassName(`tml-eqn`);for(let e of r)for(n+=1,e.setAttribute(`id`,`tml-eqn-`+String(n));e.tagName!==`mtable`;){if(e.getElementsByClassName(`tml-label`).length>0){let r=e.attributes.id.value;t[r]=String(n);break}e=e.parentElement}let i=document.getElementsByClassName(`tml-tageqn`);for(let e of i)if(e.getElementsByClassName(`tml-label`).length>0){let n=e.getElementsByClassName(`tml-tag`);if(n.length>0){let r=e.attributes.id.value;t[r]=n[0].textContent}}[...e.getElementsByClassName(`tml-ref`)].forEach(e=>{let n=e.getAttribute(`href`),r=t[n.slice(1)];e.className.indexOf(`tml-eqref`)===-1?(r=r.replace(/^\(/,``),r=r.replace(/\)$/,``)):(r.charAt(0)!==`(`&&(r=`(`+r),r.slice(-1)!==`)`&&(r+=`)`));let i=document.createElementNS(`http://www.w3.org/1998/Math/MathML`,`mtext`);i.appendChild(document.createTextNode(r));let a=document.createElementNS(`http://www.w3.org/1998/Math/MathML`,`math`);a.appendChild(i),e.textContent=``,e.appendChild(a)})}var mD=function(e,t,n){let r=n,i=0,a=e.length;for(;r<t.length;){let n=t[r];if(i<=0&&t.slice(r,r+a)===e)return r;n===`\\`?r++:n===`{`?i++:n===`}`&&i--,r++}return-1},hD=function(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`)},gD=/^\\(?:begin|(?:eq)?ref){/,_D=function(e,t){let n,r=[],i=RegExp(`(`+t.map(e=>hD(e.left)).join(`|`)+`)`);for(;n=e.search(i),n!==-1;){n>0&&(r.push({type:`text`,data:e.slice(0,n)}),e=e.slice(n));let i=t.findIndex(t=>e.startsWith(t.left));if(n=mD(t[i].right,e,t[i].left.length),n===-1)break;let a=e.slice(0,n+t[i].right.length),o=gD.test(a)?a:e.slice(t[i].left.length,n);r.push({type:`math`,data:o,rawData:a,display:t[i].display}),e=e.slice(n+t[i].right.length)}return e!==``&&r.push({type:`text`,data:e}),r},vD=[{left:`$$`,right:`$$`,display:!0},{left:`\\(`,right:`\\)`,display:!1},{left:`\\begin{equation}`,right:`\\end{equation}`,display:!0},{left:`\\begin{equation*}`,right:`\\end{equation*}`,display:!0},{left:`\\begin{align}`,right:`\\end{align}`,display:!0},{left:`\\begin{align*}`,right:`\\end{align*}`,display:!0},{left:`\\begin{alignat}`,right:`\\end{alignat}`,display:!0},{left:`\\begin{alignat*}`,right:`\\end{alignat*}`,display:!0},{left:`\\begin{gather}`,right:`\\end{gather}`,display:!0},{left:`\\begin{gather*}`,right:`\\end{gather*}`,display:!0},{left:`\\begin{CD}`,right:`\\end{CD}`,display:!0},{left:`\\ref{`,right:`}`,display:!1},{left:`\\eqref{`,right:`}`,display:!1},{left:`\\[`,right:`\\]`,display:!0}],yD={$:[{left:`$$`,right:`$$`,display:!0},{left:"$`",right:"`$",display:!1},{left:`$`,right:`$`,display:!1}],"(":[{left:`\\[`,right:`\\]`,display:!0},{left:`\\(`,right:`\\)`,display:!1}]},bD=[{left:`\\begin{equation}`,right:`\\end{equation}`,display:!0},{left:`\\begin{equation*}`,right:`\\end{equation*}`,display:!0},{left:`\\begin{align}`,right:`\\end{align}`,display:!0},{left:`\\begin{align*}`,right:`\\end{align*}`,display:!0},{left:`\\begin{alignat}`,right:`\\end{alignat}`,display:!0},{left:`\\begin{alignat*}`,right:`\\end{alignat*}`,display:!0},{left:`\\begin{gather}`,right:`\\end{gather}`,display:!0},{left:`\\begin{gather*}`,right:`\\end{gather*}`,display:!0},{left:`\\begin{CD}`,right:`\\end{CD}`,display:!0},{left:`\\ref{`,right:`}`,display:!1},{left:`\\eqref{`,right:`}`,display:!1}],xD=e=>e===`$`||e===`(`?yD[e]:e===`$+`||e===`(+`?yD[e.slice(0,1)].concat(bD):e===`ams`?bD:e===`all`?yD[`(`].concat(yD.$).concat(bD):vD,SD=function(e,t){let n=_D(e,t.delimiters);if(n.length===1&&n[0].type===`text`)return null;let r=document.createDocumentFragment();for(let e=0;e<n.length;e++)if(n[e].type===`text`)r.appendChild(document.createTextNode(n[e].data));else{let i=document.createElement(`span`),a=n[e].data;t.displayMode=n[e].display;try{t.preProcess&&(a=t.preProcess(a)),temml.render(a,i,t)}catch(i){if(!(i instanceof U))throw i;t.errorCallback("Temml auto-render: Failed to parse `"+n[e].data+"` with ",i),r.appendChild(document.createTextNode(n[e].rawData));continue}r.appendChild(i)}return r},CD=function(e,t){for(let n=0;n<e.childNodes.length;n++){let r=e.childNodes[n];if(r.nodeType===3){let i=SD(r.textContent,t);i&&(n+=i.childNodes.length-1,e.replaceChild(i,r))}else if(r.nodeType===1){let e=` `+r.className+` `;t.ignoredTags.indexOf(r.nodeName.toLowerCase())===-1&&t.ignoredClasses.every(t=>e.indexOf(` `+t+` `)===-1)&&CD(r,t)}}},wD=function(e,t){if(!e)throw Error(`No element provided to render`);let n={};for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);n.delimiters=n.fences?xD(n.fences):n.delimiters||vD,n.ignoredTags=n.ignoredTags||[`script`,`noscript`,`style`,`textarea`,`pre`,`code`,`option`],n.ignoredClasses=n.ignoredClasses||[],n.errorCallback=n.errorCallback||console.error,n.macros=n.macros||Object.create(null),CD(e,n),pD(e)},TD=function(e,t,n={}){t.textContent=``;let r=t.tagName.toLowerCase()===`math`;r&&(n.wrap=`none`);let i=AD(e,n);r||i.children.length>1?(t.textContent=``,i.children.forEach(e=>{t.appendChild(e.toNode())})):t.appendChild(i.toNode())};typeof document<`u`&&document.compatMode!==`CSS1Compat`&&(typeof console<`u`&&console.warn(`Warning: Temml doesn't work in quirks mode. Make sure your website has a suitable doctype.`),TD=function(){throw new U(`Temml doesn't work in quirks mode.`)});var ED=function(e,t){return AD(e,t).toMarkup()},DD=function(e,t){return lD(e,new QS(t))},OD=function(e,t){let n=new QS(t);if(n.macros=Object.create(null),!(typeof e==`string`||e instanceof String))throw TypeError(`Temml can only parse string typed expression`);let r=new cD(e,n,!0);return delete r.gullet.macros.current[`\\df@tag`],r.parse()},kD=function(e,t,n){if(n.throwOnError||!(e instanceof U))throw e;let r=new uC([`temml-error`],[new dC(t+`
147
+
148
+ `+e.toString())]);return r.style.color=n.errorColor,r.style.whiteSpace=`pre-line`,r},AD=function(e,t){let n=new QS(t);try{return $C(lD(e,n),e,new dD({level:n.displayMode?Nw.DISPLAY:Nw.TEXT,maxSize:n.maxSize}),n)}catch(t){return kD(t,e,n)}},jD={version:fD,render:TD,renderToString:ED,renderMathInElement:wD,postProcess:pD,ParseError:U,definePreamble:OD,__parse:DD,__renderToMathMLTree:AD,__defineSymbol:G,__defineMacro:Q},MD=/(?<=["\u201c])(?:[A-Za-z]:\\|\\\\[A-Za-z0-9_.$-]+\\)(?:\\\*|[^"`<>|*\r\n\u201c\u201d])+(?=["\u201d])|(?:(?<![A-Za-z0-9])[A-Za-z]:\\|\\\\[A-Za-z0-9_.$-]+\\)(?:\\\*|[^\s"`()\]<>|*]|(?:(?<![,;])(?: +(?:[^\s"`()\]<>|*\\,;:]|\([^\s"`()\]<>|*\\,;:]*\))+)+|(?<=[,;]) +(?:[^\s"`()\]<>|*\\,;:]|\([^\s"`()\]<>|*\\,;:]*\))+)(?=\\)|\((?:\\\*|[^\s"`()\]<>|*])*\))*/g,ND=/\\([!-/:-@[-`{-~])/g;function PD(e){return e.replace(ND,`$1`)}function FD(e,t){if(e.type===`text`&&typeof e.value==`string`){let n=e.position?.start.offset,r=e.position?.end.offset;if(n===void 0||r===void 0)return;let i=t.slice(n,r);if(!i.includes(`\\`))return;let a=e.value,o=0;for(let e of i.matchAll(MD)){let t=e[0],n=PD(t);if(n===t){let e=a.indexOf(t,o);e!==-1&&(o=e+t.length);continue}let r=a.indexOf(n,o);r!==-1&&(a=a.slice(0,r)+t+a.slice(r+n.length),o=r+t.length)}e.value=a}else e.children?.forEach(e=>FD(e,t))}function ID(){return(e,t)=>{typeof t.value==`string`&&FD(e,t.value)}}function LD(e){if(!e.children)return;let t=[];for(let n of e.children)n.type===`text`&&n.value?.includes(`
149
+ `)?n.value.split(`
150
+ `).forEach((e,n)=>{n>0&&t.push({type:`break`}),e&&t.push({type:`text`,value:e})}):(LD(n),t.push(n));e.children=t}function RD(){return e=>{LD(e)}}var zD=/^\s*(```|~~~)/,BD=/(`+)[\s\S]*?\1/g,VD=/[\\^_{}]/,HD=e=>`$$${e}$$`;function UD(e){return e.replace(/\\\((.+?)\\\)/g,(e,t)=>HD(t)).replace(/\\\[(.+?)\\\]/g,(e,t)=>HD(t)).replace(/(^|[^\\$])\$(?![\s$])([^$\n]*?[^\s$\\])\$(?![\d$])/g,(e,t,n)=>VD.test(n)?t+HD(n):e)}function WD(e){let t=/^(\s*)(?:\\\[((?:(?!\\\]).)+)\\\]|\$\$((?:(?!\$\$).)+)\$\$)\s*$/.exec(e);if(t){let e=t[1];return`${e}$$\n${e}${(t[2]??t[3]).trim()}\n${e}$$`}let n=/^(\s*)\\[[\]]\s*$/.exec(e);if(n)return`${n[1]}$$`;let r=``,i=0;for(let t of e.matchAll(BD))r+=UD(e.slice(i,t.index))+t[0],i=t.index+t[0].length;return r+UD(e.slice(i))}function GD(e){if(!e.includes(`$`)&&!e.includes(`\\`))return e;let t=!1;return e.split(`
151
+ `).map(e=>zD.test(e)?(t=!t,e):t?e:WD(e)).join(`
152
+ `)}var KD=/^[-+−]?[$€£¥]?\s?\d[\d,.\s]*\s?(?:%|[kKmMbB]|[KMGT]?B|[$€£¥])?$/,qD=/^[-—–]?$/;function JD(e){return e.value===void 0?(e.children??[]).map(JD).join(``):e.value}function YD(e){let t=e.children??[],n=t.slice(1);if(n.length===0)return;let r=Math.max(...t.map(e=>e.children?.length??0));for(let i=0;i<r;i++){if(e.align?.[i])continue;let r=n.map(e=>JD(e.children?.[i]??{type:`text`,value:``}).trim()).filter(e=>!qD.test(e));if(r.length!==0&&r.every(e=>KD.test(e)))for(let e of t){let t=e.children?.[i];t&&(t.data={...t.data,hProperties:{...t.data?.hProperties,className:`is-numeric`}})}}}function XD(e){e.type===`table`?YD(e):e.children?.forEach(XD)}function ZD(){return e=>{XD(e)}}function QD(e){if(!/^[-/]/.test(e))return!1;let t=e.slice(1).split(`:`,1)[0].toLowerCase();return t===`e`||t===`ec`||t.length>=3&&`encodedcommand`.startsWith(t)}function $D(e){let t=e.split(/\s+/).filter(Boolean),n=t.findIndex(e=>/(^|[\\/])(powershell|pwsh)(\.exe)?["']?$/i.test(e.replace(/^["']/,``)));if(n<0)return``;for(let e=n+1;e<t.length-1;e++){if(!QD(t[e]))continue;let n=t[e+1].replace(/^["']|["']$/g,``);try{let e=Uint8Array.from(atob(n),e=>e.charCodeAt(0));return new TextDecoder(`utf-16le`,{fatal:!0}).decode(e)}catch(e){return console.debug(`EncodedCommand operand is not base64 UTF-16LE`,e),``}}return``}function eO(e){let t=``,n=!1;for(let r=0;r<e.length;r++){let i=e[r];i===`"`&&(n=!n),i===`^`&&!n?(r+=1,r<e.length&&(t+=e[r])):t+=i}return t}function tO(e){return e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function nO(e){return e===null?``:String(e)}function rO(e){return e===void 0||typeof e==`string`}function iO(e){return`+${e-500} more (truncated)`}function aO(e){return e.startsWith(`+`)?`render-diff__line render-diff__line--added`:e.startsWith(`-`)?`render-diff__line render-diff__line--removed`:`render-diff__line`}var oO=20,sO=2,cO=new Set([` `,`
153
+ `]),lO=(e,t)=>yd(cO,e,t),uO=e=>Fd(cO,e);function dO(e){return typeof e.old_content==`string`&&typeof e.new_content==`string`?{kind:`edit`,lines:fO(e.old_content,e.new_content)}:typeof e.content==`string`&&(typeof e.file_path==`string`||typeof e.path==`string`)?{kind:`write`,text:e.content}:null}function fO(e,t){let n=e=>e.replace(/\r\n/g,`
154
+ `).replace(/\n$/,``).split(`
155
+ `),r=e?n(e):[],i=t?n(t):[],a=0;for(;a<r.length&&a<i.length&&r[a]===i[a];)a++;let o=0;for(;o<r.length-a&&o<i.length-a&&r[r.length-1-o]===i[i.length-1-o];)o++;return a+o>=r.length&&a+o>=i.length&&e!==t?[...r.map(e=>`-${e}`),...i.map(e=>`+${e}`)]:[...r.slice(Math.max(0,a-sO),a).map(e=>` ${e}`),...r.slice(a,r.length-o).map(e=>`-${e}`),...i.slice(a,i.length-o).map(e=>`+${e}`),...r.slice(r.length-o,r.length-o+sO).map(e=>` ${e}`)]}function pO({lines:e}){let t=L(),[n,r]=(0,V.useState)(!1),i=e.length>oO,a=i&&!n?e.slice(0,oO):e;return R(F.Fragment,{children:[I(`pre`,{dir:`ltr`,className:`render-diff__body perm-card-diff`,"data-testid":`perm-edit-diff`,children:a.map((e,t)=>I(`div`,{className:aO(e),children:lO(e,!0)},t))}),i&&I(`button`,{type:`button`,className:`perm-card-args-toggle`,onClick:()=>r(e=>!e),"aria-expanded":n,children:n?t(`prompt.showLess`):t(`prompt.showAllLines`,{n:e.length})})]})}function mO({args:e}){let t=L(),n=dO(e);if(!n)return null;let r=n.kind===`edit`?uO(e.old_content)||uO(e.new_content):uO(n.text);return R(`div`,{className:`perm-card-change`,children:[I(`p`,{className:`perm-card-change-label`,children:t(n.kind===`edit`?`prompt.willChange`:`prompt.willWrite`)}),n.kind===`edit`?I(pO,{lines:n.lines}):n.text?I(VO,{code:lO(n.text,!0),previewLines:oO,testId:`perm-write-preview`,exact:!0}):I(`p`,{className:`perm-card-detail`,children:t(`prompt.emptyFile`)}),r&&I(`p`,{className:`perm-card-risk`,role:`note`,"data-testid":`perm-change-unseen`,children:t(`prompt.unseenChars`)})]})}var hO=/^GAIA can't check where this command reads or writes: (.+)\. It can reach files outside the folders this chat may use(, and GAIA can't tell whether it goes online)?\.$/s,gO=[[/^(\S+) runs code, which can read and write anywhere you can$/,`prompt.unchecked.why.runsCode`],[/^(\S+) runs a script file, which GAIA does not read$/,`prompt.unchecked.why.runsScript`],[/^GAIA has no rule for what (\S+) reads or writes$/,`prompt.unchecked.why.noRule`],[/^(\S+) starts other programs, which GAIA can't follow$/,`prompt.unchecked.why.startsPrograms`],[/^it runs the program file (\S+), which GAIA can't inspect$/,`prompt.unchecked.why.programFile`],[/^it runs the commands in a file, which GAIA does not read$/,`prompt.unchecked.why.commandsFile`],[/^a file name in it is worked out while the command runs$/,`prompt.unchecked.why.workedOut`],[/^cmd\.exe runs it, and GAIA reads only bash commands$/,`prompt.unchecked.why.cmdExe`]];function _O(e){for(let[t,n]of gO){let r=t.exec(e);if(r)return de(n,r[1]?{name:r[1]}:void 0)}return null}function vO(e,t){let n=hO.exec(e.trim());if(!n)return e;let r=!!n[2],i=_O(n[1]);return i?t(r?`prompt.unchecked.offline`:`prompt.unchecked`,{why:i}):t.locale===`en`?e:t(r?`prompt.unchecked.plainOffline`:`prompt.unchecked.plain`)}function yO(e){let t=e.toolArgs??{},n=[`command`,`file_path`,`path`,`url`,`_site`,`query`,`name`].find(e=>typeof t[e]==`string`&&t[e].trim());return n?{key:n,text:t[n]}:{key:``,text:``}}function bO(e,t){return xO.test(e)?{shown:Ed(t),coded:Od(t)}:e===`query`?{shown:bd(t,!0),coded:Id(t)}:{shown:Td(t),coded:Dd(t)}}var xO=/^(command|cmd|argv)$/,SO=RegExp(`^(command|cmd|argv|_site|to|from|href)$|(^|_)(files?|urls?|uris?|ids?|guids?|uuids?|cwds?|src|dest|source|destination|target|location|branch|repo)$|(paths?|dirs?|director(y|ies)|folders?|names?)(_hint)?$`);function CO(e){let t=e.replace(/([a-z0-9])([A-Z])/g,`$1_$2`).replace(/([A-Z])([A-Z][a-z])/g,`$1_$2`).toLowerCase().replace(/\d+$/,``);return SO.test(t)}function wO(e){let t=(e,n)=>typeof n==`string`?CO(e)?bO(e,n).shown:n:Array.isArray(n)?n.map(n=>t(e,n)):n&&typeof n==`object`?wO(n):n;return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(e,n)]))}var TO=new Set([`run_shell_command`,`wait_for_condition`]),EO=new Set([`run_python`,`execute_python_file`]),DO=[`send_now`,`send_draft`,`reply_to_message`,`forward_message`,`discard_draft`,`update_draft`],OO=new Set([...DO,...DO.map(e=>`send-email/${e}`)]),kO=[[`Attachments left out, not sent`,`permission.mail.leftOut`],[`Attachments`,`permission.mail.attachments`],[`Subject`,`permission.mail.subject`],[`Format`,`permission.mail.format`],[`From`,`permission.mail.from`],[`Bcc`,`permission.mail.bcc`],[`Cc`,`permission.mail.cc`],[`To`,`permission.mail.to`]],AO=RegExp(`^(${kO.map(([e])=>e).join(`|`)}): (.*)$`),jO=new Set([`From`,`To`,`Cc`,`Bcc`]);function MO(e){let t=e.split(`
156
+ `),n=e=>!!e&&/^(From|To): /.test(e),r=0;for(;!n(t[r]);){let e=t.indexOf(``,r);if(e<0)return null;r=e+1}let i=[],a=r;for(;a<t.length&&t[a]!==``;a++){let e=AO.exec(t[a]);if(!e)return null;i.push([e[1],e[2]])}return i.some(([e])=>e===`To`)?{before:t.slice(0,Math.max(0,r-1)).join(`
157
+ `),fields:i,body:t.slice(a+1).join(`
158
+ `)}:null}function NO({header:e}){let t=L(),n=new Map(kO);return I(`dl`,{className:`perm-card-facts perm-mail-header`,"data-testid":`perm-mail-header`,children:e.fields.map(([e,r],i)=>R(V.Fragment,{children:[I(`dt`,{children:t(n.get(e))}),I(`dd`,{className:e===`From`?`perm-mail-from`:void 0,children:I(`bdi`,{dir:jO.has(e)?`ltr`:`auto`,children:r})})]},i))})}function PO(e){let t=e.split(`
159
+ `);if(t.length<2)return null;let n=!t[t.length-1].startsWith(`in `),r=n?t[t.length-1].trim():``,i=n?t.slice(0,-1):t,a=-1;for(let e=i.length-1;e>0;e--)if(i[e].startsWith(`in `)){a=e;break}return a<0?{command:i.join(`
160
+ `),folder:``,extras:``,note:r}:{command:i.slice(0,a).join(`
161
+ `),folder:i[a].slice(3).trim(),extras:i.slice(a+1).join(` `).trim(),note:r}}var FO=`execute_python_file`,IO={missing:`prompt.scriptUnreadable.missing`,not_text:`prompt.scriptUnreadable.not_text`,too_large:`prompt.scriptUnreadable.too_large`,unreadable:`prompt.scriptUnreadable.unreadable`};function LO(e,t){let n=t._script;if(e!==FO||typeof n!=`object`||!n)return null;let{text:r,hidden_lines:i,unreadable:a}=n;return typeof r==`string`?{text:r,hiddenLines:typeof i==`number`&&i>0?i:0,unreadable:null}:{text:null,hiddenLines:0,unreadable:typeof a==`string`&&a in IO?a:`unreadable`}}var RO=64;function zO(e){return e.length<=RO?e:`${e.slice(0,44)} … ${e.slice(-16)}`}function BO(e){return e.includes("`")?e.length<=RO?e:`${e.slice(0,44)} … ${e.slice(-16)}`:e.replace(/(\s\u2068?)((?:[A-Za-z]:)?[\\/][^\u2069]*)(\u2069?)$/,(e,t,n,r)=>`${t}${n.split(/[\\/]/).filter(Boolean).pop()??n}${r}`)}function VO({code:e,previewLines:t=12,testId:n=`perm-code`,exact:r=!1}){let i=L(),[a,o]=(0,V.useState)(!1),s=(r?e.replace(/\n$/,``):e.replace(/^\n+|\n+$/g,``)).split(`
162
+ `),c=s.length>t,l=(c&&!a?s.slice(0,t):s).join(`
163
+ `);return R(F.Fragment,{children:[I(`pre`,{dir:`ltr`,className:`perm-card-pre perm-card-code${a?` is-expanded`:``}`,"data-testid":n,children:l}),c&&I(`button`,{type:`button`,className:`perm-card-args-toggle`,onClick:()=>o(e=>!e),"aria-expanded":a,children:a?i(`prompt.showLess`):i(`prompt.showAllLines`,{n:s.length})})]})}function HO({sessionId:e}){let t=fu((0,V.useMemo)(()=>gu(e),[e]));return t?I(WO,{notification:t},t.id):null}function UO(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;return`${t}:${String(n).padStart(2,`0`)}`}function WO({notification:e}){let t=L(),n=fu(e=>e.respondToPermission),[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(!1),l=e.timeoutSeconds!=null&&e.timeoutSeconds>0,u=(0,V.useRef)(l?e.expiresAt??Date.now()+e.timeoutSeconds*1e3:null),[d,f]=(0,V.useState)(u.current===null?null:Math.max(0,Math.ceil((u.current-Date.now())/1e3))),p=(0,V.useRef)(null),m=uu(e.tool),h=m?void 0:e.alwaysScope,g=e.alwaysScope&&Td(e.alwaysScope),_=ou({...e,alwaysScope:g},t)??Td(e.alwaysLabel??h??``),v=au(g,e=>El(zO(e)))??BO(_),y=au(g,El)??_,b=fu(t=>du(t.notifications,e)),x=!!h&&b>0,S=yO(e),C=S.text,w=e.toolArgs??{},T=Object.keys(w).length>0,E=typeof w._risk_note==`string`?vO(w._risk_note,t):``,ee=E&&typeof w.working_directory==`string`?w.working_directory:``,D=LO(e.tool,w),O=typeof w.code==`string`&&w.code.trim()?w.code:D?.text?.trim()?D.text:``,te=(O||EO.has(e.tool??``))&&!E?t(`prompt.codeRisk`):``,A=D?Object.fromEntries(Object.entries(w).filter(([e])=>e!==`_script`)):w,ne=typeof w._exact_text==`string`?w._exact_text:OO.has(e.tool??``)?e.summary??``:``,j=!T&&TO.has(e.tool??``)?PO(e.summary??``):null,M=ne?MO(ne):null,re=e.tool===Yl,{heading:ie,question:ae}=eu(e,t,e=>El(Td(e))),{shown:oe,coded:se}=bO(S.key,C),ce=typeof w.command==`string`?w.command:j?.command??``,le=ce?$D(ce):``,ue=ce.includes(`^`)?eO(ce):``,de=se||[O,j?.extras].some(Id)||[ce,le].some(Od)||[w.path,ee,j?.folder].some(Dd),fe=td.has(e.tool??``);(0,V.useEffect)(()=>{p.current?.focus({preventScroll:!0})},[]),(0,V.useEffect)(()=>{if(u.current===null)return;let e=setInterval(()=>{let t=Math.max(0,Math.ceil((u.current-Date.now())/1e3));f(t),t===0&&clearInterval(e)},1e3);return()=>clearInterval(e)},[]);let pe=(0,V.useCallback)(async t=>{i(!0),o(null);try{await n(e.id,t)}catch(e){o(e instanceof Error?e.message:String(e)),i(!1)}},[e.id,n]);(0,V.useEffect)(()=>{let e=e=>{e.key!==`Escape`||kn(e)||d!==null&&d<=0||(e.preventDefault(),r||pe(`deny`))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[pe,r,d]);let me=d!==null&&d<=0;return R(`section`,{ref:p,tabIndex:-1,className:`perm-card`,role:`alertdialog`,"aria-labelledby":`perm-${e.id}`,children:[R(`div`,{className:`perm-card-head`,children:[I(Rs,{size:16,className:`perm-card-icon`,"aria-hidden":`true`}),R(`div`,{className:`perm-card-text`,children:[I(`h2`,{id:`perm-${e.id}`,className:`perm-card-title`,children:I(kl,{text:ie})}),C&&E&&I(`pre`,{dir:`ltr`,className:`perm-card-pre perm-card-exact`,children:oe}),C&&!E&&I(`p`,{className:`perm-card-detail`,children:I(`code`,{dir:`ltr`,children:oe})}),ee&&R(`p`,{className:`perm-card-detail`,children:[t.bare(`prompt.in`),` `,I(`code`,{dir:`ltr`,children:Td(ee)})]}),E&&I(`p`,{className:`perm-card-risk`,role:`note`,children:I(`bdi`,{children:bd(E,!0)})}),O&&I(VO,{code:bd(O,!0)}),D?.text!=null&&!D.text.trim()&&I(`p`,{className:`perm-card-detail`,"data-testid":`perm-script-empty`,children:t(`prompt.scriptEmpty`)}),!!D?.hiddenLines&&I(`p`,{className:`perm-card-risk`,role:`note`,"data-testid":`perm-script-more`,children:I(`bdi`,{children:t.plural(`prompt.scriptMoreLines`,D.hiddenLines,{n:D.hiddenLines})})}),D?.unreadable&&I(`p`,{className:`perm-card-risk`,role:`note`,"data-testid":`perm-script-unreadable`,children:I(`bdi`,{children:t(IO[D.unreadable])})}),te&&I(`p`,{className:`perm-card-risk`,role:`note`,"data-testid":`perm-code-risk`,children:I(`bdi`,{children:te})}),M?.before&&I(`pre`,{dir:`ltr`,className:`perm-card-pre perm-card-exact`,children:M.before}),M&&I(NO,{header:M}),ne&&I(`pre`,{dir:`ltr`,className:`perm-card-pre perm-card-exact`,"data-testid":`perm-exact-text`,children:M?M.body:ne}),j&&I(`pre`,{dir:`ltr`,className:`perm-card-pre perm-card-exact`,children:Ed(j.command)}),le&&I(`p`,{className:`perm-card-detail`,children:t(`prompt.decodedCommand`)}),le&&I(`pre`,{dir:`ltr`,className:`perm-card-pre perm-card-exact`,"data-testid":`perm-decoded`,children:Ed(le)}),ue&&ue!==ce&&I(`p`,{className:`perm-card-detail`,children:t(`prompt.cmdReading`)}),ue&&ue!==ce&&I(`pre`,{dir:`ltr`,className:`perm-card-pre perm-card-exact`,"data-testid":`perm-cmd-reading`,children:Ed(ue)}),de&&I(`p`,{className:`perm-card-risk`,role:`note`,"data-testid":`perm-hidden-note`,children:I(`bdi`,{children:t(`prompt.hiddenChars`)})}),j?.folder&&R(`p`,{className:`perm-card-detail`,children:[t.bare(`prompt.in`),` `,I(`code`,{dir:`ltr`,children:Td(j.folder)})]}),j?.extras&&I(`p`,{className:`perm-card-detail`,children:I(`bdi`,{children:bd(j.extras,!1)})}),j?.note&&I(`p`,{className:`perm-card-risk`,role:`note`,children:I(`bdi`,{children:j.note})}),fe&&T&&I(Gd,{tool:e.tool,args:w}),fe&&!T&&e.summary&&I(`pre`,{dir:`ltr`,className:`perm-card-pre perm-card-exact`,"data-testid":`perm-exact-summary`,children:e.summary}),!C&&!O&&!ne&&!fe&&e.summary&&!j&&I(`p`,{className:`perm-card-detail`,children:I(`bdi`,{children:bd(e.summary,!0)})}),m&&I(`p`,{className:`perm-card-detail perm-card-question`,children:I(kl,{text:ae})}),I(mO,{args:w})]}),d!==null&&!me&&I(`span`,{className:`perm-card-timer`,title:t(`prompt.timer`),children:UO(d)})]}),T&&!ne&&R(`div`,{className:`perm-card-args`,children:[R(`button`,{type:`button`,className:`perm-card-args-toggle`,onClick:()=>c(e=>!e),"aria-expanded":s,children:[I(gi,{size:13,className:s?`is-open`:``,"aria-hidden":`true`}),t(dO(w)?`prompt.technicalDetails`:`prompt.details`)]}),s&&I(`pre`,{dir:`ltr`,className:`perm-card-pre`,children:bd(JSON.stringify(wO(A),null,2),!0)})]}),x&&!me&&I(`p`,{className:`perm-card-hint`,children:I(kl,{text:t.compose(e=>`${e(k(`prompt.repeated`,b),{n:b})} ${e(`prompt.alwaysHint`,{scope:y})}`)})}),me?I(`p`,{className:`perm-card-detail`,children:t(`prompt.expired`)}):R(`div`,{className:`perm-card-actions`,children:[I(`button`,{type:`button`,className:`perm-btn is-primary`,onClick:()=>pe(`allow`),disabled:r,children:t(e.tool===`trust_project_folder`?`prompt.trust.allow`:re?`prompt.allowForChat`:`prompt.allowOnce`)}),h&&I(`button`,{type:`button`,className:`perm-btn is-lasting${x?` is-suggested`:``}`,onClick:()=>pe(`always`),disabled:r,title:_,children:I(`span`,{className:`perm-btn-label`,children:I(kl,{text:t(`prompt.alwaysAllow`,{scope:v})})})}),I(`button`,{type:`button`,className:`perm-btn`,onClick:()=>pe(`deny`),disabled:r,children:t(`prompt.deny`)})]}),a&&I(`p`,{className:`perm-card-error`,role:`alert`,children:a})]})}function GO(e){if(typeof document.execCommand!=`function`)return!1;let t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=document.createElement(`textarea`);n.value=e,n.setAttribute(`readonly`,``),n.style.position=`fixed`,n.style.opacity=`0`,document.body.appendChild(n);try{return n.select(),document.execCommand(`copy`)}catch{return!1}finally{n.remove(),t?.focus()}}async function KO(e){let t=null;if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch(e){t=e}if(!GO(e))throw t??Error(`Clipboard is not available here`)}var qO=2e3,JO=4e3;function YO(){let[e,t]=(0,V.useState)(`idle`),n=(0,V.useRef)(null),r=(0,V.useRef)(!0);(0,V.useEffect)(()=>(r.current=!0,()=>{r.current=!1,n.current&&clearTimeout(n.current)}),[]);let i=(0,V.useCallback)((e,i)=>{r.current&&(t(e),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>t(`idle`),i))},[]);return[e,(0,V.useCallback)(e=>{KO(e).then(()=>i(`copied`,qO),e=>{P.ui.warn(`Copy to clipboard failed`,e),i(`failed`,JO)})},[i])]}function XO(e,t){return e.bare(k(`size.lines`,t),{n:t.toLocaleString(`en-US`)})}function ZO(e){return e?e.split(`
164
+ `).length:0}function QO(e){return ZO(e)>15||e.length>1500}var $O=e=>e.length>300?`${e.slice(0,300)}…`:e;function ek(e){let t=e.split(`
165
+ `);return t.length<=15?null:{head:t.slice(0,3).map($O).join(`
166
+ `),tail:t.slice(-3).map($O).join(`
167
+ `),hidden:t.length-6}}function tk(e,t,n=15){let r=ZO(t);return r>n?XO(e,r):e.bare(k(`size.characters`,t.length),{n:t.length.toLocaleString(`en-US`)})}function nk({expanded:e,onToggle:t,controls:n,collapsedLabel:r,expandedLabel:i,className:a}){return R(`button`,{type:`button`,className:`expand-toggle${a?` ${a}`:``}`,onClick:t,"aria-expanded":e,"aria-controls":n,children:[I(e?vi:fi,{size:13,"aria-hidden":`true`}),I(`span`,{children:e?i:r})]})}function rk(e){let t=e.replace(/\\(u[0-9a-fA-F]{0,3})?$/,``);try{return JSON.parse(`"${t}"`)}catch{return t}}function ik(e,t){let n=RegExp(`"${t}"\\s*:\\s*(\\d+)`).exec(e);return n?Number(n[1]):null}function ak(e,t){let n=RegExp(`"${t}"\\s*:\\s*"((?:[^"\\\\]|\\\\.)*)`).exec(e);return n?rk(n[1]):``}function ok(e){let t=e.trim();if(!t.startsWith(`{`))return null;let n;try{n=JSON.parse(t)}catch{return!/^\{\s*"truncated"\s*:\s*true\b/.test(t)||!/"head"\s*:\s*"/.test(t)?null:{head:ak(t,`head`),tail:ak(t,`tail`),originalChars:ik(t,`original_chars`),omittedChars:ik(t,`omitted_chars`),partial:!0}}if(!n||typeof n!=`object`)return null;let r=n;return r.truncated!==!0||typeof r.head!=`string`?null:{head:r.head,tail:typeof r.tail==`string`?r.tail:``,originalChars:typeof r.original_chars==`number`?r.original_chars:null,omittedChars:typeof r.omitted_chars==`number`?r.omitted_chars:null,partial:!1}}function sk(e){let t=e=>e.toLocaleString(`en-US`);return`Showing ${e.partial?`part of the output`:e.tail?`the first ${t(e.head.length)} and last ${t(e.tail.length)} characters`:`the first ${t(e.head.length)} characters`}${e.originalChars==null?``:` of ${t(e.originalChars)}`}${e.omittedChars==null?``:` (${t(e.omittedChars)} omitted)`}.`}function ck({text:e,renderShort:t}){let n=L(),[r,i]=(0,V.useState)(!1),a=(0,V.useId)(),o=ok(e),s=o?o.tail?`${o.head}\n…\n${o.tail}`:o.head:e,c=ZO(s)>25||s.length>2500;return R(F.Fragment,{children:[o&&I(`div`,{className:`detail-result-note`,children:sk(o)}),I(`div`,{id:a,className:`detail-result-content${c&&!r?` is-collapsed`:``}`,children:o||c?Nd(s):t(s)}),c&&I(nk,{expanded:r,onToggle:()=>i(e=>!e),controls:a,collapsedLabel:n(`code.expand`,{size:tk(n,s,25)}),expandedLabel:n(`code.collapse`),className:`step-expand-toggle`})]})}var lk=null;function uk(e){if(!lk){lk=new Map;for(let[e,t]of Object.entries(se))/^tool\..+\.active$/.test(e)&&!t.includes(`{`)&&!lk.has(t)&&lk.set(t,e)}return lk.get(e)}function dk(e){let t=uk(e);if(t)return de(t);let n=/^(.+?): (.+)$/s.exec(e),r=n?uk(n[1]):void 0;return n&&r?de(`live.toolAction`,{action:de(r),detail:n[2]}):e}function fk(e,t){let n=uk(t);if(n)return e(n);let r=/^(.+?): (.+)$/s.exec(t),i=r?uk(r[1]):void 0;return r&&i?e.bare(`live.toolAction`,{action:e(i),detail:r[2]}):t}var pk={"Thinking...":`msg.thinking`,"Reading your request":`live.readingRequest`,"Reading the tool results":`live.readingResults`,Reasoning:`live.reasoning`,"Reconnecting to the model server…":`live.reconnectingServer`,"Waiting for GAIA to start this answer…":`live.waitingStart`,"The model server stopped. GAIA is restarting it…":`live.serverRestarting`,"Starting the model server…":`live.serverStarting`},mk=new Map([[`its files could not be found`,`live.skillReloadMissing`],[`the current model does not offer the tools it needs`,`live.skillReloadModel`],[`the current settings do not permit it to load`,`live.skillReloadPermission`],[`it failed to load with the current settings`,`live.skillReloadFailed`]]);function hk(e,t){return t===`Not available yet: gaiacpp doesn't report what fills its context.`?e(`ctx.nativeUnavailable`):t}function gk(e,t){let n=pk[t];if(n)return e(n);let r=/^Skill '([a-z0-9-]+)' was not restored after settings changed: ([^.]+)\. Reload it if needed\.$/.exec(t);if(r){let t=mk.get(r[2]);if(t)return e(t,{skill:r[1]})}let i=/^(Full access|Accept edits) is on, so GAIA didn't ask first\. (.+)$/s.exec(t);return i?e(i[1]===`Full access`?`live.fullAccessAuto`:`live.acceptEditsAuto`,{action:dk(i[2])}):(i=/^Reasoning — ([\d,]+) words? so far$/.exec(t),i?i[1]===`1`?e.plural(`chat.reasoningWords`,1,{n:i[1]}):e(`live.reasoningWords`,{n:i[1]}):(i=/^Connection lost\. Reconnecting \(attempt (\d+) of (\d+)\)…$/.exec(t),i?e(`live.reconnectingStream`,{attempt:i[1],max:i[2]}):(i=/^Loading (\S+) into memory$/.exec(t),i?e(`live.loadingModel`,{model:i[1]}):(i=/^Reading page (\d+) of (\d+)…$/.exec(t),i?e(`live.readingPage`,{page:i[1],total:i[2]}):(i=/^Waiting for the GPU — (\d+)(?:st|nd|rd|th) in line$/.exec(t),i?zu(e,`live.queued`,Number(i[1])):(i=/^Downloading the speech model, one time \(([\d.]+) GB\)$/.exec(t),i?e(`live.speechModelStart`,{size:i[1]}):(i=/^Downloading the speech model, one time — (\d+)% of ([\d.]+) GB$/.exec(t),i?e(`live.speechModelPercent`,{percent:i[1],size:i[2]}):(i=/^Downloading the speech model, one time — (\d+)% of ([\d.]+) GB, then ([\d.]+) GB for the NPU$/.exec(t),i?e(`live.speechModelPercentNpu`,{percent:i[1],size:i[2],npu:i[3]}):(i=/^Downloading the speech model's NPU part \(([\d.]+) GB\), no progress shown$/.exec(t),i?e(`live.speechModelNpu`,{size:i[1]}):t===`Downloading the speech model's NPU part, no progress shown`?e(`live.speechModelNpuNoSize`):t===`Loading the speech model`?e(`live.speechModelLoading`):(i=/^Downloaded the speech model \(([\d.]+) GB\)$/.exec(t),i?e(`live.speechModelDone`,{size:i[1]}):t===`Downloading the speech model, one time`?e(`live.speechModelStartNoSize`):(i=/^Downloading the speech model, one time — (\d+)%$/.exec(t),i?e(`live.speechModelPercentNoSize`,{percent:i[1]}):t===`Downloaded the speech model`?e(`live.speechModelDoneNoSize`):(i=/^Downloading (\S+)$/.exec(t),i?e(`live.downloadingModel`,{model:i[1]}):(i=/^Undo may not work for this turn: (\S+) doesn't record file changes yet\.$/.exec(t),i?e(`turnChanges.nativeNoUndo`,{name:i[1]}):t)))))))))))))}var _k={search_file:Es,search_files:Es,search_file_content:Es,search_directory:Es,read_file:Sa,write_file:ba,get_file_info:Sa,browse_directory:Ea,list_directory:Ea,list_recent_files:Ea,analyze_data_file:oi,run_shell_command:ic,run_python:ic,execute_python_file:ic,analyze_image:Ka,answer_question_about_image:Ka,generate_image:Ka,take_screenshot:Ka,query_documents:Jr,query_specific_file:Jr,search_indexed_chunks:Jr,evaluate_retrieval:Jr,index_document:Ki,index_documents:Ki,index_directory:Ki,list_indexed_documents:Ki,summarize_document:Sa,dump_document:Sa,rag_status:Ki,add_watch_directory:Ea,transcribe_media:Hr,refine_transcript:Sa,analyze_transcript:uo,export_transcript:ii,web_search:Ha,search_web:Ha,fetch_page:co,fetch_webpage:co,find_files:Es,edit_file:ba,recall:Xr,remember:Xr,update_memory:Xr,forget:Xr,forget_everything:Xr,search_past_conversations:Xr,request_user_input:So,load_skill:Ks,use_skill:Ks,unload_skill:Ks,list_skills:Ks,search_skill_hub:Ks,install_skill:Ks,capture_skill:Ks,remove_skill:Ks,skill_status:Ks,show_recipe:Jr,show_workout:uo,show_how_to:Jr,show_checklist:uo,show_itinerary:Jr,show_tip_calculator:ei,show_loan_calculator:ei};for(let e of Object.keys(_k))if(!j(`tool.${e}.done`)||!j(`tool.${e}.active`))throw Error(`AgentActivity: tool "${e}" has an icon but no tool.${e}.done/.active labels in src/i18n/locales/en.ts.`);var vk=new Set([`load_skill`,`use_skill`]),yk=new Set([`recall`]);function bk(e){return e.type===`tool`&&e.success!==!1&&yk.has(e.tool??``)}var xk={label:de(`tool.default.done`),activeLabel:de(`tool.default.active`),icon:vc},Sk=(e,t)=>({label:de(`tool.named.done`,{what:e}),activeLabel:de(`tool.named.active`,{what:e}),icon:t}),Ck=(e,t)=>e(t.ref,t.params);function wk(e,t){if(!e)return xk;if(e.startsWith(`mcp_`)){let e=t?.mcpServerLabel;return e?Sk(t?.mcpTool?`${e}: ${t.mcpTool}`:e,Ha):{label:de(`tool.mcp.done`),activeLabel:de(`tool.mcp.active`),icon:Ha}}let n=e.slice(e.lastIndexOf(`/`)+1);if(j(`tool.${n}.done`)&&j(`tool.${n}.active`))return{label:de(`tool.${n}.done`),activeLabel:de(`tool.${n}.active`),icon:Object.prototype.hasOwnProperty.call(_k,n)?_k[n]:vc};let r=n.replace(/[_-]+/g,` `).trim();return r?Sk(r,vc):xk}var Tk=new Set([`index_documents`]);function Ek(e,t){let n=wk(e.tool,e),r=e.success==null&&!e.result;return e.active?Ck(t,n.activeLabel):e.timedOut?t(`tool.timedOut`,{label:n.activeLabel}):e.autoDeclined?t(`tool.autoDeclined`,{label:n.activeLabel}):e.declined?t(`tool.declined`,{label:n.activeLabel}):e.refused?t(`tool.refused`,{label:n.activeLabel}):e.success===!1?t(`tool.failed`,{label:n.activeLabel}):r?t(`tool.unfinished`,{label:n.activeLabel}):Ck(t,n.label)}function Dk(e){if(!e.narration||!e.tool)return null;let t=`Running ${e.tool.split(/[_\-.\s]+/).filter(Boolean).join(` `).toLowerCase()}`;return e.narration===t?{}:e.narration.startsWith(`${t}: `)?{detail:e.narration.slice(t.length+2)}:null}function Ok(e,t=gt){let n=Dk(e);if(n){let r=Ek(e,t);return n.detail?t.bare(`live.toolAction`,{action:r,detail:Fk(n.detail)}):r}return e.mcpServerLabel?Ek(e,t):e.tool===`use_skill`&&e.detail?t(`activity.usingSkill`,{name:kd(e.detail)}):Tk.has(e.tool??``)||(e.declined||e.timedOut||e.refused||e.autoDeclined)&&!e.active?Ek(e,t):e.narration?fk(t,Pk(Nd(e.narration))):Ek(e,t)}var kk=48,Ak=5,jk=6,Mk=/(?:^Error fetching page:\s*|\bHTTP\s+)(\d{3})\b/;function Nk(e,t){let n=e.result??``;if(e.tool!==`fetch_page`)return n;let r=Mk.exec(n)?.[1];return r&&[`401`,`403`,`429`].includes(r)?t(`activity.fetchBlocked`,{code:r}):t(`activity.fetchFailed`)}function Pk(e){let t=/^([^:\n]{1,40}): (.+)$/.exec(e);if(!t)return e;let[,n,r]=t,i=Fk(r);return i===r?e:`${n}: ${i}`}function Fk(e){if(/^https?:\/\//i.test(e)){let t=e.replace(/^https?:\/\/(www\.)?/i,``).replace(/\/$/,``),n=t.split(`/`).filter(Boolean);return t.length>kk&&n.length>2?`${n[0]}/…/${n[n.length-1]}`:t}if(e.length>kk&&/[\\/]/.test(e)&&!/\s/.test(e)){let t=e.includes(`\\`)?`\\`:`/`,n=e.split(/[\\/]/).filter(Boolean);if(n.length>2)return`…${t}${n.slice(-2).join(t)}`}return e}function Ik(e){let t=[],n;for(let r of e)r.type===`thinking`&&!r.active&&(r.detail||``).trim()?(n&&t.push(n),n=r):n&&r.type===`tool`?(t.push({...r,thought:n}),n=void 0):(n&&t.push(n),n=void 0,t.push(r));return n&&t.push(n),t}var Lk=/^(?:Executing step \d+ of the plan\.?|Following the plan to [\s\S]*)$/;function Rk(e,t){return!!e&&!!t&&e.length===t.length&&e.every((e,n)=>e===t[n])}function zk(e,t){return e.tool===t.tool&&(e.detail??``)===(t.detail??``)&&e.mcpServer===t.mcpServer}function Bk(e,t,n,r){if(t==null||t<0)return;let i=n[n.length-1],a;return a=i?.active?`running`:i?.success===!1?`failed`:i&&(i.success===!0||i.result)?`done`:r?`running`:i?`stopped`:`pending`,Array.from({length:e},(e,n)=>n<t?`done`:n===t?a:`pending`)}function Vk(e,t){let n=[],r=new Map,i,a=!1;e.forEach((t,o)=>{if(bk(t))return;let s=n[n.length-1];if(!a||t.type!==`thinking`&&t.type!==`status`||!Lk.test((t.detail||t.label||``).trim())){if(t.type===`plan`){if(a=!0,i&&Rk(i.planSteps,t.planSteps)){t.currentStep!=null&&(i.currentStep=t.currentStep),t.planNarrations&&(i.planNarrations=t.planNarrations),r.get(i.id).anchor=o;return}i&&(r.get(i.id).end=o),i={...t},n.push(i),r.set(t.id,{anchor:o,end:e.length})}else if(t.type===`tool`){let e=n.length-1;for(;e>=0&&(n[e].type===`thinking`||n[e].type===`status`);)e--;let r=e>=0?n[e]:void 0;if(r&&r.type===`tool`&&!r.active&&zk(r,t)&&(t.active||r.success===t.success)){n[e]={...t,id:r.id,count:(r.count??1)+1};return}n.push({...t})}else if(t.type===`thinking`&&s&&s.type===`thinking`){let e=s.latencyMs!=null&&/\S$/.test(s.detail||``)&&/^\S/.test(t.detail||``)?`
168
+
169
+ `:``,r=(s.detail||``)+e+(t.detail||``);n[n.length-1]={...t,timestamp:s.timestamp,detail:r||s.detail}}else t.type===`status`&&s&&s.type===`status`&&s.success!==!1&&t.active!==!1&&!s.kept&&!t.kept?n[n.length-1]={...t,label:t.label||s.label}:t.type===`thinking`&&s&&s.type===`status`&&s.active!==!1?n[n.length-1]={...s,type:`thinking`,detail:t.detail||s.detail,active:t.active}:t.type===`status`&&t.success!==!1&&!t.kept&&s&&s.type===`thinking`?n[n.length-1]={...s,label:t.label||s.label,active:t.active??s.active}:n.push({...t})}});for(let a of n){let n=r.get(a.id);if(a.type!==`plan`||!a.planSteps||!n)continue;let o=e.slice(n.anchor+1,n.end).filter(e=>e.type===`tool`),s=t&&a===i;a.planStatuses=Bk(a.planSteps.length,a.currentStep,o,s)}return n}function Hk(e){let t=Math.max(0,Math.floor(e));return t<60?`${t}s`:`${Math.floor(t/60)}m ${String(t%60).padStart(2,`0`)}s`}function Uk(e){let[t,n]=(0,V.useState)(()=>Date.now());return(0,V.useEffect)(()=>{if(!e)return;n(Date.now());let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),t}function Wk(e,t=``){let n=[];for(let r of e){if(r.type===`commentary`){let e=r.detail?.trim();e&&!t.trimStart().startsWith(e)&&n.push({kind:`note`,row:r});continue}let e=n[n.length-1];e?.kind===`steps`?e.rows.push(r):n.push({kind:`steps`,id:r.id,rows:[r]})}return n}function Gk(e){if(vk.has(e.tool??``))return/:\s*(.+)$/.exec(e.narration??``)?.[1]?.trim()||void 0}var Kk=3;function qk(e,t=gt){let n=[];for(let t of e){let e,r;if(t.type===`tool`&&t.timedOut)e=de(`activity.timedOut`);else if(t.type===`tool`&&t.autoDeclined)e=de(`activity.autoDeclined`);else if(t.type===`tool`&&t.declined)e=de(`activity.youDeclined`);else if(t.type===`tool`&&t.refused)e=de(`activity.gaiaRefused`);else if(t.type===`tool`){let n=wk(t.tool,t),i=Gk(t);e=i?de(`activity.usedSkill`,{name:i}):n.label,r=i?de(`activity.skillFailed`,{name:i}):de(`tool.failed`,{label:n.activeLabel})}else if(t.type===`policy_alert`)e=de(`activity.blocked`);else if(t.type===`error`)e=de(`activity.hitError`);else if(t.type===`plan`)e=de(`activity.madePlan`);else continue;let i=`${e.ref}:${JSON.stringify(e.params??{})}`,a=t.type===`tool`&&t.success===!1,o=n.find(e=>e.id===i),s=t.count??1;o?(o.count+=s,o.allFailed&&=a,o.failures+=a?s:0):n.push({label:e,failedLabel:r,allFailed:a,failures:a?s:0,id:i,count:s})}return t.compose(e=>{if(n.length===0)return e(`activity.thoughtThrough`);let t=n.slice(0,Kk).map((t,n)=>{let r=t.allFailed&&t.failedLabel?t.failedLabel:t.label,i=e(r.ref,r.params),a=n===0?i:i.charAt(0).toLowerCase()+i.slice(1),o=t.count>1?`${a} ×${t.count}`:a;return t.failedLabel&&!t.allFailed&&t.failures>0?e(`activity.someFailed`,{text:o,n:t.failures}):o}),r=t.join(e(`activity.summarySep`)),i=n.length-t.length;return i>0?e(`activity.summaryMore`,{list:r,n:i}):r})}function Jk(e){return e.type===`error`||e.type===`policy_alert`}function Yk(e){return e.type===`status`&&e.success===!1}function Xk(e){return e.type===`status`&&e.kept===!0}function Zk(e){return e.type!==`status`&&!(e.type===`thinking`&&!(e.detail||``).trim())}function Qk(e){let t=new Map,n=[],r=e=>{let r=n[n.length-1],i=e==null?r?.latencyMs:e-n[0].timestamp;if(i!=null&&i>=0)for(let e of n)t.set(e.id,i);n=[]};for(let t of e)t.type===`thinking`||n.length>0&&t.type===`status`?t.type===`thinking`&&n.push(t):n.length>0&&r(t.timestamp);return n.length>0&&r(),t}var $k=e=>e.type===`tool`&&e.needsModel===`vision`&&!e.active;function eA(){let e=L();return R(`div`,{className:`flow-tool-offer`,children:[I(`span`,{children:e(`activity.visionNeeded`)}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{Vc(`vision`)},children:e(`activity.getVisionModel`)})]})}function tA({steps:e,isActive:t,running:n=t,awaitingUser:r=!1,liveLine:i,toolStatus:a=null,answer:o}){let s=L(),[c,l]=(0,V.useState)(new Map),[u,d]=(0,V.useState)(new Set),[f,p]=(0,V.useState)(``),[m,h]=(0,V.useState)(`all`),g=(0,V.useMemo)(()=>Vk(e,n),[e,n]),_=(0,V.useMemo)(()=>Wk(g,o),[g,o]),v=(0,V.useMemo)(()=>Qk(e),[e]),y=Uk(n),b=n?[...g].reverse().find(e=>e.type===`plan`&&e.planSteps?.length):void 0,x=n&&g.some(e=>e.active&&e.type!==`status`),S=n&&a?[...g].reverse().find(e=>e.type===`tool`&&e.active)?.id:void 0,C=!!f||m!==`all`,w=(0,V.useCallback)(e=>{d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),T=e=>{if(e.type!==`tool`||!C)return!0;let t=f.toLowerCase();return!(t&&!e.tool?.toLowerCase().includes(t)&&!Ok(e,s).toLowerCase().includes(t)||m===`success`&&e.success!==!0||m===`error`&&e.success!==!1)},E=e=>e.type===`thinking`?I(cA,{step:e,live:n&&!!e.active,durationMs:v.get(e.id),now:y},e.id):e.type===`tool`?I(dA,{step:e,isExpanded:u.has(e.id),thoughtMs:e.thought?v.get(e.thought.id):void 0,now:y,awaitingUser:n&&r,status:e.id===S?a:null,onToggle:()=>w(e.id)},e.id):e.type===`plan`?e===b?null:I(mA,{step:e},e.id):e.type===`status`?e.kept?I(iA,{step:e},e.id):I(rA,{step:e},e.id):e.type===`error`?I(hA,{step:e},e.id):e.type===`policy_alert`?I(gA,{step:e},e.id):null;if(g.length===0)return i?I(`div`,{className:`agent-activity active`,children:I(`div`,{className:`flow-live-line`,children:i})}):null;let ee=_.length-1,D=e=>Ik(e.filter(e=>(Zk(e)||Yk(e)||Xk(e))&&!nA(e,b))),O=_.reduce((e,t,r)=>{if(t.kind!==`steps`)return e;let i=n&&r===ee,a=D(t.rows);return a.length<2&&!i?e:c.get(t.id)??(i||a.some(Jk))?e+a.filter(e=>e.type===`tool`).length:e},0);return R(`div`,{className:`agent-activity ${n?`active`:`done`}`,children:[I(`div`,{className:`agent-timeline`,children:_.map((e,t)=>{if(e.kind===`note`)return I(aA,{text:e.row.detail??``},e.row.id);let r=n&&t===ee,i=D(e.rows);if(i.length===0)return null;let a=i.some(Jk);if(i.length===1&&!r)return T(i[0])?I(`div`,{className:`flow-steps single`,children:E(i[0])},e.id):null;let o=c.get(e.id)??(r||a),u=i.filter(T);return R(`div`,{className:`flow-steps ${o?`open`:`folded`} ${r?`live`:``}`,children:[!r&&R(`button`,{className:`flow-steps-summary`,onClick:()=>l(t=>new Map(t).set(e.id,!o)),"aria-expanded":o,children:[a?I(wi,{size:13,className:`agent-icon-error`}):i.some(e=>e.type===`tool`&&(e.declined||e.refused||e.autoDeclined))?I(Wr,{size:13,className:`flow-steps-done`}):I(Si,{size:13,className:`flow-steps-done`}),I(`span`,{className:`flow-steps-text`,children:qk(i,s)}),I(gi,{size:12,className:`flow-tool-chevron ${o?`expanded`:``}`})]}),o&&I(`div`,{className:`flow-steps-rows`,children:u.map(E)}),!o&&i.filter(Yk).map(E),!o&&!r&&i.some($k)&&I(eA,{})]},e.id)})}),b&&I(mA,{step:b}),n&&!x&&i&&I(`div`,{className:`flow-live-line`,children:i}),!n&&O>=jk&&R(`div`,{className:`activity-filter-bar`,children:[I(`input`,{type:`text`,className:`activity-filter-input`,placeholder:s(`activity.filterPlaceholder`),"aria-label":s(`activity.filterByTool`),value:f,onChange:e=>p(e.target.value)}),R(`select`,{className:`activity-filter-select`,"aria-label":s(`activity.filterByStatus`),value:m,onChange:e=>h(e.target.value),children:[I(`option`,{value:`all`,children:s.bare(`activity.filter.all`)}),I(`option`,{value:`success`,children:s.bare(`activity.filter.success`)}),I(`option`,{value:`error`,children:s.bare(`activity.filter.error`)})]})]})]})}function nA(e,t){return e.type===`plan`&&e===t}function rA({step:e}){let t=L();return R(`div`,{className:`flow-warning`,role:`status`,children:[I(wi,{size:13}),I(`span`,{children:gk(t,e.label)})]})}function iA({step:e}){let t=L();return R(`div`,{className:`flow-done`,role:`status`,children:[I(ci,{size:13,"aria-hidden":`true`}),I(`span`,{children:gk(t,e.label)})]})}function aA({text:e}){return I(`div`,{className:`flow-note md-content`,children:I(ay,{remarkPlugins:[TS],disallowedElements:[...uy],urlTransform:yy,children:e})})}var oA=3e3;function sA(e,t,n=gt){return e?t!=null&&t>=oA?n(`activity.thinkingFor`,{time:Hk(t/1e3)}):n(`activity.thinking`):t==null||t<1e3?n(`activity.thought`):n(`activity.thoughtFor`,{time:Hk(t/1e3)})}function cA({step:e,live:t,durationMs:n,now:r}){let i=L(),a=(e.detail||``).trim(),[o,s]=(0,V.useState)(!1);return a?R(`div`,{className:`flow-reasoning ${t?`live`:``}`,children:[R(`button`,{className:`flow-reasoning-toggle`,onClick:()=>s(e=>!e),"aria-expanded":o,children:[t?I(B,{size:13,className:`flow-tool-spinner`}):I(Xr,{size:13,className:`flow-tool-icon`}),I(`span`,{children:sA(t,t?r-e.timestamp:n,i)}),I(gi,{size:12,className:`flow-tool-chevron ${o?`expanded`:``}`})]}),o&&I(`div`,{className:`flow-thought-hacker`,children:a})]}):null}function lA(e,t=gt){let n=/(['"`])([A-Z]:[\\/][^'"`\n]*?)\1|(?<![\w/\\])[A-Z]:[\\/](?:[^\s*?"'`<>|,;)}\]]+[\\/])*[^\s*?"'`<>|,;)}\]]*/gi,r=[],i=0,a;for(;(a=n.exec(e))!==null;){let n=a[1]??``;(a.index>i||n)&&r.push(Nd(e.slice(i,a.index))+n);let o=n?a[2]:a[0],s=o.replace(/[)}\]]+$/,``),c=()=>{nr(s).catch(e=>P.ui.error(`Failed to open path`,e))};r.push(R(`span`,{className:`tool-result-path`,onClick:c,title:t(`activity.openPath`,{path:kd(s)}),role:`button`,tabIndex:0,onKeyDown:e=>{e.key===`Enter`&&c()},children:[I(Ea,{size:10,style:{flexShrink:0,opacity:.7}}),kd(s)]},a.index)),(s.length<o.length||n)&&r.push(o.slice(s.length)+n),i=a.index+a[0].length}return r.length===0?Nd(e):(i<e.length&&r.push(Nd(e.slice(i))),I(F.Fragment,{children:r}))}function uA({fileList:e}){let t=L(),[n,r]=(0,V.useState)(!1),i=n?e.files:e.files.slice(0,5),a=e.total-5,o=(e,n)=>{let r=e.name||e.filename||e.file_name;return r?String(r):e.file_path&&String(e.file_path).replace(/\\/g,`/`).split(`/`).pop()||t(`activity.files.file`,{n:n+1})},s=e=>e.directory?String(e.directory):``;return R(`div`,{className:`file-list-view`,children:[i.map((e,t)=>R(`div`,{className:`file-list-item`,children:[e.kind===`folder`?I(Ma,{size:11,className:`file-list-icon`,"data-kind":`folder`}):I(wa,{size:11,className:`file-list-icon`}),I(`span`,{className:`file-list-name`,children:kd(o(e,t))}),s(e)&&I(`span`,{className:`file-list-dir`,children:kd(s(e))})]},t)),a>0&&!n&&I(`button`,{className:`file-list-more`,onClick:()=>r(!0),children:t(`activity.files.more`,{n:a})}),n&&e.files.length<e.total&&I(`span`,{className:`file-list-truncated`,children:t(`activity.files.showing`,{shown:e.files.length,total:e.total})})]})}function dA({step:e,isExpanded:t,onToggle:n,now:r,awaitingUser:i=!1,status:a=null,thoughtMs:o}){let s=L(),c=wk(e.tool,e).icon,l=!!e.active&&i,u=!l&&e.active&&a?gk(s,a):``,d=l?s(`activity.waiting`):u||Ok(e,s),f=e.count??1,p=(!!e.declined||!!e.timedOut||!!e.refused||!!e.autoDeclined)&&!e.active,m=e.success===!1&&e.result&&!p&&!e.needsModel?Nk(e,s):``,h=l?``:e.active?Hk((r-e.timestamp)/1e3):e.latencyMs==null?``:yA(e.latencyMs);return R(`div`,{className:`flow-tool ${e.active?`active`:``} ${e.success===!1&&!p?`error`:``} ${p?`declined`:``} ${vk.has(e.tool??``)?`skill`:``}`,children:[R(`button`,{className:`flow-tool-header`,onClick:n,"aria-expanded":t,title:l||u?Ok(e,s):e.narration&&e.narration!==d?Nd(e.narration):void 0,children:[R(`div`,{className:`flow-tool-left`,children:[e.active&&!l?I(B,{size:13,className:`flow-tool-spinner`}):p?I(Wr,{size:13,className:`flow-tool-icon`}):e.success===!1?I(wi,{size:13,style:{color:`var(--danger)`}}):I(c,{size:13,className:`flow-tool-icon`}),I(`span`,{className:`flow-tool-label`,dir:`auto`,children:d}),f>1&&R(`span`,{className:`flow-tool-count`,"aria-label":s(`activity.identicalCalls`,{n:f}),children:[`×`,f]}),m&&I(`span`,{className:`flow-tool-failure`,dir:`auto`,children:m})]}),R(`div`,{className:`flow-tool-right`,children:[e.thought&&I(`span`,{className:`flow-tool-thought-mark`,title:s(`activity.thoughtFirst`),"aria-hidden":`true`,children:I(Xr,{size:11})}),h&&I(`span`,{className:`flow-tool-latency`,children:h}),I(`span`,{className:`flow-tool-chevron ${t?`expanded`:``}`,children:I(gi,{size:12})})]})]}),e.needsModel===`vision`&&!e.active&&I(eA,{}),t&&R(`div`,{className:`flow-tool-detail`,children:[e.thought?.detail&&R(`div`,{className:`flow-tool-thought`,children:[I(`span`,{className:`detail-section-label`,children:sA(!1,o,s)}),I(`div`,{className:`flow-thought-hacker`,children:e.thought.detail.trim()})]}),R(`div`,{className:`flow-tool-raw`,children:[I(`span`,{className:`detail-section-label`,children:s(`activity.detail.tool`)}),I(`code`,{className:`flow-tool-badge`,children:e.tool||`unknown`}),e.mcpServer&&I(`span`,{className:`flow-tool-mcp-server`,children:s(`activity.detail.via`,{server:e.mcpServer})})]}),e.detail&&!e.commandOutput&&R(`div`,{className:`step-detail-args`,children:[I(`span`,{className:`detail-section-label`,children:s(`activity.detail.arguments`)}),I(`div`,{className:`detail-args-content`,children:SA(e.detail)})]}),e.commandOutput&&I(vA,{output:e.commandOutput}),e.mcpOutput&&R(`div`,{className:`step-detail-result result-success`,children:[I(`span`,{className:`detail-section-label`,children:s(`activity.detail.output`)}),I(VO,{code:Nd(e.mcpOutput.text),previewLines:Ak,testId:`mcp-output`}),e.mcpOutput.truncated&&I(`div`,{className:`cmd-truncated`,children:s(`activity.truncated`)})]}),e.result&&!e.commandOutput&&!e.mcpOutput&&R(`div`,{className:`step-detail-result ${e.success===!1?`result-error`:`result-success`}`,children:[I(`span`,{className:`detail-section-label`,children:e.success===!1?s(`activity.detail.error`):s(`activity.detail.result`)}),I(ck,{text:e.result,renderShort:e=>lA(e,s)})]}),e.retrievalChunks&&e.retrievalChunks.length>0&&I(_A,{chunks:e.retrievalChunks}),e.fileList&&e.fileList.files.length>0&&I(uA,{fileList:e.fileList})]})]})}var fA={done:`activity.planStatus.done`,running:`activity.planStatus.running`,failed:`activity.planStatus.failed`,stopped:`activity.planStatus.stopped`,pending:`activity.planStatus.pending`};function pA({status:e}){return e===`done`?I(Si,{size:13,className:`plan-icon-done`}):e===`running`?I(B,{size:13,className:`flow-tool-spinner`}):e===`failed`?I(wi,{size:13,className:`plan-icon-failed`}):e===`stopped`?I(wi,{size:13,className:`plan-icon-stopped`}):I(Ai,{size:13,className:`plan-icon-pending`})}function mA({step:e}){let t=L(),n=e.planSteps??[];if(n.length===0)return null;let r=e.planStatuses,i=r?.filter(e=>e===`done`).length??0;return R(`div`,{className:`flow-plan`,children:[R(`div`,{className:`flow-plan-header`,children:[I(uo,{size:13}),I(`span`,{children:t(`activity.plan`)}),r&&I(`span`,{className:`flow-plan-count`,children:t(`activity.planDone`,{done:i,total:n.length})})]}),I(`ol`,{className:`flow-plan-list`,children:n.map((n,i)=>{let a=r?.[i],o=Pk(e.planNarrations?.[i]||n);return R(`li`,{className:`flow-plan-item ${a??``}`,title:n,"aria-label":a?t(`activity.planItem`,{status:de(fA[a]),text:o}):void 0,children:[I(pA,{status:a}),I(`span`,{className:`flow-plan-text`,children:o})]},i)})})]})}function hA({step:e}){let t=L();return R(`div`,{className:`flow-error`,children:[I(wi,{size:13}),I(`span`,{dir:`auto`,children:e.detail||e.label||t(`activity.errorOccurred`)})]})}function gA({step:e}){let t=L();return R(`div`,{className:`flow-policy-alert`,children:[R(`div`,{className:`flow-policy-alert-header`,children:[I(Is,{size:14}),I(`span`,{className:`flow-policy-alert-title`,children:t(`activity.policy.title`)}),I(`span`,{className:`flow-policy-alert-decision`,children:e.decision||`BLOCK`})]}),R(`div`,{className:`flow-policy-alert-body`,children:[R(`div`,{className:`flow-policy-alert-line`,children:[I(`span`,{children:t(`activity.policy.tool`)}),I(`code`,{children:e.tool||`unknown tool`})]}),I(`div`,{className:`flow-policy-alert-reason`,children:e.reason||e.detail}),e.ruleIds&&e.ruleIds.length>0&&R(`div`,{className:`flow-policy-alert-line`,children:[I(`span`,{children:t(`activity.policy.rules`)}),I(`code`,{children:e.ruleIds.join(`, `)})]}),e.policyVersion&&R(`div`,{className:`flow-policy-alert-line`,children:[I(`span`,{children:t(`activity.policy.policy`)}),I(`code`,{children:e.policyVersion})]}),R(`div`,{className:`flow-policy-alert-line`,children:[I(`span`,{children:t(`activity.policy.receipt`)}),e.receiptId?I(`code`,{children:e.receiptId}):I(`em`,{children:t(`activity.policy.receiptUnavailable`)})]})]})]})}function _A({chunks:e}){let t=L(),[n,r]=(0,V.useState)(new Set),i=e=>{r(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return R(`div`,{className:`chunks-view`,children:[I(`span`,{className:`detail-section-label`,children:t(`activity.chunks`,{n:e.length})}),I(`div`,{className:`chunks-list`,children:e.map(e=>{let r=n.has(e.id);return R(`div`,{className:`chunk-card ${r?`expanded`:``}`,children:[R(`button`,{className:`chunk-header`,onClick:()=>i(e.id),children:[R(`div`,{className:`chunk-header-left`,children:[I(Jr,{size:11,style:{color:`var(--accent-cyan)`,flexShrink:0}}),e.source&&I(`span`,{className:`chunk-source`,children:kd(e.source)}),e.page!=null&&I(`span`,{className:`chunk-page`,children:t(`activity.chunkPage`,{page:e.page})}),e.score!=null&&e.score>0&&I(`span`,{className:`chunk-score`,children:e.score.toFixed(2)})]}),I(`span`,{className:`chunk-chevron ${r?`expanded`:``}`,children:I(gi,{size:11})})]}),I(`div`,{className:`chunk-body ${r?`show`:``}`,children:r?I(`pre`,{className:`chunk-content`,children:Nd(e.content)}):I(`div`,{className:`chunk-preview`,children:Nd(e.preview)})})]},e.id)})})]})}function vA({output:e}){let t=L(),[n,r]=YO(),i=!!(e.stdout||e.stderr),a=e.returnCode!==0&&!e.expectedExit;return R(`div`,{className:`cmd-output ${a?`cmd-error`:``}`,children:[R(`div`,{className:`cmd-header`,children:[R(`div`,{className:`cmd-header-left`,children:[I(ic,{size:12,className:`cmd-header-icon`}),I(`span`,{className:`cmd-header-title`,children:t(`activity.terminal`)}),e.cwd&&I(`span`,{className:`cmd-cwd`,children:e.cwd})]}),R(`div`,{className:`cmd-header-right`,children:[e.durationSeconds!=null&&R(`span`,{className:`cmd-duration`,children:[e.durationSeconds.toFixed(1),`s`]}),e.returnCode!==0&&I(`span`,{className:`cmd-exit-code${a?``:` cmd-exit-expected`}`,title:e.expectedExit??void 0,children:t(`activity.exit`,{code:e.returnCode})}),i&&I(`button`,{className:`cmd-copy ${n===`idle`?``:n}`,onClick:()=>r(e.stdout||e.stderr||``),title:t(n===`copied`?`msg.copied`:n===`failed`?`msg.copyFailed`:`activity.copyOutput`),"aria-label":t(n===`copied`?`msg.copiedAria`:n===`failed`?`msg.copyFailed`:`activity.copyOutputAria`),children:I(n===`copied`?ci:n===`failed`?wi:Bi,{size:11})})]})]}),R(`div`,{className:`cmd-line`,children:[I(`span`,{className:`cmd-prompt`,children:`$`}),I(`span`,{className:`cmd-text`,children:Nd(e.command)})]}),e.stdout&&I(`pre`,{className:`cmd-stdout`,children:Nd(e.stdout)}),e.stderr&&I(`pre`,{className:`cmd-stderr`,children:Nd(e.stderr)}),e.truncated&&I(`div`,{className:`cmd-truncated`,children:t(`activity.truncated`)}),!i&&I(`div`,{className:`cmd-empty`,children:t(`activity.noOutput`)})]})}function yA(e){return e<1?`<1ms`:e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}function bA(e){let t=/^\[(.*)\]$/s.exec(e);return t?t[1].split(/,\s*/).map(e=>e.trim().replace(/^(['"])(.*)\1$/s,`$2`)).filter(Boolean).join(`, `):e}var xA=/^([A-Za-z_][\w.-]{0,29}):(?:\s+([\s\S]*))?$/;function SA(e){let t=e.includes(`
170
+ `)?e.split(`
171
+ `).filter(Boolean):e.split(/, (?=[A-Za-z_][\w.-]{0,29}:(?:\s|$))/).filter(Boolean);return t.length<=1?I(`span`,{className:`arg-value`,children:Nd(e)}):I(`div`,{className:`args-grid`,children:t.map((e,t)=>{let n=xA.exec(e.trim());if(n){let e=n[1],r=bA((n[2]??``).trim());return R(`div`,{className:`arg-row`,children:[I(`span`,{className:`arg-key`,children:e}),I(`span`,{className:`arg-value`,children:Nd(r)})]},t)}return I(`div`,{className:`arg-row`,children:I(`span`,{className:`arg-value`,children:Nd(e)})},t)})})}var CA=`gaia`;function wA(e){return e.some(e=>e.id===CA)}var TA=class extends Error{constructor(){super(`The GAIA agent isn't installed. Install it from the notice above, then send again.`),this.name=`FlagshipMissing`}};function EA(e){let t=e;return t?.httpStatus===422&&`${typeof t.detail==`string`?t.detail:``} ${typeof t.message==`string`?t.message:``}`.includes(`Unknown agent_type '${CA}'`)}function DA(e){return e&&!(`error`in e)?e.accounts??[]:[]}function OA(e){return e.status!==`ok`}function kA(e){let t=e.accounts??[];return t.length>1||t.some(OA)}var AA=`default`;function jA(e){return e.account_id===AA&&e.email?e.email:e.account_id}function MA(e,t){let n=t.toLowerCase();return e.find(e=>e.account_id===t||!!e.email&&e.email.toLowerCase()===n)}var NA=e=>e.status===`ok`;function PA(e,t){let n=DA(e),r=(t?MA(n,t):void 0)??(n.length===1&&OA(n[0])?n[0]:null);return{account:r,otherAccount:r!==null||n.length>1}}function FA(e,t,n){if(!e||`error`in e)return!1;if(!e.accounts)return e.configured;let r=DA(t),i=new Set(r.map(jA)),a=e.accounts.filter(NA);if(a.some(e=>!i.has(jA(e))))return!0;let o=PA(t,n).account;if(o)return a.some(e=>jA(e)===jA(o));if(r.length<=1)return a.length>0;let s=new Set(r.filter(NA).map(jA));return a.some(e=>!s.has(jA(e)))}function IA(e,t=32){if(e.length<=t)return e;let n=e.lastIndexOf(`@`),r=n>0?e.length-n:0,i=r>0&&r<=t/2?r:Math.floor((t-1)/2);return`${e.slice(0,t-1-i).replace(/[.\-_]+$/,``)}…${e.slice(e.length-i)}`}function LA(e){let t=e,n=t?.httpStatus===409&&t.body?.error===`account_choice_required`?t.body.choices:null;return Array.isArray(n)?n.map(String):null}function RA(e,t){let n=new Set(DA(t).map(jA));return DA(e).find(e=>NA(e)&&!e.is_default&&!n.has(jA(e)))??null}function zA(e){let t=window.gaia;t?.openExternal?t.openExternal(e):window.open(e,`_blank`,`noopener`)}var BA=P.api;function VA(e){switch(e){case`connector.configured`:return`configured`;case`connector.disconnected`:return`disconnected`;case`connection.revoked`:return`disconnected`;case`connector.oauth.completed`:return`oauth_completed`;case`connection.connected`:return`oauth_completed`;case`connector.oauth.error`:return`oauth_error`;case`connector.tested`:return`tested`;case`connector.enabled`:return`enabled`;case`connector.disabled`:return`disabled`;case`connector.grant.changed`:return`grant_changed`;case`connector.activation.changed`:return`activation_changed`;case`connector.account.changed`:return`account_changed`;default:return null}}function HA(e){let t=(0,V.useRef)(e);(0,V.useEffect)(()=>{t.current=e},[e]),(0,V.useEffect)(()=>{let e=null,n=1e3,r=null,i=!1,a=()=>{i||(e=new EventSource(`${Le()}/connectors/events`),e.onopen=()=>{n=1e3},e.onmessage=e=>{try{let n=JSON.parse(e.data),r=VA(n.type);if(r===null){BA.debug(`connectors-sse: ignoring event`,n.type);return}let i=n.payload??{},a=i.connector_id??i.provider??null;t.current({connectorId:a,reason:r,payload:i})}catch(e){BA.warn(`connectors-sse: malformed event`,e)}},e.onerror=()=>{e?.close(),e=null,i||(r=setTimeout(a,n),n=Math.min(n*2,3e4))})};return a(),()=>{i=!0,r&&clearTimeout(r),e?.close()}},[])}var UA=1e9;function WA(e,t){return t>=1e3?`${(e/1e3).toFixed(1)} TB`:null}function GA(e){return e>0&&e<1?`${Math.max(1,Math.round(e*1e3))} MB`:WA(e,Number(e.toFixed(1)))??`${e.toFixed(1)} GB`}function KA(e){return WA(e,Math.round(e))??`${Math.round(e)} GB`}var qA=1024**3/UA;function JA(e,t){let n=e?Number.parseFloat(e):NaN;return Number.isFinite(n)&&e?.trim().toUpperCase().endsWith(`GB`)?GA(n*qA):e||(t==null?null:GA(t))}function YA(e){return`${e.toFixed(1)} GB`}function XA(e){return GA(e/UA)}function ZA(e){let t=e/1e6;return`${t>=10?Math.round(t):t.toFixed(1)} MB/s`}function QA(e,t){return Je(e).meta.dir===`rtl`?Ge(t,`ltr`):t}var $A=3600,ej=24*$A;function tj(e,t){return e<90?t(`setup.eta.sec`,{n:String(Math.max(1,Math.round(e)))}):e<=2*$A?t(`setup.eta.min`,{n:String(Math.round(e/60))}):e<=ej?t(`setup.eta.hours`,{n:String(Math.round(e/$A))}):t(`setup.eta.day`)}function nj(e,t){if(e<90)return t(`setup.eta.secSpoken`,{n:String(Math.max(1,Math.round(e)))});if(e<=2*$A)return t(`setup.eta.minSpoken`,{n:String(Math.round(e/60))});if(e>ej)return t(`setup.eta.daySpoken`);let n=Math.round(e/$A);return t(`setup.eta.hoursSpoken.${n===2?`two`:n<=10?`few`:`many`}`,{n:String(n)})}var rj=5,ij=45,aj=class{samples=[];lastAt=0;lastBytes=0;movedAt=0;speed=0;shownEta=null;shownAt=0;restart(e,t){this.samples=[{at:t,bytes:e}],this.lastAt=t,this.lastBytes=e,this.movedAt=t}update(e,t,n){if(this.samples.length===0||e<this.lastBytes)return this.restart(e,n),this.speed=0,this.shownEta=null,{speed:null,eta:null,stalledFor:0};if(this.lastBytes===0&&e>0)return this.restart(e,n),{speed:null,eta:null,stalledFor:0};let r=(n-this.lastAt)/1e3;if(r>0){let t=(e-this.lastBytes)/r,i=1-Math.exp(-r/rj);for(this.speed=this.speed===0?t:this.speed+i*(t-this.speed),e>this.lastBytes&&(this.movedAt=n),this.lastAt=n,this.lastBytes=e,this.samples.push({at:n,bytes:e});this.samples.length>2&&this.samples[1].at<=n-ij*1e3;)this.samples.shift()}let i=(n-this.movedAt)/1e3,a=this.samples[0],o=(n-a.at)/1e3;if(o<20)return{speed:null,eta:null,stalledFor:i};let s=(e-a.bytes)/o;if(this.speed<=0||s<=0)return this.shownEta=null,{speed:Math.max(0,this.speed),eta:null,stalledFor:i};let c=Math.max(0,t-e)/s;if(this.shownEta===null)this.shownEta=c;else{let e=(n-this.shownAt)/1e3,t=this.shownEta-e;this.shownEta=c<t?this.shownEta-Math.max(e,(this.shownEta-c)/2):c>this.shownEta?this.shownEta+(c-this.shownEta)*.25:c}return this.shownAt=n,{speed:this.speed,eta:Math.max(0,this.shownEta),stalledFor:i}}};function oj(e,t){return e.filter(e=>e.id===`gaia`&&!!e.namespaced_agent_id&&(e.required_connections?.some(e=>e.connector_id===t)??!1)).map(e=>e.namespaced_agent_id)}function sj(e){if(!e)return!1;if(e.includes(`NOT_CONNECTED:`)||e.includes(`AGENT_NOT_GRANTED:`)||e.includes(`AUTH_REQUIRED:`))return!0;let t=e.toLowerCase();return!!(t.includes(`connectors → google`)||t.includes(`connections → google`)||t.includes(`connectors → microsoft`)||t.includes(`connections → microsoft`)||t.includes(`microsoft is not currently connected`))}function cj(e){if(!e)return`all`;let t=e.toLowerCase(),n=t.includes(`google`)||t.includes(`gmail`);return n===(t.includes(`microsoft`)||t.includes(`outlook`)||t.includes(`office365`)||t.includes(`o365`))?`all`:n?`google`:`microsoft`}function lj({connectorId:e,label:t,grantAgents:n,onDone:r,target:i,title:a,ready:o}){let[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(null),d=(0,V.useCallback)(async()=>{c(!0),u(null);try{zA((i?await S(e,[],n,i):await S(e,[],n)).authorization_url),r()}catch(e){u(e instanceof Error?e.message:String(e))}finally{c(!1)}},[e,n,r,i]);return R(`div`,{className:`email-connect-cta__provider-slot`,children:[R(`button`,{className:`email-connect-cta__button`,onClick:()=>void d(),disabled:s||!o,title:a,children:[s?I(B,{size:12,className:`email-connect-cta__spinner`}):I(na,{size:12}),I(`span`,{children:t})]}),l&&I(`div`,{className:`email-connect-cta__error`,role:`alert`,children:l})]})}var uj=[[`google`,`Google`],[`microsoft`,`Microsoft`]],dj={addAccount:!0};function fj({onChange:e}){return HA(e),null}function pj({content:e=``,connectorId:t}){let n=L(),[r,i]=(0,V.useState)(new Set),a=(0,V.useCallback)(e=>i(t=>new Set([...t,e])),[]),[o,s]=(0,V.useState)([]),[c,l]=(0,V.useState)(!1),u=(0,V.useCallback)(()=>{f().then(e=>s(e.connectors||[])).catch(e=>P.ui.warn(`EmailConnectCta: connector fetch failed`,e)).finally(()=>l(!0))},[]);(0,V.useEffect)(()=>(u(),window.addEventListener(`focus`,u),()=>window.removeEventListener(`focus`,u)),[u]);let{agents:d}=z(),p=(0,V.useCallback)(e=>oj(d,e),[d]),m=t===`google`||t===`microsoft`?t:cj(e),h=uj.filter(([e])=>m===e||m===`all`);return R(`div`,{className:`email-connect-cta`,role:`region`,"aria-label":n(`emailCta.label`),children:[R(`div`,{className:`email-connect-cta__text`,children:[I(wi,{size:14,className:`email-connect-cta__icon`}),I(`span`,{children:n(r.size>0?`connectCard.opened`:`emailCta.prompt`)})]}),r.size>0&&I(fj,{onChange:u}),I(`div`,{className:`email-connect-cta__buttons`,children:h.map(([e,t])=>{let i=PA(o.find(t=>t.id===e)),s=r.has(e),l={connectorId:e,grantAgents:p(e),onDone:()=>a(e),ready:c};return[i.account?I(lj,{...l,label:n(`connectCard.reconnectAccount`,{address:QA(n.locale,IA(i.account.email||i.account.account_id))}),title:i.account.email||void 0,target:{account:jA(i.account)}},`${e}:${i.account.account_id}`):I(lj,{...l,label:n(s?`emailCta.reopen`:`connectCard.connect`,{name:t})},e),i.otherAccount&&I(lj,{...l,label:n(`connectCard.otherAccount`),target:dj},`${e}:other`)]})})]})}var mj=2e6;function hj({variant:e,render:t,data:n}){let r;try{r=JSON.stringify(n)}catch{r=String(n)}let i=r.length>mj,a=r;if(!i)try{a=JSON.stringify(n,null,2)}catch{a=r}let o=e===`unknown`?`Unsupported card type: "${t}"`:`Invalid ${t} payload`;return R(`div`,{className:`render-unsupported`,children:[I(`p`,{className:`render-unsupported__message`,children:o}),R(`details`,{className:`render-unsupported__details`,children:[I(`summary`,{children:`Raw payload`}),i?R(`p`,{className:`render-unsupported__too-large`,children:[`Payload too large to display (`,r.length,` bytes)`]}):I(`pre`,{className:`render-unsupported__json`,children:a})]})]})}function gj(e){if(!e||typeof e!=`object`)return!1;let t=e;return rO(t.title)&&Array.isArray(t.columns)&&t.columns.every(e=>typeof e==`string`)&&Array.isArray(t.rows)&&t.rows.every(e=>Array.isArray(e)&&e.every(tO))}function _j({data:e}){if(!gj(e))return I(hj,{variant:`invalid`,render:`table`,data:e});let t=e.rows.length>500,n=t?e.rows.slice(0,500):e.rows,r=e.columns.length>500,i=r?e.columns.slice(0,500):e.columns;return R(`div`,{className:`render-table-card`,children:[e.title&&I(`div`,{className:`render-table-card__title`,children:e.title}),I(`div`,{className:`render-table`,children:R(`table`,{children:[I(`thead`,{children:R(`tr`,{children:[i.map((e,t)=>I(`th`,{children:e},t)),r&&I(`th`,{children:iO(e.columns.length)})]})}),I(`tbody`,{children:n.map((e,t)=>I(`tr`,{children:e.slice(0,i.length).map((e,t)=>I(`td`,{children:nO(e)},t))},t))})]})}),t&&I(`div`,{className:`render-truncation`,children:iO(e.rows.length)})]})}function vj(e){if(!e||typeof e!=`object`)return!1;let t=e;return rO(t.title)&&Array.isArray(t.items)&&t.items.every(e=>e&&typeof e==`object`&&typeof e.key==`string`&&tO(e.value))}function yj({data:e}){if(!vj(e))return I(hj,{variant:`invalid`,render:`key_value`,data:e});let t=e.items.length>500,n=t?e.items.slice(0,500):e.items;return R(`div`,{className:`render-kv`,children:[e.title&&I(`div`,{className:`render-kv__title`,children:e.title}),I(`dl`,{className:`render-kv__list`,children:n.map((e,t)=>R(`div`,{className:`render-kv__row`,children:[I(`dt`,{className:`render-kv__key`,children:e.key}),I(`dd`,{className:`render-kv__value`,children:nO(e.value)})]},t))}),t&&I(`div`,{className:`render-truncation`,children:iO(e.items.length)})]})}function bj(e){if(!e||typeof e!=`object`)return!1;let t=e;return rO(t.title)&&(t.ordered===void 0||typeof t.ordered==`boolean`)&&Array.isArray(t.items)&&t.items.every(e=>typeof e==`string`||typeof e==`number`)}function xj({data:e}){if(!bj(e))return I(hj,{variant:`invalid`,render:`list`,data:e});let t=e.items.length>500,n=(t?e.items.slice(0,500):e.items).map((e,t)=>I(`li`,{children:String(e)},t));return R(`div`,{className:`render-list`,children:[e.title&&I(`div`,{className:`render-list__title`,children:e.title}),e.ordered?I(`ol`,{className:`render-list__items`,children:n}):I(`ul`,{className:`render-list__items`,children:n}),t&&I(`div`,{className:`render-truncation`,children:iO(e.items.length)})]})}var Sj=/^\/api\/media\/(image|audio)\/([A-Za-z0-9%._~-]+)$/;function Cj(e,t){let n=Sj.exec(t);if(!n||n[1]!==e)return null;let r;try{r=decodeURIComponent(n[2])}catch{return null}return r===`.`||r===`..`||/[/\\:\0]/.test(r)?null:`${Le()}/media/${e}/${n[2]}`}var wj=/^data:image\/(png|jpe?g|gif|webp);base64,/;function Tj(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.src==`string`&&(wj.test(t.src)||Cj(`image`,t.src)!==null)&&rO(t.alt)&&rO(t.caption)}function Ej({data:e}){let t=L(),[n,r]=(0,V.useState)(!1);if(!Tj(e))return I(hj,{variant:`invalid`,render:`image`,data:e});let i=wj.test(e.src)?e.src:Cj(`image`,e.src);return R(`figure`,{className:`render-image${n?` render-image--expanded`:``}`,children:[I(`button`,{type:`button`,className:`render-image__toggle`,"aria-expanded":n,"aria-label":t(n?`media.showSmaller`:`media.showFull`),onClick:()=>r(e=>!e),children:I(`img`,{className:`render-image__img`,src:i,alt:e.alt??``})}),e.caption&&I(`figcaption`,{className:`render-image__caption`,children:e.caption})]})}function Dj(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.src==`string`&&Cj(`audio`,t.src)!==null&&rO(t.caption)&&rO(t.path)&&rO(t.saved_to)&&rO(t.script_path)&&(t.duration_seconds===void 0||typeof t.duration_seconds==`number`&&Number.isFinite(t.duration_seconds)&&t.duration_seconds>=0)}function Oj(e){let t=Math.round(e),n=Math.floor(t/60),r=t%60;return`${n}:${String(r).padStart(2,`0`)}`}function kj({data:e}){let t=L(),[n,r]=(0,V.useState)(!1);if(!Dj(e))return I(hj,{variant:`invalid`,render:`audio`,data:e});let i=Cj(`audio`,e.src),a=e.path?e.path.split(/[\\/]/).pop():void 0;return R(`figure`,{className:`render-audio`,children:[I(`audio`,{className:`render-audio__player`,controls:!0,preload:`metadata`,src:i,onError:()=>r(!0)}),R(`figcaption`,{className:`render-audio__caption`,children:[n&&I(`span`,{className:`render-audio__error`,role:`alert`,children:t(`media.audioUnplayable`)}),e.caption&&I(`span`,{className:`render-audio__text`,children:e.caption}),(a||e.duration_seconds!==void 0)&&R(`span`,{className:`render-audio__meta`,children:[a&&kd(a),a&&e.duration_seconds!==void 0&&` · `,e.duration_seconds!==void 0&&I(`bdi`,{dir:`ltr`,children:Oj(e.duration_seconds)})]}),e.saved_to&&R(`span`,{className:`render-audio__where`,children:[t(`media.savedTo`),` `,I(`bdi`,{dir:`ltr`,children:e.saved_to})]}),e.script_path&&R(`span`,{className:`render-audio__where`,children:[t(`media.listeningScript`),` `,I(`bdi`,{dir:`ltr`,children:e.script_path})]})]})]})}function Aj(e){if(!e||typeof e!=`object`)return!1;let t=e;return rO(t.title)&&rO(t.path)&&rO(t.badge)&&rO(t.note)&&typeof t.unified==`string`}var jj=`⋯`;function Mj(e){let t=e.replace(/\n$/,``).split(`
172
+ `).map(e=>e.replace(/\r$/,``)),n=t.findIndex(e=>e.startsWith(`@@`));return n===-1?t:t.slice(n+1).map(e=>e.startsWith(`@@`)?jj:e)}function Nj(e){return e.split(/(?<=[\\/])/).map((e,t)=>R(`span`,{children:[e,I(`wbr`,{})]},t))}function Pj({data:e}){if(!Aj(e))return I(hj,{variant:`invalid`,render:`diff`,data:e});let t=Mj(e.unified),n=e.title??(e.path?e.path.split(/[\\/]/).filter(Boolean).pop():void 0);return R(`div`,{className:`render-diff`,children:[(n||e.badge)&&R(`div`,{className:`render-diff__title`,children:[e.badge&&I(`span`,{className:`render-diff__badge`,children:e.badge}),n&&kd(n)]}),e.path&&I(`div`,{className:`render-diff__path`,dir:`ltr`,children:Nj(kd(e.path))}),e.note&&I(`div`,{className:`render-diff__note`,children:e.note}),e.unified&&I(`pre`,{className:`render-diff__body`,children:t.map((e,t)=>I(`div`,{className:e===jj?`render-diff__line render-diff__line--hunk`:aO(e),children:kd(e)},t))})]})}function Fj(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.action==`string`&&typeof t.summary==`string`}function Ij(e,t){let n=`tool.${e}.active`;if(j(n))return t(n);let r=e.replace(/[_-]+/g,` `).trim();return r?t(`tool.named.active`,{what:r}):t(`tool.default.active`)}function Lj({data:e}){let t=L(),[n,r]=(0,V.useState)(!1);if(!Fj(e))return I(hj,{variant:`invalid`,render:`needs_confirmation`,data:e});let i=Ij(e.action,t);return n?I(`div`,{className:`render-confirmation render-confirmation--dismissed`,children:I(`span`,{className:`render-confirmation__dismissed-note`,children:t(`confirmCard.dismissed`,{step:i})})}):R(`div`,{className:`render-confirmation`,children:[R(`div`,{className:`render-confirmation__header`,children:[I(`span`,{className:`render-confirmation__badge`,children:t(`confirmCard.badge`)}),I(`span`,{className:`render-confirmation__label`,children:i})]}),I(`pre`,{className:`render-confirmation__summary`,dir:`auto`,children:e.summary}),R(`div`,{className:`render-confirmation__footer`,children:[I(`span`,{className:`render-confirmation__note`,children:t(`confirmCard.agentTooOld`)}),I(`button`,{type:`button`,className:`render-confirmation__dismiss`,onClick:()=>r(!0),children:t(`confirmCard.dismiss`)})]})]})}var Rj=[`p`,`strong`,`em`,`code`,`ul`,`ol`,`li`,`br`],zj={p:({children:e})=>I(`p`,{children:I(`bdi`,{children:e})}),li:({node:e,children:t})=>e?.children.some(e=>e.type===`element`&&[`p`,`ul`,`ol`].includes(e.tagName))?I(`li`,{children:t}):I(`li`,{children:I(`bdi`,{children:t})})};function Bj({text:e}){return I(`div`,{className:`render-needs-input__question`,children:I(ay,{allowedElements:Rj,unwrapDisallowed:!0,components:zj,children:e})})}var Vj=e=>e;function Hj(e,t=gt.bare,n=Vj){if(e<1e3)return t(`answer.duration.underSecond`);let r=Math.round(e/1e3);if(r<60)return n(t(`answer.duration.sec`,{n:r}));let i=Math.floor(r/60),a=r%60;return n(a?t(`answer.duration.minSec`,{m:i,s:a}):t(`answer.duration.min`,{n:i}))}var Uj={answered:[`answer.answeredIn`,`answer.answeredInPlace`],stopped:[`answer.stoppedAfter`,`answer.stoppedAfterPlace`],interrupted:[`answer.interruptedAfter`,`answer.interruptedAfterPlace`],failed:[`answer.failedAfter`,`answer.failedAfterPlace`]},Wj={GPU:`device.gpu`,NPU:`device.npu`,CPU:`device.cpu`};function Gj(e){if(e===`on this PC`)return de(`answer.place.thisPc`);let t=/^via (.+)$/.exec(e);if(t)return de(`answer.place.via`,{provider:t[1]});let n=/^on your (.+)$/.exec(e)?.[1].split(` and `).map(e=>Wj[e]);if(n?.every(Boolean)){let e=n.slice(1).reduce((e,t)=>de(`answer.place.pair`,{a:e,b:de(t)}),de(n[0]));return de(`answer.place.on`,{device:e})}return e}function Kj(e,t){return t!==`failed`&&e?.time_to_first_token!=null&&e.time_to_first_token>0}function qj(e,t,n,r,i,a=!1){let o=[],s=t?.place?Gj(t.place):null;if(e!=null&&e>0){let[t,a]=Uj[n??`answered`],c=Hj(e,r,i);o.push(s?r(a,{time:c,place:s}):r(t,{time:c}))}else s&&o.push(r(n?`answer.ranPlace`:`answer.answeredPlace`,{place:s}));if(Kj(t,n)){let e=Hj(t.time_to_first_token*1e3,r,i);o.push(r(o.length?`answer.firstWord`:`answer.firstWordLead`,{time:e}))}return t?.steps!=null&&t.steps>0&&o.push(r(k(`answer.steps`,t.steps),{n:t.steps})),o.length?a?o[0]:o.join(` · `):null}function Jj(e,t,n,r,i,a=!1){return qj(e,t,n,gt.bare,Vj)===null?null:r.compose(r=>qj(e,t,n,r,i,a)??``)}function Yj(e,t,n=gt,r=Vj,i){let a=[];if(e!=null&&e>0&&a.push(n.compose(t=>t(`answer.exact.total`,{time:r(t(`answer.duration.sec`,{n:(e/1e3).toFixed(1)}))}))),t?.waiting_seconds!=null&&t.waiting_seconds>0){let e=t.waiting_seconds*1e3;a.push(n.compose(t=>t(`answer.exact.waited`,{time:Hj(e,t,r)})))}if(Kj(t,i)){let e=(t.time_to_first_token*1e3).toFixed(0);a.push(n.compose(t=>t(`answer.exact.firstToken`,{time:r(t(`answer.duration.ms`,{n:e}))})))}if(t?.output_tokens!=null&&t.output_tokens>0){let e=r(`${(t.input_tokens??0).toLocaleString()} → ${t.output_tokens.toLocaleString()}`);a.push(n.compose(t=>t(`answer.exact.tokens`,{flow:e})))}return t?.tokens_per_second!=null&&t.tokens_per_second>0&&a.push(n(`answer.exact.rate`,{n:t.tokens_per_second})),a}function Xj({latencyMs:e,stats:t,ended:n}){let r=L(),[i,a]=(0,V.useState)(!1),o=Jj(e,t,n,r,El,!i),s=Jj(e,t,n,r,Vj),c=Yj(e,t,r,El,n);return!o&&c.length===0?null:R(F.Fragment,{children:[I(`span`,{children:I(`button`,{type:`button`,className:`msg-stats-summary`,"aria-expanded":i,title:[s,...Yj(e,t,r,Vj,n)].filter(Boolean).join(`
173
+ `),onClick:()=>a(e=>!e),children:o?I(kl,{text:o}):r(`answer.details`)})}),i&&c.map(e=>I(`span`,{children:I(kl,{text:e})},e))]})}function Zj(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.session_id==`string`&&typeof t.request_id==`string`&&typeof t.question==`string`&&Array.isArray(t.options)&&typeof t.allow_free_text==`boolean`&&typeof t.sensitive==`boolean`}gt(`question.expired`);var Qj=`••••••`,$j=class extends Error{};function eM(e){return e?.httpStatus===404}async function tM(e,t,n,r){let i=z.getState();try{await St(e,t,n)}catch(e){throw eM(e)?(i.closeQuestion(t),new $j(gt(`question.expired`))):e}i.recordAnswer(t,r),i.closeQuestion(t)}function nM(e,t){let n=e.trim(),r=t.options??[],i=n.toLowerCase(),a=r[/^\d+$/.test(n)?Number(n)-1:-1]??r.find(e=>e.label.toLowerCase()===i||e.value.toLowerCase()===i);return a?{value:a.value,shown:a.label}:t.allowFreeText===!1&&r.length>0?null:{value:n,shown:n}}function rM(e,t){let n=null;for(let[r,i]of Object.entries(e))i.sessionId===t&&!i.sensitive&&(n=r);return n}function iM(e){let[t,n]=(0,V.useState)(()=>Date.now());return(0,V.useEffect)(()=>{if(!e)return;let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),e?Math.max(0,e-t):null}function aM({data:e}){let t=L(),[n,r]=(0,V.useState)({status:`pending`}),[i,a]=(0,V.useState)(``),o=Zj(e)?e.request_id:``,s=z(e=>e.liveQuestions[o]),c=z(e=>o in e.questionAnswers),l=z(e=>e.questionAnswers[o]??null),u=z(e=>e.closeQuestion),d=iM(s?.expiresAt);if((0,V.useEffect)(()=>{if(!s||s.expiresAt===null)return;let e=s.expiresAt-Date.now();if(e<=0){u(o);return}let t=setTimeout(()=>u(o),e);return()=>clearTimeout(t)},[s,o,u]),!Zj(e))return I(hj,{variant:`invalid`,render:`needs_input`,data:e});let f=n.status===`submitting`,p=async(n,i)=>{if(n.trim()&&!f&&s){r({status:`submitting`});try{await tM(e.session_id,e.request_id,n,e.sensitive?null:i),r({status:`pending`})}catch(e){if(e instanceof $j){r({status:`pending`});return}r({status:`error`,message:e instanceof Error?e.message:t(`question.sendFailed`)})}}};return c?R(`div`,{className:`render-needs-input render-needs-input--answered`,children:[I(Bj,{text:e.question}),I(`p`,{className:`render-needs-input__answered-note`,role:`status`,children:l===null||e.sensitive?t(`question.youAnsweredHidden`):t(`question.youAnswered`,{answer:l})})]}):!s&&!f?R(`div`,{className:`render-needs-input render-needs-input--expired`,"aria-disabled":`true`,children:[I(`div`,{className:`render-needs-input__header`,children:I(`span`,{className:`render-needs-input__badge`,children:t(`question.badge`)})}),I(Bj,{text:e.question}),I(`p`,{className:`render-needs-input__expired-note`,role:`status`,children:t(`question.expired`)})]}):R(`div`,{className:`render-needs-input`,children:[R(`div`,{className:`render-needs-input__header`,children:[I(`span`,{className:`render-needs-input__badge`,children:t(`question.badge`)}),e.sensitive&&I(`span`,{className:`render-needs-input__sensitive-badge`,children:t(`question.sensitive`)})]}),I(Bj,{text:e.question}),e.options.length>0&&I(`div`,{className:`render-needs-input__options`,children:e.options.map(e=>I(`button`,{type:`button`,className:`render-needs-input__option`,disabled:f,title:e.description||void 0,onClick:()=>p(e.value,e.label),children:I(`bdi`,{children:e.label})},e.value))}),e.allow_free_text&&e.sensitive&&R(`form`,{className:`render-needs-input__free-text`,onSubmit:e=>{e.preventDefault(),p(i,i)},children:[I(`input`,{type:`password`,className:`render-needs-input__free-text-input`,value:i,disabled:f,placeholder:t(`question.hiddenPlaceholder`,{mask:Qj}),onChange:e=>a(e.target.value),autoComplete:`off`,autoFocus:!0}),I(`button`,{type:`submit`,className:`render-needs-input__free-text-submit`,disabled:f||!i.trim(),children:t(`question.send`)})]}),e.allow_free_text&&!e.sensitive&&I(`p`,{className:`render-needs-input__hint`,children:e.options.length>0?t(`question.typeHint`):t(`question.typeHintNoOptions`)}),d!==null&&d>0&&I(`p`,{className:`render-needs-input__hint`,children:t(`question.timeLeft`,{time:Hj(d>=6e4?Math.ceil(d/6e4)*6e4:d,t.bare)})}),n.status===`error`&&I(`p`,{className:`render-needs-input__error`,children:n.message})]})}var oM=4e3,sM=150;function cM(e,t){(0,V.useEffect)(()=>{if(!e)return;let n=sM,r=jl(()=>{t(),--n,n<=0&&r()},oM);return r},[e,t])}function lM(e,t){return e?.length?[...new Set([...t??[],...e])]:[]}function uM(e){return e.providers.filter(t=>!e.reconnect?.includes(t))}function dM(e){let t=new Set;for(let n of e?.cards??[])n.render===`connect_account`&&ct(n.data)&&uM(n.data).forEach(e=>t.add(e));return[...t]}function fM(e){let t={};for(let n of e?.cards??[])n.render===`connect_account`&&ct(n.data)&&Object.assign(t,n.data.account);return t}function pM(e){return(e?.cards??[]).some(e=>e.render===`connect_account`&&ct(e.data))}function mM(e,t,n){return t?e.filter(e=>e.namespaced_agent_id===t&&(e.required_connections?.some(e=>e.connector_id===n)??!1)).map(e=>e.namespaced_agent_id):[]}var hM={google:`Google`,microsoft:`Microsoft`,microsoft_work:`Microsoft 365`};function gM(e){let t=e;return t?.httpStatus===503&&t.body?.error===`not_configured`}function _M({connectorId:e,name:t,connected:n,saysConnected:r,added:i,offer:a,needsSetup:o,grantAgents:s,scopes:c,onOpened:l}){let u=L(),d=z(e=>e.openSettings),f=z(e=>e.openConnectorSettings),[p,m]=(0,V.useState)(!1),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(!1);(0,V.useEffect)(()=>{o||v(!1)},[o]);let y=(0,V.useCallback)(async t=>{if(o)g(null),v(!0);else if(v(!1),s.length===0)d(`connectors`);else{m(!0),g(null);try{zA((t?await S(e,c,s,t):await S(e,c,s)).authorization_url),l()}catch(e){gM(e)?v(!0):g(e instanceof Error?e.message:String(e))}finally{m(!1)}}},[e,o,s,c,l,d]),b=p?I(B,{size:12,className:`render-connect__spinner`,"aria-hidden":`true`}):I(na,{size:12,"aria-hidden":`true`}),x=u(n?`connectCard.reconnect`:`connectCard.connect`,{name:t}),{account:C}=a;return R(`div`,{className:`render-connect__provider`,children:[C?R(`button`,{type:`button`,className:`render-connect__button`,title:C.email||void 0,onClick:()=>void y({account:jA(C)}),disabled:p,children:[b,I(`span`,{children:u(`connectCard.reconnectAccount`,{address:QA(u.locale,IA(C.email||C.account_id))})})]}):R(`button`,{type:`button`,className:`render-connect__button${n?` render-connect__button--quiet`:``}`,onClick:()=>void y(),disabled:p,children:[b,I(`span`,{children:x})]}),a.otherAccount&&I(`button`,{type:`button`,className:`render-connect__button render-connect__button--quiet`,onClick:()=>void y({addAccount:!0}),disabled:p,children:I(`span`,{children:u(`connectCard.otherAccount`)})}),r&&!C&&R(`span`,{className:`render-connect__connected`,role:`status`,children:[I(Si,{size:13,"aria-hidden":`true`}),i?u(`connectCard.addedAccount`,{address:QA(u.locale,IA(i.email||i.account_id)),name:t}):u(`connectCard.connected`,{name:t})]}),h&&I(`div`,{className:`render-connect__error`,role:`alert`,children:h}),_&&R(`div`,{className:`render-connect__setup`,role:`status`,children:[I(`span`,{children:u(`connectCard.needsSetup`,{name:t})}),I(`button`,{type:`button`,className:`render-connect__settings`,onClick:()=>f(e),children:u(`connectCard.setUp`,{name:t})})]})]})}function vM({providers:e,onEnded:t}){return HA((0,V.useCallback)(n=>{n.reason===`oauth_error`&&n.connectorId&&e.includes(n.connectorId)&&t(n.payload.reason===`cancelled`?`cancelled`:`failed`)},[e,t])),null}function yM({data:e}){let t=L(),n=z(e=>e.agents),r=z(e=>e.openSettings),[i,a]=(0,V.useState)([]),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(null),p=ct(e),m=(0,V.useCallback)(()=>{f().then(e=>{let t=e.connectors||[];a(t),s(e=>e??t)}).catch(e=>P.ui.warn(`ConnectAccountCard: connector fetch failed`,e))},[]);(0,V.useEffect)(()=>{if(p)return m(),window.addEventListener(`focus`,m),()=>window.removeEventListener(`focus`,m)},[p,m]);let h=z(e=>e.settingsSection!==null),g=(0,V.useRef)(h);(0,V.useEffect)(()=>{p&&g.current&&!h&&m(),g.current=h},[p,h,m]);let _=(e,t)=>e?.find(e=>e.id===t),v=t=>p&&o!==null&&FA(_(i,t),_(o,t),e.account?.[t]),y=p&&uM(e).some(v);cM(c&&!y,m);let b=(0,V.useCallback)(e=>{l(!1),d(e)},[]);if(!ct(e))return I(hj,{variant:`invalid`,render:it,data:e});let x=e=>i.some(t=>t.id===e&&!(`error`in t)&&t.configured),S=e=>v(e)||x(e)&&DA(_(i,e)).length<=1,C=e=>i.some(t=>t.id===e&&!(`error`in t)&&!t.configured&&t.configurable===!1),w=e=>hM[e]??i.find(t=>t.id===e&&!(`error`in t))?.display_name??e,T=e=>{let t=i.find(t=>t.id===e);return t&&!(`error`in t)?t.scopes:void 0},E=t(`connectCard.prompt`);return y?E=t(`connectCard.askAgain`):u?E=t(u===`cancelled`?`connectCard.cancelled`:`connectCard.failed`):c&&(E=t(`connectCard.opened`)),R(`div`,{className:`render-connect`,role:`group`,"aria-label":t(`connectCard.label`),children:[R(`div`,{className:`render-connect__text`,children:[I(oo,{size:14,className:`render-connect__icon`,"aria-hidden":`true`}),I(`span`,{role:u?`alert`:void 0,children:E})]}),c&&I(vM,{providers:e.providers,onEnded:b}),I(`div`,{className:`render-connect__providers`,children:e.providers.map(t=>I(_M,{connectorId:t,name:w(t),connected:x(t),saysConnected:S(t),added:v(t)?RA(_(i,t),_(o,t)):null,offer:PA(_(i,t),e.account?.[t]),needsSetup:C(t),grantAgents:mM(n,e.agent_id,t),scopes:lM(e.scopes?.[t],T(t)),onOpened:()=>{d(null),l(!0)}},t))}),I(`button`,{type:`button`,className:`render-connect__settings`,onClick:()=>r(`connectors`),children:t(`connectCard.settings`)})]})}function bM(e,t,n,r,i,a,o,s){return{id:e,dimension:t,system:n,toBase:r,singular:i,plural:a,short:o,aliases:s}}var xM=[bM(`tsp`,`volume`,`us`,4.92892,`teaspoon`,`teaspoons`,`tsp`,[`teaspoons`,`teaspoon`,`tsps`,`tsp`]),bM(`tbsp`,`volume`,`us`,14.7868,`tablespoon`,`tablespoons`,`tbsp`,[`tablespoons`,`tablespoon`,`tbsps`,`tbsp`,`tbs`,`tbl`]),bM(`floz`,`volume`,`us`,29.5735,`fluid ounce`,`fluid ounces`,`fl oz`,[`fluid ounces`,`fluid ounce`,`fl. oz`,`fl oz`]),bM(`cup`,`volume`,`us`,236.588,`cup`,`cups`,`cup`,[`cups`,`cup`]),bM(`pint`,`volume`,`us`,473.176,`pint`,`pints`,`pt`,[`pints`,`pint`,`pt`]),bM(`quart`,`volume`,`us`,946.353,`quart`,`quarts`,`qt`,[`quarts`,`quart`,`qt`]),bM(`gallon`,`volume`,`us`,3785.41,`gallon`,`gallons`,`gal`,[`gallons`,`gallon`,`gal`]),bM(`oz`,`mass`,`us`,28.3495,`ounce`,`ounces`,`oz`,[`ounces`,`ounce`,`oz`]),bM(`lb`,`mass`,`us`,453.592,`pound`,`pounds`,`lb`,[`pounds`,`pound`,`lbs`,`lb`]),bM(`ml`,`volume`,`metric`,1,`ml`,`ml`,`ml`,[`millilitres`,`milliliters`,`millilitre`,`milliliter`,`ml`]),bM(`l`,`volume`,`metric`,1e3,`L`,`L`,`L`,[`litres`,`liters`,`litre`,`liter`,`l`]),bM(`g`,`mass`,`metric`,1,`g`,`g`,`g`,[`grams`,`gram`,`g`]),bM(`kg`,`mass`,`metric`,1e3,`kg`,`kg`,`kg`,[`kilograms`,`kilogram`,`kilos`,`kilo`,`kg`])],SM=Object.fromEntries(xM.map(e=>[e.id,e])),CM=xM.flatMap(e=>e.aliases.map(t=>({alias:t,unit:e}))).sort((e,t)=>t.alias.length-e.alias.length);function wM(e){let t=e.toLowerCase();for(let{alias:e,unit:n}of CM){if(!t.startsWith(e))continue;let r=t.charAt(e.length);if(/[a-z0-9]/.test(r))continue;let i=e.length+ +(r===`.`);return{unit:n,abbreviated:e!==n.singular.toLowerCase()&&e!==n.plural.toLowerCase(),length:i}}return null}var TM={us:{volume:[`tsp`,`tbsp`,`cup`],mass:[`oz`,`lb`]},metric:{volume:[`ml`,`l`],mass:[`g`,`kg`]}},EM={tbsp:1,cup:.25,lb:1,l:1,kg:1},DM=.04,OM=.1;function kM(e,t,n){let r=TM[n][t.dimension];if(t.system===n&&!r.includes(t.id))return t;let i=t.system===n?DM:OM;for(let t=r.length-1;t>0;t--){let n=SM[r[t]],a=e/n.toBase;if(!(a<EM[n.id]*(1-i))&&!(n.system===`us`&&n.dimension===`volume`&&Math.abs(jM(a)-a)/a>i))return n}return SM[r[0]]}var AM=[[0,``],[1/8,`⅛`],[1/4,`¼`],[1/3,`⅓`],[1/2,`½`],[2/3,`⅔`],[3/4,`¾`],[1,``]];function jM(e){let t=Math.floor(e),n=e-t,r=0;for(let[e]of AM)Math.abs(e-n)<Math.abs(r-n)&&(r=e);return Math.max(t+r,1/8)}function MM(e){let t=jM(e),n=Math.floor(t+1e-9),r=t-n,i=AM.find(([e])=>Math.abs(e-r)<1e-6)?.[1]??``;return n===0?i:`${n}${i}`}function NM(e,t){return t.id===`l`||t.id===`kg`?String(Math.round(e*10)/10):String(e>=20?Math.round(e/5)*5:Math.max(1,Math.round(e)))}var PM=/(\d{2,3})(?:\s*°\s*|\s*degrees?\s+|(?=[FC]\b))(Fahrenheit|Celsius|F|C)\b/g,FM=e=>e>=150?Math.round(e/5)*5:Math.round(e),IM=/^\s*(?:\/|\(|or)\s*$/;function LM(e,t){let n=[...e.matchAll(PM)].map(e=>({start:e.index,end:e.index+e[0].length,value:Number(e[1]),fahrenheit:e[2].charAt(0)===`F`,text:e[0]})),r=``,i=0;for(let a=0;a<n.length;a++){let o=n[a],s=n[a+1];if(r+=e.slice(i,o.start),s&&s.fahrenheit!==o.fahrenheit&&IM.test(e.slice(o.end,s.start))){let n=(o.fahrenheit?t===`us`:t===`metric`)?o:s;r+=n.text,i=s.end,e.slice(o.end,s.start).includes(`(`)&&e.charAt(i)===`)`&&(i+=1),a+=1}else o.fahrenheit&&t===`metric`?r+=`${FM((o.value-32)*5/9)}°C`:!o.fahrenheit&&t===`us`?r+=`${FM(o.value*9/5+32)}°F`:r+=o.text,i=o.end}return r+e.slice(i)}function RM(e){let t=new RegExp(PM.source).exec(e);return t?t[2].charAt(0)===`F`?`us`:`metric`:null}var zM={"½":1/2,"⅓":1/3,"⅔":2/3,"¼":1/4,"¾":3/4,"⅛":1/8,"⅜":3/8,"⅝":5/8,"⅞":7/8,"⅕":1/5,"⅖":2/5,"⅗":3/5,"⅘":4/5,"⅙":1/6,"⅚":5/6},BM=`[${Object.keys(zM).join(``)}]`,VM=String.raw`(?:\d+\s+\d+\/\d+|\d+\s*${BM}|\d+\/\d+|\d*\.\d+|\d+|${BM})`,HM=new RegExp(String.raw`^\s*(${VM})(?:\s*(?:-|–|to)\s*(${VM}))?`);function UM(e){let t=e.trim(),n=/^(\d+)\s+(\d+)\/(\d+)$/.exec(t);if(n)return Number(n[1])+Number(n[2])/Number(n[3]);let r=new RegExp(String.raw`^(\d*)\s*(${BM})$`).exec(t);if(r)return Number(r[1]||0)+zM[r[2]];let i=/^(\d+)\/(\d+)$/.exec(t);return i?Number(i[1])/Number(i[2]):Number(t)}var WM=/^([^()]+?)\s*\(([^()]+)\)\s*$/;function GM(e){return/^[A-Z][a-z]/.test(e)?e.charAt(0).toLowerCase()+e.slice(1):e}function KM(e){let t=HM.exec(e);if(!t){let t=WM.exec(e),n=t?KM(t[2]):null;return!t||!n||n.rest?null:{...n,rest:GM(t[1].trim())}}let n=UM(t[1]),r=t[2]?UM(t[2]):null;if(!(n>0)||r!==null&&!(r>n))return null;let i=t[0].length,a=e.slice(i),o=/^\s*/.exec(a)[0].length,s=wM(a.slice(o));return s&&(i+=o+s.length),{amount:{low:n,high:r},unit:s?.unit??null,abbreviated:s?.abbreviated??!1,lead:e.slice(0,i).trim(),rest:e.slice(i).trim()}}var qM=/\b(whole|chickens?|turkeys?|ducks?|eggs?|cans?|tins?|jars?|bottles?|loa(?:f|ves)|packages?|packets?|bags?|boxes|box)\b/i,JM=[[`egg`,`eggs`],[`clove`,`cloves`],[`can`,`cans`],[`tin`,`tins`],[`jar`,`jars`],[`onion`,`onions`],[`lemon`,`lemons`],[`lime`,`limes`],[`potato`,`potatoes`],[`tomato`,`tomatoes`],[`carrot`,`carrots`],[`shallot`,`shallots`],[`apple`,`apples`],[`banana`,`bananas`],[`avocado`,`avocados`],[`breast`,`breasts`],[`thigh`,`thighs`],[`fillet`,`fillets`],[`slice`,`slices`],[`sprig`,`sprigs`],[`stalk`,`stalks`],[`stick`,`sticks`],[`loaf`,`loaves`],[`package`,`packages`],[`packet`,`packets`],[`head`,`heads`],[`bunch`,`bunches`],[`leaf`,`leaves`],[`tortilla`,`tortillas`],[`pepper`,`peppers`],[`chicken`,`chickens`],[`cucumber`,`cucumbers`],[`yolk`,`yolks`],[`white`,`whites`],[`bag`,`bags`]];function YM(e,t){let n=e.split(/(\s+)/),r=!1;for(let e=0;e<n.length&&e<12;e+=2){let i=n[e];if(i.startsWith(`(`)&&(r=!0),r){i.includes(`)`)&&(r=!1);continue}if(/^of$/i.test(i))break;let a=i.replace(/[,.;:]+$/,``),o=JM.find(([e,t])=>a.toLowerCase()===e||a.toLowerCase()===t);if(o){let r=t?o[1]:o[0],s=/^[A-Z]/.test(a)?r.charAt(0).toUpperCase()+r.slice(1):r;return n[e]=s+i.slice(a.length),n.join(``)}if(a!==i)break}return e}function XM(e,t){return t?Math.max(1,Math.round(e)):Math.max(.5,Math.round(e*2)/2)}function ZM(e,t,n){let r=e=>n?.system===`metric`?NM(e,n):MM(e),i=r(e);if(t===null)return i;let a=r(t);return a===i?i:`${i}–${a}`}function QM(e,t,n){return e.system===`metric`||t?e.short:n?e.plural:e.singular}function $M(e,t,n,r){if(!t)return{qty:null,text:e};let{amount:i,unit:a}=t,o=a!==null&&a.system!==r;if(n===1&&!o)return{qty:t.lead,text:t.rest};if(!a){let e=qM.test(t.rest),r=XM(i.low*n,e),a=i.high===null?null:XM(i.high*n,e),o=(a??r)>1;return{qty:ZM(r,a,null),text:YM(t.rest,o)}}let s=i.low*n*a.toBase,c=i.high===null?null:i.high*n*a.toBase,l=kM(s,a,r),u=s/l.toBase,d=c===null?null:c/l.toBase,f=d??u,p=(l.system===`us`?jM(f):f)>1,m=!o&&t.abbreviated;return{qty:`${ZM(u,d,l)} ${QM(l,m,p)}`,text:t.rest}}var eN=[[/^h/i,3600],[/^m/i,60],[/^s/i,1]],tN=String.raw`(?:hours?|hrs?|minutes?|mins?|seconds?|secs?)\b`,nN=new RegExp(String.raw`(?:(${VM})(?:\s*(?:-|–|to)\s*(?:${VM}))?|\b(an?))[\s-]*(${tN})`,`gi`),rN=/^\s*(?:,\s*)?(?:and\s+)?$/i;function iN(e){return eN.find(([t])=>t.test(e))[1]}function aN(e){let t=[];for(let n of e.matchAll(nN)){let e=n[1]?UM(n[1]):1,r=iN(n[3]);e>0&&(!n[2]||/^(?:hour|minute)$/i.test(n[3]))&&t.push({start:n.index,end:n.index+n[0].length,seconds:Math.round(e*r),unit:r})}let n=[];for(let r of t){let t=n[n.length-1];t&&r.unit<t.unit&&rN.test(e.slice(t.end,r.start))?(t.end=r.end,t.seconds+=r.seconds,t.unit=r.unit):n.push({...r})}return n.map(({start:e,end:t,seconds:n})=>({start:e,end:t,seconds:n}))}function oN(e){let t=Math.max(0,Math.ceil(e)),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=String(t%60).padStart(2,`0`);return n>0?`${n}:${String(r).padStart(2,`0`)}:${i}`:`${r}:${i}`}var sN=6,cN=/^day\s+\d+\b/i,lN=/^(day\s+\d+)\s+[-–—]\s+([\s\S]+)$/i;function uN(e,t=!1){let n=e.trim(),r=/^([^:\n]{1,80}):\s+([\s\S]+)$/.exec(n);if(r){let e=r[1].trim();if(e.split(/\s+/).length<=sN&&!/\d$/.test(e)||t&&cN.test(e))return{title:e,body:r[2].trim()}}let i=t?lN.exec(n):null;return i?{title:i[1],body:i[2].trim()}:{title:null,body:n}}function dN(e){let t=/(\d+)\s*(?:sets?\s*(?:of|x|×)\s*|[x×]\s*)(\d+)/i.exec(e),n=/(\d+)\s*sets?\b/i.exec(e),r=null,i=null;return aN(e).forEach((t,n)=>{let a=e.slice(Math.max(0,t.start-16),t.start);i===null&&/\brest(?:\s+for)?\s*$/i.test(a)?i=n:r===null&&/\bhold(?:\s+(?:it|for))*\s*$/i.test(a)&&(r=n)}),{sets:t?Number(t[1]):n?Number(n[1]):null,reps:t?Number(t[2]):null,holdIndex:r,restIndex:i}}var fN={recipe:{itemsLabel:`cards.ingredients`,stepsLabel:`cards.stepsHeading`,scaling:!0,units:!0,timers:!0,checkItems:!1,startLabel:`cards.startCooking`,timeline:!1,tip:`cards.tip.recipe`},workout:{itemsLabel:`cards.equipment`,stepsLabel:`cards.exercises`,scaling:!1,units:!1,timers:!0,checkItems:!0,startLabel:`cards.startWorkout`,timeline:!1,tip:`cards.tip.workout`},howto:{itemsLabel:`cards.materials`,stepsLabel:`cards.stepsHeading`,scaling:!1,units:!0,timers:!0,checkItems:!0,startLabel:`cards.start`,timeline:!1,tip:`cards.tip.howto`},checklist:{itemsLabel:`cards.items`,stepsLabel:null,scaling:!1,units:!1,timers:!1,checkItems:!0,startLabel:null,timeline:!1,tip:null},itinerary:{itemsLabel:`cards.packing`,stepsLabel:`cards.daysHeading`,scaling:!1,units:!1,timers:!1,checkItems:!0,startLabel:null,timeline:!0,tip:null}},pN=e=>typeof e==`string`,mN=e=>e==null||pN(e),hN=e=>Array.isArray(e)&&e.every(pN);function gN(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.kind!==`guide`||!pN(t.title)||!t.title.trim()||!(pN(t.guideType)&&t.guideType in fN)||!mN(t.description)||!mN(t.notes)||!hN(t.items)||!hN(t.steps)?!1:t.guideType===`recipe`?typeof t.servings==`number`&&Number.isInteger(t.servings)&&t.servings>=1:t.servings===null||t.servings===void 0}function _N(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}var vN=/^(?:step\s+\d+\s*[:.)-]|\d+[.)]|[-*•])\s+/i;function yN(e){let t=fN[e.guideType],n=e=>e.map(e=>e.trim().replace(vN,``)).filter(Boolean),r=n(e.items).map(e=>({raw:e,parsed:t.units||t.scaling?KM(e):null})),i=n(e.steps).map(e=>uN(e,t.timeline)),a=[];if(t.units){for(let e of r)e.parsed?.unit&&a.push(e.parsed.unit.system);for(let e of i){let t=RM(e.body);t&&a.push(t)}}let o=a.filter(e=>e===`metric`).length;return{type:e.guideType,features:t,title:e.title.trim(),description:(e.description??``).trim(),notes:(e.notes??``).trim(),baseServings:t.scaling?e.servings:null,items:r,steps:i,nativeSystem:o>a.length-o?`metric`:`us`,convertible:a.length>0,key:_N(JSON.stringify(e))}}function bN(e,t){return!e.baseServings||!t?1:t/e.baseServings}function xN(e,t,n){let r=e.items[t];return $M(r.raw,r.parsed,bN(e,n.servings),n.system)}function SN(e,t,n){return e.features.units?LM(t,n):t}function CN(e,t){return e.plural(`cards.servingCount`,t)}function wN(e,t,n){return e.steps[t].title??(e.features.timeline?n(t+1):null)}function TN(e,t,n){let r=[e.title];return e.description&&r.push(e.description),e.baseServings&&t.servings&&r.push(n.bare(`cards.makes`,{servings:n.bare(k(`cards.servingCount`,t.servings),{n:t.servings})})),e.items.length&&(r.push(``,n.bare(e.features.itemsLabel)),e.items.forEach((n,i)=>{let{qty:a,text:o}=xN(e,i,t),s=a?`${a} ${o}`.trim():o,c=e.features.checkItems?t.checked.has(i)?`[x] `:`[ ] `:`- `;r.push(`${c}${s}`)})),e.steps.length&&e.features.stepsLabel&&(r.push(``,n.bare(e.features.stepsLabel)),e.steps.forEach((i,a)=>{let o=SN(e,i.body,t.system),s=wN(e,a,e=>n.bare(`cards.dayN`,{n:e})),c=s?`${s}: ${o}`:o;r.push(e.features.timeline?c:`${a+1}. ${c}`)})),e.notes&&r.push(``,n.bare(`cards.notes`),SN(e,e.notes,t.system)),r.join(`
174
+ `)}function EN(){return typeof navigator<`u`&&typeof navigator.share==`function`}async function DN(e,t){try{return await navigator.share({title:e,text:t}),!0}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return!1;throw e}}function ON(e){return e.replace(/[&<>"']/g,e=>`&#${e.charCodeAt(0)};`)}function kN(e,t){let n=document.createElement(`iframe`);n.setAttribute(`aria-hidden`,`true`),n.tabIndex=-1,n.style.position=`fixed`,n.style.width=`0`,n.style.height=`0`,n.style.border=`0`,document.body.appendChild(n);let r=n.contentWindow;if(!r)throw n.remove(),Error(`Could not open a print frame`);r.document.open(),r.document.write(`<!doctype html><html><head><meta charset="utf-8"><title>${ON(e)}</title><style>body{font:14px/1.6 system-ui,sans-serif;margin:32px;}pre{white-space:pre-wrap;font:inherit;}</style></head><body><pre>${ON(t)}</pre></body></html>`),r.document.close();let i=()=>n.remove();r.addEventListener(`afterprint`,i,{once:!0}),r.focus(),r.print(),setTimeout(i,6e4)}function AN(e,t){return`${e}:${t}`}function jN({id:e,seconds:t,timers:n,label:r}){let i=L(),a=n.read(e,t),o=a.status===`running`?`cards.timerPause`:a.status===`paused`?`cards.timerResume`:`cards.timerStart`,s=a.status===`running`?Ko:a.status===`done`?ci:ns;return R(`button`,{type:`button`,className:`render-guide-chip is-${a.status}`,onClick:()=>n.toggle(e,t),"aria-label":i(o,{label:r}),children:[I(s,{size:11,"aria-hidden":`true`}),I(`span`,{className:`render-guide-chip__clock`,children:a.status===`done`?i(`cards.done`):oN(a.remainingSeconds)})]})}function MN({text:e,stepIndex:t,timers:n,withTimers:r}){if(!r)return I(F.Fragment,{children:e});let i=aN(e),a=0;return R(F.Fragment,{children:[i.map((r,i)=>{let o=/^[.,;:!?]+/.exec(e.slice(r.end))?.[0]??``,s=e.slice(a,r.end+o.length),c=e.slice(r.start,r.end);return a=r.end+o.length,R(V.Fragment,{children:[s,` `,I(jN,{id:AN(t,i),seconds:r.seconds,timers:n,label:c})]},i)}),e.slice(a)]})}function NN(){let[e,t]=(0,V.useState)(!0);return(0,V.useEffect)(()=>{if(!(`wakeLock`in navigator)){t(!1);return}let e=null,n=!0,r=()=>{document.visibilityState===`visible`&&navigator.wakeLock.request(`screen`).then(r=>{n?(e=r,t(!0)):r.release()},()=>{n&&t(!1)})};return r(),document.addEventListener(`visibilitychange`,r),()=>{n=!1,document.removeEventListener(`visibilitychange`,r),e?.release()}},[]),e}function PN({doc:e,state:t,timers:n,onClose:r}){let i=L(),[a,o]=(0,V.useState)(0),[s,c]=(0,V.useState)({}),l=(0,V.useRef)(null),u=NN(),d=e.steps.length,f=a===d-1;er(!0,r),yn(l,!0),(0,V.useEffect)(()=>{let e=document.activeElement;return l.current?.focus(),()=>e?.focus()},[]),(0,V.useEffect)(()=>{let e=e=>{if(!(e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey)&&!(e.target instanceof HTMLElement&&e.target.closest(`input, textarea, select`))){if(e.key===`ArrowRight`)o(e=>Math.min(d-1,e+1));else if(e.key===`ArrowLeft`)o(e=>Math.max(0,e-1));else return;e.preventDefault()}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[d]);let p=e.steps[a],m=SN(e,p.body,t.system),h=e.features.timers?aN(m):[],g=e.type===`workout`?dN(m):null,_=s[a]??0,v=g?.restIndex??null,y=v!==null&&n.read(AN(a,v),h[v].seconds).status!==`idle`?v:h.findIndex((e,t)=>t!==v),b=y===-1?h.length?0:null:y,x=b===null?null:{id:AN(a,b),seconds:h[b].seconds},S=x?n.read(x.id,x.seconds):null;return(0,by.createPortal)(R(`div`,{ref:l,className:`render-guided`,role:`dialog`,"aria-modal":`true`,"aria-label":e.title,tabIndex:-1,children:[R(`div`,{className:`render-guided__top`,children:[R(`div`,{className:`render-guided__heading`,children:[I(`span`,{className:`render-guided__guide-title`,children:e.title}),e.items.length>0&&R(`details`,{className:`render-guided__items`,children:[I(`summary`,{children:i(e.features.itemsLabel)}),I(`ul`,{children:e.items.map((n,r)=>{let{qty:i,text:a}=xN(e,r,t);return R(`li`,{children:[i&&I(`strong`,{children:i}),` `,a]},r)})})]})]}),I(`button`,{type:`button`,className:`render-guided__icon`,onClick:r,"aria-label":i(`cards.closeGuided`),children:I(bc,{size:22})})]}),R(`div`,{className:`render-guided__stage`,children:[I(`h2`,{className:`render-guided__step-title`,children:p.title??i(`cards.stepTitle`,{n:a+1})}),I(`p`,{className:`render-guided__step-text`,children:I(MN,{text:m,stepIndex:a,timers:n,withTimers:e.features.timers})}),g?.sets&&R(`div`,{className:`render-guided__sets`,children:[I(`span`,{children:i(_>=g.sets?`cards.setAllDone`:`cards.setProgress`,{n:Math.min(_+1,g.sets),total:g.sets})}),I(`button`,{type:`button`,className:`render-guided__button`,onClick:()=>{if(g?.sets&&(c(e=>({...e,[a]:Math.min(g.sets,_+1)})),v!==null&&_+1<g.sets)){let e=AN(a,v);n.reset(e),n.toggle(e,h[v].seconds)}},disabled:_>=g.sets,children:i(`cards.setDone`)})]}),x&&S&&R(`div`,{className:`render-guided__timer is-${S.status}`,children:[I(`span`,{className:`render-guided__clock`,role:`timer`,children:S.status===`done`?i(`cards.done`):oN(S.remainingSeconds)}),R(`div`,{className:`render-guided__timer-actions`,children:[R(`button`,{type:`button`,className:`render-guided__button is-primary`,onClick:()=>n.toggle(x.id,x.seconds),children:[S.status===`running`?I(Ko,{size:16}):I(ns,{size:16}),i(S.status===`running`?`cards.pause`:S.status===`paused`?`cards.resume`:`cards.start`)]}),S.status!==`idle`&&R(`button`,{type:`button`,className:`render-guided__button`,onClick:()=>n.reset(x.id),children:[I(ec,{size:14}),` `,i(`cards.stop`)]})]})]})]}),R(`div`,{className:`render-guided__nav`,children:[I(`button`,{type:`button`,className:`render-guided__icon`,onClick:()=>o(e=>Math.max(0,e-1)),disabled:a===0,"aria-label":i(`cards.prevStep`),children:I(mi,{size:26})}),R(`div`,{className:`render-guided__progress`,children:[I(`span`,{"aria-live":`polite`,children:i(`cards.stepOf`,{n:a+1,total:d})}),!u&&I(`span`,{className:`render-guided__note`,children:i(`cards.screenMaySleep`)})]}),f?I(`button`,{type:`button`,className:`render-guided__button is-primary`,onClick:r,children:i(`cards.finish`)}):I(`button`,{type:`button`,className:`render-guided__icon`,onClick:()=>o(e=>Math.min(d-1,e+1)),"aria-label":i(`cards.nextStep`),children:I(gi,{size:26})})]})]}),document.body)}var FN=250,IN=null;function LN(){IN||typeof window>`u`||typeof window.AudioContext!=`function`||(IN=new window.AudioContext)}function RN(){if(!IN)return;let e=IN.currentTime;[0,.35,.7].forEach(t=>{let n=IN.createOscillator(),r=IN.createGain();n.frequency.value=880,r.gain.setValueAtTime(1e-4,e+t),r.gain.exponentialRampToValueAtTime(.25,e+t+.02),r.gain.exponentialRampToValueAtTime(1e-4,e+t+.3),n.connect(r).connect(IN.destination),n.start(e+t),n.stop(e+t+.32)})}function zN(){let[e,t]=(0,V.useState)({}),[n,r]=(0,V.useState)(()=>Date.now()),i=(0,V.useRef)(e);(0,V.useEffect)(()=>{i.current=e},[e]);let a=Object.values(e).some(e=>e.status===`running`);(0,V.useEffect)(()=>{if(!a)return;let e=setInterval(()=>{let e=Date.now();r(e);let n=Object.entries(i.current).filter(([,t])=>t.status===`running`&&t.endsAt!==null&&t.endsAt<=e);n.length&&(t(e=>{let t={...e};for(let[e]of n)t[e]={...t[e],status:`done`,endsAt:null,leftMs:0};return t}),RN())},FN);return()=>clearInterval(e)},[a]);let o=(0,V.useCallback)((e,n)=>{LN();let i=Date.now();r(i),t(t=>{let r=t[e],a=n*1e3;return!r||r.status===`idle`||r.status===`done`?{...t,[e]:{status:`running`,totalMs:a,endsAt:i+a,leftMs:a}}:r.status===`running`?{...t,[e]:{...r,status:`paused`,endsAt:null,leftMs:Math.max(0,r.endsAt-i)}}:{...t,[e]:{...r,status:`running`,endsAt:i+r.leftMs}}})},[]),s=(0,V.useCallback)(e=>{t(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},[]),c=(0,V.useCallback)((t,r)=>{let i=e[t];if(!i)return{status:`idle`,remainingSeconds:r};let a=i.status===`running`&&i.endsAt!==null?Math.max(0,i.endsAt-n):i.leftMs;return{status:i.status,remainingSeconds:a/1e3}},[e,n]);return(0,V.useMemo)(()=>({read:c,toggle:o,reset:s}),[c,o,s])}var BN=`gaia:guide-tip-dismissed`,VN=`gaia:guide-tip-dismissed`;function HN(){try{return localStorage.getItem(BN)===`1`}catch(e){return console.warn(`[guide] could not read whether the card tip was dismissed; showing it`,e),!1}}function UN(e){return window.addEventListener(VN,e),window.addEventListener(`storage`,e),()=>{window.removeEventListener(VN,e),window.removeEventListener(`storage`,e)}}function WN(){if(!HN()){try{localStorage.setItem(BN,`1`)}catch(e){console.warn(`[guide] could not save that the card tip was dismissed; it may show again`,e)}window.dispatchEvent(new Event(VN))}}function GN(){return(0,V.useSyncExternalStore)(UN,HN,()=>!0)}var KN=99,qN=2500,JN=e=>`gaia:guide:${e.key}`;function YN(e){try{let t=localStorage.getItem(JN(e)),n=t?JSON.parse(t):[];return new Set(Array.isArray(n)?n.filter(e=>Number.isInteger(e)):[])}catch(t){return console.warn(`[guide] could not read saved checks for "${e.title}"; starting unchecked`,t),new Set}}function XN(e,t){try{t.size?localStorage.setItem(JN(e),JSON.stringify([...t])):localStorage.removeItem(JN(e))}catch(t){console.warn(`[guide] could not save checks for "${e.title}"; they hold until the chat closes`,t)}}function ZN({data:e}){return gN(e)?I(QN,{wire:e}):I(hj,{variant:`invalid`,render:`guide`,data:e})}function QN({wire:e}){let t=L(),n=(0,V.useMemo)(()=>yN(e),[e]),[r,i]=(0,V.useState)(n.baseServings),[a,o]=(0,V.useState)(n.nativeSystem),[s,c]=(0,V.useState)(()=>YN(n)),[l,u]=(0,V.useState)(!1),[d,f]=(0,V.useState)(null),p=zN(),m=GN(),h={servings:r,system:a,checked:s},{features:g}=n,_=t(`cards.copied`);(0,V.useEffect)(()=>{if(!d)return;let e=setTimeout(()=>f(null),qN);return()=>clearTimeout(e)},[d]);let v=e=>{let t=new Set(s);t.has(e)?t.delete(e):t.add(e),c(t),XN(n,t)},y=e=>n=>f(t(e,{error:n instanceof Error?n.message:String(n)})),b=()=>{KO(TN(n,h,t)).then(()=>f(_),y(`cards.copyFailed`))},x=()=>{DN(n.title,TN(n,h,t)).catch(y(`cards.shareFailed`))},S=()=>{try{kN(n.title,TN(n,h,t))}catch(e){y(`cards.printFailed`)(e)}},C=a===`us`?`metric`:`us`,w=e=>t.bare(e===`us`?`cards.system.us`:`cards.system.metric`),T=g.units&&n.convertible;return R(`article`,{className:`render-guide`,"aria-label":n.title,children:[R(`header`,{className:`render-guide__header`,children:[I(`h3`,{className:`render-guide__title`,children:n.title}),n.description&&I(`p`,{className:`render-guide__description`,children:n.description})]}),R(`div`,{className:`render-guide__toolbar`,children:[g.scaling&&r!==null&&R(`div`,{className:`render-guide__servings`,role:`group`,"aria-label":t(`cards.servings`),children:[I(`button`,{type:`button`,className:`render-guide__icon`,onClick:()=>{WN(),i(e=>Math.max(1,(e??1)-1))},disabled:r<=1,"aria-label":t(`cards.fewerServings`),children:I(Eo,{size:14})}),I(`output`,{className:`render-guide__servings-count`,"aria-live":`polite`,children:CN(t,r)}),I(`button`,{type:`button`,className:`render-guide__icon`,onClick:()=>{WN(),i(e=>Math.min(KN,(e??1)+1))},disabled:r>=KN,"aria-label":t(`cards.moreServings`),children:I(os,{size:14})})]}),R(`div`,{className:`render-guide__tools`,children:[T&&R(`button`,{type:`button`,className:`render-guide__tool`,onClick:()=>{WN(),o(C)},"aria-label":t(`cards.unitsSwitch`,{current:w(a),other:w(C)}),title:t(`cards.unitsTitle`,{other:w(C)}),children:[I(Ss,{size:15}),I(`span`,{children:w(a)})]}),EN()&&I(`button`,{type:`button`,className:`render-guide__icon`,onClick:x,"aria-label":t(`cards.share`),title:t(`cards.share`),children:I(Ms,{size:15})}),I(`button`,{type:`button`,className:`render-guide__icon`,onClick:S,"aria-label":t(`cards.print`),title:t(`cards.print`),children:I(cs,{size:15})}),I(`button`,{type:`button`,className:`render-guide__icon`,onClick:b,"aria-label":t(`cards.copy`),title:t(`cards.copy`),children:I(d===_?ci:Bi,{size:15})})]}),g.startLabel&&n.steps.length>0&&R(`button`,{type:`button`,className:`render-guide__start`,onClick:()=>{WN(),u(!0)},children:[I(ns,{size:14}),t(g.startLabel)]})]}),I(`p`,{className:`render-guide__notice`,role:`status`,children:d}),n.items.length>0&&R(`section`,{className:`render-guide__section`,children:[I(`h4`,{className:`render-guide__label`,children:t(g.itemsLabel)}),I(`ul`,{className:`render-guide__items`,children:n.items.map((e,t)=>{let{qty:r,text:i}=xN(n,t,h),o=R(F.Fragment,{children:[r&&I(`span`,{className:`render-guide__qty`,children:r}),r&&` `,SN(n,i,a)]});return I(`li`,{className:`render-guide__item${s.has(t)?` is-checked`:``}`,children:g.checkItems?R(`label`,{className:`render-guide__check`,children:[I(`input`,{type:`checkbox`,checked:s.has(t),onChange:()=>v(t)}),I(`span`,{children:o})]}):o},t)})})]}),n.steps.length>0&&g.stepsLabel&&R(`section`,{className:`render-guide__section`,children:[I(`h4`,{className:`render-guide__label`,children:t(g.stepsLabel)}),I(`ol`,{className:`render-guide__steps${g.timeline?` is-timeline`:``}`,children:n.steps.map((e,r)=>{let i=wN(n,r,e=>t(`cards.dayN`,{n:e}));return R(`li`,{className:`render-guide__step`,children:[g.timeline?I(`span`,{className:`render-guide__step-dot`,"aria-hidden":`true`}):I(`span`,{className:`render-guide__step-number`,"aria-hidden":`true`,children:r+1}),R(`div`,{className:`render-guide__step-body`,children:[i&&I(`span`,{className:`render-guide__step-title`,children:i}),I(`span`,{children:I(MN,{text:SN(n,e.body,a),stepIndex:r,timers:p,withTimers:g.timers})})]})]},r)})})]}),n.notes&&R(`aside`,{className:`render-guide__notes`,children:[I(`h4`,{className:`render-guide__label`,children:t(`cards.notes`)}),I(`p`,{children:SN(n,n.notes,a)})]}),g.tip&&!m&&R(`div`,{className:`render-guide__tip`,role:`note`,children:[I(io,{size:15,"aria-hidden":`true`}),I(`span`,{children:t(g.tip)}),I(`button`,{type:`button`,className:`render-guide__icon`,onClick:WN,"aria-label":t(`cards.dismissTip`),children:I(bc,{size:14})})]}),l&&I(PN,{doc:n,state:h,timers:p,onClose:()=>u(!1)})]})}function $N({bill:e,tipPercent:t,people:n}){let r=e*t/100,i=e+r;return{tip:r,total:i,perPerson:i/n}}function eP({amount:e,annualRatePercent:t,years:n,downPayment:r}){let i=Math.max(0,e-r),a=Math.round(n*12),o=t/100/12,s=a===0?0:o===0?i/a:i*o/(1-(1+o)**-a),c=s*a;return{principal:i,monthly:s,totalPaid:c,interest:c-i}}var tP={tip:{defaultTitle:`cards.calc.tipTitle`,fields:{bill:{label:`cards.calc.bill`,min:0,max:1e9,step:.01,format:`currency`,sliderMax:500},tipPercent:{label:`cards.calc.tip`,min:0,max:100,step:1,format:`percent`,sliderMax:40},people:{label:`cards.calc.people`,min:1,max:50,step:1,format:`count`,sliderMax:20,integer:!0}},validWire:e=>e.bill>0&&e.people>=1,results:e=>{let{tip:t,total:n,perPerson:r}=$N(e),i=e.people>1;return[{label:`cards.calc.tip`,value:t,format:`currency`},{label:`cards.calc.total`,value:n,format:`currency`,primary:!i},...i?[{label:`cards.calc.perPerson`,value:r,format:`currency`,primary:!0}]:[]]}},loan:{defaultTitle:`cards.calc.loanTitle`,fields:{amount:{label:`cards.calc.price`,min:0,max:1e10,step:1e3,format:`currency`,sliderMax:1e6},downPayment:{label:`cards.calc.downPayment`,min:0,max:1e10,step:1e3,format:`currency`,sliderMax:3e5},annualRatePercent:{label:`cards.calc.rate`,min:0,max:50,step:.05,format:`percent`,sliderMax:15},years:{label:`cards.calc.term`,min:1,max:50,step:1,format:`years`}},validWire:e=>e.amount>0&&e.years>=1&&e.downPayment<e.amount,results:e=>{let{principal:t,monthly:n,totalPaid:r,interest:i}=eP(e);return[{label:`cards.calc.monthly`,value:n,format:`currency`,primary:!0},{label:`cards.calc.loanAmount`,value:t,format:`currency`},{label:`cards.calc.totalPaid`,value:r,format:`currency`},{label:`cards.calc.totalInterest`,value:i,format:`currency`}]}}};function nP(e){return tP[e]}function rP(e){if(!e||typeof e!=`object`)return!1;let t=e;if(t.kind!==`calculator`||t.calculator!==`tip`&&t.calculator!==`loan`||t.title!==void 0&&t.title!==null&&typeof t.title!=`string`||typeof t.currency!=`string`||!iP(t.currency)||!t.inputs||typeof t.inputs!=`object`)return!1;let n=t.inputs,r=nP(t.calculator);for(let[e,t]of Object.entries(r.fields)){let r=n[e];if(typeof r!=`number`||!Number.isFinite(r)||r<0||r>t.max||t.integer&&!Number.isInteger(r))return!1}return r.validWire(n)}function iP(e){if(!/^[A-Z]{3}$/.test(e))return!1;try{return new Intl.NumberFormat(`en`,{style:`currency`,currency:e}),!0}catch{return!1}}function aP(){return typeof navigator<`u`&&navigator.language||`en-US`}function oP(e,t,{locale:n,currency:r},i=gt){switch(t){case`currency`:return new Intl.NumberFormat(n,{style:`currency`,currency:r}).format(e);case`percent`:return new Intl.NumberFormat(n,{style:`percent`,maximumFractionDigits:2}).format(e/100);case`years`:{let t=new Intl.NumberFormat(n,{maximumFractionDigits:2}).format(e);return i.bare(k(`cards.years`,e),{n:t})}case`count`:return new Intl.NumberFormat(n).format(e)}}function sP({locale:e,currency:t}){return new Intl.NumberFormat(e,{style:`currency`,currency:t}).formatToParts(0).find(e=>e.type===`currency`)?.value??``}function cP(e,t,n,r,i=gt){let a=[e];for(let[e,o]of Object.entries(t.fields))a.push(`${i.bare(o.label)}: ${oP(n[e],o.format,r,i)}`);a.push(``);for(let e of t.results(n))a.push(`${i.bare(e.label)}: ${oP(e.value,e.format,r,i)}`);return a.join(`
175
+ `)}var lP=2500;function uP({data:e}){return rP(e)?I(dP,{wire:e}):I(hj,{variant:`invalid`,render:`calculator`,data:e})}function dP({wire:e}){let t=L(),n=nP(e.calculator),r=(0,V.useMemo)(()=>({locale:aP(),currency:e.currency}),[e.currency]),[i,a]=(0,V.useState)(()=>({...e.inputs})),[o,s]=(0,V.useState)(null),c=e.title?.trim()||t(n.defaultTitle),l=n.results(i),u=t(`cards.copied`);return(0,V.useEffect)(()=>{if(!o)return;let e=setTimeout(()=>s(null),lP);return()=>clearTimeout(e)},[o]),R(`article`,{className:`render-guide render-calc`,"aria-label":c,children:[R(`header`,{className:`render-calc__header`,children:[I(`h3`,{className:`render-guide__title`,children:c}),I(`button`,{type:`button`,className:`render-guide__icon`,onClick:()=>{KO(cP(c,n,i,r,t)).then(()=>s(u),e=>s(t(`cards.copyFailed`,{error:e instanceof Error?e.message:String(e)})))},"aria-label":t(`cards.copy`),title:t(`cards.copy`),children:I(o===u?ci:Bi,{size:15})})]}),I(`p`,{className:`render-guide__notice`,role:`status`,children:o}),I(`div`,{className:`render-calc__fields`,children:Object.entries(n.fields).map(([e,t])=>I(fP,{field:t,value:i[e],money:r,onChange:t=>a(n=>({...n,[e]:t}))},e))}),I(`dl`,{className:`render-calc__results`,"aria-live":`polite`,children:l.map(e=>R(`div`,{className:`render-calc__result${e.primary?` is-primary`:``}`,children:[I(`dt`,{children:t(e.label)}),I(`dd`,{children:oP(e.value,e.format,r,t)})]},e.label))})]})}function fP({field:e,value:t,money:n,onChange:r}){let i=L(),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(!1),l=Math.min(e.max,Math.max(e.sliderMax??e.max,t)),u=e.format===`currency`?sP(n):``,d=e.format===`percent`?`%`:e.format===`years`?i.bare(`cards.yearsShort`):``,f=i(e.label),p=t=>{o(t);let n=Number(t);t.trim()===``||!Number.isFinite(n)||n<e.min||n>e.max||(!e.integer||Number.isInteger(n))&&r(n)};return R(`div`,{className:`render-calc__field`,children:[R(`label`,{className:`render-calc__label`,children:[I(`span`,{children:f}),R(`span`,{className:`render-calc__box`,children:[u&&I(`span`,{className:`render-calc__affix`,children:u}),I(`input`,{type:s?`number`:`text`,inputMode:`decimal`,min:e.min,max:e.max,step:e.step,value:a??(s?String(t):new Intl.NumberFormat(n.locale,{maximumFractionDigits:10}).format(t)),"aria-label":f,onChange:e=>p(e.target.value),onFocus:()=>c(!0),onBlur:()=>{c(!1),o(null)}}),d&&I(`span`,{className:`render-calc__affix`,children:d})]})]}),I(`input`,{type:`range`,className:`render-calc__slider`,min:e.min,max:l,step:e.step,value:t,"aria-label":i(`cards.slider`,{name:f}),"aria-valuetext":oP(t,e.format,n,i),onChange:e=>{o(null),r(Number(e.target.value))}})]})}async function pP(e,t,n){let r=`${Le()}${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(()=>``);tr(o.status,e);let 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 mP(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(`&`)}`:``}var hP=class extends Error{constructor(){super(`The memory store answer names no agent`),this.name=`MemoryStoreUnknownError`}},gP=[`due_dates`,`sources`,`sensitive_toggle`,`recategorize`,`goals`,`profile`,`advanced`];async function _P(){let e=await pP(`GET`,`/memory/store`);if(!(e&&(e.agent===`gaiapy`||e.agent===`gaiacpp`)&&typeof e.other_available==`boolean`&&e.supports&&gP.every(t=>typeof e.supports[t]==`boolean`)))throw new hP;return e}function vP(){return pP(`GET`,`/memory/stats`)}function yP(e=30){return pP(`GET`,`/memory/activity?days=${e}`)}function bP(e={}){return pP(`GET`,`/memory/knowledge${mP(e)}`)}function xP(e){return pP(`POST`,`/memory/knowledge`,e)}function SP(e,t){return pP(`PUT`,`/memory/knowledge/${encodeURIComponent(e)}`,t)}function CP(e){return pP(`DELETE`,`/memory/knowledge/${encodeURIComponent(e)}`)}function wP(){return pP(`GET`,`/memory/entities`)}function TP(){return pP(`GET`,`/memory/tools`)}function EP(e=20){return pP(`GET`,`/memory/conversations?limit=${e}`)}function DP(e,t=20){return pP(`GET`,`/memory/conversations/search?query=${encodeURIComponent(e)}&limit=${t}`)}function OP(e){return pP(`GET`,`/memory/conversations/${encodeURIComponent(e)}`)}function kP(e=7){return pP(`GET`,`/memory/upcoming?days=${e}`)}function AP(){return pP(`GET`,`/memory/embedding-coverage`)}function jP(){return pP(`POST`,`/memory/consolidate`)}function MP(){return pP(`POST`,`/memory/rebuild-embeddings`)}function NP(){return pP(`POST`,`/memory/reconcile`)}function PP(){return pP(`POST`,`/memory/rebuild-fts`)}function FP(){return pP(`POST`,`/memory/refresh-system-context`)}function IP(){return new EventSource(`${Le()}/memory/stream-discovery`)}function LP(e){return new EventSource(`${Le()}/memory/stream-inference?include_browser=${e}`)}function RP(e){return pP(`POST`,`/memory/commit-discovery`,{items:e})}function zP(e){return pP(`POST`,`/memory/commit-inference`,{insights:e})}function BP(){return pP(`GET`,`/memory/settings`)}function VP(e){return pP(`PUT`,`/memory/settings`,e)}function HP(){return pP(`GET`,`/memory/embedder`)}function UP(e){return pP(`PUT`,`/memory/embedder`,{device:e})}function WP(){return pP(`DELETE`,`/memory/all`)}function GP(){return pP(`POST`,`/memory/reinitialize`)}function KP(){return pP(`GET`,`/goals/health`)}function qP(){return pP(`POST`,`/goals/store/reset`)}function JP(){return pP(`GET`,`/goals/stats`)}function YP(e={}){return pP(`GET`,`/goals${mP(e)}`)}function XP(e){return pP(`POST`,`/goals`,e)}function ZP(e){return pP(`PUT`,`/goals/${encodeURIComponent(e)}/approve`)}function QP(e){return pP(`PUT`,`/goals/${encodeURIComponent(e)}/reject`)}function $P(e){return pP(`PUT`,`/goals/${encodeURIComponent(e)}/cancel`)}function eF(e){return pP(`PUT`,`/goals/${encodeURIComponent(e)}/retry`)}function tF(e){return pP(`DELETE`,`/goals/${encodeURIComponent(e)}`)}var nF=`gaia.resourceMonitor.visible`;function rF(){try{return window.localStorage.getItem(nF)===`1`}catch(e){return P.ui.warn(`Resource usage setting unavailable; hiding it`,e),!1}}var iF=or(e=>({visible:rF(),setVisible:t=>{try{window.localStorage.setItem(nF,t?`1`:`0`)}catch(e){P.ui.warn(`Could not remember the resource usage setting`,e)}e({visible:t})},reload:()=>e({visible:rF()})})),aF=e=>[...e.querySelectorAll(`[role="radio"]`)].filter(t=>t.closest(`[role="radiogroup"]`)===e),oF=e=>!e.matches(`:disabled`)&&e.getAttribute(`aria-disabled`)!==`true`;function sF({children:e,...t}){let n=(0,V.useRef)(null);return(0,V.useLayoutEffect)(()=>{let e=aF(n.current),t=e.find(e=>e.getAttribute(`aria-checked`)===`true`&&oF(e))??e.find(oF);for(let n of e)n.tabIndex=n===t?0:-1}),I(`div`,{ref:n,role:`radiogroup`,onKeyDown:e=>{let t=aF(e.currentTarget).filter(oF),n=t.indexOf(document.activeElement);if(n<0)return;let r=getComputedStyle(e.currentTarget).direction===`rtl`?`ArrowRight`:`ArrowLeft`,i=e.key===`Home`?0:e.key===`End`?t.length-1:e.key===`ArrowUp`||e.key===r?n-1:e.key===`ArrowDown`||e.key===`ArrowRight`||e.key===`ArrowLeft`?n+1:null;if(i===null)return;e.preventDefault();let a=t[(i+t.length)%t.length];a.focus(),a.getAttribute(`aria-checked`)!==`true`&&a.click()},...t,children:e})}var cF=`app_help`,lF={"settings.general":{section:`general`},"settings.setup":{section:`setup`},"settings.model":{section:`model`},"settings.images":{section:`images`},"settings.permissions":{section:`permissions`},"settings.skills":{section:`skills`},"settings.connectors":{section:`connectors`},"settings.messaging":{section:`messaging`},"settings.automations":{section:`automations`},"settings.memory":{section:`memory`},"settings.privacy":{section:`privacy`},"settings.notifications":{section:`notifications`},"settings.voice":{section:`voice`},"settings.advanced":{section:`advanced`},"settings.about":{section:`about`},"settings.permissions.full_access":{section:`permissions`,target:`[data-settings-target="full-access-default"]`},"settings.privacy.local_only":{section:`privacy`,target:`[data-settings-target="local-only"]`},"settings.model.cloud_keys":{section:`model`,target:`[data-settings-target="cloud-key"]`,provider:`fireworks`},"settings.model.models":{section:`model`,target:`[data-settings-target="models-on-pc"]`,provider:`local`},"settings.advanced.custom_model":{section:`advanced`,target:`[data-settings-target="custom-model"]`},"settings.advanced.model_server":{section:`advanced`,target:`[data-settings-target="model-server"]`},"page.memory":{page:`memory`},"page.documents":{page:`documents`},"page.schedules":{page:`schedules`}},uF=[`memory`,`appearance`,`language`,`resource_usage`],dF=4;function fF(e){return Object.prototype.hasOwnProperty.call(lF,e)?lF[e]:null}function pF(e){return uF.includes(e)}function mF(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=Object.keys(e);if(t.length!==1||t[0]!==`setting`&&t[0]!==`open`)return!1;let n=e[t[0]];return typeof n==`string`&&n.length>0}function hF(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.kind===`app_help`&&Array.isArray(t.items)&&t.items.length>0&&t.items.length<=dF&&t.items.every(mF)}var gF={memory:{label:`appHelp.open.memory`,icon:Xr},documents:{label:`appHelp.open.documents`,icon:Sa},schedules:{label:`appHelp.open.schedules`,icon:Mi}},_F=[{value:`light`,label:`settings.theme.light`},{value:`dark`,label:`settings.theme.dark`},{value:`system`,label:`settings.theme.system`}],vF=e=>e instanceof Error?e.message:String(e);function yF(e){let t=L(),n=z(e=>e.openSettings),r=z(e=>e.jumpToSetting),i=z(e=>e.setShowMemoryDashboard),a=z(e=>e.setShowDocLibrary),o=z(e=>e.setShowSchedules),s=fF(e);if(!s)return null;if(`page`in s){let e=gF[s.page],n={memory:i,documents:a,schedules:o}[s.page];return{label:t(e.label),icon:e.icon,go:()=>n(!0)}}let{section:c,target:l,provider:u}=s;return{label:t.compose(e=>e(`failedTurn.openSettings`,{tab:e(`settings.section.${c}`)})),icon:As,go:()=>l?r({section:c,target:l},u):n(c)}}function bF({placeId:e}){let t=yF(e);if(!t)return null;let n=t.icon;return R(`button`,{type:`button`,className:`render-apphelp__open`,onClick:t.go,children:[I(n,{size:12,"aria-hidden":`true`}),I(`span`,{children:t.label})]})}function xF({placeId:e}){let t=yF(e);return t?I(`button`,{type:`button`,className:`render-apphelp__where`,onClick:t.go,children:t.label}):null}function SF({label:e,checked:t,disabled:n,busy:r,onToggle:i}){return R(`label`,{className:`render-apphelp__row`,children:[I(`span`,{className:`render-apphelp__label`,children:e}),R(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,role:`switch`,checked:t,disabled:n,"aria-busy":r||void 0,"aria-label":e,onChange:e=>i(e.target.checked)}),I(`span`,{className:`toggle-track`})]})]})}function CF({label:e,value:t,options:n,onPick:r}){let i=(0,V.useId)();return R(`div`,{className:`render-apphelp__row`,children:[I(`span`,{className:`render-apphelp__label`,id:i,children:e}),I(sF,{className:`segmented render-apphelp__choice`,"aria-labelledby":i,children:n.map(e=>I(`button`,{type:`button`,role:`radio`,"aria-checked":t===e.value,className:t===e.value?`is-active`:``,lang:e.lang,dir:e.dir,onClick:()=>r(e.value),children:e.label},e.value))})]})}var wF=or((e,t)=>({enabled:null,loading:!1,saving:!1,loadError:null,saveError:null,load:async()=>{if(!t().loading){e({loading:!0,loadError:null});try{e({enabled:(await BP()).memory_enabled})}catch(t){e({loadError:vF(t)})}finally{e({loading:!1})}}},toggle:async()=>{let{enabled:n,saving:r}=t();if(!(n===null||r)){e({saving:!0,saveError:null});try{e({enabled:(await VP({memory_enabled:!n})).memory_enabled})}catch(t){e({saveError:vF(t)})}finally{e({saving:!1})}}}}));function TF(){let e=L(),{enabled:t,loading:n,saving:r,loadError:i,saveError:a,load:o,toggle:s}=wF(),c=z(e=>e.settingsSection!==null||e.showMemoryDashboard);return(0,V.useEffect)(()=>{c||o()},[c,o]),R(F.Fragment,{children:[I(SF,{label:e(`settings.memory.remember`),checked:t===!0,disabled:t===null||r,busy:r||n,onToggle:()=>void s()}),i&&R(`p`,{className:`render-apphelp__error`,role:`alert`,children:[e(`appHelp.memory.loadFailed`,{reason:i}),` `,I(`button`,{type:`button`,className:`render-apphelp__where`,onClick:()=>void o(),disabled:n,children:e(`mem.retry`)})]}),a&&!i&&I(`p`,{className:`render-apphelp__error`,role:`alert`,children:e(`appHelp.memory.saveFailed`,{reason:a})})]})}function EF(){let e=L(),t=z(e=>e.themePreference),n=z(e=>e.setThemePreference);return I(CF,{label:e(`settings.appearance`),value:t,options:_F.map(t=>({value:t.value,label:e(t.label)})),onPick:n})}function DF(){let e=L(),t=z(e=>e.locale),n=z(e=>e.setLocale);return I(CF,{label:e(`settings.language`),value:t,options:Pe.map(({meta:e})=>({value:e.code,label:Ze(e),lang:e.code,dir:e.dir})),onPick:n})}function OF(){let e=L(),t=iF(e=>e.visible),n=iF(e=>e.setVisible);return I(SF,{label:e(`resources.settings`),checked:t,onToggle:n})}var kF={memory:{Control:TF,home:`settings.memory`},appearance:{Control:EF,home:`settings.general`},language:{Control:DF,home:`settings.general`},resource_usage:{Control:OF,home:`settings.general`}};function AF({data:e}){let t=L();if(!hF(e))return I(hj,{variant:`invalid`,render:cF,data:e});let n=[],r=[];for(let t of e.items)`setting`in t?pF(t.setting)&&!n.includes(t.setting)&&n.push(t.setting):fF(t.open)&&!r.includes(t.open)&&r.push(t.open);return n.length===0&&r.length===0?I(hj,{variant:`invalid`,render:cF,data:e}):R(`div`,{className:`render-apphelp`,role:`group`,"aria-label":t(`appHelp.label`),children:[n.map((e,t)=>{let{Control:i,home:a}=kF[e],o=!r.includes(a)&&!n.slice(t+1).some(e=>kF[e].home===a);return R(`div`,{className:`render-apphelp__control`,children:[I(i,{}),o&&I(xF,{placeId:a})]},e)}),r.length>0&&I(`div`,{className:`render-apphelp__opens`,children:r.map(e=>I(bF,{placeId:e},e))})]})}var jF={table:_j,key_value:yj,list:xj,image:Ej,audio:kj,diff:Pj,needs_confirmation:Lj,needs_input:aM,connect_account:yM,guide:ZN,calculator:uP,app_help:AF},MF=class extends V.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.error(`[CardErrorBoundary] card render failed:`,e)}render(){return this.state.hasError?I(`div`,{role:`alert`,className:`render-card-error`,children:`Card failed to render`}):this.props.children}};function NF({render:e,data:t}){let n=jF[e];return I(`div`,{className:`render-card`,children:n?I(MF,{children:I(n,{data:t})}):I(hj,{variant:`unknown`,render:e,data:t})})}var PF=/(^|\n)[ \t]*```[^\n]*\n([\s\S]*?)(?:(?:(?<=\n)|\n)[ \t]*```[ \t]*(?=\n|$)|$)/g;function FF(e){let t=[];return e.replace(/`([^`\n]+)`/g,(e,n)=>`\u0000${t.push(n)-1}\u0000`).replace(/\\([\\`*_{}[\]()#+\-.!|~>])/g,(e,n)=>`\u0000${t.push(n)-1}\u0000`).replace(/!\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\[([^\]]+)\]\(([^)]*)\)/g,(e,t,n)=>t===n||!n?t:`${t} (${n})`).replace(/^[ \t]*([-*_][ \t]*){3,}$/gm,``).replace(/^[ \t]{0,3}#{1,6}[ \t]+/gm,``).replace(/^([ \t]*)>[ \t]?/gm,`$1`).replace(/^([ \t]*)[-*+][ \t]+/gm,`$1• `).replace(/^[ \t]*\|?[ \t:|-]+\|[ \t:|-]*\n?/gm,``).replace(/^[ \t]*\|(.*?)\|?[ \t]*$/gm,(e,t)=>t.split(`|`).map(e=>e.trim()).join(` `)).replace(/(\*\*|\*|~~)(\S(?:[^\n]*?\S)?)\1/g,`$2`).replace(/(?<!\w)(__|_)(\S(?:[^\n]*?\S)?)\1(?!\w)/g,`$2`).replace(/\u0000(\d+)\u0000/g,(e,n)=>t[Number(n)])}function IF(e){let t=``,n=0;for(let r of e.matchAll(PF)){let i=r.index??0;t+=FF(e.slice(n,i))+r[1]+r[2],n=i+r[0].length}return t+=FF(e.slice(n)),t.replace(/\n{3,}/g,`
176
+
177
+ `).trim()}function LF(e){return!e||e===`Thinking...`||e.startsWith(`Reading `)||/— retrying (now|in \d+s)/.test(e)}var RF=/failed to fetch|networkerror|load failed/i;function zF(e){return e instanceof TypeError&&RF.test(e.message)}function BF(e){return zF(e)?de(`request.gaiaUnreachable`):e instanceof On?/\blocal only is on\b/i.test(e.detail)?de(`settings.privacy.localOnlyBlocked`):e.detail||e.message:e instanceof Error?e.message:String(e)}function VF(e,t=Qt()){let n=BF(e);return typeof n==`object`?t(n.ref,n.params):String(n)}var HF=new Map;function UF(e){let t=HF.get(e);return t||(t={byMessage:new Map,checked:new Set,inFlight:null,listeners:new Set},HF.set(e,t)),t}function WF(e){let t=UF(e);return t.inFlight||=Promise.resolve().then(()=>gn(e)).then(e=>{if(!e||!Array.isArray(e.turns))throw Error(`the server sent no list of turns`);let{turns:n}=e;t.byMessage=new Map(n.filter(e=>e.message_id!=null).map(e=>[e.message_id,e])),t.listeners.forEach(e=>e())}).finally(()=>{t.inFlight=null}),t.inFlight}function GF(e){return WF(e)}function KF(e,t){let[n,r]=(0,V.useState)(()=>HF.get(e)?.byMessage.get(t)??null),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(!1);return(0,V.useEffect)(()=>{if(s(!1),t<=0)return;let n=!0,i=()=>{n&&s(!0)},o=UF(e),c=()=>r(o.byMessage.get(t)??null);return o.listeners.add(c),!o.byMessage.has(t)&&!o.checked.has(t)?(o.checked.add(t),WF(e).then(()=>{a(null),i()},e=>{o.checked.delete(t),a(BF(e))})):(c(),(o.inFlight??Promise.resolve()).then(i,()=>void 0)),()=>{n=!1,o.listeners.delete(c)}},[e,t]),{turn:n,error:i,checked:o,refresh:(0,V.useCallback)(()=>WF(e),[e])}}var qF=new Map;function JF(e){let t=qF.get(e);return t||(t=Promise.resolve().then(()=>Bn(e)).then(e=>e?.program??null).finally(()=>{qF.delete(e)}),qF.set(e,t)),t}function YF(e,t){let[n,r]=(0,V.useState)(null);return(0,V.useEffect)(()=>{if(r(null),!t)return;let n=!0;return JF(e).then(e=>{n&&r(e)}).catch(t=>P.ui.warn(`Could not tell which agent runs session=${e}`,t)),()=>{n=!1}},[e,t]),n}var XF=new Set([`write_file`,`edit_file`,`run_shell_command`]),ZF=new Set(`ls.dir.pwd.whoami.hostname.uname.date.id.echo.printf.cat.head.tail.wc.stat.file.which.where.type.readlink.realpath.basename.dirname.du.df.uptime.printenv.ps.grep.egrep.fgrep.rg.ag.diff.cmp.md5sum.sha256sum.shasum.tr.cut.nl.less.more.true.false`.split(`.`)),QF=new Set([`status`,`log`,`diff`,`show`,`rev-parse`,`describe`,`ls-files`,`ls-tree`,`blame`,`shortlog`,`cat-file`]),$F=new Set([`-a`,`--all`,`-r`,`--remotes`,`-v`,`-vv`,`--list`,`-l`,`--show-current`]),eI=new Set([`-delete`,`-exec`,`-execdir`,`-ok`,`-okdir`,`-fls`,`-fprint`,`-fprint0`,`-fprintf`]);function tI(e){let t=e.detail?.trim();if(!t)return null;let n=/^command:\s*(.+?)(?:,\s*(?:cwd|timeout|working_directory):|$)/m.exec(t);return n?n[1].trim():null}function nI(e){let t=e.trim().split(/\s+/).filter(Boolean);if(t.length===0)return!1;let n=t[0].toLowerCase();if(ZF.has(n))return!0;if(n===`sort`)return!t.some(e=>e===`-o`||e.startsWith(`--output`));if(n===`find`)return!t.some(e=>eI.has(e.toLowerCase()));if(n===`git`){let e=t[1]?.toLowerCase();if(!e)return!1;if(QF.has(e))return!0;if(e===`branch`||e===`tag`)return t.slice(2).every(e=>$F.has(e))}return!1}function rI(e){if(e.tool!==`run_shell_command`)return!1;let t=tI(e);if(!t)return!1;let n=t.replace(/\b2>\s*\/dev\/null\b|\b2>&1\b/g,``).trim();if(!n||/[><`;\n\r]|\$\(|(?<!&)&(?!&)/.test(n))return!1;let r=n.split(/\s*(?:\|\||&&|\|)\s*/);return r.length>0&&r.every(nI)}function iI(e){return(e??[]).some(e=>e.type===`tool`&&!!e.tool&&XF.has(e.tool)&&!e.active&&!e.declined&&!e.autoDeclined&&!e.timedOut&&!e.refused&&e.success===!0&&!rI(e))}var aI=`gaia:changes-undone`;function oI(e){window.dispatchEvent(new CustomEvent(aI,{detail:e}))}function sI(e,t){let n=(0,V.useRef)(t);n.current=t,(0,V.useEffect)(()=>{let t=t=>{t.detail===e&&n.current()};return window.addEventListener(aI,t),()=>window.removeEventListener(aI,t)},[e])}var cI={shell:{count:`untracked.count.shell`,one:`untracked.one.shell`,bare:`untracked.bare.shell`,many:`untracked.many.shell`},run_python:{count:`untracked.count.python`,one:`untracked.one.python`,bare:`untracked.bare.python`,many:`untracked.many.python`},execute_python_file:{count:`untracked.count.script`,one:`untracked.one.script`,bare:`untracked.bare.script`,many:`untracked.many.script`},mcp:{count:`untracked.count.mcp`,one:`untracked.one.mcp`,bare:`untracked.bare.mcp`,many:`untracked.many.mcp`},install_cli:{count:`untracked.count.install`,one:`untracked.one.install`,bare:`untracked.bare.install`,many:`untracked.many.install`},late_write:{count:`untracked.count.lateWrite`,one:`untracked.one.lateWrite`,bare:`untracked.bare.lateWrite`,many:`untracked.many.lateWrite`}},lI=120;function uI(e){let t=e.replace(/\s+/g,` `).trim();return t.length>lI?`${t.slice(0,119).trimEnd()}…`:t}function dI(e,t,n){let r=cI[e];return r?n.plural(r.count,t):`${t} ${e}`}function fI(e,t,n,r){let i=cI[e];if(n.length!==1)return`${i?r(i.many):e} ×${t}`;let a=n[0],o;return o=i?a.label?r(i.one,{label:a.label}):r(i.bare):a.label?`${e}: ${a.label}`:e,a.count>1?`${o} ×${a.count}`:o}function pI(e,t=gt){let n=new Map;for(let t of e){let e=n.get(t.kind);e||(e={kind:t.kind,count:0,entries:new Map},n.set(t.kind,e)),e.count+=1;let r=(t.detail??``).trim(),i=e.entries.get(r);i?i.count+=1:e.entries.set(r,{label:uI(r),detail:r,count:1})}return[...n.values()].map(({kind:e,count:n,entries:r})=>{let i=[...r.values()];return{kind:e,title:fI(e,n,i,t),count:n,entries:i}})}function mI(e,t=gt){let n=pI(e,t).map(e=>dI(e.kind,e.count,t));return n.length===0?t(`untracked.work`):n.length===1?n[0]:t(`untracked.and`,{list:n.slice(0,-1).join(t(`untracked.sep`)),last:n[n.length-1]})}function hI(e,{also:t=!1,inChat:n=!1}={},r=gt){let i=n?`untracked.warningChat`:t?`untracked.warningAlso`:`untracked.warning`;return r.plural(i,e.length,{work:mI(e,r)})}var gI={edited:`changes.edited`,created:`changes.created`,deleted:`changes.deleted`};function _I(e,t){let n={before:e.before_size,after:e.after_size};if(e.too_large)return t(`changes.tooLarge`,n);if(e.binary)return t(`changes.binary`,n);if(e.truncated)return t(`changes.truncated`)}function vI({sessionId:e,turn:t,onClose:n}){let r=L(),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(null);er(!0,n);let c=(0,V.useRef)(null);return yn(c,!0),(0,V.useEffect)(()=>{let n=!0;return xn(e,t.turn_id).then(e=>{n&&a(e.files)},e=>{n&&s(e instanceof Error?e.message:String(e))}),()=>{n=!1}},[e,t.turn_id]),(0,by.createPortal)(I(`div`,{ref:c,className:`modal-overlay`,onClick:n,role:`dialog`,"aria-modal":`true`,"aria-label":r(`changes.label`),children:R(`div`,{className:`modal-panel changes-review`,onClick:e=>e.stopPropagation(),children:[R(`div`,{className:`modal-header`,children:[I(`h3`,{children:r(`changes.title`)}),I(`button`,{type:`button`,className:`btn-icon`,onClick:n,"aria-label":r(`changes.close`),children:I(bc,{size:18})})]}),R(`div`,{className:`modal-body changes-review-body`,children:[o&&I(`p`,{className:`settings-error`,role:`alert`,children:r(`changes.loadFailed`,{error:o})}),!i&&!o&&R(`p`,{className:`changes-review-loading`,children:[I(B,{size:13,className:`spin`}),` `,r(`changes.loading`)]}),i?.map(e=>I(`section`,{className:`changes-review-file`,children:I(Pj,{data:{path:e.path,badge:r(gI[e.change]),note:_I(e,r),unified:e.binary||e.too_large?``:e.unified}})},e.path)),t.restored_at&&I(`p`,{className:`settings-hint`,children:r(`changes.undone`)})]})]})}),document.body)}var yI=(e,t,n)=>e(k(t,n),{n});function bI({sessionId:e,messageId:t,ranChangingTool:n=!1,agentProgram:r}){let i=L(),{turn:a,error:o,checked:s,refresh:c}=KF(e,t),l=!a||a.files.length===0&&!a.incomplete,u=r===`gaiacpp`||r===`gaiapy`?r:null,d=YF(e,s&&!o&&l&&n&&u===null),f=u??d,[p,m]=(0,V.useState)(`idle`),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(!1),y=(0,V.useCallback)(async t=>{if(a){m(`working`),g(null);try{let n=await Qe(e,a.turn_id,t);g(i.compose(e=>{let t=[];n.restored.length&&t.push(yI(e,`turnChanges.restored`,n.restored.length)),n.removed.length&&t.push(yI(e,`turnChanges.removed`,n.removed.length));let r=t.length?e(`turnChanges.undone`,{list:t.join(e(`untracked.sep`))}):e(`turnChanges.undoneNothing`);return n.kept_folders.length&&(r+=` ${yI(e,`turnChanges.keptFolders`,n.kept_folders.length)}`),r})),m(`done`),oI(e),await c()}catch(e){let t=e instanceof On&&e.reason===`conflict`;g(e instanceof On?e.detail:String(e)),m(t?`conflict`:`idle`)}}},[c,e,i,a]);if(o)return R(`div`,{className:`turn-changes is-error`,role:`note`,children:[I(cc,{size:12,"aria-hidden":`true`}),I(`span`,{children:i(`turnChanges.loadError`,{error:o})})]});if(!a||l)return!n||f!==`gaiacpp`?null:R(`div`,{className:`turn-changes is-unavailable`,role:`note`,children:[I(uc,{size:12,"aria-hidden":`true`}),I(`span`,{children:i(`turnChanges.nativeNoUndo`,{name:`gaiacpp`})})]});let b=a.files.length,x=!!a.restored_at,S=pI(a.untracked,i);return R(`div`,{className:`turn-changes`,"aria-label":i(`turnChanges.label`),children:[b>0&&R(`div`,{className:`turn-changes-row`,children:[I(`span`,{className:`turn-changes-summary`,children:i.plural(x?`turnChanges.changedUndone`:`turnChanges.changed`,b)}),R(`button`,{type:`button`,className:`turn-changes-btn`,onClick:()=>v(!0),children:[I(ua,{size:12,"aria-hidden":`true`}),` `,i(`chg.review`)]}),!x&&p!==`confirm`&&p!==`conflict`&&R(`button`,{type:`button`,className:`turn-changes-btn`,onClick:()=>m(`confirm`),disabled:p===`working`,children:[I(uc,{size:12,"aria-hidden":`true`}),` `,i(p===`working`?`chg.undoing`:`turnChanges.undo`)]}),p===`confirm`&&R(`span`,{className:`turn-changes-confirm`,role:`group`,"aria-label":i(`turnChanges.confirmLabel`),children:[i.plural(`turnChanges.confirm`,b),I(`button`,{type:`button`,className:`turn-changes-btn is-primary`,onClick:()=>void y(!1),children:i(`turnChanges.confirmUndo`)}),I(`button`,{type:`button`,className:`turn-changes-btn`,onClick:()=>m(`idle`),children:i(`turnChanges.cancel`)})]})]}),a.incomplete&&R(`div`,{className:`turn-changes-warning`,role:`note`,children:[I(cc,{size:12,"aria-hidden":`true`}),R(`span`,{children:[hI(a.untracked,{also:b>0},i),S.length>0&&I(`ul`,{children:S.map(e=>I(`li`,{children:e.entries.length===1?I(`span`,{title:e.entries[0].detail||void 0,children:e.title}):R(`details`,{children:[I(`summary`,{children:e.title}),I(`ul`,{children:e.entries.map(e=>R(`li`,{title:e.detail||void 0,children:[e.label||i(`untracked.noDescription`),e.count>1&&` ×${e.count}`]},e.detail))})]})},e.kind))})]})]}),h&&R(`div`,{className:`turn-changes-message${p===`done`?` is-ok`:` is-error`}`,role:p===`done`?`status`:`alert`,children:[h,p===`conflict`&&R(`span`,{className:`turn-changes-confirm`,children:[I(`button`,{type:`button`,className:`turn-changes-btn is-danger`,onClick:()=>void y(!0),children:i(`chg.undoAnyway`)}),I(`button`,{type:`button`,className:`turn-changes-btn`,onClick:()=>{m(`idle`),g(null)},children:i(`chg.keep`)})]})]}),_&&I(vI,{sessionId:e,turn:a,onClose:()=>v(!1)})]})}var xI=e=>`/sessions/${encodeURIComponent(e)}/artifacts`;async function SI(e){return Nn(`GET`,xI(e))}async function CI(e,t){return Nn(`GET`,`${xI(e)}/content?path=${encodeURIComponent(t)}`)}async function wI(e,t,n,r){return Nn(`PUT`,`${xI(e)}/content`,{path:t,content:n,base_version:r})}function TI(e,t,n){let r=new EventSource(`${Le()}${xI(e)}/events?path=${encodeURIComponent(t)}`);return r.onmessage=e=>{try{n(JSON.parse(e.data))}catch(e){P.api.error(`Unreadable document event for ${t}`,e)}},r.onerror=()=>P.api.warn(`Lost the watch on ${t}; reconnecting`),()=>r.close()}var EI=`gaia.sessionPanel.open`,DI=`gaia.sessionPanel.width`,OI=`gaia.sessionPanel.sections`,kI={slide:!0,answer:!0,environment:!0,context:!1,outputs:!0,changes:!0,skills:!0,tools:!1,session:!1,plan:!0,schedule:!0,documents:!0,commands:!0};function AI(e,t,n){try{let r=window.localStorage.getItem(e);return r==null?n:t(r)}catch(t){return P.ui.warn(`Session panel setting ${e} unavailable; using the default`,t),n}}function jI(e,t){try{window.localStorage.setItem(e,t)}catch(t){P.ui.warn(`Could not remember session panel setting ${e}`,t)}}function MI(e){let t=typeof window<`u`?Math.floor(window.innerWidth*.5):640;return Math.round(Math.max(280,Math.min(e,640,Math.max(280,t))))}function NI(){let e=AI(EI,e=>e,null);return{open:e===`1`,closedByUser:e===`0`,width:MI(AI(DI,e=>Number(e)||320,320)),sections:{...kI,...AI(OI,e=>JSON.parse(e),{})}}}var PI=or((e,t)=>({...NI(),overlayOpen:!1,focus:null,signals:{},setSignals:(t,n)=>e(e=>({signals:{...e.signals,[t]:{...e.signals[t],...n}}})),autoOpened:!1,setOpen:t=>{jI(EI,t?`1`:`0`),e({open:t,closedByUser:!t,autoOpened:!1})},autoOpen:()=>{t().closedByUser||t().open||e({open:!0,autoOpened:!0})},yieldSide:()=>{t().autoOpened?e({open:!1,autoOpened:!1}):t().setOpen(!1)},setOverlayOpen:t=>e({overlayOpen:t}),setWidth:t=>{let n=MI(t);jI(DI,String(n)),e({width:n})},setSection:(n,r)=>{let i={...t().sections,[n]:r};jI(OI,JSON.stringify(i)),e({sections:i})},reveal:n=>{let r={...t().sections,[n]:!0};jI(OI,JSON.stringify(r)),jI(EI,`1`),e({sections:r,open:!0,closedByUser:!1,autoOpened:!1,overlayOpen:!0,focus:{section:n,nonce:Date.now()}})},reload:()=>e({...NI(),autoOpened:!1,overlayOpen:!1,focus:null,signals:{}})}));function FI(e){return e!==null&&Date.now()-e.nonce<2e3}var II=1200,LI=`gaia.browserPane.openChats`,RI=`gaia.browserPane.width`;function zI(){return typeof window>`u`?void 0:window.gaiaBrowserPane}function BI(e){try{return window.localStorage.getItem(e)}catch(t){return P.ui.warn(`Browser pane setting ${e} unavailable; using the default`,t),null}}function VI(e,t){try{window.localStorage.setItem(e,t)}catch(t){P.ui.warn(`Could not remember browser pane setting ${e}`,t)}}function HI(e){let t=typeof document<`u`?window.innerWidth-UI()-560:II;return Math.round(Math.max(360,Math.min(e,II,t)))}function UI(){return document.querySelector(`.main-content`)?.getBoundingClientRect().left??0}function WI(){let e=BI(LI);if(e===null)return[];try{let t=JSON.parse(e);if(!Array.isArray(t)||!t.every(e=>typeof e==`string`))throw Error(`expected a list of chat ids`);return t.slice(0,200)}catch(e){return P.ui.warn(`Ignoring unreadable ${LI}; every chat's browser pane starts closed`,e),[]}}function GI(e,t){return t===null?e.draftOpen:e.openChats.includes(t)}var KI=()=>z.getState().currentSessionId,qI=or((e,t)=>{let n=t=>{let n=t.slice(0,200);VI(LI,JSON.stringify(n)),e({openChats:n})};return{pane:null,openChats:zI()===void 0?[]:WI(),draftOpen:!1,width:HI(Number(BI(RI))||520),setOpen:r=>{let i=KI();i===null?e({draftOpen:r}):n([...r?[i]:[],...t().openChats.filter(e=>e!==i)]),r&&PI.getState().open&&PI.getState().yieldSide()},toggle:()=>t().setOpen(!GI(t(),KI())),claimDraft:r=>{t().draftOpen&&(e({draftOpen:!1}),n([r,...t().openChats.filter(e=>e!==r)])),zI()?.claimDraft(r)},forgetChat:e=>{t().openChats.includes(e)&&n(t().openChats.filter(t=>t!==e)),zI()?.forgetChat(e)},setWidth:t=>{let n=HI(t);VI(RI,String(n)),e({width:n})}}});function JI(){let e=z(e=>e.currentSessionId);return qI(t=>GI(t,e))}pr(e=>qI.getState().forgetChat(e)),z.subscribe((e,t)=>{e.currentSessionId!==t.currentSessionId&&GI(qI.getState(),e.currentSessionId)&&PI.getState().open&&PI.getState().yieldSide()}),PI.subscribe((e,t)=>{e.open&&!t.open&&GI(qI.getState(),KI())&&qI.getState().setOpen(!1)});function YI(e){let t=!0,n=!1,r=e.onState(e=>{n=!0,qI.setState({pane:e})});return e.getState().then(e=>{t&&!n&&qI.setState({pane:e})}).catch(e=>P.ui.error(`Could not read the browser pane state`,e)),()=>{t=!1,r()}}var XI=1100,ZI=`(max-width: 1099px)`,QI=`gaia.documentPane.chats`,$I=`gaia.documentPane.width`,eL=/\.(md|markdown|mdx|txt)$/i,tL=/write|edit|append|replace|create|update|save/i;function nL(e){return!!e&&eL.test(e)}function rL(e){return e.split(/[\\/]/).pop()||e}function iL(e,t){return e===t||/^[A-Za-z]:[\\/]/.test(e)&&e.replace(/\\/g,`/`).toLowerCase()===t.replace(/\\/g,`/`).toLowerCase()}var aL={tabs:[],active:null,open:!1,closedByUser:!1};function oL(e){try{return window.localStorage.getItem(e)}catch(t){return P.ui.warn(`Document pane setting ${e} unavailable; using the default`,t),null}}function sL(e,t){try{window.localStorage.setItem(e,t)}catch(t){P.ui.warn(`Could not remember document pane setting ${e}`,t)}}function cL(e){let t=typeof document<`u`?document.querySelector(`.main-content`)?.getBoundingClientRect().left??0:0,n=typeof window<`u`?window.innerWidth-t-560:XI;return Math.round(Math.max(360,Math.min(e,XI,n)))}function lL(e){let t=e;return!!t&&Array.isArray(t.tabs)&&t.tabs.every(e=>typeof e==`string`)&&(t.active===null||typeof t.active==`string`)&&typeof t.open==`boolean`&&typeof t.closedByUser==`boolean`}function uL(){let e=oL(QI);if(e===null)return[];try{let t=JSON.parse(e);if(!Array.isArray(t)||!t.every(e=>Array.isArray(e)&&typeof e[0]==`string`&&lL(e[1])))throw Error(`expected a list of [chat id, documents]`);return t.slice(0,100)}catch(e){return P.ui.warn(`Ignoring unreadable ${QI}; every chat's document pane starts closed`,e),[]}}function dL(){return typeof window.matchMedia==`function`&&window.matchMedia(`(max-width: 1099px)`).matches}function fL(){let e=uL();return{order:e.map(([e])=>e),chats:Object.fromEntries(e),width:cL(Number(oL($I))||560)}}var pL=or((e,t)=>{let n=(n,r)=>{let i=t().chats[n];if(i&&t().order[0]===n&&i.open===r.open&&i.closedByUser===r.closedByUser&&i.active===r.active&&i.tabs.length===r.tabs.length&&i.tabs.every((e,t)=>e===r.tabs[t]))return;let a=[n,...t().order.filter(e=>e!==n)].slice(0,100),o=Object.fromEntries(a.map(e=>[e,e===n?r:t().chats[e]]));sL(QI,JSON.stringify(a.map(e=>[e,o[e]]))),e({order:a,chats:o})},r=(e,n,r)=>{let i=t().chats[e]??aL,a=i.tabs.find(e=>iL(e,n));return{...i,tabs:a?i.tabs:[...i.tabs,n],active:r||i.active===null?a??n:i.active}},i=e=>{z.getState().currentSessionId===e&&(PI.getState().open&&PI.getState().yieldSide(),GI(qI.getState(),e)&&qI.getState().setOpen(!1))};return{...fL(),overlayOpen:!1,live:{},turn:{},refresh:0,flush:0,show:(t,a)=>{dL()?(n(t,r(t,a,!0)),e({overlayOpen:!0})):(n(t,{...r(t,a,!0),open:!0,closedByUser:!1}),i(t))},autoShow:(e,a)=>{let o=t().chats[e]??aL,s=r(e,a,!o.open),c=PI.getState(),l=o.closedByUser||dL()||z.getState().currentSessionId!==e||c.open&&!c.autoOpened||GI(qI.getState(),e);o.open||l?n(e,s):(n(e,{...s,open:!0}),i(e))},close:r=>{e({overlayOpen:!1});let i=t().chats[r];i?.open&&n(r,{...i,open:!1,closedByUser:!0})},closeTab:(r,i)=>{let a=t().chats[r];if(!a)return;let o=a.tabs.findIndex(e=>iL(e,i));if(o===-1)return;let s=a.tabs.filter((e,t)=>t!==o);if(s.length===0){e({overlayOpen:!1}),n(r,{tabs:s,active:null,open:!1,closedByUser:a.closedByUser||a.open});return}let c=a.active&&iL(a.active,i)?s[Math.min(o,s.length-1)]:a.active;n(r,{...a,tabs:s,active:c})},yieldSide:e=>{let r=t().chats[e];r?.open&&n(e,{...r,open:!1})},setOverlayOpen:t=>e({overlayOpen:t}),setWidth:t=>{let n=cL(t);sL($I,String(n)),e({width:n})},forgetChat:n=>{if(!(n in t().chats))return;let r=t().order.filter(e=>e!==n),i=Object.fromEntries(r.map(e=>[e,t().chats[e]]));sL(QI,JSON.stringify(r.map(e=>[e,i[e]]))),e({order:r,chats:i,live:{...t().live,[n]:void 0},turn:{...t().turn,[n]:void 0}})},reload:()=>{xL.clear(),e({...fL(),overlayOpen:!1,live:{},turn:{},refresh:0,flush:0})}}});function mL(e){return pL(t=>(e?t.chats[e]:void 0)??aL)}function hL(e){let t=e?pL.getState().chats[e]:void 0;return!!t?.open&&t.active!==null}function gL(e,t,n){let r=pL.getState().turn[e]??[],i=r.filter(e=>!iL(e.path,t)),a=r.find(e=>iL(e.path,t)),o=a?.status===`ready`&&n===`stopped`?a:{path:a?.path??t,status:n};pL.setState(t=>({turn:{...t.turn,[e]:[...i,o]}}))}var _L={};function vL(e,t,n){SI(e).then(({items:r})=>{let i=pL.getState().turn[e]??[],a=!1;for(let t of r)t.message_id===null&&(i.some(e=>iL(e.path,t.path))||(a=!0),gL(e,t.path,`ready`),n||pL.getState().autoShow(e,t.path));t&&a&&!r.some(e=>iL(e.path,t))&&(pL.getState().closeTab(e,t),pL.setState(n=>({turn:{...n.turn,[e]:n.turn[e]?.filter(e=>!iL(e.path,t))}}))),pL.setState(e=>({refresh:e.refresh+1}))}).catch(t=>P.ui.error(`Could not list the documents chat ${e} is writing`,t))}function yL(e,t,n=!1){if(t.type===`draft`){if(nL(t.target)&&typeof t.text==`string`&&t.text.trim()){let r=t.target;pL.setState(n=>({live:{...n.live,[e]:{path:r,text:t.text,status:`writing`}}})),gL(e,r,`writing`),n||pL.getState().autoShow(e,r)}return!0}if(t.type===`tool_start`)return _L[e]=t.tool,!1;if(t.type!==`tool_result`)return!1;let r=t.tool??_L[e]??``,i=pL.getState().live[e],a=t.success===!1;return i?.status===`writing`&&(gL(e,i.path,a?`stopped`:`ready`),pL.setState(t=>({live:{...t.live,[e]:a?{...i,status:`stopped`}:void 0},refresh:t.refresh+1}))),!a&&tL.test(r)&&vL(e,i?.status===`writing`?i.path:void 0,n),!1}function bL(e){_L[e]=void 0,pL.setState(t=>({live:{...t.live,[e]:void 0},turn:{...t.turn,[e]:void 0},flush:t.flush+1}))}var xL=new Map,SL=(e,t)=>`${e}\n${t}`;function CL(e,t,n){xL.set(SL(e,t),n)}function wL(e,t){let n=SL(e,t),r=xL.get(n);return xL.delete(n),r}function TL(e,t){xL.delete(SL(e,t))}function EL(e){_L[e]=void 0,pL.setState(t=>({live:{...t.live,[e]:void 0},turn:{...t.turn,[e]:void 0}}))}function DL(e){let t=pL.getState().live[e];pL.setState(n=>({live:{...n.live,[e]:t?.status===`writing`?{...t,status:`stopped`}:t},turn:{...n.turn,[e]:void 0},refresh:n.refresh+1}))}pr(e=>pL.getState().forgetChat(e));var OL=()=>z.getState().currentSessionId;z.subscribe((e,t)=>{if(e.currentSessionId===t.currentSessionId)return;pL.getState().setOverlayOpen(!1);let n=e.currentSessionId;n&&hL(n)&&(GI(qI.getState(),n)?pL.getState().yieldSide(n):PI.getState().open&&PI.getState().yieldSide())}),PI.subscribe((e,t)=>{let n=OL();n&&e.open&&!t.open&&pL.getState().yieldSide(n)}),qI.subscribe((e,t)=>{let n=OL();n&&GI(e,n)&&!GI(t,n)&&pL.getState().yieldSide(n)});var kL=[],AL={writing:`docPane.card.writing`,ready:`docPane.card.ready`,stopped:`docPane.card.stopped`};function jL({files:e,live:t=!1}){let n=L(),r=z(e=>e.currentSessionId),i=pL(e=>(t&&r?e.turn[r]:void 0)??kL),a=mL(r),o=pL(e=>e.overlayOpen),s=(0,V.useMemo)(()=>t?i:(e??[]).filter(nL).map(e=>({path:e,status:`ready`})),[e,t,i]);if(!r||s.length===0)return null;let c=a.open||o?a.active:null;return I(`div`,{className:`doc-cards`,children:s.map(({path:e,status:t})=>{let i=kd(rL(e)),a=c!==null&&iL(c,e);return R(`button`,{type:`button`,className:`doc-card is-${t}`,disabled:t===`stopped`,"aria-current":a?`true`:void 0,"aria-label":n(`docPane.card.open`,{name:i}),title:kd(e),onClick:()=>pL.getState().show(r,e),children:[I(`span`,{className:`doc-card-icon`,"aria-hidden":`true`,children:I(Sa,{size:16})}),R(`span`,{className:`doc-card-text`,children:[I(`span`,{className:`doc-card-name`,dir:`ltr`,children:i}),I(`span`,{className:`doc-card-meta`,children:n(a&&t===`ready`?`docPane.card.shown`:AL[t])})]})]},e)})})}async function ML(){return Nn(`GET`,`/speech/settings`)}async function NL(e){return Nn(`PUT`,`/speech/settings`,e)}async function PL(){return Nn(`GET`,`/speech/model`)}var FL=1e3;async function IL(e,t={}){let n=`${Le()}/speech`,r=P.api.time();P.api.info(`POST ${n}`,{chars:e.length,voice:t.voice});let i=await fetch(n,{method:`POST`,headers:{...pn,"Content-Type":`application/json`},body:JSON.stringify({text:e,voice:t.voice,speed:t.speed}),signal:t.signal});if(!i.ok){let e=await i.text().catch(()=>``);P.api.error(`POST ${n} - HTTP ${i.status}`,{errorText:e});let t=hr(e);throw new On(p(i.status,t),i.status,t,xt(e))}let a=await i.blob();return P.api.timed(`POST ${n} -> ${i.status} (${a.size} bytes)`,r),a}function LL(e){return e.replace(/```[\s\S]*?(```|$)/g,`
178
+ `).replace(/!\[[^\]]*\]\([^)]*\)/g,``).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/<\/?[a-z][^>]*>/gi,``).replace(/https?:\/\/\S+/g,``).replace(/`([^`]*)`/g,`$1`).replace(/^[ \t]*([-*_][ \t]*){3,}$/gm,``).replace(/^[ \t]{0,3}#{1,6}[ \t]+/gm,``).replace(/^[ \t]*>[ \t]?/gm,``).replace(/^[ \t]*([-*+]|\d+[.)])[ \t]+/gm,``).replace(/^[ \t]*\|?[ \t:|-]+\|[ \t:|-]*$/gm,``).replace(/^[ \t]*\|(.*?)\|?[ \t]*$/gm,(e,t)=>t.split(`|`).map(e=>e.trim()).filter(Boolean).join(`, `)).replace(/(\*\*|\*|~~)(\S(?:[\s\S]*?\S)?)\1/g,`$2`).replace(/(?<!\w)(__|_)(\S(?:[\s\S]*?\S)?)\1(?!\w)/g,`$2`).split(`
179
+ `).map(e=>e.trim()).filter(Boolean).join(`
180
+ `).trim()}function RL(e,t){let n=[],r=e.trim();for(;r.length>t;){let e=r.slice(0,t),i=Math.max(e.lastIndexOf(`, `),e.lastIndexOf(`; `),e.lastIndexOf(` `)),a=i>t/3?i+1:t;n.push(r.slice(0,a).trim()),r=r.slice(a).trim()}return r&&n.push(r),n}function zL(e,t=1e3){let n=LL(e);if(!n)return[];let r=n.split(/(?<=[.!?…؟])\s+|\n+/).flatMap((e,n)=>RL(e,Math.min(n===0?180:600,t))),i=[],a=``;for(let e of r){let n=Math.min(i.length===0?180:600,t);a&&a.length+1+e.length>n?(i.push(a),a=e):a=a?`${a} ${e}`:e}return a&&i.push(a),i}var BL=class extends Error{};function VL(e,t){return t instanceof On?{messageId:e,kind:t.httpStatus===503?`unreachable`:t.httpStatus===502?`speech`:t.httpStatus===409?`unavailable`:`other`,detail:t.detail||t.message}:t instanceof BL||t instanceof DOMException&&t.name===`NotAllowedError`?{messageId:e,kind:`playback`,detail:t.message}:{messageId:e,kind:`other`,detail:t instanceof Error?t.message:String(t)}}var HL=null;function UL(e){e.abort.abort(),e.audio&&(e.audio.pause(),e.audio.src=``),e.urls.forEach(e=>URL.revokeObjectURL(e)),e.urls=[]}function WL(e,t){return new Promise((n,r)=>{let i=URL.createObjectURL(t);e.urls.push(i);let a=new Audio(i);e.audio=a;let o=()=>{e.abort.signal.removeEventListener(`abort`,o),n()};a.onended=o,a.onerror=()=>r(new BL(a.error?.message||`media error ${a.error?.code??``}`.trim())),e.abort.signal.addEventListener(`abort`,o),a.play().catch(r)})}var GL=or((e,t)=>({messageId:null,status:null,error:null,settings:null,voiceReady:!1,downloadGb:null,setSettings:t=>e({settings:t}),stop:()=>{HL&&UL(HL),HL=null,e({messageId:null,status:null,downloadGb:null})},clearError:()=>e({error:null}),read:async(n,r)=>{t().stop();let i=zL(r,FL);if(i.length===0){e({error:{messageId:n,kind:`nothing`,detail:``}});return}let a={abort:new AbortController,audio:null,urls:[]};HL=a,e({messageId:n,status:`loading`,error:null});let o=e=>{let t=IL(e,{signal:a.abort.signal});return t.catch(()=>void 0),t};try{if(!t().voiceReady){let t=await PL();if(HL!==a)return;t.downloaded||e({status:`downloading`,downloadGb:t.size_gb})}let n=o(i[0]);for(let t=0;t<i.length;t++){let r=await n;if(HL!==a||(t+1<i.length&&(n=o(i[t+1])),e({status:`playing`,voiceReady:!0,downloadGb:null}),await WL(a,r),HL!==a))return}}catch(t){if(HL!==a||a.abort.signal.aborted)return;P.ui.error(`Read aloud failed`,t),e({error:VL(n,t)})}HL===a&&(UL(a),HL=null,e({messageId:null,status:null,downloadGb:null}))}}));function KL({messageId:e,content:t}){let n=L(),r=GL(t=>t.messageId===e),i=GL(t=>t.messageId===e?t.status:null),a=GL(e=>e.read),o=GL(e=>e.stop);if(GL(e=>e.settings?.available===!1))return null;let s=n(r?`readAloud.stop`:`readAloud.read`);return I(`button`,{type:`button`,className:`msg-action-btn msg-read-aloud${r?` is-active`:``}`,onClick:()=>r?o():void a(e,t),title:s,"aria-label":s,"aria-pressed":r,children:i===`loading`||i===`downloading`?I(B,{size:12,className:`spin`}):I(r?ec:mc,{size:12})})}function qL({messageId:e}){let t=L(),n=GL(t=>t.messageId===e&&t.status===`downloading`),r=GL(e=>e.downloadGb);return n?R(`p`,{className:`msg-read-aloud-note`,role:`status`,children:[t(`readAloud.downloading`),r!=null&&R(F.Fragment,{children:[` `,R(`bdi`,{dir:`ltr`,children:[`(~`,r,` GB)`]})]})]}):null}function JL({messageId:e}){let t=L(),n=GL(t=>t.error?.messageId===e?t.error:null),r=GL(e=>e.clearError);return n?R(`p`,{className:`msg-read-aloud-error`,role:`alert`,children:[R(`span`,{children:[t(`readAloud.error.${n.kind}`),n.detail&&I(`span`,{className:`msg-read-aloud-detail`,children:I(`bdi`,{children:n.detail})})]}),I(`button`,{type:`button`,className:`msg-action-btn`,onClick:r,"aria-label":t(`readAloud.dismiss`),title:t(`readAloud.dismiss`),children:I(bc,{size:12})})]}):null}var YL=[0,3e3,1e4],XL=`The answer to your last message was lost: its run stopped before it finished, most often because GAIA restarted. Send the message again.`;function ZL(e){return e.name===`StreamStalledError`||e.name===`StreamDroppedError`}function QL(e){return e.name===`StreamDroppedError`&&e.unreachable===!0}function $L(e){return QL(e)?!1:ZL(e)||e instanceof Dt}function eR(e,t=Qt()){if(QL(e))return t(`chatError.gaiaStopped`);if(ZL(e))return t(`chatError.liveViewLost`,{n:4});if(e instanceof Dt)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: reopen this chat once GAIA is answering again.`;if(e instanceof On){let t=e.detail?hr(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 tR=/context (window|size|length|limit)|exceeds the available context|maximum context|too many tokens/i,nR=/lemonade|\bLLM\b|could not get response/i,rR=/failed to fetch|networkerror|\bfetch\b/i,iR=/timed out|timeout/i,aR=/\bGF-\d{8}-\d{6}-[0-9a-f]{4}\b/;function oR(e){return aR.exec(e)?.[0]??null}function sR(e,t=Qt()){let n=cR(e,t),r=oR(e.message||``);return r?{...n,text:`${n.text}\n\n${t(`chatError.savedReport`,{id:r})}`}:n}function cR(e,t){let n=eR(e,t);if(n)return{kind:`stream`,text:n};let r=e.message||``;return tR.test(r)?{kind:`context`,text:t(`chatError.context`)}:nR.test(r)?{kind:`model_server`,text:t(`chatError.modelServer`)}:e instanceof TypeError||rR.test(r)?{kind:`connection`,text:t(`chatError.connection`)}:iR.test(r)?{kind:`timeout`,text:t(`chatError.timeout`)}:{kind:`unknown`,text:t(`chatError.unknown`)}}function lR(e){return oR(e)!==null}function uR(e){return e instanceof Error?e.message:String(e)}function dR(e){let t=L(),[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(null);return{saving:n,saved:i,error:o,save:(0,V.useCallback)(async()=>{r(!0),s(null),a(null);try{let e=await ot(),t=await Me(e.name),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=e.name,r.click(),setTimeout(()=>URL.revokeObjectURL(n),6e4),a(e)}catch(n){s(t(e,{error:uR(n)}))}finally{r(!1)}},[t,e])}}function fR({classes:e,note:t}){let n=L(),{saving:r,saved:i,error:a,save:o}=dR(`setup.logs.reportFailed`);return R(`div`,{className:e.root,children:[R(`button`,{type:`button`,className:e.button,onClick:()=>void o(),disabled:r,children:[r?I(B,{size:13,className:`spin`,"aria-hidden":`true`}):I(fa,{size:13,"aria-hidden":`true`}),I(`span`,{children:n(`setup.logs.report`)})]}),t&&I(`span`,{className:e.hint,children:t}),i&&R(`p`,{className:e.hint,role:`status`,children:[n(`setup.logs.reportSaved`,{size:XA(i.size_bytes)}),` `,I(`bdi`,{dir:`ltr`,children:i.path})]}),a&&I(`p`,{className:e.error,role:`alert`,children:a})]})}function pR(e){let t=Uint8Array.from(atob(e.crop),e=>e.charCodeAt(0));return new File([t],`picked-${e.ref}.png`,{type:`image/png`})}function mR(e){let{crop:t,outerHTML:n,styles:r,...i}=e.element;return{...i,outerHTML:e.include.html?n:null,styles:e.include.styles?r:null,cropUrl:e.include.screenshot?e.cropUrl:null}}var hR=or((e,t)=>{let n=(t,n)=>e(e=>({chips:e.chips.map(e=>e.element.ref===t?{...e,...n}:e)})),r=e=>{lt(pR(e)).then(t=>n(e.ref,{uploading:!1,cropUrl:t.url})).catch(t=>{P.chat.error(`Could not upload the picture of picked element ${e.ref}`,t),n(e.ref,{uploading:!1,error:t instanceof Error?t.message:String(t)})})};return{chips:[],dismissed:[],applyPick:({run:n,elements:i})=>{let a=new Map(t().chips.map(e=>[e.element.ref,e])),o=[],s=i.filter(e=>!t().dismissed.includes(e.ref)).map(e=>{let t=a.get(e.ref);return t?{...t,element:e,run:n}:(o.push(e),{element:e,run:n,include:{html:!0,styles:!0,screenshot:!1},cropUrl:null,uploading:e.crop!==null,error:null})});e(e=>({chips:[...e.chips.filter(e=>e.run!==n),...s]})),o.filter(e=>e.crop!==null).forEach(r)},toggle:(t,n)=>e(e=>({chips:e.chips.map(e=>e.element.ref===t?{...e,include:{...e.include,[n]:!e.include[n]}}:e)})),remove:t=>e(e=>({chips:e.chips.filter(e=>e.element.ref!==t),dismissed:[...e.dismissed,t]})),take:()=>{let{chips:n}=t();if(n.length!==0)return e({chips:[]}),n.map(mR)}}});function gR(e){let t=e.name.length>40?`${e.name.slice(0,39)}…`:e.name;return t?`${e.label} "${t}"`:e.label}var _R=[{part:`html`,label:`browserPane.chip.part.html`,send:`browserPane.chip.send.html`,leaveOut:`browserPane.chip.leaveOut.html`},{part:`styles`,label:`browserPane.chip.part.styles`,send:`browserPane.chip.send.styles`,leaveOut:`browserPane.chip.leaveOut.styles`},{part:`screenshot`,label:`browserPane.chip.part.screenshot`,send:`browserPane.chip.send.screenshot`,leaveOut:`browserPane.chip.leaveOut.screenshot`}];function vR({chip:e}){let{element:t}=e,n=hR(e=>e.toggle),r=hR(e=>e.remove),i=L(),a=gR(t);return R(`li`,{className:`element-chip${e.error?` has-error`:``}`,"data-ref":t.ref,children:[t.crop?I(`img`,{className:`element-chip-thumb`,src:`data:image/png;base64,${t.crop}`,alt:``}):I(Mo,{size:14,"aria-hidden":`true`}),R(`span`,{className:`element-chip-text`,title:`${t.ref}: ${t.selector}\n${t.url}`,children:[I(`span`,{className:`element-chip-label`,children:a}),t.component&&R(`span`,{className:`element-chip-component`,children:[`<`,t.component.name,`>`]})]}),I(`span`,{className:`element-chip-parts`,role:`group`,"aria-label":i(`browserPane.chip.whatToSend`,{label:a}),children:_R.map(({part:r,label:a,send:o,leaveOut:s})=>{let c=r===`screenshot`&&(t.crop===null||e.error!==null);return I(`button`,{type:`button`,className:`element-chip-part`,"aria-pressed":e.include[r]&&!c,disabled:c,title:i(c?`browserPane.chip.noScreenshot`:e.include[r]?s:o),onClick:()=>n(t.ref,r),children:i(a)},r)})}),e.uploading&&I(`span`,{className:`element-chip-state`,children:i(`browserPane.chip.uploading`)}),e.error&&I(`span`,{className:`element-chip-state`,role:`alert`,children:i(`browserPane.chip.uploadFailed`)}),I(`button`,{type:`button`,className:`composer-icon-btn`,onClick:()=>r(t.ref),"aria-label":i(`browserPane.chip.remove`,{label:a}),children:I(bc,{size:12})})]})}function yR(){let e=hR(e=>e.chips),t=L();return e.length===0?null:R(F.Fragment,{children:[I(`ul`,{className:`element-chips`,"aria-label":t(`browserPane.chip.list`),children:e.map(e=>I(vR,{chip:e},e.element.ref))}),e.length>8&&I(`p`,{className:`composer-limit-error`,role:`alert`,children:t(`browserPane.chip.tooMany`,{max:8,n:e.length-8})})]})}function bR(e){let t=L(),n=hR(t=>t.chips.length===0?null:t.chips.length>8?`browserPane.block.tooMany`:t.chips.some(e=>e.uploading)?`browserPane.block.uploading`:e?`browserPane.block.streaming`:null);return n===null?null:t(n,{max:8})}function xR({elements:e}){let t=L();return I(`ul`,{className:`element-chips is-sent`,"aria-label":t(`browserPane.chip.list`),children:e.map(e=>R(`li`,{className:`element-chip`,"data-ref":e.ref,title:`${e.ref}: ${e.selector}\n${e.url}`,children:[I(Mo,{size:14,"aria-hidden":`true`}),R(`span`,{className:`element-chip-text`,children:[I(`span`,{className:`element-chip-label`,children:gR(e)}),e.component&&R(`span`,{className:`element-chip-component`,children:[`<`,e.component.name,`>`]})]})]},e.ref))})}var SR=10,CR=.6;function wR(e){let t=e.toLowerCase().match(/[\p{L}\p{N}]+/gu)??[],n=new Set;for(let e=1;e<t.length;e++)n.add(`${t[e-1]} ${t[e]}`);return n}function TR(e,t){if(e.size<SR||t.size<SR)return!1;let n=0;for(let r of e)t.has(r)&&n++;return n/e.size>=CR}function ER(e,t){let n=e.map((e,t)=>({step:e,index:t})).filter(({step:e})=>e.type===`commentary`&&e.detail?.trim());if(n.length===0)return e;let r=n.map(({step:e})=>wR(e.detail??``)),i=wR(t),a=new Set;return n.forEach(({index:e},t)=>{[...r.slice(t+1),i].some(e=>TR(r[t],e))&&a.add(e)}),a.size===0?e:e.filter((e,t)=>!a.has(t))}var DR=[{re:/Settings\s*(?:>|›|→)\s*Advanced\s*(?:>|›|→)\s*Custom model ID/i,section:`advanced`,target:`[data-settings-target="custom-model"]`}],OR=`Failed to start the query run:`,kR=/^(?:[A-Za-z_.]*(?:Error|Exception):|Failed to (?:preload|load|auto-download)\b)|Traceback \(most recent/,AR=1500,jR=/\brun:\s|re-run your|`gaia [a-z]/i,MR=/no model called|doesn't list (?:it|this model)|must include the .?user.? namespace|isn't installed on the local LLM server|\bmodel\b[^\n]{0,80}\bwas not found\b/i,NR=/\bmodel\b[^\n]{0,40}\b(?:couldn't|didn't|failed to) (?:pre)?load|failed to (?:pre)?load (?:lemonade )?model/i,PR=/context (?:window|size|length|limit)|exceeds the available context|maximum context|too many tokens/i,FR={general:`general`,setup:`setup`,"agent & model":`model`,model:`model`,permissions:`permissions`,skills:`skills`,connectors:`connectors`,messaging:`messaging`,automations:`automations`,memory:`memory`,privacy:`privacy`,notifications:`notifications`,"read aloud":`voice`,advanced:`advanced`,about:`about`},IR=/Settings\s*(?:>|›|→)\s*(General|Setup|Agent & model|Model|Permissions|Skills|Connectors|Messaging|Automations|Memory|Privacy|Notifications|Read aloud|Advanced|About)\b/g;function LR(e){return MR.test(e)?`modelUnavailable`:NR.test(e)?`modelLoad`:PR.test(e)?`context`:`unknown`}function RR(e){let t=zR(e),n=LR(t),r=kR.test(t)||t.length<AR&&jR.test(t),i=n===`modelUnavailable`||n===`modelLoad`?[`model`]:[];for(let e of t.matchAll(IR)){let t=FR[e[1].toLowerCase()];i.includes(t)||i.push(t)}let a={};for(let e of DR)i.includes(e.section)&&e.re.test(t)&&(a[e.section]=e.target);return{kind:n,raw:r,sections:i,targets:a}}function zR(e){let t=e.trim();return t.startsWith(OR)?t.slice(30).trim():t}var BR=/^!\[([^\]]*)\]\((\/api\/files\/uploads\/[^)\s]+)\)$/;function VR(e){try{return decodeURIComponent(e)}catch{return e}}function HR(e){let t=[],n=[],r=!1;for(let i of e.split(`
181
+ `)){i.trim().startsWith("```")&&(r=!r);let e=r?null:BR.exec(i.trim()),a=e?yy(e[2]):``;e&&a?t.push({src:a,name:e[1]||VR(e[2].split(`/`).pop()||``)}):n.push(i)}return t.length===0?{text:e,images:t}:{text:n.join(`
182
+ `).replace(/\n{3,}/g,`
183
+
184
+ `).trim(),images:t}}function UR({images:e,index:t,onIndex:n,onClose:r}){let i=L(),a=(0,V.useRef)(null),o=(0,V.useRef)(null),s=e.length>1,c=e[t];er(!0,r),yn(a,!0),(0,V.useEffect)(()=>{o.current?.focus()},[]);let l=(0,V.useCallback)(r=>{n((t+r+e.length)%e.length)},[t,e.length,n]);return(0,V.useEffect)(()=>{if(!s)return;let e=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;let t=a.current?getComputedStyle(a.current).direction===`rtl`:!1;e.preventDefault(),l(e.key===`ArrowRight`===t?-1:1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[s,l]),c?(0,by.createPortal)(I(`div`,{ref:a,className:`image-viewer`,role:`dialog`,"aria-modal":`true`,"aria-label":i(`imageViewer.dialog`),onClick:e=>{e.target===e.currentTarget&&r()},children:R(`div`,{className:`image-viewer-stage`,onClick:e=>{e.target===e.currentTarget&&r()},children:[I(`button`,{ref:o,type:`button`,className:`image-viewer-btn image-viewer-close`,onClick:r,"aria-label":i(`imageViewer.close`),children:I(bc,{size:18,"aria-hidden":`true`})}),s&&I(`button`,{type:`button`,className:`image-viewer-btn image-viewer-prev`,onClick:()=>l(-1),"aria-label":i(`imageViewer.prev`),children:I(mi,{size:20,"aria-hidden":`true`})}),I(`img`,{className:`image-viewer-img`,src:c.src,alt:c.name}),s&&I(`button`,{type:`button`,className:`image-viewer-btn image-viewer-next`,onClick:()=>l(1),"aria-label":i(`imageViewer.next`),children:I(gi,{size:20,"aria-hidden":`true`})}),R(`p`,{className:`image-viewer-caption`,dir:`auto`,children:[I(`bdi`,{children:c.name}),s&&R(F.Fragment,{children:[` · `,I(`bdi`,{dir:`ltr`,children:i(`imageViewer.count`,{n:t+1,total:e.length})})]})]})]})}),document.body):null}function WR({images:e}){let t=L(),[n,r]=(0,V.useState)(null),i=(0,V.useRef)([]),a=(0,V.useCallback)(()=>{let e=n;r(null),e!==null&&requestAnimationFrame(()=>i.current[e]?.focus())},[n]);return e.length===0?null:R(F.Fragment,{children:[I(`ul`,{className:`image-thumbs`,"aria-label":t(`msg.images`),children:e.map((e,n)=>I(`li`,{children:I(`button`,{type:`button`,ref:e=>{i.current[n]=e},className:`image-thumb`,onClick:()=>r(n),"aria-label":t(`msg.imageOpen`,{name:e.name}),title:e.name,children:I(`img`,{src:e.src,alt:``,loading:`lazy`})})},`${e.src}-${n}`))}),n!==null&&I(UR,{images:e,index:n,onIndex:r,onClose:a})]})}var GR=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),KR=String.raw`[^\s*?"<>|,;)}\]\\/]+[\\/]`,qR=String.raw`(?:(?:[A-Za-z]:[\\/]|(?<![\p{L}\p{N}_.\-\\/])/)(?:${KR})*)?`,JR=String.raw`(?<![\p{L}\p{N}_.\-])`,YR=String.raw`(?![\p{L}\p{N}_\-]|\.[\p{L}\p{N}])`,XR=e=>e.trim().replace(/\\/g,`/`).toLowerCase(),ZR=e=>e.trim().split(/[\\/]/).pop()??``,QR=e=>e.split(/[\\/]/).slice(0,-1).filter(Boolean);function $R(e){let t=new Map;for(let n of e)t.set(n.filename.toLowerCase(),[...t.get(n.filename.toLowerCase())??[],n]);let n=new Map;for(let e of t.values()){let t=Math.max(...e.map(e=>QR(e.filepath??``).length)),r=null;for(let n=1;e.length>1&&n<=t&&!r;n++){let t=e.map(e=>[...QR(e.filepath??``).slice(-n),e.filename].join(`/`));new Set(t.map(e=>e.toLowerCase())).size===e.length&&(r=t)}e.forEach((e,t)=>n.set(e,r?r[t]:e.filename))}return n}function ez(e){let t=e.filter(e=>e.filename),n=$R(t),r=new Map,i=new Map;for(let e of t){let t={id:e.id,filename:e.filename,label:n.get(e)},a=new Set([e.filename.toLowerCase()]);e.filepath&&(a.add(ZR(e.filepath).toLowerCase()),i.set(XR(e.filepath),t));for(let n of a){let i=r.get(n);r.set(n,i===void 0||i?.id===e.id?t:null)}}if(r.size===0)return{re:null,byName:r,byPath:i};let a=[...r.keys()].sort((e,t)=>t.length-e.length).map(GR).join(`|`);return{re:RegExp(`${qR}${JR}(${a})${YR}`,`giu`),byName:r,byPath:i}}function tz(e,t){return e.byPath.get(XR(t))??e.byName.get(ZR(t).toLowerCase())??null}function nz(e,t){if(!e.re)return[];let n=[];for(let r of t.matchAll(e.re)){let i=r.index+r[0].length,a=rz(e,t,i,ZR(r[0]).toLowerCase()),o=a&&a.start<=r.index?null:tz(e,r[0]);o?n.push({start:r.index,end:i,doc:o}):a&&n.push({start:a.start,end:i,doc:a.doc})}return n}function rz(e,t,n,r){let i=t.slice(0,n).replace(/\\/g,`/`).toLowerCase(),a=null;for(let[t,o]of e.byPath)ZR(t)===r&&i.endsWith(t)&&(!a||n-t.length<a.start)&&(a={start:n-t.length,doc:o});return a}var iz=`[0-9\\u0660-\\u0669\\u06F0-\\u06F9]+`,az=`pages?|pp?\\.|[وبفل]?(?:الصفحات|الصفحتان|الصفحتين|الصفحة|صفحات|صفحتي|صفحة)|ص\\.?`,oz=String.raw`\s*(?:,|،|&|and|to|و|إلى|[-–—])\s*`,sz=new RegExp(String.raw`(?<!\p{L})(?:${az})(?!\p{L})\s*(${iz}(?:${oz}${iz})*)`,`iu`);function cz(e){return Number(e.replace(/[٠-٩۰-۹]/g,e=>String(e.charCodeAt(0)&15)))}function lz(e){let t=sz.exec(e);if(!t||t.index>40)return[];let n=t.index+t[0].length-t[1].length,r=[];for(let e of t[1].matchAll(new RegExp(iz,`g`))){let t=cz(e[0]);t>0&&r.push({start:n+e.index,end:n+e.index+e[0].length,page:t})}return r}function uz({active:e,label:t,awaitingUser:n=!1}){let r=L(),i=n?r(`activity.waiting`):t?gk(r,t):r(`msg.thinking`),a=fz(e,i),o=e&&!n&&LF(t),s=fz(o),c=fl();return e?R(`span`,{className:`thinking-indicator${n?``:` is-live`}`,children:[I(`span`,{className:`thinking-indicator-text`,children:i}),!n&&a>=dz&&R(`span`,{className:`thinking-indicator-elapsed`,children:[` · `,R(`bdi`,{dir:`ltr`,children:[a,`s`]})]}),o&&s>=45&&I(`span`,{className:`thinking-indicator-hint`,role:`status`,children:c?.remote===!1?r(`live.localModelWaitHint`,{n:`45`}):r(`live.modelWaitHint`)})]}):null}var dz=3;function fz(e,t){let[n,r]=(0,V.useState)(0);return(0,V.useEffect)(()=>{if(r(0),!e)return;let t=Date.now(),n=setInterval(()=>r(Math.floor((Date.now()-t)/1e3)),1e3);return()=>clearInterval(n)},[e,t]),n}var pz=/^The model (?:call failed|stopped responding) at step \d+, so this request is unfinished\./;function mz(e){return pz.test(e.trimStart())}var hz=/[\\/]agents[\\/][^\\/\s]+[\\/]logs\b/;function gz(e){return hz.test(e)}var _z={root:`msg-report`,button:`msg-try-again`,hint:`msg-report-hint`,error:`msg-report-error`};function vz(e){if(!e)return!1;let t=e.toLowerCase();return t.startsWith(`error:`)||t.startsWith(`error -`)||t.includes(`traceback (most recent`)||t.includes(`object has no attribute`)||t.includes(`is lemonade server running`)||t.includes(`connection refused`)||t.includes(`failed to fetch`)}var yz=e=>e.replace(/\s+/g,` `).trim();function bz(e,t){let n=yz(t);if(!n)return{steps:e,echoed:!1,endedBy:null};let r=t.trimEnd(),i=e[e.length-1],a=!1,o=null;return{steps:e.filter(e=>e.type!==`error`||!e.detail?.trim()?!0:yz(e.detail)===n?(a=!0,!1):e!==i||!r.endsWith(`\n\n${e.detail.trim()}`)||(o=e.detail.trim(),!1)),echoed:a,endedBy:o}}var xz=/\s*\{\s*"?tool"?\s*:\s*"[^"]+"\s*,\s*"?tool_args"?\s*:\s*\{[^}]*\}\s*\}/g,Sz=new Set([`thought`,`answer`,`tool`,`tool_args`,`goal`]),Cz=/^\{\s*"(thought|answer|tool|tool_args|goal)"\s*:/;function wz(e,t){let n=0,r=!1,i=!1;for(let a=t;a<e.length;a++){let t=e[a];if(r)i?i=!1:t===`\\`?i=!0:t===`"`&&(r=!1);else if(t===`"`)r=!0;else if(t===`{`)n++;else if(t===`}`&&(n--,n===0))return a}return-1}function Tz(e){let t=e.indexOf(`"answer"`);if(t===-1)return null;let n=e.indexOf(`:`,t+8);if(n===-1)return null;let r=n+1;for(;r<e.length&&/\s/.test(e[r]);)r++;if(r>=e.length||e[r]!==`"`)return null;let i=e.slice(r+1);return i.endsWith(`"}`)?i=i.slice(0,-2):i.endsWith(`"`)&&(i=i.slice(0,-1)),i.replace(/\\"/g,`"`).replace(/\\n/g,`
185
+ `).replace(/\\\\/g,`\\`)}function Ez(e){let t;try{t=JSON.parse(e)}catch{let t=Tz(e);return t===null?e.includes(`"tool_args"`)?{action:`drop`}:{action:`keep`}:{action:`answer`,text:t}}if(typeof t!=`object`||!t||Array.isArray(t))return{action:`keep`};let n=t,r=Object.keys(n),i=r.length>0&&r.every(e=>Sz.has(e));return typeof n.tool==`string`&&n.tool_args!==void 0?{action:`drop`}:typeof n.answer==`string`&&i?{action:`answer`,text:n.answer}:typeof n.thought==`string`&&n.answer===void 0&&i?{action:`drop`}:{action:`keep`}}function Dz(e,t){let n=``,r=0;for(;r<e.length;){let i=e.indexOf(`{`,r);if(i===-1){n+=e.slice(r);break}if(!Cz.test(e.slice(i,i+40))){n+=e.slice(r,i+1),r=i+1;continue}let a=wz(e,i);if(a===-1){n+=t?e.slice(r,i):e.slice(r);break}n+=e.slice(r,i);let o=e.slice(i,a+1),s=Ez(o);s.action===`answer`?n+=s.text:s.action===`keep`&&(n+=o),r=a+1}return n}var Oz=new Set(`python.py.javascript.js.typescript.ts.java.c.cpp.csharp.cs.go.rust.ruby.rb.php.swift.kotlin.scala.r.perl.lua.bash.sh.zsh.powershell.ps1.sql.html.css.scss.sass.less.xml.json.yaml.yml.toml.ini.csv.markdown.md.dockerfile.docker.makefile.cmake.nginx.apache.graphql.proto.protobuf.jsx.tsx.vue.svelte.dart.elixir.ex.erlang.haskell.hs.ocaml.ml.fsharp.fs.clojure.clj.lisp.scheme.racket.zig.nim.crystal.julia.matlab.octave.fortran.cobol.pascal.delphi.ada.assembly.asm.nasm.wasm.solidity.sol.verilog.vhdl.text.txt.plaintext.diff.patch.log`.split(`.`));function kz(e){return e.replace(/```(\w*)[ \t]*\n([\s\S]*?)```/g,(e,t,n)=>{let r=t.toLowerCase();return r.length>0&&r.length<=2&&!Oz.has(r)?n.trim():e})}var Az=/\n{1,2}Verification: unverified[^\n]*\s*$/;function jz(e){let t=e;for(;;){let e=t.replace(Az,``);if(e===t)return t;t=e}}function Mz(e,t=!1){if(!e)return e;e=jz(e);let n=e;n=n.replace(xz,``),n=Dz(n,t),n=n.replace(/<think>[\s\S]*?<\/think>/g,``);let r=(n.match(/\\n/g)||[]).length,i=(n.match(/\n/g)||[]).length;return r>2&&r>i*2&&(n=n.replace(/\\n/g,`
186
+ `),n=n.replace(/\\"/g,`"`)),n=kz(n).trim(),Nz(n)}function Nz(e){let t=!1;return e.split(`
187
+ `).map(e=>(/^\s*(```|~~~)/.test(e)&&(t=!t),t?e:e.replace(/^(\s*\d+)\.(\s*)$/,`$1\\.$2`))).join(`
188
+ `)}function Pz(e,t){return e?new Date(e).toLocaleString(Ln(t),{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`,second:`2-digit`,hour12:!0}):``}function Fz(e,t,n=new Date){if(!e)return``;let r=new Date(e),i=Ln(t),a=r.toLocaleTimeString(i,{hour:`numeric`,minute:`2-digit`}),o=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime(),s=Math.round((o(n)-o(r))/864e5);return s===0?a:s===1?t(`msg.yesterdayAt`,{time:a}):r.toLocaleString(i,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,...r.getFullYear()===n.getFullYear()?{}:{year:`numeric`}})}var Iz=`Cancelled.`,Lz=[[`This answer was interrupted when GAIA closed. Send again to retry.`,`msg.cutOff.interrupted`],[`This answer was interrupted before it finished. Send again to retry.`,`msg.cutOff.cancelled`],[`This answer ended before GAIA could save a reply. Send again to retry.`,`msg.cutOff.noReply`],[`This run was stopped because its schedule was deleted.`,`msg.cutOff.scheduleDeleted`],[`This run was stopped because its schedule was paused.`,`msg.cutOff.schedulePaused`]],Rz=/(?:^|\n\n)Before it stopped, it had started these tools: (.+)\.$/;function zz(e){let t=e.trim(),n=Lz.find(([e])=>t.endsWith(e));if(!n)return null;t=t.slice(0,-n[0].length).trimEnd();let r=Rz.exec(t);return r&&(t=t.slice(0,r.index).trimEnd()),{body:t,notice:n[1],tools:r?r[1]:null}}function Bz(e,t,n=!1){return t?`stopped`:zz(e)?`interrupted`:n?`failed`:void 0}var Vz=320;function Hz({original:e,draft:t,onDraft:n,onSend:r,onCancel:i,confirming:a=!1}){let o=L(),{text:s,links:c}=(0,V.useMemo)(()=>gy(e),[e]),[l,u]=(0,V.useState)(()=>t==null?s:gy(t).text),d=(0,V.useRef)(null),f=l.trim()!==``&&l!==s,p=()=>r(_y(l,c));return(0,V.useLayoutEffect)(()=>{let e=d.current;e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},[]),(0,V.useLayoutEffect)(()=>{let e=d.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,Vz)}px`)},[l]),R(`div`,{className:`msg-edit`,children:[I(`textarea`,{ref:d,className:`msg-edit-input`,value:l,onChange:e=>{u(e.target.value),n?.(e.target.value)},onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),i()):e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),f&&!a&&p())},"aria-label":o(`msg.editLabel`),readOnly:a,rows:1,dir:`auto`,...Lt}),c.length>0&&I(`ul`,{className:`msg-edit-attachments`,"aria-label":o(`composer.attached`),children:c.map((e,t)=>R(`li`,{className:`msg-edit-attachment`,children:[I(Sa,{size:14,"aria-hidden":`true`}),I(`span`,{className:`msg-edit-attachment-name`,title:e.name,dir:`auto`,children:e.name})]},t))}),!a&&R(`div`,{className:`msg-edit-actions`,children:[I(`button`,{type:`button`,className:`btn-secondary msg-edit-btn`,onClick:i,children:o(`msg.editCancel`)}),I(`button`,{type:`button`,className:`btn-primary msg-edit-btn`,onClick:p,disabled:!f,children:o(`msg.editSend`)})]})]})}var Uz=/^\[schedule-run\] Run #(\d+) \u00b7 (.+)$/;function Wz({message:e,isStreaming:t,agentSteps:n,agentStepsActive:r,cards:i,onDelete:a,onResend:o,extraActions:s,onTryAgain:c,onContinue:l,onRegenerate:u,onEditStart:d,editing:f=!1,editDraft:p=null,onEditDraft:m,onEdit:h,onEditCancel:g,laterCount:_=0,latest:v=!1,latencyMs:y,liveStatus:b,toolStatus:x,awaitingUser:S}){let C=L();ol();let w=(0,V.useMemo)(()=>{if(e.role!==`assistant`||!n)return{steps:n,echoed:!1,endedBy:null};let r=ER(n,e.content);return t?{steps:r,echoed:!1,endedBy:null}:bz(r,e.content)},[n,e.content,e.role,t]),T=e.role===`assistant`&&(w.echoed||e.failed===!0||e.stalled===!0||vz(e.content)),E=fl(),ee=Pc(e=>e.show),D=z(e=>e.openSettings),O=z(e=>e.jumpToSetting),te=(0,V.useMemo)(()=>T&&!t?RR(e.content):null,[T,t,e.content]),k=e.role===`assistant`?e.stopState??(e.content.trim()===Iz?`stopped`:void 0):void 0,A=(0,V.useMemo)(()=>e.role===`assistant`&&!t?zz(e.content):null,[e.content,e.role,t]),ne=A?null:w.endedBy,j=(0,V.useMemo)(()=>e.role===`user`?HR(e.content):null,[e.content,e.role]),M=(0,V.useMemo)(()=>j?Nd(j.text):Mz(A?A.body:ne?e.content.trimEnd().slice(0,-ne.length):e.content,!!t),[e.content,j,t,A,ne]),re=!!M.trim()&&!(k&&M.trim()===Iz),ie=e.turnSummary?.files,ae=(0,V.useMemo)(()=>ie?.map(e=>e.path)??[],[ie]),oe=`${e.session_id}:${e.id}`,[se,ce]=YO(),[le,ue]=(0,V.useState)(!1),de=e.role===`user`&&QO(e.content),fe=(0,V.useMemo)(()=>de?ek(e.content):null,[de,e.content]),[pe,me]=(0,V.useState)(!1),he=(0,V.useId)(),ge=(0,V.useRef)(null),_e=(0,V.useRef)(!1),ve=(0,V.useCallback)(()=>{pe&&(_e.current=!0),me(!pe)},[pe]);(0,V.useEffect)(()=>{!pe&&_e.current&&(_e.current=!1,ge.current?.scrollIntoView?.({block:`nearest`}))},[pe]);let ye=(0,V.useRef)(null);(0,V.useEffect)(()=>()=>{ye.current&&clearTimeout(ye.current)},[]);let be=(0,V.useCallback)(()=>{ce(e.role===`assistant`?IF(M):e.content)},[ce,M,e.content,e.role]),xe=(0,V.useCallback)(()=>{le?(ue(!1),ye.current&&clearTimeout(ye.current),a?.(e.id)):(ue(!0),ye.current&&clearTimeout(ye.current),ye.current=setTimeout(()=>ue(!1),3e3))},[le,e.id,a]),[Se,Ce]=(0,V.useState)(null),we=(0,V.useCallback)(e=>{_>0?Ce(()=>e):e()},[_]),N=(0,V.useCallback)(()=>{we(()=>o?.(e))},[e,o,we]),Te=e.created_at?C(e.role===`user`?`msg.sent`:`msg.replied`,{time:Pz(e.created_at,C)}):void 0,Ee=e.role===`system`?Uz.exec(e.content):null;return Ee?I(`div`,{className:`msg-run-divider`,role:`separator`,children:C(`msg.scheduledRun`,{n:Ee[1],time:Ee[2]})}):I(`div`,{className:`msg msg-${e.role} ${T?`msg-error`:``}${v?` msg-latest`:``}`,title:Te,children:R(`div`,{className:`msg-inner`,children:[R(`div`,{className:`msg-header`,children:[I(`div`,{className:`msg-header-left`}),!t&&!f&&R(`div`,{className:`msg-actions`,children:[e.role===`user`&&d&&h&&I(`button`,{type:`button`,className:`msg-action-btn`,onClick:()=>d(e),title:C(`msg.edit`),"aria-label":C(`msg.edit`),children:I(Xo,{size:12})}),e.role===`user`&&o&&I(`button`,{className:`msg-action-btn`,onClick:N,title:C(`msg.resend`),"aria-label":C(`msg.resend`),children:I(fs,{size:12})}),e.role===`assistant`&&u&&I(`button`,{type:`button`,className:`msg-action-btn`,onClick:u,title:C(`msg.tryAgain`),"aria-label":C(`msg.tryAgain`),children:I(bs,{size:12})}),s,e.role===`assistant`&&!T&&re&&I(KL,{messageId:oe,content:M}),re&&I(`button`,{className:`msg-copy ${se===`idle`?``:se}`,onClick:be,title:C(se===`copied`?`msg.copied`:se===`failed`?`msg.copyFailed`:`msg.copy`),"aria-label":C(se===`copied`?`msg.copiedAria`:se===`failed`?`msg.copyFailed`:`msg.copy`),children:I(se===`copied`?ci:se===`failed`?wi:Bi,{size:12})}),a&&I(`button`,{className:`msg-action-btn msg-delete ${le?`confirm`:``}`,onClick:xe,title:C(le?`msg.confirmDelete`:`msg.delete`),"aria-label":C(le?`msg.confirmDeleteAria`:`msg.delete`),children:I(oc,{size:12})})]})]}),R(`div`,{className:`msg-body`,children:[e.role===`assistant`&&(w.steps&&w.steps.length>0||t)&&I(tA,{steps:w.steps??[],isActive:r??!1,running:!!t,awaitingUser:S,toolStatus:t?x:null,answer:t?void 0:M,liveLine:t&&I(uz,{active:!!r||!M,label:b,awaitingUser:S})}),T&&R(`div`,{className:`error-banner`,children:[I(cc,{size:14}),I(`span`,{children:C(te&&te.kind!==`unknown`?`failedTurn.${te.kind}.title`:`msg.error`)})]}),(e.cards??i)?.map((e,t)=>I(NF,{render:e.render,data:e.data},t)),e.page_elements&&e.page_elements.length>0&&I(xR,{elements:e.page_elements}),f&&h?I(Hz,{original:e.content,draft:p,onDraft:m,onSend:t=>we(()=>h(e,t)),onCancel:()=>{Ce(null),g?.()},confirming:Se!==null&&!t}):de?R(F.Fragment,{children:[!pe&&fe?R(`div`,{ref:ge,id:he,className:`msg-excerpt md-content`,children:[I(`div`,{className:`msg-excerpt-lines`,dir:`auto`,children:fe.head}),I(`div`,{className:`msg-excerpt-gap`,children:C.plural(`msg.moreLines`,fe.hidden)}),I(`div`,{className:`msg-excerpt-lines`,dir:`auto`,children:fe.tail})]}):I(`div`,{ref:ge,id:he,className:`msg-collapsible${pe?``:` is-collapsed`}`,children:I(mB,{content:M})}),I(nk,{expanded:pe,onToggle:ve,controls:he,collapsedLabel:C.hint(C(`msg.showAll`),tk(C,e.content)),expandedLabel:C(`msg.showLess`),className:`msg-expand-toggle`})]}):te?.raw?R(F.Fragment,{children:[I(`p`,{className:`msg-failed-lead`,children:C(`failedTurn.${te.kind}.body`)}),R(`details`,{className:`msg-failed-details`,children:[I(`summary`,{children:C(`failedTurn.details`)}),I(mB,{content:zR(M)})]})]}):!(k&&M.trim()===Iz)&&I(mB,{content:M,showCursor:t&&!!M&&!r,isStreaming:t,writtenFiles:ae}),e.role===`assistant`&&I(jL,{files:ae,live:!!t}),!f&&j&&I(WR,{images:j.images}),Se&&!t&&R(`div`,{className:`msg-drop-confirm`,role:`alertdialog`,"aria-labelledby":`${he}-drop`,children:[I(`span`,{id:`${he}-drop`,children:C.plural(`msg.dropLater`,_)}),R(`div`,{className:`msg-edit-actions`,children:[I(`button`,{type:`button`,className:`btn-secondary msg-edit-btn`,onClick:()=>Ce(null),autoFocus:!0,children:C(`msg.editCancel`)}),I(`button`,{type:`button`,className:`btn-primary msg-edit-btn`,onClick:()=>{Ce(null),Se()},children:C(`msg.dropLaterGo`)})]})]}),k&&R(`div`,{className:`msg-stopped${k===`unconfirmed`||e.stopError?` is-unconfirmed`:``}`,role:`note`,children:[I(ec,{size:9,fill:`currentColor`,"aria-hidden":`true`}),I(`span`,{children:k===`unconfirmed`?C(`msg.stoppedUnconfirmed`):e.stopError?C(`msg.stoppedError`,{error:e.stopError}):C(`msg.stopped`)})]}),A&&I(`p`,{className:`msg-cut-off`,role:`note`,children:C.compose(e=>A.tools?`${e(`msg.cutOff.toolsRan`,{tools:A.tools})} ${e(A.notice)}`:e(A.notice))}),ne&&I(`p`,{className:`msg-cut-off`,role:`note`,dir:`auto`,children:ne}),l&&k&&!t&&M.trim()&&M.trim()!==Iz&&R(`button`,{type:`button`,className:`msg-try-again`,onClick:l,children:[I(ns,{size:12,"aria-hidden":`true`}),C(`msg.continue`)]}),c&&!t&&R(`button`,{type:`button`,className:`msg-try-again`,onClick:c,children:[I(bs,{size:12,"aria-hidden":`true`}),C(`msg.tryAgain`)]}),te?.sections.map(e=>R(`button`,{type:`button`,className:`msg-try-again`,onClick:()=>{let t=te?.targets[e];t?O({section:e,target:t}):D(e)},children:[I(As,{size:12,"aria-hidden":`true`}),C.compose(t=>t(`failedTurn.openSettings`,{tab:t(`settings.section.${e}`)}))]},e)),(T||ne)&&!t&&gz(ne??e.content)?R(`button`,{type:`button`,className:`msg-try-again`,onClick:()=>ee(`agent`),children:[I(ws,{size:12,"aria-hidden":`true`}),C(`logs.agentLog`)]}):(T||e.role===`assistant`&&mz(e.content))&&!t&&(e.turnSummary?.model?.remote??E?.remote)===!1&&R(`button`,{type:`button`,className:`msg-try-again`,onClick:()=>ee(`model_server`),children:[I(ws,{size:12,"aria-hidden":`true`}),C(`logs.serverLog`)]}),e.role===`assistant`&&!t&&(lR(e.content)||lR(e.failureText??``))&&I(fR,{classes:_z,note:C(`msg.reportNote`)}),e.role===`assistant`&&!t&&sj(M)&&I(pj,{content:M}),e.role===`assistant`&&!t&&(e.stats||y!=null||e.created_at)&&R(`div`,{className:`msg-stats`,"aria-label":C(`msg.about`),children:[e.created_at&&I(`span`,{className:`msg-stats-ts`,title:Pz(e.created_at,C),children:Fz(e.created_at,C)}),e.stats?.retried&&e.stats.model&&I(`span`,{title:`This answer was kept from Retry with… (${e.stats.model})`,children:cl(e.stats.model)}),!e.stats?.retried&&e.stats?.route?.model&&I(`span`,{className:`msg-stats-route`,title:C(`msg.route`,{reason:e.stats.route.reason??``}),children:cl(e.stats.route.model)}),I(Xj,{latencyMs:y,stats:e.stats,ended:Bz(e.content,k,T||!!ne)})]}),e.role===`assistant`&&!t&&e.stats?.route?.degraded&&e.stats.route.notice&&I(`div`,{className:`msg-route-notice`,role:`status`,children:e.stats.route.notice}),e.role===`assistant`&&!t&&e.id>0&&e.session_id&&I(bI,{sessionId:e.session_id,messageId:e.id,ranChangingTool:iI(n),agentProgram:e.agentProgram}),e.role===`assistant`&&I(qL,{messageId:oe}),e.role===`assistant`&&I(JL,{messageId:oe})]})]})})}var Gz=(0,V.createContext)(!1);function Kz({lang:e,code:t}){let n=L(),[r,i]=YO(),[a,o]=(0,V.useState)(!1),s=(0,V.useContext)(Gz),c=(0,V.useId)(),l=ZO(t),u=l>(s?20:25);return R(`div`,{className:`code-block${u&&!a?` is-collapsed`:``}`,dir:`ltr`,children:[R(`div`,{className:`code-header`,children:[I(`span`,{className:`code-lang`,children:e||`code`}),R(`button`,{className:`code-copy ${r===`idle`?``:r}`,onClick:()=>i(t),title:n(r===`copied`?`msg.copied`:r===`failed`?`msg.copyFailed`:`code.copy`),"aria-label":n(r===`copied`?`msg.copiedAria`:r===`failed`?`msg.copyFailed`:`code.copyAria`),children:[I(r===`copied`?ci:r===`failed`?wi:Bi,{size:13}),I(`span`,{children:n(r===`copied`?`code.copied`:r===`failed`?`msg.copyFailed`:`code.copy`)})]})]}),I(`pre`,{id:c,children:I(`code`,{children:t})}),u&&I(nk,{expanded:a,onToggle:()=>o(e=>!e),controls:c,collapsedLabel:n(`code.expand`,{size:XO(n,l)}),expandedLabel:n(`code.collapse`),className:`code-expand-toggle`})]})}var qz=/(?<=["\u201c])[A-Z]:[\\/][^*?"<>|\r\n\u201c\u201d]+(?=["\u201d])|\b[A-Z]:[\\/](?=[^\s*?"<>|,;)}\]\\/])(?:[^\s*?"<>|,;)}\]\\/]+(?:(?: +(?:[^\s*?"<>|,;:)}\]\\/]+|\([^\s*?"<>|,;:)}\]\\/]+\)))+\\|[\\/]))*(?:(?:[^\s*?"<>|,;:.)}\]\\/]+ +){1,2}[^\s*?"<>|,;)}\]\\/]+\.[A-Za-z0-9]{1,5}\b|[^\s*?"<>|,;)}\]\\/]+)?/gi,Jz=/[.:!']+$/,Yz=RegExp(`^(?:${qz.source})$`,`i`),Xz=(0,V.createContext)([]);function Zz(e,t){if(typeof t!=`string`||e.length===0)return null;let n=t.trim();if(!n)return null;if(e.includes(n))return n;if(/[\\/]/.test(n))return null;let r=n.toLowerCase(),i=e.filter(e=>(e.split(/[\\/]/).pop()??``).toLowerCase()===r);return i.length===1?i[0]:null}function Qz(e){if(typeof e!=`string`)return null;let t=e.trim();return Yz.test(t)?t:null}function $z({path:e,label:t}){let n=t=>{t.preventDefault(),nr(e).catch(e=>{P.ui.error(`Failed to open path`,e)})};return R(`span`,{className:`file-path-link`,dir:`ltr`,onClick:n,title:`Open in file explorer: ${kd(e)}`,role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n(e))},children:[I(Ea,{size:12,className:`file-path-icon`}),kd(t??e)]})}function eB(e){return[...e.matchAll(new RegExp(qz.source,`gi`))].map(t=>{let n=t.index+t[0].length,r=`"“`.includes(e[t.index-1]??`
189
+ `)&&`"”`.includes(e[n]??`
190
+ `);return{start:t.index,path:r?t[0]:t[0].replace(Jz,``)}})}function tB(e){let t=[],n=0;for(let{start:r,path:i}of eB(e))r>n&&t.push(e.slice(n,r)),t.push(I($z,{path:i},r)),n=r+i.length;return t.length===0?e:(n<e.length&&t.push(e.slice(n)),I(F.Fragment,{children:t}))}var nB=(0,V.createContext)(ez([]));function rB({doc:e,page:t,t:n}){return R(`a`,{className:`citation-link`,href:C(e.id,t),target:`_blank`,rel:`noopener noreferrer`,dir:`ltr`,title:t?n(`citation.openPage`,{page:t}):n(`citation.open`,{name:kd(e.label)}),"data-doc-id":e.id,"data-page":t,children:[I(Sa,{size:12,className:`citation-icon`,"aria-hidden":`true`}),kd(e.label)]})}function iB({doc:e,page:t,label:n,t:r}){return I(`a`,{className:`citation-page`,href:C(e.id,t),target:`_blank`,rel:`noopener noreferrer`,title:r(`citation.openPage`,{page:t}),"data-doc-id":e.id,"data-page":t,children:n})}function aB(e,t){let n=nz(e,t)[0];return lz(n?t.slice(0,n.start):t)}function oB(e,t,n,r){let i=eB(e),a=nz(t,e).filter(e=>!i.some(t=>t.start<e.start&&e.start<t.start+t.path.length)),o=[],s=(t,r,i)=>{for(let a of r){let r=i+a.start,s=i+a.end;o.push({start:r,end:s,node:I(iB,{doc:t,page:a.page,label:e.slice(r,s),t:n},`p${r}`)})}};if(r&&s(r,lz(e.slice(0,a[0]?.start??e.length)),0),a.forEach((t,r)=>{let i=lz(e.slice(t.end,a[r+1]?.start??e.length));o.push({start:t.start,end:t.end,node:I(rB,{doc:t.doc,page:i[0]?.page,t:n},`c${t.start}`)}),s(t.doc,i,t.end)}),o.length===0)return tB(e);o.sort((e,t)=>e.start-t.start);let c=[],l=0;for(let t of o)t.start>l&&c.push(I(V.Fragment,{children:tB(e.slice(l,t.start))},`t${l}`)),c.push(t.node),l=t.end;return l<e.length&&c.push(I(V.Fragment,{children:tB(e.slice(l))},`t${l}`)),I(F.Fragment,{children:c})}function sB(e,t){return typeof t==`string`?tz(e,t):null}function cB({children:e}){let t=(0,V.useContext)(nB),n=L(),r=V.Children.toArray(e),i=null,a=r.map((e,a)=>{if(typeof e==`string`){let r=oB(e,t,n,i);return i=null,I(V.Fragment,{children:r},`s${a}`)}if(i=null,V.isValidElement(e)&&e.type===uB){let o=sB(t,e.props.children);if(o){let e=r[a+1],s=typeof e==`string`?aB(t,e):[];return i=o,I(rB,{doc:o,page:s[0]?.page,t:n},`k${a}`)}}return e});return I(F.Fragment,{children:a})}function lB({tex:e,display:t}){let n=(0,V.useMemo)(()=>jD.renderToString(e,{displayMode:t,throwOnError:!1,errorColor:`var(--danger)`}),[e,t]),r=(0,V.useRef)(null),[i,a]=(0,V.useState)(!1);return(0,V.useLayoutEffect)(()=>{let e=r.current;if(t||!e)return;let n=()=>{let t=e.firstElementChild,n=e.parentElement;for(;n&&n.clientWidth===0;)n=n.parentElement;t&&n&&a(t.getBoundingClientRect().width>n.clientWidth)};n();let i=e.closest(`.md-content`);if(!i||typeof ResizeObserver>`u`)return;let o=new ResizeObserver(n);return o.observe(i),()=>o.disconnect()},[n,t]),I(t?`div`:`span`,{ref:r,className:t?`md-math md-math-display`:i?`md-math md-math-wide`:`md-math`,dir:`ltr`,dangerouslySetInnerHTML:{__html:n}})}function uB({className:e,children:t,node:n,...r}){let i=(0,V.useContext)(nB),a=(0,V.useContext)(Xz),o=L();if(e?.includes(`math-inline`))return I(lB,{tex:String(t),display:!1});let s=sB(i,t);if(s)return I(rB,{doc:s,t:o});let c=Qz(t);if(c)return I($z,{path:c});let l=Zz(a,t);return l?I($z,{path:l,label:String(t).trim()}):I(`code`,{className:`inline-code`,dir:`ltr`,...r,children:t})}var dB={code:uB,pre({children:e}){let t=V.Children.toArray(e)[0];if(V.isValidElement(t)&&(t.type===`code`||t.props?.className!==void 0||typeof t.props?.children==`string`)){let e=t.props,n=e?.className||``,r=/language-([\w-]+)/.exec(n),i=String(e?.children||``).replace(/\n$/,``);if(n.includes(`math-display`))return I(lB,{tex:i,display:!0});let a=r?.[1]||``;return I(Kz,{lang:a,code:i})}return I(`pre`,{dir:`ltr`,children:e})},table({children:e}){return I(`div`,{className:`md-table-wrap`,children:I(`table`,{className:`md-table`,dir:`auto`,children:e})})},a({href:e,children:t}){return vy(e)?I(Ty,{href:e,children:t}):I(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`md-link`,children:t})},p({children:e}){return I(`p`,{className:`md-p`,dir:`auto`,children:I(cB,{children:e})})},h1({children:e}){return I(`h2`,{className:`md-h2`,dir:`auto`,children:I(cB,{children:e})})},h2({children:e}){return I(`h3`,{className:`md-h3`,dir:`auto`,children:I(cB,{children:e})})},h3({children:e}){return I(`h4`,{className:`md-h4`,dir:`auto`,children:I(cB,{children:e})})},h4({children:e}){return I(`h5`,{className:`md-h4`,dir:`auto`,children:I(cB,{children:e})})},ul({children:e}){return I(`ul`,{className:`md-ul`,dir:`auto`,children:e})},ol({children:e,start:t}){return I(`ol`,{className:`md-ol`,start:t,dir:`auto`,children:e})},li({children:e,className:t}){return I(`li`,{className:t?`md-li ${t}`:`md-li`,dir:`auto`,children:I(cB,{children:e})})},blockquote({children:e}){return I(`blockquote`,{className:`md-blockquote`,dir:`auto`,children:I(cB,{children:e})})},hr(){return I(`hr`,{className:`md-hr`})},td({children:e,className:t,style:n}){return I(`td`,{className:t,style:n,children:I(cB,{children:e})})},th({children:e,className:t,style:n}){return I(`th`,{className:t,style:n,children:I(cB,{children:e})})}},fB=[],pB=[LS,{singleDollarTextMath:!1}];function mB({content:e,showCursor:t,isStreaming:n=!1,writtenFiles:r=fB}){let i=z(e=>e.documents),a=(0,V.useMemo)(()=>ez(i),[i]),o=(0,V.useMemo)(()=>GD(e),[e]);return!e&&!t?null:!e&&t?I(`span`,{className:`cursor`}):I(Gz.Provider,{value:n,children:I(nB.Provider,{value:a,children:I(Xz.Provider,{value:r,children:R(`div`,{className:`md-content`,children:[I(ay,{remarkPlugins:[TS,pB,ZD,ID,RD],disallowedElements:[...uy],urlTransform:yy,components:dB,children:o}),t&&I(`span`,{className:`cursor`})]})})})})}var hB=()=>[...z.getState().messages].reverse().find(e=>e.role===`assistant`)?.id;function gB({busy:e}){let t=L(),[n,r]=(0,V.useState)({n:0,text:``}),i=(0,V.useRef)(hB());return(0,V.useEffect)(()=>{e&&(i.current=hB())},[e]),bf(e,()=>{let e=z.getState().messages,n=e[e.length-1];if(n?.role!==`assistant`||n.id===i.current||n.stopState===`stopped`&&!n.stopError)return;let a=n.failed===!0||vz(n.content);r(e=>({n:e.n+1,text:t(a?`live.replyFailed`:`live.replyReady`)}))}),I(`div`,{className:`turn-announcer`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:I(`span`,{children:n.text},n.n)})}function _B(e){return e.type===`status`&&e.status===`working`&&!e.phase&&(e.message??``).startsWith(`Model is processing`)}function vB(e){return e.phase===`loading_tools`?Qt()(`chat.loadingTools`):e.phase===`setup_wait`?Qt()(`chat.setupWait`):e.phase===`model_load_wait`?Qt()(`chat.modelLoadWait`):e.phase===`model_queue`&&e.queue?yB(e.queue):e.phase===`reasoning`&&typeof e.words==`number`?Qt().plural(`chat.reasoningWords`,e.words,{n:e.words.toLocaleString(`en-US`)}):(e.message||``).trim()}function yB(e){let t=Qt(),n=String(Math.floor(e.waited_s??0));if(e.event===`granted`)return t(`chat.modelQueue.granted`,{seconds:n});let r=e.queue_length??1;return r>1&&e.position!=null?t(`chat.modelQueue.waitingInLine`,{position:String(e.position),length:String(r),seconds:n}):!e.holder&&e.scope!==`process`?t(`chat.modelQueue.priority`,{seconds:n}):t(`chat.modelQueue.waiting`,{seconds:n})}function bB(e,t){let n=++t.current,r=Date.now();switch(e.type){case`thinking`:return{id:n,type:`thinking`,label:`Thinking`,detail:e.content,active:!0,timestamp:r};case`commentary`:return{id:n,type:`commentary`,label:`Commentary`,detail:e.content,active:!1,timestamp:r};case`tool_start`:return{id:n,type:`tool`,label:`Using tool`,tool:e.tool,detail:e.detail,narration:e.narration,active:!0,timestamp:r,mcpServer:e.mcp_server,mcpServerLabel:e.mcp_server_label,mcpTool:e.mcp_tool};case`skill_use`:return{id:n,type:`tool`,label:`Using tool`,tool:`use_skill`,detail:e.skill,narration:`Using skill: ${e.skill}`,active:!1,success:!0,timestamp:r};case`plan`:return{id:n,type:`plan`,label:`Created plan`,planSteps:e.steps,planNarrations:e.step_narrations,currentStep:e.current_step,active:!1,success:!0,timestamp:r};case`step`:return{id:n,type:`status`,label:`Step ${e.step}${e.total?` of ${e.total}`:``}`,active:!0,timestamp:r};case`status`:return e.message?.startsWith(`Agent: `)?null:{id:n,type:`status`,label:e.message||e.status||`Working`,active:e.status===`working`,...e.status===`warning`?{success:!1}:{},timestamp:r};case`agent_error`:return{id:n,type:`error`,label:`Error`,detail:e.content,success:!1,active:!1,timestamp:r};case`policy_alert`:{let t=e.tool||`unknown tool`,i=e.reason||e.message||e.content||`Tool execution was blocked by governance policy.`;return{id:n,type:`policy_alert`,label:`Policy blocked ${t}`,detail:i,tool:t,decision:e.decision||`BLOCK`,reason:i,ruleIds:e.rule_ids??[],policyVersion:e.policy_version,receiptId:e.receipt_id,success:!1,active:!1,timestamp:r}}default:return null}}function xB(e){let t=new Map,n;for(let r of e)if(r.role===`user`&&r.created_at)n=new Date(r.created_at).getTime();else if(r.role===`assistant`&&r.created_at&&n!==void 0){let e=new Date(r.created_at).getTime()-n-(r.stats?.waiting_seconds??0)*1e3;e>0&&t.set(r.id,e),n=void 0}return t}var SB=`speech_model_downloaded`,CB=new Set([`tool`,`waiting`]);function wB(e){return e.livePhase&&!CB.has(e.livePhase)?e.liveStatus:null}function TB(e,t){let n=z.getState(),r=e.status,i=vB(e);if(e.phase===`recording_found`&&e.section!=null){n.addRecordingSection({section:e.section,sections:e.sections??e.section,start:e.start??``,end:e.end??``,summary:e.summary??``,items:e.items??[]});return}if(e.phase===`recording`&&e.stage!=null){n.setRecordingStage(e.stage,{state:e.state??0,percent:e.percent,etaSeconds:e.eta_seconds});return}if(e.phase===SB&&i){let e={label:i,active:!1,success:!0,kept:!0},r=n.agentSteps[n.agentSteps.length-1];r&&r.type===`status`&&r.active?n.updateLastAgentStep({...e,detail:void 0}):n.addStepBeforeRunningCall({id:++t.current,type:`status`,timestamp:Date.now(),...e}),n.setLiveStatus(null);return}if(e.phase&&i&&n.setLiveStatus(i,e.phase),e.phase===`waiting`||_B(e)||i.toLowerCase().startsWith(`executing `)||r!==`working`&&r!==`warning`&&r!==`info`)return;let a=n.agentSteps[n.agentSteps.length-1];if(a&&a.type===`status`&&a.active&&r!==`warning`){n.updateLastAgentStep({label:i||`Working`,detail:i});return}if(a&&a.type===`thinking`&&a.active){n.updateLastAgentStep({label:i||`Thinking`});return}let o=bB({...e,message:i},t);o&&n.addAgentStep(o)}var EB=/\s*\{\s*"?(?:tool|thought|goal)"?\s*:\s*"[^"]*"[^}]*(?:"?tool_args"?\s*:\s*\{[^}]*\})?\s*\}/g;function DB(e){let t=e.trim();if(!t.startsWith(`{`)||!t.includes(`"thought"`)&&!t.includes(`"answer"`)&&!t.includes(`"goal"`))return e;try{let e=JSON.parse(t);if(e.answer!==void 0)return String(e.answer)}catch{}let n=t.indexOf(`"answer"`);if(n===-1)return``;let r=t.indexOf(`:`,n+8);if(r===-1)return``;let i=r+1;for(;i<t.length&&/\s/.test(t[i]);)i++;if(i>=t.length||t[i]!==`"`)return``;let a=t.slice(i+1);return a.endsWith(`"}`)?a=a.slice(0,-2):a.endsWith(`"`)&&(a=a.slice(0,-1)),a.replace(/\\"/g,`"`).replace(/\\n/g,`
191
+ `).replace(/\\\\/g,`\\`)}function OB(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 kB(e){let t=(e||[]).filter(e=>typeof e.render==`string`&&e.render.length>0).reduce((e,t)=>tt(e,{render:t.render,data:t.data}),[]);return t.length>0?t:void 0}function AB(e){return(e||[]).map(e=>{let t=e.agentSteps||e.agent_steps||void 0;return{...e,agentSteps:t,cards:e.cards||kB(t),stats:e.stats||e.inference_stats||void 0,turnSummary:e.turnSummary||e.turn_summary||void 0,libraryNotices:e.libraryNotices||e.library_notices||void 0,stopState:e.stopState??(e.stopped?`stopped`:void 0),agentProgram:e.agentProgram||e.agent_program||void 0}})}function jB(e,t,n){let r=e.find(e=>e.id===n.id&&e.role===`user`);if(r)return r;let i=t.findIndex(e=>e.id===n.id);if(i<0)throw Error(`Message ${n.id} is no longer in this chat.`);let a=new Set(e.map(e=>e.id)),o=i-1;for(;o>=0&&!a.has(t[o].id);)o--;let s=o<0?0:e.findIndex(e=>e.id===t[o].id)+1,c=e.slice(s).filter(e=>e.role===`user`),l=0;for(let e of t.slice(o+1,i))e.role===`user`&&c[l]?.content===e.content&&l++;return c[l]?.content===n.content?c[l]:null}function MB(e,t){return!!e&&e.role===`assistant`&&!!t.failureText&&e.content.trim()===t.failureText.trim()}function NB(e,t,n){let r=e.slice(e.findIndex(e=>e.id===t.id)+1);return r.length===0||r.length===1&&(r[0].id===n.id||MB(r[0],n))}function PB(e,t,n){let r=new Set(t.map(e=>e.id)),i=new Set(e.map(e=>e.id)),a=e.filter(e=>!r.has(e.id));for(let e of t){if(i.has(e.id)||n.has(e.id))continue;let t=a.findIndex(t=>t.role===e.role&&t.content.trim()===e.content.trim());if(t<0)continue;let[r]=a.splice(t,1);n.set(e.id,n.get(r.id)??r.id)}}function FB(e,t){let n=e[e.length-1],r=t[t.length-1];if(!n?.failed||!MB(r,n))return t;let i=e=>[...e].reverse().find(e=>e.role===`user`)?.content;return i(e)===i(t)?[...t.slice(0,-1),{...r,failed:!0,failureText:n.failureText}]:t}function IB(e){return`policy-receipt-${encodeURIComponent(e)}`}var LB=or((e,t)=>({lifecycle:null,restartError:null,apply:n=>{n.apiBase&&h(n.apiBase),e({lifecycle:n,restartError:n.status===`running`?null:t().restartError})},restart:async()=>{let n=window.gaiaAPI?.backend;if(!n)throw Error(`Restart GAIA needs the desktop app.`);e({restartError:null});try{t().apply(await n.restart())}catch(t){P.system.error(`Restart GAIA failed`,t),e({restartError:t instanceof Error?t.message:String(t)})}}}));function RB(){let e=window.gaiaAPI?.backend;e&&e.getState().then(e=>LB.getState().apply(e)).catch(e=>P.system.error(`Could not read the backend state from the desktop app`,e))}function zB(e){let t=window.gaiaAPI?.backend;if(!t)return()=>{};let n=t=>{let n=LB.getState().lifecycle?.status;LB.getState().apply(t),t.status===`running`&&n&&n!==`running`&&e()},r=t.onState(n);return t.getState().then(n).catch(e=>P.system.error(`Could not read the backend state from the desktop app`,e)),r}function BB(e){let t=e.content.trim();return!t||e.stopState||e.failed||e.failure||vz(t)||zL(t,1e3).length===0?!1:!bz(e.agentSteps??[],t).echoed}function VB(){(0,V.useEffect)(()=>{let e=!0,t=async()=>{try{let t=await ML();e&&t&&GL.getState().setSettings(t)}catch(e){P.ui.error(`Could not load the read-aloud settings; replies will not be read automatically`,e)}};return t(),window.addEventListener(`focus`,t),()=>{e=!1,window.removeEventListener(`focus`,t)}},[])}var HB=[`download`,`decode`,`transcribe`,`voices`,`prepare`,`analyze`],UB=0,WB=5;function GB(e,t){return e==null?``:e<60?t(`recording.leftUnderMinute`):t(`recording.leftMinutes`,{minutes:Math.ceil(e/60)})}function KB(e){return HB.map((e,t)=>t).filter(t=>t!==UB&&t!==WB||t in e)}function qB({state:e}){return e===1?I(ci,{size:14,"aria-hidden":`true`}):e===2?I(Eo,{size:14,"aria-hidden":`true`}):I(`span`,{className:`recording-progress-dot`,"aria-hidden":`true`})}function JB({index:e,stage:t}){let n=L(),r=n(`recording.stage.${HB[e]}`),i=t?.state===0,a=t?.percent,o=i?GB(t?.etaSeconds,n):``,s=t?.state===2?n(`recording.skipped`):o;return R(`li`,{className:`recording-progress-row${i?` is-running`:``}${t?``:` is-waiting`}${t?.state===1?` is-done`:``}`,children:[I(`span`,{className:`recording-progress-mark`,children:I(qB,{state:t?.state})}),I(`span`,{className:`recording-progress-label`,children:r}),i&&a!=null&&R(`bdi`,{className:`recording-progress-percent`,dir:`ltr`,children:[a,`%`]}),s&&I(`span`,{className:`recording-progress-left`,children:s}),i&&I(`div`,{className:`recording-progress-track${a==null?` is-indeterminate`:``}`,role:`progressbar`,"aria-label":r,"aria-valuemin":a==null?void 0:0,"aria-valuemax":a==null?void 0:100,"aria-valuenow":a??void 0,children:I(`div`,{className:`recording-progress-fill`,style:a==null?void 0:{inlineSize:`${a}%`}})})]})}var YB=120;function XB(e){let t=[];return Object.values(e).sort((e,t)=>e.section-t.section).map(e=>{let n=e.items.filter(e=>{let n=e.title.trim().toLowerCase(),r=t.some(t=>t.title===n&&Math.abs(t.seconds-e.seconds)<YB);return r||t.push({title:n,seconds:e.seconds}),!r});return{...e,items:n}})}function ZB({sections:e}){let t=L(),n=XB(e),r=n[0]?.sections??0;return R(`section`,{className:`recording-found`,"aria-label":t(`recording.found.title`),children:[R(`h4`,{className:`recording-found-title`,children:[t(`recording.found.title`),I(`span`,{className:`recording-found-count`,children:t(`recording.found.count`,{done:n.length,total:r})})]}),n.map(e=>R(`div`,{className:`recording-found-section`,children:[R(`p`,{className:`recording-found-span`,children:[R(`bdi`,{dir:`ltr`,className:`recording-found-time`,children:[e.start,`–`,e.end]}),e.summary&&I(`span`,{dir:`auto`,children:e.summary})]}),e.items.length>0&&I(`ul`,{className:`recording-found-items`,children:e.items.map(e=>R(`li`,{children:[I(`bdi`,{dir:`ltr`,className:`recording-found-time`,children:e.start}),I(`span`,{dir:`auto`,children:e.title})]},`${e.seconds}-${e.title}`))})]},e.section))]})}function QB(){let e=L(),t=z(e=>e.recordingStages),n=z(e=>e.recordingSections);return t?R(`section`,{className:`recording-progress`,"aria-label":e(`recording.title`),children:[I(`ol`,{className:`recording-progress-list`,children:KB(t).map(e=>I(JB,{index:e,stage:t[e]},e))}),n&&I(ZB,{sections:n})]}):null}function $B(e,t){let n=e.tool||``,r=e.tool_label||n,{addNotification:i,notifications:a}=fu.getState(),o=e.confirm_id?a.find(t=>t.id===e.confirm_id):void 0;if(o){!o.response&&o.dismissed&&fu.setState(e=>({notifications:e.notifications.map(e=>e.id===o.id?{...e,dismissed:!1}:e)}));return}let s=n===Yl,c=s&&lu(a,t,e.args);i({id:e.confirm_id??`perm-${Date.now()}`,type:`permission_request`,agentId:t,sessionId:t,agentName:`GAIA`,title:s?Ql(e.args,c):n===`trust_project_folder`?`Trust this folder's instructions and skills?`:`Allow ${r}?`,message:s?Zl(e.args,c):n===`trust_project_folder`?`GAIA would put this folder's CLAUDE.md, AGENTS.md and skills in the model's prompt, now and every time you work in it.`:`GAIA needs your OK before ${r}.`,timestamp:Date.now(),read:!1,dismissed:!1,priority:`high`,tool:n,toolArgs:e.args,confirmId:e.confirm_id,alwaysScope:typeof e.always_scope==`string`?e.always_scope:void 0,alwaysLabel:typeof e.always_label==`string`&&e.always_label?e.always_label:void 0,toolLabel:e.tool_label||void 0,risk:typeof e.risk==`string`?e.risk:void 0,summary:typeof e.summary==`string`&&e.summary?e.summary:void 0,pathFollowUp:c||void 0,timeoutSeconds:e.timeout_seconds,expiresAt:typeof e.expires_at==`number`?e.expires_at*1e3:void 0})}function eV(e,t,n){let r=e.tool||`unknown tool`,i=e.reason||e.message||e.content||`Tool execution was blocked by governance policy.`;return{id:e.receipt_id??n,type:`policy_alert`,agentId:t,agentName:`GAIA`,title:`Blocked: ${r} is restricted by policy.`,message:i,timestamp:Date.now(),read:!1,dismissed:!1,priority:`critical`,tool:r,decision:e.decision||`BLOCK`,reason:i,ruleIds:e.rule_ids??[],policyVersion:e.policy_version,receiptId:e.receipt_id}}function tV(e){let t=e.data&&typeof e.data==`object`?e.data:{};return(e.status??t.status)===`denied`?e.timed_out===!0||t.timed_out===!0?`timedOut`:(e.denied_by??t.denied_by)===`policy`?`refused`:(e.declined_by??t.declined_by)===`agent`?`autoDeclined`:`declined`:null}function nV(e){let t={result:e.summary||e.title||`Done`,active:!1,success:e.success!==!1,latencyMs:e.latency_ms},n=tV(e);n&&(t[n]=!0),e.command_output&&(t.commandOutput={command:e.command_output.command,stdout:e.command_output.stdout,stderr:e.command_output.stderr,returnCode:e.command_output.return_code,expectedExit:e.command_output.expected_exit,cwd:e.command_output.cwd,durationSeconds:e.command_output.duration_seconds,truncated:e.command_output.truncated}),e.mcp_output?.text&&(t.mcpOutput=e.mcp_output),e.result_data?.chunks&&e.result_data.chunks.length>0&&(t.retrievalChunks=e.result_data.chunks.map(e=>({id:e.id,source:e.source,sourcePath:e.sourcePath,page:e.page,score:e.score,preview:e.preview,content:e.content}))),e.result_data?.type===`file_list`&&e.result_data.files?.length>0&&(t.fileList={files:e.result_data.files,total:e.result_data.total??e.result_data.files.length});let r=e.data&&typeof e.data==`object`?e.data.needs_model:void 0;return(e.needs_model??r)===`vision`&&(t.needsModel=`vision`),t}var rV=5e3,iV=2e3,aV=3e4,oV=6e4;function sV(e){return e?.init_state===`initializing`?!e.init_tasks||e.init_tasks.some(e=>e.status===`pending`||e.status===`running`):!1}function cV(e){return e.lemonade_running?`up`:e.lemonade_error?`unresponsive`:`down`}function lV(e){return e.kind===`slow`||e.kind===`error`||e.kind===`ok`&&cV(e.status)===`unresponsive`}function uV(e){let t=e.kind===`ok`?e.status.download_progress?.state:void 0;return t===`downloading`||t===`starting`}function dV(e){let t=null,n=0,r=!1,i=null,a=null,o=!1,s=!1,c=()=>{o||!s||a||(a=setTimeout(()=>{a=null,f()},p()))},l=0,u=null,d=async()=>{let e={controller:new AbortController,cancelled:!1};u=e;let{controller:t}=e,n=setTimeout(()=>t.abort(),oV);try{return{kind:`ok`,status:await Pt(t.signal)}}catch(n){if(e.cancelled)return null;if(t.signal.aborted)return{kind:`slow`};let r=n?.httpStatus;return r===504?{kind:`slow`}:n?.name===`ApiError`&&typeof r==`number`&&r!==502?{kind:`error`,httpStatus:r,message:n.message}:{kind:`unreachable`,error:n}}finally{clearTimeout(n),u===e&&(u=null)}},f=()=>{if(t)return t;let i=d().then(t=>{if(t!==null){n=lV(t)?n+1:0,r=uV(t),t.kind===`ok`?s=sV(t.status):t.kind===`unreachable`&&(s=!1),c();try{e(t)}catch(e){P.system.error(`Could not apply the system status; the next poll will try again`,e)}}}).finally(()=>{t===i&&(t=null)});return t=i,i},p=()=>Math.min((r?iV:rV)*2**n,aV),m=e=>{f().finally(()=>{e===l&&(i=setTimeout(()=>m(e),p()))})};return{check:f,start:()=>{let e=++l;return o=!0,a&&clearTimeout(a),a=null,m(e),()=>{e===l&&(l++,o=!1,c(),i&&clearTimeout(i),i=null,u&&(u.cancelled=!0,u.controller.abort(),u=null,t=null))}}}}var fV=1e3,pV=15e3,mV=null,hV=null,gV=fV,_V=0,vV=null;function yV(){if(mV)return mV;let e=Date.now();return mV=_n().then(t=>z.getState().setActiveRuns(t,e)).catch(e=>{P.api.warn(`Could not read which chats are running`,e),zF(e)&&z.getState().loseActiveRuns()}).finally(()=>{mV=null}),mV}function bV(){let e=z.getState();return e.isStreaming||e.runningSessionIds.length>0}function xV(){return bV()?(gV=fV,fV):(gV=Math.min(gV*2,pV),gV)}function SV(e){yV().then(()=>{e===_V&&(hV=setTimeout(()=>SV(e),xV()))})}function CV(){vV&&(hV&&clearTimeout(hV),hV=null,gV=fV,SV(++_V))}function wV(){vV?.();let e=z.subscribe((e,t)=>{e.isStreaming&&!t.isStreaming&&CV()}),t=()=>CV();window.addEventListener(`focus`,t);let n=()=>{_V++,hV&&clearTimeout(hV),hV=null,e(),window.removeEventListener(`focus`,t),vV===n&&(vV=null)};return vV=n,gV=fV,SV(++_V),n}var TV=3e3,EV=new Set,DV=new Map,OV=new Set,kV=null;function AV(e,t=Date.now()){DV.set(e,t)}function jV(e){let t=z.getState();return t.activeRunsAt>0&&t.activeRunsAt>=(DV.get(e)??0)&&!t.runningSessionIds.includes(e)&&!t.queuedSessionIds.includes(e)}function MV(e){return OV.add(e),()=>{OV.delete(e),kV?.()}}function NV(e){return e instanceof Error?eR(e)??(e.message||`Unknown error`):String(e)}function PV(e){let t=e?.httpStatus;return typeof t==`number`?t:void 0}function FV(e){let t=PV(e);return t===409||t===429}function IV(e){P.chat.warn(`Chat ${e} no longer exists; dropping its queued messages`),z.getState().updateQueue(e,()=>[])}function LV(e){z.getState().setQueueHold(e,!0),setTimeout(()=>z.getState().setQueueHold(e,!1),TV)}function RV(e,t,n){return PV(n)===409&&(P.chat.info(`Chat ${e} was busy; queueing the message to try again`),z.getState().updateQueue(e,e=>ar(e,t,`queued`)),LV(e),!0)}async function zV(e,t,n){let r=z.getState;if(EV.has(e)||r().queueHolds[e])return;let i=r().messageQueues[e]??[];if(i.some(e=>e.state===`sending`))return;let a=y(i);if(a||we(i)){EV.add(e);try{if(a){let t;try{t=await ht(e)}catch(t){if(PV(t)===409){P.chat.info(`Chat ${e} is answering again; its queue waits for that turn to end`);return}if(PV(t)===404){IV(e);return}P.chat.error(`Could not learn what chat ${e}'s last reply did with the messages added to it`,t),r().updateQueue(e,e=>Be(e,`GAIA could not say whether it read this message: ${NV(t)}`));return}r().updateQueue(e,e=>rn(e,t))}let i=we(r().messageQueues[e]??[]);if(!i||!n())return;r().updateQueue(e,e=>s(e,i.id,`queued`,`starting`));let o;try{o=await t(e,i.text)}catch(e){o={kind:`failed`,error:NV(e)}}if(o.kind===`accepted`){AV(e),r().updateQueue(e,e=>ve(e,i.id)),CV();return}if(o.kind===`busy`){P.chat.info(`Queued message found chat ${e} busy; holding it`),r().updateQueue(e,e=>on(e,i.id)),LV(e);return}if(o.kind===`gone`){IV(e);return}P.chat.error(`Queued message for chat ${e} was not sent: ${typeof o.error==`string`?o.error:o.error.key}`),r().updateQueue(e,e=>on(e,i.id,o.error))}finally{EV.delete(e)}}}function BV(e){return e.type!==`status`||e.phase!==`waiting`}var VV=(e,t)=>new Promise(n=>{let r=!1,i=null,a=!1,o=e=>{r||(r=!0,e.kind===`accepted`&&(i?i.abort():a=!0),n(e))},s=()=>o({kind:`accepted`});P.chat.info(`Sending queued message for chat ${e} in the background`),i=O(e,t,{onChunk:s,onAgentEvent:e=>{BV(e)&&s()},onDone:s,onError:e=>{ZL(e)?s():FV(e)?o({kind:`busy`}):PV(e)===404?o({kind:`gone`}):o({kind:`failed`,error:NV(e)})}}),a&&i.abort()});function HV(e=VV){let t=()=>{let t=z.getState();if(!sV(t.systemStatus))for(let n of Object.keys(t.messageQueues))!OV.has(n)&&jV(n)&&zV(n,e,()=>!OV.has(n))},n=z.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 kV=t,t(),()=>{n(),kV===t&&(kV=null)}}var UV=new Set([`.3g2`,`.3gp`,`.asf`,`.avi`,`.divx`,`.f4v`,`.flv`,`.m2ts`,`.m2v`,`.m4v`,`.mkv`,`.mov`,`.mp4`,`.mpeg`,`.mpg`,`.mts`,`.mxf`,`.ogv`,`.rm`,`.rmvb`,`.vob`,`.webm`,`.wmv`]),WV=new Set([`.aac`,`.ac3`,`.aif`,`.aiff`,`.amr`,`.ape`,`.au`,`.caf`,`.dts`,`.eac3`,`.flac`,`.m4a`,`.m4b`,`.mka`,`.mp2`,`.mp3`,`.oga`,`.ogg`,`.opus`,`.spx`,`.wav`,`.wma`,`.wv`]);function GV(e){let t=e.lastIndexOf(`.`);return t<0?``:e.slice(t).toLowerCase()}function KV(e){return UV.has(GV(e))}function qV(e){let t=GV(e);return UV.has(t)||WV.has(t)}function JV(e,t){return e===`model_server_down`?t(`docs.serverDown`):e===`model_server_busy`?t(`docs.serverBusy`):null}function YV(e){return e===`model_server_down`}function XV(e){return e===`model_server_busy`}function ZV(e,t,n){return e===`model_server_down`?n(`docs.notAddedServer`,{name:t}):e===`model_server_busy`?n(`docs.notAddedServerBusy`,{name:t}):null}var QV=`https://github.com/amd/gaia/issues/new`,$V=[{label:`Image`,titleKey:`docs.uploadError.image`,messageKey:`docs.uploadError.imageDetail`,extensions:new Set([`.ico`,`.heic`,`.heif`]),message:`This image format cannot be indexed.`,alternatives:[`Convert it to PNG or JPEG — GAIA reads the text in those images`],featureTitle:`Support HEIC and ICO image indexing`},{label:`Video`,titleKey:`docs.uploadError.video`,messageKey:`docs.uploadError.videoDetail`,extensions:UV,message:`Video files can't go in the document library.`,alternatives:[`Attach the video to a chat, and GAIA will transcribe it`],featureTitle:`Support video files in the document library`},{label:`Audio`,titleKey:`docs.uploadError.audio`,messageKey:`docs.uploadError.audioDetail`,extensions:WV,message:`Audio files can't go in the document library.`,alternatives:[`Attach the recording to a chat, and GAIA will transcribe it`],featureTitle:`Support audio files in the document library`},{label:`Archive`,titleKey:`docs.uploadError.archive`,messageKey:`docs.uploadError.archiveDetail`,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`,titleKey:`docs.uploadError.executable`,messageKey:`docs.uploadError.executableDetail`,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`,titleKey:`docs.uploadError.database`,messageKey:`docs.uploadError.databaseDetail`,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`,titleKey:`docs.uploadError.office`,messageKey:`docs.uploadError.officeDetail`,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 eH(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;for(let e of $V)if(e.extensions.has(t))return e;return null}var tH=new Set(`.pdf,.pptx,.docx,.epub,.png,.jpg,.jpeg,.webp,.bmp,.gif,.tif,.tiff,.txt,.md,.mdx,.markdown,.rst,.csv,.json,.xlsx,.html,.htm,.xml,.svg,.yaml,.yml,.py,.js,.ts,.java,.c,.cpp,.h,.rs,.go,.rb,.sh,.bat,.ps1,.log,.cfg,.ini,.toml`.split(`,`));function nH(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;return tH.has(t)}function rH(){let e=navigator.userAgent;return`**Environment:**\n- GAIA Version: 0.27.1rc1\n- Platform: ${navigator.platform||`unknown`}\n- User Agent: ${e}\n- Interface: Agent UI (Web)`}function iH(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?_`,``,`---`,rH(),``,`_Submitted from GAIA Agent UI_`].join(`
192
+ `);return`${QV}?${new URLSearchParams({title:`[Feature] ${e}`,body:n,labels:`enhancement,agent-ui`}).toString()}`}function aH(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?_`,``,`---`,rH(),``,`_Submitted from GAIA Agent UI_`].join(`
193
+ `);return`${QV}?${new URLSearchParams({title:`[Bug] ${e}`,body:n,labels:`bug,agent-ui`}).toString()}`}var oH={corrupted:`docs.failureHint.corrupted`,encrypted:`docs.failureHint.encrypted`,empty:`docs.failureHint.empty`,empty_file:`docs.failureHint.emptyFile`,unsupported_workbook:`docs.failureHint.unsupportedWorkbook`};function sH({filename:e,error:t,status:n,kind:r,onDismiss:i,timeout:a=0}){let o=L(),s=(0,V.useRef)(null);(0,V.useEffect)(()=>(a>0&&(s.current=setTimeout(i,a)),()=>{s.current&&clearTimeout(s.current)}),[i,a]);let c=e.includes(`.`)?`.`+e.split(`.`).pop()?.toLowerCase():``,l=c?eH(c):null,u=t.toLowerCase().includes(`unsupported file type`)||t.toLowerCase().includes(`not supported for indexing`)||t.toLowerCase().includes(`file type not allowed`)||l!==null,d=t.toLowerCase().includes(`fetch`)||t.toLowerCase().includes(`network`)||t.toLowerCase().includes(`connect`),f,p,m,h=wi,g=r?oH[r]:void 0;return g?(f=o(`docs.cantBeRead`,{name:e}),p=o(g),m=null,h=cc):JV(r,o)?(f=ZV(r,e,o)??o(`docs.notAddedServer`,{name:e}),p=JV(r,o)??t,m=null,h=cc):r===`too_large`?(f=o(`docs.tooLarge`,{name:e}),p=t,m=null,h=cc):n===404?(f=o(`docs.notFound`,{name:e}),p=o(`docs.notFoundDetail`),m=null,h=cc):n===403?(f=o(`docs.uploadError.forbidden`),p=`${t} ${o(`docs.uploadError.forbiddenDrop`)}`,m=null,h=cc):u&&l?(f=o(l.titleKey),p=o(l.messageKey),m=iH(l.featureTitle),h=cc):u&&!c?(f=o(`docs.uploadError.noExtension`,{name:e}),p=o(`docs.uploadError.noExtensionDetail`),m=null,h=cc):u?(f=o(`docs.uploadError.unsupportedType`,{ext:c}),p=o(`docs.uploadError.unsupportedTypeDetail`),m=iH(`Support ${c} file indexing`),h=cc):d?(f=o(`docs.uploadError.connection`),p=o(`docs.uploadError.connectionDetail`),m=aH(`Upload connection error for ${e}`),h=wi):(f=o(`docs.uploadError.failed`,{name:e}),p=t||o(`docs.uploadError.failedDetail`),m=aH(`Indexing error: ${t.slice(0,80)}`),h=Qr),R(`div`,{className:`upload-error-toast`,role:`alert`,children:[I(h,{size:16}),R(`div`,{className:`upload-error-content`,children:[I(`div`,{className:`upload-error-title`,children:f}),R(`div`,{className:`upload-error-detail`,children:[p,m&&` `,m===null?null:u?I(`a`,{href:m,target:`_blank`,rel:`noopener noreferrer`,children:o(`docs.uploadError.requestFeature`)}):I(`a`,{href:m,target:`_blank`,rel:`noopener noreferrer`,children:o(`docs.uploadError.reportIssue`)})]})]}),I(`button`,{className:`upload-error-dismiss`,onClick:i,"aria-label":o(`docs.dismissError`),children:I(bc,{size:14})})]})}function cH(e,t,n=[],r=[],i={}){let a=lH(t,r,i);if(n.length>0)return n.some(a);let o=cj(e);return o===`google`?a(`google`):o===`microsoft`?a(`microsoft`):a(`google`)||a(`microsoft`)}function lH(e,t,n){return r=>FA(e.find(e=>e.id===r),t.find(e=>e.id===r),n[r])}function uH(e,t,n=[],r=[],i={}){let a=lH(t,r,i),o=n.find(a);if(o){let e=t.find(e=>e.id===o&&!(`error`in e));return e&&!(`error`in e)?e.display_name:o}let s=cj(e);return s===`google`?`Google`:s===`microsoft`?`Microsoft`:a(`google`)?`Google`:a(`microsoft`)?`Microsoft`:`Google`}function dH({content:e,providers:t=[],accounts:n,onRetry:r}){let i=L(),[a,o]=(0,V.useState)([]),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1),d=(0,V.useCallback)(()=>{f().then(e=>{let t=e.connectors||[];o(t),c(e=>e??t)}).catch(e=>P.ui.warn(`ConnectorRetryBanner: connector fetch failed`,e))},[]),p=s!==null&&cH(e,a,t,s,n);if((0,V.useEffect)(()=>{d();let e=()=>d();return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[d]),cM(!p,d),!p||l)return null;let m=uH(e,a,t,s??[],n);return R(`div`,{className:`connector-retry-banner`,role:`status`,children:[I(Si,{size:14,className:`connector-retry-banner__icon`}),I(`span`,{className:`connector-retry-banner__text`,children:i(`retryBanner.connected`,{name:m})}),R(`button`,{type:`button`,className:`connector-retry-banner__btn`,onClick:()=>{u(!0),r()},children:[I(fs,{size:12}),I(`span`,{children:i(`retryBanner.askAgain`)})]}),I(`button`,{type:`button`,className:`connector-retry-banner__dismiss`,onClick:()=>u(!0),"aria-label":i(`retryBanner.dismiss`),children:`×`})]})}var fH=0,pH=or(e=>({current:null,refresh:async()=>{let t=++fH;try{let n=await ke();t===fH&&e({current:n.current})}catch(n){P.api.warn(`Could not read which agent is in use`,n),t===fH&&e({current:null})}},setCurrent:t=>{fH++,e({current:t})}}));function mH(){let e=L(),t=pH(e=>e.current),n=pH(e=>e.refresh),r=z(e=>e.settingsSection!==null),i=z(e=>e.openSettings);return(0,V.useEffect)(()=>{r||n()},[r,n]),t===`gaiacpp`?R(`button`,{type:`button`,className:`composer-chip composer-chip-agent`,onClick:()=>i(`model`),title:e(`composer.agentFastTitle`),children:[I(ca,{size:13,"aria-hidden":`true`}),I(`span`,{className:`composer-chip-label`,dir:`auto`,children:e(`composer.agentFast`)})]}):null}function hH(e,t=32){let n=Array.from(e);if(n.length<=t)return e;let r=Array.from(/\.[^.\s]{1,8}$/.exec(e)?.[0]??``).length,i=Math.min(Math.max(Math.ceil(t*.45),r+4),t-2);return`${n.slice(0,t-i-1).join(``)}…${n.slice(-i).join(``)}`}function gH(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 _H(e){return e.replace(/-/g,``).slice(0,7)}function vH(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 yH(e,t){return e.key===`ArrowUp`&&!e.shiftKey&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.nativeEvent?.isComposing&&t===``}function bH(e){for(let t=e.length-1;t>=0;t--)if(e[t].role===`user`)return e[t]}function xH(e,t){for(let n=t+1;n<e.length;n++)if(e[n].role===`user`)return e.length-n;return 0}var SH=/^\/[a-z0-9-]*$/i;function CH(e){let t=SH.test(e),[n,r]=(0,V.useState)([]),[i,a]=(0,V.useState)(`loading`),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(0),[u,d]=(0,V.useState)(null);(0,V.useEffect)(()=>{if(!t)return;let e=!0;return a(e=>e===`ready`?e:`loading`),jn().then(t=>{T(t.skills.map(e=>e.name)),e&&(r(t.skills),a(`ready`),s(null))},t=>{e&&(a(`error`),s(t instanceof Error?t.message:String(t)))}),()=>{e=!1}},[t]),(0,V.useEffect)(()=>{l(0)},[e]);let f=e.toLowerCase(),p=t?n.filter(e=>!e.always_on&&`/${e.name}`.startsWith(f)):[],m=t&&u!==e&&(i!==`ready`||p.length>0),h=(0,V.useCallback)(e=>l(e),[]),g=(0,V.useCallback)(()=>d(e),[e]);return{open:m,status:i,error:o,matches:p,selected:Math.min(c,Math.max(p.length-1,0)),select:h,dismiss:g}}var wH=`composer-skill-menu`;function TH(e){return`${wH}-${e}`}function EH(e){let t=e.replace(/\s+/g,` `).trim(),n=t.indexOf(`. `);return n>=0?t.slice(0,n+1):t}var DH=320,OH=6,kH=8;function AH(e,t,n){let r=Math.max(0,e.top-OH-kH),i=Math.max(0,t-e.bottom-OH-kH),a=r<Math.min(DH,n)&&i>r;return{below:a,maxHeight:Math.floor(Math.min(DH,a?i:r))}}function jH({menu:e,onPick:t}){let n=L(),r=(0,V.useRef)(null),[i,a]=(0,V.useState)(null),o=e.open&&e.status===`ready`?e.matches.length:-1;if((0,V.useLayoutEffect)(()=>{let e=r.current,t=e?.parentElement;if(!e||!t){a(null);return}let n=()=>{let n=AH(t.getBoundingClientRect(),window.innerHeight,e.scrollHeight);a(e=>e&&e.below===n.below&&e.maxHeight===n.maxHeight?e:n)};n(),window.addEventListener(`resize`,n);let i=typeof ResizeObserver>`u`?null:new ResizeObserver(n);return i?.observe(t),()=>{window.removeEventListener(`resize`,n),i?.disconnect()}},[e.open,e.status,o]),(0,V.useLayoutEffect)(()=>{o>0&&document.getElementById(TH(e.selected))?.scrollIntoView?.({block:`nearest`})},[e.selected,o,i]),!e.open)return null;let s=`skill-menu${i?.below?` is-below`:``}`,c=i?{maxHeight:i.maxHeight}:void 0;return e.status===`ready`?R(`div`,{ref:r,className:s,style:c,children:[I(`p`,{className:`skill-menu-title`,children:n(`composer.skillsTitle`)}),I(`ul`,{id:wH,role:`listbox`,"aria-label":n(`composer.skillsTitle`),children:e.matches.map((n,r)=>R(`li`,{id:TH(r),role:`option`,"aria-selected":r===e.selected,className:`skill-menu-row${r===e.selected?` is-selected`:``}`,onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>e.select(r),onClick:()=>t(n.name),children:[R(`span`,{className:`skill-menu-name`,dir:`ltr`,children:[`/`,n.name]}),I(`span`,{className:`skill-menu-desc`,dir:`auto`,children:EH(n.description)})]},n.name))})]}):I(`div`,{ref:r,className:s,style:c,role:e.status===`error`?`alert`:`status`,children:I(`p`,{className:`skill-menu-note`,children:e.status===`error`?n(`composer.skillsFailed`,{error:e.error??``}):n(`composer.skillsLoading`)})})}function MH(e){return e.isMedia?KV(e.name)?va:ma:Sa}var NH=240,PH=1e5;function FH({value:e,onChange:t,onSubmit:n,onStop:r,streaming:i=!1,stopping:a=!1,queueWhileStreaming:o=!1,answering:s=!1,disabledReason:c,attachments:l,placeholder:u,autoFocus:d,inputRef:f,leftControls:p,rightControls:m,onEditLast:h}){let g=L(),_=(0,V.useRef)(null),v=f??_,y=(0,V.useRef)(null),b=!!c,x=e.trim().length>0||l.hasUploaded,S=l.compose(e.trim()).length,C=S>PH,w=bR(i),T=l.attachments.filter(e=>e.error).map(e=>e.name).join(`, `),E=!b&&(!i||o)&&!l.uploading&&x&&!C&&!T&&!w,ee=c||u||g(`composer.placeholder`),D=CH(b?``:e),O=(0,V.useCallback)(e=>{t(`/${e} `),v.current?.focus()},[t,v]);(0,V.useLayoutEffect)(()=>{let e=v.current;if(!e)return;let t=()=>{e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,NH)}px`};if(t(),typeof ResizeObserver>`u`)return;let n=e.clientWidth,r=new ResizeObserver(()=>{e.clientWidth!==n&&(n=e.clientWidth,t())});return r.observe(e),()=>r.disconnect()},[e,ee,v]);let te=(0,V.useCallback)(t=>{if(D.open&&!t.nativeEvent.isComposing){let{matches:n,selected:r}=D;if(t.key===`Escape`){t.preventDefault(),D.dismiss();return}if(n.length>0&&(t.key===`ArrowDown`||t.key===`ArrowUp`)){t.preventDefault();let e=t.key===`ArrowDown`?1:-1;D.select((r+e+n.length)%n.length);return}let i=n[r]?.name,a=i!==void 0&&e.toLowerCase()===`/${i}`;if(i&&(t.key===`Tab`||t.key===`Enter`&&!t.shiftKey&&!a)){t.preventDefault(),O(i);return}}h&&yH(t,e)?(t.preventDefault(),h()):t.key===`Enter`&&!t.shiftKey&&!t.nativeEvent.isComposing&&(t.preventDefault(),E&&n())},[E,n,h,e,D,O]),k=(0,V.useCallback)(e=>{e.dataTransfer?.files?.length&&(e.preventDefault(),e.stopPropagation(),l.addFiles(Array.from(e.dataTransfer.files)))},[l]);return R(`div`,{className:`composer${b?` composer-disabled`:``}`,onDrop:k,onDragOver:e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault()},children:[I(yR,{}),l.attachments.length>0&&I(`ul`,{className:`composer-attachments`,"aria-label":g(`composer.attached`),children:l.attachments.map(e=>{let t=MH(e);return R(`li`,{title:e.isImage&&e.url?e.name:void 0,className:`composer-attachment${e.error?` has-error`:``}${e.isMedia?` is-media`:``}${e.isImage&&e.url?` is-image`:``}`,children:[e.isImage&&e.url?I(`img`,{src:e.url,alt:``,className:`composer-attachment-thumb`}):I(t,{size:14,"aria-hidden":`true`}),I(`span`,{className:`composer-attachment-name`,title:e.name,dir:`ltr`,children:hH(e.name)}),e.uploading&&I(`span`,{className:`composer-attachment-state`,children:e.progress===void 0?g(`composer.uploading`):g(`composer.uploadingPercent`,{percent:e.progress})}),e.uploaded&&e.isMedia&&I(`span`,{className:`composer-attachment-state`,children:g(`composer.mediaReady`)}),e.error&&I(`span`,{className:`composer-attachment-state`,role:`alert`,title:e.error,children:e.error}),I(`button`,{type:`button`,className:`composer-icon-btn`,onClick:()=>l.remove(e.id),"aria-label":g(`composer.remove`,{name:e.name}),children:I(bc,{size:12})})]},e.id)})}),I(jH,{menu:D,onPick:O}),I(`textarea`,{ref:v,className:`composer-input`,value:e,onChange:e=>t(e.target.value),onKeyDown:te,onPaste:e=>{l.handlePaste(e)},placeholder:ee,rows:1,disabled:b,autoFocus:d,"aria-label":g(`composer.message`),"aria-autocomplete":`list`,"aria-expanded":D.open&&D.matches.length>0,"aria-controls":D.open&&D.matches.length>0?wH:void 0,"aria-activedescendant":D.open&&D.matches.length>0?TH(D.selected):void 0,dir:e?`auto`:void 0}),C&&R(`p`,{className:`composer-limit-error`,role:`alert`,children:[g(`composer.tooLong`,{sent:S.toLocaleString(),max:1e5.toLocaleString()}),` `,g(`composer.tooLongHint`)]}),T&&x&&I(`p`,{className:`composer-limit-error`,role:`alert`,children:g(`composer.removeRefused`,{names:T})}),R(`div`,{className:`composer-row`,children:[R(`div`,{className:`composer-row-left`,children:[I(`button`,{type:`button`,className:`composer-icon-btn`,onClick:()=>y.current?.click(),disabled:b,"aria-label":g(`composer.attach`),title:g(`composer.attach`),children:I(os,{size:16})}),I(`input`,{ref:y,type:`file`,multiple:!0,hidden:!0,onChange:e=>{e.target.files&&l.addFiles(Array.from(e.target.files)),e.target.value=``}}),p]}),R(`div`,{className:`composer-row-right`,children:[m,i&&o&&x&&I(`button`,{type:`button`,className:`composer-send`,onClick:n,disabled:!E,"aria-label":g(s?`composer.sendAnswer`:`composer.queue`),title:s?g(`composer.sendAnswerTitle`):w??g(`composer.queueTitle`),children:I(Br,{size:16})}),i?I(`button`,{type:`button`,className:`composer-send is-stop`,onClick:r,disabled:a,"aria-label":g(`composer.stop`),title:a?g(`composer.stopping`):g.hint(g(`composer.stop`),`Esc`),children:I(ec,{size:12,fill:`currentColor`})}):I(`button`,{type:`button`,className:`composer-send`,onClick:n,disabled:!E,"aria-label":g(`composer.send`),title:w??g.hint(g(`composer.send`),`Enter`),children:I(Br,{size:16})})]})]})]})}var IH=8,LH=8;function RH({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+IH+t.width<=r-LH?(a=n.right+IH,o=e.top+e.height/2-t.height/2):n.left-IH-t.width>=LH?(a=n.left-IH-t.width,o=e.top+e.height/2-t.height/2):(a=Math.min(Math.max(LH,e.right-t.width),r-LH-t.width),o=e.top-IH-t.height>=LH?e.top-IH-t.height:e.bottom+IH),o=Math.min(Math.max(LH,o),i-LH-t.height),h({left:a,top:o})},[p]),(0,V.useEffect)(()=>{if(!p)return;let e=()=>{f(!1),a?.()};return window.addEventListener(`scroll`,e,!0),()=>window.removeEventListener(`scroll`,e,!0)},[p,a]),R(F.Fragment,{children:[I(`button`,{ref:l,type:`button`,className:`info-bubble-icon${t?` is-warning`:``}`,"aria-label":e,tabIndex:o,"aria-describedby":p?c:void 0,onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),onFocus:()=>f(!0),onBlur:()=>f(!1),onClick:e=>{e.stopPropagation(),f(e=>!e)},onKeyDown:e=>{e.key===`Escape`&&p&&(e.stopPropagation(),f(!1))},children:I(Ja,{size:13,"aria-hidden":`true`})}),p&&(0,by.createPortal)(I(`div`,{ref:u,id:c,role:`tooltip`,className:`info-bubble`,style:m?{left:m.left,top:m.top}:{left:0,top:0,visibility:`hidden`},children:n}),document.body)]})}function zH({support:e}){let t=L();return e===`verified`?I(`span`,{className:`mc-chip is-verified`,children:t(`setup.label.verified`)}):e===`untested`?I(`span`,{className:`mc-chip is-untested`,children:t(`setup.label.untested`)}):null}function BH(e){return e<.1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function VH(e,t=gt){return e?t(`settings.price.perMillion`,{input:BH(e.input_per_million),output:BH(e.output_per_million)}):t(`settings.price.unknown`)}function HH(e){return`$${e.toFixed(2)}`}function UH(e,t,n,r=!1){return!j(t)||gt(t)!==n?n:r?e.bare(t):e(t)}function WH(e,t){return UH(e,`providers.${t.id}.name`,t.name,!0)}function GH(e,t){return UH(e,`providers.${t.id}.notice`,t.privacy_notice)}var KH=2e3,qH=`waiting_for_os_permission`,JH=`store_locked`,YH=5;function XH(e,t,n){let r=e.note?yl[e.note]:void 0,i=e.rank?{key:`rank`,content:R(F.Fragment,{children:[R(`bdi`,{dir:`ltr`,children:[`#`,e.rank]}),e.note?R(F.Fragment,{children:[` `,r?n(r):I(`bdi`,{children:e.note})]}):null]})}:null;if(t){let t=VH(e.price,n);return[i,t?{key:`price`,content:t}:null].filter(e=>e!==null)}let a=bl(e.placement,n);return[a?{key:`placement`,content:a}:null,e.size_gb?{key:`size`,content:R(`bdi`,{dir:`ltr`,children:[e.size_gb,` GB`]})}:null,e.tokens_per_second?{key:`speed`,content:I(kl,{text:n(`settings.model.speed`,{speed:El(`${Math.round(e.tokens_per_second)} tok/s`)})})}:null,i,e.custom?{key:`custom`,content:n(`settings.model.custom`)}:null].filter(e=>e!==null)}function ZH(e,t){return!sl(t,e.id)&&(Tl(e)||Cl(e)===`not_downloaded`)}function QH(e,t,n){let r=e=>e.provider.id===t?0:1,i=e=>ZH(e,n)?e.support===`verified`?1:2:0;return[...e].sort((e,t)=>r(e)-r(t)).map(e=>e.provider.remote?e:{...e,models:[...e.models].sort((e,t)=>i(e)-i(t))})}function $H({m:e,onDownload:t,busy:n}){let r=L();if(Tl(e)){let t=Math.round(e.download_progress?.percent??0);return R(`span`,{className:`model-state is-downloading`,title:r(`modelMenu.downloading`,{percent:t}),children:[I(B,{size:12,className:`spin`,"aria-hidden":`true`}),` `,t,`%`]})}let i=Cl(e);return i===`not_downloaded`?I(`button`,{type:`button`,className:`model-state-btn`,onClick:e=>{e.stopPropagation(),t()},disabled:n,"aria-label":r(`modelMenu.downloadModel`,{name:e.display_name??e.id}),title:e.size_gb?`${vl.not_downloaded} (${e.size_gb} GB)`:vl.not_downloaded,tabIndex:-1,children:I(Ji,{size:13,"aria-hidden":`true`})}):i===`loaded`?I(`span`,{className:`model-state is-loaded`,role:`img`,"aria-label":vl.loaded,title:vl.loaded}):I(`span`,{className:`model-state is-ready`,title:vl.downloaded,children:r(`modelMenu.ready`)})}var eU=[`local`,`cloud`];function tU(){let e=L(),t=il(e=>e.active),n=il(e=>e.select),r=il(e=>e.queued),i=r??t?.model,a=il(e=>e.queue),o=il(e=>e.queueError),s=il(e=>e.rememberNames);il(e=>e.names);let l=fl(),u=z(e=>pl(t,e.sessions,e.currentSessionId)),d=z(e=>e.isStreaming),f=z(e=>e.openSettings),p=(0,V.useRef)(null),[m,h]=(0,V.useState)(!1),[g,_]=(0,V.useState)(null),[v,y]=(0,V.useState)(null),[b,x]=(0,V.useState)({local:!1,cloud:!1}),[S,C]=(0,V.useState)(!1),[w,T]=(0,V.useState)(0),[E,ee]=(0,V.useState)(null),[D,O]=(0,V.useState)(null),[te,k]=(0,V.useState)(null),[A,ne]=(0,V.useState)(null),[j,M]=(0,V.useState)(null),[re,ie]=(0,V.useState)(null),[ae,oe]=(0,V.useState)(0),[se,ce]=(0,V.useState)(null),le=(0,V.useRef)(0),ue=(0,V.useRef)(null),de=(0,V.useId)(),fe=(0,V.useRef)(null),pe=(0,V.useRef)(null),[me,he]=(0,V.useState)(null),[ge,_e]=(0,V.useState)(null),ve=(0,V.useCallback)(()=>_e(null),[]),ye=(0,V.useCallback)(()=>h(!1),[]),be=(0,V.useRef)(!1),xe=(0,V.useRef)(null),Se=(0,V.useCallback)(async(t=!1)=>{t||(be.current=!1,ee(null),_(null));try{let[{providers:n,lemonade_error:r},i]=await Promise.all([At(),rt()]);if(r)throw Error(r);y(i);let a=n.filter(e=>!e.remote||e.models_discovered||e.id===`fireworks`||e.registered),o=await Promise.all(a.map(async t=>{if(t.blocked)return{provider:t,models:[],error:e(`settings.privacy.localOnlyBlocked`)};if(t.remote&&!t.models_discovered)return{provider:t,models:[]};try{let n=await Zn(t.id);return{provider:t,models:n.models,error:n.blocked?e(`settings.privacy.localOnlyBlocked`):void 0}}catch(e){return{provider:t,models:[],error:VF(e)}}}));s(o.flatMap(e=>e.models)),T(o.flatMap(e=>e.models).filter(e=>e.available===!1).length),t||(be.current=!0),_(o.map(e=>({...e,models:e.models.filter(e=>e.available!==!1)})))}catch(e){ee(VF(e))}},[s,e]),Ce=(0,V.useCallback)(async()=>{try{await c()}catch(e){ee(VF(e));return}await Se(!0)},[Se]);(0,V.useEffect)(()=>{m&&(O(null),k(null),C(!1),x({local:!1,cloud:!1}),he(null),_e(null),Se())},[m,Se]),(0,V.useEffect)(()=>{if(!m||!g||!be.current)return;let e=fe.current?.querySelector(`[role="option"][tabindex="0"]`);e&&(be.current=!1,e.focus(),e.scrollIntoView?.({block:`nearest`}))},[m,g]),(0,V.useEffect)(()=>{let e=xe.current;if(!m||!g||!e||!S)return;let t=g.find(t=>t.provider.id===e)?.models.find(e=>e.rank===null&&!sl(i,e.id));if(!t)return;let n=Array.from(fe.current?.querySelectorAll(`[role="option"]`)??[]).find(e=>e.dataset.row===t.id);n&&(xe.current=null,he(t.id),n.focus(),n.scrollIntoView?.({block:`nearest`}))},[m,g,S,i]),(0,V.useEffect)(()=>{(D||te)&&pe.current?.scrollIntoView?.({block:`nearest`})},[D,te]);let we=e=>{if(e.altKey||e.ctrlKey||e.metaKey)return;let t=Array.from(fe.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;if(e.preventDefault(),r.startsWith(`mode:`)){e.key===`ArrowRight`&&x(e=>({...e,[r.slice(5)]:!0}));return}_e(t=>e.key===`i`&&t===r?null:r);return}case`ArrowLeft`:{e.preventDefault();let r=n<0?void 0:t[n].dataset.row;r?.startsWith(`mode:`)&&x(e=>({...e,[r.slice(5)]:!1})),_e(null);return}default:return}e.preventDefault(),t[r].focus(),t[r].scrollIntoView?.({block:`nearest`})},N=!!g?.some(e=>e.models.some(Tl)),Te=!!g?.some(e=>e.provider.key_state===qH);(0,V.useEffect)(()=>{if(!(m||re)||!(N||re||Te))return;let e=()=>{Se(!0)};if(re){let t=setInterval(e,KH);return()=>clearInterval(t)}return jl(e,KH)},[m,N,re,Te,Se]);let De=(0,V.useCallback)(async e=>{M(e),oe(e=>e+1),ee(null);try{await Ee(e),await Se(!0)}catch(t){ie(t=>t?.model===e?null:t),ee(VF(t))}finally{M(null),oe(e=>e-1)}},[Se]),Oe=(0,V.useCallback)((e,t,n)=>{k(null),n&&(le.current=0,ce(null),ie({model:e,provider:t})),De(e)},[De]),ke=(0,V.useCallback)(async(e,r)=>{if(r.remote&&!t?.remote&&D?.model!==e)return O({model:e,provider:r}),null;if(O(null),d)return a(e===t?.model?null:e),h(!1),null;ne(e),ee(null);try{return await n(e),ce(null),h(!1),null}catch(e){let t=VF(e);return ee(t),t}finally{ne(null)}},[t?.model,t?.remote,D,a,n,d]);(0,V.useEffect)(()=>{if(!re||!g||ae>0)return;let{model:t,provider:n}=re,r=()=>(ue.current!==g&&(ue.current=g,le.current+=1),le.current>=YH),i=g.flatMap(e=>e.models).find(e=>e.id===t);if(!i){if(!r())return;ie(null),ce(e(`modelMenu.autoSwitch.gone`,{name:cl(t)}));return}if(Tl(i)){le.current=0;return}let a=i.download_progress;if(a?.state===`error`)ie(null),ce(e(`modelMenu.autoSwitch.downloadFailed`,{name:cl(t),reason:a.message??e.bare(`modelMenu.autoSwitch.noReason`)}));else if(a?.state!==`complete`&&Cl(i)===`not_downloaded`){if(!r())return;ie(null),ce(e(`modelMenu.autoSwitch.neverStarted`,{name:cl(t)}))}else ie(null),ke(t,n).then(n=>{n&&ce(e(`modelMenu.autoSwitch.switchFailed`,{name:cl(t),reason:n}))})},[g,re,ae,ke,e]);let Ae=e=>e.provider.remote?`cloud`:`local`,je=e=>v?.modes.find(t=>t.id===e)?.chat.model??null,Me=je(`cloud`),Ne=e=>sl(i,e)||!!Me&&wl(Me,e),Pe=(e,t)=>e.id===`fireworks`&&!S&&t.some(e=>e.rank!==null),Fe=(e,t)=>Pe(e,t)?t.filter(e=>e.rank!==null||Ne(e.id)):t,Ie=(e,t)=>Pe(e,t)&&t.some(e=>e.rank===null&&!Ne(e.id)),Le=g&&QH(g,t?.provider,i),Re=e=>(Le??[]).filter(t=>Ae(t)===e),ze=r?g?.find(e=>e.models.some(e=>sl(r,e.id))):void 0,Be=ze?Ae(ze):t?.model?t.remote?`cloud`:`local`:null,Ve=eU.flatMap(e=>[`mode:${e}`,...b[e]?Re(e).flatMap(({provider:e,models:t})=>[...e.key_state===JH?[`unlock:${e.id}`]:[],...e.remote&&!e.models_discovered?[`key:${e.id}`]:[],...Fe(e,t).filter(e=>A===null&&!Tl(e)).map(e=>e.id),...Ie(e,t)?[`showall:${e.id}`]:[]]):[]]),He=me&&Ve.includes(me)?me:Be?`mode:${Be}`:Ve[0],Ue=e=>({role:`option`,tabIndex:e===He?0:-1,"data-row":e,onFocus:()=>he(e),onBlur:()=>_e(null)}),We=(e,t)=>{t.remote||Cl(e)!==`not_downloaded`?(ie(null),k(null),ke(e.id,t)):(O(null),k({model:e.id,provider:t,pick:!0}))},Ge=e=>{let t=je(e);if(t)return Re(e).flatMap(e=>e.models.map(t=>({m:t,provider:e.provider}))).find(({m:e})=>wl(t,e.id))},Ke=t=>{if(t===Be){x(e=>({...e,[t]:!e[t]}));return}x(e=>({...e,[t]:!0}));let n=Ge(t),r=je(t);if(n)return We(n.m,n.provider);r&&Re(t).some(e=>e.models.length>0)&&ee(e(`runMode.modelNotListed.${t}`,{name:cl(r)}))},qe=t=>{let n=Re(t),r=je(t),i=r?cl(r):null;if(t===`cloud`){if(n.some(e=>e.provider.blocked))return{text:e(`settings.privacy.localOnlyBlocked`),warning:!0};let t=n.filter(e=>e.provider.models_discovered);if(t.length===0){let t=n.some(e=>e.provider.key_source);return{text:e(t?`runMode.keyNotWorking`:`runMode.needsKey`),warning:t||Be===`cloud`}}let r=t.find(e=>e.error);return r&&t.every(e=>e.models.length===0)?{text:r.error,warning:!0}:i?{text:i,warning:!1}:null}let a=Ge(t);return i&&a&&Cl(a.m)===`not_downloaded`&&!Tl(a.m)?{text:e(`runMode.notDownloaded`,{name:i}),warning:!0}:i&&a?.m.tight?{text:e(`runMode.tight`,{name:i}),warning:!0}:i?{text:i,warning:!1}:null},Je=l?l.remote?`cloud`:`local`:null,Ye=Je===`cloud`?Pi:Je?Wi:Ei,Xe=u?cl(u):e(`runMode.noModel`),Ze=e(Je?`runMode.${Je}`:`runMode.unknown`),Qe=Object.fromEntries((g??[]).map(e=>[e.provider.id,gl(e.models)])),$e=r?ze?Ae(ze):/^(fireworks|amd)\./.test(r)?`cloud`:null:null,et=!!$e&&$e!==Je,tt=t?.downloaded===!1&&u===t.model,nt=se||o||(r?e(`modelChip.queuedTitle`,{model:cl(r)}):t?.config_error?t.config_error:tt?e(`modelChip.notDownloadedTitle`,{name:Xe}):l?l.description?.replace(/`/g,``)??`${Xe} · ${l.remote?e(`modelStatus.runsRemote`,{name:l.label}):e(`modelStatus.runsHere`)}`:dl);return R(`div`,{className:`composer-chip-wrap run-mode-chip-wrap`,children:[R(`button`,{ref:p,type:`button`,className:`composer-chip${tt||o||se?` is-warning`:``}`,onClick:()=>h(e=>!e),"aria-haspopup":`dialog`,"aria-expanded":m,title:nt,children:[I(Ye,{size:13,"aria-hidden":`true`}),I(`span`,{className:`composer-chip-label`,dir:`auto`,children:Ze}),r&&R(`span`,{className:`composer-chip-next`,children:[I(Ir,{size:11,className:`composer-chip-next-arrow`,"aria-hidden":`true`}),et?I(`bdi`,{className:`composer-chip-next-model`,children:e.bare(`runMode.${$e}`)}):I(`bdi`,{dir:`ltr`,className:`composer-chip-next-model`,children:cl(r)}),I(`span`,{className:`composer-chip-next-tag`,children:e.bare(`modelChip.next`)})]}),tt&&I(Ji,{size:12,"aria-label":e(`modelChip.notDownloaded`)}),se&&I(wi,{size:12,"aria-label":e(`modelChip.switchFailed`)}),I(fi,{size:12,"aria-hidden":`true`})]}),I(`button`,{type:`button`,className:`composer-chip run-mode-customize`,onClick:()=>f(`mode`),"aria-label":e(`runMode.customize`),title:e(`runMode.customize`),children:I(Hs,{size:13,"aria-hidden":`true`})}),R(Mc,{open:m,onClose:ye,anchor:p,label:e(`runMode.menuLabel`),align:`end`,className:`model-menu run-mode-menu`,children:[d&&I(`div`,{className:`popover-message`,role:`status`,children:u?e(`modelMenu.keepsModel`,{model:cl(u)}):e(`modelMenu.keepsItsModel`)}),se&&I(`div`,{className:`popover-message is-error`,role:`alert`,children:se}),o&&I(`div`,{className:`popover-message is-error`,role:`alert`,children:o}),E&&I(`div`,{className:`popover-message is-error`,role:`alert`,children:E}),!g&&!E&&R(`div`,{className:`popover-message`,children:[I(B,{size:13,className:`spin`}),` `,e(`modelMenu.loading`)]}),g&&I(`div`,{ref:fe,role:`listbox`,"aria-label":e(`runMode.menuLabel`),onKeyDown:we,children:eU.map(n=>{let a=qe(n),o=n===`cloud`?Pi:Wi,s=e(`runMode.${n}`);return R(`div`,{role:`group`,"aria-label":s,className:`run-mode-group`,children:[R(`div`,{className:`popover-row`,children:[R(`button`,{type:`button`,className:`popover-item run-mode-item`,...Ue(`mode:${n}`),"aria-selected":Be===n,onClick:()=>Ke(n),disabled:A!==null,children:[I(`span`,{className:`popover-item-check`,"aria-hidden":`true`,children:Be===n?I(ci,{size:13}):null}),R(`span`,{className:`popover-item-body`,children:[R(`span`,{className:`popover-item-title run-mode-name`,children:[I(o,{size:13,"aria-hidden":`true`}),` `,s]}),I(`span`,{className:`popover-item-note`,children:e(`runMode.${n}Note`)}),a&&I(`span`,{className:`popover-item-note run-mode-state${a.warning?` is-warning`:``}`,children:a.text})]})]}),I(`button`,{type:`button`,className:`run-mode-expand`,"aria-expanded":b[n],"aria-label":e(`runMode.showModels.${n}`),title:e(`runMode.showModels.${n}`),tabIndex:-1,onClick:()=>x(e=>({...e,[n]:!e[n]})),children:b[n]?I(fi,{size:13,"aria-hidden":`true`}):I(gi,{size:13,className:`run-mode-chevron`,"aria-hidden":`true`})})]}),b[n]&&Re(n).map(({provider:n,models:a,error:o})=>R(`div`,{role:`group`,"aria-label":WH(e,n),className:`run-mode-models`,children:[n.remote&&I(`div`,{className:`popover-heading`,children:WH(e,n)}),o&&I(`div`,{className:`popover-message is-error`,children:o}),n.key_state===qH?R(`div`,{className:`popover-message`,role:`status`,children:[I(B,{size:13,className:`spin`,"aria-hidden":`true`}),` `,n.key_message]}):n.key_state===JH?R(`button`,{type:`button`,className:`popover-item`,...Ue(`unlock:${n.id}`),"aria-selected":!1,onClick:()=>void Ce(),children:[I(`span`,{className:`popover-item-check`,children:I(Xa,{size:13,"aria-hidden":`true`})}),R(`span`,{className:`popover-item-body`,children:[I(`span`,{className:`popover-item-title`,children:e(`settings.key.unlockAgain`)}),I(`span`,{className:`popover-item-note`,children:e(`settings.key.storeLocked`)})]})]}):n.remote&&!n.models_discovered&&R(`button`,{type:`button`,className:`popover-item`,...Ue(`key:${n.id}`),"aria-selected":!1,onClick:()=>{h(!1),f(`model`,n.id)},children:[I(`span`,{className:`popover-item-check`,children:I(Xa,{size:13,"aria-hidden":`true`})}),R(`span`,{className:`popover-item-body`,children:[I(`span`,{className:`popover-item-title`,children:e(n.key_source?`runMode.settings.checkKey`:`modelMenu.addKey`)}),I(`span`,{className:`popover-item-note`,children:e(n.key_source?`modelMenu.replaceInSettings`:`modelMenu.connectInSettings`,{provider:n.name})})]})]}),!o&&a.length===0&&n.models_discovered!==!1&&I(`div`,{className:`popover-message`,children:e(`modelMenu.noModels`)}),Fe(n,a).map((a,o,s)=>{let c=!n.remote&&ZH(a,i)&&o===s.findIndex(e=>ZH(e,i)),l=sl(r??t?.model,a.id),u=Qe[n.id][a.id],d=XH(a,n.remote,e),f=`${de}-info-${n.id}-${a.id}`;return R(V.Fragment,{children:[c&&I(`div`,{className:`popover-subheading`,children:e(`modelMenu.availableToDownload`)}),R(`div`,{className:`popover-row`,children:[R(`button`,{type:`button`,className:`popover-item`,onClick:()=>We(a,n),disabled:A!==null||Tl(a),...Ue(a.id),"aria-selected":l,"aria-describedby":ge===a.id?f:void 0,children:[I(`span`,{className:`popover-item-check`,"aria-hidden":`true`,children:A===a.id?I(B,{size:13,className:`spin`}):l?I(ci,{size:13}):null}),R(`span`,{className:`popover-item-body is-inline`,children:[I(`span`,{className:`popover-item-title is-model`,children:u}),!n.remote&&I(zH,{support:a.support}),!n.remote&&a.size_gb?I(`span`,{className:`popover-item-meta`,children:R(`bdi`,{dir:`ltr`,children:[a.size_gb,` GB`]})}):null]})]}),R(RH,{label:e(`modelMenu.aboutModel`,{name:u}),warning:!!a.placement?.warning,id:f,pinned:ge===a.id,onUnpin:ve,tabIndex:-1,children:[I(`div`,{className:`info-bubble-title`,children:I(`bdi`,{dir:`ltr`,children:u})}),d.length>0&&I(`ul`,{className:`info-bubble-lines`,children:d.map(e=>I(`li`,{children:e.content},e.key))}),a.placement?.warning&&I(`ul`,{className:`info-bubble-lines`,children:I(`li`,{className:`is-warning`,children:a.placement.warning})}),I(`div`,{className:`info-bubble-id`,dir:`ltr`,children:a.id})]}),I(`span`,{className:`popover-row-state`,children:!n.remote&&I($H,{m:a,busy:j!==null,onDownload:()=>{O(null),k({model:a.id,provider:n,pick:!1})}})})]}),te?.model===a.id&&te.provider.id===n.id&&R(`div`,{ref:pe,className:`popover-message model-download-confirm`,role:`alert`,children:[R(`span`,{children:[I(kl,{text:a.size_gb?e(`modelMenu.downloadConfirm`,{name:El(u),size:El(`${a.size_gb} GB`)}):e(`modelMenu.downloadConfirmNoSize`,{name:El(u)})}),te.pick&&` ${e(`modelMenu.switchWhenDone`)}`]}),R(`span`,{className:`model-download-confirm-actions`,children:[I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>Oe(a.id,n,te.pick),children:e(`modelMenu.download`)}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>k(null),children:e(`modelMenu.cancel`)})]})]}),D?.model===a.id&&D.provider.id===n.id&&R(`div`,{ref:pe,className:`popover-message`,role:`alert`,children:[GH(e,D.provider),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>ke(D.model,D.provider),children:e(`modelMenu.useModel`,{name:cl(D.model)})})]})]},a.id)}),Ie(n,a)&&R(`button`,{type:`button`,className:`popover-item`,...Ue(`showall:${n.id}`),"aria-selected":!1,onClick:()=>{xe.current=n.id,C(!0)},children:[I(`span`,{className:`popover-item-check`}),I(`span`,{className:`popover-item-body`,children:I(`span`,{className:`popover-item-title`,children:e(`settings.model.showAll`)})})]})]},n.id))]},n)})}),w>0&&b.local&&R(`button`,{type:`button`,className:`popover-item`,onClick:()=>{h(!1),f(`model`)},children:[I(`span`,{className:`popover-item-check`}),I(`span`,{className:`popover-item-body`,children:I(`span`,{className:`popover-item-note`,children:e.plural(`modelMenu.unavailable`,w)})})]}),I(`div`,{className:`popover-divider`}),R(`button`,{type:`button`,className:`popover-item`,onClick:()=>{h(!1),f(`mode`)},children:[I(`span`,{className:`popover-item-check`,children:I(Hs,{size:13,"aria-hidden":`true`})}),R(`span`,{className:`popover-item-body`,children:[I(`span`,{className:`popover-item-title`,children:e(`runMode.customizeMenu`)}),I(`span`,{className:`popover-item-note`,children:e(`runMode.customizeNote`)})]})]})]})]})}function nU(e,t,n){if(e==null||!t(e))throw Error(`the server sent no ${n}`);return e}var rU=e=>e.startsWith(`.`);function iU({onPick:e,onClose:t}){let n=L(),[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(``),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1),[d,f]=(0,V.useState)(!1);er(!0,t);let p=(0,V.useRef)(null);yn(p,!0);let m=(0,V.useCallback)(e=>{u(!0),c(null),Promise.resolve().then(()=>Kt(e)).then(e=>{let t=nU(e,e=>Array.isArray(e.entries),`folder listing`);i(t),o(t.current_path)}).catch(e=>c(e instanceof On?e.detail||e.message:String(e))).finally(()=>u(!1))},[]);(0,V.useEffect)(()=>m(),[m]);let h=r?.entries.filter(e=>e.type===`folder`)??[],g=d?h:h.filter(e=>!rU(e.name));return I(`div`,{className:`modal-overlay`,onClick:t,children:R(`div`,{ref:p,className:`modal-panel sp-picker`,role:`dialog`,"aria-modal":`true`,"aria-label":n(`pick.label`),onClick:e=>e.stopPropagation(),children:[R(`div`,{className:`modal-header`,children:[I(`h3`,{children:n(`pick.title`)}),I(`button`,{type:`button`,className:`btn-icon`,onClick:t,"aria-label":n(`sp.closeShort`),children:I(bc,{size:18})})]}),R(`div`,{className:`modal-body sp-picker-body`,children:[I(`p`,{className:`sp-meta`,children:n(`pick.note`)}),R(`form`,{className:`sp-picker-path`,onSubmit:e=>{e.preventDefault(),a.trim()&&m(a.trim())},children:[I(`input`,{value:a,onChange:e=>o(e.target.value),"aria-label":n(`pick.path`),spellCheck:!1,dir:`ltr`}),I(`button`,{type:`submit`,className:`sp-action`,children:n(`pick.go`)})]}),r&&R(`div`,{className:`sp-picker-quick`,children:[r.quick_links.map(e=>I(`button`,{type:`button`,className:`sp-action`,onClick:()=>m(e.path),children:e.name},e.path)),R(`label`,{className:`sp-picker-hidden`,children:[I(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked)}),n(`pick.showHidden`)]})]}),R(`ul`,{className:`sp-picker-list`,"aria-busy":l,children:[r?.parent_path&&I(`li`,{children:R(`button`,{type:`button`,onClick:()=>m(r.parent_path??void 0),children:[I(Br,{size:13,"aria-hidden":`true`}),` `,n(`pick.up`)]})}),g.map(e=>I(`li`,{children:R(`button`,{type:`button`,onClick:()=>m(e.path),children:[I(Ma,{size:13,"aria-hidden":`true`}),` `,e.name]})},e.path)),r&&g.length===0&&I(`li`,{className:`sp-meta`,children:n(h.length>0?`pick.onlyHidden`:`pick.none`)}),l&&R(`li`,{className:`sp-meta`,children:[I(B,{size:12,className:`spin`,"aria-hidden":`true`}),` `,n(`pick.loading`)]})]}),s&&I(`p`,{className:`sp-error`,role:`alert`,children:s}),r?.folder_refusal&&I(`p`,{className:`sp-meta`,role:`status`,children:r.folder_refusal})]}),R(`div`,{className:`sp-picker-actions`,children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:t,children:n(`sp.cancel`)}),I(`button`,{type:`button`,className:`btn-primary`,disabled:!r||!!r.folder_refusal,onClick:()=>r&&e(r.current_path),children:n(`pick.use`)})]})]})})}var aU=e=>e instanceof On?e.detail||e.message:e instanceof Error?e.message:String(e);function oU(e){let t=L(),[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(null);return{open:n=>{a(null);let i=window.gaiaAPI?.dialog;i?i.pickFolder(n).then(async n=>{if(!n)return;let r;try{({refusal:r}=await Ft(n))}catch(e){a(t(`pick.checkFailed`,{error:aU(e)}));return}r?a(r):e(n)},e=>a(t(`pick.openFailed`,{error:aU(e)}))):r(!0)},picker:n?I(iU,{onPick:t=>{r(!1),e(t)},onClose:()=>r(!1)}):null,error:i}}var sU=new Map;function cU(e){let t=sU.get(e);return t||(t={env:null,error:null,inFlight:null,version:0,listeners:new Set},sU.set(e,t)),t}function lU(e,t,n){let r=cU(e);r.env=t??r.env,r.error=n,r.listeners.forEach(e=>e())}function uU(e){let t=cU(e);if(t.inFlight)return t.inFlight;let n=t.version;return t.inFlight=Promise.resolve().then(()=>tn(e)).then(r=>{let i=nU(r,e=>Array.isArray(e.folders),`chat's environment`);t.version===n&&lU(e,i,null)}).catch(t=>lU(e,null,t instanceof Error?t.message:String(t))).finally(()=>{t.inFlight=null}),t.inFlight}function dU(e){let[,t]=(0,V.useState)(0);(0,V.useEffect)(()=>{let n=cU(e),r=()=>t(e=>e+1);return n.listeners.add(r),!n.env&&!n.inFlight&&uU(e),()=>{n.listeners.delete(r)}},[e]);let n=(0,V.useCallback)(()=>uU(e),[e]),r=(0,V.useCallback)(async t=>{let n=await t();return cU(e).version+=1,lU(e,n,null),n},[e]),i=cU(e);return{env:i.env,error:i.error,refresh:n,change:r}}var fU=e=>e.split(/[\\/]/).filter(Boolean).pop()??e;function pU({folder:e,disabled:t}){let n=L(),r=z(e=>e.draftFolder),i=z(e=>e.setDraftFolder),{open:a,picker:o,error:s}=oU(i),c=e.gaia_folder?n(`folderChip.worksInOwn`,{path:e.path}):n(`folderChip.worksIn`,{path:e.path}),l=!e.gaia_folder&&R(`span`,{className:`new-chat-folder`,title:c,children:[I(Ma,{size:13,"aria-hidden":`true`}),I(`span`,{className:`new-chat-folder-name`,dir:`auto`,children:e.name})]});return e.choosable?R(F.Fragment,{children:[l,r?R(`span`,{className:`new-chat-folder is-on`,title:n(`folderChip.picked`,{path:r}),children:[I(Ma,{size:13,"aria-hidden":`true`}),I(`span`,{className:`new-chat-folder-name`,dir:`auto`,children:fU(r)}),I(`button`,{type:`button`,className:`new-chat-folder-clear`,onClick:()=>i(null),disabled:t,"aria-label":n(`folderChip.remove`,{name:fU(r)}),title:n(`folderChip.remove`,{name:fU(r)}),children:I(bc,{size:12,"aria-hidden":`true`})})]}):R(`button`,{type:`button`,className:`new-chat-folder is-button`,onClick:()=>a(e.path),disabled:t,"aria-haspopup":`dialog`,title:`${c} ${n(`folderChip.addHint`)}`,children:[I(os,{size:13,"aria-hidden":`true`}),I(`span`,{className:`new-chat-folder-name`,children:n(`folderChip.add`)})]}),s&&I(`span`,{className:`new-chat-folder-error`,role:`alert`,children:s}),o]}):l||R(`span`,{className:`new-chat-folder`,title:`${c} ${n(`folderChip.ownFixedHint`)}`,children:[I(Ma,{size:13,"aria-hidden":`true`}),I(`span`,{className:`new-chat-folder-name`,children:n(`folderChip.gaiaFolder`)})]})}function mU({sessionId:e,onOpen:t}){let{env:n}=dU(e),r=n?.folders.find(e=>e.source===`working_folder`);if(!r)return null;let i=fU(r.path);return R(`button`,{type:`button`,className:`composer-chip folder-chip`,title:`GAIA works in ${r.path}`,"aria-label":`Working folder ${i}, show the chat's folders`,onClick:t,children:[I(Ma,{size:13,"aria-hidden":`true`}),I(`span`,{className:`composer-chip-label`,dir:`auto`,children:i})]})}var hU=`gaia:permission-mode`;function gU(e,t){window.dispatchEvent(new CustomEvent(hU,{detail:{sessionId:e,mode:t}}))}function _U(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(hU,t),()=>window.removeEventListener(hU,t)},[e])}var vU=[{mode:`ask`,label:`perm.ask`,note:`perm.askNote`},{mode:`full_access`,label:`perm.full`,note:`perm.fullNote`}];function yU({sessionId:e,disabled:t}){let n=L(),r=z(e=>e.draftPermissionMode),i=z(e=>e.setDraftPermissionMode),[a,o]=(0,V.useState)(e?null:r),[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(!1),[d,f]=(0,V.useState)(null),p=(0,V.useRef)(null),m=fu(t=>e!==null&&gu(e)(t)!==null);(0,V.useEffect)(()=>{e||o(r)},[e,r]),(0,V.useEffect)(()=>{if(!e)return;let t=!1;return o(null),f(null),rr(e).then(e=>{t||o(e.mode)}).catch(e=>{t||f(VF(e))}),()=>{t=!0}},[e]),_U(e,(0,V.useCallback)(e=>{f(null),o(e)},[]));let h=(0,V.useCallback)(async t=>{if(t===`full_access`&&!l)u(!0);else{f(null);try{if(e){let n=(await Ue(e,t)).mode;o(n),gU(e,n),n===`full_access`&&m||c(!1)}else i(t),o(t),c(!1)}catch(t){f(VF(t)),e&&rr(e).then(e=>o(e.mode)).catch(e=>f(t=>`${t??``} Couldn't re-read the saved mode: ${VF(e)}`.trim()))}finally{u(!1)}}},[l,m,e,i]),g=a===`full_access`,_=a===null,v=g||_&&d?Is:Ps,y=n(g?`perm.full`:_?d?`perm.unknown`:`perm.checking`:`env.ask`);return R(`div`,{className:`composer-chip-wrap`,children:[R(`button`,{ref:p,type:`button`,className:`composer-chip composer-chip-permission${g||_&&d?` is-warning`:``}`,onClick:()=>{u(!1),c(e=>!e)},disabled:t,"aria-haspopup":`dialog`,"aria-expanded":s,"aria-label":_?n(`perm.chipAriaUnread`,{state:y}):n(`perm.chipAria`,{mode:de(g?`perm.fullLower`:`perm.askLower`)}),children:[I(v,{size:13,"aria-hidden":`true`}),I(`span`,{className:`composer-chip-label`,dir:`auto`,children:y}),I(fi,{size:12,"aria-hidden":`true`})]}),R(Mc,{open:s,onClose:()=>c(!1),anchor:p,label:n(`env.permission`),children:[vU.map(e=>R(`button`,{type:`button`,className:`popover-item`,onClick:()=>h(e.mode),"aria-pressed":a===e.mode,children:[I(`span`,{className:`popover-item-check`,"aria-hidden":`true`,children:a===e.mode&&I(ci,{size:13})}),R(`span`,{className:`popover-item-body`,children:[I(`span`,{className:`popover-item-title`,children:n(e.label)}),I(`span`,{className:`popover-item-note`,children:n(e.note)})]})]},e.mode)),l&&R(`div`,{className:`popover-message`,role:`alert`,children:[n(`env.fullAccessWarn`),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>h(`full_access`),children:n(`env.turnOn`)})]}),g&&m&&!l&&I(`div`,{className:`popover-message`,role:`status`,children:n(`perm.fullPendingNote`)}),d&&I(`div`,{className:`popover-message is-error`,role:`alert`,children:d})]})]})}function bU(e){return z(t=>bt(t,e))}function xU(e,t){return b(e,bt(z.getState(),t))}async function SU(e,t){CU(e,t)&&T((await jn()).skills.map(e=>e.name))}function CU(e,t){return Ve(e,bt(z.getState(),t))}function wU({sessionId:e,disabled:t,compact:n=!1}){let r=L(),i=bU(e),a=z(e=>e.setResearch),o=t=>a(e,t);return(0,V.useEffect)(()=>{if(!i)return;let e=!0;return jn().then(t=>{e&&T(t.skills.map(e=>e.name))},e=>P.chat.warn(`Research mode could not read the installed skills; a /<name> message will ask again`,e)),()=>{e=!1}},[i]),R(`button`,{type:`button`,className:`composer-chip composer-chip-research${i?` is-on`:``}`,onClick:()=>o(!i),disabled:t,"aria-pressed":i,"aria-label":r(`composer.research`),title:r(i?`composer.researchOnTitle`:`composer.researchOffTitle`),children:[I(nc,{size:13,"aria-hidden":`true`}),!n&&I(`span`,{className:`composer-chip-label`,dir:`auto`,children:r(`composer.research`)})]})}function TU({text:e}){return I(`div`,{className:`history-notice`,role:`note`,children:e})}function EU({notices:e}){return I(`div`,{className:`library-notices`,role:`note`,children:e.map((e,t)=>I(`div`,{dir:`auto`,children:e},`${t}-${e}`))})}var DU={sending:`queue.sending`,delivered:`queue.delivered`,queued:`queue.queued`};function OU(e,t,n){return n(e?DU.queued:t?`queue.busy`:`queue.next`)}function kU(e,t){return e?t.compose(t=>t(`queue.notSent`,{error:typeof e==`string`?e:t(e.key,e.params)})):t(`queue.notSentBare`)}function AU({items:e,onRemove:t,onSteer:n,onRetry:r,replying:i=!0,busyRetry:a=!1}){let o=L(),s=e.filter(e=>e.state!==`starting`);return s.length===0?null:I(`ul`,{className:`queued-messages`,"aria-label":o(`queue.listAria`),"aria-live":`polite`,children:s.map(e=>R(`li`,{className:`queued-message is-${e.state}`,children:[e.state===`failed`?I(wi,{size:12,"aria-hidden":`true`}):e.state===`queued`?I(Mi,{size:12,"aria-hidden":`true`}):I(Hi,{size:12,"aria-hidden":`true`}),I(`span`,{className:`queued-message-text`,dir:`auto`,title:e.text,children:e.text}),I(`span`,{className:`queued-message-state`,title:e.state===`failed`?kU(e.error,o):void 0,children:e.state===`failed`?kU(e.error,o):e.state===`queued`?(i&&e.note?o(e.note):``)||OU(i,a,o):o(DU[e.state])}),e.state===`failed`&&R(`button`,{type:`button`,className:`queued-message-steer`,onClick:()=>r(e.id),"aria-label":o(`queue.sendAgainAria`,{text:e.text}),children:[I(bs,{size:11,"aria-hidden":`true`}),` `,o(`queue.sendAgain`)]}),e.state===`queued`&&n&&I(`button`,{type:`button`,className:`queued-message-steer`,onClick:()=>n(e.id),title:o(`queue.steerTitle`),children:o(`queue.steer`)}),(e.state===`queued`||e.state===`failed`)&&I(`button`,{type:`button`,className:`queued-message-remove`,onClick:()=>t(e.id),"aria-label":o(`queue.removeAria`,{text:e.text}),title:o(`queue.remove`),children:I(bc,{size:12})})]},e.id))})}function jU(e,{reason:t,code:n}){let r=`ctx.reason.${n}`;return n?!j(r)||gt(r)!==t?t:e(r):hk(e,t)}var MU=e=>e.toLocaleString(`en-US`);function NU({n:e,window:t=!1}){let n=L();if(e==null)return I(`span`,{className:`cp-unknown`,children:n(`ctx.unknown`)});let r=t?Sl(e):e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(+(e<1e4))}K`:`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`;return I(`span`,{title:n(`ctx.tokens`,{n:MU(e)}),dir:`ltr`,children:r})}function PU({s:e}){let t=L();if(e==null)return I(`span`,{className:`cp-unknown`,children:t(`ctx.unknown`)});let n=e<.1?e===0?`0 s`:`<0.1 s`:e<10?`${e.toFixed(1)} s`:`${Math.round(e)} s`;return I(`span`,{title:`${(e*1e3).toFixed(0)} ms`,dir:`ltr`,children:n})}function FU({r:e}){let t=L();return e==null?I(`span`,{className:`cp-unknown`,children:t(`ctx.unknown`)}):I(`span`,{title:t(`ctx.rateTitle`,{n:e}),children:t(`ctx.rate`,{n:Math.round(e).toLocaleString(`en-US`)})})}var IU=(e,t)=>t>0?Math.round(e/t*100):0,LU=(e,t)=>{let n=IU(e,t);return n===0&&e>0?`<1`:String(n)},RU=(e,t)=>t&&e!=null?Math.floor(e/t*100):null,zU=256;function BU(e,t=gt){if(e.provider===`unknown`)return t(`ctx.unknown`);if(e.provider===`cloud`)return t(`ctx.cloud`);if(e.provider!==`local`)return t(`ctx.cloudVia`,{provider:_l(e.provider)});if(!e.device)return e.loaded===!1?t(`ctx.notLoadedNow`):t(`ctx.unknown`);let n=e.device.toUpperCase(),r=e.backend===`npu`?`FLM`:e.backend;return r&&r!==e.device?`${n} · ${r.charAt(0).toUpperCase()}${r.slice(1)}`:n}function VU({label:e,children:t,hint:n}){return R(`div`,{className:`cp-row`,title:n,children:[I(`dt`,{children:e}),I(`dd`,{children:t})]})}function HU({t:e}){let t=L();if(e.model_seconds==null||e.gaia_seconds==null)return R(VU,{label:t(`ctx.took`),children:[I(PU,{s:e.wall_seconds}),` · `,t.bare(`ctx.split`),` `,I(`span`,{className:`cp-unknown`,children:t(`ctx.unknown`)})]});let n=[{key:`model`,label:t(`ctx.inModel`),s:e.model_seconds},{key:`tools`,label:t(`ctx.runningTools`),s:e.tool_seconds},{key:`waiting`,label:t(`ctx.waitingOnYou`),s:e.waiting_seconds},{key:`gaia`,label:t(`ctx.gaiaItself`),s:e.own_seconds??0}];return R(F.Fragment,{children:[I(VU,{label:t(`ctx.took`),hint:t(`ctx.tookHint`),children:I(PU,{s:e.wall_seconds})}),I(`div`,{className:`cp-stack`,"aria-hidden":`true`,children:n.map(t=>I(`span`,{className:`cp-time-${t.key}`,style:{width:`${IU(t.s,e.wall_seconds)}%`}},t.key))}),R(`dl`,{className:`cp-rows cp-indent`,children:[I(VU,{label:t(`ctx.inModel`),children:I(PU,{s:e.model_seconds})}),I(VU,{label:t(`ctx.inGaia`),hint:t(`ctx.inGaiaHint`),children:I(PU,{s:e.gaia_seconds})}),n.slice(1).filter(e=>e.s>0).map(e=>R(VU,{label:`· ${e.label}`,children:[I(`span`,{className:`swatch cp-time-${e.key}`,"aria-hidden":`true`}),` `,I(PU,{s:e.s})]},e.key))]})]})}function UU({why:e}){let t=L();return I(`span`,{className:`cp-unknown`,title:e,children:t(`ctx.unknown`)})}var WU={server:`ctx.src.server`,client:`ctx.src.client`};function GU(e,t){return e?t(WU[e]):void 0}function KU({turn:e}){let t=L(),n=RU(e.tokens_cached,e.tokens_in),r=e.unknown??{},i=e.tools.map(e=>`${e.name??t(`ctx.toolOutside`)}: ${e.seconds??`?`} s`).join(`
194
+ `);return R(F.Fragment,{children:[I(HU,{t:e.time}),R(`dl`,{className:`cp-rows`,children:[I(VU,{label:t(`ctx.firstWord`),hint:GU(e.first_token_source,t),children:e.first_token_seconds==null?I(UU,{why:r.first_token_seconds}):R(F.Fragment,{children:[t.bare(`ctx.in`),` `,I(PU,{s:e.first_token_seconds})]})}),I(VU,{label:t(`ctx.readingPrompt`),hint:t(`ctx.readingHint`),children:e.tokens_new!=null&&e.tokens_new<zU?I(`span`,{title:t(`ctx.tooFewTitle`),children:t(`ctx.onlyNew`,{n:e.tokens_new})}):e.prefill_tokens_per_second==null?I(UU,{why:r.prefill_tokens_per_second}):R(F.Fragment,{children:[I(FU,{r:e.prefill_tokens_per_second}),e.prefill_source===`client`&&I(`span`,{className:`cp-chip`,title:t(`ctx.approxTitle`),children:t(`ctx.approx`)})]})}),I(VU,{label:t(`ctx.writing`),hint:GU(e.generation_source,t)??t(`ctx.writingHint`),children:e.generation_tokens_per_second==null?I(UU,{why:r.generation_tokens_per_second}):I(FU,{r:e.generation_tokens_per_second})}),I(VU,{label:t(`ctx.tokensInOut`),hint:r.tokens,children:R(`span`,{dir:`ltr`,children:[I(NU,{n:e.tokens_in}),` → `,I(NU,{n:e.tokens_out})]})}),I(VU,{label:t(`ctx.cache`),hint:t(`ctx.cacheHint`),children:e.tokens_cached==null?I(UU,{why:r.tokens_cached}):R(F.Fragment,{children:[I(NU,{n:e.tokens_cached}),n!=null&&` (${n}%)`]})}),I(VU,{label:t(`ctx.modelCalls`),children:e.model_calls}),I(VU,{label:t(`ctx.toolCalls`),hint:i||void 0,children:e.tool_calls===0&&!e.tool_seconds_total?t(`ctx.none`):R(F.Fragment,{children:[e.tool_calls,` · `,I(PU,{s:e.tool_seconds_total??0})]})}),I(VU,{label:t(`ctx.loads`),children:e.loads.length===0?t(`ctx.none`):R(`span`,{title:e.loads.map(e=>`${e.model}${e.replaced?.length?` replaced ${e.replaced.join(`, `)}`:``}: ${e.seconds} s`).join(`
195
+ `),children:[e.loads.length,` · `,I(PU,{s:e.loads.reduce((e,t)=>e+t.seconds,0)})]})}),I(VU,{label:t(`rail.cost`),children:I(qU,{cost:e.cost})})]})]})}function qU({cost:e}){let t=L();return e.kind===`local`?I(`span`,{title:t(`ctx.costLocalTitle`),children:t(`ctx.costLocal`)}):e.kind===`no_reply`?I(`span`,{children:t(`rail.costNoReply`)}):e.kind===`unreported`?I(`span`,{className:`cp-unknown`,children:t(`ctx.costUnreported`)}):e.kind===`estimate`&&e.usd!=null?I(`span`,{title:t(`ctx.listPriceTitle`,{usd:e.usd}),children:t(`ctx.about`,{usd:e.usd<.01?e.usd.toFixed(4):e.usd.toFixed(2)})}):I(`span`,{className:`cp-unknown`,children:t(`ctx.unknown`)})}function JU({totals:e}){let t=L(),n=RU(e.tokens_cached,e.tokens_in),r=I(`span`,{className:`cp-unknown`,children:t(`ctx.unknown`)});return R(`dl`,{className:`cp-rows`,children:[I(VU,{label:t(`ctx.turns`),children:e.turns}),I(VU,{label:t(`ctx.totalTime`),children:I(PU,{s:e.wall_seconds})}),I(VU,{label:t(`ctx.inModel`),children:I(PU,{s:e.model_seconds})}),I(VU,{label:t(`ctx.inGaia`),children:I(PU,{s:e.gaia_seconds})}),I(VU,{label:t(`ctx.tokensInOut`),children:R(`span`,{dir:`ltr`,children:[I(NU,{n:e.tokens_in}),` → `,I(NU,{n:e.tokens_out})]})}),I(VU,{label:t(`ctx.cache`),children:e.tokens_cached==null?r:R(F.Fragment,{children:[I(NU,{n:e.tokens_cached}),n!=null&&` (${n}%)`]})}),I(VU,{label:t(`ctx.toolCalls`),children:e.tool_calls??r}),I(VU,{label:t(`ctx.loads`),children:e.loads===0?t(`ctx.none`):R(F.Fragment,{children:[e.loads,` · `,I(PU,{s:e.load_seconds})]})}),I(VU,{label:t(`rail.cost`),children:e.usd==null?r:e.unpriced_turns>0?I(`span`,{title:t(`ctx.unpricedTitle`,{n:e.unpriced_turns}),children:t(`ctx.unpriced`,{usd:e.usd.toFixed(2),n:e.unpriced_turns})}):e.usd===0?`$0`:t(`ctx.about`,{usd:e.usd.toFixed(2)})})]})}function YU({usage:e}){let t=L(),n=e.context_state?.put_away,r=e.context_state?.summarized;return R(`div`,{className:`cp-full`,children:[R(`dl`,{className:`cp-rows`,children:[I(VU,{label:t(`ctx.live`),children:I(NU,{n:e.used})}),n&&n.results>0&&R(VU,{label:t(`ctx.putAway`),hint:t(`ctx.putAwayHint`),children:[t.plural(`ctx.results`,n.results),` · `,I(NU,{n:n.tokens})]}),r&&r.turns>0&&R(VU,{label:t(`ctx.summarized`),hint:t(`ctx.summarizedHint`),children:[t.plural(`ctx.earlier`,r.turns),` · `,I(NU,{n:r.tokens}),` → `,I(NU,{n:r.summary_tokens})]})]}),r&&r.turns>0&&I(`p`,{className:`cp-note cp-summarized`,children:t(`ctx.summarizedNote`)}),e.at_risk.length>0&&I(`p`,{className:`cp-warning`,role:`status`,children:t(`ctx.filling`)})]})}function XU({sessionId:e,busy:t,onUsage:n}){let r=L(),[i,a]=(0,V.useState)(null),[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)(`turn`),g=(0,V.useRef)(n);g.current=n;let _=(0,V.useCallback)(()=>{let t=!1,n=(n,r)=>i=>{t||(P.chat.error(`Could not read the ${n} for session=${e}`,i),r(i instanceof Error?i.message:String(i)))};return Gt(e).then(e=>{t||(e.available?(a(e),s(null),g.current?.(e)):(a(null),s({reason:e.reason,code:e.reason_code})),d(null))}).catch(n(`context usage`,d)),Xt(e).then(e=>{t||(l(e),p(null))}).catch(n(`performance`,p)),()=>{t=!0}},[e]);(0,V.useEffect)(()=>_(),[_]);let v=(0,V.useRef)(t);(0,V.useEffect)(()=>{let e=v.current&&!t;return v.current=t,e?_():void 0},[t,_]);let y=c?.turns[c.turns.length-1]??null,b=y&&y.message_id===c?.latest_message_id?y:null,x=i?Math.max(0,i.window-i.used):0;return R(F.Fragment,{children:[R(`section`,{"aria-labelledby":`cp-context`,children:[I(`h3`,{id:`cp-context`,children:r(`ctx.context`)}),u&&I(`p`,{className:`cp-error`,role:`alert`,children:u}),!i&&!u&&I(`p`,{className:`cp-note`,children:o?jU(r,o):r(`ctx.measuring`)}),i&&R(F.Fragment,{children:[R(`p`,{className:`cp-lead`,children:[I(`strong`,{children:r(`ctx.used`,{pct:IU(i.used,i.window)})}),` · `,I(NU,{n:i.used}),` `,r.bare(`ctx.of`),` `,I(NU,{n:i.window,window:!0}),` `,r.bare(`ctx.tokensWord`),i.model&&R(F.Fragment,{children:[` · `,I(`span`,{className:`cp-model`,dir:`ltr`,children:i.model})]}),i.model_window!=null&&i.model_window>i.window&&R(`span`,{className:`cp-window-note`,title:r(`ctx.windowTitle`),children:[` `,`· `,r.bare(`ctx.gaiaUses`),` `,I(NU,{n:i.window,window:!0}),` `,r.bare(`ctx.ofModel`),` `,I(NU,{n:i.model_window,window:!0})]}),i.tokenizer&&!i.tokenizer.exact&&I(`span`,{className:`cp-chip`,title:i.tokenizer.reason,children:r(`ctx.approx`)})]}),I(`div`,{className:`cp-stack`,"aria-hidden":`true`,children:(i.categories??[]).map(e=>I(`span`,{className:`cp-cat-${e.key}`,style:{width:`${e.tokens/i.window*100}%`}},e.key))}),R(`dl`,{className:`cp-rows`,children:[(i.categories??[]).map(e=>R(`div`,{className:`cp-row`,children:[R(`dt`,{children:[I(`span`,{className:`swatch cp-cat-${e.key}`,"aria-hidden":`true`}),e.label]}),R(`dd`,{children:[I(NU,{n:e.tokens}),` `,R(`span`,{className:`cp-pct`,children:[LU(e.tokens,i.window),`%`]})]})]},e.key)),R(`div`,{className:`cp-row is-quiet`,children:[R(`dt`,{children:[I(`span`,{className:`swatch cp-cat-free`,"aria-hidden":`true`}),r(`ctx.freeRow`)]}),R(`dd`,{children:[I(NU,{n:x}),` `,R(`span`,{className:`cp-pct`,children:[IU(x,i.window),`%`]})]})]}),R(`div`,{className:`cp-row is-quiet cp-indent`,children:[I(`dt`,{children:r(`ctx.reserve`)}),I(`dd`,{children:I(NU,{n:Math.min(x,i.reply_reserve)})})]})]}),R(`p`,{className:`cp-note`,children:[i.tokenizer?.exact?r(`ctx.exactTokenizer`,{model:i.tokenizer.model}):r(`ctx.estimated`,{reason:i.tokenizer?.reason??de(`ctx.sharedTokenizer`)}),b?.last_prompt_tokens!=null&&R(F.Fragment,{children:[` `,r(`ctx.lastRequest`,{n:MU(b.last_prompt_tokens)})]})]}),i.tool_loading&&i.tool_loading.on_demand.length>0&&R(`details`,{className:`cp-details`,children:[I(`summary`,{children:r(`ctx.onDemand`,{n:i.tool_loading.on_demand.length})}),I(`p`,{className:`cp-note`,children:r(`ctx.sentNow`,{n:i.tool_loading.loaded.length})}),I(`ul`,{className:`cp-tools`,children:i.tool_loading.on_demand.map(e=>I(`li`,{children:e},e))})]}),I(YU,{usage:i})]})]}),R(`section`,{"aria-labelledby":`cp-hood`,children:[R(`div`,{className:`cp-section-head`,children:[I(`h3`,{id:`cp-hood`,children:r(`ctx.hood`)}),R(`div`,{className:`cp-toggle`,role:`group`,"aria-label":r(`ctx.show`),children:[I(`button`,{type:`button`,"aria-pressed":m===`turn`,onClick:()=>h(`turn`),children:r(`ctx.lastTurn`)}),I(`button`,{type:`button`,"aria-pressed":m===`chat`,onClick:()=>h(`chat`),children:r(`sp.title`)})]})]}),c&&R(`dl`,{className:`cp-rows`,children:[I(VU,{label:r(`env.runsOn`),hint:c.now.error??void 0,children:BU(c.now,r)}),c.now.provider===`local`&&R(VU,{label:r(`ctx.memory`),hint:r(`ctx.memoryHint`),children:[c.now.weights_gb==null?I(`span`,{className:`cp-unknown`,children:r(`ctx.unknown`)}):R(F.Fragment,{children:[r(`ctx.gbModel`,{gb:c.now.weights_gb.toFixed(1)}),c.now.kv_cache_gb!=null&&` + ${r(`ctx.gbCache`,{gb:c.now.kv_cache_gb.toFixed(1)})}`]}),` · `,c.now.free_gb==null?I(`span`,{className:`cp-unknown`,children:r(`ctx.freeUnknown`)}):r(`env.free`,{gb:c.now.free_gb.toFixed(1)})]})]}),f&&I(`p`,{className:`cp-error`,role:`alert`,children:f}),!c&&!f&&I(`p`,{className:`cp-note`,children:r(`ctx.measuring`)}),c&&m===`turn`&&(b?I(KU,{turn:b}):I(`p`,{className:`cp-note`,children:c.latest_message_id==null?r(`ctx.afterNext`):R(F.Fragment,{children:[r.bare(`ctx.latestAnswer`),` `,I(`span`,{className:`cp-unknown`,children:r(`ctx.unknown`)}),`. `,r.bare(`ctx.notMeasured`)]})})),c&&m===`chat`&&I(JU,{totals:c.totals})]})]})}function ZU({sessionId:e,busy:t,onClose:n,onUsage:r}){let i=L(),a=(0,V.useRef)(null),o=(0,V.useRef)(n);o.current=n,(0,V.useEffect)(()=>{a.current?.focus()},[]);let s=(0,V.useCallback)(()=>o.current(),[]);er(!0,s);let c=(0,V.useRef)(null);return yn(c,!0),I(`div`,{className:`cp-overlay`,onClick:n,children:R(`aside`,{ref:c,className:`cp-sheet`,role:`dialog`,"aria-modal":`true`,"aria-label":i(`ctx.sheetAria`),onClick:e=>e.stopPropagation(),children:[R(`header`,{className:`cp-header`,children:[I(`h2`,{children:i(`sp.section.context`)}),I(`button`,{ref:a,type:`button`,className:`cp-icon`,onClick:n,"aria-label":i(`sp.closeShort`),children:I(bc,{size:16})})]}),I(`div`,{className:`cp-body`,children:I(XU,{sessionId:e,busy:t,onUsage:r})})]})})}function QU(e){return e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(+(e<1e4))}K`:`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`}var $U=[{key:`system`,label:`ctx.meter.part.system`},{key:`tools`,label:`ctx.meter.part.tools`},{key:`documents`,label:`ctx.meter.part.documents`},{key:`history`,label:`ctx.meter.part.history`},{key:`query`,label:`ctx.meter.part.query`}],eW=50;function tW({usage:e,sessionId:t,busy:n=!1,onUsage:r,onDetails:i}){let a=L(),o=(0,V.useRef)(null),[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(!1),d=l&&t?I(ZU,{sessionId:t,busy:n,onUsage:r,onClose:()=>u(!1)}):null;if(!e)return null;let f=Math.min(100,Math.round(e.used/e.window*100)),p=e.at_risk.length>0;if(f<=eW&&!p&&!s&&!d)return null;let m=Math.max(0,e.window-e.used-e.reply_reserve),h=e.model_window!=null&&e.model_window>e.window?e.model_window:null,g=h?{gaia:Sl(e.window),model:Sl(h)}:null,_=e.system+e.tools,v=e.used>0&&_/e.used>=.6?a(`ctx.meter.mostlySetup`,{setup:QU(_),chat:QU(e.history+e.query+e.documents)}):null;return R(`div`,{className:`composer-chip-wrap context-meter-wrap`,children:[R(`button`,{ref:o,type:`button`,className:`context-meter${p?` is-warning`:``}`,onClick:()=>c(e=>!e),"aria-expanded":s,"aria-label":a.compose(t=>{let n=t(`ctx.meter.aria`,{pct:f,used:QU(e.used),window:Sl(e.window)});return g?`${n} (${t(`ctx.meter.capNote`,g)})`:n}),title:[g?a(`ctx.meter.titleCapped`,g):a(`ctx.meter.title`),v].filter(Boolean).join(`
196
+ `),children:[I(`span`,{className:`context-meter-bar`,"aria-hidden":`true`,children:I(`span`,{style:{width:`${f}%`}})}),I(`span`,{className:`context-meter-label`,children:R(`bdi`,{dir:`ltr`,children:[f,`%`]})})]}),I(Mc,{open:s,onClose:()=>c(!1),anchor:o,label:a(`ctx.meter.window`),align:`end`,children:R(`div`,{className:`context-meter-panel`,children:[R(`div`,{className:`context-meter-head`,children:[I(`strong`,{children:I(`bdi`,{dir:`ltr`,children:QU(e.used)})}),` `,a.bare(`ctx.of`),` `,I(`bdi`,{dir:`ltr`,children:Sl(e.window)}),` `,a.bare(`ctx.tokensWord`),g&&R(`span`,{className:`context-meter-cap`,title:a(`ctx.windowTitle`),children:[` · `,a.bare(`ctx.gaiaUses`),` `,I(`bdi`,{dir:`ltr`,children:g.gaia}),` `,a.bare(`ctx.ofModel`),` `,I(`bdi`,{dir:`ltr`,children:g.model})]})]}),v&&I(`p`,{className:`context-meter-note is-setup`,children:v}),I(`div`,{className:`context-meter-stack`,"aria-hidden":`true`,children:$U.map(({key:t})=>I(`span`,{className:`part-${t}`,style:{width:`${e[t]/e.window*100}%`}},t))}),R(`dl`,{className:`context-meter-rows`,children:[$U.filter(({key:t})=>t!==`query`||e.query>0).map(({key:t,label:n})=>R(`div`,{className:`context-meter-row`,children:[R(`dt`,{children:[I(`span`,{className:`swatch part-${t}`,"aria-hidden":`true`}),a(n)]}),I(`dd`,{children:I(`bdi`,{dir:`ltr`,children:QU(e[t])})})]},t)),R(`div`,{className:`context-meter-row is-quiet`,children:[I(`dt`,{children:a(`ctx.meter.reserve`)}),I(`dd`,{children:I(`bdi`,{dir:`ltr`,children:QU(e.reply_reserve)})})]}),R(`div`,{className:`context-meter-row is-quiet`,children:[I(`dt`,{children:a(`ctx.freeRow`)}),I(`dd`,{children:I(`bdi`,{dir:`ltr`,children:QU(m)})})]})]}),I(`p`,{className:`context-meter-note`,children:a.compose(t=>[t(k(`ctx.meter.inView`,e.turns_in_view),{n:e.turns_in_view}),e.turns_hidden>0?t(k(`ctx.meter.hidden`,e.turns_hidden),{n:e.turns_hidden}):``,`. `,t(e.tokenizer?.exact?`ctx.meter.exact`:`ctx.meter.estimates`),` `,t(`ctx.meter.saved`)].join(``))}),t&&I(`button`,{type:`button`,className:`context-meter-details`,onClick:()=>{c(!1),i?i():u(!0)},children:a(`ctx.meter.details`)})]})}),d]})}function nW({usage:e}){let t=L(),[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(null);if(!e||e.at_risk.length===0)return null;let o=e.at_risk.join(`
197
+ `);if(i===o)return null;let s=e.at_risk.length;return R(`div`,{className:`context-warning`,role:`status`,children:[I(cc,{size:13,"aria-hidden":`true`}),R(`div`,{className:`context-warning-body`,children:[I(`span`,{children:t(`ctx.warning.short`)}),` `,I(`button`,{type:`button`,className:`link-btn`,"aria-expanded":n,onClick:()=>r(e=>!e),children:t(n?`ctx.warning.hideDetails`:`ctx.warning.details`)}),n&&R(`p`,{className:`context-warning-details`,children:[t.plural(`ctx.meter.warning`,s),` `,e.at_risk.map((e,t)=>R(`span`,{children:[t>0&&`, `,I(`q`,{children:e})]},t)),`. `,t(`ctx.meter.warningSaved`)]})]}),I(`button`,{type:`button`,className:`btn-icon-sm context-warning-close`,onClick:()=>{a(o),r(!1)},"aria-label":t(`ctx.warning.dismiss`),title:t(`ctx.warning.dismiss`),children:I(bc,{size:12,"aria-hidden":`true`})})]})}function rW(...e){return e.some(e=>e>0&&e<.01)?4:2}function iW(e,t=rW(e)){return`$${e.toFixed(t)}`}function aW(e=new Date){let t=new Date(e);return t.setHours(0,0,0,0),t.toISOString()}function oW({sessionId:e,busy:t}){let n=L(),r=il(e=>e.active),i=z(e=>pl(r,e.sessions,e.currentSessionId)),a=z(e=>e.openSettings),o=(0,V.useRef)(null),[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(null),d=(0,V.useCallback)(()=>c(!1),[]),f=(0,V.useCallback)(()=>{let t=!1;return(async()=>{try{let n=await te(e,aW(),i??null);t||u(n??null)}catch(n){t||P.chat.error(`Could not read cloud spending for session=${e}`,n)}})(),()=>{t=!0}},[e,i]);(0,V.useEffect)(()=>f(),[f]);let p=(0,V.useRef)(t);if((0,V.useEffect)(()=>{let e=p.current&&!t;return p.current=t,e?f():void 0},[t,f]),(0,V.useEffect)(()=>s?f():void 0,[s,f]),(0,V.useEffect)(()=>{let e,t=()=>{e?.(),e=f()};return window.addEventListener(`focus`,t),()=>{window.removeEventListener(`focus`,t),e?.()}},[f]),!l?.paid||l.model!==(i??null))return null;let{chat:m,today:h}=l,g=rW(m.usd,h.usd),_=e=>`${e.unpriced_answers>0?`≥ `:``}${iW(e.usd,g)}`,v=m.unpriced_answers+h.unpriced_answers>0,y=[...m.items].reverse(),b=e=>new Date(e).toLocaleTimeString(Ln(n),{hour:`numeric`,minute:`2-digit`});return R(`div`,{className:`composer-chip-wrap spend-meter-wrap`,children:[R(`button`,{ref:o,type:`button`,className:`context-meter spend-meter`,onClick:()=>c(e=>!e),"aria-expanded":s,"aria-label":n(`spend.aria`,{chat:_(m),today:_(h)}),title:n(v?`spend.titleExcluded`:`spend.title`),children:[I(`bdi`,{dir:`ltr`,children:_(m)}),R(`span`,{className:`spend-meter-today`,children:[`· `,n.bare(`spend.today`),` `,I(`bdi`,{dir:`ltr`,children:_(h)})]})]}),I(Mc,{open:s,onClose:d,anchor:o,label:n(`spend.window`),align:`end`,children:R(`div`,{className:`context-meter-panel spend-meter-panel`,children:[R(`dl`,{className:`context-meter-rows`,children:[R(`div`,{className:`context-meter-row`,children:[I(`dt`,{children:n(`spend.thisChat`)}),I(`dd`,{children:I(`bdi`,{dir:`ltr`,children:_(m)})})]}),R(`div`,{className:`context-meter-row`,children:[I(`dt`,{children:n.plural(`spend.todayChats`,h.chats)}),I(`dd`,{children:I(`bdi`,{dir:`ltr`,children:_(h)})})]})]}),v&&I(`p`,{className:`context-meter-note spend-meter-excluded`,role:`note`,children:n(`spend.excluded`,{chat:m.unpriced_answers,today:h.unpriced_answers})}),y.length>0&&R(F.Fragment,{children:[I(`div`,{className:`spend-meter-heading`,children:n(`spend.perAnswer`)}),I(`dl`,{className:`context-meter-rows spend-meter-answers`,children:y.map(e=>R(`div`,{className:`context-meter-row`,children:[I(`dt`,{children:I(`bdi`,{dir:`ltr`,children:b(e.created_at)})}),I(`dd`,{children:e.kind===`estimate`&&e.usd!=null?I(`bdi`,{dir:`ltr`,children:iW(e.usd)}):I(`span`,{className:`spend-meter-unknown`,children:n(e.kind===`unreported`?`ctx.costUnreported`:`ctx.unknown`)})})]},e.message_id))})]}),I(`p`,{className:`context-meter-note`,children:n(`spend.note`)}),I(`button`,{type:`button`,className:`context-meter-details`,onClick:()=>{c(!1),a(`model`)},children:n(`spend.month`)})]})})]})}function sW(e){return{id:e.id,name:e.display_name??cl(e.id),sizeGb:e.size_gb??null}}async function cW(e){let{providers:t,lemonade_error:n}=await At();if(n)throw Error(n);let r=t.filter(e=>!e.remote).map(e=>Zn(e.id)),i=e?t.find(t=>t.remote&&t.id===e):void 0,[a,...o]=await Promise.all([i?Zn(i.id):Promise.resolve(null),...r]);return{cloud:a&&!a.blocked?a.models.filter(e=>e.available!==!1).map(e=>({...sW(e),sizeGb:null})):[],local:o.flatMap(e=>e.models.filter(e=>e.downloaded).map(sW))}}function lW({answeredBy:e,onPick:t}){let n=(0,V.useRef)(null),r=L(),i=il(e=>e.active),a=i?.remote?i.provider_name??null:null,o=i?.remote?i.provider:null,[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(null),[d,f]=(0,V.useState)(null),p=(0,V.useCallback)(async()=>{u(null),f(null);try{u(await cW(o))}catch(e){f(e instanceof Error?e.message:String(e))}},[o]);(0,V.useEffect)(()=>{s&&p()},[s,p]);let m=l?.cloud.filter(t=>t.id!==e)??[],h=l?.local.filter(t=>t.id!==e)??[],g=(e,n)=>R(`button`,{type:`button`,className:`retry-menu-item`,title:e.id,onClick:()=>{c(!1),t(e.id)},children:[I(`span`,{className:`retry-menu-name`,children:e.name}),I(`span`,{className:`retry-menu-meta`,children:e.sizeGb?R(`bdi`,{dir:`ltr`,children:[e.sizeGb,` GB`]}):n})]},e.id);return R(`span`,{className:`retry-menu-anchor`,children:[I(`button`,{ref:n,type:`button`,className:`msg-action-btn`,onClick:()=>c(e=>!e),title:r(`retry.button`),"aria-label":r(`retry.button`),"aria-expanded":s,children:I(Bs,{size:12})}),I(Mc,{open:s,onClose:()=>c(!1),anchor:n,label:`Retry with`,placement:`below`,align:`start`,children:R(`div`,{className:`retry-menu`,children:[I(`div`,{className:`retry-menu-head`,children:r(`retry.head`)}),d&&I(`div`,{className:`retry-menu-error`,role:`alert`,children:d}),!d&&l===null&&R(`div`,{className:`retry-menu-empty`,children:[I(B,{size:12,className:`spin`,"aria-hidden":`true`}),` `,r(`retry.loading`)]}),m.length>0&&a&&I(`div`,{className:`retry-menu-note`,children:r(`retry.onProvider`,{provider:a})}),m.map(e=>g(e,r(`retry.cloudHint`))),h.length>0&&a&&I(`div`,{className:`retry-menu-note`,children:r(`retry.onThisPc`,{provider:a})}),h.map(e=>g(e,r(`retry.localHint`))),l!==null&&m.length===0&&h.length===0&&I(`div`,{className:`retry-menu-empty`,children:r(`retry.none`)})]})})]})}function uW(e,t){return El(e(`answer.duration.sec`,{n:t.toFixed(1)}))}function dW(e,t){return t?El(e(`compare.rate`,{n:t})):null}function fW({parts:e}){let t=e.filter(e=>!!e);return t.length?I(`div`,{className:`compare-meta`,children:t.map((e,t)=>R(`span`,{children:[t>0&&` · `,I(kl,{text:e})]},t))}):null}function pW({original:e,originalModel:t,originalLatencyMs:n,state:r,keeping:i,onKeep:a,onClose:o}){ol();let s=L(),c=r.status===`ready`?r.result.model:r.model,l=e.stats?.tokens_per_second;return R(`section`,{className:`answer-compare`,"aria-label":s(`compare.title`),children:[R(`header`,{className:`answer-compare-head`,children:[I(`span`,{children:s(`compare.title`)}),I(`button`,{type:`button`,className:`msg-action-btn`,onClick:o,"aria-label":s(`compare.close`),disabled:!!i,children:I(bc,{size:12})})]}),R(`div`,{className:`answer-compare-cols`,children:[R(`article`,{className:`compare-col`,"aria-label":s(`compare.answerFrom`,{model:t??de(`compare.originalModel`)}),children:[I(`h4`,{children:t?cl(t):s(`compare.original`)}),I(fW,{parts:[n!=null&&n>0?uW(s,n/1e3):null,dW(s,l)]}),I(`div`,{className:`compare-body`,children:I(mB,{content:e.content})}),I(`button`,{type:`button`,className:`compare-keep`,onClick:()=>a(`original`),disabled:!!i||r.status===`running`,children:s(i===`original`?`compare.keeping`:`compare.keep`)})]}),R(`article`,{className:`compare-col`,"aria-label":s(`compare.answerFrom`,{model:c}),children:[I(`h4`,{children:cl(c)}),r.status===`running`&&R(`div`,{className:`compare-wait`,children:[I(B,{size:14,className:`spin`,"aria-hidden":`true`}),I(`span`,{children:s(`compare.loading`,{model:cl(c)})})]}),r.status===`failed`&&I(`div`,{className:`compare-error`,role:`alert`,children:r.error}),r.status===`ready`&&R(F.Fragment,{children:[I(fW,{parts:[uW(s,r.result.stats.seconds),r.result.stats.load_seconds>=1?s.compose(e=>e(`compare.loadTime`,{time:El(e(`answer.duration.sec`,{n:r.result.stats.load_seconds.toFixed(1)}))})):null,dW(s,r.result.stats.tokens_per_second)]}),I(`div`,{className:`compare-body`,children:I(mB,{content:r.result.content})}),I(`button`,{type:`button`,className:`compare-keep`,onClick:()=>a(`retry`),disabled:!!i,children:s(i===`retry`?`compare.keeping`:`compare.keep`)})]})]})]})]})}var mW=2e3,hW=9e4;function gW(){let e=L(),[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(`idle`),[s,c]=(0,V.useState)(null),l=(0,V.useRef)(!0),u=(0,V.useCallback)(async()=>{try{let e=await re();return l.current&&n(e),e}catch(e){return l.current&&c(e instanceof Error?e.message:String(e)),null}},[]);(0,V.useEffect)(()=>(l.current=!0,u(),Xe().then(e=>{l.current&&i(e)}).catch(e=>{l.current&&c(e instanceof Error?e.message:String(e))}),()=>{l.current=!1}),[u]);let d=(0,V.useCallback)(async()=>{c(null);let e=await u();e&&o(e.state===`stopped`?`still_down`:`back`)},[u]),f=(0,V.useCallback)(async()=>{o(`starting`),c(null);try{await cn(!1)}catch(e){if(!l.current)return;c(e instanceof Error?e.message:String(e)),o(`idle`);return}let e=Date.now()+hW;for(;l.current&&Date.now()<e;){await new Promise(e=>setTimeout(e,mW));let e=await u();if(!l.current)return;if(e?.restart_error){c(e.restart_error),o(`idle`);return}if(e&&e.state!==`stopped`&&!e.restarting){o(`back`);return}}l.current&&o(`still_down`)},[u]),p=(0,V.useCallback)(async()=>{o(`switching`),c(null);try{let e=await ge({mode:`gaia`});if(!l.current)return;i(e),o(`back`)}catch(e){if(!l.current)return;c(e instanceof Error?e.message:String(e)),o(`idle`)}},[]),m=a===`starting`||a===`switching`,h=t?.owner===`gaia`,g=!h&&r?.mode===`external`&&r.source!==`env`;return a===`back`?I(`div`,{className:`server-down-notice server-down-notice--ok`,role:`status`,children:I(`p`,{children:e(`serverDown.back`)})}):R(`div`,{className:`server-down-notice`,role:`alert`,children:[R(`strong`,{className:`server-down-notice__title`,children:[I(cc,{size:14,"aria-hidden":`true`}),` `,e(`serverDown.title`)]}),I(`p`,{children:e(`serverDown.body`)}),t&&!h&&!g&&I(`p`,{children:e(`serverDown.notOurs`)}),a===`still_down`&&I(`p`,{children:e(`serverDown.stillDown`)}),s&&I(`p`,{children:I(`bdi`,{dir:`ltr`,className:`server-down-notice__raw`,children:s})}),R(`div`,{className:`server-down-notice__actions`,children:[h&&I(`button`,{type:`button`,className:`btn-primary`,disabled:m,onClick:()=>void f(),children:a===`starting`?R(F.Fragment,{children:[I(B,{size:13,className:`btn-spinner`,"aria-hidden":`true`}),` `,e(`serverDown.starting`)]}):e(`serverDown.start`)}),g&&I(`button`,{type:`button`,className:`btn-primary`,disabled:m,onClick:()=>void p(),children:a===`switching`?R(F.Fragment,{children:[I(B,{size:13,className:`btn-spinner`,"aria-hidden":`true`}),` `,e(`serverDown.switching`)]}):e(`serverDown.useOwn`)}),I(`button`,{type:`button`,className:`btn-secondary`,disabled:m,onClick:()=>void d(),children:e(`settings.key.checkAgain`)})]})]})}var _W=1e3,vW=e=>e instanceof Error?e.message:String(e),yW={gaiacpp_update_chat_busy:`setup.agent.refused.updateChatBusy`,gaiacpp_update_setup_busy:`setup.agent.refused.updateSetupBusy`,gaiacpp_already_installed:`setup.agent.refused.alreadyInstalled`};function bW(e){let[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(!1),a=(0,V.useRef)(e);a.current=e;let o=(0,V.useRef)(!1),s=(0,V.useRef)(!1),c=(0,V.useCallback)(async()=>{o.current=!1,s.current=!0,i(!1),n({state:`downloading`,bytes_done:0,bytes_total:null,error:null});try{n(await d())}catch(e){let t=e instanceof On&&e.reason?yW[e.reason]:void 0;n(t?{state:`failed`,bytes_done:0,bytes_total:null,error:null,refusal:t}:{state:`failed`,bytes_done:0,bytes_total:null,error:vW(e)})}},[]),l=(0,V.useCallback)(e=>{e.state===`downloading`&&(o.current=!1,s.current=!1,i(!1),n(e))},[]),u=t?.state;return(0,V.useEffect)(()=>{if(u!==`downloading`)return;let e=!0,t=setTimeout(()=>{be().then(t=>{e&&(t.state===`idle`?(i(!0),n(e=>({...e??t,state:`failed`,error:null}))):n(t))}).catch(t=>{e&&n(e=>({...e??{bytes_done:0,bytes_total:null},state:`failed`,error:vW(t)}))})},_W);return()=>{e=!1,clearTimeout(t)}},[t,u]),(0,V.useEffect)(()=>{u!==`done`||o.current||(o.current=!0,a.current(s.current))},[u]),{job:t,start:c,follow:l,interrupted:r}}function xW(e,t){return e.state===`done`?t(`setup.state.ready`):e.state===`failed`?t(`setup.state.failed`):t(`setup.state.downloading`)}function SW({job:e,name:t,onRetry:n,failedNote:r,interrupted:i=!1}){let a=L(),o=(0,V.useId)(),s=e.bytes_total??0,c=e.state===`done`?100:s>0?Math.min(100,e.bytes_done/s*100):0,l=xW(e,a),u=s>0?`${XA(e.bytes_done)} / ${XA(s)}`:XA(e.bytes_done);return I(`ul`,{className:`dl-list agent-download`,children:R(`li`,{className:`dl-row is-${e.state===`done`?`ready`:e.state}${e.state===`downloading`?` is-live`:``}`,children:[R(`div`,{className:`dl-row-head`,children:[I(`span`,{className:`dl-icon`,"aria-hidden":`true`,children:e.state===`done`?I(ci,{size:14}):e.state===`failed`?I(wi,{size:14}):I(`span`,{className:`dl-dot`})}),I(`span`,{className:`dl-name`,children:I(`bdi`,{dir:`ltr`,children:t})}),I(`span`,{className:`dl-state`,children:l}),e.state===`downloading`&&R(`bdi`,{className:`dl-pct`,children:[Math.floor(c),`%`]})]}),I(`div`,{className:`dl-track`,role:`progressbar`,"aria-label":a(`setup.progress.rowLabel`,{name:t,state:l}),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.floor(c),"aria-valuetext":s>0?a(`setup.progress.of`,{done:XA(e.bytes_done),total:XA(s)}):l,children:I(`span`,{className:`dl-fill`,style:{inlineSize:`${c}%`}})}),e.state===`downloading`&&I(`p`,{className:`dl-detail`,children:I(`bdi`,{children:QA(a.locale,u)})}),e.state===`failed`&&R(`div`,{className:`dl-fail`,role:`alert`,children:[I(`p`,{className:`dl-error`,id:o,children:a(`setup.agent.downloadFailed`,{name:t})}),i&&I(`p`,{className:`dl-detail`,children:a(`setup.agent.downloadInterrupted`)}),e.refusal&&I(`p`,{className:`dl-detail`,children:a(e.refusal)}),r&&I(`p`,{className:`dl-detail`,children:r}),e.error&&R(`details`,{className:`dl-details`,children:[I(`summary`,{children:a(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:e.error})]}),I(`div`,{className:`setup-row`,children:R(`button`,{type:`button`,className:`btn-primary`,onClick:n,"aria-describedby":o,children:[I(bs,{size:13,"aria-hidden":`true`}),` `,a(`setup.progress.retry`)]})})]})]})})}var CW=[{id:`gaiapy`,label:`setup.agent.gaiapy`,more:`setup.agent.gaiapyMore`,tag:`setup.offer.recommended`},{id:`gaiacpp`,label:`setup.agent.gaiacpp`,more:`setup.agent.gaiacppMore`,tag:`setup.agent.beta`}],wW=[`setup.agent.diff.memory`,`setup.agent.diff.undo`,`setup.agent.diff.search`,`setup.agent.diff.media`,`setup.agent.diff.context`],TW={no_release:`setup.agent.why.noRelease`,unreachable:`setup.agent.why.unreachable`,unverifiable:`setup.agent.why.unverifiable`},EW={agent_switch_chat_busy:`setup.agent.error.chatBusy`,agent_switch_setup_busy:`setup.agent.error.setupBusy`,gaiacpp_not_installed:`setup.agent.error.notInstalled`},DW=e=>e instanceof Error?e.message:String(e);function OW(e){if(e instanceof On&&e.reason){let t=EW[e.reason];if(t)return de(t);if(e.reason===`agent_stop_failed`&&typeof e.body?.agent==`string`&&typeof e.body?.error==`string`)return de(`setup.agent.error.stopFailed`,{agent:e.body.agent,error:e.body.error})}return DW(e)}function kW({inSettings:e=!1,disabled:t=!1,pending:n=null,onPending:r,headingId:i}){let a=L(),o=(0,V.useId)(),s=i??`${o}-title`,c=`${o}-more`,l=`${o}-off`,u=`${o}-old`,[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(!1),x=(0,V.useRef)(!0),S=(0,V.useCallback)(async(e,t)=>{v(!0),g(null),f(t=>t&&{...t,current:e});try{let t=await Pn({flagship_agent:e});pH.getState().setCurrent(t.flagship_agent),x.current&&f(e=>e&&{...e,current:t.flagship_agent})}catch(e){if(!x.current)return;g(OW(e));let n=e instanceof On&&(e.httpStatus===422||e.httpStatus===409)?null:await ke().catch(()=>null);x.current&&f(e=>n??(e&&{...e,current:t}))}finally{x.current&&v(!1)}},[]),C=(0,V.useRef)(`gaiapy`);C.current=d?.current??`gaiapy`;let w=(0,V.useRef)(!1),{job:T,start:E,follow:ee,interrupted:D}=bW(e=>{let t=C.current;ke().then(e=>{x.current&&f(e)},e=>console.warn(`[AgentChoice] could not re-read the agents after the download`,e)).then(()=>{x.current&&e&&w.current&&S(`gaiacpp`,t)})}),O=e=>{w.current=e,E()};(0,V.useEffect)(()=>(x.current=!0,ke().then(t=>{x.current&&(f(t),e&&ee(t.download))}).catch(e=>{x.current&&m(DW(e))}),()=>{x.current=!1}),[e,ee]);let te=e=>d?.programs.find(t=>t.id===e),k=e=>e.id===`gaiapy`||e.installed,A=e=>!!e&&!k(e)&&!e.can_download,ne=t=>!!t&&e&&!k(t)&&t.can_download,j=e=>!!e&&e.id===`gaiacpp`&&e.installed&&e.update_available===!0&&e.can_download,M=T?.state===`downloading`,re=n??d?.current,ie=n=>{let i=te(n);d&&i&&!t&&!A(i)&&(e?_||M||ne(i)||n!==d.current&&S(n,d.current):r?.(n===d.current?null:{id:n,download:!k(i),current:d.current}))},ae=te(`gaiacpp`),oe=j(ae)?ae?.version&&ae.release_version?a(`setup.agent.outdated`,{name:`gaiacpp`,found:ae.version,expected:ae.release_version}):a(`setup.agent.outdatedNoVersion`,{name:`gaiacpp`}):null,se=ae?.unavailable_code?a(TW[ae.unavailable_code]):ae?.unavailable_reason,ce=!ae||k(ae)?null:ae.can_download?a(e?`setup.agent.downloadsOnButton`:`setup.agent.downloadsLater`):se?a(`setup.agent.cantDownload`,{reason:se}):a(`setup.agent.notInstalledMore`);return R(`section`,{className:`agent-choice${e?` settings-card`:``}`,"aria-labelledby":s,"aria-busy":_||M||!d&&!p,children:[R(`h3`,{className:`agent-choice-title ${e?`settings-label`:`mc-job-title`}`,id:s,tabIndex:i?-1:void 0,children:[a(`setup.agent.title`),_&&I(B,{size:13,className:`spin`,"aria-hidden":`true`})]}),p&&I(`p`,{className:`agent-choice-error`,role:`alert`,children:a(`setup.agent.loadFailed`,{error:p})}),d&&R(F.Fragment,{children:[I(sF,{className:`setup-choices`,"aria-labelledby":s,children:CW.map(n=>{let r=te(n.id),i=A(r),o=ne(r),s=j(r),c=s&&!M&&T?.state!==`failed`,d=R(`button`,{type:`button`,role:`radio`,"aria-checked":re===n.id,"aria-disabled":i||o||t||void 0,"aria-describedby":i||o?l:s?u:void 0,className:`setup-choice agent-choice-row${re===n.id?` is-active`:``}${i?` is-disabled`:``}${o?` is-pending`:``}`,onClick:()=>ie(n.id),children:[R(`span`,{className:`agent-choice-what`,children:[I(`span`,{className:`agent-choice-label`,children:a(n.label)}),I(`bdi`,{dir:`ltr`,className:`agent-choice-name`,children:n.id}),r?.size_bytes!=null&&I(`bdi`,{dir:`ltr`,className:`agent-choice-size`,children:XA(r.size_bytes)})]}),I(`span`,{className:`setup-choice-tag`,children:a(n.tag)}),i&&I(`span`,{className:`setup-choice-tag agent-choice-off`,children:a(`setup.agent.notInstalled`)}),s&&!c&&I(`span`,{className:`setup-choice-tag agent-choice-off`,children:a(`setup.agent.outOfDate`)}),r&&!k(r)&&!i&&!e&&I(`span`,{className:`setup-choice-tag agent-choice-off is-quiet`,children:a(`settings.model.notDownloaded`)})]},n.id);if(i)return R(`div`,{className:`agent-choice-blocked`,children:[d,I(`p`,{id:l,className:`agent-choice-why`,dir:`auto`,children:ce})]},n.id);if(s){let e=!M&&T?.state!==`failed`;return R(`div`,{className:`agent-choice-blocked`,children:[R(`div`,{className:e?`agent-choice-item`:void 0,children:[d,e&&R(`button`,{type:`button`,className:`btn-secondary agent-choice-download`,onClick:()=>O(!1),disabled:_||t,"aria-label":a(`setup.agent.updateNamed`,{name:n.id}),children:[I(Ji,{size:13,"aria-hidden":`true`}),` `,a(`setup.agent.update`)]})]}),I(`p`,{id:u,className:`agent-choice-why`,children:oe})]},n.id)}return!o||M||T?.state===`failed`?d:R(`div`,{className:`agent-choice-item`,children:[d,R(`button`,{type:`button`,className:`btn-secondary agent-choice-download`,onClick:()=>O(!0),disabled:_||t,"aria-label":a(`setup.agent.downloadNamed`,{name:n.id}),children:[I(Ji,{size:13,"aria-hidden":`true`}),` `,a(`setup.agent.download`)]})]},n.id)})}),T&&(T.state===`downloading`||T.state===`failed`)&&I(SW,{job:T,name:`gaiacpp`,onRetry:()=>void E(),failedNote:a(`setup.agent.stays`,{name:d.current}),interrupted:D}),R(`button`,{type:`button`,className:`agent-choice-more`,"aria-expanded":y,"aria-controls":c,onClick:()=>b(e=>!e),children:[I(fi,{size:13,className:`agent-choice-chevron${y?` is-open`:``}`,"aria-hidden":`true`}),` `,a(`setup.agent.compare`)]}),R(`div`,{id:c,className:`agent-choice-detail`,hidden:!y,children:[CW.map(e=>I(`p`,{children:a(e.more,{name:e.id})},e.id)),I(`ul`,{className:`agent-choice-diffs`,children:wW.map(e=>I(`li`,{children:a(e,{name:`gaiacpp`,other:`gaiapy`})},e))}),ce&&!A(ae)&&I(`p`,{id:l,children:ce}),I(`p`,{children:a(e?`settings.agent.nextMessage`:`setup.agent.hint`)})]})]}),h&&I(`p`,{className:`agent-choice-error`,role:`alert`,children:a(`setup.agent.saveFailed`,{error:h})})]})}var AW=`gaiacpp`;function jW({problem:e,onRetry:t,kept:n=!1,onBusy:r,nested:i=!1}){let a=L(),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(null),[f,p]=(0,V.useState)(!1),[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)(!1),v=(0,V.useRef)(!0),y=(0,V.useRef)(t);y.current=t;let{job:b,start:x,follow:S,interrupted:C}=bW(()=>{v.current&&(_(!0),y.current())});(0,V.useEffect)(()=>(v.current=!0,ke().then(e=>{v.current&&(l(e.programs.find(e=>e.id===AW)??null),S(e.download))}).catch(e=>{P.api.warn(`Could not read whether gaiacpp can be downloaded`,e),v.current&&d(BF(e))}),()=>{v.current=!1}),[S]),(0,V.useEffect)(()=>_(!1),[e]);let w=async()=>{p(!0),h(null);try{let e=await ke();if(!v.current)return;if(e.programs.find(e=>e.id===`gaiapy`)?.installed!==!0){h(de(`newChat.agent.pythonMissing`,{name:AW}));return}if(await Pn({flagship_agent:`gaiapy`}),pH.getState().setCurrent(`gaiapy`),!v.current)return;_(!0),t()}catch(e){v.current&&h(BF(e))}finally{v.current&&p(!1)}},T=b?.state===`downloading`,E=T||f||g,ee=(0,V.useRef)(r);ee.current=r,(0,V.useEffect)(()=>ee.current?.(E),[E]);let D=c?.can_download===!0,O=!c||c.can_download?null:c.unavailable_code?de(TW[c.unavailable_code]):c.unavailable_reason;return R(`div`,{className:`new-chat-setup-failed agent-recovery`,role:i?void 0:`alert`,children:[I(`p`,{className:`new-chat-setup-failed-title`,children:a(e.code===`gaiacpp_invalid`?`newChat.agent.invalid`:`newChat.agent.missing`,{name:AW})}),n&&I(`p`,{children:a(`newChat.agent.kept`)}),O&&I(`p`,{className:`new-chat-setup-failed-error`,children:a(`newChat.agent.cantDownload`,{name:AW,reason:O})}),u&&I(`p`,{className:`new-chat-setup-failed-error`,children:a(`newChat.agent.checkFailed`,{name:AW,error:u})}),b&&b.state!==`idle`&&I(SW,{job:b,name:AW,onRetry:()=>void x(),interrupted:C}),g&&!T&&R(`p`,{className:`agent-recovery-status`,role:`status`,children:[I(B,{size:13,className:`spin`,"aria-hidden":`true`}),` `,a(`newChat.agent.starting`)]}),R(`div`,{className:`agent-recovery-actions`,children:[D&&!b&&R(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void x(),disabled:E,children:[I(Ji,{size:13,"aria-hidden":`true`}),` `,a(`newChat.agent.downloadAgain`,{name:AW})]}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void w(),disabled:E,children:a(`newChat.agent.usePython`)})]}),m&&I(`p`,{className:`new-chat-setup-failed-error`,children:a(`newChat.agent.switchFailed`,{error:m})}),R(`button`,{type:`button`,className:`new-chat-details`,"aria-expanded":o,onClick:()=>s(e=>!e),children:[I(gi,{size:12,className:o?`is-open`:``,"aria-hidden":`true`}),` `,a(`newChat.details`)]}),o&&I(`pre`,{className:`new-chat-details-text`,dir:`ltr`,children:e.detail})]})}function MW({onTryAgain:e,otherwise:t=null,onProblem:n}){let[r,i]=(0,V.useState)(void 0);return(0,V.useEffect)(()=>{let e=!0;return _t().then(t=>{e&&i(t.agent_problem??null)}).catch(t=>{P.api.warn(`Could not check whether the chosen agent can start`,t),e&&i(null)}),()=>{e=!1}},[]),(0,V.useEffect)(()=>{r!==void 0&&n?.(r!==null)},[r,n]),r===void 0?null:r===null?I(F.Fragment,{children:t}):I(`div`,{className:`chat-agent-recovery`,children:I(jW,{problem:r,onRetry:e})})}var NW=`gaiacpp`;function PW(){let e=L(),t=z(e=>e.openSettings),[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(!1),[o,s]=(0,V.useState)(null),c=(0,V.useRef)(!0);(0,V.useEffect)(()=>(c.current=!0,()=>{c.current=!1}),[]);let l=async()=>{r(!0),s(null);try{let e=await ke();if(!c.current)return;if(e.programs.find(e=>e.id===`gaiapy`)?.installed!==!0){s(de(`newChat.agent.pythonMissing`,{name:NW}));return}await Pn({flagship_agent:`gaiapy`}),pH.getState().setCurrent(`gaiapy`),c.current&&a(!0)}catch(e){c.current&&s(BF(e))}finally{c.current&&r(!1)}};return i?I(`div`,{className:`server-down-notice server-down-notice--ok native-agent-notice`,role:`status`,children:I(`p`,{children:e(`nativeFailed.switched`)})}):R(`div`,{className:`server-down-notice native-agent-notice`,role:`note`,children:[I(`p`,{children:e(`nativeFailed.body`,{name:NW})}),o&&I(`p`,{role:`alert`,children:e(`newChat.agent.switchFailed`,{error:o})}),R(`div`,{className:`server-down-notice__actions`,children:[R(`button`,{type:`button`,className:`btn-secondary`,disabled:n,onClick:()=>void l(),children:[n&&I(B,{size:13,className:`btn-spinner`,"aria-hidden":`true`}),` `,e(`newChat.agent.usePython`)]}),R(`button`,{type:`button`,className:`link-btn native-agent-notice__settings`,disabled:n,onClick:()=>t(`model`),children:[I(As,{size:12,"aria-hidden":`true`}),` `,e.compose(e=>e(`failedTurn.openSettings`,{tab:e(`settings.section.model`)}))]})]})]})}var FW=new Set([`model_server_down`,`model_unavailable`]),IW=(0,V.memo)(function({message:e,className:t,notice:n,busy:r,readOnly:i,unsent:a,isLast:o,comparing:s,comparison:c,laterCount:l,latencyMs:u,answeredBy:d,editing:f,editDraft:p,onDelete:m,onResend:h,onEditStart:g,onEditDraft:_,onEdit:v,onEditCancel:y,onRegenerate:b,onRetryWith:x,onTryAgain:S,onContinue:C,onKeepAnswer:w,onCloseComparison:T}){let E=e.role===`assistant`&&Bz(e.content,e.stopState)===`interrupted`,ee=e.role===`assistant`&&e.stopState===`stopped`&&!e.stopError,D=(e.failed===!0||E||ee)&&!r&&!i&&o,O=!D&&!r&&!s&&!i&&e.role===`assistant`&&o&&!e.stopState&&!e.failed&&!vz(e.content),te=!r&&!a&&e.role===`user`&&!i,k=e.stats?.model??d,A=e.failed===!0&&!(e.failure&&FW.has(e.failure)),ne=A&&D,j=A&&e.agentProgram===`gaiacpp`&&o&&!r,[M,re]=(0,V.useState)(!1),ie=ne&&M;return R(`div`,{className:t,"data-message-id":e.id,"data-role":e.role,children:[n&&I(TU,{text:n}),e.libraryNotices&&e.libraryNotices.length>0&&I(EU,{notices:e.libraryNotices}),!ie&&I(Wz,{message:e,agentSteps:e.role===`assistant`?e.agentSteps:void 0,onDelete:!r&&!a?m:void 0,onResend:te?h:void 0,onEditStart:te?()=>g(e.id):void 0,editing:f,editDraft:p,onEditDraft:_,onEdit:v,onEditCancel:y,laterCount:l,onRegenerate:O&&!a?()=>b(e):void 0,extraActions:O?I(lW,{answeredBy:k,onPick:t=>x(e,t)}):void 0,onTryAgain:D?()=>S(e):void 0,onContinue:D&&ee?C:void 0,latest:e.role===`assistant`&&o,latencyMs:u}),e.failure===`model_server_down`&&o&&!r&&I(gW,{}),ne?I(MW,{onTryAgain:()=>S(e),onProblem:re,otherwise:j?I(PW,{}):null},e.id):j&&I(PW,{}),c&&I(pW,{original:e,originalModel:k,originalLatencyMs:u,state:c.state,keeping:c.keeping,onKeep:w,onClose:T})]})}),LW=16;function RW({width:e,setWidth:t,clamp:n,min:r,max:i,defaultWidth:a}){let[o,s]=(0,V.useState)(null),c=(0,V.useCallback)(r=>{if(r.button!==0)return;r.preventDefault();let i=r.clientX,a=e,o=r.currentTarget;o.setPointerCapture?.(r.pointerId);let c=getComputedStyle(o).direction===`rtl`?-1:1,l=a,u=e=>{l=n(a+c*(i-e.clientX)),s(l)},d=()=>{o.removeEventListener(`pointermove`,u),o.removeEventListener(`pointerup`,d),o.removeEventListener(`pointercancel`,d),s(null),t(l)};o.addEventListener(`pointermove`,u),o.addEventListener(`pointerup`,d),o.addEventListener(`pointercancel`,d)},[n,t,e]),l=(0,V.useCallback)(n=>{let a=getComputedStyle(n.currentTarget).direction===`rtl`?-16:LW,o={ArrowLeft:e+a,ArrowRight:e-a,Home:r,End:i}[n.key];o!==void 0&&(n.preventDefault(),t(o))},[i,r,t,e]),u=o??e;return{width:u,dragging:o!==null,separatorProps:{role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":r,"aria-valuemax":i,"aria-valuenow":u,tabIndex:0,onPointerDown:c,onKeyDown:l,onDoubleClick:()=>t(a)}}}function zW(e,t){if(t)return e.some(e=>e.turnSummary)?{kind:`busy`}:null;let n=e[e.length-1];return!n||n.role!==`assistant`||!n.turnSummary?null:{kind:`turn`,turn:n}}function BW(e){let t=e.live_data?.attempted??0;return t>0&&(e.live_data?.failed??0)>=t}function VW(e){try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}}function HW(e,t,n){let r=[];return t&&t.length>0&&r.push(e(k(`rail.pages`,t.length),{list:t.join(`, `)})),r.push(e(k(`rail.passages`,n),{n})),r.join(` · `)}function UW(e,t=gt,n=!1){let{cost:r}=e;return r.kind===`local`?t(`rail.costLocal`):r.kind===`no_reply`?t(`rail.costNoReply`):r.kind===`unreported`?t(n?`rail.costUnreportedStopped`:`rail.costUnreported`):r.kind===`estimate`&&typeof r.usd==`number`?t(`rail.costAbout`,{usd:`$${r.usd<.01?r.usd.toFixed(4):r.usd.toFixed(2)}`}):t(e.model?`rail.costUnknownModel`:`rail.costUnknown`)}function WW(e){return e instanceof On?e.detail||e.message:e instanceof Error?e.message:String(e)}function GW({messages:e,busy:t=!1}){let n=L(),r=zW(e,t);if(!r)return null;let i=r.kind===`turn`?r.turn.turnSummary??null:null;if(!i)return null;let a=BW(i);return R(`div`,{className:`side-rail-body`,children:[a&&R(`div`,{className:`side-rail-warn`,role:`status`,children:[I(cc,{size:14,"aria-hidden":`true`}),R(`div`,{children:[I(`strong`,{children:n(`rail.noLive`)}),I(`span`,{children:n(`rail.noLiveWhy`)})]})]}),i&&(i.error?I(`p`,{className:`side-rail-error`,role:`alert`,children:n(`rail.error`,{error:i.error})}):R(F.Fragment,{children:[I(qW,{summary:i}),I(XW,{summary:i}),I(QW,{summary:i,stopped:r.kind===`turn`&&!!r.turn.stopState,alone:(i.pages??[]).length===0&&(i.documents??[]).length===0&&(i.files??[]).length===0})]}))]})}function KW({title:e,children:t}){return R(`section`,{className:`side-rail-section`,children:[I(`h4`,{className:`side-rail-section-head`,children:e}),I(`div`,{className:`side-rail-section-body`,children:t})]})}function qW({summary:e}){let t=L(),n=e.pages??[],r=e.documents??[];return n.length===0&&r.length===0?null:I(KW,{title:t(`rail.sources`),children:R(`ul`,{className:`side-rail-list`,children:[n.map(e=>R(`li`,{className:`side-rail-item`,children:[I(Ha,{size:13,className:`side-rail-item-icon`,"aria-hidden":`true`}),R(`div`,{className:`side-rail-item-text`,children:[R(`a`,{href:yy(e.url)||void 0,target:`_blank`,rel:`noopener noreferrer`,className:`side-rail-link`,title:e.url,children:[I(`span`,{className:`side-rail-link-text`,children:e.title||VW(e.url)}),I(na,{size:10,"aria-hidden":`true`,className:`side-rail-link-icon`})]}),R(`span`,{className:`side-rail-meta`,children:[VW(e.url),e.kind===`search_result`?` · ${t(`rail.searchResult`)}`:``]})]})]},e.url)),r.map(e=>{let n=e.passages??0;return R(`li`,{className:`side-rail-item`,children:[I(Sa,{size:13,className:`side-rail-item-icon`,"aria-hidden":`true`}),R(`div`,{className:`side-rail-item-text`,children:[I(`span`,{className:`side-rail-name`,title:kd(e.name),dir:`ltr`,children:kd(e.name)}),I(`span`,{className:`side-rail-meta`,children:t.compose(t=>HW(t,e.pages,n))})]})]},e.path)})]})})}var JW=4e3;function YW(e){let t=e.join(`
198
+ `),[n,r]=(0,V.useState)(()=>new Map),[i,a]=(0,V.useState)(null);return(0,V.useEffect)(()=>{if(!t)return;let e=t.split(`
199
+ `),n=!1,i=()=>{document.visibilityState!==`hidden`&&br(e).then(e=>{n||(r(new Map(e.files.map(e=>[e.path,e]))),a(null))},e=>{n||(P.ui.warn(`Could not re-check the files this turn wrote`,e),a(WW(e)))})};i();let o=window.setInterval(i,JW);return window.addEventListener(`focus`,i),()=>{n=!0,window.clearInterval(o),window.removeEventListener(`focus`,i)}},[t]),{status:n,error:i}}function XW({summary:e}){let t=L(),n=e.files??[],[r,i]=(0,V.useState)(null),{status:a,error:o}=YW(n.map(e=>e.path));if(n.length===0)return null;let s=(e,n)=>{i(null),e.catch(e=>{P.ui.error(`Failed to open ${n}`,e),i(t(`sp.couldntOpen`,{name:n,error:WW(e)}))})};return R(KW,{title:t(`rail.files`),children:[I(`ul`,{className:`side-rail-list`,children:n.map(e=>{let n=a.get(e.path);if(n?.exists===!1)return R(`li`,{className:`side-rail-item side-rail-item-gone`,children:[I(Sa,{size:13,className:`side-rail-item-icon`,"aria-hidden":`true`}),R(`div`,{className:`side-rail-item-text`,children:[I(`span`,{className:`side-rail-name`,title:kd(e.path),children:kd(e.name)}),I(`span`,{className:`side-rail-meta`,children:t(`sp.gone`)})]})]},e.path);let r=n?.exists===!0&&typeof n.mtime==`number`&&typeof e.mtime==`number`&&n.mtime!==e.mtime;return R(`li`,{className:`side-rail-item`,children:[I(Sa,{size:13,className:`side-rail-item-icon`,"aria-hidden":`true`}),R(`div`,{className:`side-rail-item-text`,children:[I(`span`,{className:`side-rail-name`,title:kd(e.path),children:kd(e.name)}),r&&I(`span`,{className:`side-rail-meta`,children:t(`rail.changedSince`)}),R(`span`,{className:`side-rail-actions`,children:[e.openable&&I(`button`,{type:`button`,className:`side-rail-action`,onClick:()=>s(mt(e.path),kd(e.name)),children:t(`sp.open`)}),R(`button`,{type:`button`,className:`side-rail-action`,onClick:()=>s(nr(e.path,!0),kd(e.name)),children:[I(Ea,{size:11,"aria-hidden":`true`}),t(`sp.showInFolder`)]})]})]})]},e.path)})}),r&&I(`p`,{className:`side-rail-error`,role:`alert`,children:r}),o&&I(`p`,{className:`side-rail-error`,children:t(`rail.checkFailed`,{error:o})})]})}function ZW(e){return!!e.error||BW(e)||(e.pages??[]).length>0||(e.documents??[]).length>0||(e.files??[]).length>0||(e.sites??[]).length>0||e.model?.remote!==!1||e.cost.kind!==`local`}function QW({summary:e,stopped:t,alone:n}){let r=L();ol();let{model:i}=e,a=e.sites??[],o=(e.documents??[]).length>0,s=i?.remote===!0,c=e.cost.kind!==`local`;if(i&&!s&&!o&&a.length===0&&!c)return null;let l=R(`dl`,{className:`side-rail-facts`,children:[s&&R(F.Fragment,{children:[I(`dt`,{children:r(`rail.model`)}),R(`dd`,{children:[R(`span`,{className:`side-rail-where remote`,children:[I(Pi,{size:12,"aria-hidden":`true`}),r(`rail.cloudModel`,{name:i.provider_name})]}),i.name&&I(`span`,{className:`side-rail-meta`,title:i.name,dir:`ltr`,children:cl(i.name)})]})]}),!i&&R(F.Fragment,{children:[I(`dt`,{children:r(`rail.model`)}),I(`dd`,{children:I(`span`,{className:`side-rail-where`,children:r(`rail.notReported`)})})]}),o&&R(F.Fragment,{children:[I(`dt`,{children:r(`rail.documents`)}),I(`dd`,{children:s?r(`rail.docsSent`,{provider:i.provider_name}):r(i?`rail.docsLocal`:`rail.docsSearched`)})]}),a.length>0&&R(F.Fragment,{children:[I(`dt`,{children:r(`rail.websites`)}),I(`dd`,{children:I(`span`,{dir:`ltr`,children:a.join(`, `)})})]}),c&&R(F.Fragment,{children:[I(`dt`,{children:r(`rail.cost`)}),I(`dd`,{children:UW(e,r,t)})]})]});return n?l:I(KW,{title:r(`rail.thisTurn`),children:l})}var $W=`(prefers-reduced-motion: reduce)`;function eG(e){let t=getComputedStyle(document.documentElement).getPropertyValue(e).trim(),n=/^([\d.]+)(ms|s)$/.exec(t);if(!n)throw Error(`Motion token ${e} is "${t}", not a duration; check styles/index.css.`);return parseFloat(n[1])*(n[2]===`s`?1e3:1)}function tG(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia($W).matches}function nG(){return tG()?`auto`:`smooth`}var rG=(0,V.createContext)(!1);function iG(e){let[t,n]=(0,V.useState)(null);return(0,V.useEffect)(()=>{let t=window.setTimeout(()=>n(e),900);return()=>window.clearTimeout(t)},[e]),t===e}function aG(){let e=(0,V.useContext)(rG);return(0,V.useRef)(e).current?` sp-appear`:``}function oG({id:e,title:t,summary:n,children:r}){let i=PI(t=>t.sections[e]),a=PI(e=>e.setSection),o=PI(e=>e.focus),s=(0,V.useRef)(null),c=`sp-section-${e}`,l=aG();return(0,V.useEffect)(()=>{o?.section===e&&FI(o)&&s.current?.scrollIntoView?.({block:`start`,behavior:nG()})},[o,e]),R(`section`,{ref:s,className:`sp-section${l}`,"data-section":e,"aria-labelledby":`${c}-title`,children:[I(`h3`,{className:`sp-section-heading`,children:R(`button`,{type:`button`,id:`${c}-title`,className:`sp-section-head`,"aria-expanded":i,"aria-controls":c,onClick:()=>a(e,!i),children:[I(gi,{size:13,className:`sp-chevron${i?` is-open`:``}`,"aria-hidden":`true`}),I(`span`,{className:`sp-section-title`,children:t}),n!=null&&I(`span`,{className:`sp-section-summary`,children:n})]})}),i&&I(`div`,{id:c,className:`sp-section-body`,children:r})]})}var sG=`gaia:mobile-access-request`,cG=`gaia:mobile-access-state`;function lG(e){window.dispatchEvent(new CustomEvent(sG,{detail:e}))}function uG(e){window.dispatchEvent(new CustomEvent(cG,{detail:e}))}function dG(e,t){let n=(0,V.useRef)(t);n.current=t,(0,V.useEffect)(()=>{let t=e=>n.current(!!e.detail);return window.addEventListener(e,t),()=>window.removeEventListener(e,t)},[e])}var fG=e=>dG(sG,e),pG=e=>dG(cG,e);function mG({checked:e,onChange:t,label:n,text:r,disabled:i}){return R(`span`,{className:`sp-switch-wrap`,children:[I(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":n,className:`sp-switch${e?` is-on`:``}`,onClick:()=>t(!e),disabled:i,children:I(`span`,{className:`sp-switch-knob`,"aria-hidden":`true`})}),r&&I(`span`,{className:`sp-state-text`,children:r})]})}var hG={warming:`modelStatus.state.warming`,idle:`modelStatus.state.idle`,stopped:`modelStatus.state.stopped`},gG=3e3,_G={added:`env.source.added`,gaia_documents:`env.source.gaia_documents`,scratch:`env.source.scratch`,document:`env.source.document`,working_folder:`env.source.working_folder`,approved:`env.source.approved`,allowed_paths:`env.source.allowed_paths`},vG=new Set([`gaia_documents`,`scratch`]),yG=3,bG=14;function xG(e){let t=e.split(/[\\/]/).filter(Boolean);return t[t.length-1]??e}function SG({sessionId:e,busy:t,usage:n,hideDocuments:r=!1}){let i=L(),{env:a,refresh:o}=dU(e);bf(t,()=>{o()});let s=a&&!a.internet?i(`env.offline`):null;return I(oG,{id:`environment`,title:i(`env.title`),summary:s,children:R(`div`,{className:`sp-rows`,children:[I(AG,{sessionId:e,busy:t,usage:n??null}),I(CG,{usage:n??null}),I(TG,{sessionId:e}),I(DG,{sessionId:e,busy:t}),I(jG,{sessionId:e,hideDocuments:r}),I(PG,{sessionId:e}),I(MG,{sessionId:e}),I(NG,{})]})})}function CG({usage:e}){let t=L(),n=PI(e=>e.reveal),r=aG();if(!e||e.window<=0)return null;let i=Math.min(100,Math.round(e.used/e.window*100)),a=i>=80?` is-high`:``;return I(`div`,{className:`sp-row${r}`,children:R(`button`,{type:`button`,className:`sp-row-line sp-row-button`,onClick:()=>n(`context`),title:t(`env.contextTitle`),children:[I(`span`,{className:`sp-row-icon`,"aria-hidden":`true`,children:I(Pa,{size:bG})}),I(`span`,{className:`sp-row-label`,children:t(`env.context`)}),R(`span`,{className:`sp-row-end`,children:[R(`bdi`,{className:`sp-quiet`,dir:`ltr`,children:[i,`%`]}),I(`span`,{className:`sp-meter${a}`,"aria-hidden":`true`,children:I(`span`,{style:{width:`${i}%`}})})]})]})})}var wG={google:`env.mailbox.google`,microsoft:`env.mailbox.microsoft`};function TG({sessionId:e}){let t=L(),n=z(t=>{let n=t.sessions.find(t=>t.id===e);return n?.agent_type===`email`?n.mail_provider??null:null}),r=n?wG[n]:void 0;return r?I(OG,{icon:I(vo,{size:bG}),label:t(r),title:t(`env.mailboxTitle`)}):null}var EG=xG;function DG({sessionId:e,busy:t}){let n=L(),r=PI(t=>t.signals[e]?.changedFiles??0),[i,a]=(0,V.useState)(null),o=aG(),s=(0,V.useRef)(0),c=(0,V.useCallback)(()=>{let t=++s.current;r===0?a(null):Promise.resolve().then(()=>Wn(e)).then(e=>{t===s.current&&a(nU(e,e=>Array.isArray(e.repos),`git state`))}).catch(n=>{P.ui.warn(`Could not read the git state of session=${e}`,n),t===s.current&&a(null)})},[r,e]);return(0,V.useEffect)(()=>(c(),()=>{s.current+=1}),[c]),bf(t,c),!i||i.repos.length===0?null:I(F.Fragment,{children:i.repos.map(e=>I(`div`,{className:`sp-row${o}`,children:R(`div`,{className:`sp-row-line`,title:n(`env.branchTitle`),children:[I(`span`,{className:`sp-row-icon`,"aria-hidden":`true`,children:I(Ra,{size:bG})}),R(`span`,{className:`sp-row-label`,dir:`ltr`,children:[EG(e.root),` `,I(`span`,{className:`sp-quiet`,children:e.branch})]}),e.uncommitted.length>0&&I(`span`,{className:`sp-row-end sp-quiet`,children:n.plural(`env.uncommitted`,e.uncommitted.length,{n:e.uncommitted.length})})]})},e.root))})}function OG({icon:e,label:t,title:n,children:r,info:i,below:a,className:o}){let[s,c]=(0,V.useState)(!1);return R(`div`,{className:`sp-row${o?` ${o}`:``}`,children:[R(`div`,{className:`sp-row-line`,children:[I(`span`,{className:`sp-row-icon`,"aria-hidden":`true`,children:e}),I(`span`,{className:`sp-row-label`,title:n,children:t}),i&&I(`button`,{type:`button`,className:`btn-icon-sm sp-info`,onClick:()=>c(e=>!e),"aria-expanded":s,"aria-label":i.label,title:i.label,children:I(Ja,{size:13})}),r!=null&&I(`span`,{className:`sp-row-end`,children:r})]}),i&&s&&I(`span`,{className:`sp-note`,children:i.text}),a]})}function kG(e,t){let n=e=>e.toLowerCase().replace(/^user\./,``);return n(e)===n(t)}function AG({sessionId:e,busy:t,usage:n}){let r=L(),i=fl(),a=il(e=>e.active),o=z(t=>pl(a,t.sessions,e)),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(null),d=i?.remote===!0,f=n&&n.window>0?n.window:s?.ctx_size??null,p=(0,V.useCallback)(()=>{d||Promise.resolve().then(()=>re()).then(e=>{c(nU(e,e=>typeof e.state==`string`,`model status`)),u(null)}).catch(e=>{P.ui.warn(`Could not read where the local model runs`,e),u(VF(e))})},[d]);(0,V.useEffect)(p,[p]),bf(t,p);let m=s?.state===`warming`;if((0,V.useEffect)(()=>{if(!m)return;let e=setInterval(p,gG);return()=>clearInterval(e)},[m,p]),d)return R(F.Fragment,{children:[I(OG,{className:`is-remote`,icon:I(Pi,{size:bG}),label:r(`env.cloudPlace`,{name:i?.label??``}),info:i?.description?{text:i.description,label:r(`env.aboutCloud`)}:void 0}),o&&I(OG,{icon:I(Wi,{size:bG}),label:I(`span`,{dir:`ltr`,children:cl(o)}),title:o})]});if(!i)return I(OG,{icon:I(Ao,{size:bG}),label:I(`span`,{className:`sp-quiet`,children:r(`env.notKnownYet`)}),title:dl});let h=!!(s?.model&&o&&!kG(s.model,o)),g=h?null:s?.memory,_=s?.display_name??(s&&s.state!==`loaded`&&o?cl(o):null),v=g?.model_gb==null?s?.state===`loaded`||s?.state===`warming`?r(`env.inUseUnknown`):null:r(`env.inUse`,{gb:g.model_gb.toFixed(1)}),y=g?.free_gb==null?null:r(`env.free`,{gb:g.free_gb.toFixed(1)}),b=g&&[v,y].filter(Boolean).join(` · `)||void 0;return R(F.Fragment,{children:[I(OG,{icon:I(Ao,{size:bG}),label:`${r(`env.thisPc`)}${!h&&s?.placement?.label?` · ${s.placement.label}`:``}`,below:l?I(`span`,{className:`sp-error`,children:l}):s?.error&&I(`span`,{className:`sp-error`,children:I(Al,{status:s})})}),h&&I(OG,{icon:I(Wi,{size:bG}),label:I(`span`,{className:`sp-quiet`,children:r(`env.notLoaded`,{model:cl(o)})})}),!h&&s&&_&&I(OG,{icon:I(Wi,{size:bG}),label:R(F.Fragment,{children:[I(`bdi`,{dir:`ltr`,children:_}),s.state===`loaded`?``:` · ${r(hG[s.state])}`]}),title:b,children:f!=null&&I(`span`,{className:`sp-quiet`,title:r(`modelStatus.context`),children:r(`settings.ctx.tokens`,{size:Sl(f)})})})]})}function jG({sessionId:e,hideDocuments:t}){let n=L(),{env:r,error:a,change:o}=dU(e),s=z(t=>t.sessions.find(t=>t.id===e)?.agent_type===`gaia`),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(null),[f,p]=(0,V.useState)(!1),[m,h]=(0,V.useState)(!1),[g,_]=(0,V.useState)(!1),v=async(e,t)=>{d(e),l(null);try{await t()}catch(e){l(VF(e))}finally{d(null)}},y=t=>v(t.path,()=>o(()=>Et(e,t.path))),{open:b,picker:x,error:S}=oU(t=>{v(t,()=>o(()=>i(e,t)))}),C=(r?.folders??[]).filter(e=>!(t&&e.kind===`file`&&e.source===`document`)),w=C.filter(e=>vG.has(e.source)),T=C.filter(e=>e.kind===`folder`&&!vG.has(e.source)),E=C.filter(e=>e.kind===`file`&&!vG.has(e.source)),ee=f?E:E.slice(0,yG),D=!r||!r.enforced,O=e=>R(`li`,{className:`sp-scope-item sp-row-line`,children:[I(`span`,{className:`sp-row-icon`,"aria-hidden":`true`,children:e.kind===`folder`?I(Ma,{size:bG}):I(wa,{size:bG})}),I(`span`,{className:`sp-item-name`,dir:`ltr`,title:kd(e.path),children:kd(e.name||xG(e.path))}),e.kind===`folder`?I(`span`,{className:`sp-item-path sp-quiet`,dir:`ltr`,title:n(_G[e.source]),children:kd(e.path)}):I(`span`,{className:`sp-item-source sp-quiet`,title:kd(e.path),children:n(_G[e.source])}),e.removable&&!D&&I(`button`,{type:`button`,className:`btn-icon-sm sp-info sp-item-remove`,onClick:()=>void y(e),disabled:u!==null,"aria-label":n(`env.remove`,{path:kd(e.path)}),title:n(`env.removeShort`),children:I(bc,{size:12})})]},e.path),te=r&&!r.enforced?n(s?`env.flagshipScope`:`env.agentScope`):null,k=!!r&&!D;return R(`div`,{className:`sp-row`,children:[!r&&!a&&I(`span`,{className:`sp-quiet`,children:n(`sp.checking`)}),a&&I(`span`,{className:`sp-error`,children:n(`env.foldersError`,{error:a})}),r&&R(F.Fragment,{children:[T.length+ee.length>0&&R(`ul`,{className:`sp-list`,"aria-label":r.enforced?n(`env.readWrite`):n(`env.reach`),children:[T.map(O),ee.map(O)]}),E.length>yG&&I(`button`,{type:`button`,className:`link-btn sp-more`,onClick:()=>p(e=>!e),children:f?n(`env.fewerFiles`):n(`env.allFiles`,{n:E.length})}),(k||te||r.folders.length===0)&&R(`div`,{className:`sp-row-line`,children:[k?R(`button`,{type:`button`,className:`sp-row-button`,onClick:()=>b(),disabled:u!==null,children:[I(`span`,{className:`sp-row-icon`,"aria-hidden":`true`,children:I(Oa,{size:bG})}),n(`env.addFolder`)]}):I(`span`,{className:`sp-row-label sp-quiet`,children:r.folders.length===0?n(`env.nothing`):n(`env.reach`)}),te&&I(`button`,{type:`button`,className:`btn-icon-sm sp-info`,onClick:()=>h(e=>!e),"aria-expanded":m,"aria-label":n(`env.aboutFolders`),title:n(`env.aboutFolders`),children:I(Ja,{size:13})})]}),te&&m&&I(`span`,{className:`sp-note`,children:te}),w.length>0&&R(`button`,{type:`button`,className:`sp-row-line sp-row-button`,onClick:()=>_(e=>!e),"aria-expanded":g,title:n(`env.ownFoldersTitle`),children:[I(`span`,{className:`sp-row-icon`,"aria-hidden":`true`,children:I(gi,{size:bG,className:`sp-chevron${g?` is-open`:``}`})}),I(`span`,{className:`sp-row-label`,children:n(`env.ownFolders`)}),I(`bdi`,{className:`sp-row-end sp-quiet`,dir:`ltr`,children:w.length})]}),g&&w.length>0&&I(`ul`,{className:`sp-list sp-row-sub`,"aria-label":n(`env.ownFolders`),children:w.map(O)}),r.removed.length>0&&I(`span`,{className:`sp-quiet`,children:n(`env.removed`,{names:r.removed.map(xG).join(`, `)})})]}),(c??S)&&I(`span`,{className:`sp-error`,role:`alert`,children:c??S}),x]})}function MG({sessionId:e}){let t=L(),{env:n,change:r,refresh:i}=dU(e),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(!1);if(!n)return null;let l=async t=>{c(!0),o(null);try{await r(()=>fn(e,t))}catch(e){o(VF(e)),i()}finally{c(!1)}},u=I(Ha,{size:bG});return n.internet_enforced?I(OG,{icon:u,label:t(`env.internet`),title:n.internet?void 0:t(`env.blocked`),below:a&&I(`span`,{className:`sp-error`,role:`alert`,children:a}),children:I(mG,{checked:n.internet,onChange:e=>void l(e),disabled:s,label:t(`env.internetFor`),text:n.internet?t(`env.on`):t(`env.off`)})}):I(OG,{icon:u,label:t(`env.internet`),children:I(`span`,{className:`sp-quiet`,children:n.internet?t(`env.on`):t(`env.off`)})})}function NG(){let e=L(),[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(null),s=(0,V.useCallback)(()=>{Promise.resolve().then(()=>qn()).then(e=>{n(nU(e,e=>typeof e.active==`boolean`,`phone access status`)),o(null)}).catch(e=>o(VF(e)))},[]);(0,V.useEffect)(s,[s]),pG(()=>{i(!1),s()});let c=t?.active===!0;return I(OG,{icon:I(Ws,{size:bG}),label:e(`env.phone`),below:R(F.Fragment,{children:[c&&R(`span`,{className:`sp-row-line sp-row-sub`,children:[I(`span`,{className:`sp-row-label sp-quiet`,children:t?.device?e(`env.phoneConnected`,{name:t.device.name}):e(`env.noPhone`)}),I(`button`,{type:`button`,className:`sp-action`,onClick:()=>lG(!0),children:e(`env.qr`)})]}),(a||c&&t?.error)&&I(`span`,{className:`sp-error`,children:a??t?.error})]}),children:I(mG,{checked:c,onChange:e=>{i(!0),lG(e)},disabled:r,label:e(`env.phone`),text:e(r?c?`env.stopping`:`env.starting`:c?`env.on`:`env.off`)})})}function PG({sessionId:e}){let t=L(),[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(!1),[o,s]=(0,V.useState)(null),c=fu(t=>gu(e)(t)!==null);(0,V.useEffect)(()=>{let t=!0;return Promise.resolve().then(()=>rr(e)).then(e=>{t&&r(nU(e,e=>typeof e.mode==`string`,`permission mode`).mode)}).catch(e=>{t&&s(VF(e))}),()=>{t=!1}},[e]),_U(e,r);let l=async t=>{a(!1),s(null);try{let n=(await Ue(e,t)).mode;r(n),gU(e,n)}catch(e){s(VF(e))}},u=vU.find(e=>e.mode===n)?.note;return I(OG,{icon:I(n===`full_access`?Is:Ps,{size:bG}),label:t(`env.permissionShort`),info:u?{text:t(u),label:t(`env.aboutPermission`)}:void 0,below:R(F.Fragment,{children:[n===`full_access`&&c&&I(`span`,{className:`sp-quiet`,role:`status`,children:t(`perm.fullPendingNote`)}),i&&R(`span`,{className:`sp-confirm`,role:`alert`,children:[t(`env.fullAccessWarn`),R(`span`,{className:`sp-actions-row`,children:[I(`button`,{type:`button`,className:`sp-action is-warning`,onClick:()=>void l(`full_access`),children:t(`env.turnOn`)}),I(`button`,{type:`button`,className:`sp-action`,onClick:()=>a(!1),children:t(`sp.cancel`)})]})]}),o&&I(`span`,{className:`sp-error`,role:`alert`,children:o})]}),children:I(sF,{className:`sp-segmented`,"aria-label":t(`env.permission`),children:vU.map(e=>I(`button`,{type:`button`,role:`radio`,"aria-checked":n===e.mode,className:`${n===e.mode?`is-selected`:``}${e.mode===`full_access`?` is-risky`:``}`,onClick:()=>e.mode===`full_access`?a(!0):void l(e.mode),children:e.mode===`ask`?t(`env.ask`):t(e.label)},e.mode))})})}function FG(){let e=(0,V.useRef)(0),t=(0,V.useRef)(0),n=(0,V.useRef)(!0);return(0,V.useEffect)(()=>(n.current=!0,()=>{n.current=!1}),[]),(0,V.useCallback)(()=>{let r=++e.current;return()=>!n.current||r<t.current?!1:(t.current=r,!0)},[])}var IG={file:{label:`out.kind.file`,Icon:Sa},export:{label:`out.kind.export`,Icon:ga},image:{label:`out.kind.image`,Icon:Ka},audio:{label:`out.kind.audio`,Icon:Xi},document:{label:`out.kind.document`,Icon:no},memory:{label:`out.kind.memory`,Icon:Xr},schedule:{label:`out.kind.schedule`,Icon:ni}},LG={created:`out.change.created`,edited:`out.change.edited`,deleted:`out.change.deleted`};function RG(e,t,n){if(!e)return null;let r=Date.parse(`${e.replace(` `,`T`)}Z`);if(Number.isNaN(r))return null;let i=Math.max(0,Math.round((t-r)/1e3));return i<60?{key:`out.justNow`}:i<3600?{key:`out.minAgo`,params:{n:Math.floor(i/60)}}:i<86400?{key:`out.hAgo`,params:{n:Math.floor(i/3600)}}:new Date(r).toLocaleDateString(n,{month:`short`,day:`numeric`})}function zG(e){return e.state===`undone`?`out.undone`:e.state===`gone`?`sp.gone`:null}function BG({sessionId:e,busy:t,onJumpToMessage:n}){let r=L(),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(null),c=FG(),l=(0,V.useCallback)(()=>{let t=c();Promise.resolve().then(()=>vt(e)).then(e=>{t()&&(a(nU(e,e=>Array.isArray(e.items),`list of outputs`).items),s(null))}).catch(n=>{t()&&(P.ui.warn(`Could not list what session=${e} produced`,n),s(BF(n)))})},[c,e]);return(0,V.useEffect)(()=>{l()},[l]),bf(t,l),sI(e,l),!o&&(!i||i.length===0)?null:I(oG,{id:`outputs`,title:r(`out.title`),summary:i&&i.length>0?String(i.length):null,children:o?I(`p`,{className:`sp-error`,children:r(`out.listError`,{error:o})}):I(VG,{sessionId:e,items:i??[],onJumpToMessage:n})})}function VG({sessionId:e,items:t,onJumpToMessage:n}){let r=L(),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(!1),c=(e,t)=>{a(null),e.catch(e=>a(r(`sp.couldntOpen`,{name:t,error:BF(e)})))},l=o?t:t.slice(0,5);return R(F.Fragment,{children:[I(`ul`,{className:`sp-list`,"aria-label":r(`out.listLabel`),children:l.map(t=>{let{label:i,Icon:o}=IG[t.kind],s=zG(t),l=t.change&&t.kind!==`document`?LG[t.change]:void 0,u=RG(t.created_at,Date.now(),Ln(r)),d=(t.kind===`image`||t.kind===`audio`)&&t.detail?t.detail:null,f=r.compose(e=>[l?e(`out.kindChanged`,{kind:de(i),change:de(l)}):e(i),u==null?``:typeof u==`string`?u:e(u.key,u.params),s?e(s):``].filter(Boolean).join(` · `));return R(`li`,{className:`sp-output${t.state===`present`?``:` is-inactive`}`,children:[I(o,{size:13,className:`sp-item-icon`,"aria-hidden":`true`}),R(`div`,{className:`sp-item-text`,children:[I(`span`,{className:`sp-item-name`,dir:`ltr`,title:kd(t.path??t.name),children:kd(t.name)}),d&&I(`span`,{className:`sp-item-detail`,dir:`auto`,title:d,children:d}),I(`span`,{className:`sp-meta`,children:f}),R(`span`,{className:`sp-item-actions`,children:[t.message_id!=null&&R(`button`,{type:`button`,className:`sp-action`,onClick:()=>{n(t.message_id)||a(r(`out.notLoaded`))},"aria-label":r(`out.goToAria`,{name:kd(t.name)}),children:[I(Hi,{size:11,"aria-hidden":`true`}),` `,r(`sp.goToTurn`)]}),t.kind===`file`&&t.state===`present`&&nL(t.path)&&R(`button`,{type:`button`,className:`sp-action`,onClick:()=>pL.getState().show(e,t.path),children:[I(Ho,{size:11,"aria-hidden":`true`}),` `,r(`docPane.openHere`)]}),t.openable&&t.path&&I(`button`,{type:`button`,className:`sp-action`,onClick:()=>c(mt(t.path),kd(t.name)),children:r(`sp.open`)}),t.revealable&&t.path&&R(`button`,{type:`button`,className:`sp-action`,onClick:()=>c(nr(t.path,!0),kd(t.name)),children:[I(Ea,{size:11,"aria-hidden":`true`}),` `,r(`sp.showInFolder`)]})]})]})]},t.id)})}),t.length>5&&I(`button`,{type:`button`,className:`link-btn sp-more`,onClick:()=>s(e=>!e),children:o?r(`out.fewer`):r(`out.more`,{n:t.length-5})}),i&&I(`p`,{className:`sp-error`,role:`alert`,children:i})]})}async function HG(){return Nn(`GET`,`/schedules`)}function UG(){return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}async function WG(e,t,n){return Nn(`POST`,`/schedules`,{name:e,interval:t,prompt:n,timezone:UG()})}async function GG(e,t,n){return Nn(`PATCH`,`/schedules/${encodeURIComponent(e)}`,{interval:t,prompt:n,timezone:UG()})}async function KG(e,t){return Nn(`PUT`,`/schedules/${encodeURIComponent(e)}`,{status:t})}async function qG(e){return Nn(`POST`,`/schedules/${encodeURIComponent(e)}/run`)}async function JG(e){return Nn(`DELETE`,`/schedules/${encodeURIComponent(e)}`)}async function YG(e,t=20){return Nn(`GET`,`/schedules/${encodeURIComponent(e)}/results?limit=${t}`)}async function XG(e){return Nn(`POST`,`/schedules/parse`,{input:e,timezone:UG()})}function ZG(e){return e.replace(/^\s*(```|~~~).*$/gm,``).replace(/!?\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/`([^`]+)`/g,`$1`).replace(/\*\*(.+?)\*\*/g,`$1`).replace(/(^|[^\w])__(?=\S)(.+?\S)__(?![\w.])/g,`$1$2`).replace(/(^|[^\w*])\*(?!\s)(.*?\S)\*(?!\w)/g,`$1$2`).replace(/(^|[^\w])_(?![\s_])(.+?)_(?!\w)/g,`$1$2`).replace(/^\s{0,3}(#{1,6}\s+|>\s?|[-*+]\s+)/gm,``).replace(/\s+/g,` `).trim()}function QG(e,t){if(!(e instanceof Error))return t;let n=e.message,r=n.match(/API \d+: (.+)/);if(r)try{let e=JSON.parse(r[1]);if(e.detail)return e.detail}catch{}return n}var $G=`gaia-schedule-announced-errors`;function eK(){let e;try{e=localStorage.getItem($G)}catch(e){return P.system.warn(`Announced schedule failures unreadable; failures from before launch may be announced again. localStorage is blocked -- check private-browsing or site-data settings.`,e),{}}if(!e)return{};try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return Object.fromEntries(Object.entries(t).filter(([,e])=>typeof e==`number`));P.system.warn(`Ignored malformed "${$G}"; failures from before launch may be announced again.`)}catch(e){P.system.warn(`"${$G}" is corrupt; failures from before launch may be announced again.`,e)}return{}}function tK(e){try{localStorage.setItem($G,JSON.stringify(e))}catch(e){P.system.warn(`Announced schedule failures not saved; they may be announced again on the next launch. localStorage is blocked -- check private-browsing or site-data settings.`,e)}}function nK(e,t){let{addNotification:n}=fu.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:Qt()(`schedules.failed`,{name:r.name}),message:r.last_error,timestamp:Date.now(),read:!1,dismissed:!1,priority:`high`,...r.session_id?{sessionId:r.session_id}:{}})}function rK(e){return e.run_count-+!!e.running}function iK(e,t,n){let{addNotification:r}=fu.getState();for(let i of n){let n=rK(i);n<=(t[i.id]??0)||i.error_count>(e[i.id]??0)||r({id:`schedule-done-${i.id}-${n}`,type:`info`,agentId:`scheduler`,agentName:`GAIA`,title:Qt()(`schedules.finished`,{name:i.name}),message:ZG(i.last_result??``),timestamp:Date.now(),read:!1,dismissed:!1,priority:`medium`,...i.session_id?{sessionId:i.session_id}:{}})}}var aK=or((e,t)=>({schedules:[],loading:!1,error:null,actionError:null,selectedSchedule:null,results:[],resultsLoading:!1,errorCounts:null,finishedCounts:{},draft:null,setDraft:t=>e({draft:t}),loadSchedules:async()=>{t().schedules.length===0&&!t().error&&e({loading:!0}),e({error:null});try{let n=(await HG()).schedules||[],r=t().errorCounts,i=t().finishedCounts,a=r??eK();nK(a,n),r&&iK(a,i,n);let o=Object.fromEntries(n.map(e=>[e.id,e.error_count]));tK(o),e({schedules:n,loading:!1,errorCounts:o,finishedCounts:Object.fromEntries(n.map(e=>[e.id,Math.max(rK(e),i[e.id]??0)]))})}catch(t){P.api.error(`Failed to load schedules`,t),e({error:`Failed to load schedules`,loading:!1})}},createSchedule:async(t,n,r)=>{try{let i=await WG(t,n,r);e(e=>({schedules:[...e.schedules,i],actionError:null}))}catch(e){throw P.api.error(`Failed to create schedule`,e),e}},editSchedule:async(t,n,r)=>{try{let i=await GG(t,n,r);e(e=>({schedules:e.schedules.map(e=>e.name===t?i:e),actionError:null}))}catch(e){throw P.api.error(`Failed to edit schedule "${t}"`,e),e}},updateScheduleStatus:async(t,n)=>{try{let r=await KG(t,n);e(e=>({schedules:e.schedules.map(e=>e.name===t?r:e),actionError:null}))}catch(n){P.api.error(`Failed to update schedule "${t}"`,n),e({actionError:QG(n,`Failed to update schedule`)})}},runScheduleNow:async t=>{try{let n=await qG(t);e(e=>({schedules:e.schedules.map(e=>e.name===t?n:e),actionError:null}))}catch(n){P.api.error(`Failed to run schedule "${t}" now`,n),e({actionError:QG(n,`Could not run the schedule now`)})}},deleteSchedule:async t=>{try{await JG(t),e(e=>({schedules:e.schedules.filter(e=>e.name!==t),selectedSchedule:e.selectedSchedule===t?null:e.selectedSchedule,actionError:null}))}catch(n){P.api.error(`Failed to delete schedule "${t}"`,n),e({actionError:QG(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 YG(n);if(t().selectedSchedule!==n)return;e({results:r.results||[],resultsLoading:!1})}catch(r){if(P.api.error(`Failed to load results for "${n}"`,r),t().selectedSchedule!==n)return;e({results:[],resultsLoading:!1})}},dismissActionError:()=>e({actionError:null})})),oK=/^(coding|code|git|github)/i;function sK(e,t){let n=e=>e.replace(/\\/g,`/`).toLowerCase();return n(e)===n(t)}function cK(e,t){let n=Vk(e,t);for(let e=n.length-1;e>=0;e--){let t=n[e];if(t.type===`plan`&&t.planSteps&&t.planSteps.length!==0)return{steps:t.planNarrations?.length===t.planSteps.length?t.planNarrations:t.planSteps,statuses:t.planStatuses??t.planSteps.map(()=>`pending`)}}return null}function lK(e){return cK(e,!0)}function uK(e){let t=e[e.length-1];if(!t||t.role!==`assistant`)return null;let n=cK(t.agentSteps??[],!1);return n?{...n,finished:!0}:null}function dK(e){let t=new Set;for(let n of e)for(let e of n.turnSummary?.sites??[])t.add(e);return t.size}function fK(e,t,n){let r=z(t=>t.sessions.find(t=>t.id===e)),i=z(e=>e.documents),a=z(e=>e.agentSteps),o=aK(e=>e.schedules),s=PI(t=>t.signals[e]),{env:c}=dU(e);return(0,V.useMemo)(()=>{let l=(c?.folders??[]).filter(e=>e.kind===`file`&&e.source===`document`).map(e=>({entry:e,doc:i.find(t=>sK(t.filepath,e.path))??null})),u=o.filter(t=>t.session_id===e&&t.status!==`cancelled`),d=(n?lK(a):null)??uK(t),f=vK(t,n?a:[]),p=zW(t,n),m=p?.kind===`turn`&&!!p.turn.turnSummary&&ZW(p.turn.turnSummary),h=s?.changedFiles??0,g=(s?.changedCode??0)>0||(s?.skills??[]).some(e=>oK.test(e))||f.some(e=>CK(e.command)),_=dK(t),v=[];return r?.agent_type===`email`&&v.push({kind:`email`,section:`environment`}),(u.length>0||r?.kind===`scheduled`)&&v.push({kind:`scheduled`,section:u.length>0?`schedule`:void 0}),g&&v.push({kind:`coding`,count:h||void 0,section:h>0?`changes`:f.length>0?`commands`:void 0}),f.length>0&&v.push({kind:`commands`,count:f.length,section:`commands`}),l.length>0&&v.push({kind:`documents`,count:l.length,section:`documents`}),_>0&&v.push({kind:`web`,count:_,section:m?`answer`:void 0}),d&&!d.finished&&v.push({kind:`plan`,section:`plan`}),v.length===0&&v.push({kind:`chat`}),{facets:v,documents:l,schedules:u,plan:d,commands:f,coding:g,showAnswer:m}},[o,n,c,i,t,r?.agent_type,r?.kind,e,s,a])}var pK=`run_shell_command`,mK=/(?:^|,[ \t]*|\n)[ \t]*command:[ \t]?/,hK=/(?:,[ \t]*|\n)[ \t]*(?:working_directory:[ \t]|timeout:[ \t]?\d+[ \t]*(?:,|\n|$))/;function gK(e){if(e.commandOutput?.command)return e.commandOutput.command;let t=e.detail??``,n=mK.exec(t);if(!n)return null;let r=t.slice(n.index+n[0].length),i=hK.exec(r);return(i?r.slice(0,i.index):r).trim()||null}function _K(e){if(e.declined||e.timedOut)return`declined`;if(e.active)return`running`;let t=e.commandOutput;return typeof t?.returnCode==`number`?t.returnCode===0||t.expectedExit?`ok`:`failed`:typeof t?.return_code==`number`?t.return_code===0||e.success===!0?`ok`:`failed`:e.success===!1?`failed`:e.success===!0||e.result?`ok`:`stopped`}function vK(e,t){let n=[],r=(e,t)=>{for(let r of e??[]){if(r.type!==`tool`||r.tool!==pK)continue;let e=gK(r);e&&n.push({key:`${t??`live`}-${r.id}`,command:e,state:_K(r),messageId:t})}};for(let t of e)t.role===`assistant`&&r(t.agentSteps,t.id);return r(t,null),n}var yK=/\.(py|pyi|ipynb|ts|tsx|js|jsx|mjs|cjs|go|rs|c|cc|cpp|cxx|h|hpp|cs|java|kt|kts|swift|rb|php|lua|r|scala|sh|bash|zsh|ps1|psm1|bat|cmd|sql|html|htm|css|scss|vue|svelte|json|jsonc|yaml|yml|toml|ini|cfg|xml|gradle|cmake|mk|lock)$/i,bK=/^(makefile|dockerfile|cmakelists\.txt|requirements[\w.-]*\.txt|\.gitignore|\.env\.example)$/i;function xK(e){let t=e.split(/[\\/]/).pop()??``;return yK.test(t)||bK.test(t)}var SK=/^(git|gh|npm|npx|pnpm|yarn|node|python3?|py|pip3?|uv|pytest|cargo|go|make|cmake|dotnet|mvn|gradle|tsc|docker)$/i;function CK(e){let t=/^\s*(?:"([^"]+)"|'([^']+)'|(\S+))/.exec(e),n=(t?.[1]??t?.[2]??t?.[3]??``).split(/[\\/]/).pop()??``;return SK.test(n.replace(/\.(exe|cmd|bat)$/i,``))}function wK(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}function TK(e){let t=e.split(/[\\/]/).filter(Boolean);return t[t.length-1]??e}var EK=e=>de(e===1?`chg.files.one`:`chg.files.other`,{n:e});function DK(e,t=gt){let{files:n,additions:r,deletions:i}=e.totals;return t(`chg.total`,{files:EK(n),add:r,del:i})}var OK={edited:`Edited`,created:`Created`,deleted:`Deleted`},kK={edited:`chg.edited`,created:`chg.created`,deleted:`chg.deleted`};function AK({sessionId:e,busy:t,onJumpToMessage:n}){let r=L(),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(null),u=(0,V.useCallback)(()=>{Promise.resolve().then(()=>Dn(e)).then(t=>{let n=nU(t,e=>Array.isArray(e.files),`list of this chat's changes`);a(n),PI.getState().setSignals(e,{changedFiles:n.files.length,changedCode:n.files.filter(e=>xK(e.path)).length}),s(null)}).catch(t=>{P.ui.warn(`Could not total what session=${e} changed`,t),s(BF(t))})},[e]);(0,V.useEffect)(u,[u]),bf(t,()=>{l(null),u()}),sI(e,u);let d=!i||i.files.length===0;return!o&&d&&!c?null:R(oG,{id:`changes`,title:r(`chg.title`),summary:i&&!d?r(`chg.summary`,{files:EK(i.totals.files),add:i.totals.additions,del:i.totals.deletions}):null,children:[o&&I(`p`,{className:`sp-error`,children:r(`chg.error`,{error:o})}),i&&!d&&I(jK,{sessionId:e,busy:t,changes:i,onChanged:u,onUndone:l,onJumpToMessage:n}),d&&c&&I(`p`,{className:`sp-ok`,role:`status`,children:c})]})}function jK({sessionId:e,busy:t,changes:n,onChanged:r,onUndone:i,onJumpToMessage:a}){let o=L(),[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(`idle`),[d,f]=(0,V.useState)(null),p=n.files.length,m=async t=>{u(`working`),f(null);try{let n=await Qn(e,t),r=[];n.restored.length&&r.push(`restored ${wK(n.restored.length,`file`)}`),n.removed.length&&r.push(`removed ${wK(n.removed.length,`new file`)}`);let a=`Undone: ${r.join(`, `)||`no files needed changing`}.`;n.kept_folders.length&&(a+=` Kept ${wK(n.kept_folders.length,`folder`)} the chat created, because they now hold other files.`),f(a),u(`done`),i(a),oI(e),await GF(e)}catch(e){let t=e?.reason===`conflict`;f(VF(e)),u(t?`conflict`:`idle`)}};return R(`div`,{className:`sp-changes`,children:[R(`p`,{className:`sp-changes-total`,"aria-live":`polite`,children:[I(`strong`,{children:DK(n,o)}),n.totals.uncounted>0&&R(`span`,{className:`sp-meta`,children:[` · `,o.plural(`chg.uncounted`,n.totals.uncounted)]})]}),n.pending&&I(`p`,{className:`sp-meta`,children:o(`chg.pending`)}),I(`ul`,{className:`sp-list`,children:n.files.map(e=>{let t=e.message_ids[e.message_ids.length-1];return R(`li`,{className:`sp-change`,children:[R(`div`,{className:`sp-item-text`,children:[I(`span`,{className:`sp-item-name`,dir:`ltr`,title:kd(e.path),children:kd(TK(e.path))}),R(`span`,{className:`sp-meta`,children:[o(kK[e.change]),e.additions!=null&&R(F.Fragment,{children:[` · `,R(`span`,{className:`sp-add`,children:[`+`,e.additions]}),` `,R(`span`,{className:`sp-del`,children:[`−`,e.deletions]})]}),e.message_ids.length>1&&` · ${o(`chg.turns`,{n:e.message_ids.length})}`]}),e.changed_since&&R(`span`,{className:`sp-warn-text`,children:[I(cc,{size:11,"aria-hidden":`true`}),` `,o(`chg.outside`,{when:e.changed_since})]})]}),t!=null&&I(`button`,{type:`button`,className:`btn-icon-sm`,onClick:()=>a(t),"aria-label":o(`chg.goToLast`,{name:kd(TK(e.path))}),title:o(`sp.goToTurn`),children:I(Hi,{size:12})})]},e.path)})}),n.incomplete&&R(`p`,{className:`sp-warn-text`,role:`note`,children:[I(cc,{size:11,"aria-hidden":`true`}),` `,hI(n.untracked,{inChat:!0},o)]}),R(`div`,{className:`sp-actions-row`,children:[R(`button`,{type:`button`,className:`sp-action`,onClick:()=>c(!0),children:[I(ua,{size:12,"aria-hidden":`true`}),` `,o(`chg.review`)]}),l!==`confirm`&&l!==`conflict`&&R(`button`,{type:`button`,className:`sp-action`,onClick:()=>u(`confirm`),disabled:l===`working`||t,title:t?o(`chg.wait`):void 0,children:[I(uc,{size:12,"aria-hidden":`true`}),` `,o(l===`working`?`chg.undoing`:`chg.undoAll`)]})]}),l===`confirm`&&R(`div`,{className:`sp-confirm`,role:`group`,"aria-label":o(`chg.confirmLabel`),children:[o(p===1?`chg.confirm.one`:`chg.confirm.other`,{files:EK(p)}),R(`span`,{className:`sp-actions-row`,children:[I(`button`,{type:`button`,className:`sp-action is-danger`,onClick:()=>void m(!1),children:o(`chg.undoAll`)}),I(`button`,{type:`button`,className:`sp-action`,onClick:()=>u(`idle`),children:o(`sp.cancel`)})]})]}),d&&R(`div`,{className:l===`done`?`sp-ok`:`sp-error`,role:l===`done`?`status`:`alert`,children:[d,l===`conflict`&&R(`span`,{className:`sp-actions-row`,children:[I(`button`,{type:`button`,className:`sp-action is-danger`,onClick:()=>void m(!0),children:o(`chg.undoAnyway`)}),I(`button`,{type:`button`,className:`sp-action`,onClick:()=>{u(`idle`),f(null)},children:o(`chg.keep`)})]})]}),I(PK,{sessionId:e,busy:t,onCommitted:r}),s&&I(NK,{changes:n,onClose:()=>c(!1)})]})}function MK(e){if(e.too_large)return`Too large to show: ${e.before_size} → ${e.after_size} bytes.`;if(e.binary)return`Binary file: ${e.before_size} → ${e.after_size} bytes. No text diff.`;if(e.truncated)return`Diff shortened: the change is too long to show in full.`}function NK({changes:e,onClose:t}){er(!0,t);let n=(0,V.useRef)(null);return yn(n,!0),I(`div`,{ref:n,className:`modal-overlay`,onClick:t,role:`dialog`,"aria-modal":`true`,"aria-label":`Review this chat's changes`,children:R(`div`,{className:`modal-panel changes-review`,onClick:e=>e.stopPropagation(),children:[R(`div`,{className:`modal-header`,children:[R(`h3`,{children:[`Changes in this chat · `,DK(e)]}),I(`button`,{type:`button`,className:`btn-icon`,onClick:t,"aria-label":`Close`,children:I(bc,{size:18})})]}),I(`div`,{className:`modal-body changes-review-body`,children:e.files.map(e=>I(`section`,{className:`changes-review-file`,children:I(Pj,{data:{path:e.path,badge:OK[e.change],note:MK(e),unified:e.binary||e.too_large?``:e.unified}})},e.path))})]})})}function PK({sessionId:e,busy:t,onCommitted:n}){let r=L(),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(null),f=(0,V.useCallback)(()=>{Promise.resolve().then(()=>Wn(e)).then(e=>{a(nU(e,e=>Array.isArray(e.repos),`list of git repositories`)),s(null)}).catch(e=>s(BF(e)))},[e]);return(0,V.useEffect)(f,[f]),bf(t,f),sI(e,f),o?I(`p`,{className:`sp-error`,children:r(`chg.gitError`,{error:o})}):!i||!i.available||i.repos.length===0?null:R(`div`,{className:`sp-git`,children:[i.repos.map(e=>R(`div`,{className:`sp-git-repo`,children:[R(`span`,{className:`sp-meta`,title:kd(e.root),children:[I(Ra,{size:12,"aria-hidden":`true`}),` `,kd(TK(e.root)),` · `,kd(e.branch),e.uncommitted.length===0&&e.files.length>0&&` · committed`]}),R(`span`,{className:`sp-actions-row`,children:[R(`button`,{type:`button`,className:`sp-action`,disabled:t||e.uncommitted.length===0,onClick:()=>{d(null),l({kind:`commit`,repo:e})},children:[I(Ia,{size:12,"aria-hidden":`true`}),` Commit…`]}),R(`button`,{type:`button`,className:`sp-action`,disabled:t||e.pr_blocked!=null,title:e.pr_blocked??void 0,onClick:()=>{d(null),l({kind:`pr`,repo:e})},children:[I(Ba,{size:12,"aria-hidden":`true`}),` Create PR…`]})]}),e.pr_blocked&&I(`span`,{className:`sp-meta`,children:e.pr_blocked})]},e.root)),u&&I(`p`,{className:`sp-ok`,role:`status`,children:u}),c&&I(FK,{sessionId:e,kind:c.kind,repo:c.repo,onClose:()=>l(null),onDone:e=>{l(null),d(e),f(),n()}})]})}function FK({sessionId:e,kind:t,repo:n,onClose:r,onDone:i}){let[a,o]=(0,V.useState)(n.draft.title),[s,c]=(0,V.useState)(n.draft.body),[l,u]=(0,V.useState)(!1),[d,f]=(0,V.useState)(null);er(!0,r,!l);let p=(0,V.useRef)(null);yn(p,!0);let m=async()=>{u(!0),f(null);try{if(t===`commit`){let t=await Jn(e,n.root,`${a.trim()}\n\n${s.trim()}`.trim());i(`Committed ${wK(t.files.length,`file`)} as ${t.commit}.`)}else i(`Opened ${(await Sn(e,n.root,a,s)).url}`)}catch(e){f(VF(e)),u(!1)}},h=t===`commit`?n.uncommitted:n.files;return I(`div`,{className:`modal-overlay`,onClick:l?void 0:r,children:R(`div`,{ref:p,className:`modal-panel sp-git-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":t===`commit`?`Commit this chat’s changes`:`Create a pull request`,onClick:e=>e.stopPropagation(),children:[R(`div`,{className:`modal-header`,children:[I(`h3`,{children:t===`commit`?`Commit this chat’s changes`:`Create a pull request`}),I(`button`,{type:`button`,className:`btn-icon`,onClick:r,disabled:l,"aria-label":`Close`,children:I(bc,{size:18})})]}),R(`div`,{className:`modal-body sp-git-body`,children:[I(`p`,{className:`sp-meta`,children:t===`commit`?`In ${kd(n.root)} on ${kd(n.branch)}. Only the files below are committed; anything else you changed stays as it is.`:`Pushes ${kd(n.branch)} to ${n.remote} (never forced), then opens a pull request with GitHub's gh tool.`}),R(`label`,{className:`sp-field`,children:[I(`span`,{children:t===`commit`?`Summary`:`Title`}),I(`input`,{value:a,onChange:e=>o(e.target.value),disabled:l})]}),R(`label`,{className:`sp-field`,children:[I(`span`,{children:t===`commit`?`Details`:`Description`}),I(`textarea`,{value:s,onChange:e=>c(e.target.value),rows:7,disabled:l})]}),R(`div`,{className:`sp-meta`,children:[wK(h.length,`file`),`: `,h.join(`, `)]}),t===`commit`&&n.ignored.length>0&&R(`div`,{className:`sp-meta`,children:[`Left out, because git ignores `,n.ignored.length===1?`it`:`them`,`: `,n.ignored.join(`, `)]}),d&&I(`p`,{className:`sp-error`,role:`alert`,children:d})]}),R(`div`,{className:`sp-picker-actions`,children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:r,disabled:l,children:`Cancel`}),R(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void m(),disabled:l||!a.trim(),children:[l&&I(B,{size:13,className:`spin`,"aria-hidden":`true`}),t===`commit`?`Commit ${wK(h.length,`file`)}`:`Push and open PR`]})]})]})})}RegExp(`\\\\(${Object.keys({rightarrow:`→`,to:`→`,longrightarrow:`→`,Rightarrow:`⇒`,leftarrow:`←`,uparrow:`↑`,downarrow:`↓`,Uparrow:`⇑`,Downarrow:`⇓`,times:`×`,le:`≤`,leq:`≤`,ge:`≥`,geq:`≥`,approx:`≈`,pm:`±`,cdot:`·`}).sort((e,t)=>t.length-e.length).join(`|`)})(?![A-Za-z])`,`g`),"`".repeat(3);var IK=`slide-decks`;`${IK}`,`${IK}`;var LK=e=>!e||e.status===`done`||e.status===`failed`,RK=or(e=>({drafts:{},update:(t,n)=>e(e=>{let r=e.drafts[t],i=LK(r)?{status:`preparing`,markdown:``,previous:r?.markdown||void 0}:r;return{drafts:{...e.drafts,[t]:{...i,...n}}}})}));function zK(e){let t=RK.getState().drafts[e];LK(t)||RK.getState().update(e,{status:`failed`})}function BK(){return(0,V.useSyncExternalStore)(Ht,()=>qt()>0)}function VK(e){let t=e.toLowerCase().replace(/\.$/,``);return t===`localhost`||t.endsWith(`.localhost`)||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)||t===`[::1]`}var HK=/^[a-z][a-z0-9+.-]*:(?!\d)/i;function UK(e){let t=e.trim();if(!t||/\s/.test(t))return null;if(HK.test(t))return t;let n;try{n=new URL(`http://${t}`)}catch{return null}return VK(n.hostname)?n.href:n.hostname.includes(`.`)||n.port!==``?(n.protocol=`https:`,n.href):null}var WK={starting:`browserPane.devServer.starting`,ready:`browserPane.devServer.ready`,failed:`browserPane.devServer.failed`,exited:`browserPane.devServer.exited`,stopped:`browserPane.devServer.stopped`},GK=e=>e.status===`starting`||e.status===`ready`;function KK(e,t){t.catch(t=>P.ui.error(`Browser pane: ${e} failed`,t))}function qK(e){let t=e.chats[0],n=z(e=>e.currentSessionId),r=z(e=>e.sessions.find(e=>e.id===t)?.title),i=L();return t===n?i(`browserPane.startedHere`):r===void 0?null:i(`browserPane.startedIn`,{title:r})}function JK({server:e}){let t=qK(e);return t===null?null:I(`div`,{className:`bp-devserver-chat`,children:t})}function YK({api:e,servers:t}){let[n,r]=(0,V.useState)(!1),i=(0,V.useRef)(null),a=()=>r(!1),o=t.filter(GK).length,s=L();return R(`div`,{className:`bp-menu`,children:[I(`button`,{ref:i,type:`button`,className:`btn-icon-sm${n||o?` active`:``}`,"aria-label":s(`browserPane.devServers`),"aria-expanded":n,title:o?s(`browserPane.devServersRunning`,{n:o}):s(`browserPane.devServers`),onClick:()=>r(e=>!e),children:I(Os,{size:15})}),R(Mc,{open:n,onClose:a,anchor:i,label:s(`browserPane.devServers`),placement:`below`,align:`end`,children:[I(`div`,{className:`popover-heading`,children:s(`browserPane.devServers`)}),t.length===0&&I(`p`,{className:`bp-devservers-empty`,children:s(`browserPane.devServersEmpty`)}),t.map(t=>R(`div`,{className:`bp-devserver`,role:`group`,"aria-label":s(`browserPane.devServerNamed`,{name:t.name}),children:[R(`div`,{className:`bp-devserver-head`,children:[I(`span`,{className:`bp-devserver-name`,children:t.name}),I(`span`,{className:`bp-devserver-status is-${t.status}`,children:s(WK[t.status])}),R(`span`,{className:`bp-devserver-port`,dir:`ltr`,children:[`:`,t.port]})]}),I(JK,{server:t}),I(`div`,{className:`bp-devserver-cmd`,title:t.cwd,dir:`ltr`,children:t.argv.join(` `)}),R(`div`,{className:`bp-devserver-actions`,children:[R(`button`,{type:`button`,className:`bp-chip`,disabled:t.status!==`ready`,onClick:()=>{a(),KK(`open dev server`,e.openTab(t.url))},children:[I(Wo,{size:12,"aria-hidden":`true`}),` `,s(`browserPane.openInPane`)]}),R(`button`,{type:`button`,className:`bp-chip`,disabled:!GK(t),onClick:()=>KK(`stop dev server`,e.stopDevServer(t.key)),children:[I(Oi,{size:12,"aria-hidden":`true`}),` `,s(`browserPane.stopServer`)]})]})]},t.key))]})]})}var XK=`Mod+Shift+B`,ZK=`Mod+Shift+S`;function QK(e,t){t.catch(t=>P.ui.error(`Browser pane: ${e} failed`,t))}function $K({pane:e,api:t,onClosePane:n,addressRef:r}){let i=e.tabs.find(t=>t.id===e.activeTabId),a=i.url!==null,o=L();return R(`div`,{className:`bp-toolbar`,children:[R(`div`,{className:`bp-tabs`,role:`tablist`,"aria-label":o(`browserPane.tabs`),children:[e.tabs.map(n=>{let r=n.id===e.activeTabId;return R(`div`,{className:`bp-tab${r?` is-active`:``}`,children:[R(`button`,{type:`button`,role:`tab`,"aria-selected":r,className:`bp-tab-title`,title:n.url??n.title,onClick:()=>QK(`select tab`,t.selectTab(n.id)),children:[n.loading&&I(`span`,{className:`bp-tab-spinner`,"aria-hidden":`true`}),n.control===`private`&&I(go,{size:11,"aria-label":o(`browserPane.private`)}),I(`span`,{children:n.title||n.url||o(`browserPane.newTab`)})]}),I(`button`,{type:`button`,className:`bp-tab-close`,"aria-label":o(`browserPane.closeTabNamed`,{name:n.title}),title:o(`browserPane.closeTab`),onClick:()=>QK(`close tab`,t.closeTab(n.id)),children:I(bc,{size:12})})]},n.id)}),I(`button`,{type:`button`,className:`btn-icon-sm bp-new-tab`,"aria-label":o(`browserPane.newTab`),title:o(`browserPane.newTab`),onClick:()=>QK(`open tab`,t.openTab(null)),children:I(os,{size:14})})]}),R(`div`,{className:`bp-nav`,children:[I(`button`,{type:`button`,className:`btn-icon-sm`,"aria-label":o(`browserPane.back`),title:o(`browserPane.back`),disabled:!i.canGoBack,onClick:()=>QK(`back`,t.history(i.id,`back`)),children:I(Pr,{size:15})}),I(`button`,{type:`button`,className:`btn-icon-sm`,"aria-label":o(`browserPane.forward`),title:o(`browserPane.forward`),disabled:!i.canGoForward,onClick:()=>QK(`forward`,t.history(i.id,`forward`)),children:I(Ir,{size:15})}),i.loading?I(`button`,{type:`button`,className:`btn-icon-sm`,"aria-label":o(`browserPane.stopLoading`),title:o(`browserPane.stopLoading`),onClick:()=>QK(`stop`,t.history(i.id,`stop`)),children:I(bc,{size:15})}):I(`button`,{type:`button`,className:`btn-icon-sm`,"aria-label":o(`browserPane.reload`),title:o(`browserPane.reload`),disabled:!a,onClick:()=>QK(`reload`,t.history(i.id,`reload`)),children:I(bs,{size:15})}),I(eq,{tab:i,inputRef:r,onSubmit:e=>QK(`navigate`,t.navigate(i.id,e))},i.id),I(`button`,{type:`button`,className:`btn-icon-sm${e.picking?` active`:``}`,"aria-label":o(`browserPane.select`),"aria-pressed":e.picking,title:o.hint(o(e.picking?`browserPane.selectStop`:`browserPane.selectStart`),Gu(ZK)),disabled:!a,onClick:()=>QK(`select element`,t.togglePicking()),children:I(Xs,{size:15})}),I(`button`,{type:`button`,className:`btn-icon-sm${i.devToolsOpen?` active`:``}`,"aria-label":o(`browserPane.devTools`),"aria-pressed":i.devToolsOpen,title:o(i.devToolsOpen?`browserPane.devToolsHide`:`browserPane.devToolsShow`),disabled:!a,onClick:()=>QK(`developer tools`,t.toggleDevTools(i.id)),children:I(Js,{size:15})}),I(oq,{api:t,tab:i}),I(YK,{api:t,servers:e.devServers}),I(tq,{api:t,tab:i}),I(`button`,{type:`button`,className:`btn-icon-sm`,"aria-label":o(`browserPane.close`),title:o.hint(o(`browserPane.close`),Gu(XK)),onClick:n,children:I(Ro,{size:15})})]})]})}function eq({tab:e,inputRef:t,onSubmit:n}){let[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(!1),s=L();return(0,V.useEffect)(()=>{i(null),o(!1)},[e.url]),I(`form`,{className:`bp-address`,onSubmit:a=>{a.preventDefault();let s=UK(r??e.url??``);s===null?o(!0):(i(null),o(!1),n(s),t.current?.blur())},role:`search`,children:I(`input`,{ref:t,type:`text`,className:`bp-address-input${a?` is-invalid`:``}`,"aria-label":s(`browserPane.address`),"aria-invalid":a,title:a?s(`browserPane.addressInvalid`):void 0,placeholder:s(`browserPane.addressPlaceholder`),dir:`ltr`,spellCheck:!1,autoComplete:`off`,value:r??e.url??``,onChange:e=>{i(e.target.value),o(!1)},onFocus:e=>e.currentTarget.select(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),i(null),o(!1),e.currentTarget.blur())},...Lt})})}function tq({api:e,tab:t}){let[n,r]=(0,V.useState)(!1),i=(0,V.useRef)(null),a=()=>r(!1),o=L();return R(`div`,{className:`bp-menu`,children:[I(`button`,{ref:i,type:`button`,className:`btn-icon-sm${n?` active`:``}`,"aria-label":o(`browserPane.moreActions`),"aria-expanded":n,title:o(`browserPane.more`),onClick:()=>r(e=>!e),children:I(Qi,{size:15})}),R(Mc,{open:n,onClose:a,anchor:i,label:o(`browserPane.actions`),placement:`below`,align:`end`,children:[R(`button`,{type:`button`,className:`popover-item`,onClick:()=>{a(),QK(`tab privacy`,e.setControl(t.id,t.control===`private`?`shared`:`private`))},children:[t.control===`private`?I(mo,{size:14,"aria-hidden":`true`}):I(go,{size:14,"aria-hidden":`true`}),R(`span`,{className:`popover-item-body`,children:[I(`span`,{className:`popover-item-title`,children:o(t.control===`private`?`browserPane.shareTab`:`browserPane.privateTab`)}),I(`span`,{className:`popover-item-note`,children:o(t.control===`private`?`browserPane.shareTabNote`:`browserPane.privateTabNote`)})]})]}),R(`button`,{type:`button`,className:`popover-item`,disabled:t.url===null,onClick:()=>{a(),QK(`open in system browser`,e.openExternal(t.id))},children:[I(na,{size:14,"aria-hidden":`true`}),I(`span`,{className:`popover-item-body`,children:I(`span`,{className:`popover-item-title`,children:o(`browserPane.openExternal`)})})]}),R(`button`,{type:`button`,className:`popover-item`,onClick:()=>{a(),QK(`clear browsing data`,e.clearBrowsingData())},children:[I(ea,{size:14,"aria-hidden":`true`}),R(`span`,{className:`popover-item-body`,children:[I(`span`,{className:`popover-item-title`,children:o(`browserPane.clearData`)}),I(`span`,{className:`popover-item-note`,children:o(`browserPane.clearDataNote`)})]})]})]})]})}var nq=[{name:`iPhone SE`,width:375,height:667,mobile:!0},{name:`iPhone 15`,width:393,height:852,mobile:!0},{name:`Pixel 8`,width:412,height:915,mobile:!0},{name:`iPad mini`,width:768,height:1024,mobile:!0},{name:`iPad Air`,width:820,height:1180,mobile:!0},{name:`Laptop`,width:1280,height:800,mobile:!1,label:`browserPane.laptop`}],rq=[{label:`browserPane.scheme.system`,value:null},{label:`browserPane.scheme.light`,value:`light`},{label:`browserPane.scheme.dark`,value:`dark`}],iq=200,aq=4e3;function oq({api:e,tab:t}){let[n,r]=(0,V.useState)(!1),i=(0,V.useCallback)(()=>r(!1),[]),a=(0,V.useRef)(null),o=t.viewport,s=o?.size??null,c=o?.colorScheme??null,[l,u]=(0,V.useState)(``),[d,f]=(0,V.useState)(``),p=L();(0,V.useEffect)(()=>{u(s?String(s.width):``),f(s?String(s.height):``)},[s?.width,s?.height]);let m=n=>{let r=n.size===null&&n.colorScheme===null;QK(`responsive`,e.setViewport(t.id,r?null:n))},h=e=>{let t=Number(e);return Number.isInteger(t)&&t>=iq&&t<=aq?t:null},g=h(l),_=h(d);return R(`div`,{className:`bp-menu`,children:[I(`button`,{ref:a,type:`button`,className:`btn-icon-sm${o?` active`:``}`,"aria-label":p(`browserPane.responsive`),"aria-expanded":n,"aria-pressed":o!==null,title:s?p(`browserPane.responsiveSize`,{width:s.width,height:s.height}):p(`browserPane.responsive`),disabled:t.url===null,onClick:()=>r(e=>!e),children:I(Oo,{size:15})}),I(Mc,{open:n,onClose:i,anchor:a,label:p(`browserPane.responsive`),placement:`below`,align:`end`,children:R(`div`,{className:`bp-responsive`,children:[o?.source===`agent`&&I(`p`,{className:`bp-responsive-note`,children:p(`browserPane.agentChose`)}),R(`div`,{className:`bp-responsive-presets`,role:`group`,"aria-label":p(`browserPane.screenSize`),children:[I(`button`,{type:`button`,className:`bp-chip${s===null?` is-on`:``}`,"aria-pressed":s===null,onClick:()=>m({size:null,colorScheme:c}),children:p(`browserPane.fillPane`)}),nq.map(e=>{let t=s!==null&&s.width===e.width&&s.height===e.height;return I(`button`,{type:`button`,className:`bp-chip${t?` is-on`:``}`,"aria-pressed":t,title:`${e.width}×${e.height}`,onClick:()=>m({size:{width:e.width,height:e.height,mobile:e.mobile},colorScheme:c}),children:e.label?p(e.label):e.name},e.name)})]}),R(`form`,{className:`bp-responsive-size`,onSubmit:e=>{e.preventDefault(),g!==null&&_!==null&&m({size:{width:g,height:_,mobile:g<768},colorScheme:c})},children:[I(`input`,{"aria-label":p(`browserPane.width`),inputMode:`numeric`,value:l,placeholder:p(`browserPane.width`),onChange:e=>u(e.target.value)}),I(`span`,{"aria-hidden":`true`,children:`×`}),I(`input`,{"aria-label":p(`browserPane.height`),inputMode:`numeric`,value:d,placeholder:p(`browserPane.height`),onChange:e=>f(e.target.value)}),I(`button`,{type:`submit`,className:`bp-chip`,disabled:g===null||_===null,children:p(`browserPane.setSize`)}),I(`button`,{type:`button`,className:`btn-icon-sm`,"aria-label":p(`browserPane.rotate`),title:p(`browserPane.rotate`),disabled:s===null,onClick:()=>s&&m({size:{...s,width:s.height,height:s.width},colorScheme:c}),children:I(gs,{size:15})})]}),I(`div`,{className:`bp-responsive-presets`,role:`group`,"aria-label":p(`browserPane.colorScheme`),children:rq.map(e=>I(`button`,{type:`button`,className:`bp-chip${c===e.value?` is-on`:``}`,"aria-pressed":c===e.value,onClick:()=>m({size:s,colorScheme:e.value}),children:p(e.label)},e.label))})]})})]})}function sq({api:e}){let t=L();return R(`div`,{className:`bp-agent-strip is-picking`,role:`status`,children:[I(`span`,{children:t(`browserPane.pickHelp`)}),I(`button`,{type:`button`,className:`bp-chip`,onClick:()=>QK(`stop selecting`,e.togglePicking()),children:t(`browserPane.done`)})]})}function cq({tab:e,api:t}){let n=L();return e.control===`private`?I(`div`,{className:`bp-agent-strip is-private`,role:`status`,children:I(`span`,{children:n(`browserPane.privateStrip`)})}):e.control===`user`?R(`div`,{className:`bp-agent-strip is-paused`,role:`status`,children:[I(`span`,{children:n(`browserPane.paused`)}),I(`button`,{type:`button`,className:`bp-chip`,onClick:()=>QK(`resume`,t.setControl(e.id,`shared`)),children:n(`browserPane.resume`)})]}):!e.agentActing&&!e.agentBusy?null:R(`div`,{className:`bp-agent-strip`,role:`status`,children:[I(`span`,{children:n(e.agentActing?`browserPane.agentUsing`:`browserPane.agentReading`)}),I(`button`,{type:`button`,className:`bp-chip`,onClick:()=>QK(`pause`,t.setControl(e.id,`user`)),children:n(`browserPane.pause`)})]})}var lq={alert:{ok:`browserPane.dialog.ok`,cancel:null},confirm:{ok:`browserPane.dialog.ok`,cancel:`browserPane.dialog.cancel`},prompt:{ok:`browserPane.dialog.ok`,cancel:`browserPane.dialog.cancel`},beforeunload:{ok:`browserPane.dialog.leave`,cancel:`browserPane.dialog.stay`}};function uq(e){try{return new URL(e).host||e}catch{return e}}function dq({tab:e,api:t}){let n=e.dialog,r=L(),[i,a]=(0,V.useState)(n?.defaultText??``);if((0,V.useEffect)(()=>a(n?.defaultText??``),[n]),!n)return null;let{ok:o,cancel:s}=lq[n.type],c=r=>{t.answerDialog(e.id,r,n.type===`prompt`&&r?i:null).catch(e=>P.ui.error(`Browser pane: answering the page box failed`,e))};return R(`form`,{className:`bp-dialog`,role:`alertdialog`,"aria-label":r(`browserPane.dialog.says`,{host:uq(n.url)}),onSubmit:e=>{e.preventDefault(),c(!0)},children:[I(`span`,{className:`bp-dialog-from`,children:r(`browserPane.dialog.says`,{host:uq(n.url)})}),I(`span`,{className:`bp-dialog-message`,children:n.message}),n.type===`prompt`&&I(`input`,{className:`bp-dialog-input`,"aria-label":r(`browserPane.dialog.answer`),value:i,onChange:e=>a(e.target.value),autoFocus:!0}),R(`span`,{className:`bp-dialog-actions`,children:[s&&I(`button`,{type:`button`,className:`bp-chip`,onClick:()=>c(!1),children:r(s)}),I(`button`,{type:`submit`,className:`bp-chip is-on`,children:r(o)})]})]})}function fq(e,t){return(e.ctrlKey||e.metaKey)&&e.shiftKey&&!e.altKey&&e.key.toLowerCase()===t}function pq({api:e}){let t=z(e=>e.currentSessionId),n=JI(),r=qI(e=>e.pane);(0,V.useEffect)(()=>YI(e),[e]),(0,V.useEffect)(()=>{e.setView(t,n)},[e,t,n]),(0,V.useEffect)(()=>()=>e.setView(z.getState().currentSessionId,!1),[e]),(0,V.useEffect)(()=>e.onPicked(e=>hR.getState().applyPick(e)),[e]),(0,V.useEffect)(()=>{let t=t=>{fq(t,`b`)?(t.preventDefault(),qI.getState().toggle()):fq(t,`s`)&&(t.preventDefault(),qI.getState().setOpen(!0),e.togglePicking().catch(e=>P.ui.warn(`Could not start selecting an element`,e)))};window.addEventListener(`keydown`,t);let n=e.onCommand(e=>{e.kind===`toggle`?qI.getState().toggle():e.chat===z.getState().currentSessionId&&qI.getState().setOpen(!0)});return()=>{window.removeEventListener(`keydown`,t),n()}},[e]);let i=r&&r.chat===t?r.tabs.find(e=>e.id===r.activeTabId):void 0;return!n||!r||!i?null:I(mq,{api:e,pane:r,active:i})}function mq({api:e,pane:t,active:n}){let r=qI(e=>e.width),i=qI(e=>e.setWidth),a=qI(e=>e.setOpen),o=BK(),s=(0,V.useRef)(null),c=(0,V.useRef)(null),[l,u]=(0,V.useState)(null),d=L(),f=RW({width:r,setWidth:i,clamp:HI,min:360,max:II,defaultWidth:520});return(0,V.useLayoutEffect)(()=>{let t=s.current;if(!t)return;let n=()=>{let n=t.getBoundingClientRect();e.setBounds({x:n.x,y:n.y,width:n.width,height:n.height})};n();let r=new ResizeObserver(n);return r.observe(t),window.addEventListener(`resize`,n),()=>{r.disconnect(),window.removeEventListener(`resize`,n)}},[e]),(0,V.useEffect)(()=>{let t=!0;return e.setOccluded(o).then(e=>{t&&u(o?e:null)}).catch(e=>P.ui.error(`Could not hide the browser page under an overlay`,e)),()=>{t=!1}},[e,o]),(0,V.useEffect)(()=>{let e=document.documentElement;return e.style.setProperty(`--browser-pane-inset`,`${f.width}px`),()=>{e.style.removeProperty(`--browser-pane-inset`)}},[f.width]),(0,V.useEffect)(()=>{n.url===null&&c.current?.focus()},[n.id,n.url]),R(`aside`,{className:`browser-pane`,style:{width:f.width},"aria-label":d(`browserPane.label`),children:[I(`div`,{className:`bp-resize${f.dragging?` is-dragging`:``}`,"aria-label":d(`browserPane.resize`),...f.separatorProps}),I($K,{pane:t,api:e,onClosePane:()=>a(!1),addressRef:c}),t.picking?I(sq,{api:e}):I(cq,{tab:n,api:e}),n.dialog&&I(dq,{tab:n,api:e}),n.notice&&I(_q,{notice:n.notice,t:d}),R(`div`,{ref:s,className:`bp-viewport`,children:[l&&I(`img`,{className:`bp-frozen`,src:l,alt:``,"aria-hidden":`true`}),n.url===null&&!l&&I(vq,{pane:t,onOpen:t=>{e.navigate(n.id,t).catch(e=>P.ui.error(`Browser pane: navigate failed`,e))}})]})]})}var hq={media:`browserPane.permission.media`,geolocation:`browserPane.permission.geolocation`,notifications:`browserPane.permission.notifications`};function gq(e,t){switch(e.kind){case`blocked`:return e.message;case`load-failed`:return t(`browserPane.notice.loadFailed`,{url:e.url,message:e.message});case`permission-denied`:{let n=hq[e.permission];return t(`browserPane.notice.permissionDenied`,{what:n?{ref:n}:e.permission,origin:e.origin||{ref:`browserPane.notice.thisPage`}})}}}function _q({notice:e,t}){return I(`div`,{className:`bp-notice is-${e.kind}`,role:e.kind===`load-failed`?`alert`:`status`,children:gq(e,t)})}function vq({pane:e,onOpen:t}){let n=L();return R(`div`,{className:`bp-newtab`,children:[I(`h2`,{className:`bp-newtab-title`,children:n(`browserPane.newTab`)}),e.recent.length===0?I(`p`,{className:`bp-newtab-empty`,children:n(`browserPane.newTabEmpty`)}):I(`ul`,{className:`bp-recent`,"aria-label":n(`browserPane.recent`),children:e.recent.map(e=>I(`li`,{children:R(`button`,{type:`button`,className:`bp-recent-item`,onClick:()=>t(e.url),title:e.url,children:[I(`span`,{className:`bp-recent-title`,children:e.title}),I(`span`,{className:`bp-recent-url`,dir:`ltr`,children:e.url})]})},e.url))})]})}function yq(){let e=JI(),t=qI(e=>e.toggle),n=L();if(!zI())return null;let r=n(e?`browserPane.hide`:`browserPane.show`),i=n.hint(r,Gu(XK));return I(`button`,{type:`button`,className:`btn-icon-sm bp-toggle${e?` active`:``}`,onClick:t,"aria-label":r,"aria-pressed":e,title:i,children:I(Ha,{size:15})})}var bq={mcp:`tools.cat.mcp`,skill:`tools.cat.skill`,agent:`tools.cat.agent`},xq={gaiapy:`setup.agent.gaiapy`,gaiacpp:`setup.agent.gaiacpp`};function Sq(e,t){let n=bq[e];return n?t(n):e.replace(/_/g,` `)}function Cq(e){let t=new Map;for(let n of e){let e=t.get(n.category);e?e.push(n):t.set(n.category,[n])}return[...t.entries()]}function wq(e){return e.split(`
200
+ `,1)[0].trim()}function Tq({sessionId:e,busy:t}){let n=L();return I(oG,{id:`tools`,title:n(`tools.title`),children:I(Eq,{sessionId:e,busy:t})})}function Eq({sessionId:e,busy:t}){let n=L(),[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(null),l=(0,V.useCallback)(()=>{let t=!0;return Promise.resolve().then(()=>Bn(e)).then(e=>{t&&(i(nU(e,e=>Array.isArray(e.tools),`list of tools`).tools),o(e.program??null),c(null))}).catch(n=>{if(!t)return;let r=n.httpStatus,a=n.detail;P.ui.warn(`Could not list the tools of session=${e}`,n),i(null),o(null),c({notRunning:r===409,text:a||BF(n)})}),()=>{t=!1}},[e]);if((0,V.useEffect)(l,[l]),bf(t,l),Sf(t,s?.notRunning===!0,l),s?.notRunning)return I(`p`,{className:`sp-meta`,role:`status`,children:n(`tools.notRunning`)});if(s)return I(`p`,{className:`sp-error`,role:`alert`,children:n(`tools.listError`,{error:s.text})});if(!r)return I(`p`,{className:`sp-meta`,children:n(`sp.checking`)});let u=a&&xq[a]&&R(`p`,{className:`sp-meta sp-agent-program`,children:[n(`tools.program`,{name:n(xq[a]),id:a}),a===`gaiacpp`&&R(F.Fragment,{children:[` `,I(`span`,{className:`setup-choice-tag`,children:n(`setup.agent.beta`)})]})]});return r.length===0?R(F.Fragment,{children:[u,I(`p`,{className:`sp-meta`,children:n(`tools.empty`)})]}):R(F.Fragment,{children:[u,I(`div`,{className:`sp-tools`,"aria-label":n(`tools.listLabel`),role:`group`,children:Cq(r).map(([e,t])=>{let r=Sq(e,n);return R(`section`,{className:`sp-tool-group`,"aria-label":r,children:[R(`h4`,{className:`sp-tool-group-title`,children:[r,` `,I(`span`,{className:`sp-meta`,children:t.length})]}),I(`ul`,{className:`sp-list`,children:t.map(e=>R(`li`,{className:`sp-tool`,children:[I(`code`,{className:`sp-item-name`,dir:`ltr`,children:e.name}),e.description&&I(`span`,{className:`sp-meta`,title:e.description,children:wq(e.description)})]},e.name))})]},e)})})]})}var Dq={model:`skills.how.model`,user:`skills.how.user`,auto:`skills.how.auto`,always:`skills.how.always`};function Oq({sessionId:e,busy:t}){let n=L(),r=z(e=>e.skillUses),[i,a]=(0,V.useState)(void 0),[o,s]=(0,V.useState)(null),c=FG(),l=(0,V.useCallback)(()=>{let t=c();Promise.resolve().then(()=>Bn(e)).then(n=>{if(!t())return;let r=nU(n,e=>e.skills===null||Array.isArray(e.skills),`list of skills`);PI.getState().setSignals(e,{skills:(r.skills??[]).map(e=>e.name)}),a(r.skills??null),s(null)}).catch(n=>{if(!t())return;let r=n.httpStatus,i=n.detail;P.ui.warn(`Could not list the skills of session=${e}`,n),a(void 0),PI.getState().setSignals(e,{skills:[]}),s({notRunning:r===409,text:i||(n instanceof Error?n.message:String(n))})})},[c,e]);(0,V.useEffect)(()=>{l()},[l,r]),bf(t,l),Sf(t,o?.notRunning===!0,l);let u=o&&!o.notRunning?o:null;return!u&&(!i||i.length===0)?null:I(oG,{id:`skills`,title:n(`skills.title`),children:u?I(`p`,{className:`sp-error`,children:n(`skills.listError`,{error:u.text})}):I(`ul`,{className:`sp-list`,"aria-label":n(`skills.listLabel`),children:(i??[]).map(e=>R(`li`,{className:`sp-row-line`,title:n(Dq[e.how]??`skills.how.always`),children:[I(`span`,{className:`sp-row-icon sp-skill-icon`,"aria-hidden":`true`,children:I(Ks,{size:14})}),I(`code`,{className:`sp-item-name`,dir:`ltr`,children:e.name})]},e.name))})})}function kq({label:e,children:t}){return I(`div`,{className:`sp-row`,children:R(`div`,{className:`sp-row-line`,children:[I(`span`,{className:`sp-row-label sp-quiet`,children:e}),I(`span`,{className:`sp-row-end`,children:t})]})})}function Aq({sessionId:e}){let t=L();return I(oG,{id:`session`,title:t(`sp.section.session`),children:I(jq,{sessionId:e})})}function jq({sessionId:e}){let t=L(),n=z(t=>t.sessions.find(t=>t.id===e)),r=z(e=>e.systemStatus),[i,a]=(0,V.useState)(!1),[o,s]=(0,V.useState)(null),c=()=>{s(null),Promise.resolve().then(()=>navigator.clipboard.writeText(e)).then(()=>a(!0)).catch(n=>{P.ui.warn(`Could not copy the id of session=${e}`,n),a(!1),s(t(`session.copyFailed`,{error:VF(n)}))})},l=n?.created_at?new Date(n.created_at):null,u=l&&!Number.isNaN(l.getTime())?l.toLocaleString(Ln(t),{dateStyle:`medium`,timeStyle:`short`}):null;return R(`div`,{className:`sp-rows`,children:[R(kq,{label:t(`session.id`),children:[I(`code`,{className:`sp-mono`,dir:`ltr`,title:e,children:e}),I(`button`,{type:`button`,className:`btn-icon-sm sp-info`,onClick:c,"aria-label":t(`session.copyId`),title:t(i?`code.copied`:`session.copyId`),children:I(i?ci:Bi,{size:13})})]}),o&&I(`span`,{className:`sp-error`,role:`alert`,children:o}),u&&I(kq,{label:t(`session.started`),children:I(`span`,{children:u})}),n?.agent_type&&I(kq,{label:t(`session.agent`),children:I(`code`,{className:`sp-mono`,dir:`ltr`,children:n.agent_type})}),r?.version&&I(kq,{label:t(`session.gaia`),children:I(`span`,{dir:`ltr`,children:r.version})}),r?.lemonade_version&&I(kq,{label:t(`session.lemonade`),children:I(`span`,{dir:`ltr`,children:r.lemonade_version})})]})}function Mq(e,t,n,r){if(!e)return t(`schedules.time.never`);let i=new Date(e),a=(n||new Date).getTime()-i.getTime(),o=Math.floor(a/1e3);if(o<0){let e=Math.abs(o);if(e<60)return t(`schedules.time.inSeconds`,{n:e});let n=Math.floor(e/60);if(n<60)return t(`schedules.time.inMinutes`,{n});let r=Math.floor(n/60);return r<24?t(`schedules.time.inHours`,{n:r}):t(`schedules.time.inDays`,{n:Math.floor(r/24)})}if(o<60)return t(`time.justNow`);let s=Math.floor(o/60);if(s<60)return t(`time.minutesAgo`,{n:s});let c=Math.floor(s/60);return c<24?t(`time.hoursAgo`,{n:c}):i.toLocaleDateString(r,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function Nq(e,t,n=gt.bare,r){if(!e)return n(`schedules.time.never`);let i=Mq(e,n,t,r),a=new Date(e);return a.getTime()<=(t||new Date).getTime()?i:n(`schedules.time.clockIn`,{clock:a.toLocaleString(r,{weekday:`short`,hour:`numeric`,minute:`2-digit`}),relative:i})}function Pq(e){if(!e)return!1;let t=new Date(e).getTime()-Date.now();return t>0&&t<6e4}function Fq(e,t,n=0){let r=new Date(2e3,0,1,t,n);return new Intl.DateTimeFormat(Ln(e),{hour:`numeric`,minute:`2-digit`}).format(r)}function Iq(e,t){let[n,r]=e.split(`:`).map(Number);return Fq(t,n,r)}function Lq(e,t,n){let r=`${e}.${new Intl.PluralRules(n.locale).select(t)}`;return j(r)?r:null}var Rq=e=>e.length===5&&e.every(e=>e<5),zq=e=>e.length===2&&e.includes(5)&&e.includes(6);function Bq(e,t,n){if(Rq(e))return n(`schedules.desc.days.weekdays`);if(zq(e))return n(`schedules.desc.days.weekends`);if(e.length===7)return n(`schedules.desc.days.every`);let r=Lq(`schedules.desc.dayList`,e.length,t);return r?n(r,{days:e.map(e=>n(`schedules.dayName.${e}`)).join(n(`schedules.desc.dayJoin`))}):null}function Vq(e,t,n,r){let{kind:i,count:a,unit:o,days:s,time:c,start_hour:l,end_hour:u}=e,d=e=>c?n(`schedules.desc.at`,{when:e,time:Iq(c,r)}):e;if(i===`every`||i===`window`){let e=a&&o?Lq(`schedules.span.${o}`,a,t):null,c=s?Bq(s,t,n):void 0;if(!e||c===null)return null;let d=n(e,{n:a});if(i===`every`)return c?n(`schedules.desc.everyOn`,{span:d,days:c}):n(`schedules.desc.every`,{span:d});if(l==null||u==null)return null;let f=n(`schedules.hours`,{start:Fq(r,l),end:Fq(r,u)});return c?n(`schedules.desc.windowOn`,{span:d,hours:f,days:c}):n(`schedules.desc.window`,{span:d,hours:f})}if(i===`daily`)return c?d(n(`schedules.desc.daily`)):null;if(i!==`days`||!s?.length)return null;if(s.length===7)return d(n(`schedules.desc.daily`));if(Rq(s))return d(n(`schedules.desc.weekdays`));if(zq(s))return d(n(`schedules.desc.weekends`));let f=Bq(s,t,n);return f&&d(n(`schedules.desc.onDays`,{days:f}))}function Hq(e,t){return!e||Vq(e,t,t.bare,t)===null?null:t.compose((n,r)=>Vq(e,t,n,wn(r))??``)}var Uq=14,Wq={chat:{label:`focus.chat`,Icon:wo},coding:{label:`focus.coding`,Icon:Ii},commands:{label:`focus.commands`,Icon:ic},documents:{label:`focus.documents`,Icon:Sa},scheduled:{label:`focus.scheduled`,Icon:ni},plan:{label:`focus.plan`,Icon:uo},web:{label:`focus.web`,Icon:Ha},email:{label:`focus.email`,Icon:vo}};function Gq({facets:e}){let t=L(),n=PI(e=>e.reveal);return I(`ul`,{className:`sp-focus`,"aria-label":t(`focus.label`),children:e.map(e=>I(Kq,{facet:e,onGo:n},e.kind))})}function Kq({facet:e,onGo:t}){let n=L(),r=aG(),{label:i,Icon:a}=Wq[e.kind],o=R(F.Fragment,{children:[I(a,{size:12,"aria-hidden":`true`}),n(i),e.count!=null&&I(`bdi`,{className:`sp-focus-count`,dir:`ltr`,children:e.count})]});return I(`li`,{className:`sp-focus-item${r}`,children:e.section?I(`button`,{type:`button`,className:`sp-chip is-${e.kind}`,onClick:()=>t(e.section),children:o}):I(`span`,{className:`sp-chip is-${e.kind}`,children:o})})}var qq={done:{label:`activity.planStatus.done`,Icon:ci},running:{label:`activity.planStatus.running`,Icon:B},failed:{label:`activity.planStatus.failed`,Icon:bc},stopped:{label:`activity.planStatus.stopped`,Icon:Wr},pending:{label:`activity.planStatus.pending`,Icon:Ai}};function Jq({plan:e}){let t=L();if(!e)return null;let n=e.steps.length,r=e.statuses.filter(e=>e===`done`).length;return R(oG,{id:`plan`,title:t(`plan.title`),summary:t(`plan.progress`,{done:r,total:n}),children:[I(`div`,{className:`sp-progress`,role:`progressbar`,"aria-label":t(`plan.title`),"aria-valuemin":0,"aria-valuemax":n,"aria-valuenow":r,children:I(`span`,{style:{width:`${r/n*100}%`}})}),I(`ol`,{className:`sp-list sp-plan${e.finished?``:` is-live`}`,"aria-label":t(`plan.listLabel`),children:e.steps.map((n,r)=>{let i=e.statuses[r]??`pending`,{label:a,Icon:o}=qq[i];return R(`li`,{className:`sp-row-line sp-plan-step is-${i}`,"aria-current":i===`running`?`step`:void 0,children:[I(`span`,{className:`sp-row-icon`,title:t(a),children:I(o,{size:Uq,className:i===`running`?`spin`:i===`done`?`plan-icon-done`:void 0,"aria-label":t(a)})}),I(`span`,{className:`sp-plan-text`,children:I(`bdi`,{children:n})})]},`${r}-${n}`)})})]})}function Yq({schedules:e}){let t=L(),n=z(e=>e.setShowSchedules),[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(!1);return e.length===0?null:R(oG,{id:`schedule`,title:t(`sched.title`),children:[I(`ul`,{className:`sp-list`,"aria-label":t(`sched.listLabel`),children:e.map(e=>I(Xq,{schedule:e,working:a,onWorking:o,onSettled:i},e.id))}),r&&I(`span`,{className:`sp-error`,role:`alert`,children:r}),I(`button`,{type:`button`,className:`link-btn sp-more`,onClick:()=>n(!0),children:t(`sched.manage`)})]})}function Xq({schedule:e,working:t,onWorking:n,onSettled:r}){let i=L(),a=aK(e=>e.updateScheduleStatus),o=aK(e=>e.runScheduleNow),s=e.status===`paused`,c=e=>{n(!0),e.finally(()=>{n(!1),r(aK.getState().actionError)})},l=Hq(e.description_parts,i)??e.description,u=i.compose((t,n)=>t(`schedules.card.next`,{when:s?t(`schedules.status.paused`):Nq(e.next_run_at,void 0,t,Ln(wn(n)))}));return R(`li`,{className:`sp-row`,children:[R(`div`,{className:`sp-row-line`,children:[I(`span`,{className:`sp-row-icon`,"aria-hidden":`true`,children:I(ni,{size:Uq})}),I(`span`,{className:`sp-row-label`,title:e.prompt,children:I(`bdi`,{children:e.name})}),R(`span`,{className:`sp-row-end`,children:[I(`button`,{type:`button`,className:`btn-icon-sm sp-info`,onClick:()=>c(a(e.name,s?`active`:`paused`)),disabled:t,"aria-label":i(s?`schedules.card.resume`:`schedules.card.pause`),title:i(s?`schedules.card.resume`:`schedules.card.pause`),children:I(s?ns:Ko,{size:13})}),I(`button`,{type:`button`,className:`btn-icon-sm sp-info`,onClick:()=>c(o(e.name)),disabled:t||e.running===!0,"aria-label":i(`schedules.card.runNow`),title:i(`schedules.card.runNowTitle`),children:e.running?I(B,{size:13,className:`spin`}):I(Sc,{size:13})})]})]}),I(`span`,{className:`sp-row-sub sp-quiet`,children:l}),R(`span`,{className:`sp-row-sub sp-quiet`,children:[e.running?i(`schedules.card.running`):u,` · `,i(`schedules.card.runs`,{n:e.run_count})]}),e.last_error&&I(`span`,{className:`sp-row-sub sp-error`,children:i(`schedules.card.lastFailed`,{error:e.last_error})})]})}var Zq={ok:{label:`cmd.ok`,Icon:ci},failed:{label:`cmd.failed`,Icon:bc},declined:{label:`cmd.declined`,Icon:Wr},stopped:{label:`activity.planStatus.stopped`,Icon:ec},running:{label:`cmd.running`,Icon:B}};function Qq({commands:e,onJumpToMessage:t}){let n=L(),[r,i]=(0,V.useState)(!1);if(e.length===0)return null;let a=[...e].reverse(),o=r?a:a.slice(0,5),s=e.filter(e=>e.state===`failed`).length;return R(oG,{id:`commands`,title:n(`cmd.title`),summary:s>0?n.plural(`cmd.failedCount`,s,{n:s}):I(`bdi`,{dir:`ltr`,children:e.length}),children:[I(`ul`,{className:`sp-list`,"aria-label":n(`cmd.listLabel`),children:o.map(e=>{let{label:r,Icon:i}=Zq[e.state],a=bd(e.command,!0),o=R(F.Fragment,{children:[I(`span`,{className:`sp-row-icon sp-cmd-icon is-${e.state}`,title:n(r),children:I(i,{size:Uq,className:e.state===`running`?`spin`:void 0,"aria-label":n(r)})}),I(`code`,{className:`sp-row-label sp-mono`,dir:`ltr`,title:a,children:a})]});return I(`li`,{children:e.messageId==null?I(`div`,{className:`sp-row-line`,children:o}):I(`button`,{type:`button`,className:`sp-row-line sp-row-button`,onClick:()=>t(e.messageId),children:o})},e.key)})}),e.length>5&&I(`button`,{type:`button`,className:`link-btn sp-more`,onClick:()=>i(e=>!e),children:r?n(`out.fewer`):n(`out.more`,{n:e.length-5})})]})}function $q(e,t){let n=e[e.length-1];return(n?.role===`assistant`?n.turnSummary?.documents??[]:[]).find(e=>sK(e.path,t))?.passages??0}function eJ({documents:e,messages:t}){let n=L();return e.length===0?null:I(oG,{id:`documents`,title:n(`docsp.title`),summary:I(`bdi`,{dir:`ltr`,children:e.length}),children:I(`ul`,{className:`sp-list`,"aria-label":n(`docsp.listLabel`),children:e.map(({entry:e,doc:r})=>{let i=e.name||r?.filename||e.path.split(/[\\/]/).pop()||e.path,a=r?.indexing_status,o=a===`indexing`||a===`pending`,s=a===`failed`||a===`missing`,c=$q(t,e.path);return R(`li`,{className:`sp-row`,children:[R(`div`,{className:`sp-row-line`,children:[I(`span`,{className:`sp-row-icon`,"aria-hidden":`true`,children:o?I(B,{size:Uq,className:`spin`}):I(Sa,{size:Uq})}),I(`span`,{className:`sp-row-label`,dir:`ltr`,title:e.path,children:i}),R(`span`,{className:`sp-row-end`,children:[c>0&&I(`span`,{className:`sp-badge`,title:n(`docsp.usedTitle`),children:n.plural(`docsp.used`,c,{n:c})}),o&&I(`span`,{className:`sp-quiet`,children:n(`docs.indexingLabel`)}),s&&I(`span`,{className:`sp-error`,children:n(`docs.failed`)}),!o&&!s&&r&&r.chunk_count>0&&c===0&&I(`span`,{className:`sp-quiet`,title:n(`docsp.passagesTitle`),children:n.plural(`docsp.passages`,r.chunk_count,{n:r.chunk_count})})]})]}),s&&r?.last_error&&I(`span`,{className:`sp-row-sub sp-error`,children:r.last_error})]},e.path)})})})}var tJ=`(max-width: 1099px)`;function nJ(e){return e?(e.files?.length??0)>0||(e.outputs??[]).some(e=>(e.kind===`image`||e.kind===`audio`)&&!!e.path):!1}function rJ(e,t,n){let r=PI(e=>e.autoOpen),i=JI();bf(t,()=>{if(n||i)return;let t=e[e.length-1];hL(t?.session_id??null)||t?.role===`assistant`&&nJ(t.turnSummary)&&(e.slice(0,-1).some(e=>nJ(e.turnSummary))||r())})}function iJ({sessionId:e,messages:t,busy:n,usage:r,onUsage:i,onJumpToMessage:a}){let o=L(),s=Yd(tJ),c=PI(e=>s?e.overlayOpen:e.open),l=PI(e=>e.width),u=PI(e=>e.setWidth),d=PI(e=>e.setOpen),f=PI(e=>e.setOverlayOpen),p=PI(e=>e.focus),m=(0,V.useRef)(null),h=RW({width:l,setWidth:u,clamp:MI,min:280,max:640,defaultWidth:320}),g=(0,V.useCallback)(()=>{s?f(!1):d(!1)},[s,d,f]);rJ(t,n,s),er(c&&s,g);let _=(0,V.useRef)(null);return yn(_,c&&s),(0,V.useEffect)(()=>{c&&s&&m.current?.focus()},[c,s]),(0,V.useEffect)(()=>{s&&FI(p)&&f(!0)},[p,s,f]),c?R(F.Fragment,{children:[s&&I(`div`,{className:`sp-backdrop`,onClick:g,"aria-hidden":`true`}),R(`aside`,{ref:_,className:`session-panel ${s?`is-overlay`:`is-docked`}`,style:s?void 0:{width:h.width},"aria-label":o(`sp.label`),role:s?`dialog`:`complementary`,"aria-modal":s?!0:void 0,children:[!s&&I(`div`,{className:`sp-resize${h.dragging?` is-dragging`:``}`,"aria-label":o(`sp.resize`),...h.separatorProps}),R(`header`,{className:`sp-header`,children:[I(`h2`,{className:`sp-title`,children:o(`sp.title`)}),I(`button`,{ref:m,type:`button`,className:`btn-icon-sm`,onClick:g,"aria-label":o(`sp.close`),title:o(`sp.closeShort`),children:I(s?bc:Ro,{size:14})})]}),I(aJ,{sessionId:e,messages:t,busy:n,usage:r,onUsage:i,onJumpToMessage:a})]})]}):null}function aJ({sessionId:e,messages:t,busy:n,usage:r,onUsage:i,onJumpToMessage:a}){let o=L(),s=fK(e,t,n),c=iG(e);return I(rG.Provider,{value:c,children:R(`div`,{className:`sp-body`,children:[I(Gq,{facets:s.facets}),!1,I(SG,{sessionId:e,busy:n,usage:r,hideDocuments:!0}),I(Jq,{plan:s.plan}),I(Yq,{schedules:s.schedules}),s.coding&&I(AK,{sessionId:e,busy:n,onJumpToMessage:a},`changes`),I(Qq,{commands:s.commands,onJumpToMessage:a}),I(eJ,{documents:s.documents,messages:t}),s.showAnswer&&I(oG,{id:`answer`,title:o(`sp.section.answer`),children:I(GW,{messages:t,busy:n})}),I(BG,{sessionId:e,busy:n,onJumpToMessage:a}),!s.coding&&I(AK,{sessionId:e,busy:n,onJumpToMessage:a},`changes`),I(Oq,{sessionId:e,busy:n}),I(`h3`,{className:`sp-group-title`,children:o(`sp.details`)}),I(oG,{id:`context`,title:o(`sp.section.context`),children:I(`div`,{className:`sp-context`,children:I(XU,{sessionId:e,busy:n,onUsage:i})})}),I(Tq,{sessionId:e,busy:n}),I(Aq,{sessionId:e})]})})}function oJ({messages:e,busy:t}){let n=L(),r=Yd(tJ),i=PI(e=>r?e.overlayOpen:e.open),a=PI(e=>e.setOpen),o=PI(e=>e.setOverlayOpen),s=zW(e,t),c=!i&&s?.kind===`turn`&&s.turn.turnSummary?BW(s.turn.turnSummary):!1,l=n(i?`sp.hide`:c?`sp.showWarn`:`sp.show`);return R(F.Fragment,{children:[I(yq,{}),I(`button`,{type:`button`,className:`btn-icon-sm sp-toggle${i?` active`:``}${c?` is-warn`:``}`,onClick:()=>r?o(!i):a(!i),"aria-label":l,"aria-pressed":i,title:l,children:I(c?cc:i?Ro:Bo,{size:15})})]})}function sJ({isPrivate:e,onToggle:t}){let n=L();return I(`button`,{className:`btn-icon-sm task-header-private`,onClick:t,title:n(e?`chat.privateOffTitle`:`composer.privateOnTitle`),"aria-label":n(e?`composer.privateOff`:`composer.privateOn`),"data-private":e?`true`:void 0,children:I(e?ia:oa,{size:15})})}function cJ(e){let t=0,n=0;for(let r of e){if(n>=1e4)return`size`;if(t>=100)return`files`;if(n+=r.chunk_count,t+=1,n>1e4&&t>1)return`size`}return null}function lJ({sessionId:e,onDetachFailed:t}){let n=z(t=>t.sessions.find(t=>t.id===e)),r=z(e=>e.documents),i=z(e=>e.setShowDocLibrary),a=z(e=>e.updateSessionInList),[o,s]=(0,V.useState)(!1),c=L(),l=new Set(n?.document_ids??[]),u=r.filter(e=>l.has(e.id)),d=(0,V.useCallback)(async(n,i)=>{n.stopPropagation();let o=r.find(e=>e.id===i);P.doc.info(`Detaching document from session: ${o?.filename||i}`);try{await We(e,i);let t=(z.getState().sessions.find(t=>t.id===e)?.document_ids??[]).filter(e=>e!==i);a(e,{document_ids:t}),t.length<=3&&s(!1),P.doc.info(`Detached document from session: ${o?.filename||i}`)}catch(e){P.doc.error(`Failed to detach document: ${o?.filename||i}`,e),t(o?.filename?kd(o.filename):i,e)}},[r,e,a,t]);if(u.length===0)return null;let f=[...u].sort((e,t)=>{let n=e.last_accessed_at||e.indexed_at||``;return(t.last_accessed_at||t.indexed_at||``).localeCompare(n)}),p=o?f:f.slice(0,3),m=f.length-3,h=u.filter(e=>e.indexing_status===`failed`),g=h.length,_=h.filter(e=>YV(e.error_kind)).length,v=h.filter(e=>XV(e.error_kind)).length,y=g-_-v,b=u.length-g,x=new Map(u.map(e=>[e.id,e])),S=cJ((n?.document_ids??[]).flatMap(e=>{let t=x.get(e);return t&&t.indexing_status!==`failed`?[t]:[]})),C=c.compose(e=>[b>0?e(k(`docsBar.count`,b),{n:b}):null,y>0?e(k(`docsBar.failed`,y),{n:y}):null,_>0?e(k(`docsBar.serverWaiting`,_),{n:_}):null,v>0?e(k(`docsBar.needsRetry`,v),{n:v}):null].filter(Boolean).join(` · `));return R(`div`,{className:`doc-context-bar${o?` doc-context-expanded`:``}`,"aria-label":g>0?C:c.plural(`docsBar.aria`,b),children:[g>0?I(wi,{size:12,className:`doc-context-icon doc-context-icon-failed`,"aria-hidden":`true`}):I(Si,{size:12,className:`doc-context-icon`,"aria-hidden":`true`}),I(`button`,{type:`button`,className:`doc-context-label`,onClick:()=>i(!0),title:c(`docsBar.manage`),children:C}),R(`div`,{className:`doc-context-pills${o?` doc-context-pills-expanded`:``}`,children:[p.map(e=>{let t=e.indexing_status===`failed`,n=YV(e.error_kind)?`docsBar.serverTitle`:XV(e.error_kind)?`docsBar.busyTitle`:`docsBar.failedTitle`;return R(`span`,{className:`doc-pill${t?` doc-pill-failed`:``}`,title:t?c(n,{name:kd(e.filename)}):kd(e.filepath||e.filename),children:[I(t?wi:Sa,{size:9,className:`doc-pill-icon`,"aria-hidden":`true`}),I(`span`,{className:`doc-pill-name`,dir:`ltr`,children:hH(kd(e.filename),24)}),I(`button`,{className:`doc-pill-remove`,onClick:t=>d(t,e.id),"aria-label":c(`docsBar.remove`,{name:kd(e.filename)}),children:I(bc,{size:10})})]},e.id)}),!o&&m>0&&I(`button`,{className:`doc-pill-more`,onClick:e=>{e.stopPropagation(),s(!0)},children:c(`docsBar.more`,{n:m})})]}),o&&m>0&&I(`button`,{className:`doc-pill-collapse`,onClick:e=>{e.stopPropagation(),s(!1)},children:c(`docsBar.less`)}),S&&R(`p`,{className:`doc-context-past-cap`,role:`status`,children:[I(wi,{size:12,className:`doc-context-icon doc-context-icon-warn`,"aria-hidden":`true`}),I(`span`,{className:`doc-context-past-cap-text`,children:S===`size`?c(`docsBar.pastSize`,{passages:1e4.toLocaleString(),n:b}):c(`docsBar.pastCap`,{limit:100,n:b})})]})]})}var uJ=5e3;function dJ(e){let[t,n]=(0,V.useState)({usage:null,error:null});return(0,V.useEffect)(()=>{if(!e)return;let t,r=null,i=!1,a=e=>{i||document.hidden||(t=setTimeout(o,e))};async function o(){r=new AbortController;try{let e=await st(r.signal);if(i)return;n({usage:e,error:null}),a(e.interval_ms)}catch(e){if(i||r.signal.aborted)return;P.ui.warn(`Could not read resource usage`,e),n(t=>({usage:t.usage,error:e instanceof Error?e.message:String(e)})),a(uJ)}}let s=()=>{document.hidden?(clearTimeout(t),r?.abort()):(clearTimeout(t),o())};return o(),document.addEventListener(`visibilitychange`,s),()=>{i=!0,clearTimeout(t),r?.abort(),document.removeEventListener(`visibilitychange`,s)}},[e]),e?t:{usage:null,error:null}}var fJ=1024**3;function pJ(e){return(e/fJ).toFixed(1)}function mJ(e){return`${Math.round(e)}%`}var hJ=[[1e9,`Gbps`],[1e6,`Mbps`],[1e3,`Kbps`]];function gJ(e){return hJ.find(([t])=>e>=t)??hJ[hJ.length-1]}function _J(e,[t]){let n=e/t;return n<.05?`0`:n>=100?n.toFixed(0):n.toFixed(1)}function vJ(e){let t=Math.max(1e5,...e),n=10**Math.floor(Math.log10(t));return[1,2,5,10].find(e=>t<=e*n)*n}function yJ(e,t){let n=e.slice(-60),r=60-n.length;return n.map((e,n)=>[(r+n)/59*100,98-Math.max(0,Math.min(t,e))/t*96])}function bJ(e){return e.map(([e,t],n)=>`${n?`L`:`M`}${e.toFixed(2)} ${t.toFixed(2)}`).join(` `)}function xJ({values:e,max:t=100,dashed:n}){let r=yJ(e,t),i=bJ(r),a=r.length>1?`${i} L100 100 L${r[0][0].toFixed(2)} 100 Z`:``,o=n?yJ(n,t):[];return R(`svg`,{className:`resource-spark`,viewBox:`0 0 100 100`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:[I(`path`,{className:`resource-spark-grid`,d:`M0 25H100M0 50H100M0 75H100M25 0V100M50 0V100M75 0V100`,vectorEffect:`non-scaling-stroke`}),a&&I(`path`,{className:`resource-spark-area`,d:a}),r.length>1&&I(`path`,{className:`resource-spark-line`,d:i,vectorEffect:`non-scaling-stroke`}),o.length>1&&I(`path`,{className:`resource-spark-line is-dashed`,d:bJ(o),vectorEffect:`non-scaling-stroke`})]})}var SJ={gpu:`resources.gpu`,npu:`resources.npu`,ethernet:`resources.ethernet`,wifi:`resources.wifi`,network:`resources.network`};function CJ(e,t,n){let r=e(SJ[t.kind]),i=n.filter(e=>e.kind===t.kind);return i.length>1?e(`resources.numbered`,{label:r,n:i.indexOf(t)}):r}function wJ(e){let t=gJ(e);return`${_J(e,t)} ${t[1]}`}function TJ(e,t,n,r){return{key:`${t}-unavailable`,tone:t,label:n,value:``,detail:e(`resources.unavailable`),title:e(`resources.unavailableWhy`,{label:n,reason:r}),history:[]}}function EJ(e){return[e.send_bps,e.recv_bps,...e.send_history,...e.recv_history].every(e=>e===0)}function DJ(e){let t=e.filter(e=>!EJ(e));return t.length>0?t:e.slice(0,1)}function OJ(e,t){let n=[];if(t.cpu){let r=t.cpu.ghz==null?void 0:`${t.cpu.ghz.toFixed(2)} GHz`;n.push({key:`cpu`,tone:`cpu`,label:e(`resources.cpu`),value:mJ(t.cpu.percent),detail:r,title:[e(`resources.cpu`),mJ(t.cpu.percent),r].filter(Boolean).join(` · `),history:t.cpu.history})}if(t.memory){let r=t.memory,i=`${pJ(r.used_bytes)}/${pJ(r.total_bytes)} GB`;n.push({key:`memory`,tone:`memory`,label:e(`resources.memory`),value:mJ(r.percent),detail:i,title:`${e(`resources.memory`)} · ${i} (${mJ(r.percent)})`,history:r.history})}let r=t.devices??[];for(let t of r){let i=t.memory_used_bytes==null?void 0:`${pJ(t.memory_used_bytes)} GB`;n.push({key:t.id,tone:t.kind,label:CJ(e,t,r),value:mJ(t.percent),detail:i,name:t.name,title:[t.name,mJ(t.percent),i&&e(`resources.inUse`,{size:i})].filter(Boolean).join(` · `),history:t.history})}t.devices_error&&n.push(TJ(e,`gpu`,e(`resources.gpu`),t.devices_error)),t.npus_error&&n.push(TJ(e,`npu`,e(`resources.npu`),t.npus_error));let i=DJ(t.networks??[]);for(let t of i){let r=gJ(Math.max(t.send_bps,t.recv_bps)),a=_J(t.send_bps,r),o=_J(t.recv_bps,r);n.push({key:t.id,tone:`network`,label:CJ(e,t,i),value:``,detail:e(`resources.sendRecv`,{send:a,recv:o,unit:r[1]}),name:t.name,title:[t.name,t.description,e(`resources.send`,{rate:wJ(t.send_bps)}),e(`resources.receive`,{rate:wJ(t.recv_bps)})].join(` · `),history:t.recv_history,dashed:t.send_history,max:vJ([...t.recv_history,...t.send_history])})}return t.networks_error&&n.push(TJ(e,`network`,e(`resources.network`),t.networks_error)),n}function kJ({onClose:e}){let t=L(),{usage:n,error:r}=dJ(!0),i=n?.ready?OJ(t,n):[];return R(`section`,{className:`resource-strip`,"aria-label":t(`resources.region`),children:[i.length>0?I(`ul`,{className:`resource-tiles${r?` is-stale`:``}`,children:i.map(e=>R(`li`,{className:`resource-tile tone-${e.tone}`,title:e.title,children:[I(xJ,{values:e.history,max:e.max,dashed:e.dashed}),R(`span`,{className:`resource-text`,children:[R(`span`,{className:`resource-label`,children:[I(`bdi`,{children:e.label}),e.name&&I(`span`,{className:`resource-sr-only`,children:` (${e.name})`})]}),R(`span`,{className:`resource-reading`,children:[e.value&&I(`bdi`,{dir:`ltr`,className:`resource-value`,children:e.value}),e.detail&&I(`bdi`,{dir:`ltr`,className:`resource-detail`,children:e.detail})]})]})]},e.key))}):I(`p`,{className:`resource-status`,role:`status`,children:t(r?`resources.error`:`resources.reading`)}),r&&i.length>0&&I(`p`,{className:`resource-status is-error`,role:`status`,title:r,children:t(`resources.error`)}),I(`button`,{type:`button`,className:`btn-icon-sm resource-close`,onClick:e,"aria-label":t(`resources.hide`),title:t(`resources.hide`),children:I(bc,{size:14,"aria-hidden":`true`})})]})}function AJ({sessionId:e}){let t=L(),{env:n,change:r}=dU(e),[i,a]=(0,V.useState)(null);return!n||n.internet?null:R(`div`,{className:`offline-notice`,role:`status`,children:[I(gc,{size:13,"aria-hidden":`true`}),R(`span`,{children:[t(`offline.text`),i&&R(`span`,{className:`offline-notice-error`,children:[` `,t(`offline.error`,{error:i})]})]}),I(`button`,{type:`button`,className:`link-btn`,onClick:()=>{a(null),r(()=>fn(e,!0)).catch(e=>{a(e instanceof On?e.detail||e.message:String(e))})},children:t(`offline.turnOn`)})]})}function jJ({message:e,onDismiss:t,dismissLabel:n}){return e?R(`div`,{className:`export-error-bar`,role:`alert`,children:[I(`span`,{children:e}),I(`button`,{type:`button`,className:`btn-icon-sm`,onClick:t,"aria-label":n,children:I(bc,{size:13})})]}):null}var MJ={".doc":`.docx`,".xls":`.xlsx`,".ppt":`.pptx`};function NJ(e,t){if(!(e instanceof On))return e instanceof Error?e.message:t(`composer.uploadFailed`);let{extension:n,size_mb:r,max_mb:i}=e.body??{};switch(e.reason){case`no_extension`:return t(`composer.upload.noExtension`);case`unsupported_type`:{let e=MJ[String(n)];return e?t(`composer.upload.legacyOffice`,{ext:String(n),modern:e}):t(`composer.upload.unsupported`,{ext:String(n)})}case`empty_file`:return t(`composer.upload.empty`);case`too_large`:return t(`composer.upload.tooLarge`,{size:String(r),max:String(i)});default:return e.message}}function PJ(){return`screenshot-${new Date().toISOString().slice(0,19).replace(/[T:]/g,`-`)}.png`}function FJ(){let e=L(),[t,n]=(0,V.useState)([]),r=(0,V.useRef)(!0),i=(0,V.useRef)([]);i.current=t;let a=(0,V.useRef)(new Map);(0,V.useEffect)(()=>(r.current=!0,()=>{r.current=!1}),[]);let o=(0,V.useCallback)(async t=>{let i=new AbortController;a.current.set(t.id,i);try{let e=t.isMedia?await je(t.file,e=>{r.current&&n(n=>n.map(n=>n.id===t.id?{...n,progress:e}:n))},i.signal):await lt(t.file);if(!r.current)return;n(n=>n.map(n=>n.id===t.id?{...n,uploading:!1,uploaded:!0,serverUrl:e.url}:n))}catch(a){if(i.signal.aborted||(P.chat.error(`Upload failed: ${t.name}`,a),!r.current))return;let o=NJ(a,e);n(e=>e.map(e=>e.id===t.id?{...e,uploading:!1,error:o}:e))}finally{a.current.delete(t.id)}},[e]),s=(0,V.useCallback)(e=>{let t=[...i.current];for(let r of e){if(t.some(e=>!e.error&&e.file.name===r.name&&e.file.size===r.size&&e.file.lastModified===r.lastModified))continue;let e=r.type.startsWith(`image/`),i={id:`attach-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,file:r,name:r.name||(e?PJ():`file`),url:e?URL.createObjectURL(r):``,uploading:!0,uploaded:!1,isImage:e,isMedia:qV(r.name)};t.push(i),n(e=>[...e,i]),o(i)}},[o]),c=(0,V.useCallback)(e=>{let t=Array.from(e.clipboardData?.items??[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>e!==null);return t.length!==0&&(e.preventDefault(),s(t),!0)},[s]),l=(0,V.useCallback)(e=>{a.current.get(e)?.abort(),n(t=>{let n=t.find(t=>t.id===e);return n?.url&&URL.revokeObjectURL(n.url),t.filter(t=>t.id!==e)})},[]),u=(0,V.useCallback)(()=>{n(e=>(e.forEach(e=>{e.url&&URL.revokeObjectURL(e.url)}),[]))},[]),d=(0,V.useCallback)(n=>{let r=t.filter(e=>e.uploaded&&e.serverUrl).map(e=>{let t=e.name.replace(/[[\]]/g,` `).trim();return e.isImage?`![${t}](${e.serverUrl})`:`[${t}](${e.serverUrl})`}).join(`
201
+ `);if(!r)return n;let i=n||(t.some(e=>e.uploaded&&e.isMedia)?e(`composer.mediaPrompt`):``);return i?`${i}\n\n${r}`:r},[t,e]);return{attachments:t,addFiles:s,handlePaste:c,remove:l,clear:u,hasUploaded:t.some(e=>e.uploaded),hasImage:t.some(e=>e.uploaded&&e.isImage),uploading:t.some(e=>e.uploading),compose:d,takeElements:hR.getState().take}}function IJ({sessionId:e,isStreaming:t,isStale:n,setMessages:r,refreshContext:i}){let[a,o]=(0,V.useState)(null),s=a?.state.status===`running`,c=(0,V.useRef)(!1);c.current=s;let l=(0,V.useRef)(a);l.current=a,(0,V.useEffect)(()=>{o(null)},[e]);let u=(0,V.useCallback)((r,i)=>{t||c.current||(P.chat.info(`Retrying message ${r.id} with ${i}`),o({messageId:r.id,state:{status:`running`,model:i},keeping:null}),fr(e,r.id,i).then(e=>{n()||o(t=>t&&t.messageId===r.id?{...t,state:{status:`ready`,result:e}}:t)}).catch(e=>{P.chat.error(`Retry with ${i} failed`,e),n()||o(t=>t&&t.messageId===r.id?{...t,state:{status:`failed`,model:i,error:e instanceof Error?e.message:String(e)}}:t)}))},[e,t,n]),d=(0,V.useCallback)(async t=>{if(!a)return;let{messageId:s}=a;o({...a,keeping:t});try{let a=await Bt(e,s,t);if(n())return;if(a.kept===`retry`){let e=a.stats;r(z.getState().messages.map(t=>t.id===s?{...t,content:a.content,stats:{...t.stats,...e,tokens_per_second:e.tokens_per_second??0,time_to_first_token:e.time_to_first_token??0,input_tokens:e.input_tokens??0,output_tokens:e.output_tokens??0,retried:!0}}:t)),i()}o(null)}catch(e){if(P.chat.error(`Could not keep the chosen answer`,e),n())return;o(t=>t&&{...t,keeping:null,state:{status:`failed`,model:t.state.status===`ready`?t.state.result.model:t.state.model,error:e instanceof Error?e.message:String(e)}})}},[a,e,r,n,i]);return{comparison:a,comparing:s,comparingRef:c,handleRetryWith:u,handleKeepAnswer:d,handleCloseComparison:(0,V.useCallback)(()=>{a?.state.status===`ready`?d(`original`):o(null)},[a,d]),closeForNewTurn:(0,V.useCallback)(()=>{let t=l.current;t&&(t.state.status===`ready`&&Bt(e,t.messageId,`original`).catch(e=>P.chat.error(`Could not close the answer comparison`,e)),o(null))},[e])}}function LJ(e,t){let[n,r]=(0,V.useState)(null);(0,V.useEffect)(()=>{r(null)},[e]);let i=(0,V.useCallback)(()=>{Gt(e).then(e=>{t()||r(e.available?e:null)}).catch(t=>P.chat.error(`Could not measure the context for session=${e}`,t))},[e,t]);return(0,V.useEffect)(()=>{i()},[i]),{contextUsage:n,refreshContext:i,showContextUsage:(0,V.useCallback)(e=>{r(e)},[])}}function RJ(e,t){return(0,V.useCallback)(n=>{let r=e.current?.querySelector(`[data-message-id="${n}"]`);if(!r)return!1;let i=r.previousElementSibling,a=i?.dataset.role===`user`?i:r;return t.current=!1,a.scrollIntoView?.({block:`start`,behavior:nG()}),r.classList.add(`msg-jump-target`),window.setTimeout(()=>r.classList.remove(`msg-jump-target`),1600),!0},[e,t])}var zJ=1,BJ=80,VJ=500,HJ=new Set([`PageUp`,`ArrowUp`,`Home`]),UJ=new Set([`PageDown`,`ArrowDown`,`End`]);function WJ(e,t,n){let r=(0,V.useRef)(0),i=(0,V.useRef)(0),a=(0,V.useRef)(0),o=(0,V.useRef)(!1),s=(0,V.useCallback)(()=>o.current||Date.now()-a.current<VJ,[]),c=(0,V.useCallback)(()=>{a.current=Date.now()},[]),l=(0,V.useCallback)(()=>{a.current=0},[]),u=(0,V.useCallback)(()=>{let a=e.current;if(!a)return;let o=a.scrollHeight-a.scrollTop-a.clientHeight,c=i.current,l=a.scrollTop<r.current&&s();r.current=a.scrollTop,i.current=o,o<=zJ?t.current=!0:l?t.current=!1:o<=BJ&&o<c&&(t.current=!0),n(o)},[e,t,n,s]),d=(0,V.useCallback)(r=>{if(r.deltaY>0){l();return}if(r.deltaY===0)return;c();let i=e.current;if(!i||i.scrollTop>0)return;let a=i.scrollHeight-i.scrollTop-i.clientHeight;a<=zJ||(t.current=!1,n(a))},[e,t,n,c,l]),f=(0,V.useCallback)(e=>{e.target===e.currentTarget&&(o.current=!0)},[]);return(0,V.useEffect)(()=>{let n=e.current;if(!n||typeof ResizeObserver>`u`)return;let r=n.clientHeight,i=new ResizeObserver(()=>{let e=n.clientHeight<r;r=n.clientHeight,e&&t.current&&!s()&&(n.scrollTop=n.scrollHeight)});return i.observe(n),()=>i.disconnect()},[e,t,s]),(0,V.useEffect)(()=>{let e=()=>{o.current=!1},t=e=>{let t=e.target;t instanceof Element&&t.closest(`input, textarea, select, [contenteditable="true"]`)||(HJ.has(e.key)||e.key===` `&&e.shiftKey?c():(UJ.has(e.key)||e.key===` `)&&l())};return window.addEventListener(`pointerup`,e),window.addEventListener(`pointercancel`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerup`,e),window.removeEventListener(`pointercancel`,e),window.removeEventListener(`keydown`,t)}},[c,l]),(0,V.useEffect)(()=>{let n=e.current;if(!n||typeof ResizeObserver>`u`)return;let r=n.clientHeight,i=new ResizeObserver(()=>{let e=n.clientHeight<r;r=n.clientHeight,e&&t.current&&!s()&&(n.scrollTop=n.scrollHeight)});return i.observe(n),()=>i.disconnect()},[e,t,s]),{userScrolling:s,clearUserScroll:l,listProps:{onScroll:u,onWheel:d,onTouchMove:c,onPointerDown:f}}}function GJ(e,t){let[n,r]=(0,V.useState)(null);(0,V.useEffect)(()=>{r(null)},[e]);let i=(0,V.useCallback)(()=>r(null),[]);return{exportChat:(0,V.useCallback)(async()=>{r(null);try{let n=await ln(e),r=new Blob([n.content],{type:`text/markdown`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`${(t||`chat`).replace(/[/\\:*?"<>|]/g,`_`).slice(0,100)}.md`,a.click(),URL.revokeObjectURL(i)}catch(e){P.chat.error(`Export failed`,e),r(e instanceof On?`Couldn't export this chat: GAIA's backend returned an error (HTTP ${e.httpStatus}). Try Export again; if it keeps failing, check the backend log.`:`Couldn't export this chat because GAIA's backend isn't reachable. Try Export again once GAIA is answering.`)}},[e,t]),exportError:n,clearExportError:i}}var KJ=5200;function qJ(e=KJ){let[t,n]=(0,V.useState)(null),r=(0,V.useRef)(null),i=(0,V.useCallback)(()=>{r.current&&=(clearTimeout(r.current),null)},[]),a=(0,V.useCallback)(()=>{i(),n(null)},[i]),o=(0,V.useCallback)(t=>{i(),n(t),r.current=setTimeout(()=>{r.current=null,n(null)},e)},[i,e]);return(0,V.useEffect)(()=>i,[i]),{policyToast:t,showPolicyToast:o,dismissPolicyToast:a}}function JJ(e,t){let n=z.getState(),r=n.sessions.find(t=>t.id===e)?.document_ids??[],i=t.filter(e=>!r.includes(e));i.length>0&&n.updateSessionInList(e,{document_ids:[...r,...i]})}function YJ(e,t){if(t.length===0)return;let n=z.getState(),r=new Set(t.map(e=>e.id));n.setDocuments([...t,...n.documents.filter(e=>!r.has(e.id))]),JJ(e,t.map(e=>e.id))}async function XJ(e,t){let n=[];for(let r of t){P.doc.info(`Dropped on chat view: ${r.name}`);try{let t=await at(r);if(t?.indexing_status===`failed`){let e=YV(t.error_kind)?`server`:XV(t.error_kind)?`busy`:`unreadable`;P.doc.warn(`"${r.name}" couldn't be added (${t.error_kind??`unreadable`}); not attaching it`),n.push({name:r.name,stage:e,error:t.last_error??null})}else if(e&&t?.id)try{await vn(e,t.id),JJ(e,[t.id]),P.doc.info(`Auto-attached "${r.name}" to session ${e}`)}catch(e){P.doc.warn(`Could not attach dropped document to session: ${e}`),n.push({name:r.name,stage:`attach`,error:e})}}catch(e){P.doc.error(`Upload failed: ${r.name}`,e),n.push({name:r.name,stage:`upload`,error:e})}}try{let e=await Tt();z.getState().setDocuments(e.documents||[])}catch(e){P.doc.error(`Could not refresh the document list after a drop`,e)}return n}function ZJ(e,t=``){let[n,r]=(0,V.useState)(()=>e&&Ut(e)||t),i=(0,V.useRef)(e);return(0,V.useEffect)(()=>{i.current!==e&&(i.current=e,r(e?Ut(e):``))},[e]),(0,V.useEffect)(()=>{e&&i.current===e&&pt(e,n)},[e,n]),[n,r]}function QJ(e,t){return ZJ(t?null:hn(e))}function $J(e){for(let t=e.length-1;t>=0;t--){let n=e[t].turnSummary?.files??[];for(let e=n.length-1;e>=0;e--)if(nL(n[e].path))return n[e].path}return null}function eY({messages:e}){let t=L(),n=z(e=>e.currentSessionId),r=mL(n),i=Yd(ZI),a=pL(e=>e.overlayOpen),o=(0,V.useMemo)(()=>$J(e),[e]),s=r.active??o;if(!n||s===null)return null;let c=r.active!==null&&(i?a:r.open),l=t(c?`docPane.hide`:`docPane.show`);return I(`button`,{type:`button`,className:`btn-icon-sm dp-toggle${c?` active`:``}`,onClick:()=>c?pL.getState().close(n):pL.getState().show(n,s),"aria-label":l,"aria-pressed":c,title:l,children:I(Sa,{size:15})})}var tY=-2,nY=`opening`;function rY(e,t,n){return!t||e.some(e=>e.role===`user`&&e.content.trim()===t)?e:[...e,{id:tY,session_id:n,role:`user`,content:t,created_at:``,rag_sources:null}]}function iY({sessionId:e,pendingPrompt:t,messages:n,messageCount:r,isLoadingMessages:i,initializing:a,mountedRef:o,send:s}){let c=(0,V.useRef)(!1),[l,u]=(0,V.useState)(null);(0,V.useEffect)(()=>{let e=t?.text;if(!e||t.sending||z.getState().isLoadingMessages||a)return;let n={...t,sending:!0};z.getState().setPendingPrompt(n),c.current=!0,u(e.trim()),setTimeout(()=>{c.current=!1;let t=z.getState();t.pendingPrompt===n?o.current?(t.setPendingPrompt(null),s.current(e,{opening:!0}).finally(()=>{o.current&&u(null)})):t.setPendingPrompt({sessionId:n.sessionId,text:n.text}):o.current&&u(null)},0)},[t,i,a]);let d=!a&&r===0?t?.text.trim()||l:null,f=(0,V.useRef)(null);d&&!f.current&&(f.current=d);let p=f.current?n.find(e=>e.role===`user`&&e.content.trim()===f.current):void 0;return{openingRef:c,openingShown:d,rows:rY(n,d,e),isUnsent:e=>e.id===tY,openingKey:e=>e.id===tY||e===p?nY:void 0}}var aY=new Set([`tool_start`,`tool_end`,`tool_result`]),oY=`Connection lost. Reconnecting`,sY=`answer_check`,cY=15e3,lY=1e4,uY=[],dY=[],fY=[],pY=new Map,mY=12e3;function hY({sessionId:e}){let t=L(),n=bU(e),{sessions:r,messages:i,setMessages:a,addMessage:o,removeMessage:c,removeMessagesFrom:l,updateSessionInList:u,isStreaming:d,streamingContent:f,setStreaming:p,setStreamContent:h,clearStreamContent:g,agentSteps:y,addAgentStep:b,updateLastAgentStep:x,appendThinkingContent:S,updateLastToolStep:C,clearAgentSteps:w,cards:T,appendCard:E,clearCards:ee,setDocuments:te,setShowFileBrowser:k,isLoadingMessages:A,setLoadingMessages:ne,systemStatus:j}=z(),M=fu(e=>e.addNotification),re=fu(e=>e.showPanel),ae=fu(e=>e.setShowPanel),oe=fu(e=>e.setTypeFilter),se=z(t=>t.pendingPrompt?.sessionId===e?t.pendingPrompt:null),ce=z(e=>e.liveStatus),le=z(wB),ue=z(e=>e.awaitingUser),de=z(t=>Object.values(t.liveQuestions).some(t=>t.sessionId===e)),pe=z(t=>rM(t.liveQuestions,e)),he=fu(t=>gu(e)(t)!==null),ge=r.find(t=>t.id===e),[_e,ye]=QJ(e,ge?.private),be=(0,V.useRef)(_e);be.current=_e;let[Se,Ce]=(0,V.useState)(!1),[we,N]=(0,V.useState)(``),[Te,Ee]=(0,V.useState)(!1),[Oe,ke]=(0,V.useState)(!1),Ae=FJ(),[je,Me]=(0,V.useState)(null),{policyToast:Ne,showPolicyToast:Pe,dismissPolicyToast:Fe}=qJ(),[Ie,Le]=(0,V.useState)(null),{exportChat:Re,exportError:Be,clearExportError:Ve}=GJ(e,ge?.title),[He,Ue]=(0,V.useState)(null);(0,V.useEffect)(()=>Ue(null),[e]);let We=(0,V.useCallback)((e,n)=>{Ue(t(`chat.detachFailed`,{name:e,error:BF(n)}))},[t]),Ge=ge?.agent_type&&ge.agent_type!==`gaia`?ge.agent_type:null,[qe,Je]=(0,V.useState)(null),Ye=(0,V.useRef)(new Map),Xe=(0,V.useRef)(new Set);VB(),(0,V.useEffect)(()=>()=>GL.getState().stop(),[]);let Ze=(0,V.useRef)(null),Qe=(0,V.useRef)(null),$e=(0,V.useRef)(null),et=(0,V.useRef)(null),tt=(0,V.useRef)(0),nt=(0,V.useRef)(!1),rt=(0,V.useRef)(0),it=(0,V.useRef)(null),[at,ot]=(0,V.useState)(!1),st=(0,V.useRef)(!1),ct=(0,V.useRef)(null),lt=(0,V.useRef)(null),ut=(0,V.useRef)(0),ft=(0,V.useRef)(!1),pt=(0,V.useRef)(async()=>!1),mt=(0,V.useRef)(!1),ht=(0,V.useRef)(!1),gt=z(t=>t.messageQueues[e]??uY),_t=(0,V.useCallback)(t=>z.getState().updateQueue(e,t),[e]),vt=(0,V.useRef)(!1),[yt,bt]=(0,V.useState)(!1),xt=(0,V.useRef)(!1),St=(0,V.useRef)(!1),Ct=(0,V.useRef)(d);Ct.current=d;let wt=z(t=>!!t.queueHolds[e]),Et=il(e=>!!e.queued),Ot=(0,V.useRef)(``),kt=(0,V.useRef)(null),At=(0,V.useRef)(null),Mt=(0,V.useRef)(0),Nt=(0,V.useRef)(!0),{userScrolling:Ft,clearUserScroll:It,listProps:Rt}=WJ(Qe,Nt,e=>ke(e>200)),zt=(0,V.useCallback)(()=>z.getState().currentSessionId!==e,[e]),Bt=(0,V.useCallback)(()=>{kt.current=null,zt()||Ot.current&&h(Ot.current)},[h,zt]),Vt=(0,V.useRef)(0),[Ht,Ut]=(0,V.useState)(!1),Wt=(0,V.useRef)(0);(0,V.useEffect)(()=>{P.chat.info(`ChatView mounted for session=${e}, loading messages...`);let t=P.chat.time();ne(!0);let n=!1,r=!1,i=async(i=!1)=>{if(n||r)return;r=!0;let o=Wt.current;try{if(!i){if(z.getState().isStreaming)return;let t=await me(e);if(n||t===Vt.current||z.getState().isStreaming)return}let r=await In(e);if(n)return;let s=AB(r.messages);if(i&&Wt.current!==o)Vt.current=s.length;else if(i)a(s),Vt.current=s.length,P.chat.timed(`Loaded ${s.length} message(s) for session=${e}`,t);else if(s.length!==Vt.current&&!z.getState().isStreaming){P.chat.info(`Messages changed externally: ${Vt.current} -> ${s.length}`);let e=z.getState().messages;PB(e,s,Ye.current),a(FB(e,s)),Vt.current=s.length}i&&Ut(!0)}catch(t){if(n)return;i&&(P.chat.error(`Failed to load messages for session=${e}`,t),a([]))}finally{r=!1,!n&&i&&ne(!1)}};i(!0);let o=jl(()=>i(!1),3e3);return()=>{n=!0,o()}},[e,a,ne]),(0,V.useEffect)(()=>{Tt().then(e=>te(e.documents||[])).catch(e=>P.doc.error(`Could not load the document list`,e))},[te]);let Gt=(0,V.useRef)(!0),Kt=sV(j);(0,V.useEffect)(()=>(Gt.current=!0,()=>{Gt.current=!1}),[]);let{openingRef:qt,openingShown:Yt,rows:Xt,isUnsent:$t,openingKey:en}=iY({sessionId:e,pendingPrompt:se,messages:i,messageCount:ge?.message_count??0,isLoadingMessages:A,initializing:Kt,mountedRef:Gt,send:pt});(0,V.useLayoutEffect)(()=>{if(!Nt.current)return;let e=Date.now()-Mt.current,t=()=>{Nt.current&&!Ft()&&(Mt.current=Date.now(),Ze.current?.scrollIntoView({behavior:`instant`}))};(!d||e>=100)&&t(),At.current&&clearTimeout(At.current),At.current=setTimeout(t,100)},[i,f,y,d]),(0,V.useEffect)(()=>{$e.current?.focus()},[e]),(0,V.useEffect)(()=>{vt.current=!1},[e]);let{contextUsage:tn,refreshContext:nn,showContextUsage:rn}=LJ(e,zt),{comparison:an,comparing:on,comparingRef:sn,handleRetryWith:cn,handleKeepAnswer:ln,handleCloseComparison:un,closeForNewTurn:dn}=IJ({sessionId:e,isStreaming:d,isStale:zt,setMessages:a,refreshContext:nn});(0,V.useEffect)(()=>()=>{Ct.current&&AV(e),et.current&&!St.current&&et.current.abort(),et.current&&=null,ct.current&&=(clearTimeout(ct.current),null),st.current=!1,lt.current=null,ot(!1),kt.current!==null&&(cancelAnimationFrame(kt.current),kt.current=null),At.current&&=(clearTimeout(At.current),null),it.current&&=(clearTimeout(it.current),null),Fe(),Ot.current=``,EL(e),z.getState().resetStreaming()},[e]),(0,V.useEffect)(()=>{Ie&&re&&(document.getElementById(IB(Ie))?.scrollIntoView({behavior:nG(),block:`center`}),Le(null))},[Ie,re]);let fn=PI(e=>e.width),pn=PI(e=>e.reveal),mn=iF(e=>e.visible),gn=iF(e=>e.setVisible),_n=(0,V.useRef)(null),[vn,yn]=(0,V.useState)(!1),bn=(0,V.useCallback)(()=>{gn(!1),yn(!0),_n.current?.focus()},[gn]);(0,V.useEffect)(()=>{if(!vn)return;if(mn){yn(!1);return}let e=window.setTimeout(()=>yn(!1),mY);return()=>window.clearTimeout(e)},[vn,mn]);let xn=RJ(Qe,Nt),Sn=(0,V.useCallback)(()=>{Nt.current=!0,It(),Ze.current?.scrollIntoView({behavior:nG()})},[It]),Cn=(0,V.useCallback)(()=>{st.current||(st.current=!0,vt.current=!0,ot(!0),fu.getState().dismissSessionPrompts(e),z.getState().closeSessionQuestions(e),P.stream.warn(`User stopped generation; waiting for the server to close the turn`),jt(e).catch(e=>{P.stream.error(`Stop request failed; waiting for the stream to close`,e)}),it.current?(clearTimeout(it.current),it.current=null,lt.current?.()):ct.current=setTimeout(()=>{P.stream.error(`No closing event ${cY}ms after Stop; closing the turn locally (session=${e})`),lt.current?.()},cY))},[e]);(0,V.useEffect)(()=>{let e=e=>{e.key===`Escape`&&d&&!kn(e)&&(e.preventDefault(),Cn())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[d,Cn]);let wn=(0,V.useCallback)(async(n,r)=>{let i=r?.attach===!0,s=r?.queued===!0,l=i?r?.reconnect??0:0,f=!i&&n===void 0,_=(f?_e:n??``).trim(),v=f&&Ae.hasUploaded,y=f&&Ae.hasImage;if(f&&ht.current)return!1;let T=!1;if(f&&CU(_,e)){ht.current=!0,Ue(null);try{await SU(_,e)}catch(e){return Ue(t(`composer.researchSkillsUnavailable`,{error:BF(e)})),!1}finally{ht.current=!1}if(be.current!==_e)return!1;T=zt()}let D=()=>{if(!f)return _;let t=Ae.compose(xU(_,e));return ye(``),Ae.clear(),$e.current?.focus(),t},te=()=>{let t=D();return f&&!ge?.private&&Jt(hn(e)),_t(e=>ar(e,t,`queued`)),!0};Nt.current=!0;let k=sV(z.getState().systemStatus),A=e=>{s&&r?.onQueuedOutcome?.(e)};if(!i&&Ge)return P.chat.warn(`Send blocked: chat ${e} belongs to the retired "${Ge}" agent`),A({kind:`failed`,error:xe(Ge)}),!1;if(T)return te();let ne=!r?.opening&&(z.getState().messageQueues[e]??uY).length>0;if(i){if(d&&!l)return!1}else if(!s&&(_||v)&&!k&&(d||sn.current||ne)){if(y&&!Rc(`vision`)&&!await Vc(`vision`))return!1;let e=D();return _t(t=>ar(t,e,`queued`)),!0}else if(!_&&!v||d||k)return A({kind:`busy`}),!_&&!v&&P.chat.debug(`Send blocked: empty message`),d&&P.chat.debug(`Send blocked: already streaming`),k&&P.chat.debug(`Send blocked: system initializing`),!1;if(!i&&!s&&(!Rc(`chat`)||y&&!Rc(`vision`))){if(mt.current)return!1;mt.current=!0;try{if(!await Vc(`chat`)||y&&!await Vc(`vision`))return!1}finally{mt.current=!1}if(zt())return te()}let j=_,re=null,ae=i||s?void 0:Ae.takeElements();if(i)P.chat.info(`Re-attaching to background run for session=${e}${l?` (reconnect ${l})`:``}`);else{j=D(),P.chat.info(`Sending message to session=${e}`,{length:j.length,preview:j.slice(0,80)}),dn();let t={id:Date.now(),session_id:e,role:`user`,content:j,created_at:new Date().toISOString(),rag_sources:null,page_elements:ae};o(t),re=t,Wt.current+=1}l||(rt.current=0),bL(e),p(!0),g(),w(),ee(),ut.current=0,ft.current=!1,l&&z.getState().setLiveStatus(`${oY} (attempt ${l} of 3)…`),P.stream.info(`Starting agent stream...`);let oe=P.stream.time(),se=``,ce;Je(null);let le=!1;xt.current=!1,i||bt(!1);let ue=null,de=!s;St.current=s;let fe=e=>{de||(de=!0,St.current=!1,r?.onQueuedOutcome?.(e),e.kind===`accepted`&&zt()&&ue?.abort())},pe=i||!!ge&&!qd(ge.title),me=()=>{fe({kind:`accepted`}),pe||(pe=!0,dt(e).then(t=>u(e,{title:t.title})).catch(e=>P.chat.warn(`Could not refresh the chat title`,e)))};Ot.current=``,st.current=!1,ot(!1);let he=()=>{ct.current&&=(clearTimeout(ct.current),null),st.current=!1,lt.current=null,ot(!1)},ve=()=>{let{agentSteps:e,cards:t}=z.getState();return{steps:e.map(e=>({...e,active:!1})),cards:[...t]}};lt.current=()=>{if(le)return;le=!0,nt.current=!0,tt.current=Date.now(),he(),fe({kind:`failed`,error:m}),et.current?.abort(),et.current=null,kt.current!==null&&(cancelAnimationFrame(kt.current),kt.current=null);let t=Ot.current||z.getState().streamingContent;if(Ot.current=``,zt())return;let{steps:n,cards:r}=ve();o({id:Date.now()+1,session_id:e,role:`assistant`,content:t,created_at:new Date().toISOString(),rag_sources:null,agentSteps:n.length>0?n:void 0,cards:r.length>0?r:void 0,stopState:`unconfirmed`}),p(!1),g(),w(),ee()};let Se={onConnected:()=>{if(zt())return;let e=z.getState();(e.liveStatus===`Waiting for GAIA to start this answer…`||e.liveStatus?.startsWith(oY))&&e.setLiveStatus(null)},onChunk:t=>{if(me(),zt())return;z.getState().awaitingUser&&z.getState().setAwaitingUser(!1);let n=t.content||``;if(n&&fu.getState().dismissSessionPrompts(e),n){if(t.type===`answer`)se=n;else{ft.current&&=(se.length>0&&(se+=`
202
+
203
+ `),!1),se+=n;let e=z.getState().agentSteps,t=e[e.length-1];t?.type===`thinking`&&t.active&&x({active:!1,latencyMs:Date.now()-t.timestamp})}let e=se.replace(EB,``).trim();if(e=DB(e),e){let t=e.lastIndexOf(`{`);if(t>-1){let n=e.slice(t);/^\{\s*"(?:thought|answer|goal|tool)"/.test(n)&&(n.match(/\{/g)||[]).length>(n.match(/\}/g)||[]).length&&(e=e.slice(0,t).trim())}}Ot.current=e,kt.current===null&&(kt.current=requestAnimationFrame(Bt))}},onAgentEvent:t=>{if((t.type!==`status`||t.phase!==`waiting`)&&me(),yL(e,t,i),t.type===`draft`)return;if(t.type===`followup_taken`&&t.text){let n=t.text;if(_t(e=>ie(e,n)),zt())return;o({id:Date.now(),session_id:e,role:`user`,content:n,created_at:new Date().toISOString(),rag_sources:null});return}if(t.type===`followup_unavailable`){zt()||bt(!0);return}if(t.type===`followup_returned`){let e=t.texts??[];_t(t=>De(t,e));return}if(zt())return;if(t.type===`context_usage`){rn(t);return}let n=t.type===`permission_request`||t.type===`needs_input`;if(z.getState().awaitingUser!==n&&z.getState().setAwaitingUser(n),aY.has(t.type)&&fu.getState().dismissSessionPrompts(e),t.type===`permission_request`){$B(t,e);return}if(t.type===`needs_confirmation`){E({render:`needs_confirmation`,data:{action:typeof t.action==`string`?t.action:``,summary:typeof t.summary==`string`?t.summary:``}});return}if(t.type===`needs_input`){if(!t.request_id){console.error(`[ChatView] needs_input event missing request_id, ignoring`);return}z.getState().openQuestion(t.request_id,e,typeof t.timeout_seconds==`number`?t.timeout_seconds:null,{options:Array.isArray(t.options)?t.options:[],allowFreeText:t.allow_free_text!==!1,sensitive:!!t.sensitive}),E({render:`needs_input`,data:{session_id:e,request_id:t.request_id,question:typeof t.question==`string`?t.question:``,options:Array.isArray(t.options)?t.options:[],allow_free_text:t.allow_free_text!==!1,sensitive:!!t.sensitive}});return}if(t.type===`policy_alert`){let n=eV(t,e,`policy-${Date.now()}-${ut.current+1}`);M(n);let r=bB(t,ut);r&&b(r),Pe({tool:n.tool,receiptId:t.receipt_id});return}if((t.type===`tool_end`||t.type===`tool_result`)&&z.getState().livePhase===`tool`&&z.getState().setLiveStatus(null),t.type===`tool_end`){C({active:!1,success:t.success!==!1});return}if(t.type===`tool_result`){typeof t.render==`string`&&t.render.length>0&&E({render:t.render,data:t.data}),C(nV(t));return}if(t.type===`tool_args`){let e=!!t.args&&Object.keys(t.args).length>0,n=t.detail||(e?JSON.stringify(t.args):``);C({...n?{detail:n}:{},...t.narration?{narration:t.narration}:{}});let r=z.getState(),i=[...r.agentSteps].reverse().find(e=>e.type===`tool`);t.narration&&i?.active&&r.livePhase===`tool`&&r.setLiveStatus(Ok(i,Qt()),`tool`);return}if(t.type===`skill_use`){z.getState().addSkillStep(t.how===`model`?null:bB(t,ut));return}if(t.type===`commentary`){se=``,ft.current=!1,Ot.current=``,h(``);let e=bB(t,ut);e&&b(e);return}if(t.retracts_answer){if(se=``,ft.current=!1,Ot.current=``,h(``),t.type===`status`&&t.phase===sY){TB({...t,message:Qt()(`live.answerChecking`)},ut);return}if(t.type===`status`){let e=bB({type:`status`,status:`warning`,message:Qt()(`live.answerRestarted`)},ut);e&&b(e);return}}if(t.type===`thinking`){let e=z.getState().agentSteps,n=e[e.length-1];if(n&&n.type===`thinking`){S(t.content||``);return}let r=bB(t,ut);r&&b(r);return}if(t.type===`status`){if(t.status===`history_cut`){ce=(t.message||``).trim()||void 0,Je(ce??null);return}TB(t,ut);return}if(t.type===`step`||t.type===`agent_error`&&OB(t,z.getState().agentSteps))return;let r=bB(t,ut);r&&(b(r),t.type===`tool_start`&&(ft.current=!0,z.getState().setLiveStatus(Ok(r,Qt()),`tool`),t.tool===`load_skill`&&z.getState().addSkillStep(null)))},onDone:t=>{if(me(),zK(e),DL(e),fu.getState().dismissSessionPrompts(e),z.getState().closeSessionQuestions(e),le)return;le=!0;let n=t.cancelled===!0?`stopped`:st.current&&t.message_id==null?`unconfirmed`:void 0;if(he(),kt.current!==null&&(cancelAnimationFrame(kt.current),kt.current=null),Ot.current=``,YJ(e,t.documents_added??[]),zt())return;tt.current=Date.now(),xt.current=!0;let r=z.getState();r.setRunningSessions(r.runningSessionIds.filter(t=>t!==e));let s=t.content||se;P.chat.timed(`Agent response complete: ${s.length} chars${n?` (${n})`:``}`,oe);let{steps:c,cards:l}=ve(),u=c.some(e=>e.type===`policy_alert`);if(s||u||n){Vt.current=z.getState().messages.length+1;let r={id:t.message_id||Date.now()+1,session_id:e,role:`assistant`,content:s,created_at:new Date().toISOString(),rag_sources:null,agentSteps:c.length>0?c:void 0,stats:t.stats||void 0,turnSummary:t.turn_summary||void 0,cards:l.length>0?l:void 0,stopState:n,historyNotice:ce,libraryNotices:t.library_notices,failed:t.failed?!0:void 0,failure:t.failed?t.failure:void 0,agentProgram:t.failed?t.agent_program:void 0};ce&&pY.set(r.id,ce),Xe.current.add(r.id),o(r);let i=GL.getState();i.settings?.auto&&i.settings.available!==!1&&BB(r)&&i.read(`${e}:${r.id}`,Mz(s))}p(!1),g(),w(),ee(),$e.current&&$e.current.focus(),setTimeout(()=>{In(e).then(t=>{if(zt()||z.getState().isStreaming)return;let n=z.getState().messages,r=n.filter(e=>e.cards&&e.cards.length>0),c=AB(t.messages).map(e=>{let t=r.find(t=>t.id===e.id||t.role===e.role&&t.content===e.content);return{...e,cards:t?.cards??e.cards,stopState:e.stopState??n.find(t=>t.id===e.id)?.stopState,failed:e.failed??n.find(t=>t.id===e.id)?.failed,failure:e.failure??n.find(t=>t.id===e.id)?.failure,agentProgram:e.agentProgram??n.find(t=>t.id===e.id)?.agentProgram}});PB(n,c,Ye.current),a(c),Vt.current=c.length,i&&!s&&c[c.length-1]?.role===`user`&&o({id:Date.now()+2,session_id:e,role:`assistant`,content:XL,created_at:new Date().toISOString(),rag_sources:null})}).catch(t=>P.chat.error(`Could not refresh messages for session=${e}`,t))},300)},onError:t=>{let n=ZL(t);n||zK(e),n||DL(e);let r=de&&!i&&!n&&!!re&&RV(e,j,t);if(!de||r){if(n)me();else{if(fe(FV(t)?{kind:`busy`}:{kind:`failed`,error:sR(t).text}),tt.current=Date.now(),he(),kt.current!==null&&(cancelAnimationFrame(kt.current),kt.current=null),Ot.current=``,zt())return;P.chat.info(`Queued message for session=${e} not taken: ${t.message}`),re&&c(re.id),xt.current=!0,p(!1),g(),w(),ee();return}}if(n&&st.current&&!le){P.chat.warn(`Stream for session=${e} was lost while stopping; closing the turn locally`),lt.current?.();return}if(n&&!Gt.current)return;if(n&&!le&&!zt()&&rt.current<3){let n=++rt.current,r=YL[n-1]??0;P.chat.warn(`Stream for session=${e} lost (${t.name}); reconnecting in ${r}ms (${n}/3)`),z.getState().setLiveStatus(`${oY} (attempt ${n} of 3)…`);let i=()=>{it.current=null,!Gt.current||zt()||st.current||pt.current(void 0,{attach:!0,reconnect:n})};r>0?it.current=setTimeout(i,r):i();return}tt.current=Date.now(),fu.getState().dismissSessionPrompts(e),z.getState().closeSessionQuestions(e);let a=st.current;if(he(),kt.current!==null&&(cancelAnimationFrame(kt.current),kt.current=null),Ot.current=``,zt())return;if(n||(xt.current=!0),P.chat.error(`Chat error for session=${e}`,t),a){let{steps:n,cards:r}=ve();o({id:Date.now()+2,session_id:e,role:`assistant`,content:se,created_at:new Date().toISOString(),rag_sources:null,agentSteps:n.length>0?n:void 0,cards:r.length>0?r:void 0,stopState:`stopped`,stopError:t.message||`Unknown error`}),Vt.current=z.getState().messages.length,p(!1),g(),w(),ee();return}let{kind:s,text:l}=sR(t),u=s===`stream`?l:l+`
204
+
205
+ ---
206
+ *Unexpected error?* [Report it on GitHub](${aH((t.message||``).slice(0,80))})`,d={id:Date.now()+2,session_id:e,role:`assistant`,content:u,created_at:new Date().toISOString(),rag_sources:null,failed:!$L(t),stalled:t instanceof Dt||void 0,failureText:t.message||void 0};t instanceof Dt&&t.endpoint===`send`&&z.getState().setBackendStalled(!0),o(d),p(!1),g(),w(),ee()}},Ce=i?Zt(e,Se):O(e,j,{...Se,pageElements:ae});return ue=Ce,et.current=Ce,!0},[_e,Ae,d,e,ge,Ge,o,c,a,p,Bt,g,u,b,x,S,C,w,E,ee,M,zt,t]);pt.current=wn;let Tn=z(t=>t.runningSessionIds.includes(e)),En=z(e=>e.activeRunsAt>tt.current);(0,V.useEffect)(()=>{yV()},[e]),(0,V.useEffect)(()=>{Tn?!En||d||nt.current||(P.chat.info(`Resuming live view of background run for session=${e}`),pt.current(void 0,{attach:!0})):nt.current=!1},[e,Tn,En,d]),(0,V.useEffect)(()=>{let e=e=>{let t=e.detail?.text;typeof t==`string`&&t.trim()&&pt.current(t)};return window.addEventListener(`gaia:send-message`,e),()=>window.removeEventListener(`gaia:send-message`,e)},[]),(0,V.useEffect)(()=>{!d&&$e.current&&$e.current.focus()},[d]);let Dn=(0,V.useCallback)(async t=>{d||(P.chat.info(`Deleting message ${t} from session=${e}`),Me(t),setTimeout(async()=>{c(t),Me(null);try{await ze(e,t)}catch(n){P.chat.error(`Failed to delete message ${t}`,n),In(e).then(e=>{zt()||a(AB(e.messages))}).catch(t=>P.chat.error(`Could not reload messages for session=${e}`,t))}},250))},[e,d,c,a,zt]),On=(0,V.useRef)(!1),An=(0,V.useCallback)(async(n,r,i)=>{if(d||n.role!==`user`)return!1;if(On.current)return P.chat.info(`Resend of message ${n.id} ignored: an earlier resend is still running`),!1;On.current=!0;let o=i??n.content;P.chat.info(`Resending message ${n.id} from session=${e}`,{preview:o.slice(0,80)});let s=n=>M({id:`resend-failed-${e}-${Date.now()}`,type:`error`,agentId:e,agentName:`GAIA`,title:t(`chatError.resendFailed`),message:n,timestamp:Date.now(),read:!1,dismissed:!1,priority:`high`,sessionId:e});try{if(LB.getState().lifecycle?.status===`restarting`)return P.chat.info(`Resend of message ${n.id} refused: the desktop app is restarting the backend`),s(t(`chatError.resendStarting`)),!1;if(sV(z.getState().systemStatus)){let e=new AbortController,r=setTimeout(()=>e.abort(),lY),i;try{i=await Pt(e.signal)}catch(r){if(!e.signal.aborted)throw r;return P.chat.warn(`Resend of message ${n.id} refused: no status within ${lY} ms`),s(t(`chatError.resendStarting`)),!1}finally{clearTimeout(r)}if(z.getState().setSystemStatus(i),sV(i))return s(t(`chatError.resendStarting`)),!1}if(!Rc(`chat`)&&!await Vc(`chat`))return!1;let i=await In(e);if(zt())return!1;let c=AB(i.messages),l=jB(c,z.getState().messages,n);if(l&&r&&!NB(c,l,r))return P.chat.info(`Message ${n.id} was answered since it failed; not resending`),a(c),Vt.current=c.length,!1;if(l&&await v(e,l.id),zt()){let{sessions:t,pendingDeleteIds:n}=z.getState();return t.some(t=>t.id===e)&&!n.includes(e)&&_t(e=>ar(e,o,`queued`)),!0}}catch(r){P.chat.error(`Could not resend message ${n.id} in session=${e}`,r);let i=r instanceof Error?sR(r):null;return s(i?.kind===`connection`||i?.kind===`timeout`?i.text:t(`chatError.resendStale`)),!1}finally{On.current=!1}l(n.id);let c=!1;try{c=await pt.current(o)}catch(t){P.chat.error(`Could not resend message ${n.id} in session=${e}; queued it`,t)}return c||_t(e=>ar(e,o,`queued`)),!0},[e,d,l,a,_t,zt,M,t]);(0,V.useEffect)(()=>MV(e),[e]);let jn=z(()=>jV(e)),Mn=(0,V.useCallback)((e,t)=>new Promise(e=>{pt.current(t,{queued:!0,onQueuedOutcome:e})}),[]),Nn=d||on;(0,V.useEffect)(()=>{if(!Nn){if(vt.current){vt.current=!1;let e=gt.map(e=>e.text);e.length&&(_t(()=>[]),ye(t=>[t.trim(),...e].filter(Boolean).join(`
207
+
208
+ `)))}else gt.length===0||wt||Et||A||se||qt.current||Ge||Kt||zt()||!xt.current&&!jn||zV(e,Mn,()=>Gt.current&&!zt()&&!z.getState().isStreaming&&!sn.current)}},[Nn,gt,wt,Et,jn,A,se,Ge,Kt,e,Mn,zt]);let Pn=(0,V.useRef)(!1);(0,V.useEffect)(()=>{Pn.current&&!Nn&&nn(),Pn.current=Nn},[Nn,nn]);let Fn=(0,V.useCallback)(t=>{let n=gt.find(e=>e.id===t&&e.state===`queued`);n&&d&&(_t(e=>s(e,t,`queued`,`sending`)),_(e,n.text).then(()=>_t(e=>s(e,t,`sending`,`delivered`))).catch(e=>{P.chat.info(`Follow-up not taken by the running reply; it stays queued: ${e instanceof Error?e.message:e}`),_t(e=>D(e,t))}))},[gt,d,e,_t]),Ln=(0,V.useCallback)(async()=>{let n=pe?z.getState().liveQuestions[pe]:void 0,r=_e.trim();if(!pe||!n||!r||Ae.hasUploaded){wn();return}let i=nM(r,n);if(!i)Ue(t(`composer.pickAnOption`));else{Ue(null),ye(``);try{await tM(e,pe,i.value,i.shown)}catch(e){ye(r),e instanceof $j||Ue(t(`composer.answerFailed`,{error:BF(e)}))}}},[pe,_e,Ae,wn,ye,e,t]),Rn=(0,V.useCallback)(()=>{for(let e=i.length-1;e>=0;e--)if(i[e].role===`user`){An(i[e]);return}},[i,An]),zn=(0,V.useCallback)(e=>{let t=i.indexOf(e);for(let n=t-1;n>=0;n--)if(i[n].role===`user`){An(i[n],e);return}},[i,An]),Bn=(0,V.useCallback)(e=>{let t=i.indexOf(e);for(let e=t-1;e>=0;e--)if(i[e].role===`user`){An(i[e]);return}},[i,An]),[Vn,Hn]=(0,V.useState)(null),Un=(0,V.useRef)(null),Wn=(0,V.useCallback)(e=>{Un.current=null,Hn(e)},[]),Gn=(0,V.useCallback)(()=>{let e=bH(i);e&&Wn(e.id)},[i,Wn]),Kn=(0,V.useCallback)(e=>{Un.current=e},[]),qn=(0,V.useCallback)(()=>{Un.current=null,Hn(null),$e.current?.focus()},[]),Jn=(0,V.useCallback)(async(e,t)=>{Un.current=t,await An(e,void 0,t)&&(Un.current=null,Hn(t=>t===e.id?null:t))},[An]),Yn=(0,V.useCallback)(()=>{pt.current(t(`msg.continuePrompt`))},[t]),Xn=()=>{N(ge?.title||``),Ce(!0)},Zn=async()=>{let n=we.trim().slice(0,200).trim();if(n&&we!==ge?.title&&n!==ge?.title){Ue(null);try{await fe(e,{title:n,title_is_custom:!0}),u(e,{title:n})}catch(n){P.chat.error(`Could not rename chat ${e}`,n),Ue(t(`chat.renameFailed`,{error:BF(n)}))}}Ce(!1)},Qn=(0,V.useCallback)(async()=>{if(e){Ue(null);try{let t=await Ke(e);u(e,{private:t.private})}catch(e){P.ui.warn(`Failed to toggle private mode`,e),Ue(t(`chat.privateFailed`,{error:BF(e)}))}}},[e,u,t]),$n=(0,V.useCallback)(async n=>{if(n.preventDefault(),n.stopPropagation(),Ee(!1),n.dataTransfer.files.length===0)return;let r=Array.from(n.dataTransfer.files),i=e=>qV(e.name)||e.type.startsWith(`image/`),a=r.filter(i);a.length>0&&Ae.addFiles(a);let o=r.filter(e=>!i(e));if(o.length===0||!await Vc(`embedding`))return;Ue(null);let s=await XJ(e,o);s.length>0&&Ue(s.map(({name:e,stage:n,error:r})=>n===`unreadable`||n===`server`||n===`busy`?t(n===`server`?`docsBar.serverTitle`:n===`busy`?`docsBar.busyTitle`:`docsBar.failedTitle`,{name:e}):t(n===`attach`?`chat.dropAttachFailed`:`chat.dropUploadFailed`,{name:e,error:BF(r)})).join(` `))},[e,Ae,t]),er=e=>{e.dataTransfer?.types?.includes(`Files`)&&(e.preventDefault(),e.stopPropagation(),Ee(!0))},tr=e=>{e.preventDefault(),e.stopPropagation(),Ee(!1)},nr=i.length>0?i[i.length-1]:void 0,rr=(0,V.useMemo)(()=>dM(nr),[nr]),ir=(0,V.useMemo)(()=>fM(nr),[nr]),or=!d&&!A&&nr?.role===`assistant`&&(pM(nr)?rr.length>0:sj(nr.content)),sr=(0,V.useMemo)(()=>xB(i),[i]),cr=Ge?`This chat used the retired "${Ge}" agent and is read-only. Start a new chat.`:sV(j)?ed:null;return R(`main`,{className:`task-view ${Te?`drag-active`:``}`,style:{"--session-panel-w":`${fn}px`},onDrop:$n,onDropCapture:()=>Ee(!1),onDragOver:er,onDragLeave:tr,"aria-label":Jd(t,ge)||`Chat`,children:[I(gB,{busy:Nn}),R(`header`,{className:`task-header`,children:[I(`div`,{className:`task-header-left`,children:Se?I(`input`,{className:`title-edit`,value:we,maxLength:200,onChange:e=>N(e.target.value),onBlur:Zn,onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&Zn(),e.key===`Escape`&&(e.preventDefault(),Ce(!1))},...Lt,autoFocus:!0,"aria-label":`Chat title`,dir:`auto`}):R(`button`,{type:`button`,className:`task-title`,onClick:Xn,title:t(`row.rename`),children:[I(`span`,{children:qd(ge?.title)?t(`sidebar.newChat`):Jd(t,ge)}),I(Jo,{size:12,"aria-hidden":`true`,className:`task-title-edit`})]})}),R(`div`,{className:`task-header-right`,children:[I(`button`,{ref:_n,className:`btn-icon-sm task-header-resources`,onClick:()=>gn(!mn),"aria-pressed":mn,"aria-label":t(`resources.toggle`),title:t(mn?`resources.hide`:`resources.show`),children:I(Or,{size:15,"aria-hidden":`true`})}),I(sJ,{isPrivate:!!ge?.private,onToggle:Qn}),I(`button`,{className:`btn-icon-sm`,onClick:()=>k(!0),title:t(`chat.browseFiles`),"aria-label":t(`chat.browseFiles`),children:I(Aa,{size:15})}),I(`button`,{className:`btn-icon-sm`,onClick:Re,title:t(`chat.exportTitle`),"aria-label":t(`chat.exportLabel`),children:I(Ji,{size:15})}),I(eY,{messages:i}),I(oJ,{messages:i,busy:d})]})]}),mn&&I(kJ,{onClose:bn}),!mn&&vn&&R(`div`,{className:`resource-strip resource-hidden-note`,role:`status`,children:[I(`span`,{children:t(`resources.hiddenNote`)}),I(`button`,{type:`button`,className:`resource-hidden-undo`,onClick:()=>gn(!0),children:t(`resources.show`)})]}),I(lJ,{sessionId:e,onDetachFailed:We}),I(`div`,{className:`messages-scroll`,ref:Qe,...Rt,children:R(`div`,{className:`messages-column`,children:[A&&!Yt&&I(`div`,{className:`skeleton-messages`,"aria-label":t(`chat.loadingMessages`),children:[0,1,2].map(e=>I(`div`,{className:`skeleton-msg`,children:R(`div`,{className:`skeleton-lines`,children:[I(`div`,{className:`skeleton-line`}),I(`div`,{className:`skeleton-line`}),e!==2&&I(`div`,{className:`skeleton-line`})]})},e))}),Ht&&Xt.length===0&&!d&&!Yt&&!se&&R(`div`,{className:`chat-empty`,children:[I(`h2`,{className:`chat-empty-title`,children:t(`chat.empty.title`)}),!Ge&&I(`p`,{className:`chat-empty-hint`,children:t(`chat.empty.hint`)})]}),Xt.map((e,t)=>{let n=Ye.current.get(e.id)??e.id,r=$t(e);return I(IW,{message:e,className:je===e.id?`msg-deleting`:Xe.current.has(n)?`msg-settled`:void 0,notice:e.role===`assistant`?e.historyNotice??pY.get(e.id):void 0,busy:Nn,readOnly:!!Ge,unsent:r,isLast:t===i.length-1,comparing:!!an,comparison:an?.messageId===e.id?an:null,laterCount:e.role===`user`?xH(i,t):0,latencyMs:e.stats?.seconds==null?sr.get(e.id):e.stats.seconds*1e3,answeredBy:ge?.effective_model,editing:Vn===e.id&&!Nn,editDraft:Vn===e.id?Un.current:null,onDelete:Dn,onResend:An,onEditStart:Wn,onEditDraft:Kn,onEdit:Jn,onEditCancel:qn,onRegenerate:Bn,onRetryWith:cn,onTryAgain:zn,onContinue:Yn,onKeepAnswer:ln,onCloseComparison:un},en(e)??n)}),d&&qe&&I(TU,{text:qe}),d&&I(QB,{}),(d||!!Yt)&&I(`div`,{className:`streaming-bubble stream-active`,children:I(Wz,{message:{id:-1,session_id:e,role:`assistant`,content:d&&f||``,created_at:``,rag_sources:null},isStreaming:d||!!Yt,agentSteps:d?y:dY,agentStepsActive:d&&y.some(e=>e.active),cards:d?T:fY,liveStatus:d?ce:null,toolStatus:d?le:null,awaitingUser:d&&(ue||de||he)})}),I(`div`,{ref:Ze})]})}),I(iJ,{sessionId:e,messages:i,busy:Nn,usage:tn,onUsage:rn,onJumpToMessage:xn}),Te&&R(`div`,{className:`drag-overlay`,children:[I(fc,{size:32,strokeWidth:1.5,"aria-hidden":`true`}),I(`span`,{children:t(`chat.dropOverlay`)})]}),Ne&&R(`div`,{className:`toast policy-alert-toast`,role:`alert`,children:[I(`span`,{children:t(`chat.policyBlocked`,{tool:Ne.tool})}),Ne.receiptId?I(`button`,{type:`button`,className:`policy-alert-toast-link`,onClick:()=>{let e=Ne.receiptId;e&&(oe(`policy_alert`),ae(!0),Le(e))},children:t(`chat.policyViewReceipt`)}):I(`span`,{className:`policy-alert-toast-missing`,children:t(`activity.policy.receiptUnavailable`)})]}),R(`div`,{className:`input-area`,children:[Oe&&I(`button`,{className:`scroll-bottom-btn`,onClick:Sn,title:t(`chat.scrollBottom`),"aria-label":t(`chat.scrollBottom`),children:I(Mr,{size:16})}),R(`div`,{className:`input-column`,children:[I(jJ,{message:Be,onDismiss:Ve,dismissLabel:t(`chat.dismissExportError`)}),I(jJ,{message:He,onDismiss:()=>Ue(null),dismissLabel:t(`chat.dismissError`)}),or&&nr&&I(dH,{content:nr.content,providers:rr,accounts:ir,onRetry:Rn},nr.id),I(HO,{sessionId:e}),I(nW,{usage:tn}),I(AJ,{sessionId:e}),se&&Kt&&I(`ul`,{className:`queued-messages`,"aria-label":t(`composer.heldLabel`),"aria-live":`polite`,children:R(`li`,{className:`queued-message is-queued`,children:[I(Mi,{size:12,"aria-hidden":`true`}),I(`span`,{className:`queued-message-text`,title:se.text,children:se.text}),I(`span`,{className:`queued-message-state`,children:t(`composer.heldUntilStarted`)})]})}),I(AU,{items:gt,onRemove:e=>_t(t=>ve(t,e)),onRetry:e=>_t(t=>s(t,e,`failed`,`queued`)),onSteer:d&&!at&&!yt?Fn:void 0,replying:d,busyRetry:!!wt}),I(FH,{value:_e,onChange:ye,onSubmit:pe?Ln:()=>wn(),answering:!!pe,onStop:Cn,streaming:d,stopping:at,queueWhileStreaming:!0,disabledReason:cr,attachments:Ae,inputRef:$e,onEditLast:!Nn&&!Ge?Gn:void 0,placeholder:pe?t(`composer.answerQuestion`):d?t(`composer.queueNext`):n?t(`composer.researchPlaceholder`):i.length===0?t(`composer.placeholder`):t(`composer.reply`),leftControls:R(F.Fragment,{children:[I(yU,{sessionId:e,disabled:!!Ge}),I(wU,{sessionId:e,disabled:!!Ge,compact:!0})]}),rightControls:R(F.Fragment,{children:[I(tW,{usage:tn,sessionId:e,busy:Nn,onUsage:rn,onDetails:()=>pn(`context`)}),I(oW,{sessionId:e,busy:Nn}),I(mU,{sessionId:e,onOpen:()=>pn(`environment`)}),I(mH,{}),I(tU,{})]})})]})]})]})}var gY=1.1,_Y=60,vY=110,yY=24,bY=2.4,xY=Math.PI*2,SY=(e,t,n)=>{let r=Math.min(1,Math.max(0,(n-e)/(t-e)));return r*r*(3-2*r)};function CY(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 wY=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=CY(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()*xY),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*SY(.75,1.5,a))*SY(0,50,i)*SY(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()*xY})}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()*xY},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*bY),a=Math.min(1,e*14),o=Math.min(1,e*9),s=r?_Y+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)>yY+.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)/yY;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<vY){let i=(1-n/vY)**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/gY),i=(1-(1-r)**3)*n.reach,a=new Path2D;for(let e=0;e<=180;e++){let t=e/180*xY,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)}},TY=90;function EY(){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 DY(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 OY({activity:e,progress:t=0,pulse:n,docked:r,contentRef:i,composerRef:a}){let o=(0,V.useRef)(null),s=(0,V.useRef)(null),c=(0,V.useRef)(null),l=(0,V.useRef)(()=>{}),u=(0,V.useRef)(()=>{}),d=(0,V.useRef)(r),f=(0,V.useRef)({value:n,at:0});d.current=r,(0,V.useEffect)(()=>{let e=o.current,t=e?.parentElement;if(!e||!t)return;let n=e.getContext(`2d`);if(!n){P.ui.warn(`New-chat background is off: the browser gave no 2D canvas context (often low graphics memory).`);return}c.current=t;let r=new wY;s.current=r;let f=typeof window.matchMedia==`function`?window.matchMedia($W):null,p=EY(),m=0,h=0,g=!1,_=``,v={x:0,y:0,at:0,speed:0},y=()=>r.draw(n,p),b=(e,t=!1)=>{let n=d.current?a.current:i.current,r=(n&&DY(n,e,d.current?24:40))??{cx:e.width/2,cy:e.height/2,rx:1,ry:1},o=`${Math.round(r.cx)},${Math.round(r.cy)},${Math.round(r.rx)},${Math.round(r.ry)}`;return t||o!==_?(_=o,r):null},x=()=>{let i=t.getBoundingClientRect();if(!i.width||!i.height)return;let a=Math.min(2,window.devicePixelRatio||1);e.width=Math.round(i.width*a),e.height=Math.round(i.height*a),n.setTransform(a,0,0,a,0,0),r.resize(i.width,i.height,b(i,!0)),y()},S=e=>{if(m=requestAnimationFrame(S),e-h<31.833333333333336)return;let n=Math.min(.1,(e-h)/1e3);h=e;let i=b(t.getBoundingClientRect());i&&r.setHole(i),e-v.at>80&&(v.speed*=.8),(r.step(n)||i)&&y(),r.cleared&&w()},C=()=>{g||document.hidden||f?.matches||r.cleared||(g=!0,h=performance.now(),m=requestAnimationFrame(S))},w=()=>{g=!1,cancelAnimationFrame(m)};l.current=C,u.current=()=>{let e=b(t.getBoundingClientRect());e&&r.setHole(e),g||y()};let T=()=>document.hidden?w():C(),E=()=>{w(),y(),C()},ee=()=>{p=EY(),y()},D=e=>{let n=t.getBoundingClientRect(),i=e.clientX-n.left,a=e.clientY-n.top,o=performance.now();if(v.at&&o>v.at){let e=Math.hypot(i-v.x,a-v.y)/((o-v.at)/1e3);v.speed+=(Math.min(4e3,e)-v.speed)*.35}Object.assign(v,{x:i,y:a,at:o});let s=e.target instanceof Element&&e.target.closest(`button, a, input, textarea, .composer`);r.setPointer(i,a,(e.buttons&1)==1&&!s,v.speed)},O=()=>{v.at=0,v.speed=0,r.clearPointer()},te=typeof ResizeObserver>`u`?null:new ResizeObserver(x);te?.observe(t,{box:`border-box`});let k=new MutationObserver(ee);return k.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`,`data-palette`,`style`]}),document.addEventListener(`visibilitychange`,T),f?.addEventListener(`change`,E),t.addEventListener(`pointermove`,D),t.addEventListener(`pointerleave`,O),x(),C(),()=>{w(),te?.disconnect(),k.disconnect(),document.removeEventListener(`visibilitychange`,T),f?.removeEventListener(`change`,E),t.removeEventListener(`pointermove`,D),t.removeEventListener(`pointerleave`,O),s.current=null,l.current=()=>{},u.current=()=>{}}},[i,a]);let p=(0,V.useCallback)(()=>{let e=c.current,t=a.current;if(!e||!t)return null;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return[r.left-n.left+r.width/2,r.top-n.top+r.height/2]},[a]);return(0,V.useEffect)(()=>{let t=s.current;if(t){if(t.setActivity(e),e===`sending`){let e=p();e&&t.dissolve(...e)}else t.dissolving&&(t.restore(),l.current())}},[e,p]),(0,V.useEffect)(()=>{s.current?.setProgress(t)},[t]),(0,V.useEffect)(()=>{u.current()},[r]),(0,V.useEffect)(()=>{let e=f.current;if(n===e.value)return;let t=performance.now();if(e.value=n,t-e.at<TY)return;e.at=t;let r=p();r&&s.current?.ripple(...r,.45)},[n,p]),I(`canvas`,{ref:o,className:`npu-backdrop`,"aria-hidden":`true`})}function kY({disabled:e}){let t=L(),n=z(e=>e.draftPrivate),r=z(e=>e.setDraftPrivate),i=z(e=>e.settingsSection!==null),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(!1),d=(0,V.useRef)(null),f=(0,V.useCallback)(()=>u(!1),[]);if((0,V.useEffect)(()=>{if(i)return;let e=!1;return BP().then(t=>{e||(o(t.memory_enabled),c(!1))}).catch(t=>{e||(P.ui.error(`Could not read the memory setting for the Private chip`,t),o(null),c(!0))}),()=>{e=!0}},[i]),(0,V.useEffect)(()=>{a===!1&&n&&r(!1)},[a,n,r]),a===!1)return R(`button`,{type:`button`,className:`composer-chip composer-chip-memory is-unavailable`,disabled:!0,"aria-label":t(`composer.memoryOff`),title:t(`composer.memoryOffTitle`),children:[I(ia,{size:13,"aria-hidden":`true`}),I(`span`,{className:`composer-chip-label`,dir:`auto`,children:t(`composer.memoryOff`)})]});let p=e=>{r(e),u(!1)},m=[{priv:!1,Icon:oa,label:t(`composer.remember`),note:t(s?`composer.memoryUnknownTitle`:`composer.rememberNote`)},{priv:!0,Icon:ia,label:t(`composer.privateChat`),note:t(`composer.privateChatNote`)}];return R(`div`,{className:`composer-chip-wrap`,children:[R(`button`,{ref:d,type:`button`,className:`composer-chip composer-chip-memory${n?` is-on`:``}`,onClick:()=>u(e=>!e),disabled:e,"aria-haspopup":`dialog`,"aria-expanded":l,"aria-label":t(`composer.memoryChipAria`,{state:t(n?`composer.private`:s?`composer.memoryUnknown`:`composer.memoryOn`)}),title:t(n?`composer.privateChatNote`:s?`composer.memoryUnknownTitle`:`composer.rememberNote`),children:[I(n?ia:oa,{size:13,"aria-hidden":`true`}),I(`span`,{className:`composer-chip-label`,dir:`auto`,children:t(n?`composer.private`:s?`composer.memoryUnknown`:`composer.memoryOn`)}),I(fi,{size:12,"aria-hidden":`true`})]}),I(Mc,{open:l,onClose:f,anchor:d,label:t(`composer.memoryMenu`),children:m.map(({priv:e,Icon:t,label:r,note:i})=>R(`button`,{type:`button`,className:`popover-item`,onClick:()=>p(e),"aria-pressed":n===e,children:[I(`span`,{className:`popover-item-check`,"aria-hidden":`true`,children:I(n===e?ci:t,{size:13})}),R(`span`,{className:`popover-item-body`,children:[I(`span`,{className:`popover-item-title`,children:r}),I(`span`,{className:`popover-item-note`,children:i})]})]},String(e)))})]})}function AY(e){if(e.skill===`document-brief`){let t=/^(\d+) /.exec(e.note)?.[1];return t?{n:Number(t)}:void 0}if(e.skill===`coding`){let t=/^In (.+)$/.exec(e.note)?.[1];return t?{folder:t}:void 0}}function jY(e,t,n,r){let i=`${n}.one`,a=`${n}.other`,o=j(i)&&j(a)&&typeof r?.n==`number`?r.n===1?i:a:n;return!j(o)||se[o].includes(`{`)&&!r?t:gt(o,r)===t?e(o,r):t}function MY(e,t){return{title:jY(t,e.title,`card.${e.skill}.title`),note:jY(t,e.note,`card.${e.skill}.note`,AY(e))}}function NY({text:e}){let t=u(e);return t.length===1?I(F.Fragment,{children:e}):I(F.Fragment,{children:t.map((e,t)=>I(`span`,{className:`start-card-part`,children:e},t))})}function PY({cards:e,onPick:t,disabled:n}){let r=L();return e.length===0?null:I(`ul`,{className:`start-cards`,"aria-label":r(`newChat.cardsLabel`),children:e.map(e=>{let{title:i,note:a}=MY(e,r);return I(`li`,{children:R(`button`,{type:`button`,className:`start-card`,onClick:()=>t(e),disabled:n,title:e.needs_input?`${e.prompt}…`:e.prompt,children:[R(`span`,{className:`start-card-title`,children:[i,I(Rr,{size:13,"aria-hidden":`true`})]}),I(`span`,{className:`start-card-note`,children:I(NY,{text:a})})]})},e.skill)})})}var FY=[{icon:ui,label:`cards.try.recipe`,prompt:`cards.try.recipePrompt`},{icon:uo,label:`cards.try.checklist`,prompt:`cards.try.checklistPrompt`},{icon:us,label:`cards.try.bill`,prompt:`cards.try.billPrompt`}],IY={"document-brief":Sa,"inbox-triage":vo,"research-report":Es,coding:Ri,summarize:ws,"check-in":ms};function LY({cards:e=[],onPick:t,disabled:n,pending:r=!1}){let i=L(),a=e.slice(0,2),o=FY.slice(0,3-a.length);return R(`div`,{className:`try-chips${r?` is-pending`:``}`,role:`group`,"aria-label":i(`newChat.cardsLabel`),"aria-hidden":r||void 0,inert:r||void 0,children:[a.map(e=>{let r=IY[e.skill]??Rr,{title:a,note:o}=MY(e,i),s=e.needs_input?`${e.prompt.trimEnd()}…`:e.prompt;return R(`button`,{type:`button`,className:`try-chip`,title:`${o}\n${s}`,"aria-label":`${a}: ${s}`,onClick:()=>t(e.prompt),disabled:n,children:[I(r,{size:14,"aria-hidden":`true`}),a]},e.skill)}),o.map(({icon:e,label:r,prompt:a})=>{let o=i(r),s=i.bare(a);return R(`button`,{type:`button`,className:`try-chip`,title:s,"aria-label":`${o}: ${s}`,onClick:()=>t(s),disabled:n,children:[I(e,{size:14,"aria-hidden":`true`}),o]},r)})]})}var RY=1e3;function zY(){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(()=>{en().then(r,i)},RY)):t(null))},i=n=>{e||(P.system.warn(`Warm-up status unavailable`,n),t(null))};return x().then(r,i),()=>{e=!0,n&&clearTimeout(n)}},[]),e}function BY(e){return e===`gpu`?`your GPU`:e===`npu`?`your NPU`:e===`cpu`?`the CPU`:null}function VY(e){return e<1?`under 1 GB`:`${e.toFixed(1)} GB`}var HY=15e3,UY=3e3;function WY(e=new Date,t=gt){let n=e.getHours();return t(`newChat.greeting.${n<5?`evening`:n<12?`morning`:n<18?`afternoon`:`evening`}`)}var GY={gpu:`device.gpu`,npu:`device.npu`,cpu:`device.cpu`};function KY({seconds:e,model:t,device:n},r=gt){if(!t)return r(`newChat.warmup.ready`,{s:e});let i=cl(t),a=n?GY[n]:void 0;if(a)return r(`newChat.warmup.loadingOn`,{model:i,where:de(a),s:e});let o=BY(n);return o?r(`newChat.warmup.loadingOn`,{model:i,where:o,s:e}):r(`newChat.warmup.loading`,{model:i,s:e})}function qY({detail:e,onRetry:t}){let n=L(),[r,i]=(0,V.useState)(!1);return R(`div`,{className:`new-chat-note`,children:[R(`p`,{children:[n(`newChat.assistantUnavailable`),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:t,children:n(`newChat.tryAgain`)})]}),R(`button`,{type:`button`,className:`new-chat-details`,"aria-expanded":r,onClick:()=>i(e=>!e),children:[I(gi,{size:12,className:r?`is-open`:``,"aria-hidden":`true`}),` `,n(`newChat.details`)]}),r&&I(`pre`,{className:`new-chat-details-text`,children:e})]})}function JY(){let{documents:e,draftDocumentIds:t,addDraftDocuments:n}=z.getState();n(e.filter(e=>e.indexing_status===`complete`&&!t.includes(e.id)).map(e=>e.id))}function YY(){let e=L(),[t,n]=(0,V.useState)(!1),r=z(e=>e.documents),i=z(e=>e.draftDocumentIds),a=z(e=>e.removeDraftDocument),o=z(e=>e.setShowDocLibrary),s=r.filter(e=>i.includes(e.id)),c=r.filter(e=>e.indexing_status===`complete`&&!i.includes(e.id));if(!s.length&&!c.length)return null;let l=c.length,u=s.length-5,d=t||u<=0?s:s.slice(0,5);return R(`div`,{className:`new-chat-docs`,children:[s.length>0&&I(`ul`,{id:`new-chat-doc-list`,className:`new-chat-doc-list${t?` is-expanded`:``}`,"aria-label":e(`newChat.docs.forChat`),children:d.map(t=>R(`li`,{className:`new-chat-doc`,children:[I(Sa,{size:12,"aria-hidden":`true`}),I(`span`,{dir:`ltr`,children:kd(t.filename)}),I(`button`,{type:`button`,className:`new-chat-doc-remove`,onClick:()=>a(t.id),"aria-label":e(`newChat.docs.dontAttach`,{name:kd(t.filename)}),children:I(bc,{size:12,"aria-hidden":`true`})})]},t.id))}),u>0&&I(`button`,{type:`button`,className:`link-btn new-chat-doc-toggle`,"aria-expanded":t,"aria-controls":`new-chat-doc-list`,onClick:()=>n(e=>!e),children:t?e(`newChat.docs.fewer`):e(`newChat.docs.hidden`,{n:u})}),l>0&&R(`p`,{className:`new-chat-note`,children:[s.length?e.plural(`newChat.docs.more`,l):e.plural(`newChat.docs.library`,l),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:JY,children:l===1?e(`newChat.docs.attachIt`):e(`newChat.docs.attachAll`,{n:l})}),l>1&&R(F.Fragment,{children:[` · `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>o(!0),children:e(`newChat.docs.choose`)})]})]})]})}function XY({error:e}){let t=L(),n=z(e=>e.openSettings);return R(`div`,{className:`new-chat-setup-failed`,role:`alert`,children:[I(`p`,{className:`new-chat-setup-failed-title`,children:t(`newChat.setupFailed.title`)}),I(`p`,{className:`new-chat-setup-failed-error`,children:e}),R(`p`,{children:[t(`newChat.setupFailed.hint`),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>n(`model`),children:t(`newChat.setupFailed.choose`)})]})]})}function ZY({onSend:e,initialText:t=``,focusRequest:n=0,agentMissing:r=!1,agentRefused:i=!1}){let a=L(),o=bU(null),s=z(e=>sV(e.systemStatus)),c=z(e=>e.systemStatus?.download_progress??null),l=z(e=>e.systemStatus?.model_loaded?null:e.systemStatus?.setup_error??null),u=il(e=>!!e.active?.remote),[d,f]=ZJ(An,t),p=(0,V.useRef)(d);p.current=d;let[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)(i),[v,y]=(0,V.useState)(!1),[b,x]=(0,V.useState)(null),[S,C]=(0,V.useState)(null),[T,E]=(0,V.useState)(!1),[ee,D]=(0,V.useState)(null),[O,te]=(0,V.useState)(!1),k=(0,V.useRef)(null),A=(0,V.useRef)(null),ne=(0,V.useRef)(null),j=FJ(),M=zY();ol();let re=(0,V.useRef)(!0),ie=(0,V.useCallback)((e=!1)=>{e||C(null),_t().then(e=>{re.current&&(x(e),C(e.skills_error??null),D(e.agent_problem??null),e.agent_problem||te(!1))}).catch(e=>{P.api.warn(`New-chat start screen unavailable`,e),re.current&&C(VF(e))})},[]);(0,V.useEffect)(()=>(re.current=!0,ie(),()=>{re.current=!1}),[ie]),(0,V.useEffect)(()=>{let e=window.setTimeout(()=>E(!0),UY);return()=>window.clearTimeout(e)},[]),(0,V.useEffect)(()=>{Tt().then(e=>z.getState().setDocuments(e.documents||[])).catch(e=>P.api.warn(`Document library unavailable; not offering its documents`,e))},[]),(0,V.useEffect)(()=>{if(S)return jl(()=>ie(!0),HY)},[S,ie]);let ae=(0,V.useRef)(!1),oe=(0,V.useRef)([]),se=(0,V.useCallback)(async(t,n=``)=>{if(t){if(ae.current)oe.current.push(n||t),f(``);else{ae.current=!0,y(!0),h(null),_(!1),f(``);try{let n=await e(t);j.clear();let r=oe.current.splice(0),i=z.getState().currentSessionId;if(r.length>0&&i){let e=(e,t)=>n===!1?[...e,{...w(t,`failed`),error:Ie}]:ar(e,t,`queued`);z.getState().updateQueue(i,t=>r.reduce(e,t))}}catch(e){let r=oe.current.splice(0);f([n||t,...r].join(`
209
+
210
+ `)),e instanceof TA?_(!0):h(VF(e))}finally{ae.current=!1,y(!1)}}}},[j,e]),ce=(0,V.useRef)(!1),le=(0,V.useCallback)(async()=>{if(ee){te(!0);return}let e=d.trim();if(!ce.current){if(CU(e,null)){ce.current=!0,h(null);try{await SU(e,null)}catch(e){h(a(`composer.researchSkillsUnavailable`,{error:BF(e)}));return}finally{ce.current=!1}if(p.current!==d)return}await se(j.compose(xU(e,null)),e)}},[ee,j,se,d,a]);(0,V.useEffect)(()=>{n&&k.current?.focus()},[n]),(0,V.useEffect)(()=>{let e=k.current;t&&e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},[t]);let ue=v,de=(0,V.useRef)(null);(0,V.useLayoutEffect)(()=>{let e=A.current;if(!e)return;typeof e.getAnimations==`function`&&e.getAnimations().forEach(e=>e.cancel());let t=e.getBoundingClientRect().top,n=de.current;if(de.current={top:t,docked:ue},!n||n.docked===ue||tG()||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:eG(`--duration-spring`),easing:r})});let fe=(0,V.useRef)(``),pe=(0,V.useCallback)(e=>{let t=fe.current,n=(t&&d.endsWith(t)?d.slice(0,-t.length):d).trimEnd();fe.current=e,f(n?`${n}\n\n${e}`:e),k.current?.focus()},[d,f]),me=c?.state===`starting`||c?.state===`downloading`,he=v?`sending`:me?`download`:s||M!==null?`loading`:`idle`,ge=b?.working_folder;return R(`main`,{className:`new-chat${ue?` is-docked`:``}`,"aria-label":a(`newChat.label`),children:[I(OY,{activity:he,progress:(c?.percent??0)/100,pulse:d.length,docked:ue,contentRef:A,composerRef:ne}),I(`div`,{className:`new-chat-actions`,children:I(yq,{})}),R(`div`,{className:`new-chat-inner`,ref:A,children:[I(`h1`,{className:`new-chat-greeting`,"aria-hidden":ue,children:WY(new Date,a)}),l&&!u&&I(XY,{error:l}),ee&&I(jW,{problem:ee,onRetry:()=>ie(),kept:O}),I(`div`,{ref:ne,children:I(FH,{value:d,onChange:f,onSubmit:le,attachments:j,disabledReason:s?a(`composer.starting`):null,autoFocus:!0,inputRef:k,placeholder:o?a(`composer.researchPlaceholder`):void 0,leftControls:R(F.Fragment,{children:[I(yU,{sessionId:null}),I(kY,{disabled:v}),I(wU,{sessionId:null,disabled:v,compact:!0})]}),rightControls:I(tU,{})})}),R(`div`,{className:`new-chat-meta`,children:[ge&&I(pU,{folder:ge,disabled:s||v}),I(mH,{})]}),I(YY,{}),M!==null&&!s&&M.seconds>=2&&I(`p`,{className:`new-chat-warmup`,role:`status`,children:KY(M,a)}),m&&I(`p`,{className:`new-chat-error`,role:`alert`,children:m}),g&&r&&I(`p`,{className:`new-chat-error`,role:`alert`,children:a(`agentNotice.sendRefused`)}),I(LY,{cards:b?.cards,pending:!b&&!S&&!T,onPick:pe,disabled:s||v}),!ee&&S&&I(qY,{detail:S,onRetry:()=>ie()})]})]})}var QY=1e3,$Y=15,eX=5,tX=new Map;function nX(){let e=L(),t=Bc(e=>e.need),n=Bc(e=>e.settle),r=(0,V.useRef)(null),i=(0,V.useRef)(null),a=(0,V.useRef)(0),o=(0,V.useRef)(0),s=(0,V.useRef)(null);s.current=t;let[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)(null),[m,h]=(0,V.useState)(!1),g=(0,V.useCallback)(()=>{i.current&&clearInterval(i.current),i.current=null},[]);(0,V.useEffect)(()=>(l(null),d(!1),p(null),h(!1),g),[t,g]);let _=(0,V.useCallback)(()=>{g(),u&&t?.model&&ne(t.model.id).catch(e=>console.warn(`[ModelNeededDialog] could not cancel the download`,e)),n(!1)},[u,t,n,g]);er(!!t,_),yn(r,!!t);let v=(0,V.useCallback)(async r=>{if(!t?.model)return;let c=t,u=t.model.id,f=(tX.get(u)??0)+1;tX.set(u,f),p(null),d(!0),a.current=0,o.current=0;try{await ut(u,{acknowledgeLowDisk:r})}catch(e){if(s.current!==c)return;d(!1),p(e instanceof Error?e.message:String(e)),e instanceof On&&e.body?.code===`low_disk`&&h(!0);return}s.current===c?(g(),i.current=setInterval(()=>{$t().then(t=>{if(s.current!==c){g();return}o.current=0;let r=t.models?.find(e=>e.id===u);if(r)r.bytes_total>0&&l(Math.floor(r.bytes_done*100/r.bytes_total)),r.state===`ready`||r.state===`verifying`?(g(),n(!0)):(r.state===`failed`||r.state===`cancelled`)&&(g(),d(!1),p(r.error??e(`modelNeeded.failed`)));else{if(++a.current<$Y)return;g(),d(!1),p(e(`modelNeeded.failed`))}}).catch(e=>{s.current===c?++o.current<eX||(g(),d(!1),p(e instanceof Error?e.message:String(e))):g()})},QY)):tX.get(u)===f&&ne(u).catch(e=>console.warn(`[ModelNeededDialog] could not cancel the download`,e))},[t,n,g,e]);if(t?.off)return(0,by.createPortal)(I(`div`,{className:`model-needed-overlay`,children:R(`div`,{ref:r,className:`model-needed`,role:`dialog`,"aria-modal":`true`,"aria-label":e(`modelNeeded.off.${t.off}.title`),children:[I(`h2`,{className:`model-needed-title`,children:e(`modelNeeded.off.${t.off}.title`)}),I(`p`,{className:`model-needed-from`,children:e(`modelNeeded.off.${t.off}.body`)}),R(`div`,{className:`model-needed-actions`,children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:_,children:e(`modelNeeded.notNow`)}),I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>n(!0),children:e(`modelNeeded.off.send`)})]})]})}),document.body);if(!t?.model)return null;let{model:y,job:b,disk_free_gb:x}=t,S=y.size_gb!=null&&x!=null&&y.size_gb>x,C=S||m;return(0,by.createPortal)(I(`div`,{className:`model-needed-overlay`,children:R(`div`,{ref:r,className:`model-needed`,role:`dialog`,"aria-modal":`true`,"aria-label":e(`modelNeeded.dialog`),children:[I(`h2`,{className:`model-needed-title`,children:e(`modelNeeded.title.${b}`)}),R(`p`,{className:`model-needed-line`,children:[I(`bdi`,{children:y.name}),y.size_gb!=null&&R(F.Fragment,{children:[`, `,I(`bdi`,{dir:`ltr`,children:GA(y.size_gb)})]}),x!=null&&R(F.Fragment,{children:[` · `,e(`modelNeeded.free`),` `,I(`bdi`,{dir:`ltr`,children:GA(x)})]})]}),y.source&&R(`p`,{className:`model-needed-from`,children:[e(`setup.contents.from`),` `,I(`bdi`,{dir:`ltr`,children:y.source})]}),I(`p`,{className:`model-needed-from`,children:e(`modelNeeded.waits`)}),u&&(c==null?R(`p`,{role:`status`,children:[I(B,{size:13,className:`spin`,"aria-hidden":`true`}),` `,e(`modelNeeded.starting`)]}):I(`progress`,{className:`setup-progress`,max:100,value:c,"aria-label":e(`modelNeeded.dialog`)})),S&&!u&&I(`p`,{className:`setup-error`,role:`alert`,children:e(`modelNeeded.lowDisk`,{need:GA(y.size_gb??0),free:GA(x??0),freeUp:GA((y.size_gb??0)-(x??0))})}),f&&I(`p`,{className:`setup-error`,role:`alert`,children:f}),R(`div`,{className:`model-needed-actions`,children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:_,children:e(`modelNeeded.notNow`)}),I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void v(C),disabled:u,children:e(C?`setup.confirm.downloadAnyway`:f?`setup.tryAgain`:`modelNeeded.download`)})]})]})}),document.body)}function rX(e,t,n){let r=(0,V.useRef)(n);(0,V.useEffect)(()=>{r.current=n});let i=(0,V.useRef)(!1),a=(0,V.useRef)(null);if(t&&!i.current){let e=document.activeElement;a.current=e instanceof HTMLElement?e:null}(0,V.useEffect)(()=>{if(!t)return;i.current=!0;let n=a.current,o=e.current;if(o&&!o.contains(document.activeElement)){let e=r.current?.()??Gn(o)[0];e?e.focus():(o.hasAttribute(`tabindex`)||o.setAttribute(`tabindex`,`-1`),o.focus())}return()=>{i.current=!1;let e=document.activeElement;(!e||e===document.body||o?.contains(e))&&n?.isConnected&&n.focus()}},[e,t])}var iX=2e3,aX=`⁦`,oX=`⁩`,sX={model_server:`logs.source.modelServer`,gaia:`logs.source.gaia`,service:`logs.source.service`,agent:`logs.source.agent`,desktop:`logs.source.desktop`,other:`logs.source.other`},cX={model_server:`logs.hint.modelServer`,gaia:`logs.hint.gaia`,service:`logs.hint.service`,agent:`logs.hint.agent`,desktop:`logs.hint.desktop`,other:`logs.hint.other`},lX={no_file:`logs.reason.noFile`,unreadable:`logs.reason.unreadable`,not_running:`logs.reason.notRunning`,remote:`logs.reason.remote`,no_stream:`logs.reason.noStream`,stream_failed:`logs.reason.streamFailed`},uX=e=>e.severity===`warning`||e.severity===`error`;function dX(e){return e instanceof Error?e.message:String(e)}function fX(e){let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}${t(e.getMonth()+1)}${t(e.getDate())}-${t(e.getHours())}${t(e.getMinutes())}${t(e.getSeconds())}`}function pX({source:e,file:t}){let n=L(),[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)([]),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!0),[d,f]=(0,V.useState)(!0),[p,m]=(0,V.useState)(!1),[h,g]=(0,V.useState)(null),_=(0,V.useRef)(null),v=(0,V.useRef)(!1),y=(0,V.useRef)(null),b=(0,V.useRef)(!0),x=(0,V.useRef)(null),S=(0,V.useCallback)(async n=>{if(!v.current){v.current=!0,n&&u(!0);try{let r=await qe(e,{file:t,after:n?null:_.current});r.cursor&&(_.current=r.cursor);let a=r.lines??[],s=n||!!r.reset;o(e=>(s?a:[...e,...a]).slice(-5e3)),i(e=>s||!e?r:{...r,server_answering:r.server_answering??e.server_answering,dropped:e.dropped}),c(null)}catch(e){c(dX(e))}finally{v.current=!1,u(!1)}}},[e,t]);(0,V.useEffect)(()=>{_.current=null,b.current=!0,i(null),o([]),g(null),S(!0)},[S]),(0,V.useEffect)(()=>{if(d)return jl(()=>{S(!1)},iX)},[d,S]);let C=p?a.filter(uX):a,w=C.map(e=>e.text).join(`
211
+ `),T=(0,V.useCallback)(()=>{let e=y.current;e&&b.current&&(e.scrollTop=e.scrollHeight,x.current=e.scrollTop)},[]);(0,V.useEffect)(T,[w,T]);let E=C.length>0;(0,V.useEffect)(()=>{let e=y.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(T);return t.observe(e),e.firstElementChild&&t.observe(e.firstElementChild),()=>t.disconnect()},[E,T]);let ee=(0,V.useCallback)(async()=>{try{await navigator.clipboard.writeText(w),g({ok:!0,text:n(`logs.copied`)})}catch(e){g({ok:!1,text:n(`logs.copyFailed`,{error:dX(e)})})}},[n,w]),D=(0,V.useCallback)(()=>{let t=URL.createObjectURL(new Blob([`${w}\n`],{type:`text/plain;charset=utf-8`})),n=document.createElement(`a`);n.href=t,n.download=`gaia-${e.replace(`_`,`-`)}-log-${fX(new Date)}.txt`,n.click(),setTimeout(()=>URL.revokeObjectURL(t),6e4),g(null)},[e,w]),O=e===`model_server`,te=r&&!r.available&&r.reason?!O&&r.reason===`no_file`?`logs.reason.notWritten`:lX[r.reason]:void 0;return R(`div`,{className:`log-viewer-view`,children:[I(`p`,{className:`log-viewer-hint`,children:n(cX[e])}),r?.source===`file`&&r.log_path&&R(`p`,{className:`log-viewer-source`,children:[n(`logs.fromFile`),` `,I(`bdi`,{dir:`ltr`,children:r.log_path})]}),r?.source===`stream`&&R(`p`,{className:`log-viewer-source`,children:[n(`logs.fromStream`),` `,I(`bdi`,{dir:`ltr`,children:r.base_url})]}),O&&r?.source===`file`&&r.server_answering===!1&&I(`p`,{className:`log-viewer-warning`,role:`alert`,children:n(`logs.notAnswering`)}),te&&R(`div`,{className:`log-viewer-warning`,role:`alert`,children:[I(`p`,{children:n(te)}),r?.detail&&I(`p`,{className:`log-viewer-detail`,children:I(`bdi`,{dir:`ltr`,children:r.detail})})]}),r?.available&&r.detail&&I(`p`,{className:`log-viewer-hint`,role:`note`,children:I(`bdi`,{dir:`ltr`,children:r.detail})}),s&&I(`p`,{className:`log-viewer-warning`,role:`alert`,children:n(`logs.readFailed`,{error:s})}),R(`div`,{className:`log-viewer-toolbar`,children:[R(`label`,{className:`log-viewer-check`,children:[I(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked)}),n(`logs.follow`)]}),R(`label`,{className:`log-viewer-check`,children:[I(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked)}),n(`logs.problemsOnly`)]}),R(`div`,{className:`log-viewer-actions`,children:[R(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void S(!0),disabled:l,children:[l?I(B,{size:13,className:`spin`,"aria-hidden":`true`}):I(bs,{size:13,"aria-hidden":`true`}),n(`logs.refresh`)]}),R(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void ee(),disabled:!w,children:[h?.ok?I(ci,{size:13,"aria-hidden":`true`}):I(Bi,{size:13,"aria-hidden":`true`}),n(`logs.copy`)]}),R(`button`,{type:`button`,className:`btn-secondary`,onClick:D,disabled:!w,children:[I(fa,{size:13,"aria-hidden":`true`}),n(`logs.save`)]})]})]}),l&&!r?R(`p`,{className:`log-viewer-empty`,role:`status`,children:[I(B,{size:13,className:`spin`,"aria-hidden":`true`}),` `,n(`logs.loading`)]}):r?.available&&C.length===0?I(`p`,{className:`log-viewer-empty`,role:`status`,children:p&&a.length>0?n(`logs.noProblems`):n(`logs.empty`)}):C.length>0&&I(`pre`,{ref:y,className:`log-viewer-lines`,dir:`ltr`,tabIndex:0,"aria-label":n(sX[e]),onScroll:e=>{let t=e.currentTarget;t.scrollTop!==x.current&&(x.current=null,b.current=t.scrollHeight-t.scrollTop-t.clientHeight<8)},children:I(`span`,{className:`log-viewer-body`,children:C.map((e,t)=>R(`span`,{className:e.severity?`is-${e.severity}`:void 0,children:[e.text,`
212
+ `]},t))})}),(r?.dropped??0)>0&&I(`p`,{className:`log-viewer-hint`,children:n(`logs.older`)}),h&&I(`p`,{className:h.ok?`settings-ok`:`log-viewer-warning`,role:h.ok?`status`:`alert`,children:h.text})]})}function mX(){let e=L(),{saving:t,saved:n,error:r,save:i}=dR(`logs.saveAllFailed`);return R(`div`,{className:`log-viewer-save-all`,children:[R(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void i(),disabled:t,children:[t?I(B,{size:13,className:`spin`,"aria-hidden":`true`}):I(Ar,{size:13,"aria-hidden":`true`}),e(`logs.saveAll`)]}),I(`span`,{className:`log-viewer-hint`,children:e(`setup.logs.reportNote`)}),n&&R(`p`,{className:`log-viewer-hint`,role:`status`,children:[e(`logs.savedAll`,{size:XA(n.size_bytes)}),` `,I(`bdi`,{dir:`ltr`,children:n.path})]}),r&&I(`p`,{className:`log-viewer-warning`,role:`alert`,children:r})]})}function hX(){let e=L(),t=Pc(e=>e.open),n=Pc(e=>e.source),r=Pc(e=>e.show),i=Pc(e=>e.hide),a=(0,V.useRef)(null),o=(0,V.useRef)(null),[s,c]=(0,V.useState)({}),[l,u]=(0,V.useState)(null);if(er(t,i),yn(a,t),rX(a,t,()=>o.current),(0,V.useEffect)(()=>{t&&et().then(e=>c(Object.fromEntries(e.sources.map(e=>[e.id,e.files??[]])))).catch(e=>console.warn(`[LogsDialog] could not list log files`,e))},[t]),(0,V.useEffect)(()=>{u(null)},[n]),!t)return null;let d=s[n]??[];return(0,by.createPortal)(I(`div`,{className:`log-viewer-overlay`,onMouseDown:e=>{e.target===e.currentTarget&&i()},children:R(`div`,{ref:a,className:`log-viewer`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`log-viewer-title`,children:[R(`div`,{className:`log-viewer-head`,children:[I(`h2`,{id:`log-viewer-title`,className:`log-viewer-title`,children:e(`logs.title`)}),I(`button`,{ref:o,type:`button`,className:`log-viewer-close`,onClick:i,"aria-label":e(`logs.close`),title:e(`logs.close`),children:I(bc,{size:16,"aria-hidden":`true`})})]}),I(`div`,{className:`log-viewer-tabs`,role:`tablist`,"aria-label":e(`logs.title`),children:Nc.map(t=>I(`button`,{type:`button`,role:`tab`,"aria-selected":t===n,className:t===n?`is-active`:``,onClick:()=>r(t),children:t===`gaia`?I(`bdi`,{children:e(sX[t])}):e(sX[t])},t))}),d.length>1&&R(`label`,{className:`log-viewer-file`,children:[e(`logs.file`),I(`select`,{dir:`ltr`,value:l??d[0].name,onChange:e=>u(e.target.value),children:d.map(e=>R(`option`,{value:e.name,children:[e.name,e.size_bytes==null?``:` (${aX}${gH(e.size_bytes)}${oX})`]},e.name))})]}),I(`div`,{role:`tabpanel`,className:`log-viewer-panel`,children:I(pX,{source:n,file:l},`${n}:${l??``}`)}),I(`p`,{className:`log-viewer-hint`,children:e(`logs.privacy`)}),I(mX,{})]})}),document.body)}var gX=[{label:`shortcuts.newChat`,keys:`Mod+Shift+O`},{label:`shortcuts.search`,keys:`Mod+K`},{label:`shortcuts.sidebar`,keys:`Mod+B`},{label:`shortcuts.settings`,keys:`Mod+,`},{label:`shortcuts.sheet`,keys:`Mod+/`},{label:`shortcuts.browserPane`,keys:`Mod+Shift+B`,desktopOnly:!0},{label:`shortcuts.send`,keys:`Enter`},{label:`shortcuts.newLine`,keys:`Shift+Enter`},{label:`shortcuts.editLast`,keys:`↑`},{label:`shortcuts.stop`,keys:`Esc`}];function _X(){let e=!!zI();return gX.filter(t=>e||!t.desktopOnly)}function vX({onClose:e}){let t=L(),n=(0,V.useRef)(null);return er(!0,e),yn(n,!0),rX(n,!0),I(`div`,{ref:n,className:`modal-overlay`,onClick:e,role:`dialog`,"aria-modal":`true`,"aria-label":t(`shortcuts.title`),children:R(`div`,{className:`modal-panel shortcuts-dialog`,onClick:e=>e.stopPropagation(),children:[R(`div`,{className:`modal-header`,children:[I(`h3`,{children:t(`shortcuts.title`)}),I(`button`,{type:`button`,className:`btn-icon`,onClick:e,"aria-label":t(`shortcuts.close`),children:I(bc,{size:18,"aria-hidden":`true`})})]}),I(`dl`,{className:`modal-body shortcuts-list`,children:_X().map(({label:e,keys:n})=>R(`div`,{className:`shortcuts-row`,children:[I(`dt`,{children:t(e)}),I(`dd`,{children:I(`kbd`,{dir:`ltr`,children:Gu(n)})})]},e))})]})})}function yX(e){let t=e?.reason;return t===`needs_key`||t===`bad_key`}function bX({provider:e,limit:t,picked:n=null,onPick:r,pickDisabled:i=!1,onDefault:a}){let o=L(),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(null),d=(0,V.useRef)(a);if(d.current=a,(0,V.useEffect)(()=>{let t=!0;return c(null),u(null),d.current?.(null),oe(e).then(e=>{t&&(c(e),d.current?.(e.models[0]?.model??null))}).catch(e=>{t&&u(e instanceof Error?e.message:String(e))}),()=>{t=!1}},[e]),l)return I(`p`,{className:`settings-error`,role:`alert`,children:o(`settings.price.loadFailed`,{reason:l})});if(!s)return R(`p`,{className:`settings-hint`,children:[I(B,{size:13,className:`spin`}),` `,o(`settings.price.loading`)]});if(s.models.length===0)return R(`p`,{className:`settings-hint cloud-prices-note`,children:[o(`settings.price.unknownSentence`),` `,I(`bdi`,{children:s.note})]});let f=t?s.models.slice(0,t):s.models,p=n?s.models.find(e=>e.model===n&&!f.includes(e)):void 0,m=p?[...f,p]:f,h=n??m[0]?.model,g=r!==void 0;return R(`div`,{className:`cloud-prices`,"aria-label":o(`settings.model.prices`),children:[g&&I(`p`,{className:`cloud-prices-legend`,id:`cloud-prices-legend`,children:o(`settings.price.pickLegend`)}),I(`ul`,{className:`cloud-prices-list${g?` is-pickable`:``}`,role:g?`radiogroup`:void 0,"aria-labelledby":g?`cloud-prices-legend`:void 0,children:m.map((t,n)=>{let a=R(`span`,{className:`cloud-prices-name`,children:[I(`bdi`,{children:t.name}),n===0&&g&&R(`span`,{className:`cloud-prices-default`,children:[` · `,o(`settings.price.default`)]}),t.note&&R(`span`,{className:`cloud-prices-note`,children:[` · `,I(`bdi`,{children:t.note})]})]});return R(`li`,{className:g&&h===t.model?`is-chosen`:void 0,children:[g?R(`label`,{className:`cloud-prices-pick`,children:[I(`input`,{type:`radio`,name:`cloud-model-${e}`,value:t.model,checked:h===t.model,disabled:i,onChange:()=>r(t.model)}),a]}):a,I(`span`,{className:`cloud-prices-price`,children:VH(t.price,o)})]},t.model)})}),R(`span`,{className:`settings-hint`,children:[I(`bdi`,{children:s.source}),`. `,o(`settings.price.payProvider`)]})]})}function xX(){return Yd($W)}function SX(e,t=150){let n=xX(),[r,i]=(0,V.useState)(e),a=(0,V.useRef)(e);return(0,V.useEffect)(()=>{if(n||typeof requestAnimationFrame!=`function`){a.current=e,i(e);return}let r=a.current,o=performance.now(),s=0,c=n=>{let l=Math.min(1,(n-o)/t),u=1-(1-l)**3,d=r+(e-r)*u;a.current=d,i(d),l<1&&(s=requestAnimationFrame(c))};return s=requestAnimationFrame(c),()=>cancelAnimationFrame(s)},[e,t,n]),r}function CX(e,t){let[n,r]=(0,V.useState)(e);return(0,V.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}function wX(){let[e,t]=(0,V.useState)(()=>typeof document>`u`||document.visibilityState!==`hidden`);return(0,V.useEffect)(()=>{let e=()=>t(document.visibilityState!==`hidden`);return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),e}var TX=180;function EX({open:e,children:t}){let[n,r]=(0,V.useState)(e),[i,a]=(0,V.useState)(e),o=(0,V.useRef)(t);return e&&(o.current=t),(0,V.useEffect)(()=>{if(e){r(!0);let e=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(e)}a(!1);let t=setTimeout(()=>r(!1),TX);return()=>clearTimeout(t)},[e]),n?I(`div`,{className:`reveal${i?` is-open`:``}`,"aria-hidden":!e||void 0,children:I(`div`,{className:`reveal-inner`,children:e?t:o.current})}):null}var DX=e=>e?.catalog??[],OX=e=>e.roles.includes(`vision`),kX=e=>e.roles.includes(`embedding`),AX=e=>e.recipe===`flm`,jX=e=>!!e&&AX(e)&&!e.reads_images,MX=e=>e.fits===!1&&(e.fit_code===`npu`||e.fit_code===`backend`),NX=e=>e.support===null,PX=e=>e?.feature_tier!==`compact`;function FX(e,t){let n=e.find(e=>e.id===t.defaultChat);return jX(n)||t.vision===`none`?null:n&&AX(n)?n.id:t.vision?t.vision:n?.reads_images?n.id:e.find(e=>OX(e)&&e.gaia_model)?.id??null}function IX(e,t){let n=FX(t,e),r=new Set(e.ticked),i=new Set(e.unticked);for(let a of t)OX(a)&&a.id!==e.defaultChat&&(a.id===n?(r.add(a.id),i.delete(a.id)):a.downloaded||(r.delete(a.id),i.add(a.id)));return{...e,ticked:r,unticked:i}}function LX(e,t,n){let r=new Set(e.ticked),i=t.find(t=>t.id===e.defaultChat);i&&!i.downloaded&&r.delete(i.id);let a=t.find(e=>e.id===n);if(a?.downloaded||r.add(n),!PX(a))for(let e of t)e.roles.includes(`image_creation`)&&r.delete(e.id);return IX({...e,ticked:r,defaultChat:n,chatChosen:!0,vision:null},t)}function RX(e,t,n){return IX({...e,vision:n},t)}function zX(e,t){if(t.vision===`none`)return null;let n=FX(e,t),r=e.find(e=>e.id===t.defaultChat);return r&&AX(r)||n===(r?.reads_images?r.id:e.find(e=>OX(e)&&e.gaia_model)?.id)?null:n}function BX(e){return e.filter(e=>e.gaia_model&&(e.planned||e.recommended||e.downloaded||e.partial))}function VX(e){let t=new Set(BX(e).map(e=>e.id));return e.filter(e=>e.gaia_model&&!t.has(e.id))}function HX(e){return e.filter(e=>!e.gaia_model&&e.downloaded)}function UX(e){let t=DX(e),n=new Set(t.filter(e=>e.selected||e.gaia_model&&e.downloaded&&!e.skipped).map(e=>e.id)),r=!t.find(t=>t.id===e.chat_model.id)?.reads_images&&t.some(e=>OX(e)&&e.gaia_model&&e.skipped);return IX({ticked:n,defaultChat:e.chat_model.id,unticked:new Set,chatChosen:e.chat_model.user_set,vision:e.vision_model??(r?`none`:null)},t)}function WX(e,t){return e.filter(e=>e.chat_choice&&(t.has(e.id)||e.downloaded))}function GX(e,t,n,r){let i=new Set(e.ticked),a=new Set(e.unticked);r?(i.add(n),a.delete(n)):(i.delete(n),a.add(n));let o=WX(t,i),s=e.defaultChat;if(!s||!o.some(e=>e.id===s)){let e=t.find(e=>e.id===n);s=r&&e?.chat_choice?n:(o.find(e=>e.recommended)??o[0])?.id??null}return{...e,ticked:i,defaultChat:s,unticked:a}}function KX(e,t,n){let r=t.find(e=>e.id===n)?.downloaded;return{...e,defaultChat:n,chatChosen:!0,ticked:r?e.ticked:new Set([...e.ticked,n])}}function qX(e){let t=DX(e),n=new Set(t.filter(e=>e.recommended||e.gaia_model&&e.downloaded).map(e=>e.id)),r=WX(t,n);return IX({ticked:n,defaultChat:e.recommended_model&&r.some(t=>t.id===e.recommended_model)?e.recommended_model:(r.find(e=>e.recommended)??r[0])?.id??null,unticked:new Set,chatChosen:!1,vision:null},t)}function JX(e,t){return e.filter(e=>t.ticked.has(e.id)&&!e.downloaded).sort((e,t)=>(t.size_gb??0)-(e.size_gb??0))}function YX(e,t){let n=JX(DX(e),t).map(e=>e.size_gb),r=n.every(e=>e!=null)?nZ(n.reduce((e,t)=>e+t,0)):null,i=e.disk?.free_gb??null;return{downloadGb:r,freeGb:i,afterGb:r!=null&&i!=null?nZ(i-r):null}}function XX(e,t){let{downloadGb:n,freeGb:r}=YX(e,t);return n==null||r==null||n<=r?null:{needGb:n,freeGb:r,freeUpGb:nZ(n-r),drop:JX(DX(e),t).find(e=>e.size_gb!=null&&n-e.size_gb<=r)??null}}function ZX(e,t){return e.filter(e=>e.fits===!1&&(t.ticked.has(e.id)||e.id===t.defaultChat)||e.fits===!0&&!!e.tight&&e.id===t.defaultChat)}function QX(e){return e.length>0&&e.every(e=>e.fits===!0&&!!e.tight)}function $X(e,t){let n=[];for(let r of DX(e)){if(!r.planned){r.skipped&&t.ticked.has(r.id)&&n.push({id:r.id,skipped:!1});continue}if(r.id===e.chat_model.id){r.skipped&&n.push({id:r.id,skipped:!1});continue}let i=t.ticked.has(r.id);!i&&!r.skipped&&n.push({id:r.id,skipped:!0}),i&&r.skipped&&n.push({id:r.id,skipped:!1})}return n}function eZ(e,t){return DX(e).filter(e=>t.ticked.has(e.id)&&!e.planned&&!e.downloaded).map(e=>e.id)}function tZ(e,t){let n=(e.models??[]).filter(e=>e.state!==`skipped`);if(n.length===0)return e.overall;let r=0,i=0;for(let e of n){let n=t?.catalog?.find(t=>t.id===e.id),a=e.bytes_total||(n?.full_size_gb??0)*1e9;i+=a,r+=e.state===`ready`||e.state===`verifying`||e.state===`unchecked`?a:Math.min(a,e.bytes_done)}return{bytes_done:r,bytes_total:i,speed_bps:e.overall?.speed_bps??0,eta_s:null,percent:i>0?Math.floor(r*100/i):100,failed:n.filter(e=>e.state===`failed`).length}}function nZ(e){return Math.round(e*10)/10}var rZ=6;function iZ(e,t){let n=[];return e.chat_choice&&!kX(e)&&n.push(t(`setup.models.purpose.chat`)),OX(e)&&n.push(t(`setup.models.purpose.vision`)),kX(e)&&n.push(t(`setup.models.purpose.documents`)),e.roles.includes(`speech`)&&n.push(t(`setup.models.purpose.speech`)),e.roles.includes(`voice`)&&n.push(t(`setup.models.purpose.voice`)),e.roles.includes(`image_creation`)&&n.push(t(`setup.models.purpose.imageCreation`)),n}function aZ(e,t){return kX(e)?t(`setup.models.line.documents`):OX(e)?t(`setup.models.line.vision`):e.roles.includes(`speech`)?t(`setup.models.line.speech`):e.roles.includes(`voice`)?t(`setup.models.line.voice`):e.roles.includes(`image_creation`)?t(`setup.models.line.imageCreation`):t(`setup.models.line.chat`)}function oZ(e,t){return e.downloaded?t(`setup.models.status.onPc`):e.size_gb==null?t(`setup.models.status.sizeUnknown`):e.partial?t(`setup.models.status.partial`,{size:GA(e.size_gb)}):t(`setup.models.status.download`,{size:GA(e.size_gb)})}function sZ(e,t){return e.fits!==!0||e.need_gb==null||e.capacity_gb==null?null:t(`setup.models.fit.ok`,{need:YA(e.need_gb),have:YA(e.capacity_gb)})}function cZ(e,t){return e.fits===!0&&e.tight?t(`setup.models.warn.tight`):e.fit_code===`npu`?t(`setup.models.warn.npu`):e.fit_code===`backend`?t(`setup.models.warn.backend`):e.need_gb!=null&&e.capacity_gb!=null?t(`setup.models.warn.tooBig`,{need:YA(e.need_gb),have:YA(e.capacity_gb)}):t(`setup.models.warn.tooBigNoNumbers`)}function lZ(e,t,n,r){return!OX(e)&&!kX(e)||OX(e)&&!e.downloaded&&r?null:n===`settings`?e.downloaded?t(`settings.models.warn.kept`,{name:e.name}):t(OX(e)?`settings.models.warn.vision`:`settings.models.warn.documents`,{name:e.name}):t(OX(e)?`setup.models.warn.vision`:`setup.models.warn.documents`,{name:e.name})}function uZ({entry:e,ticked:t,onToggle:n,disabled:r,progress:i,actions:a,place:o,imagesCovered:s}){let c=L(),l=(0,V.useId)(),u=e.fits===!1,d=t?null:lZ(e,c,o,s),f=i?.state===`downloading`&&i.bytes_total>0,p=e.fits===!0&&!!e.tight,m=u?cZ(e,c):d??(p?c(`setup.models.warn.tight`):null),h=[`${l}-status`,`${l}-note`,m?`${l}-warn`:null].filter(Boolean).join(` `);return R(`li`,{className:`mc-row${t?` is-ticked`:``}${m?` has-warning`:``}`,children:[R(`div`,{className:`mc-row-top`,children:[R(`label`,{className:`mc-row-main`,children:[I(`input`,{type:`checkbox`,className:`mc-input`,checked:t,disabled:r,onChange:e=>n(e.target.checked),"aria-describedby":h}),I(`span`,{className:`mc-box`,"aria-hidden":`true`,children:I(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,children:I(`path`,{className:`mc-tick`,d:`M3.5 8.5l3 3 6-7`})})}),R(`span`,{className:`mc-text`,children:[R(`span`,{className:`mc-name-line`,children:[I(`bdi`,{className:`mc-name`,title:e.id,children:e.name}),R(`span`,{className:`mc-chips`,children:[iZ(e,c).map(e=>I(`span`,{className:`mc-chip`,children:e},e)),AX(e)&&I(`span`,{className:`mc-chip is-npu`,children:c(`setup.models.npu`)})]})]}),R(`span`,{className:`mc-status`,id:`${l}-status`,children:[f?c(`setup.models.status.downloading`,{done:XA(i.bytes_done),total:XA(i.bytes_total)}):oZ(e,c),e.recommended&&I(`span`,{className:`mc-pill`,children:c(`setup.models.recommended`)}),e.fits===null&&R(`span`,{className:`mc-chip is-unknown`,children:[I(Ei,{size:11,"aria-hidden":`true`}),` `,c(`setup.models.fitUnknown`)]})]}),I(`span`,{className:`mc-note`,id:`${l}-note`,children:c.compose(t=>[aZ(e,t),sZ(e,t),e.fits===null?t(e.capacity_gb!=null&&e.need_gb==null?`setup.models.fit.unknownNeed`:`setup.models.fit.unknown`):null].filter(Boolean).join(` `))})]})]}),a&&I(`span`,{className:`mc-actions`,children:a})]}),f&&I(`progress`,{className:`mc-mini-progress`,max:i.bytes_total,value:i.bytes_done,"aria-label":c(`setup.progress.rowLabel`,{name:e.name,state:c(`setup.state.downloading`)})}),I(EX,{open:!!m,children:R(`p`,{className:`mc-warn${u?` is-big`:``}`,role:`note`,id:`${l}-warn`,children:[I(cc,{size:13,"aria-hidden":`true`}),I(`span`,{children:m})]})})]})}function dZ({plan:e,selection:t}){let n=L(),{downloadGb:r,freeGb:i,afterGb:a}=YX(e,t),o=XX(e,t),s=SX(r??0),c=SX(a??0),l=fZ(e.disk?.path??null),u=r!=null&&i?Math.min(1,r/i):0,d=CX(r==null?n(`setup.summary.spokenUnknown`):a==null?n(`setup.summary.spokenNoDisk`,{download:GA(r)}):n(`setup.summary.spoken`,{download:GA(r),after:GA(Math.max(0,a))}),600);return R(`div`,{className:`mc-summary${o?` is-warn`:``}`,role:`group`,"aria-label":n(`setup.summary.label`),children:[R(`div`,{className:`mc-summary-stats`,children:[R(`span`,{className:`mc-stat`,children:[I(`span`,{className:`mc-stat-label`,children:n(`setup.summary.download`)}),I(`bdi`,{className:`mc-stat-value`,children:r==null?n(`setup.summary.sizeUnknown`):GA(pZ(s))})]}),R(`span`,{className:`mc-stat`,children:[R(`span`,{className:`mc-stat-label`,children:[I(Wa,{size:12,"aria-hidden":`true`}),` `,l?R(F.Fragment,{children:[n(`setup.summary.freeOn`),` `,I(`bdi`,{dir:`ltr`,className:`mc-stat-path`,children:l})]}):n(`setup.summary.free`)]}),I(`bdi`,{className:`mc-stat-value`,children:i==null?n(`setup.summary.freeUnknown`):GA(i)})]}),a!=null&&!o&&R(`span`,{className:`mc-stat`,children:[I(`span`,{className:`mc-stat-label`,children:n(`setup.summary.after`)}),I(`bdi`,{className:`mc-stat-value`,children:GA(Math.max(0,pZ(c)))})]})]}),i!=null&&I(`div`,{className:`mc-disk`,"aria-hidden":`true`,children:I(`span`,{className:`mc-disk-fill`,style:{inlineSize:`${(u*100).toFixed(1)}%`}})}),I(EX,{open:!!o,children:o&&R(`p`,{className:`mc-disk-warn`,role:`note`,children:[I(cc,{size:13,"aria-hidden":`true`}),I(`span`,{children:o.drop?n(`setup.summary.shortDrop`,{need:GA(o.needGb),free:GA(o.freeGb),drive:l??n(`setup.summary.theDrive`),freeUp:GA(o.freeUpGb),name:o.drop.name,saves:GA(o.drop.size_gb??0)}):n(`setup.summary.short`,{need:GA(o.needGb),free:GA(o.freeGb),drive:l??n(`setup.summary.theDrive`),freeUp:GA(o.freeUpGb)})})]})}),I(`span`,{className:`visually-hidden`,"aria-live":`polite`,children:d})]})}function fZ(e){if(!e)return null;let t=/^([A-Za-z]:)[\\/]/.exec(e);return t?t[1]:e}function pZ(e){return Math.round(e*10)/10}function mZ({plan:e,selection:t,onToggle:n,onDefaultChat:r,labelledBy:i,cloud:a,disabled:o,progress:s,rowActions:c,place:l=`setup`}){let u=L(),d=DX(e),[f,p]=(0,V.useState)(``),m=(0,V.useId)(),h=a?d.filter(kX):BX(d),g=a?[]:VX(d),_=a?[]:HX(d),v=(0,V.useMemo)(()=>{let e=f.trim().toLowerCase();return e?_.filter(t=>t.id.toLowerCase().includes(e)||t.name.toLowerCase().includes(e)):_},[_,f]),y=WX(d,t.ticked),b=e=>I(uZ,{entry:e,ticked:t.ticked.has(e.id),onToggle:t=>n(e.id,t),disabled:o,progress:s?.[e.id],actions:c?.(e),place:l,imagesCovered:d.some(n=>n.id!==e.id&&OX(n)&&(t.ticked.has(n.id)||n.downloaded===!0))},e.id);return R(`div`,{className:`mc`,children:[I(`ul`,{className:`mc-list`,role:`group`,"aria-labelledby":i,children:h.map(b)}),a?I(`p`,{className:`setup-hint`,children:u(`setup.models.cloudNote`)}):I(`p`,{className:`mc-foot`,children:u(`setup.models.neverDeletes`)}),g.length>0&&R(`details`,{className:`mc-more`,children:[I(`summary`,{children:u(`setup.models.more`,{n:String(g.length)})}),I(`ul`,{className:`mc-list`,role:`group`,"aria-label":u(`setup.models.moreLabel`),children:g.map(b)})]}),_.length>0&&R(`details`,{className:`mc-more`,children:[I(`summary`,{children:u(`setup.models.installed`,{n:String(_.length)})}),_.length>rZ&&I(`input`,{className:`settings-input mc-search`,type:`search`,value:f,onChange:e=>p(e.target.value),placeholder:u(`setup.models.search`),"aria-label":u(`setup.models.search`)}),I(`ul`,{className:`mc-list`,role:`radiogroup`,"aria-label":u(`setup.models.installedLabel`),children:v.map(e=>I(`li`,{className:`mc-row is-installed${t.defaultChat===e.id?` is-ticked`:``}`,children:R(`label`,{className:`mc-row-main`,children:[I(`input`,{type:`radio`,name:`${m}-installed`,className:`mc-radio`,checked:t.defaultChat===e.id,disabled:o,onChange:()=>r(e.id)}),R(`span`,{className:`mc-text`,children:[R(`span`,{className:`mc-name-line`,children:[I(`bdi`,{className:`mc-name`,title:e.id,children:e.name}),R(`span`,{className:`mc-chips`,children:[I(`span`,{className:`mc-chip`,children:u(`setup.models.purpose.chat`)}),AX(e)&&I(`span`,{className:`mc-chip is-npu`,children:u(`setup.models.npu`)})]})]}),R(`span`,{className:`mc-status`,children:[u(`setup.models.status.onPc`),` · `,u(`setup.models.useAsDefault`)]})]})]})},e.id))})]}),!a&&R(`div`,{className:`mc-default`,children:[I(`label`,{htmlFor:m,className:`mc-default-label`,children:u(`setup.models.defaultChat`)}),R(`select`,{id:m,className:`settings-input mc-select`,value:t.defaultChat??``,disabled:o||y.length===0,onChange:e=>r(e.target.value),children:[y.length===0&&I(`option`,{value:``,children:u.bare(`setup.models.noChat`)}),y.map(e=>R(`option`,{value:e.id,children:[e.name,AX(e)?` (${u(`setup.models.npu`)})`:``]},e.id))]})]})]})}function hZ(){let e=L();return R(`div`,{className:`mc`,"aria-busy":`true`,children:[R(`p`,{className:`setup-hint`,role:`status`,children:[I(B,{size:13,className:`spin`,"aria-hidden":`true`}),` `,e(`setup.models.loading`)]}),I(`ul`,{className:`mc-list`,"aria-hidden":`true`,children:[0,1,2].map(e=>I(`li`,{className:`mc-row is-skeleton`,children:I(`span`,{className:`mc-skeleton`})},e))})]})}function gZ({entry:e}){let t=L();return e.support===`verified`?I(`span`,{className:`mc-chip is-verified`,children:t(`setup.label.verified`)}):e.support===`untested`?I(`span`,{className:`mc-chip is-untested`,children:t(`setup.label.untested`)}):null}function _Z({name:e,entry:t,checked:n,recommended:r,disabled:i,onPick:a,children:o}){let s=L();return I(`li`,{className:`mc-row${n?` is-ticked`:``}`,children:R(`label`,{className:`mc-row-main`,children:[I(`input`,{type:`radio`,className:`mc-radio`,name:e,checked:n,disabled:i||MX(t),onChange:a}),R(`span`,{className:`mc-text`,children:[R(`span`,{className:`mc-name-line`,children:[I(`span`,{className:`mc-name`,title:t.id,children:I(`bdi`,{children:t.name})}),R(`span`,{className:`mc-chips`,children:[r&&I(`span`,{className:`mc-pill`,children:s(`setup.models.recommended`)}),I(gZ,{entry:t}),AX(t)&&I(`bdi`,{className:`mc-chip is-npu`,children:s(`setup.models.npu`)})]})]}),I(`span`,{className:`mc-status`,children:oZ(t,s)}),t.fits===!1&&R(`span`,{className:`mc-warn is-big`,role:`note`,children:[I(cc,{size:13,"aria-hidden":`true`}),` `,cZ(t,s)]}),t.fits===!0&&t.tight&&R(`span`,{className:`mc-warn`,role:`note`,children:[I(cc,{size:13,"aria-hidden":`true`}),` `,s(`setup.models.warn.tight`)]}),o]})]})})}function vZ({label:e,note:t,size:n,checked:r,disabled:i,warning:a,chips:o,onChange:s}){return I(`li`,{className:`mc-row${r?` is-ticked`:``}${i?` is-off`:``}`,children:R(`label`,{className:`mc-row-main`,children:[I(`input`,{type:`checkbox`,className:`mc-input`,checked:r,disabled:i,onChange:e=>s(e.target.checked)}),I(`span`,{className:`mc-box`,"aria-hidden":`true`,children:I(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,children:I(`path`,{className:`mc-tick`,d:`M3.5 8.5l3 3 6-7`})})}),R(`span`,{className:`mc-text`,children:[R(`span`,{className:`mc-name-line`,children:[I(`span`,{className:`mc-name`,children:I(`bdi`,{children:e})}),I(`span`,{className:`mc-chips`,children:o})]}),I(`span`,{className:`mc-status`,children:I(`bdi`,{dir:`ltr`,children:n})}),I(`span`,{className:`mc-note`,children:t}),a&&R(`span`,{className:`mc-warn`,role:`note`,children:[I(cc,{size:13,"aria-hidden":`true`}),` `,a]})]})]})})}function yZ({plan:e,selection:t,onSelection:n,disabled:r}){let i=L(),a=(0,V.useId)(),o=DX(e),[s,c]=(0,V.useState)(!1),l=o.find(e=>e.id===t.defaultChat),u=!!l&&AX(l),d=o.filter(e=>e.chat_choice&&!kX(e)&&(e.gaia_model||e.downloaded)&&AX(e)===u&&(e.setup_offer||e.id===t.defaultChat)),f=d.filter(e=>e.support===`verified`),p=d.filter(e=>e.support!==`verified`),m=FX(o,t),h=!!l?.reads_images,g=o.filter(e=>OX(e)&&e.id!==l?.id),_=o.find(kX),v=e=>o.find(t=>NX(t)&&t.roles.includes(e)),y=e=>e.downloaded?i(`setup.models.status.onPc`):e.size_gb==null?i(`setup.contents.sizeOnDownload`):GA(e.size_gb),b=(e,r)=>n(GX(t,o,e,r)),x=e=>n(LX(t,o,e)),S=e=>n(RX(t,o,e)),C=v(`speech`),w=v(`voice`),T=v(`image_creation`),E=PX(l),ee=l?.support===`untested`,[D,O]=(0,V.useState)(ee);return(0,V.useEffect)(()=>{ee&&O(!0)},[ee]),R(`div`,{className:`mc`,children:[R(`section`,{className:`mc-job`,"aria-labelledby":`${a}-chat`,children:[I(`h3`,{className:`mc-job-title`,id:`${a}-chat`,children:i(`setup.job.chat`)}),I(`p`,{className:`setup-hint`,children:i(`setup.job.verifiedNote`)}),I(`ul`,{className:`mc-list`,role:`radiogroup`,"aria-labelledby":`${a}-chat`,children:f.map(n=>I(_Z,{name:`${a}-chat-model`,entry:n,checked:n.id===t.defaultChat,recommended:n.id===e.recommended_model,disabled:r,onPick:()=>x(n.id)},n.id))}),p.length>0&&R(`details`,{className:`mc-more`,open:D,onToggle:e=>O(e.currentTarget.open),children:[I(`summary`,{children:i(`setup.job.showUntested`,{n:String(p.length)})}),I(`p`,{className:`setup-hint`,children:i(`setup.job.untestedNote`)}),I(`ul`,{className:`mc-list`,role:`radiogroup`,"aria-label":i(`setup.job.untestedLabel`),children:p.map(e=>I(_Z,{name:`${a}-chat-model`,entry:e,checked:e.id===t.defaultChat,recommended:!1,disabled:r,onPick:()=>x(e.id)},e.id))})]}),ee&&R(`p`,{className:`mc-warn`,role:`note`,children:[I(cc,{size:13,"aria-hidden":`true`}),` `,i(`setup.job.untestedPicked`)]})]}),R(`section`,{className:`mc-job`,"aria-labelledby":`${a}-vision`,children:[I(`h3`,{className:`mc-job-title`,id:`${a}-vision`,children:i(`setup.job.vision`)}),jX(l)?I(`p`,{className:`setup-hint`,role:`note`,children:i(`setup.job.visionOffNpu`,{name:l?.name??``})}):h?R(`div`,{className:`setup-card`,children:[R(`p`,{className:`mc-job-line`,children:[I(`bdi`,{children:i(`setup.job.visionBuiltIn`,{name:l?.name??``})}),I(`span`,{className:`setup-ok`,children:i(`setup.job.nothingMore`)})]}),!u&&I(`button`,{type:`button`,className:`link-btn`,"aria-expanded":s,onClick:()=>c(e=>!e),children:i(s?`setup.job.hideVision`:`setup.job.otherVision`)})]}):I(`p`,{className:`setup-hint`,children:i(`setup.job.visionNeeded`,{name:l?.name??``})}),!u&&(!h||s)&&R(`ul`,{className:`mc-list`,role:`radiogroup`,"aria-labelledby":`${a}-vision`,children:[g.map(e=>I(_Z,{name:`${a}-vision-model`,entry:e,checked:m===e.id,recommended:!h&&e.gaia_model&&e.support===`verified`,disabled:r,onPick:()=>S(e.id)},e.id)),I(`li`,{className:`mc-row${m===null?` is-ticked`:``}`,children:R(`label`,{className:`mc-row-main`,children:[I(`input`,{type:`radio`,className:`mc-radio`,name:`${a}-vision-model`,checked:h?m===l?.id:m===null,disabled:r,onChange:()=>S(h?null:`none`)}),R(`span`,{className:`mc-text`,children:[I(`span`,{className:`mc-name`,children:i(h?`setup.job.useChatForVision`:`setup.job.skipVision`)}),m===null&&!h&&R(`span`,{className:`mc-warn`,role:`note`,children:[I(cc,{size:13,"aria-hidden":`true`}),` `,i(`setup.job.skipVisionNote`)]})]})]})})]})]}),_&&R(`section`,{className:`mc-job`,"aria-labelledby":`${a}-docs`,children:[I(`h3`,{className:`mc-job-title`,id:`${a}-docs`,children:i(`setup.job.documents`)}),I(`ul`,{className:`mc-list`,children:I(vZ,{label:_.name,note:i(`setup.models.line.documents`),size:y(_),checked:t.ticked.has(_.id),disabled:r,warning:t.ticked.has(_.id)?null:i(`setup.job.documentsOff`),chips:R(F.Fragment,{children:[I(`span`,{className:`mc-pill`,children:i(`setup.models.recommended`)}),I(gZ,{entry:_})]}),onChange:e=>b(_.id,e)})})]}),R(`section`,{className:`mc-job`,"aria-labelledby":`${a}-extras`,children:[I(`h3`,{className:`mc-job-title`,id:`${a}-extras`,children:i(`setup.job.extras`)}),I(`p`,{className:`setup-hint`,children:i(`setup.job.extrasNote`)}),R(`ul`,{className:`mc-list`,children:[C&&I(vZ,{label:i(`setup.job.speech`),note:i(`setup.job.speechNote`),size:y(C),checked:t.ticked.has(C.id),disabled:r,onChange:e=>b(C.id,e)}),w&&I(vZ,{label:i(`setup.job.voice`),note:i(`setup.job.voiceNote`),size:y(w),checked:t.ticked.has(w.id),disabled:r,onChange:e=>b(w.id,e)}),T&&I(vZ,{label:i(`setup.job.images`),note:i(`setup.job.imagesNote`),size:y(T),checked:t.ticked.has(T.id),disabled:r||!E,warning:E?null:i(`setup.job.imagesBlocked`,{name:l?.name??``}),onChange:e=>b(T.id,e)})]})]}),I(bZ,{plan:e,selection:t})]})}function bZ({plan:e,selection:t}){let n=L(),r=DX(e),i=e=>r.find(t=>t.id===e)?.name??e??n(`setup.get.off`),a=e=>r.find(n=>NX(n)&&n.roles.includes(e)&&t.ticked.has(n.id)),o=r.find(e=>kX(e)&&t.ticked.has(e.id)),s=r.find(e=>e.id===t.defaultChat),c=FX(r,t),l=[a(`speech`)&&n(`setup.job.speech`),a(`voice`)&&n(`setup.job.voice`)].filter(Boolean).join(`, `);return R(`section`,{className:`setup-card`,"aria-label":n(`setup.get.title`),children:[I(`h3`,{className:`mc-job-title`,children:n(`setup.get.title`)}),R(`dl`,{className:`setup-summary-list`,children:[R(`div`,{children:[I(`dt`,{children:n(`setup.job.chat`)}),I(`dd`,{children:I(`bdi`,{children:i(t.defaultChat)})})]}),R(`div`,{children:[I(`dt`,{children:n(`setup.job.vision`)}),I(`dd`,{children:I(`bdi`,{children:jX(s)?n(`setup.get.offNpu`):c?i(c):n(`setup.get.off`)})})]}),R(`div`,{children:[I(`dt`,{children:n(`setup.job.documents`)}),I(`dd`,{children:I(`bdi`,{children:o?o.name:n(`setup.get.off`)})})]}),R(`div`,{children:[I(`dt`,{children:n(`setup.get.voice`)}),I(`dd`,{children:l||n(`setup.get.off`)})]}),R(`div`,{children:[I(`dt`,{children:n(`setup.job.images`)}),I(`dd`,{children:PX(s)?a(`image_creation`)?n(`setup.get.on`):n(`setup.get.off`):n(`setup.get.notAvailable`)})]})]})]})}var xZ=(0,V.createContext)(void 0),SZ=xZ.Provider;function CZ({children:e}){let t=(0,V.useContext)(xZ);return t===void 0?I(`div`,{className:`setup-row setup-nav`,children:e}):t===null?null:(0,by.createPortal)(I(`div`,{className:`setup-footer-row`,children:e}),t)}function wZ({title:e,children:t,confirmLabel:n,cancelLabel:r,onConfirm:i,onCancel:a,danger:o,busy:s}){let c=(0,V.useRef)(null),l=(0,V.useRef)(null),u=(0,V.useId)(),d=(0,V.useId)();return yn(c,!0),(0,V.useEffect)(()=>{let e=document.activeElement;return l.current?.focus(),()=>e?.focus?.()},[]),er(!0,a,!s),(0,by.createPortal)(I(`div`,{className:`confirm-overlay`,children:R(`div`,{ref:c,className:`confirm-sheet`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":u,"aria-describedby":t?d:void 0,children:[I(`h2`,{id:u,className:`confirm-title`,children:e}),t&&I(`div`,{id:d,className:`confirm-body`,children:t}),R(`div`,{className:`confirm-actions`,children:[I(`button`,{ref:l,type:`button`,className:`btn-secondary`,onClick:a,disabled:s,children:r}),I(`button`,{type:`button`,className:o?`btn-danger`:`btn-primary`,onClick:i,disabled:s,children:n})]})]})}),document.body)}function TZ(e){return e===`windows`?`Windows`:e===`linux`?`Linux`:e}function EZ(e){let t=/^Run:\s*(.+)$/.exec(e)??/^(sudo .+)$/.exec(e);return t?t[1].trim():null}function DZ(e,t){return e.setting&&Math.abs(e.setting.current_gb-t)<.05&&e.gpu_gb!=null?e.gpu_gb:e.presets?.find(e=>Math.abs(e.setting_gb-t)<.05)?.gpu_gb??null}function OZ(e,t,n=!1){return t==null?e(n?`gpu.appliedAny`:`gpu.pending.restartAny`):e(n?`gpu.applied`:`gpu.pending.restart`,{gb:GA(t)})}function kZ(e){e.focus({preventScroll:!0});for(let t=e.parentElement;t;t=t.parentElement){let n=getComputedStyle(t).overflowY;if(n!==`auto`&&n!==`scroll`)continue;let r=e.getBoundingClientRect().top-t.getBoundingClientRect().top;(r<0||r>t.clientHeight-40)&&(t.scrollTop+=r-16);return}}function AZ(e){return e instanceof Error?e.message:String(e)}function jZ({status:e,targetGpuGb:t}){let n=L(),r=e=>Math.round(e*10),i=r(e.total_gb??0),a=r(e.gpu_gb??0),o=t!=null&&r(t)>a?r(t):null,s=o==null?0:o-a,c=Math.max(0,i-a-s),l=e=>GA(e/10),u=e=>i>0?Math.min(100,e/i*100):0,d=e.pending?.state===`took_effect`;return R(`div`,{className:`gpu-split`,children:[R(`div`,{className:`gpu-bar${d?` is-new`:``}`,role:`img`,"aria-label":o==null?n(`gpu.split.aria`,{cpu:l(c),gpu:l(a)}):n(`gpu.split.ariaTarget`,{cpu:l(c),gpu:l(o),now:l(a)}),children:[I(`span`,{className:`gpu-seg is-gpu`,style:{inlineSize:`${u(a)}%`}}),I(`span`,{className:`gpu-seg is-target`,style:{inlineSize:`${u(s)}%`}}),I(`span`,{className:`gpu-seg is-cpu`}),o!=null&&I(`span`,{className:`gpu-marker`,style:{insetInlineStart:`${u(o)}%`}})]}),R(`div`,{className:`gpu-legend`,"aria-hidden":`true`,children:[I(`span`,{className:`gpu-key is-gpu`,children:I(`bdi`,{children:n(`gpu.split.gpu`,{gb:l(a)})})}),o!=null&&I(`span`,{className:`gpu-key is-target`,children:I(`bdi`,{children:n(`gpu.split.added`,{gb:l(s)})})}),I(`span`,{className:`gpu-key is-cpu`,children:I(`bdi`,{children:n(`gpu.split.cpu`,{gb:l(c)})})})]})]})}function MZ({presets:e,value:t,onChange:n,recommended:r,max:i,keepGb:a,disabled:o}){let s=L();return R(sF,{className:`gpu-presets`,"aria-label":s(`gpu.presets.label`),children:[a!=null&&I(`button`,{type:`button`,role:`radio`,"aria-checked":t===null,className:`gpu-preset${t===null?` is-active`:``}`,disabled:o,onClick:()=>n(null),children:I(`bdi`,{children:s(`gpu.presets.keep`,{gb:GA(a)})})}),e.map(e=>R(`button`,{type:`button`,role:`radio`,"aria-checked":e.setting_gb===t,className:`gpu-preset${e.setting_gb===t?` is-active`:``}`,disabled:o,onClick:()=>n(e.setting_gb),children:[I(`bdi`,{children:s(`gpu.presets.gpu`,{gb:GA(e.gpu_gb)})}),e.setting_gb===r&&R(F.Fragment,{children:[` `,I(`span`,{className:`gpu-tag is-recommended`,children:s(`gpu.presets.recommended`)})]}),e.setting_gb===i&&R(F.Fragment,{children:[` `,I(`span`,{className:`gpu-tag is-max`,children:s(`gpu.presets.max`)})]})]},e.setting_gb))]})}function NZ({status:e,onStatus:t,mode:n,names:r,onSkip:i,onContinue:a,onBack:o,headingId:s,cloud:c=!1}){let l=L(),u=il(e=>!!e.active?.remote)||c,d=(0,V.useCallback)(()=>{let e=s?document.getElementById(s):null;e&&kZ(e)},[s]);(0,V.useEffect)(()=>{n===`setup`&&d()},[n,d]);let f=(0,V.useId)(),p=e.presets??[],m=u?null:e.recommended_setting_gb??null,[h,g]=(0,V.useState)(m??(e.gpu_gb==null?p[0]?.setting_gb??null:null)),[_,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(null),[x,S]=(0,V.useState)(void 0),[C,w]=(0,V.useState)(null),[T,E]=(0,V.useState)(null),[ee,D]=(0,V.useState)(null),[O,te]=(0,V.useState)(null),k=p.find(e=>e.setting_gb===h)??null,A=p.length>0&&p[p.length-1].setting_gb===e.setting?.max_gb?p[p.length-1].setting_gb:null,ne=k&&e.total_gb!=null?Math.max(0,e.total_gb-k.gpu_gb):null,j=m==null&&!u?(e.models??[]).find(e=>e.default&&e.fits_now):void 0,M=(k?.unlocks??[]).slice(0,2).map(e=>r[e]??e),re=e.pending??null,ie=e.method===`apply`,ae=e.guided_value!==null,oe=(0,V.useCallback)(async()=>{v(!0),b(null),E(`steps`),D(null);try{let e=await Nt(h??void 0);S(e.guided_value),b(e.guided_value===null?[]:e.guided_steps??[])}catch(e){S(void 0),b([]),D({kind:`error`,message:AZ(e)})}finally{E(null)}},[h]),se=async()=>{if(h!=null){w(null),E(`apply`),D(null);try{t(await $e(h)),D({kind:`applied`})}catch(e){let t=e instanceof On&&e.httpStatus===403;D(t?{kind:`denied`}:{kind:`error`,message:AZ(e)}),t&&d()}finally{E(null)}}},ce=async()=>{w(null),E(`revert`),D(null);try{t(await un()),D({kind:`applied`})}catch(e){D(e instanceof On&&e.httpStatus===403?{kind:`denied`}:{kind:`error`,message:AZ(e)})}finally{E(null)}},le=async()=>{if(h!=null){E(`done`),D(null);try{t(await Hn(h)),v(!1)}catch(e){D({kind:`error`,message:AZ(e)})}finally{E(null)}}},ue=async()=>{E(`keep`),D(null);try{t(await nt())}catch(e){D({kind:`error`,message:AZ(e)})}finally{E(null)}},de=async e=>{try{await navigator.clipboard.writeText(e),te(e)}catch(e){D({kind:`error`,message:l(`gpu.copyFailed`,{reason:AZ(e)})})}},fe=re?.state===`restart_required`;return R(`div`,{className:`gpu`,children:[I(`p`,{className:`setup-hint`,children:l(`gpu.body`,{total:GA(e.total_gb??0),gpu:GA(e.gpu_gb??0)})}),I(jZ,{status:e,targetGpuGb:!fe&&!_?k?.gpu_gb??null:null}),re?.state===`took_effect`&&R(`div`,{className:`gpu-notice is-ok`,role:`status`,children:[I(ci,{size:14,"aria-hidden":`true`}),I(`span`,{children:l(`gpu.pending.tookEffect`,{gb:GA(e.gpu_gb??0)})}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void ue(),disabled:T!==null,children:l(`gpu.ok`)})]}),fe&&R(`div`,{className:`gpu-notice`,role:`status`,children:[I(Ja,{size:14,"aria-hidden":`true`}),I(`span`,{children:l.compose(t=>[OZ(t,DZ(e,re.setting_gb),ee?.kind===`applied`),t(`gpu.pending.restartHow`),n===`setup`?t(`gpu.pending.downloadsFirst`):null].filter(Boolean).join(` `))}),re.source===`guided`&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void ue(),disabled:T!==null,children:l(`gpu.keep`,{gb:GA(e.gpu_gb??0)})})]}),re?.state===`not_applied`&&R(`div`,{className:`gpu-notice is-warn`,role:`status`,children:[I(cc,{size:14,"aria-hidden":`true`}),I(`span`,{children:l(`gpu.pending.notApplied`,{gb:GA(e.gpu_gb??0)})}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void ue(),disabled:T!==null,children:l(`gpu.keep`,{gb:GA(e.gpu_gb??0)})})]}),!fe&&!_&&p.length>0&&R(F.Fragment,{children:[j&&R(`p`,{className:`gpu-unlock is-keep`,children:[I(ci,{size:13,"aria-hidden":`true`}),` `,l(`gpu.keepRecommended`,{model:r[j.id]??j.id})]}),I(MZ,{presets:p,value:h,onChange:g,recommended:m,max:A,keepGb:e.gpu_gb??null,disabled:T!==null}),k&&I(`p`,{className:`gpu-unlock`,children:M.length>0?l(M.length>1?`gpu.unlock.two`:`gpu.unlock.one`,{gb:GA(k.gpu_gb),a:M[0],b:M[1]??``}):l(`gpu.unlock.none`,{gb:GA(k.gpu_gb)})}),k&&k.setting_gb===A&&ne!=null&&R(`p`,{className:`gpu-unlock is-warn`,role:`note`,children:[I(cc,{size:13,"aria-hidden":`true`}),` `,l(`gpu.maxWarn`,{cpu:GA(ne),os:TZ(e.os)})]}),I(`p`,{className:`setup-hint`,children:l.compose(t=>`${t(`gpu.reserve`,{gb:GA(e.reserve_gb??16),os:TZ(e.os)})} ${t(`gpu.needs`)}`)}),!ie&&e.method_reason&&I(`p`,{className:`setup-hint`,children:I(`bdi`,{dir:`ltr`,children:e.method_reason})})]}),!fe&&!_&&p.length===0&&I(`p`,{className:`setup-hint`,children:l(`gpu.noPresets`)}),_&&R(`div`,{className:`gpu-guided`,children:[k&&I(`p`,{className:`setup-hint`,id:f,children:l(`gpu.guided.lede`,{gb:GA(k.gpu_gb)})}),y===null?R(`p`,{className:`setup-hint`,role:`status`,children:[I(B,{size:13,className:`spin`,"aria-hidden":`true`}),` `,l(`gpu.guided.loading`)]}):x===null?I(`p`,{className:`setup-hint`,children:l(`gpu.noPresets`)}):I(`ol`,{className:`gpu-steps`,"aria-labelledby":f,children:y.map(e=>{let t=EZ(e);return R(`li`,{children:[I(`span`,{children:e}),t&&R(`button`,{type:`button`,className:`btn-secondary gpu-copy`,onClick:()=>void de(t),"aria-label":l(`gpu.copyAria`,{what:t}),children:[I(O===t?ci:Bi,{size:12,"aria-hidden":`true`}),l(O===t?`gpu.copied`:`gpu.copy`)]})]},e)})}),R(CZ,{children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>v(!1),disabled:T!==null,children:l(`gpu.guided.back`)}),!ie&&x!==null&&R(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void le(),disabled:T!==null||h==null,children:[T===`done`&&I(B,{size:13,className:`spin`,"aria-hidden":`true`}),` `,l(`gpu.guided.done`)]})]})]}),T===`apply`||T===`revert`?R(`p`,{className:`setup-hint`,role:`status`,children:[I(B,{size:13,className:`spin`,"aria-hidden":`true`}),` `,l(`gpu.waiting`)]}):null,ee?.kind===`denied`&&R(`div`,{className:`gpu-notice is-warn`,role:`alert`,children:[I(cc,{size:14,"aria-hidden":`true`}),I(`span`,{children:l(`gpu.denied`)})]}),ee?.kind===`error`&&I(`p`,{className:`setup-error`,role:`alert`,children:ee.message}),!_&&(()=>{let t=!fe&&ie&&p.length>0&&I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>w(`apply`),disabled:T!==null||h==null,children:ee?.kind===`denied`||re?.state===`not_applied`?l(`gpu.tryAgain`):l(`gpu.apply`)}),r=!fe&&p.length>0&&ae&&I(`button`,{type:`button`,className:ie?`btn-secondary`:`btn-primary`,onClick:()=>void oe(),disabled:T!==null||h==null,children:l(`gpu.showMe`)});return n===`setup`?R(CZ,{children:[o&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:o,children:l(`setup.back`)}),fe?a&&I(`button`,{type:`button`,className:`btn-primary`,onClick:a,autoFocus:!0,children:l(`setup.continue`)}):h==null&&p.length>0?(i??a)&&I(`button`,{type:`button`,className:`btn-primary`,onClick:i??a,disabled:T!==null,children:l(`gpu.keepAsIs`)}):R(F.Fragment,{children:[i&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:i,disabled:T!==null,children:l(`gpu.skip`)}),ie?R(F.Fragment,{children:[r,t]}):r]})]}):R(`div`,{className:`setup-row gpu-actions`,children:[t,r,e.revert?.available&&R(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>w(`revert`),disabled:T!==null,children:[I(vs,{size:13,"aria-hidden":`true`}),` `,l(`gpu.undo`)]})]})})(),C===`apply`&&h!=null&&R(wZ,{title:k?l(`gpu.consent.title`,{gb:GA(k.gpu_gb)}):l(`gpu.consent.titleAny`),confirmLabel:l(`setup.continue`),cancelLabel:l(`setup.cancel`),onConfirm:()=>void se(),onCancel:()=>w(null),children:[I(`p`,{children:k?l(`gpu.consent.body`,{name:e.setting?.name??``,gb:GA(k.gpu_gb)}):l(`gpu.consent.bodyAny`,{name:e.setting?.name??``})}),I(`p`,{className:`confirm-note`,children:l(`gpu.consent.saved`,{gb:GA(e.gpu_gb??0)})})]}),C===`revert`&&I(wZ,{title:l(`gpu.revert.title`),confirmLabel:l(`setup.continue`),cancelLabel:l(`setup.cancel`),onConfirm:()=>void ce(),onCancel:()=>w(null),children:I(`p`,{children:l(`gpu.revert.body`)})})]})}function PZ({plan:e,planError:t,onRetryPlan:n,onUseRecommended:r,selection:i,onSelection:a,cloud:o,keepTrying:s,onKeepTrying:c,onBack:l,onContinue:u,busy:d,error:f}){let p=L(),m=(0,V.useRef)(null),[h,g]=(0,V.useState)(!1),_=!!e&&!!i&&!!e.catalog,v=(0,V.useRef)(null);if(_&&v.current===null&&(v.current=!o&&JX(DX(e),i).length===0&&!!i.defaultChat&&DX(e).some(e=>e.downloaded)),(0,V.useEffect)(()=>{_&&m.current?.querySelector(`input:not([disabled])`)?.focus()},[_,h]),t&&!_)return R(`div`,{className:`setup-models-error`,children:[I(`p`,{className:`setup-error`,role:`alert`,children:p(`setup.models.listFailed`,{reason:t})}),R(`div`,{className:`setup-row`,children:[I(`button`,{type:`button`,className:`btn-primary`,onClick:n,children:p(`setup.tryAgain`)}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:r,children:p(`setup.models.useRecommended`)})]}),I(`p`,{className:`setup-hint`,children:p(`setup.models.useRecommendedNote`)})]});if(!_)return I(hZ,{});let y=DX(e),b=JX(y,i),x=!o&&!i.defaultChat,S=XX(e,i),C=o?[]:y.filter(e=>e.fits===!1&&i.ticked.has(e.id)),w=!h&&!!v.current&&b.length===0,T=p(S?`setup.continueAnyway`:`setup.continue`);return w?R(`div`,{className:`setup-present`,role:`status`,children:[R(`p`,{children:[I(ci,{size:14,"aria-hidden":`true`}),` `,p(`setup.models.allPresent`)]}),I(`button`,{type:`button`,className:`link-btn`,onClick:()=>g(!0),children:p(`setup.models.change`)}),R(CZ,{children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:l,disabled:d,children:p(`setup.back`)}),R(`button`,{type:`button`,className:`btn-primary`,onClick:()=>u(!1),disabled:d,children:[d&&I(B,{size:13,className:`spin`,"aria-hidden":`true`}),` `,p(`setup.finish`)]})]}),f&&I(`p`,{className:`setup-error`,role:`alert`,children:f})]}):R(`div`,{className:`setup-models`,ref:m,children:[I(`p`,{className:`setup-hint`,children:p(`setup.job.lede`)}),I(yZ,{plan:e,selection:i,onSelection:a,disabled:d}),!o&&I(`button`,{type:`button`,className:`link-btn setup-reset`,onClick:()=>a(qX(e)),disabled:d,children:p(`setup.models.resetRecommended`)}),R(`div`,{className:`setup-models-footer`,children:[I(dZ,{plan:e,selection:i}),R(`label`,{className:`setup-keep-trying`,children:[I(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked),disabled:d}),I(`span`,{children:p(`setup.keepTrying`)})]}),I(EX,{open:x,children:I(`p`,{className:`setup-error`,id:`setup-no-chat`,children:p(`setup.models.noChatReason`)})}),C.length>0&&I(`span`,{className:`visually-hidden`,children:C.map(e=>cZ(e,p)).join(` `)}),f&&I(`p`,{className:`setup-error`,role:`alert`,children:f}),R(CZ,{children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:l,disabled:d,children:p(`setup.back`)}),R(`button`,{type:`button`,className:`btn-primary`,onClick:()=>u(!!S),disabled:d||x,"aria-describedby":x?`setup-no-chat`:void 0,children:[d&&I(B,{size:13,className:`spin`,"aria-hidden":`true`}),` `,T]})]})]})]})}function FZ({plan:e,chatModel:t,gpu:n}){let r=L();if(!e?.catalog)return null;let i=e.catalog,a=e=>e?i.find(t=>t.id===e)?.name??e:null,o=FX(i,{ticked:new Set,unticked:new Set,chatChosen:!1,defaultChat:t,vision:e.vision_model??null}),s=i.find(e=>e.id===o)??i.find(e=>OX(e)&&e.gaia_model),c=i.find(e=>kX(e)&&e.downloaded),l=i.filter(e=>e.gaia_model&&e.planned&&e.skipped),u=n?.pending,d=i.find(e=>e.id===t);return R(`dl`,{className:`setup-summary-list`,children:[t&&R(`div`,{children:[I(`dt`,{children:r(`setup.ready.chat`)}),R(`dd`,{children:[I(`bdi`,{children:a(t)}),d?.recipe===`flm`?` (${r(`setup.models.npu`)})`:``]})]}),R(`div`,{children:[I(`dt`,{children:r(`setup.ready.vision`)}),I(`dd`,{children:s?.downloaded?I(`bdi`,{children:s.name}):r(`setup.ready.visionOff`,{name:s?.name??`Gemma-4-E4B-it`})})]}),c&&R(`div`,{children:[I(`dt`,{children:r(`setup.ready.documents`)}),I(`dd`,{children:I(`bdi`,{children:c.name})})]}),l.length>0&&R(`div`,{children:[I(`dt`,{children:r(`setup.ready.notInstalled`)}),I(`dd`,{children:l.map(e=>e.name).join(`, `)})]}),u?.state===`restart_required`&&R(`div`,{className:`is-warn`,children:[I(`dt`,{children:r(`setup.ready.gpu`)}),R(`dd`,{children:[I(cc,{size:13,"aria-hidden":`true`}),` `,OZ(r,n?DZ(n,u.setting_gb):null)]})]}),u?.state===`took_effect`&&R(`div`,{children:[I(`dt`,{children:r(`setup.ready.gpu`)}),I(`dd`,{children:n?.gpu_gb==null?r(`setup.ready.gpuChanged`):r(`setup.ready.gpuNow`,{gb:GA(n.gpu_gb)})})]})]})}function IZ(){let[e,t]=(0,V.useState)(null),[n,r]=(0,V.useState)([]),i=(0,V.useCallback)(()=>{Promise.resolve(At()).then(e=>{t(e?.providers?.find(e=>e.id===`amd`)?.network??null),r(e?.providers??[])}).catch(e=>{console.warn(`[useGatewayNetwork] could not check the AMD gateway`,e),t(null)})},[]);return(0,V.useEffect)(i,[i]),{network:e,providers:n,recheck:i}}function LZ(e,t,n){return t===`active`?n(`setup.contents.working`):t===`done`?n(`setup.contents.ready`):t===`failed`?n(`setup.contents.failed`):e.installed?n(`setup.contents.alreadyHere`):n(`setup.contents.waiting`)}function RZ(e,t){return e==null?t(`setup.contents.sizeOnDownload`):GA(e)}function zZ({state:e}){return e===`done`?I(ci,{size:13,"aria-hidden":`true`}):e===`active`?I(B,{size:13,className:`spin`,"aria-hidden":`true`}):I(e===`failed`?bc:Ai,{size:13,"aria-hidden":`true`})}function BZ({id:e,error:t,transient:n,onRetry:r,disabled:i}){let a=L(),o=a(`setup.component.${e}`);return R(`div`,{className:`setup-content-failure`,role:`alert`,children:[I(`p`,{children:a(n?`setup.contents.failedNetwork`:`setup.contents.failedOther`,{name:o})}),t&&R(`details`,{className:`dl-details`,children:[I(`summary`,{children:a(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:t})]}),r&&I(`button`,{type:`button`,className:`btn-primary`,onClick:r,disabled:i,"aria-label":a(`setup.contents.retryNamed`,{name:o}),children:a(`setup.progress.retry`)})]})}function VZ({plan:e,run:t,models:n=[],onRetry:r,retryDisabled:i}){let a=L();return R(`ul`,{className:`setup-contents`,children:[(e.components??[]).map(e=>{let n=t?.components?.[e.id],o=t!=null&&t.state!==`running`&&t.state!==`verifying`,s=n===`active`&&o?void 0:n;return R(`li`,{className:`setup-content is-${s??(e.installed?`done`:`waiting`)}`,children:[I(`span`,{className:`setup-content-icon`,children:I(zZ,{state:s??(e.installed?`done`:void 0)})}),R(`span`,{className:`setup-content-main`,children:[I(`span`,{className:`setup-content-name`,children:a(`setup.component.${e.id}`)}),I(`span`,{className:`setup-content-note`,children:a(`setup.component.${e.id}Note`)}),e.bundled?I(`span`,{className:`setup-content-from`,children:a(`setup.contents.bundled`)}):R(`span`,{className:`setup-content-from`,children:[a(`setup.contents.from`),` `,I(`bdi`,{dir:`ltr`,children:e.source})]})]}),R(`span`,{className:`setup-content-side`,children:[I(`bdi`,{dir:`ltr`,children:RZ(e.size_gb,a)}),I(`span`,{children:LZ(e,s,a)})]}),s===`failed`&&o&&!t?.problem&&I(BZ,{id:e.id,error:t?.error,transient:t?.component_kinds?.[e.id]===`transient`,onRetry:r,disabled:i})]},e.id)}),n.map(e=>R(`li`,{className:`setup-content is-waiting`,children:[I(`span`,{className:`setup-content-icon`,children:I(zZ,{state:void 0})}),R(`span`,{className:`setup-content-main`,children:[I(`span`,{className:`setup-content-name`,children:I(`bdi`,{children:e.name})}),I(`span`,{className:`setup-content-note`,children:e.roles.map(e=>a(`setup.purpose.${e}`)).join(` · `)}),e.source&&R(`span`,{className:`setup-content-from`,children:[a(`setup.contents.from`),` `,I(`bdi`,{dir:`ltr`,children:e.source})]})]}),I(`span`,{className:`setup-content-side`,children:I(`bdi`,{dir:`ltr`,children:RZ(e.size_gb,a)})})]},e.id))]})}function HZ({lines:e,className:t,id:n}){let r=(0,V.useRef)(null),i=(0,V.useRef)(!0),a=e.join(`
213
+ `);return(0,V.useEffect)(()=>{let e=r.current;e&&i.current&&(e.scrollTop=e.scrollHeight)},[a]),I(`pre`,{ref:r,id:n,className:t,dir:`ltr`,tabIndex:0,onScroll:e=>{let t=e.currentTarget;i.current=t.scrollHeight-t.scrollTop-t.clientHeight<8},children:a})}var UZ=1e9,WZ={downloading:0,verifying:1,failed:2,ready:3,unchecked:3,cancelled:4,queued:5,skipped:6};function GZ(e){return e.roles.includes(`embedding`)?0:e.roles.includes(`chat`)?1:2}function KZ(e){return[...e].filter(e=>e.state!==`skipped`).sort((e,t)=>WZ[e.state]-WZ[t.state]||GZ(e)-GZ(t))}var qZ=/^\s*(Downloading:|Downloaded\b|\[[=\-\s>#]*\])/;function JZ(e){return e.some(e=>e.trim()&&!qZ.test(e))}var YZ={queued:`setup.state.queued`,downloading:`setup.state.downloading`,verifying:`setup.state.verifying`,ready:`setup.state.ready`,failed:`setup.state.failed`,skipped:`setup.state.skipped`,cancelled:`setup.state.cancelled`,unchecked:`setup.state.unchecked`};function XZ(e){return e?e.state===`running`||e.state===`verifying`||!!e.models?.some(e=>e.state===`downloading`||e.state===`queued`||e.state===`verifying`):!1}function ZZ(e,t,n,r){switch(e.error_kind){case`network`:return r(`setup.fail.network`,{name:t});case`disk_full`:{let i=Math.max(0,e.bytes_total-e.bytes_done)/1e9,a=n==null?i:Math.max(.1,i-n);return r(`setup.fail.diskFull`,{name:t,done:XA(e.bytes_done),need:GA(a)})}case`verify`:return r(`setup.fail.verify`,{name:t});case`memory`:return r(`setup.fail.testMemory`,{name:t});case`stuck`:return r(`setup.fail.testStuck`,{name:t});case`answer`:return r(`setup.fail.testAnswer`,{name:t});case`window`:return r(`setup.fail.testWindow`,{name:t});case`path_too_long`:return r(`setup.fail.pathTooLong`,{name:t});default:return r(`setup.fail.lemonade`,{name:t})}}function QZ({model:e,name:t,estimate:n,now:r,freeGb:i,onRetry:a,onResume:o,onSkip:s,onRestart:c,busy:l,retryLater:u,checking:d,checkingFor:f}){let p=L(),m=(0,V.useId)(),h=(0,V.useId)(),[g,_]=(0,V.useState)(!1),v=e.log??[],y=e.state===`ready`||e.state===`unchecked`?100:e.bytes_total>0?Math.min(100,e.bytes_done/e.bytes_total*100):0,b=p(YZ[e.state]),x=e.retrying_until?Math.max(0,Math.round(e.retrying_until-r/1e3)):0,S=e.state===`downloading`&&!x?n?.stalledFor??0:0,C=e.state===`verifying`&&d||e.state===`downloading`&&!x&&S<15,w;if(e.state===`downloading`){let t=QA(p.locale,e.bytes_total>0?`${XA(e.bytes_done)} / ${XA(e.bytes_total)}`:XA(e.bytes_done));if(x>0)w=p(`setup.progress.retrying`,{n:String(x)});else if(S>=60)w=p(`setup.progress.stuck`);else if(S>=15)w=p(`setup.progress.stalled`,{n:`15`});else if(n?.speed&&n.eta!=null){let{speed:e,eta:r}=n;w=p.compose(n=>`${t} · ${QA(p.locale,ZA(e))} · ${tj(r,n)}`)}else w=p.compose(e=>`${t} · ${e(`setup.progress.estimating`)}`)}else w=e.state===`verifying`?d?f>=10?p(`setup.progress.checkingFor`,{n:String(f)}):p(`setup.progress.checkingLoad`):p(`setup.progress.waitingCheck`):e.state===`ready`?e.bytes_total?XA(e.bytes_total):``:e.state===`unchecked`?p(`setup.progress.unchecked`):e.state===`cancelled`?e.bytes_done>0?p(`setup.progress.keptPartial`,{done:XA(e.bytes_done)}):``:e.state===`queued`&&e.bytes_total?XA(e.bytes_total):``;let T=e.state===`downloading`?p.compose(t=>[t(`setup.progress.percent`,{n:String(Math.floor(y))}),e.bytes_total?t(`setup.progress.of`,{done:XA(e.bytes_done),total:XA(e.bytes_total)}):null,n?.eta==null?null:nj(n.eta,t)].filter(Boolean).join(`, `)):b;return R(`li`,{className:`dl-row is-${e.state}${C?` is-live`:``}${S>=15?` is-stalled`:``}`,children:[R(`div`,{className:`dl-row-head`,children:[I(`span`,{className:`dl-icon`,"aria-hidden":`true`,children:e.state===`ready`||e.state===`unchecked`?I(ci,{size:14}):e.state===`failed`?I(wi,{size:14}):e.state===`cancelled`?I(Ko,{size:13}):I(`span`,{className:`dl-dot`})}),I(`span`,{className:`dl-name`,children:I(`bdi`,{title:e.id,children:t})}),I(`span`,{className:`dl-state`,children:b}),e.state===`downloading`&&R(`bdi`,{className:`dl-pct`,children:[Math.floor(y),`%`]}),e.state!==`failed`&&JZ(v)&&I(`button`,{type:`button`,className:`dl-log-toggle`,onClick:()=>_(e=>!e),"aria-expanded":g,"aria-controls":h,"aria-label":p(`setup.progress.logFor`,{name:t}),title:p(`setup.progress.logFor`,{name:t}),children:I(gi,{size:14,className:g?`is-open`:``,"aria-hidden":`true`})})]}),I(`div`,{className:`dl-track`,role:`progressbar`,"aria-label":p(`setup.progress.rowLabel`,{name:t,state:b}),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":C&&e.state===`verifying`?void 0:Math.floor(y),"aria-valuetext":T,children:I(`span`,{className:`dl-fill`,style:{inlineSize:`${e.state===`verifying`?100:y}%`}})}),w&&I(`p`,{className:`dl-detail`,children:I(`bdi`,{children:w})}),g&&e.state!==`failed`&&JZ(v)&&I(HZ,{lines:v,id:h,className:`dl-log`}),e.state===`failed`&&R(`div`,{className:`dl-fail`,children:[I(`p`,{className:`dl-error`,id:m,children:ZZ(e,t,i,p)}),(v.length>0||e.error)&&R(`details`,{className:`dl-details`,children:[I(`summary`,{children:p(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:v.length>0?v.join(`
214
+ `):e.error})]}),u?I(`p`,{className:`dl-detail`,children:p(`setup.progress.retryLater`)}):R(`div`,{className:`setup-row`,children:[a&&R(`button`,{type:`button`,className:`btn-primary`,disabled:l,onClick:()=>a(e.id,e.error_kind),"aria-describedby":m,children:[I(bs,{size:13,"aria-hidden":`true`}),` `,p(`setup.progress.retry`)]}),s&&I(`button`,{type:`button`,className:`btn-secondary`,disabled:l,onClick:()=>s(e.id),children:p(`setup.progress.skipModel`)})]})]}),e.state===`cancelled`&&o&&I(`div`,{className:`setup-row`,children:I(`button`,{type:`button`,className:`btn-secondary`,disabled:l,onClick:()=>o(e.id),children:p(`setup.progress.resume`)})}),S>=60&&c&&I(`div`,{className:`setup-row`,children:R(`button`,{type:`button`,className:`btn-secondary`,disabled:l,onClick:c,children:[I(bs,{size:13,"aria-hidden":`true`}),` `,p(`setup.progress.retry`)]})})]})}function $Z({status:e,names:t,freeGb:n=null,onCancel:r,onRetry:i,onResume:a,onResumeAll:o,onFinishWithout:s,onSkip:c,onRestart:l,busy:u=!1,retryLater:d=!1,labelledBy:f}){let p=L(),m=wX(),h=(0,V.useMemo)(()=>KZ(e.models??[]),[e.models]),g=(0,V.useRef)(new Map),_=(0,V.useRef)(new Map),v=(0,V.useRef)(new aj),y=(0,V.useRef)(!1),[b,x]=(0,V.useState)(()=>Date.now()),[S,C]=(0,V.useState)(!1),[w,T]=(0,V.useState)(null),E=i&&((e,t)=>{let n=h.find(t=>t.id===e);t===`verify`&&n?T(n):i(e,t)}),[ee,D]=(0,V.useState)(``),[O,te]=(0,V.useState)(``),k=(0,V.useRef)(null),A=e.state===`verifying`||e.state!==`running`&&h.some(e=>e.state===`verifying`),ne=(0,V.useRef)(new Map);(0,V.useEffect)(()=>{if(!m||!(h.some(e=>e.retrying_until)||A))return;let e=setInterval(()=>x(Date.now()),1e3);return()=>clearInterval(e)},[h,m,A]);let j=e.overall,{estimates:M,overallEstimate:re}=(0,V.useMemo)(()=>{let e=Date.now(),t={};for(let n of h){if(n.state!==`downloading`){g.current.delete(n.id);continue}let r=g.current.get(n.id),i=n.downloaded_before_gb??null;r&&_.current.get(n.id)===i||(r=new aj,g.current.set(n.id,r),_.current.set(n.id,i)),t[n.id]=r.update(n.bytes_done,n.bytes_total,e)}let n=h.some(e=>e.state===`downloading`);n&&!y.current&&(v.current=new aj),y.current=n;let r=h.filter(e=>e.state===`downloading`||e.state===`queued`).reduce((e,t)=>e+Math.max(0,t.bytes_total-t.bytes_done),0);return{estimates:t,overallEstimate:n&&j?v.current.update(j.bytes_done,j.bytes_done+r,e):void 0}},[h,j]);(0,V.useEffect)(()=>{let e=new Map(h.map(e=>[e.id,e.state])),n=Math.floor((j?.percent??0)/25),r=k.current;if(k.current={states:e,quarter:n},!r)return;let i=[];for(let e of h){if(r.states.get(e.id)===e.state)continue;let n=t[e.id]??e.id;e.state===`failed`?te(p(`setup.progress.announceFailed`,{name:n})):i.push(p(`setup.progress.announceState`,{name:n,state:p(YZ[e.state])}))}n>r.quarter&&n>0&&n<4&&i.push(p(`setup.progress.announceOverall`,{n:String(n*25)})),i.length&&D(i.join(`. `))},[h,j?.percent,t,p]);let ie=e=>{if(!A)return ne.current.delete(e),0;let t=Date.now(),n=ne.current.get(e)??t;return ne.current.set(e,n),Math.floor((t-n)/1e3)},ae=XZ(e),oe=h.filter(e=>e.state===`cancelled`),se=j?.failed??h.filter(e=>e.state===`failed`).length,ce=j?.percent??0,le=()=>{(j?.bytes_done??0)>UZ?C(!0):r?.()},ue=p.compose(e=>[e(`setup.progress.overallPct`,{n:String(ce)}),j&&j.bytes_total>0?e(`setup.progress.of`,{done:XA(j.bytes_done),total:XA(j.bytes_total)}):null,ae&&re?.speed?QA(p.locale,ZA(re.speed)):null,ae?re?.eta==null?e(`setup.progress.estimating`):e(`setup.progress.left`,{eta:tj(re.eta,e)}):null,se>0?e(`setup.progress.failedCount`,{n:String(se)}):null].filter(Boolean).join(` · `));return R(`section`,{className:`dl${m?``:` is-paused`}`,"aria-labelledby":f,children:[R(`div`,{className:`dl-overall`,children:[I(`p`,{className:`dl-overall-line`,children:I(`bdi`,{children:ue})}),I(`div`,{className:`dl-track is-overall${h.some(e=>e.state===`downloading`)?` is-live`:``}`,role:`progressbar`,"aria-label":p(`setup.progress.overallLabel`),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":ce,"aria-valuetext":p(`setup.progress.percent`,{n:String(ce)}),children:I(`span`,{className:`dl-fill`,style:{inlineSize:`${ce}%`}})})]}),I(`ul`,{className:`dl-list`,children:h.map(e=>I(QZ,{model:e,name:t[e.id]??e.id,estimate:M[e.id],now:b,freeGb:n,onRetry:E,onResume:ae?void 0:a,onSkip:c,onRestart:l,busy:u,retryLater:d,checking:A,checkingFor:ie(e.id)},e.id))}),ae&&I(`p`,{className:`setup-hint dl-controls`,children:p(`setup.progress.keepsGoing`)}),(ae&&r||!ae&&(oe.length>0&&o||s))&&R(CZ,{children:[ae&&r&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:le,disabled:u,children:p(`setup.progress.cancel`)}),!ae&&s&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:s,disabled:u,children:p(`setup.download.finishWithoutExtras`)}),!ae&&oe.length>0&&o&&I(`button`,{type:`button`,className:`btn-primary`,onClick:o,disabled:u,children:p(`setup.progress.resumeAll`)})]}),I(`span`,{className:`visually-hidden`,"aria-live":`polite`,children:ee}),I(`span`,{className:`visually-hidden`,role:`alert`,children:O}),S&&I(wZ,{title:p(`setup.progress.cancelTitle`),confirmLabel:p(`setup.progress.cancelConfirm`),cancelLabel:p(`setup.progress.cancelKeep`),onConfirm:()=>{C(!1),r?.()},onCancel:()=>C(!1),children:I(`p`,{children:p(`setup.progress.cancelBody`)})}),w&&I(wZ,{title:p(`setup.redownload.title`,{name:t[w.id]??w.id}),confirmLabel:p(`setup.redownload.confirm`),cancelLabel:p(`setup.redownload.keep`),onConfirm:()=>{let e=w;T(null),i?.(e.id,`verify`)},onCancel:()=>T(null),children:I(`p`,{children:p(`setup.redownload.body`,{name:t[w.id]??w.id,size:XA(w.bytes_total)})})})]})}function eQ({run:e,plan:t,idle:n,bar:r=!0}){let i=L(),a=t?.components??[],o=a.find(t=>e.components?.[t.id]===`active`),s=a.filter(t=>e.components?.[t.id]===`done`||e.components?.[t.id]==null&&t.installed).length,c=e.percent==null?null:Math.max(0,Math.min(100,Math.round(e.percent))),l=o?i(`setup.download.now`,{name:i(`setup.component.${o.id}`)}):n;return R(`div`,{className:`setup-activity`,children:[R(`p`,{className:`setup-hint`,children:[I(B,{size:13,className:`spin`,"aria-hidden":`true`}),` `,I(`span`,{role:`status`,children:l}),c!=null&&R(F.Fragment,{children:[` · `,R(`bdi`,{dir:`ltr`,children:[c,`%`]})]}),a.length>0&&R(F.Fragment,{children:[` · `,i(`setup.download.partsReady`,{done:String(s),total:String(a.length)})]})]}),r&&c!=null&&I(`progress`,{className:`setup-progress`,max:100,value:c,"aria-label":l})]})}var tQ=[`check`,`download`,`test`],nQ={root:`setup-report`,button:`btn-secondary setup-report-button`,hint:`setup-hint`,error:`setup-error`},rQ=/\d+(\.\d+)?\s*%/;function iQ(e){let t=[],n=null;for(let r of e){let e=r.search(rQ),i=e>=0?r.slice(0,e):null;i!==null&&i===n?t[t.length-1]=r:t.push(r),n=i}return t}function aQ({run:e,before:t={},failed:n=!1}){let r=L(),[i,a]=(0,V.useState)(n),[o,s]=(0,V.useState)(()=>new Set);(0,V.useEffect)(()=>{n&&a(!0)},[n]);let c=e=>s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),l=n=>iQ([...t[n]??[],...e?.logs?.[n]??[]]),u=tQ.filter(e=>l(e).length>0);return R(`section`,{className:`setup-logs`,"aria-label":r(`setup.logs.title`),children:[R(`button`,{type:`button`,className:`setup-log-toggle setup-help-toggle`,onClick:()=>a(e=>!e),"aria-expanded":i,"aria-controls":`setup-help`,children:[I(gi,{size:13,className:i?`is-open`:``,"aria-hidden":`true`}),` `,r(`setup.logs.help`)]}),i&&R(`div`,{id:`setup-help`,className:`setup-help`,children:[u.map(e=>{let t=l(e),n=o.has(e);return R(`div`,{className:`setup-log`,children:[R(`button`,{type:`button`,className:`setup-log-toggle`,onClick:()=>c(e),"aria-expanded":n,children:[I(gi,{size:13,className:n?`is-open`:``,"aria-hidden":`true`}),` `,r(`setup.logs.${e}`)]}),n&&I(HZ,{lines:t,className:`setup-log-pre`})]},e)}),I(fR,{classes:nQ,note:r(`setup.logs.reportNote`)})]})]})}function oQ(){let e=L(),t=z(e=>e.locale),n=z(e=>e.setLocale);return R(`label`,{className:`setup-language`,children:[I(Qa,{size:14,"aria-hidden":`true`}),I(`span`,{className:`visually-hidden`,children:e(`settings.language`)}),I(`select`,{value:t,onChange:e=>n(e.target.value),children:Pe.map(({meta:e})=>I(`option`,{value:e.code,lang:e.code,dir:e.dir,children:Ze(e)},e.code))})]})}var sQ={driver:[`setup.npu.problem.driver`,`setup.npu.fix.driver`],device:[`setup.npu.problem.device`,`setup.npu.fix.device`],firmware:[`setup.npu.problem.firmware`,`setup.npu.fix.firmware`],access:[`setup.npu.problem.access`,`setup.npu.fix.access`],memlock:[`setup.npu.problem.memlock`,`setup.npu.fix.memlock`],runtime:[`setup.npu.problem.runtime`,`setup.npu.fix.runtime`]},cQ={cancelled:`setup.npu.fixError.cancelled`,timeout:`setup.npu.fixError.timeout`,not_authorized:`setup.npu.fixError.notAuthorized`,no_pkexec:`setup.npu.fixError.noPkexec`};function lQ({problem:e}){let t=L(),n=sQ[e.code];if(!n)return R(`li`,{children:[I(`strong`,{children:e.title}),` `,e.fix]});let r=e.params,i=n[1];e.code===`access`&&r.group&&(i=`setup.npu.fix.accessGroup`);let a=n[0];return e.code===`memlock`&&r.fix===`restart`&&(a=`setup.npu.problem.memlockStill`,i=`setup.npu.fix.memlockRestart`),e.code===`memlock`&&r.fix===`stuck`&&(a=`setup.npu.problem.memlockStuck`,i=`setup.npu.fix.memlockStuck`),R(`li`,{children:[I(`strong`,{children:t(a,{device:r.device??``,limit:r.limit??``,version:r.version??``,detail:r.detail??``})}),` `,t(i,{group:r.group??``})]})}function uQ({problems:e,disabled:t,onRecheck:n,id:r=`setup-npu-problems`}){let i=L(),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(null),u=e.some(e=>e.code===`memlock`&&e.params.fix===`apply`),d=async(e,t)=>{s(!0),l(null);try{await e(),n?.()}catch(e){let n=e instanceof On?e.body?.code:void 0,r=n&&n in cQ?cQ[n]:t;l(i(r))}finally{s(!1)}};return R(`div`,{className:`setup-npu-problems`,id:r,role:`note`,children:[I(`p`,{children:i(`setup.npu.notReady`)}),I(`ul`,{children:e.map(e=>I(lQ,{problem:e},e.code))}),I(`p`,{className:`setup-hint`,children:i(`setup.npu.meanwhile`)}),c&&I(`p`,{className:`setup-npu-error`,role:`alert`,children:c}),R(`div`,{className:`setup-npu-actions`,children:[u&&I(`button`,{type:`button`,className:`btn-primary`,disabled:t||o,onClick:()=>void d(a,`setup.npu.fixError.failed`),children:i(`setup.npu.fixMemlock`)}),n&&I(`button`,{type:`button`,className:`btn-secondary`,disabled:t||o,onClick:()=>void d(Tn,`setup.npu.recheckFailed`),children:i(`setup.npu.recheck`)})]})]})}async function dQ(){let e=await ue();e.reachable&&(e.available_backends??[]).some(e=>e.name===`vulkan`)&&(e.preferred_backend??e.default_backend)!==`vulkan`&&await Fe(`vulkan`)}function fQ({plan:e,selection:t,onSelection:n,disabled:r=!1,onRecheck:i}){let a=L(),o=DX(e),s=e.npu?.present&&!e.npu.ready?e.npu.problems:[],c=s.length?void 0:o.find(e=>AX(e)&&e.gaia_model&&e.chat_choice&&e.fits!==!1)??o.find(e=>AX(e)&&e.chat_choice&&e.downloaded&&!MX(e)),l=!s.length&&!c&&o.some(e=>AX(e)&&e.fit_code===`npu`),u=!!o.find(e=>e.id===t.defaultChat&&AX(e)),d=qX(e).defaultChat,f=d&&!o.find(e=>e.id===d&&AX(e))?d:o.find(e=>e.chat_choice&&e.gaia_model&&e.support===`verified`&&!AX(e))?.id,p=e=>{e===`npu`&&c&&!u&&n(LX(t,o,c.id)),e===`gpu`&&u&&f&&n(LX(t,o,f))},m=[{id:`gpu`,label:a(`setup.backend.gpu`)},...c?[{id:`npu`,label:a(`setup.backend.npu`)}]:[],...s.length?[{id:`npu`,label:a(`setup.backend.npu`),unavailable:!0}]:[]],h=u?`npu`:`gpu`;return R(`section`,{className:`setup-backend`,"aria-labelledby":`setup-backend-title`,children:[I(`h3`,{className:`mc-job-title`,id:`setup-backend-title`,children:a(`setup.backend.title`)}),I(sF,{className:`segmented`,"aria-labelledby":`setup-backend-title`,children:m.map(e=>I(`button`,{type:`button`,role:`radio`,"aria-checked":h===e.id,"aria-describedby":e.unavailable?`setup-npu-problems`:void 0,className:h===e.id?`is-active`:``,disabled:r||e.unavailable,onClick:()=>p(e.id),children:I(`bdi`,{children:e.label})},e.id))}),s.length>0?I(uQ,{problems:s,disabled:r,onRecheck:i}):I(`p`,{className:`setup-hint`,children:a(c?`setup.backend.hint`:l?`setup.backend.hintNpuUnusable`:`setup.backend.hintNoNpu`)})]})}var pQ=({children:e})=>I(`bdi`,{dir:`ltr`,children:e});function mQ({label:e,children:t}){return R(`div`,{className:`found-row`,children:[I(`dt`,{children:e}),I(`dd`,{children:t})]})}function hQ(e){return e.family?`${e.name} (${e.family})`:e.name}var gQ=[[`llamacpp`,`llama.cpp`],[`flm`,`FastFlowLM`],[`whispercpp`,`whisper.cpp`],[`kokoro`,`Kokoro`],[`sd-cpp`,`stable-diffusion.cpp`]],_Q=new Set([`llamacpp`,`flm`]);function vQ(e){let t=[];for(let[n,r]of gQ){let i=(e.backends??[]).find(e=>e.recipe===n&&e.default);i&&i.state!==`unsupported`&&t.push({name:r,b:i})}return t}function yQ(e,t){return e?e.kind===`release_candidate`&&e.rc?`${e.version.replace(/rc\d+$/,``)} RC ${e.rc}`:e.kind===`source`&&e.commit?`${e.version} (${e.commit})`:e.version:t??null}var bQ={release:`release`,release_candidate:`release candidate`,local:`local build`,source:`from source`};function xQ(e,t){let n=e.system,r=e=>(n?.devices??[]).filter(t=>t.available&&e(t.kind)),i=r(e=>e.endsWith(`gpu`)),a=r(e=>e.endsWith(`npu`)),o=vQ(e);return{sys:n,cpu:r(e=>e===`cpu`)[0],gpus:i,graphics:i.length?i.map(hQ).join(`; `):t?.gpu_name??null,npus:a,runsOn:i[0]?.name??t?.gpu_name??null,npu:a[0]??null,runtimes:o,gaia:yQ(n?.gaia_build,n?.gaia_version),build:n?.gaia_build?.kind??null,software:[yQ(n?.gaia_build,n?.gaia_version)?`GAIA ${yQ(n?.gaia_build,n?.gaia_version)}`:null,n?.lemonade_version?`Lemonade ${n.lemonade_version}`:null,...o.filter(({b:e})=>_Q.has(e.recipe)&&CQ(e)).map(({name:e,b:t})=>`${e} ${t.version??t.backend}`)].filter(e=>!!e),totalMemory:JA(n?.physical_memory,t?.ram_gb),freeGb:e.disk?.free_gb??t?.disk_free_gb??null,modelsPath:e.disk?.path??null,gaiaHome:n?.gaia_home??null}}var SQ={installed:`installed`,update_required:`installed, updates on first use`},CQ=e=>e.state===`installed`||e.state===`update_required`,wQ={chat:`setup.job.chat`,vision:`setup.job.vision`,embedding:`setup.job.documents`,speech:`setup.job.speech`,voice:`setup.job.voice`,image_creation:`setup.job.images`};function TQ(e,t){let n=xQ(e,t),r=e.lemonade.mode===`external`?`the user's own`:`GAIA's own`;return[`GAIA: ${n.gaia??`unknown`}${n.build?`, ${bQ[n.build]}`:``} (agent ${n.sys?.agent_version??`not installed yet`})`,`Model server: ${r} Lemonade ${n.sys?.lemonade_version??`(version not reported)`}${e.lemonade.url?` at ${e.lemonade.url}`:``}`,...n.runtimes.map(({name:e,b:t})=>`${e}: ${t.backend}${t.version?` ${t.version}`:``} (${SQ[t.state??``]??`not installed`})`),`OS: ${n.sys?.os??t?.os??`unknown`}`,`Processor: ${n.cpu?.name??n.sys?.processor??`unknown`}${n.cpu?.cores?` (${n.cpu.cores} cores, ${n.cpu.threads??n.cpu.cores} threads)`:``}`,`Graphics: ${n.graphics??`none found`}`,`NPU: ${n.npus.map(hQ).join(`; `)||`none found`}`,`Memory: ${n.totalMemory??`unknown`}${e.capacity_gb==null?``:`, ${GA(e.capacity_gb)} for models${e.memory_source?` (${e.memory_source})`:``}`}`,`Models folder: ${n.modelsPath??`unknown`}${n.freeGb==null?``:` (${GA(n.freeGb)} free)`}`,`GAIA data and logs: ${n.gaiaHome??`unknown`}`].join(`
215
+ `)}function EQ({plan:e,hardware:t,onChangeMemory:n}){let r=L(),i=xQ(e,t),[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(null),d=async e=>{u(null);try{await nr(e,!1)}catch(e){u(r(`setup.found.openFailed`,{error:e instanceof Error?e.message:String(e)}))}},f=I(`span`,{className:`found-muted`,children:r(`setup.found.unknown`)}),p=[...t?.blockers??[],...(t?.warnings??[]).filter(e=>t?.lemonade_running||!/\bNPU\b/.test(e))],m=(0,V.useRef)(null);(0,V.useEffect)(()=>()=>{m.current&&clearTimeout(m.current)},[]);let h=e=>{c(e),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>c(null),2e3)};return R(`section`,{className:`setup-card found`,"aria-label":r(`setup.found.title`),children:[R(`div`,{className:`found-head`,children:[I(`h3`,{className:`mc-job-title`,children:r(`setup.found.title`)}),I(`button`,{type:`button`,className:`found-copy`,onClick:()=>{navigator.clipboard.writeText(TQ(e,t)).then(()=>h(`done`),e=>{console.warn(`[DetectedSummary] could not copy the details`,e),h(`failed`)})},"aria-label":r(`setup.found.copy`),title:r(`setup.found.copy`),children:I(s===`done`?ci:Bi,{size:14,"aria-hidden":`true`})}),s&&I(`span`,{className:`found-copied`,role:`status`,children:r(s===`done`?`setup.found.copied`:`setup.found.copyFailed`)})]}),R(`dl`,{className:`found-glance`,children:[R(mQ,{label:r(`setup.found.runsOn`),children:[i.runsOn?I(pQ,{children:i.runsOn}):f,i.npu&&I(`span`,{className:`found-chip`,children:I(pQ,{children:`NPU`})})]}),R(mQ,{label:r(`setup.found.memory`),children:[e.capacity_gb!=null&&i.totalMemory?r(`setup.found.memoryOf`,{size:GA(e.capacity_gb),total:i.totalMemory}):e.capacity_gb==null?i.totalMemory?I(pQ,{children:i.totalMemory}):f:I(pQ,{children:GA(e.capacity_gb)}),n&&I(`button`,{type:`button`,className:`link-btn found-link`,onClick:n,children:r(`setup.found.changeMemory`)})]}),I(mQ,{label:r(`setup.found.space`),children:i.freeGb==null?f:I(pQ,{children:GA(i.freeGb)})}),R(mQ,{label:r(`setup.found.software`),children:[i.software.length?I(pQ,{children:i.software.join(` · `)}):f,i.build&&i.build!==`release`&&I(`span`,{className:`found-chip`,children:r(`setup.found.build.${i.build}`)})]})]}),R(`div`,{className:`found-paths`,children:[[[`setup.found.modelsFolder`,i.modelsPath],[`setup.found.gaiaFolder`,i.gaiaHome]].map(([e,t])=>t&&R(`button`,{type:`button`,className:`link-btn found-open`,onClick:()=>void d(t),title:t,children:[I(Ea,{size:13,"aria-hidden":`true`}),` `,r(e)]},e)),l&&I(`p`,{className:`setup-error`,role:`alert`,children:l})]}),p.length>0&&R(`details`,{className:`dl-details found-warnings`,children:[R(`summary`,{children:[I(wi,{size:13,"aria-hidden":`true`}),` `,r(`setup.found.noticed`)]}),I(`ul`,{children:p.map(e=>I(`li`,{children:I(pQ,{children:e})},e))})]}),R(`button`,{type:`button`,className:`setup-log-toggle found-more`,onClick:()=>o(e=>!e),"aria-expanded":a,children:[I(gi,{size:13,className:a?`is-open`:``,"aria-hidden":`true`}),` `,r(`setup.found.details`)]}),a&&R(`div`,{className:`found-details`,children:[I(`h4`,{className:`found-group`,children:r(`setup.found.software`)}),R(`dl`,{className:`found-list`,children:[R(mQ,{label:I(pQ,{children:`GAIA`}),children:[i.gaia?I(pQ,{children:i.gaia}):f,i.build&&i.build!==`release`&&I(`span`,{className:`found-chip`,children:r(`setup.found.build.${i.build}`)})]}),I(mQ,{label:r(`setup.found.agent`),children:i.sys?.agent_version?I(pQ,{children:i.sys.agent_version}):I(`span`,{className:`found-muted`,children:r(`setup.found.agentLater`)})}),R(mQ,{label:r(`setup.found.server`),children:[e.lemonade.mode===`external`?r(`setup.found.serverYours`):r(`setup.found.serverOwn`),i.sys?.lemonade_version&&R(F.Fragment,{children:[` `,I(pQ,{children:i.sys.lemonade_version})]}),e.lemonade.url&&I(`span`,{className:`found-sub`,children:I(pQ,{children:e.lemonade.url})})]})]}),I(`h4`,{className:`found-group`,children:r(`setup.found.runtime`)}),i.runtimes.length?I(`div`,{className:`found-table-wrap`,children:R(`table`,{className:`found-table`,children:[I(`thead`,{className:`visually-hidden`,children:R(`tr`,{children:[I(`th`,{scope:`col`,children:r(`setup.found.col.runtime`)}),I(`th`,{scope:`col`,children:r(`setup.found.col.device`)}),I(`th`,{scope:`col`,children:r(`setup.found.col.version`)}),I(`th`,{scope:`col`,children:r(`setup.found.col.state`)})]})}),I(`tbody`,{children:i.runtimes.map(({name:e,b:t})=>R(`tr`,{children:[I(`th`,{scope:`row`,children:I(pQ,{children:e})}),I(`td`,{children:I(pQ,{children:t.backend})}),I(`td`,{children:I(pQ,{children:t.version??``})}),I(`td`,{className:CQ(t)?`is-installed`:void 0,children:r(CQ(t)?`setup.pc.backend.installed`:`setup.pc.backend.available`)})]},t.recipe))})]})}):I(`p`,{className:`found-muted`,children:r(`setup.found.unknown`)}),I(`h4`,{className:`found-group`,children:r(`setup.found.models`)}),(e.catalog??[]).length?I(`div`,{className:`found-table-wrap`,children:R(`table`,{className:`found-table`,children:[I(`thead`,{className:`visually-hidden`,children:R(`tr`,{children:[I(`th`,{scope:`col`,children:r(`setup.found.col.model`)}),I(`th`,{scope:`col`,children:r(`setup.found.col.job`)}),I(`th`,{scope:`col`,children:r(`setup.found.col.tested`)}),I(`th`,{scope:`col`,children:r(`setup.found.col.size`)}),I(`th`,{scope:`col`,children:r(`setup.found.col.state`)})]})}),I(`tbody`,{children:(e.catalog??[]).map(e=>R(`tr`,{children:[I(`th`,{scope:`row`,title:e.id,children:I(`bdi`,{children:e.name})}),I(`td`,{children:e.roles.map(e=>r(wQ[e])).join(` · `)}),R(`td`,{children:[e.support===`verified`&&I(`span`,{className:`mc-chip is-verified`,children:r(`setup.label.verified`)}),e.support===`untested`&&I(`span`,{className:`mc-chip is-untested`,children:r(`setup.label.untested`)})]}),I(`td`,{children:I(pQ,{children:e.full_size_gb??e.size_gb?GA(e.full_size_gb??e.size_gb):``})}),I(`td`,{className:e.downloaded?`is-installed`:void 0,children:r(e.downloaded?`setup.models.status.onPc`:`setup.found.notDownloaded`)})]},e.id))})]})}):I(`p`,{className:`found-muted`,children:r(`setup.found.unknown`)}),I(`h4`,{className:`found-group`,children:r(`setup.found.hardware`)}),R(`dl`,{className:`found-list`,children:[I(mQ,{label:r(`setup.found.os`),children:i.sys?.os??t?.os?I(pQ,{children:i.sys?.os??t?.os}):f}),R(mQ,{label:r(`setup.found.cpu`),children:[i.cpu||i.sys?.processor?I(pQ,{children:i.cpu?.name??i.sys?.processor}):f,i.cpu?.cores?I(`span`,{className:`found-sub`,children:r(`setup.found.cores`,{cores:String(i.cpu.cores),threads:String(i.cpu.threads??i.cpu.cores)})}):null]}),I(mQ,{label:r(`setup.found.gpu`),children:i.graphics?I(pQ,{children:i.graphics}):I(`span`,{className:`found-muted`,children:r(`setup.found.none`)})}),I(mQ,{label:r(`setup.found.npu`),children:i.npus.length?I(pQ,{children:i.npus.map(hQ).join(`; `)}):I(`span`,{className:`found-muted`,children:r(`setup.found.none`)})})]})]})]})}function DQ(){return window.gaiaUpdater}var OQ={status:`idle`,version:null,progress:0,releaseNotes:null,error:null,currentVersion:null,pinnedVersion:null,autoUpdate:!1,includePrereleases:!1};function kQ(){let[e,t]=(0,V.useState)({...OQ}),n=(0,V.useRef)(!1),r=(0,V.useRef)(0),i=(0,V.useCallback)(async()=>{let e=DQ();if(!e)return;let i=r.current;try{let r=await e.getStatus();n.current&&r&&t(r)}catch(e){P.system.error(`Reading the update status failed`,e),n.current&&r.current===i&&t(e=>({...e,readFailed:!0}))}},[]);return(0,V.useEffect)(()=>{let e=DQ();if(!e)return;n.current=!0;let a=e.onStatusChange(e=>{e&&(r.current+=1,n.current&&t(e))});return i(),()=>{n.current=!1,a()}},[i]),{...e,reload:i}}var AQ=`gaia-update-error:`;function jQ(e,t){let n=`update.err.${e}`;return j(n)?de(n,t??{}):null}function MQ(e){let t=e instanceof Error?e.message:String(e),n=t.indexOf(AQ);if(n<0)return t.replace(/^Error invoking remote method '[^']+': (?:Error: )?/,``);let r;try{r=JSON.parse(t.slice(n+18))}catch{return t.slice(0,n)+t.slice(n+18)}let i=jQ(r.code,r.params)??r.message??r.code,a=r.note&&jQ(r.note.code,r.note.params);return a?de(`update.err.withNote`,{error:i,note:a}):i}function NQ(e,t){let n=MQ(e);return typeof n==`object`?t(n.ref,n.params):String(n)}function PQ({className:e}){let t=L(),n=kQ(),[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(null),s=n.lastWorking;if(!DQ()||!s)return null;let c=(r||n.version===s.version)&&n.status===`downloading`,l=r&&n.status===`downloaded`,u=!r&&n.status===`downloaded`&&n.version===s.version,d=new Date(s.at).toLocaleDateString(Ln(t),{year:`numeric`,month:`short`,day:`numeric`}),f=t(`setup.goBack.title`);return R(`section`,{className:e?`setup-card ${e}`:`setup-card`,"aria-label":f,children:[I(`h3`,{className:`mc-job-title`,children:f}),I(`p`,{children:t(`setup.goBack.lead`,{version:s.version,date:d})}),I(`p`,{className:`setup-hint`,children:t(`setup.goBack.fixes`,{version:s.version})}),c||l?R(`p`,{className:`setup-hint`,role:`status`,children:[I(B,{size:13,className:`spin`,"aria-hidden":`true`}),` `,c?t(`setup.goBack.downloading`,{version:s.version,pct:Math.max(0,Math.min(100,Math.round(n.progress)))}):t(`setup.goBack.restarting`,{version:s.version})]}):u?R(F.Fragment,{children:[I(`p`,{className:`setup-hint`,children:t(`setup.goBack.ready`,{version:s.version})}),I(`div`,{className:`setup-row`,children:I(`button`,{type:`button`,className:`btn-secondary go-back-action`,onClick:()=>{let e=DQ();e&&(o(null),e.restart().catch(e=>{P.system.error(`Restarting into the last working version failed`,e),o(t(`setup.goBack.failed`,{reason:NQ(e,t)}))}))},children:t(`setup.goBack.restart`,{version:s.version})})})]}):I(`div`,{className:`setup-row`,children:I(`button`,{type:`button`,className:`btn-secondary go-back-action`,onClick:()=>{let e=DQ();e&&(i(!0),o(null),e.revertToLastWorking().catch(e=>{P.system.error(`Going back to the last working version failed`,e),o(t(`setup.goBack.failed`,{reason:NQ(e,t)}))}).finally(()=>i(!1)))},disabled:r,children:t(`setup.goBack.action`,{version:s.version})})}),a&&I(`p`,{className:`setup-error`,role:`alert`,children:a}),R(`details`,{className:`dl-details`,children:[I(`summary`,{children:t(`setup.progress.details`)}),I(`p`,{className:`setup-hint`,children:t(`setup.goBack.note`,{version:s.version,current:n.currentVersion??``})})]})]})}function FQ({state:e}){return e===`done`?I(ci,{size:13,"aria-hidden":`true`}):e===`active`?I(B,{size:13,className:`spin`,"aria-hidden":`true`}):I(e===`failed`?bc:e===`question`?Ei:Ai,{size:13,"aria-hidden":`true`})}function IQ({hardware:e,hardwareError:t,plan:n,serverRun:r,awaitingChoice:i=!1}){let a=L(),[o,s]=(0,V.useState)(!1),c=!!n?.lemonade.reachable,l=r?.state===`failed`||r?.state===`cancelled`,u=a(n?.lemonade.mode===`external`?`setup.found.serverYours`:`setup.found.serverOwn`),d=n?.system?.lemonade_version?a(`setup.checks.serverFound`,{version:n.system.lemonade_version,whose:u}):u,f=e?`done`:t?`failed`:`active`,p=[e?.gpu_name,e?.npu_detected?a(`setup.checks.npu`):null].filter(Boolean).join(` · `),m=t?null:n?.capacity_gb==null?c?JA(n?.system?.physical_memory,e?.ram_gb):null:GA(n.capacity_gb),h=t?`failed`:m?`done`:l?`failed`:i?`waiting`:`active`,g=[{id:`device`,label:a(`setup.checks.device`),value:t?`${a(`setup.system.unread`)} ${t}`:p||null,state:f},{id:`memory`,label:a(`setup.found.memory`),value:m,state:h},{id:`disk`,label:a(`setup.checks.disk`),value:e?.disk_free_gb==null?null:a(`setup.checks.diskValue`,{size:QA(a.locale,KA(e.disk_free_gb))}),state:f},{id:`server`,label:a(`setup.checks.server`),value:c?d:i?a(`setup.checks.serverChoose`):null,state:c?`done`:l?`failed`:i?`question`:e?`active`:`waiting`},{id:`models`,label:a(`setup.checks.backends`),value:c&&n?.catalog?a(`setup.checks.backendsValue`,{models:String(n.catalog.length),downloaded:String(n.catalog.filter(e=>e.downloaded).length)}):null,state:c&&n?.catalog?`done`:c?`active`:`waiting`}],_=g.filter(e=>e.state===`done`).length,v=Math.round(_/g.length*100),y=I(`ul`,{className:`setup-rows`,id:`setup-check-rows`,children:g.map(e=>R(`li`,{className:`setup-result is-${e.state}`,children:[I(FQ,{state:e.state}),I(`span`,{className:`setup-result-label`,children:e.label}),e.value&&I(`bdi`,{className:`setup-result-value`,children:e.value})]},e.id))});return _===g.length?R(`section`,{className:`setup-card setup-checks-done`,"aria-label":a(`setup.check.title`),children:[I(`p`,{className:`setup-result is-done`,role:`status`,children:R(`button`,{type:`button`,className:`setup-checks-toggle`,"aria-expanded":o,"aria-controls":`setup-check-rows`,onClick:()=>s(e=>!e),children:[I(ci,{size:13,"aria-hidden":`true`}),I(`span`,{className:`setup-result-label`,children:a(`setup.checks.allPassed`,{n:String(g.length)})}),I(gi,{size:13,className:o?`is-open`:``,"aria-hidden":`true`})]})}),o&&y]}):R(`section`,{className:`setup-card`,"aria-label":a(`setup.check.title`),children:[I(`div`,{className:`setup-bar-head`,children:i?I(`span`,{children:a(`setup.checks.waitingChoice`)}):R(F.Fragment,{children:[I(`span`,{children:a(`setup.checks.count`,{done:String(_),total:String(g.length)})}),R(`bdi`,{dir:`ltr`,children:[v,`%`]})]})}),I(`progress`,{className:`setup-progress`,max:100,value:v,"aria-label":a(`setup.check.title`)}),y]})}function LQ({steps:e}){let t=L();return R(`nav`,{className:`setup-rail`,"aria-label":t(`setup.rail.label`),children:[I(`p`,{className:`setup-rail-title`,children:t(`setup.title`)}),I(`ol`,{className:`setup-rail-list`,children:e.map((e,t)=>{let n=e.status===`done`?I(ci,{size:13,"aria-hidden":`true`}):e.status===`active`?I(B,{size:13,className:`spin`,"aria-hidden":`true`}):e.status===`failed`?I(wi,{size:13,"aria-hidden":`true`}):t+1,r=R(F.Fragment,{children:[I(`span`,{className:`setup-rail-num`,children:n}),I(`span`,{children:e.label})]}),i=`setup-rail-step is-${e.status}${e.shown?` is-shown`:``}`,a=e.shown?`step`:void 0;return I(`li`,{children:e.onOpen?I(`button`,{type:`button`,className:i,onClick:e.onOpen,children:r}):I(`span`,{className:i,"aria-current":a,children:r})},e.id)})})]})}var RQ={memory:`setup.test.why.memory`,broken:`setup.test.why.broken`,stuck:`setup.test.why.stuck`,missing:`setup.test.why.missing`,agent:`setup.test.why.agent`,answer:`setup.test.why.answer`,window:`setup.test.why.window`},zQ=`gaiacpp`,BQ=e=>e.job===`agent`&&e.agent===zQ;function VQ(e,t){return t(`setup.test.job.${e}`)}function HQ({state:e}){return e===`passed`?I(ci,{size:13,"aria-hidden":`true`}):e===`running`?I(B,{size:13,className:`spin`,"aria-hidden":`true`}):I(e===`failed`?bc:e===`skipped`?Eo:Ai,{size:13,"aria-hidden":`true`})}function UQ(e,t){return e.state===`running`?t(`setup.test.running`):e.state===`failed`?t(`setup.test.failed`):e.state===`skipped`?t(`setup.test.skipped`):e.seconds==null?t(`setup.test.passed`):t(`setup.test.passedIn`,{seconds:String(Math.round(e.seconds))})}function WQ({run:e,expected:t,names:n,catalog:r,onRetry:i,onChooseAnother:a,onCancel:o,onDownloadAgain:s,busy:c}){let l=L(),u=e.tests??[],d=new Set(u.map(e=>e.job)),f=t.filter(e=>!d.has(e)),p=u.filter(e=>e.state!==`running`).length,m=Math.max(u.length+f.length,1),h=Math.round(p/m*100),g=u.filter(e=>e.state===`failed`).filter(e=>!r.find(t=>t.id===e.subject)?.roles.some(e=>[`speech`,`voice`,`image_creation`].includes(e))),_=e.state===`failed`||e.state===`cancelled`,v=s?[...new Set(g.filter(e=>e.kind===`broken`&&e.subject).map(e=>e.subject))]:[],[y,b]=(0,V.useState)(null),x=r.find(e=>e.id===y)?.full_size_gb,S=_&&e.components?.agent===`failed`,C=g.some(e=>e.subject&&e.kind!==`missing`&&!BQ(e)),w=_&&e.state===`failed`&&g.some(BQ),T=w?g.find(e=>BQ(e)&&e.agent_problem)?.agent_problem??null:null,[E,ee]=(0,V.useState)(!1),[D,O]=(0,V.useState)(!1),[te,k]=(0,V.useState)(null),A=async()=>{ee(!0),k(null);try{if((await ke()).programs.find(e=>e.id===`gaiapy`)?.installed!==!0){k(de(`newChat.agent.pythonMissing`,{name:zQ}));return}await Pn({flagship_agent:`gaiapy`}),i()}catch(e){k(BF(e))}finally{ee(!1)}},ne=e.state===`verifying`&&!u.some(e=>e.state===`running`)?f[0]:void 0;return R(F.Fragment,{children:[R(`section`,{className:`setup-card`,"aria-label":l(`setup.test.title`),children:[R(`div`,{className:`setup-bar-head`,children:[I(`span`,{children:l(`setup.test.count`,{done:String(p),total:String(m)})}),R(`bdi`,{dir:`ltr`,children:[h,`%`]})]}),I(`progress`,{className:`setup-progress`,max:100,value:h,"aria-label":l(`setup.test.title`)}),R(`ul`,{className:`setup-rows`,children:[u.map(e=>R(`li`,{className:`setup-result is-${e.state}`,children:[I(HQ,{state:e.state}),R(`span`,{className:`setup-result-label`,children:[VQ(e.job,l),e.subject&&R(`bdi`,{className:`setup-result-model`,children:[` `,n[e.subject]??cl(e.subject)]})]}),I(`span`,{className:`setup-result-value`,children:UQ(e,l)}),e.error&&R(`div`,{className:`setup-result-error`,children:[I(`p`,{children:BQ(e)?l(`setup.test.why.agentNative`,{name:zQ}):l(e.kind===`broken`&&!s?`setup.test.why.brokenYours`:RQ[e.kind??``]??`setup.test.why.other`)}),BQ(e)&&e.agent_error&&!e.agent_problem&&R(`p`,{className:`setup-result-error-said`,children:[l(`setup.test.agentSaid`,{name:zQ}),` `,I(`bdi`,{dir:`ltr`,children:e.agent_error})]}),R(`details`,{className:`dl-details`,children:[I(`summary`,{children:l(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:e.error})]})]})]},`${e.job}:${e.subject??``}`)),f.map(e=>e===`agent`&&S?R(`li`,{className:`setup-result is-failed`,children:[I(HQ,{state:`failed`}),I(`span`,{className:`setup-result-label`,children:VQ(e,l)}),I(`span`,{className:`setup-result-value`,children:l(`setup.test.failed`)}),I(`div`,{className:`setup-result-error`,children:I(`p`,{children:l(`setup.test.why.hub`)})})]},e):e===ne?R(`li`,{className:`setup-result is-running`,children:[I(HQ,{state:`running`}),I(`span`,{className:`setup-result-label`,children:VQ(e,l)}),I(`span`,{className:`setup-result-value`,children:l(`setup.test.starting`)})]},e):R(`li`,{className:`setup-result is-waiting`,children:[I(HQ,{state:`waiting`}),I(`span`,{className:`setup-result-label`,children:VQ(e,l)}),I(`span`,{className:`setup-result-value`,children:l(`setup.test.waiting`)})]},e))]})]}),e.state===`verifying`&&o&&I(CZ,{children:I(`button`,{type:`button`,className:`btn-secondary`,onClick:o,disabled:c,children:l(`setup.progress.cancel`)})}),_&&R(`div`,{className:`setup-failure`,role:`alert`,children:[T?I(jW,{problem:T,onRetry:i,onBusy:O,nested:!0}):I(`p`,{children:e.state===`cancelled`?l(`setup.test.cancelled`):w?l(`setup.test.failedNative`,{name:zQ}):g.some(e=>e.kind===`memory`)?l(`setup.test.failedMemory`):l(`setup.test.failedHelp`)}),w&&I(`p`,{className:`setup-failure-hint`,children:l(`setup.agent.hint`)}),te&&I(`p`,{className:`setup-result-error`,children:l(`newChat.agent.switchFailed`,{error:te})}),R(CZ,{children:[C&&a&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:a,disabled:c,children:l(`setup.test.chooseAnother`)}),I(`button`,{type:`button`,className:v.length||w?`btn-secondary`:`btn-primary`,onClick:i,disabled:c||E||T!==null&&D,children:l(`setup.test.tryAgain`)}),w&&!T&&R(`button`,{type:`button`,className:`btn-primary setup-wrap-btn`,onClick:()=>void A(),disabled:c||E,children:[E&&I(B,{size:13,className:`spin`,"aria-hidden":`true`}),` `,l(`setup.test.finishOnPython`)]}),v.map(e=>I(`button`,{type:`button`,className:`btn-primary setup-wrap-btn`,onClick:()=>b(e),disabled:c,children:v.length===1?l(`setup.test.downloadItAgain`):l(`setup.test.downloadAgain`,{name:n[e]??e})},e))]})]}),y&&I(wZ,{title:l(`setup.redownload.title`,{name:n[y]??y}),confirmLabel:l(`setup.redownload.confirm`),cancelLabel:l(`setup.redownload.keep`),onConfirm:()=>{let e=y;b(null),s?.(e)},onCancel:()=>b(null),children:I(`p`,{children:l(`setup.redownload.body`,{name:n[y]??y,size:x==null?``:GA(x)})})})]})}var GQ=`https://app.fireworks.ai/settings/users/api-keys`,KQ=`https://amd-gaia.ai/docs/guides/llm-gateway`,qQ=[{id:`local`,title:`setup.where.local`,note:`setup.where.localNote`},{id:`fireworks`,title:`Fireworks AI`,note:`setup.where.fireworksNote`},{id:`amd`,title:`AMD LLM Gateway`,note:`setup.where.amdNote`}];function JQ(e,t){return j(e.title)?t(e.title):e.title}var YQ=1e3,XQ=`gaia-setup-choice`;function ZQ(){try{let e=localStorage.getItem(XQ);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 QQ(e){try{localStorage.setItem(XQ,e)}catch(e){console.warn(`[SetupScreen] could not save the provider choice; a reload will ask again`,e)}}var $Q=[`ok`,`needs_key`,`too_old`];function e$({onChosen:e,onNothingToOffer:t,onFound:n,canInstallOwn:r=!0}){let i=L(),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)([]),[d,f]=(0,V.useState)(!1),[p,m]=(0,V.useState)(``),[h,g]=(0,V.useState)(!1),[_,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(null),[x,S]=(0,V.useState)(null),[C,w]=(0,V.useState)(null),[T,E]=(0,V.useState)(`gaia`),D=(0,V.useRef)(!0),O=(0,V.useCallback)(async()=>{c(null);try{let e=await Xe();if(!e.offer){t?.();return}f(!0);let{found:r,unchecked:i=[]}=await ee();if(!D.current)return;u(r?[]:i),r&&$Q.includes(r.status)?(o({target:e,found:r}),n?.(r),g(r.status===`needs_key`),r.status===`too_old`&&t?.()):i.length===0&&t?.()}catch(e){D.current&&c(e instanceof Error?e.message:String(e))}finally{D.current&&f(!1)}},[t,n]);(0,V.useEffect)(()=>(D.current=!0,O(),()=>{D.current=!1}),[O]);let te=(0,V.useCallback)(async t=>{if(a){b(t),S(null);try{await ge(t===`external`?{mode:t,base_url:a.found.url,api_key:p.trim()||void 0}:{mode:t}),m(``),w(t),e(t)}catch(e){yX(e)&&g(!0),S(e instanceof Error?e.message:String(e))}finally{b(null)}}},[a,p,e]);if(s||l.length>0)return R(F.Fragment,{children:[I(`p`,{className:`setup-hint`,children:s?i(`setup.offer.checkFailed`):i(`setup.offer.noAnswer`,{url:l.join(`, `)})}),s&&R(`details`,{className:`dl-details`,children:[I(`summary`,{children:i(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:s})]}),R(CZ,{children:[R(`button`,{type:`button`,className:`btn-secondary`,disabled:d,onClick:()=>void O(),children:[d&&I(B,{size:13,className:`spin`}),` `,i(`setup.offer.checkAgain`)]}),t&&r&&I(`button`,{type:`button`,className:`btn-primary`,disabled:d,onClick:t,children:i(`setup.offer.useOwn`)})]})]});if(!a)return d?R(`p`,{className:`setup-hint`,role:`status`,children:[I(B,{size:13,className:`spin`,"aria-hidden":`true`}),` `,i(`setup.offer.looking`)]}):null;let{target:k,found:A}=a;return C?I(`p`,{className:`setup-hint`,role:`status`,children:C===`external`?i(`setup.offer.usingYours`,{url:A.url}):i(`setup.offer.usingOwn`)}):A.status===`too_old`?R(`p`,{className:`setup-hint`,role:`status`,children:[i(`setup.offer.tooOld`),` `,R(`bdi`,{dir:`ltr`,className:`setup-choice-note`,children:[`Lemonade `,A.version??``,` · `,A.url]})]}):R(`form`,{id:`setup-lemonade-form`,className:`setup-lemonade`,"aria-label":i(`setup.offer.label`),onSubmit:e=>{e.preventDefault(),te(T)},children:[R(`fieldset`,{className:`setup-choices`,disabled:!!y,children:[I(`legend`,{className:`setup-choice-title`,children:i(`setup.offer.title`)}),[{mode:`gaia`,title:`setup.offer.useOwn`,note:`setup.offer.ownNote`},{mode:`external`,title:`setup.offer.useMine`,note:`setup.offer.mineNote`}].map(e=>R(`label`,{className:`setup-choice${T===e.mode?` is-active`:``}`,children:[I(`input`,{type:`radio`,name:`setup-server`,value:e.mode,checked:T===e.mode,onChange:()=>{E(e.mode),S(null)}}),R(`span`,{children:[R(`span`,{className:`setup-choice-title`,children:[i(e.title),e.mode===`gaia`&&I(`span`,{className:`setup-choice-tag`,children:i(`setup.offer.recommended`)})]}),I(`span`,{className:`setup-choice-note`,children:i(e.note)})]})]},e.mode))]}),R(`button`,{type:`button`,className:`setup-log-toggle setup-offer-more`,onClick:()=>v(e=>!e),"aria-expanded":_,"aria-controls":`setup-offer-detail`,children:[I(gi,{size:13,className:_?`is-open`:``,"aria-hidden":`true`}),` `,i(`setup.offer.whatGaiaDoes`)]}),_&&R(`div`,{id:`setup-offer-detail`,children:[I(`p`,{className:`setup-choice-note`,children:R(`bdi`,{dir:`ltr`,children:[`Lemonade`,A.version?` ${A.version}`:``,` · `,A.url]})}),I(`p`,{className:`setup-choice-note`,children:i(`setup.offer.whatGaiaDoesText`)})]}),T===`external`&&h&&I(`input`,{className:`settings-input`,type:`password`,autoComplete:`off`,value:p,onChange:e=>m(e.target.value),placeholder:i(`setup.offer.keyPlaceholder`),"aria-label":i(`setup.offer.keyLabel`)}),x&&(h&&T===`external`?I(`p`,{className:`setup-error`,role:`alert`,children:i(`setup.offer.keyRejected`)}):I(n$,{text:x})),I(CZ,{children:R(`button`,{type:`submit`,form:`setup-lemonade-form`,className:`btn-primary`,disabled:!!y||T===`external`&&h&&!p.trim(),children:[y&&I(B,{size:13,className:`spin`}),` `,i(`setup.continue`)]})})]})}function t$({problem:e,onRetry:t,onUseGaia:n}){let r=L(),i=e.kind===`server_too_old`&&e.use_gaia;return R(F.Fragment,{children:[e.start&&R(`details`,{className:`dl-details`,children:[I(`summary`,{children:r(`setup.server.howToStart`)}),I(`pre`,{dir:`ltr`,children:e.start})]}),R(CZ,{children:[I(`button`,{type:`button`,className:i?`btn-secondary`:`btn-primary`,onClick:t,children:r(`setup.tryAgain`)}),e.use_gaia&&I(`button`,{type:`button`,className:i?`btn-primary`:`btn-secondary`,onClick:n,children:r(`setup.server.useGaia`)})]}),e.use_gaia&&I(`p`,{className:`setup-hint`,children:r(`setup.server.useGaiaNote`)}),e.use_gaia&&e.env_url&&I(`p`,{className:`setup-hint`,children:r(`setup.server.envIgnoredNote`,{url:e.env_url})})]})}function n$({text:e}){let t=L();return R(`div`,{className:`setup-error`,role:`alert`,children:[I(`p`,{children:t(`setup.failedLead`)}),R(`details`,{className:`dl-details`,children:[I(`summary`,{children:t(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:e})]})]})}function r$({run:e}){let t=L();return e.problem?R(`div`,{className:`setup-error`,role:`alert`,children:[I(`p`,{children:t(e.problem.kind===`server_too_old`?`setup.server.tooOld`:`setup.server.unreachable`)}),R(`details`,{className:`dl-details`,children:[I(`summary`,{children:t(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:e.problem.message})]})]}):R(`div`,{className:`setup-error`,role:`alert`,children:[I(`p`,{children:t(e.components?.server===`failed`?`setup.server.ownFailed`:`setup.stopped`)}),e.error&&R(`details`,{className:`dl-details`,children:[I(`summary`,{children:t(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:e.error})]})]})}var i$=[`check`,`plan`,`key`,`models`,`gpu`,`download`,`test`,`ready`],a$=`gaia.setup.agentPick`,o$=`setup-agent-title`,s$=`gaia.setup.heldRun`,c$=`gaia.setup.queuedExtras`;function l$(){try{let e=localStorage.getItem(c$),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch(e){return console.warn(`[SetupScreen] could not read the extras added during setup; they show as Add again`,e),[]}}function u$(e){try{e.length?localStorage.setItem(c$,JSON.stringify(e)):localStorage.removeItem(c$)}catch(e){console.warn(`[SetupScreen] could not save the extras added during setup; a restart will forget them`,e)}}function d$(e){try{let t=sessionStorage.getItem(e);return t?JSON.parse(t):null}catch(t){return console.warn(`[SetupScreen] could not read ${e}; the agent pick starts fresh`,t),null}}function f$(e,t){try{t==null?sessionStorage.removeItem(e):sessionStorage.setItem(e,JSON.stringify(t))}catch(t){console.warn(`[SetupScreen] could not save ${e}; a reload will lose the agent pick`,t)}}function p$(e){return e instanceof Error?e.message:String(e)}function m$({onReady:e,onClose:t}){let n=L(),r=il(e=>e.refresh),i=il(e=>e.select),[a,o]=(0,V.useState)(`local`),[s,c]=(0,V.useState)(`check`),[l,u]=(0,V.useState)(!1),[d,f]=(0,V.useState)(`models`),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(()=>new Set([`check`])),y=(0,V.useRef)(`check`),[b,x]=(0,V.useState)(null),[S,C]=(0,V.useState)(null),[w,T]=(0,V.useState)(null),[E,ee]=(0,V.useState)(null),[D,O]=(0,V.useState)(null),[te,k]=(0,V.useState)(``),[A,j]=(0,V.useState)({busy:!1,error:null,done:!1}),[M,re]=(0,V.useState)(null),[ie,ae]=(0,V.useState)(null),[oe,se]=(0,V.useState)(null),[ce,ue]=(0,V.useState)(null),[de,fe]=(0,V.useState)(null),[pe,me]=(0,V.useState)(null),[he,ge]=(0,V.useState)(!0),[_e,ve]=(0,V.useState)(null),[ye,be]=(0,V.useState)(!1),[xe,Se]=(0,V.useState)(!1),[Ce,we]=(0,V.useState)(null),[N,Te]=(0,V.useState)(!1),[Ee,De]=(0,V.useState)(null),[Oe,Ae]=(0,V.useState)(null),[je,Me]=(0,V.useState)(null),[Ne,Pe]=(0,V.useState)(!1),[Fe,Ie]=(0,V.useState)([]),[Le,Re]=(0,V.useState)(l$);(0,V.useEffect)(()=>u$(Le),[Le]);let[ze,Be]=(0,V.useState)([]),[Ve,He]=(0,V.useState)(!1),[Ue,We]=(0,V.useState)(!1),Ge=(0,V.useRef)({gaiaLemonade:!1,options:{}}),Ke=(0,V.useRef)(null),qe=(0,V.useRef)(!1),Je=(0,V.useRef)(!1),[Ye,Ze]=(0,V.useState)(!1),[Qe,$e]=(0,V.useState)(!1),et=(0,V.useCallback)(()=>$e(!0),[]),[tt,nt]=(0,V.useState)(null),[rt,it]=(0,V.useState)(null),at=(0,V.useRef)(!0);(0,V.useEffect)(()=>(at.current=!0,()=>{at.current=!1}),[]);let{network:ot,providers:st,recheck:ct}=IZ(),lt=e=>st.find(t=>t.id===e),dt=lt(a),ft=dt?.key_source===`environment`&&dt.key_hint?dt:void 0,pt=e=>!!lt(e)?.blocked,mt=ot?.reachable!==!1||a===`amd`,ht=dt?.key_source===`stored`||dt?.key_source===`lemonade`,gt=pt(`fireworks`)&&pt(`amd`),vt=e=>pt(e)||e===`amd`&&ot?.reachable===!1,yt=e=>pt(e)?n(`settings.privacy.localOnlyBlocked`):n(`setup.key.gatewayOff`),bt=a!==`local`,P=w?.server_only?w:null,xt=w&&!w.server_only?w:null,St=w?.state===`running`||w?.state===`verifying`,Ct=xt?.state===`ready`,Tt=XZ(w),Et=!(xt?.models??[]).some(e=>e.state===`downloading`||e.state===`queued`)&&((xt?.tests?.length??0)>0||xt?.state===`verifying`),Dt=(0,V.useCallback)(()=>{C(null),bn().then(x).catch(e=>C(p$(e)))},[]),Ot=(0,V.useRef)(0),At=(0,V.useCallback)(async()=>{let e=++Ot.current;ae(null);try{let t=await Rn(!1);return e===Ot.current?(re(t),t):null}catch(t){return e===Ot.current&&ae(p$(t)),null}},[]),jt=(0,V.useCallback)(async()=>{try{let e=await Nt();at.current&&me(e??null)}catch(e){console.warn(`[SetupScreen] GPU memory could not be read; the step stays hidden`,e)}},[]),Mt=t!=null;(0,V.useEffect)(()=>{Xe().then(e=>He(e.source===`config`)).catch(e=>console.warn(`[SetupScreen] could not read which Lemonade GAIA uses`,e)),Dt(),At(),$t().then(e=>{e.state===`idle`&&!e.models?.length||Mt&&e.state!==`running`&&e.state!==`verifying`||(T(e),e.server_only||c(`download`),e.skip_chat_model&&o(ZQ()===`amd`?`amd`:`fireworks`))}).catch(e=>O(p$(e))).finally(()=>Ze(!0))},[Dt,At,Mt]),(0,V.useEffect)(()=>{M?.catalog&&M.lemonade.reachable&&(se(e=>e??UX(M)),jt(),!w&&M.catalog.some(e=>e.partial&&e.selected)&&Te(!0))},[M,jt,w]);let Pt=(0,V.useCallback)(()=>{Ke.current&&clearInterval(Ke.current),Ke.current=null},[]),Ft=(w?.models??[]).filter(e=>e.state===`failed`&&e.error_kind===`disk_full`).length;(0,V.useEffect)(()=>{Ft>0&&At()},[Ft,At]);let It=(0,V.useCallback)(async()=>{try{let e=await $t();if(ee(null),e.state===`idle`&&!e.models?.length){T(null),c(`plan`),We(!0),At();return}T(e)}catch(e){ee(p$(e))}},[At,n]);(0,V.useEffect)(()=>(!Tt&&!E||(Ke.current=setInterval(()=>{It()},YQ)),Pt),[Tt,E,It,Pt]),(0,V.useEffect)(()=>{P&&P.state===`ready`&&(Dt(),At())},[P,P?.state,Dt,At]),(0,V.useEffect)(()=>{Ct&&(Dt(),At().then(e=>{e&&fe(e)}),jt())},[Ct,Dt,At,jt]);let Lt=(0,V.useRef)(!1),zt=(0,V.useCallback)(async(e=!1,t={})=>{if(Lt.current)return!1;Lt.current=!0,O(null),we(null),Te(!1),We(!1);try{QQ(a),Ge.current={gaiaLemonade:e,options:t};let n=await Rt(bt,e,t);T(n),g(null);let r=t.extraModels??[];return r.length&&Be(e=>e.filter(e=>!r.includes(e))),t.serverOnly||c(`download`),e&&He(!1),!0}catch(e){let t=Xn(e);if(t)return ve({kind:`server`,detail:t,then:`run`}),!1;if(e instanceof On&&e.httpStatus===409){let e=await $t().catch(()=>null);if(e&&(e.state===`running`||e.state===`verifying`))return T(e),g(null),e.server_only||c(`download`),!0}return O(p$(e)),!1}finally{Lt.current=!1}},[a,bt]);(0,V.useEffect)(()=>{s===`check`&&Ye&&Qe&&M&&!M.lemonade.reachable&&!w&&!qe.current&&(qe.current=!0,zt(!1,{serverOnly:!0}))},[s,Ye,Qe,M,w,zt]);let Bt=!!(oe&&M?.catalog&&M.lemonade.reachable&&(b||S)),Vt=(0,V.useCallback)(()=>{let{gaiaLemonade:e,options:t}=Ge.current;zt(e,t)},[zt]),Ht=(0,V.useCallback)((e,t=M)=>{ue(t);let n=t&&oe&&!bt?eZ(t,oe):[];return zt(!1,{acknowledgeLowDisk:e,keepTrying:he,extraModels:n})},[M,oe,bt,he,zt]),[Ut,Wt]=(0,V.useState)(!1),[Gt,Kt]=(0,V.useState)(()=>d$(a$)),qt=(0,V.useCallback)(e=>{Kt(e),f$(a$,e)},[]),[Jt,Yt]=(0,V.useState)(()=>d$(s$)),Xt=(0,V.useCallback)(e=>{Yt(e),f$(s$,e)},[]),[Zt,Qt]=(0,V.useState)(null),[en,tn]=(0,V.useState)(!1),nn=(0,V.useCallback)(async(e,t,n)=>{if(Qt(null),t){tn(!0);try{await Pn({flagship_agent:t})}catch(e){Qt(p$(e));return}finally{tn(!1)}}qt(null),Xt(null),await Ht(e.acknowledgeLowDisk,n)},[Ht,qt,Xt]),rn=(0,V.useRef)(Gt);rn.current=Gt;let an=(0,V.useRef)(Jt);an.current=Jt;let on=(0,V.useRef)(nn);on.current=nn;let sn=bW(()=>{let e=rn.current;e&&qt({...e,download:!1}),e&&an.current&&on.current(an.current,e.id)}),cn=sn.start,ln=sn.follow,un=(0,V.useCallback)(async(e,t)=>{let n=rn.current;if(Xt(e),g(null),c(`download`),!n||!n.download){await nn(e,n?.id??null,t);return}Qt(null);let r;try{r=await ke()}catch(e){Qt(p$(e));return}r.programs.find(e=>e.id===n.id)?.installed?await nn(e,n.id,t):r.download.state===`downloading`?ln(r.download):cn()},[nn,Xt,ln,cn]),dn=(0,V.useCallback)(()=>{Xt(null),Qt(null),g(null),c(`models`)},[Xt]),fn=(0,V.useCallback)(()=>{Jt&&nn(Jt,null)},[Jt,nn]),pn=(0,V.useRef)(!1);(0,V.useEffect)(()=>{pn.current||(pn.current=!0,ke().then(e=>{let t=e.download.state===`downloading`;if(ln(e.download),!an.current)return;if(t){c(`download`);return}Xt(null);let n=rn.current;n&&e.programs.find(e=>e.id===n.id)?.installed&&qt({...n,download:!1})}).catch(e=>console.warn(`[SetupScreen] could not read the agent programs; the Agent card says so on Customize`,e)))},[ln,Xt,qt]);let mn=(0,V.useRef)(!1),hn=(0,V.useCallback)(async(e,t=ye)=>{if(!M||!oe||mn.current)return;we(null),Wt(e);let r=DX(M),i=bt?[]:ZX(r,oe).filter(e=>!e.downloaded||e.id===oe.defaultChat),a=i.find(MX);if(a){let e=a.id===oe.defaultChat?`setup.models.cantRun.chat`:`setup.models.cantRun.other`;we(n(e,{name:a.name,why:cZ(a,n)}))}else if(!bt&&!t&&i.length>0&&i.every(e=>e.need_gb!=null))ve({kind:`no_fit`,models:i});else{Se(!0),mn.current=!0;try{let n=M;if(!bt&&oe.defaultChat&&oe.defaultChat!==n.chat_model.id)try{n=await Fn(oe.defaultChat,t,!1)}catch(e){let t=Xn(e);if(t){ve({kind:`server`,detail:t,then:`chat`});return}throw e}if(!bt){await dQ();let e=zX(r,oe);e!==(n.vision_model??null)&&(n=await le(e,!1));for(let e of $X(n,oe))n=await kt(e.id,e.skipped,!1)}re(n),rn.current?await un({acknowledgeLowDisk:e},n):await Ht(e,n)}catch(e){we(p$(e))}finally{mn.current=!1,Se(!1)}}},[M,oe,bt,ye,Ht,un,n]),gn=(0,V.useCallback)(e=>{we(null),s===`download`?g(e===y.current?null:e):(g(null),c(e===`test`||e===`ready`?`download`:e))},[s]),_n=(0,V.useCallback)(()=>{h??o(`local`),gn(`plan`)},[gn,h]),vn=(0,V.useCallback)(()=>{St&&h!=null||(o(`local`),u(!0),gn(`models`))},[gn,St,h]),yn=(0,V.useRef)(!1),xn=(0,V.useCallback)(()=>{yn.current=!0,vn()},[vn]),[Sn,Cn]=(0,V.useState)(`local`),wn=il(e=>e.active?.remote&&e.active.provider!==`local`?e.active.provider:null),Tn=il(e=>e.active?.remote?e.active.model:null),En=(0,V.useCallback)(e=>{St&&h!=null||(u(!1),o(e),Cn(`cloud`),Ae(e===wn?Tn:null),gn(`key`))},[gn,St,h,wn,Tn]),Dn=(0,V.useCallback)(()=>En(ZQ()===`amd`?`amd`:`fireworks`),[En]),kn=(0,V.useCallback)(()=>{wn?En(wn):gn(`plan`)},[wn,En,gn]),An=!!pe?.applies,jn=(0,V.useCallback)(()=>{gn((h??s)===`gpu`?d:`plan`)},[d,gn,h,s]),Mn=(0,V.useCallback)(e=>{f(e),gn(`gpu`)},[gn]),Nn=(0,V.useRef)({prev:null,next:null});(0,V.useEffect)(()=>{let e=e=>{if(!e.altKey||_e||(e.target instanceof Element?e.target:null)?.closest(`input, textarea, select, [contenteditable="true"]`))return;let t=e.key===`ArrowLeft`?Nn.current.prev:e.key===`ArrowRight`?Nn.current.next:null;t&&(e.preventDefault(),gn(t))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[gn,_e]);let In=(0,V.useCallback)(async()=>{try{await ne(),await It()}catch(e){we(p$(e))}},[It]),Ln=(0,V.useCallback)(async(e,t)=>{we(null),Se(!0);try{t===`verify`&&await wt(e),t===`disk_full`&&At();try{T(await ut(e,{keepTrying:he}))}catch(t){let n=Xn(t);if(!n)throw t;ve({kind:`server`,detail:n,then:`retry`,id:e})}}catch(e){we(p$(e))}finally{Se(!1)}},[he,At]),zn=(0,V.useCallback)(async e=>{we(null),Se(!0);try{M?.catalog?.find(t=>t.id===e)?.planned&&re(await kt(e,!0,!1)),T(t=>t&&{...t,models:t.models?.map(t=>t.id===e?{...t,state:`skipped`}:t)});let{options:t}=Ge.current;return Ge.current.options={...t,extraModels:t.extraModels?.filter(t=>t!==e)},se(t=>t&&t.ticked.has(e)?GX(t,DX(M),e,!1):t),!0}catch(e){return we(p$(e)),!1}finally{Se(!1)}},[M]),Bn=(0,V.useCallback)(async e=>{for(let t of e)if(!await zn(t))return;Be(t=>[...t,...e.filter(e=>!t.includes(e))]),Vt()},[zn,Vt]),Vn=(0,V.useCallback)(async()=>{await In(),Vt()},[In,Vt]),Hn=(0,V.useCallback)(async()=>{if(!St){j({busy:!0,error:null,done:!1});try{await _r(a,{api_key:!Ve&&te||void 0},e=>j({busy:!0,error:null,done:!1,waiting:e}),()=>!at.current);let{models:e}=await Zn(a),t=Oe??je,r=t?e.find(e=>e.id===t):e.find(e=>e.rank===1)??e[0];if(!r)throw Error(t?n(`setup.key.modelNotOffered`,{model:hl(t)}):n(`setup.key.noModels`));await i(r.id),De(r.id),k(``),j({busy:!1,error:null,done:!0}),Ht(!1)}catch(e){j({busy:!1,error:p$(e),done:!1})}}},[a,te,Oe,je,i,Ve,Ht,n,St]),Un=(0,V.useCallback)(e=>{QQ(e),o(e),Ae(e===wn?Tn:null),Me(null),j({busy:!1,error:null,done:!1})},[wn,Tn]);(0,V.useEffect)(()=>{if(!Ct||Le.length===0||Je.current)return;let e=Le;Je.current=!0,(async()=>{let t=[];for(let n of e)try{T(await ut(n,{keepTrying:he}))}catch(e){t.push(n);let r=Xn(e);r?ve(e=>e??{kind:`server`,detail:r,then:`retry`,id:n}):O(p$(e))}Je.current=!1,Re(t=>t.filter(t=>!e.includes(t))),t.length&&Be(e=>[...e,...t.filter(t=>!e.includes(t))])})()},[Ct,Le,he]);let Wn=Ct&&Le.length===0,Gn=bt?Ee:xt?.chat_model??(M&&!M.decided_after_server?M.chat_model.id:null),Kn=(0,V.useCallback)(async t=>{we(null);try{!bt&&Gn&&await i(Gn),await r()}catch(e){we(p$(e));return}e(t)},[Gn,bt,e,r,i]);(0,V.useEffect)(()=>{Wn&&_t().then(e=>Ie(e.cards)).catch(e=>console.warn(`[SetupScreen] no first tasks to offer`,e))},[Wn]);let qn=(0,V.useMemo)(()=>{let e={};for(let t of M?.catalog??[])e[t.id]=t.name;return e},[M]),Jn=w?.state===`failed`||w?.state===`cancelled`,Yn=w?.state===`failed`||!!D||!!ie||!!S||!!E||!!Ce,Qn=Mt?Fe:Fe.filter(e=>e.skill!==`check-in`),$n=e=>e.state===`ready`||e.state===`skipped`||e.state===`verifying`||e.state===`unchecked`,er=xt&&(xt.state===`failed`||xt.state===`cancelled`)&&(xt.models??[]).length>0&&(xt.models??[]).every($n)&&!Tt,tr=e=>!!Ge.current.options.extraModels?.includes(e)||!!M?.catalog?.some(t=>t.id===e&&NX(t)),nr=xt&&Jn&&!Tt&&!er&&(xt.models??[]).every(e=>$n(e)||tr(e.id))?(xt.models??[]).filter(e=>!$n(e)).map(e=>e.id):[],rr=!!xt&&Jn&&!xt.problem&&Object.values(xt.components??{}).includes(`failed`),ir=DX(M),ar=oe?JX(ir,oe):[],or=M&&oe?XX(M,oe):null,sr=oe?ir.filter(e=>oe.ticked.has(e.id)&&e.downloaded).length:0,cr=ir.some(e=>e.downloaded),lr=Bt?sr===0?cr?`setup.check.ledeOthersOnPc`:`setup.check.ledeDone`:ar.length===0?`setup.check.ledeAllOnPc`:`setup.check.ledeSomeOnPc`:`setup.check.lede`,z=ir.find(e=>e.id===oe?.defaultChat),ur=!!b&&!b.compatible&&b.blockers.length>0,dr=Wn?`ready`:s===`download`&&Et?`test`:s;y.current=dr;let fr=h??dr;(0,V.useEffect)(()=>{v(e=>e.has(fr)?e:new Set(e).add(fr))},[fr]);let pr=(0,V.useRef)(!0);(0,V.useEffect)(()=>{if(pr.current){pr.current=!1;return}let e=document.querySelector(`.setup-scroll`);e&&(e.scrollTop=0);let t=yn.current&&fr===`models`?document.getElementById(o$):null;yn.current=!1,t?(t.scrollIntoView({block:`start`,behavior:nG()}),t.focus({preventScroll:!0})):document.getElementById(`setup-title`)?.focus({preventScroll:!0})},[fr]);let[mr,hr]=(0,V.useState)(null);(0,V.useEffect)(()=>{if(fr!==`plan`)return;let e=!0;return ke().then(t=>{e&&hr(t)}).catch(e=>console.warn(`[SetupScreen] could not read the agents; the plan leaves out the agent line`,e)),()=>{e=!1}},[fr]);let gr=mr?.programs.find(e=>e.id===`gaiacpp`),vr=Gt?.id??mr?.current,yr=!gr||!(gr.installed||gr.can_download)?null:vr===`gaiapy`?`setup.agent.gaiapy`:vr===`gaiacpp`?`setup.agent.gaiacpp`:null,br=[{id:`check`,label:n(`setup.check.title`),key:`setup.check.title`},{id:`plan`,label:n(`setup.plan.step`),key:`setup.plan.step`},{id:`download`,label:n(`setup.download.step`),key:`setup.download.step`},{id:`test`,label:n(`setup.test.step`),key:`setup.test.step`},{id:`ready`,label:n(`setup.ready.step`),key:`setup.ready.step`}],xr=e=>e===`models`||e===`key`?`plan`:e===`gpu`?d===`check`?`check`:`plan`:e,Sr=bt?`key`:l?`models`:`plan`,Cr=br.findIndex(e=>e.id===xr(dr)),wr=e=>e===`download`||e===`test`||e===`ready`,Tr=[];if(b){let e=[M?.system?.physical_memory?`${JA(M.system.physical_memory,null)} installed`:null,b.ram_gb==null?null:`${b.ram_gb} GB the OS can use`].filter(Boolean).join(`, `),t=b.disk_free_gb==null?null:`${Math.round(b.disk_free_gb)} GB free on disk`;Tr.push(`This PC: ${[b.gpu_name,b.npu_detected?`NPU`:null].filter(Boolean).join(`, `)||`no GPU reported`}`+[e,t].filter(Boolean).map(e=>`; ${e}`).join(``))}else S&&Tr.push(`Couldn't read this PC: ${S}`);tt&&(Tr.push(`Found your Lemonade${tt.version?` ${tt.version}`:``} at ${tt.url}`),Tr.push(rt===`external`?`You chose your own Lemonade`:rt===`gaia`?`You chose GAIA's own Lemonade`:`Waiting for you to choose which Lemonade GAIA uses`)),M&&(!tt||rt)?Tr.push(M.lemonade.reachable?`Model server answering at ${M.lemonade.url??`its address`}`:`No model server answering yet`):ie&&Tr.push(`Couldn't read the model list: ${ie}`);let Er=(e,t)=>t<=Cr||_.has(e)&&!wr(e),Dr=br.map((e,t)=>({id:e.id,label:e.label,status:t<Cr?`done`:t>Cr?`pending`:dr===`ready`?`done`:w?.state===`failed`&&(dr===`download`||dr===`test`||dr===`check`)?`failed`:St&&(dr===`download`||dr===`test`)?`active`:`current`,shown:e.id===xr(fr),onOpen:e.id!==xr(fr)&&Er(e.id,t)?()=>gn(e.id===`plan`?Sr:e.id):void 0})),Or=br.findIndex(e=>e.id===xr(fr)),kr=fr===`gpu`&&d===`check`?.5:i$.indexOf(fr),Ar=(0,V.useRef)(kr),jr=(0,V.useRef)(`forward`);Ar.current!==kr&&(jr.current=kr>Ar.current?`forward`:`back`,Ar.current=kr);let Mr=fr===`gpu`?d:fr===`models`||fr===`key`?`plan`:Or>0?br[Or-1].id===`plan`?Sr:br[Or-1].id:null,Nr=(fr!==`gpu`&&Or>=0&&Or<br.length-1&&Er(br[Or+1].id,Or+1)?br[Or+1].id:null)??(h==null?fr===`check`&&Bt?`plan`:fr===`gpu`?d:null:null);Nn.current={prev:Mr,next:Nr};let Pr=fr===`gpu`||fr===`models`||fr===`key`,Fr=h!=null&&St,Ir=[`server`];bt||Ir.push(`chat`),!bt&&oe&&FX(ir,oe)&&Ir.push(`vision`),oe&&ir.some(e=>kX(e)&&oe.ticked.has(e.id))&&Ir.push(`embedding`);for(let e of ir)oe&&NX(e)&&oe.ticked.has(e.id)&&!e.downloaded&&Ir.push(e.roles[0]);Ir.push(`agent`);let Lr=sn.job,Rr=Lr?.state===`failed`,zr=Jt?R(F.Fragment,{children:[Lr&&Lr.state!==`idle`&&Lr.state!==`done`&&R(`section`,{className:`setup-agent-download`,"aria-labelledby":`setup-agent-download-title`,children:[I(`h3`,{className:`mc-job-title`,id:`setup-agent-download-title`,children:n(`setup.agent.title`)}),I(SW,{job:Lr,name:Gt?.id??`gaiacpp`,onRetry:()=>void cn(),failedNote:n(`setup.agent.carryOnNote`,{name:Gt?.current??`gaiapy`}),interrupted:sn.interrupted})]}),Zt&&I(`p`,{className:`setup-error`,role:`alert`,children:n(`setup.agent.saveFailed`,{error:Zt})}),(en||!Lr&&!Zt)&&R(`p`,{className:`setup-hint`,role:`status`,children:[I(B,{size:13,className:`spin`,"aria-hidden":`true`}),` `,n(`setup.download.starting`)]}),M&&I(`section`,{className:`setup-card`,"aria-label":n(`setup.contents.title`),children:I(VZ,{plan:M,models:ar})}),R(CZ,{children:[(Rr||Zt)&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:fn,disabled:en,children:n(`setup.agent.carryOn`,{name:Gt?.current??`gaiapy`})}),Zt&&Jt&&I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void un(Jt),disabled:en,children:n(`setup.tryAgain`)}),!Rr&&!Zt&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:dn,disabled:en,children:n(`setup.progress.cancel`)})]})]}):null,Br=bt&&A.done&&Ee?R(`p`,{className:`setup-ok setup-key-accepted`,role:`status`,children:[I(ci,{size:14,"aria-hidden":`true`}),` `,n(`setup.key.accepted`,{model:hl(Ee)})]}):null,Vr=(xt?.models??[]).filter(e=>e.state!==`skipped`).map(e=>e.id),Hr=Ct?(xt?.models??[]).filter(e=>e.state===`downloading`||e.state===`queued`).map(e=>e.id):[],Ur=[...new Set([...ze,...Ct?(xt?.models??[]).filter(e=>e.state===`failed`).map(e=>e.id):[]])],Wr=oe&&!bt?ir.filter(e=>NX(e)&&!oe.ticked.has(e.id)&&!e.downloaded&&(PX(z)||!e.roles.includes(`image_creation`))):[],Gr=ir.find(e=>e.fit_code===`memory`&&e.chat_choice&&e.support===`verified`);return R(`main`,{className:`setup`,"aria-labelledby":`setup-title`,children:[I(LQ,{steps:Dr}),I(SZ,{value:p,children:R(`div`,{className:`setup-pane`,children:[I(`div`,{className:`setup-scroll`,children:R(`div`,{className:`setup-inner`,children:[Or>=0&&R(`nav`,{className:`setup-topnav`,"aria-label":n(`setup.nav.label`),children:[I(`button`,{type:`button`,className:`setup-arrow`,onClick:()=>Mr&&gn(Mr),disabled:!Mr,"aria-label":n(`setup.nav.prev`),children:I(mi,{size:16,"aria-hidden":`true`})}),I(`button`,{type:`button`,className:`setup-arrow`,onClick:()=>Nr&&gn(Nr),disabled:!Nr,"aria-label":n(`setup.nav.next`),children:I(gi,{size:16,"aria-hidden":`true`})}),I(`span`,{children:I(`bdi`,{children:n(`setup.nav.stepOf`,{n:String(Or+1),total:String(br.length)})})}),h!=null&&h!==dr&&I(`button`,{type:`button`,className:`link-btn`,onClick:()=>g(null),children:n.compose(e=>e(`setup.nav.toLive`,{step:e(br.find(e=>e.id===dr)?.key??`setup.download.step`)}))}),I(oQ,{})]}),N&&s!==`download`&&R(`div`,{className:`setup-banner`,role:`status`,children:[I(Ja,{size:14,"aria-hidden":`true`}),I(`span`,{children:n(`setup.resume.banner`)})]}),Ue&&s!==`download`&&I(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.interrupted`)}),R(`div`,{className:`setup-stage is-${jr.current}`,children:[fr===`check`&&R(F.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(Bt?`setup.check.headingDone`:`setup.check.heading`)}),I(`p`,{className:`setup-lede`,children:n(lr)}),I(IQ,{hardware:b,hardwareError:S,plan:M,serverRun:P,awaitingChoice:!!tt&&!Qe}),P?.state===`running`&&R(F.Fragment,{children:[I(eQ,{run:P,idle:n(`setup.check.serverWorking`),bar:!1}),I(CZ,{children:I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void In(),children:n(`setup.progress.cancel`)})})]}),Bt&&M&&I(EQ,{plan:M,hardware:b,onChangeMemory:An&&h==null?()=>Mn(`check`):void 0}),Bt&&h==null&&!(tt&&!Qe)&&I(CZ,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:kn,children:n(`setup.continue`)})}),P&&Jn&&R(F.Fragment,{children:[I(r$,{run:P}),P.problem?I(t$,{problem:P.problem,onRetry:()=>void zt(!1,{serverOnly:!0}),onUseGaia:()=>void zt(!0,{serverOnly:!0})}):I(CZ,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void zt(!!P.gaia_lemonade,{serverOnly:!0}),children:n(`setup.tryAgain`)})})]}),ie&&!M&&R(F.Fragment,{children:[I(n$,{text:ie}),R(CZ,{children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void zt(!1,{keepTrying:he}),children:n(`setup.models.useRecommended`)}),I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void At(),children:n(`setup.tryAgain`)})]}),I(`p`,{className:`setup-hint`,children:n(`setup.models.useRecommendedNote`)})]}),D&&I(n$,{text:D}),D&&!P&&M&&!M.lemonade.reachable&&I(CZ,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void zt(!1,{serverOnly:!0}),children:n(`setup.tryAgain`)})}),Ye&&M&&(!M.lemonade.reachable&&!P||Bt&&h==null&&M.lemonade.mode!==`external`)&&I(e$,{onNothingToOffer:et,canInstallOwn:!M.lemonade.reachable&&!P,onFound:nt,onChosen:e=>{He(e===`external`),it(e),$e(!0),Dt(),At()}})]}),fr===`plan`&&M&&oe&&R(F.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.plan.title`)}),I(`p`,{className:`setup-lede`,children:n(`setup.plan.lede`)}),R(`div`,{className:`setup-where`,children:[R(`section`,{className:`setup-hero setup-where-card${Sn===`local`?` is-active`:``}`,"aria-label":n(`setup.plan.label`),onClick:()=>!Fr&&Cn(`local`),children:[I(`p`,{className:`setup-eyebrow`,children:oe.chatChosen?n(`setup.plan.yours`):n(`setup.plan.recommended`)}),R(`p`,{className:`setup-hero-title`,children:[I(`input`,{type:`radio`,name:`setup-where`,checked:Sn===`local`,onChange:()=>Cn(`local`),disabled:Fr,"aria-labelledby":`setup-where-local`}),I(`bdi`,{id:`setup-where-local`,children:n(`setup.plan.run`,{name:z?.name??``})})]}),R(`dl`,{className:`setup-facts`,children:[R(`div`,{children:[I(`dt`,{children:n(`setup.summary.download`)}),I(`dd`,{children:I(`bdi`,{dir:`ltr`,children:GA(YX(M,oe).downloadGb??0)})})]}),R(`div`,{children:[I(`dt`,{children:n(`setup.plan.runsOn`)}),I(`dd`,{children:I(`bdi`,{children:z&&AX(z)?n(`setup.checks.npu`):b?.gpu_name??n(`setup.plan.cpu`)})})]}),R(`div`,{children:[I(`dt`,{children:n(`setup.plan.diskAfter`)}),I(`dd`,{children:I(`bdi`,{dir:`ltr`,children:YX(M,oe).afterGb==null?`—`:GA(Math.max(0,YX(M,oe).afterGb))})})]})]}),R(`ul`,{className:`setup-reasons`,children:[!oe.chatChosen&&I(`li`,{children:n(`setup.plan.why.evaluated`)}),!oe.chatChosen&&M.left_for_apps_gb!=null&&I(`li`,{children:n(`setup.plan.why.headroom`,{left:YA(M.left_for_apps_gb)})}),z&&(z.fits===!1||z.fits===!0&&z.tight)&&I(`li`,{role:`note`,children:cZ(z,n)}),z?.need_gb!=null&&z.capacity_gb!=null&&z.fits&&!z.tight&&I(`li`,{children:n(`setup.plan.why.fits`,{need:YA(z.need_gb),have:YA(z.capacity_gb)})}),I(`li`,{children:n(`setup.plan.why.private`)}),jX(z)&&I(`li`,{children:n(`setup.plan.why.noImagesNpu`)}),Gr&&Gr.id!==z?.id&&Gr.need_gb!=null&&Gr.capacity_gb!=null&&z?.fits!==!1&&!z?.tight&&I(`li`,{children:n(`setup.plan.why.bigger`,{name:Gr.name,need:YA(Gr.need_gb),have:YA(Gr.capacity_gb)})})]}),yr&&R(`p`,{className:`setup-agent-line`,children:[n.compose(e=>e(`setup.plan.agent`,{name:e(yr)})),I(`span`,{"aria-hidden":`true`,children:` · `}),I(`button`,{type:`button`,className:`link-btn`,onClick:xn,disabled:xe||Fr,"aria-label":n(`setup.plan.agentChangeAria`),children:n(`setup.plan.agentChange`)})]}),ar.length>0&&I(`p`,{className:`setup-hint`,children:n(`setup.plan.cancelAnytime`)})]}),R(`section`,{className:`setup-hero setup-where-card${Sn===`cloud`?` is-active`:``}${gt?` is-disabled`:``}`,"aria-label":n(`setup.plan.cloudLabel`),onClick:()=>!Fr&&!gt&&Cn(`cloud`),children:[R(`p`,{className:`setup-hero-title`,children:[I(`input`,{type:`radio`,name:`setup-where`,checked:Sn===`cloud`,onChange:()=>Cn(`cloud`),disabled:Fr||gt,"aria-labelledby":`setup-where-cloud`}),I(`span`,{id:`setup-where-cloud`,children:n(`setup.plan.cloud`)})]}),gt?I(`p`,{className:`setup-hint`,children:n(`settings.privacy.localOnlyBlocked`)}):R(`ul`,{className:`setup-reasons`,children:[I(`li`,{children:n(`setup.plan.cloudWhy.stillLocal`)}),I(`li`,{children:n(`setup.plan.cloudWhy.key`)}),I(`li`,{children:n(`setup.plan.cloudWhy.sent`)})]})]})]}),R(CZ,{children:[Sn!==`cloud`&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:vn,disabled:xe||Fr,children:n(`setup.plan.customize`)}),Sn===`cloud`?I(`button`,{type:`button`,className:`btn-primary`,onClick:Dn,disabled:Fr,children:n(`setup.continue`)}):R(`button`,{type:`button`,className:`btn-primary`,onClick:()=>or?ve({kind:`low_disk`}):void hn(!1),disabled:xe||ur||Fr,children:[xe&&I(B,{size:13,className:`spin`,"aria-hidden":`true`}),` `,ar.length?n(`setup.plan.start`):n(`setup.plan.startNoDownload`)]})]}),t&&I(`div`,{className:`setup-row`,children:I(`button`,{type:`button`,className:`link-btn`,onClick:t,children:n(`setup.backToGaia`)})}),ur&&R(`div`,{className:`setup-error`,role:`alert`,children:[I(`p`,{children:n(`setup.blocked`)}),R(`details`,{className:`dl-details`,children:[I(`summary`,{children:n(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:b?.blockers.join(`
216
+ `)})]})]}),or&&I(`p`,{className:`setup-error`,role:`alert`,children:n(`setup.summary.short`,{need:GA(or.needGb),free:GA(or.freeGb),drive:n(`setup.summary.theDrive`),freeUp:GA(or.freeUpGb)})}),(Ce??D)&&I(n$,{text:Ce??D}),Sn!==`cloud`&&R(`details`,{className:`setup-disclosure`,children:[I(`summary`,{children:n(`setup.plan.whatDownloads`)}),I(VZ,{plan:M,models:ar})]})]}),fr===`gpu`&&pe&&R(F.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.gpu.title`)}),I(`p`,{className:`setup-lede`,children:n(`setup.gpu.lede`)}),I(NZ,{status:pe,onStatus:me,mode:`setup`,headingId:`setup-title`,names:qn,cloud:a!==`local`,onBack:jn,onSkip:()=>gn(d),onContinue:()=>gn(d)})]}),fr===`models`&&R(F.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.models.title`)}),M&&oe&&I(fQ,{plan:M,selection:oe,onSelection:se,disabled:xe||Fr,onRecheck:()=>void At()}),An&&pe?.total_gb!=null&&pe.gpu_gb!=null&&R(`p`,{className:`setup-hint setup-gpu-option`,children:[n(`setup.models.gpu`,{gpu:GA(pe.gpu_gb),total:GA(pe.total_gb)}),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>Mn(`models`),disabled:xe||Fr,children:n(`setup.found.changeMemory`)})]}),I(kW,{disabled:xe||Fr,pending:Gt?.id??null,onPending:qt,headingId:o$}),I(PZ,{plan:M,planError:ie,onRetryPlan:()=>void At(),onUseRecommended:()=>void zt(!1,{keepTrying:he}),selection:oe,onSelection:se,cloud:!1,keepTrying:he,onKeepTrying:ge,onBack:jn,onContinue:e=>void hn(e),busy:xe||Fr,error:Ce??D})]}),fr===`key`&&R(`form`,{id:`setup-key-form`,onSubmit:e=>{e.preventDefault(),Hn()},className:`setup-form`,children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.key.title`)}),I(sF,{className:`setup-choices`,"aria-label":n(`setup.key.provider`),children:qQ.filter(e=>e.id!==`local`&&(e.id!==`amd`||mt)).map(e=>R(`button`,{type:`button`,role:`radio`,"aria-checked":a===e.id,className:`setup-choice${a===e.id?` is-active`:``}${vt(e.id)?` is-disabled`:``}`,onClick:()=>Un(e.id),disabled:A.busy||vt(e.id),title:pt(e.id)?n(`settings.privacy.localOnlyBlocked`):void 0,children:[I(Pi,{size:16,"aria-hidden":`true`}),R(`span`,{children:[I(`span`,{className:`setup-choice-title`,children:I(`bdi`,{children:JQ(e,n)})}),I(`span`,{className:`setup-choice-note`,children:vt(e.id)?yt(e.id):n(e.note)})]})]},e.id))}),ot?.reachable===!1&&mt&&I(`button`,{type:`button`,className:`link-btn setup-start`,onClick:ct,children:n(`setup.key.checkAgain`)}),pt(a)&&I(`p`,{className:`setup-a11y-alert`,role:`alert`,children:n(`settings.privacy.localOnlyBlocked`)}),a===`fireworks`&&!Ve&&!pt(a)&&R(`section`,{className:`setup-card`,children:[I(`h3`,{className:`mc-job-title`,children:n(`setup.key.getOne`)}),R(`ol`,{className:`setup-key-steps`,children:[I(`li`,{children:I(`a`,{href:GQ,target:`_blank`,rel:`noreferrer`,children:n(`setup.key.step1`)})}),I(`li`,{children:n(`setup.key.step2`)}),I(`li`,{children:n(`setup.key.step3`)})]})]}),a===`amd`&&!Ve&&!pt(a)&&I(`section`,{className:`setup-card`,children:I(`p`,{className:`setup-hint`,children:I(`a`,{href:KQ,target:`_blank`,rel:`noreferrer`,children:n(`setup.key.gatewayHelp`)})})}),!pt(a)&&I(bX,{provider:a,limit:3,picked:Oe,onPick:Ae,onDefault:Me,pickDisabled:A.busy||Fr}),!Ve&&R(F.Fragment,{children:[I(`label`,{className:`setup-key-label`,htmlFor:`setup-key-input`,children:n(`setup.key.labelFor`,{provider:JQ(qQ.find(e=>e.id===a)??qQ[1],n)})}),R(`div`,{className:`setup-row setup-key-row`,children:[I(`input`,{id:`setup-key-input`,className:`settings-input`,type:Ne?`text`:`password`,autoComplete:`off`,spellCheck:!1,value:te,onChange:e=>k(e.target.value),placeholder:ht?n.bare(`setup.key.placeholder`):n.bare(`setup.key.placeholderNew`)}),I(`button`,{type:`button`,className:`btn-secondary setup-key-show`,"aria-label":n(Ne?`setup.key.hide`:`setup.key.show`),title:n(Ne?`setup.key.hide`:`setup.key.show`),onClick:()=>Pe(e=>!e),children:I(Ne?ia:oa,{size:14,"aria-hidden":`true`})})]})]}),I(`p`,{className:`setup-hint`,children:n(Ve?`setup.key.usersServer`:`setup.key.where`)}),ft&&!Ve&&!te&&I(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.key.foundEnv`,{name:ft.name,hint:ft.key_hint??``})}),A.busy&&!A.waiting&&I(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.key.testing`)}),A.busy&&A.waiting&&I(`p`,{className:`setup-hint`,role:`status`,children:A.waiting}),A.error&&I(`p`,{className:`setup-error`,role:`alert`,children:A.error}),R(CZ,{children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:_n,disabled:A.busy,children:n(`setup.back`)}),R(`button`,{type:`submit`,form:`setup-key-form`,className:`btn-primary`,disabled:A.busy||vt(a)||Fr,children:[A.busy&&I(B,{size:13,className:`spin`}),` `,n(`setup.key.connect`)]})]})]}),fr===`download`&&!xt&&R(F.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.download.title`)}),I(`p`,{className:`setup-lede`,children:n(`setup.download.lede`)}),Br,zr??R(`p`,{className:`setup-hint`,role:`status`,children:[I(B,{size:13,className:`spin`,"aria-hidden":`true`}),` `,n(`setup.download.starting`)]})]}),fr===`download`&&xt&&R(F.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.download.title`)}),I(`p`,{className:`setup-lede`,children:n(`setup.download.lede`)}),Br,M&&I(`section`,{className:`setup-card`,"aria-label":n(`setup.contents.title`),children:I(VZ,{plan:M,run:xt,onRetry:Vt,retryDisabled:xe})}),(xt.models?.length??0)>0?I(`div`,{className:E?`is-stale`:void 0,children:I($Z,{status:{...xt,overall:tZ(xt,ce??M)},names:qn,freeGb:M?.disk?.free_gb??null,onCancel:()=>void In(),onRetry:(e,t)=>void Ln(e,t),onResume:e=>void Ln(e,null),onResumeAll:Vt,onFinishWithout:nr.length>0&&!rr?()=>void Bn(nr):void 0,onSkip:e=>void zn(e),onRestart:()=>void Vn(),busy:xe||!!E,retryLater:St,labelledBy:`setup-title`})}):St?R(F.Fragment,{children:[I(eQ,{run:xt,plan:M,idle:n(`setup.download.working`)}),I(CZ,{children:I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void In(),disabled:xe,children:n(`setup.progress.cancel`)})})]}):null,Wr.length>0&&R(`section`,{className:`setup-card`,"aria-label":n(`setup.optional.title`),children:[I(`h3`,{className:`mc-job-title`,children:n(`setup.optional.title`)}),I(`p`,{className:`setup-hint`,children:n(`setup.optional.lede`)}),I(`ul`,{className:`setup-rows`,children:Wr.map(e=>{let t=Le.includes(e.id)||Vr.includes(e.id);return R(`li`,{className:`setup-result is-waiting`,children:[I(`span`,{className:`setup-result-label`,children:n(`setup.purpose.${e.roles[0]}`)}),R(`span`,{className:`setup-result-value`,children:[I(`bdi`,{dir:`ltr`,children:e.size_gb==null?n(`setup.contents.sizeOnDownload`):GA(e.size_gb)}),I(`button`,{type:`button`,className:`btn-secondary`,"aria-pressed":t,disabled:Vr.includes(e.id),onClick:()=>Re(n=>t?n.filter(t=>t!==e.id):[...n,e.id]),children:n(t?`setup.optional.added`:`setup.optional.add`)})]})]},e.id)})})]}),E&&R(F.Fragment,{children:[I(`p`,{className:`setup-error`,role:`alert`,children:n(`setup.lostContact`,{error:E})}),I(CZ,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void It(),children:n(`setup.reconnect`)})})]}),Jn&&er&&!rr&&xt.state===`failed`&&!xt.model_failed&&(xt.problem?I(t$,{problem:xt.problem,onRetry:Vt,onUseGaia:()=>void zt(!0,Ge.current.options)}):R(`div`,{className:`setup-error`,role:`alert`,children:[I(`p`,{children:n(`setup.download.stoppedBeforeCheck`)}),xt.error&&R(`details`,{className:`dl-details`,children:[I(`summary`,{children:n(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:xt.error})]})]})),Jn&&er&&!rr&&R(F.Fragment,{children:[I(`p`,{className:`setup-hint`,children:n(`setup.download.finishNote`)}),I(CZ,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:Vt,disabled:xe,children:n(`setup.finish`)})})]}),nr.length>0&&!rr&&I(`p`,{className:`setup-hint`,children:n(`setup.download.extrasLeftNote`,{names:nr.map(e=>qn[e]??e).join(`, `)})}),Jn&&!er&&!rr&&!(xt.models??[]).some(e=>e.state===`failed`||e.state===`cancelled`)&&R(F.Fragment,{children:[I(r$,{run:xt}),xt.problem?I(t$,{problem:xt.problem,onRetry:Vt,onUseGaia:()=>void zt(!0,Ge.current.options)}):I(CZ,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void zt(!!xt.gaia_lemonade,Ge.current.options),children:n(`setup.tryAgain`)})})]}),(Ce||D)&&I(n$,{text:Ce??D})]}),fr===`test`&&xt&&R(F.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.test.title`)}),I(`p`,{className:`setup-lede`,children:n(`setup.test.lede`)}),I(WQ,{run:xt,expected:Ir,names:qn,catalog:ir,onRetry:Vt,onChooseAnother:bt?void 0:vn,onCancel:()=>void In(),onDownloadAgain:M?.lemonade.mode===`external`?void 0:e=>void Ln(e,`verify`),busy:xe}),Jn&&xt.error&&!(xt.tests??[]).some(e=>e.error===xt.error)&&R(`details`,{className:`dl-details`,children:[I(`summary`,{children:n(`setup.progress.details`)}),I(`pre`,{dir:`ltr`,children:xt.error})]}),(Ce||D)&&I(n$,{text:Ce??D})]}),fr===`ready`&&R(F.Fragment,{children:[I(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.ready.heading`)}),R(`div`,{className:`setup-done`,role:`status`,children:[I(`div`,{className:`setup-done-head`,children:Gn&&I(`p`,{children:n(bt?`setup.ready.answersCloud`:`setup.ready.answersLocal`,{model:bt?cl(Gn):qn[Gn]??de?.catalog?.find(e=>e.id===Gn)?.name??cl(Gn)})})}),I(CZ,{children:I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Kn(),autoFocus:!0,children:n(`setup.ready.start`)})}),!bt&&de&&I(FZ,{plan:de,chatModel:Gn,gpu:pe}),D&&I(n$,{text:D}),(xt?.tests??[]).filter(e=>e.state===`failed`).map(e=>I(`p`,{className:`setup-failed-extra`,role:`alert`,children:n(`setup.ready.extraFailed`,{job:n(`setup.test.job.${e.job}`)})},`${e.job}:${e.subject??``}`)),Hr.length>0&&I(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.ready.extraDownloading`,{names:Hr.map(e=>qn[e]??e).join(`, `)})}),Ur.length>0&&!_e&&I(`p`,{className:`setup-failed-extra`,role:`alert`,children:n(`setup.ready.extraNotFetched`,{names:Ur.map(e=>qn[e]??e).join(`, `)})}),Qn.length>0&&R(F.Fragment,{children:[I(`p`,{className:`setup-hint`,children:n(`setup.ready.tasks`)}),I(PY,{cards:Qn,onPick:e=>void Kn(e)})]})]})]}),w?.state===`failed`&&I(PQ,{})]},fr),t&&!St&&fr!==`plan`&&fr!==`ready`&&I(`div`,{className:`setup-row`,children:I(`button`,{type:`button`,className:`link-btn setup-close`,onClick:t,children:n(`setup.backToGaia`)})}),Fr&&(Pr||fr===`plan`)&&I(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.nav.runGoing`)}),I(aQ,{run:w,before:{check:Tr},failed:Yn})]})}),I(`div`,{className:`setup-footer`,ref:m})]})}),_e?.kind===`no_fit`&&I(wZ,{title:QX(_e.models)?n(`setup.confirm.tightOne`,{name:_e.models[0].name}):_e.models.length===1?n(`setup.confirm.noFitOne`,{name:_e.models[0].name}):n(`setup.confirm.noFitMany`),confirmLabel:QX(_e.models)?n(`setup.confirm.useAnyway`):n(`setup.confirm.downloadAnyway`),cancelLabel:n(`setup.confirm.pickSmaller`),onConfirm:()=>{ve(null),be(!0),hn(Ut,!0)},onCancel:()=>ve(null),children:_e.models.map(e=>R(`p`,{children:[I(`bdi`,{children:e.name}),`: `,cZ(e,n)]},e.id))}),_e?.kind===`low_disk`&&or&&I(wZ,{title:n(`setup.confirm.lowDiskTitle`),confirmLabel:n(`setup.confirm.downloadAnyway`),cancelLabel:n(`setup.confirm.changeModels`),onConfirm:()=>{ve(null),hn(!0)},onCancel:()=>{ve(null),vn()},children:I(`p`,{children:n(`setup.summary.short`,{need:GA(or.needGb),free:GA(or.freeGb),drive:n(`setup.summary.theDrive`),freeUp:GA(or.freeUpGb)})})}),_e?.kind===`server`&&I(wZ,{title:_e.detail.code===`low_disk`?n(`setup.confirm.lowDiskTitle`):n(`setup.confirm.noFitServerTitle`),confirmLabel:_e.detail.code===`low_disk`?n(`setup.confirm.downloadAnyway`):n(`setup.confirm.useAnyway`),cancelLabel:n(`setup.confirm.changeModels`),onConfirm:()=>{let e=_e;if(ve(null),e.then===`chat`)be(!0),hn(Ut,!0);else if(e.then===`retry`)ut(e.id,{keepTrying:he,acknowledgeLowDisk:!0}).then(t=>{T(t),Be(t=>t.filter(t=>t!==e.id))}).catch(e=>we(p$(e)));else{let{gaiaLemonade:e,options:t}=Ge.current;zt(e,{...t,acknowledgeLowDisk:!0})}},onCancel:()=>{let e=_e;ve(null),e.then!==`retry`&&!Ct&&vn()},children:I(`p`,{children:_e.detail.message})})]})}function h$({title:e,titleId:t,count:n,hint:r,defaultOpen:i=!1,forceOpen:a=!1,targetId:o,children:s}){let[c,l]=(0,V.useState)(i);return R(`details`,{className:`settings-disclosure`,"data-settings-target":o,open:c||a,onToggle:e=>{a||l(e.currentTarget.open)},children:[R(`summary`,{onClick:e=>{a&&e.preventDefault()},children:[I(fi,{size:15,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),R(`span`,{className:`settings-disclosure-text`,children:[I(`span`,{className:`settings-disclosure-title`,id:t,tabIndex:t?-1:void 0,children:e}),r&&I(`span`,{className:`settings-disclosure-hint`,children:r})]}),n!=null&&I(`bdi`,{dir:`ltr`,className:`settings-disclosure-count`,children:n})]}),I(`div`,{className:`settings-disclosure-body`,children:s})]})}var g$=de(Vu()?`settings.desktop.menuBar`:`settings.desktop.tray`),_$=[{key:`minimizeToTray`,label:`settings.desktop.keepRunning`,hint:`settings.desktop.keepRunningHint`},{key:`startOnLogin`,label:`settings.desktop.startOnLogin`,hint:`settings.desktop.startOnLoginHint`},{key:`startMinimized`,label:`settings.desktop.startMinimized`,hint:`settings.desktop.startMinimizedHint`}],v$=new Set([`startMinimized`]),y$={minimizeToTray:`settings.desktop.keepRunningNoTray`};function b$(e){return e?.reason===`no-host`?`settings.desktop.noTray`:e?.reason===`check-failed`?`settings.desktop.noTrayCheckFailed`:null}function x$(){let e=L(),t=window.gaiaAPI?.tray,[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(null);(0,V.useEffect)(()=>{t&&t.getConfig().then(e=>{r(e.tray),a(e.host)}).catch(t=>s(e(`settings.desktop.readFailed`,{reason:t instanceof Error?t.message:String(t)})))},[t,e]);let u=(0,V.useCallback)(async e=>{if(t&&n&&c===null){l(e),s(null);try{let i=await t.setConfig({tray:{[e]:!n[e]}});r(i.tray),a(i.host)}catch(e){s(e instanceof Error?e.message:String(e))}finally{l(null)}}},[t,n,c]);if(!t)return null;let d=b$(i);return I(h$,{title:e(`settings.desktop.title`),children:R(`div`,{className:`settings-field`,role:`group`,"aria-labelledby":`desktop-app-label`,children:[I(`span`,{className:`settings-label`,id:`desktop-app-label`,children:e(`settings.desktop.title`)}),_$.map(({key:t,label:r,hint:i})=>{let a=v$.has(t)?d:null,o=d&&y$[t]||i;return R(`div`,{children:[R(`label`,{className:`setting-row`,children:[I(`span`,{children:e(r,{tray:g$})}),R(`span`,{className:`toggle-switch`,children:[I(`input`,{id:`desktop-${t}`,type:`checkbox`,role:`switch`,checked:!a&&!!n?.[t],"aria-describedby":`desktop-${t}-hint`,onChange:()=>void u(t),disabled:!!a||!n||c!==null&&c!==t,"aria-busy":c===t,"aria-label":e(r,{tray:g$})}),I(`span`,{className:`toggle-track`})]})]}),I(`p`,{className:`settings-hint`,id:`desktop-${t}-hint`,children:a?e(a):e(o,{tray:g$})})]},t)}),o&&I(`p`,{className:`settings-error`,role:`alert`,children:o})]})})}function S$({onClose:e,manualInstall:t=!1}){let n=L(),[r,i]=(0,V.useState)({kind:`loading`}),a=(0,V.useRef)(null);(0,V.useEffect)(()=>{let e=DQ();e?e.listReleases().then(e=>{i(Array.isArray(e)?{kind:`list`,releases:e}:{kind:`error`,message:e.error})}).catch(()=>{i({kind:`error`,message:`Couldn't reach GitHub to list releases — check your connection; you can still download installers from the Releases page.`})}):i({kind:`error`,message:`Couldn't reach GitHub to list releases — check your connection; you can still download installers from the Releases page.`})},[]),er(!0,e),yn(a,!0),(0,V.useEffect)(()=>{let e=a.current;e&&e.querySelector(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)?.focus()},[]),(0,V.useEffect)(()=>{let e=a.current;if(!e)return;function t(t){if(t.key!==`Tab`||!e)return;let n=e.querySelectorAll(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);if(n.length===0)return;let r=n[0],i=n[n.length-1];t.shiftKey?document.activeElement===r&&(t.preventDefault(),i?.focus()):document.activeElement===i&&(t.preventDefault(),r?.focus())}return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[]);function o(e,t){e.isCurrent||i({kind:`confirm`,release:e,releases:t})}async function s(t){i({kind:`installing`});let r=DQ();if(!r)i({kind:`error`,message:n(`update.picker.noBridge`)});else try{await r.installVersion(t.tag),e()}catch(e){i({kind:`error`,message:n(`update.picker.failed`,{reason:MQ(e)})})}}function c(e){if(!e)return``;try{return new Date(e).toLocaleDateString(Ln(n),{year:`numeric`,month:`short`,day:`numeric`})}catch{return e}}return I(`div`,{className:`version-picker-overlay`,onClick:t=>{t.target===t.currentTarget&&e()},children:R(`div`,{className:`version-picker-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":n(`update.picker.title`),ref:a,children:[R(`div`,{className:`version-picker-header`,children:[I(`h3`,{children:n(`update.picker.title`)}),I(`button`,{className:`version-picker-close`,onClick:e,"aria-label":n(`update.picker.close`),type:`button`,children:`×`})]}),R(`div`,{className:`version-picker-body`,children:[r.kind===`loading`&&R(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[I(`span`,{className:`version-picker-spinner`}),n(`update.picker.loading`)]}),r.kind===`error`&&R(`div`,{className:`version-picker-error`,children:[I(`p`,{children:r.message}),I(`p`,{children:I(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:n(`update.picker.browse`)})})]}),r.kind===`list`&&I(`ul`,{className:`version-picker-list`,role:`listbox`,"aria-label":n(`update.picker.listAria`),children:r.releases.map(e=>I(`li`,{children:R(`button`,{type:`button`,className:`version-picker-row`,"data-version":e.version,"aria-label":e.isCurrent?n(`update.picker.rowInstalled`,{version:e.version}):e.isPinned?n(`update.picker.rowPinned`,{version:e.version}):e.version,"aria-disabled":e.isCurrent?`true`:`false`,onClick:()=>o(e,r.releases),disabled:e.isCurrent,children:[I(`span`,{className:`vp-version`,children:e.version}),I(`span`,{className:`vp-date`,children:c(e.date)}),e.isCurrent&&I(`span`,{className:`vp-badge vp-badge-current`,children:n(`update.picker.installed`)}),e.isPinned&&!e.isCurrent&&I(`span`,{className:`vp-badge vp-badge-pinned`,children:n(`update.picker.pinned`)}),!e.isCurrent&&I(`span`,{className:`vp-arrow`,"aria-hidden":`true`,children:`›`})]})},e.tag))}),r.kind===`list`&&R(`p`,{className:`version-picker-more`,children:[n(`update.picker.recent`,{n:r.releases.length}),` `,I(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:n(`update.picker.browseAll`)})]}),r.kind===`confirm`&&R(`div`,{className:`version-picker-confirm`,children:[t?I(`p`,{children:n(`update.picker.manual`,{version:r.release.version})}):R(F.Fragment,{children:[I(`p`,{children:n(`update.picker.confirm`,{version:r.release.version})}),I(`p`,{className:`vp-confirm-note`,children:n(`update.picker.confirmNote`,{version:r.release.version})})]}),R(`div`,{className:`vp-confirm-actions`,children:[I(`button`,{type:`button`,className:`vp-btn-cancel`,onClick:()=>i({kind:`list`,releases:r.releases}),children:n(`update.picker.back`)}),t?I(`a`,{className:`vp-btn-confirm`,href:r.release.notesUrl??`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noopener noreferrer`,children:n(`update.picker.openRelease`)}):I(`button`,{type:`button`,className:`vp-btn-confirm`,onClick:()=>s(r.release),children:n(`update.picker.install`)})]})]}),r.kind===`installing`&&R(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[I(`span`,{className:`version-picker-spinner`}),n(`update.picker.starting`)]})]})]})})}var C$=`https://github.com/amd/gaia/releases`;function w$(e){return/^\d+\.\d+\.\d+-/.test(e??``)}function T$(e,t){let n=e.version??``;if(e.readFailed)return t(`update.status.readFailed`);switch(e.status){case`checking`:return t(`update.status.checking`);case`available`:return t(`update.status.available`,{version:n});case`downloading`:return e.preparing?t(`update.status.preparing`,{version:n}):t(`update.status.downloading`,{version:n,pct:e.progress});case`downloaded`:return t(`update.status.downloaded`,{version:n});case`error`:return t(`update.status.error`,{reason:e.error??t(`update.status.unknownError`)});case`no-channel`:return e.error??t(`update.status.noChannel`);case`disabled`:return t(`update.status.disabled`);default:return t(`update.status.upToDate`)}}function E$(){let e=kQ(),t=L(),n=DQ(),[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(!1);if(!n)return null;async function l(e,r){if(n){i(!0),o(null);try{await r(n)}catch(n){P.system.error(`${e} failed`,n),o(t(`update.settings.failed`,{action:de(e),reason:MQ(n)}))}finally{i(!1)}}}let u=e.status===`disabled`,d=r||e.status===`checking`||e.status===`downloading`,f=e.readFailed?T$(e,t):`${t(`update.settings.running`,{version:e.currentVersion??t(`update.settings.unknownVersion`)})} ${T$(e,t)}`,p=[`available`,`downloaded`,`error`].includes(e.status)||!!e.pinnedVersion||!!e.installFailed||!!e.configError||!!e.readFailed||!!a;return I(h$,{title:t(`update.settings.title`),titleId:`updates-label`,hint:f,forceOpen:p,children:R(`div`,{className:`settings-field`,role:`group`,"aria-labelledby":`updates-label`,children:[I(`p`,{className:`visually-hidden`,role:`status`,children:f}),!e.manualInstall&&R(F.Fragment,{children:[R(`label`,{className:`setting-row`,children:[I(`span`,{children:t(`update.settings.auto`)}),R(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,role:`switch`,checked:e.autoUpdate,"aria-describedby":`updates-auto-hint`,"aria-label":t(`update.settings.auto`),"aria-busy":r,disabled:u,onChange:()=>{r||l(`update.action.saveAuto`,t=>t.setAutoUpdate(!e.autoUpdate))}}),I(`span`,{className:`toggle-track`})]})]}),I(`p`,{className:`settings-hint`,id:`updates-auto-hint`,children:t(`update.settings.autoHint`)})]}),R(`label`,{className:`setting-row`,children:[I(`span`,{children:t(`update.settings.rc`)}),R(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,role:`switch`,checked:!!e.includePrereleases,"aria-describedby":`updates-rc-hint`,"aria-label":t(`update.settings.rc`),"aria-busy":r,disabled:u,onChange:()=>{r||l(`update.action.saveRc`,t=>t.setIncludePrereleases(!e.includePrereleases))}}),I(`span`,{className:`toggle-track`})]})]}),R(`p`,{className:`settings-hint`,id:`updates-rc-hint`,children:[t(`update.settings.rcHint`),w$(e.currentVersion)&&` ${t(`update.settings.rcHintRunning`)}`]}),e.pinnedVersion&&R(`p`,{className:`settings-hint`,children:[t(`update.settings.pinned`,{version:e.pinnedVersion}),` `,I(`button`,{type:`button`,className:`btn-secondary`,disabled:r,onClick:()=>void l(`update.action.resume`,e=>e.resumeUpdates()),children:t(`update.settings.unpin`)})]}),R(`div`,{className:`setting-actions`,children:[e.status===`available`&&e.manualInstall&&I(`a`,{className:`btn-primary update-download-link`,href:e.downloadUrl??C$,target:`_blank`,rel:`noopener noreferrer`,"aria-describedby":`updates-manual-hint`,children:t(`update.settings.downloadVersion`,{version:e.version??``})}),e.status===`available`&&!e.manualInstall&&!e.pinnedVersion&&I(`button`,{type:`button`,className:`btn-primary`,disabled:r,onClick:()=>void l(`update.action.download`,e=>e.downloadUpdate()),children:t(`update.settings.updateTo`,{version:e.version??``})}),e.status===`downloaded`&&I(`button`,{type:`button`,className:`btn-primary`,disabled:r,onClick:()=>void l(`update.action.restart`,e=>e.restart()),children:t(`update.settings.restart`)}),e.readFailed?I(`button`,{type:`button`,className:`btn-secondary`,disabled:r,onClick:async()=>{i(!0);try{await e.reload()}finally{i(!1)}},children:t(`update.settings.retryRead`)}):I(`button`,{type:`button`,className:`btn-secondary`,disabled:d||u,onClick:()=>void l(`update.action.check`,e=>e.check()),children:t(`update.settings.check`)}),I(`button`,{type:`button`,className:`btn-secondary`,disabled:d||u,onClick:()=>c(!0),children:t(`update.settings.pick`)}),e.previousVersion&&I(`button`,{type:`button`,className:`btn-secondary`,"aria-describedby":`updates-back-hint`,disabled:d||u,onClick:()=>void l(`update.action.goBack`,e=>e.revertUpdate()),children:t(`update.settings.goBack`,{version:e.previousVersion})})]}),e.status===`available`&&e.manualInstall&&I(`p`,{className:`settings-hint`,id:`updates-manual-hint`,children:t(`update.settings.manualHint`)}),e.previousVersion&&I(`p`,{className:`settings-hint`,id:`updates-back-hint`,children:t(`update.settings.goBackHint`)}),e.installFailed&&I(`p`,{className:`settings-error`,role:`alert`,children:t(`update.settings.installFailed`,{...e.installFailed,url:C$})}),e.lastCheckError&&I(`p`,{className:`settings-hint`,children:t(`update.settings.lastCheckError`,{reason:e.lastCheckError})}),e.configError&&I(`p`,{className:`settings-error`,role:`alert`,children:e.configError}),a&&I(`p`,{className:`settings-error`,role:`alert`,children:a}),s&&I(S$,{onClose:()=>c(!1),manualInstall:e.manualInstall})]})})}var D$=[{value:`light`,label:`settings.theme.light`},{value:`dark`,label:`settings.theme.dark`},{value:`system`,label:`settings.theme.system`}],O$={default:`palette.default`,stone:`palette.stone`,marble:`palette.marble`,glacier:`palette.glacier`,forest:`palette.forest`,sage:`palette.sage`,basalt:`palette.basalt`,gold:`palette.gold`,dusk:`palette.dusk`,custom:`settings.colors.custom`};function k$(){let e=L(),t=z(e=>e.locale),n=z(e=>e.setLocale),i=z(e=>e.themePreference),a=z(e=>e.setThemePreference),o=z(e=>e.palette),s=z(e=>e.setPalette),c=z(e=>e.customColors),l=z(e=>e.setCustomColors),u=iF(e=>e.visible),d=iF(e=>e.setVisible),f=e=>t=>l({...c,[e]:t.target.value.toUpperCase()});return R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.general`)}),R(`div`,{className:`settings-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`ui-language`,children:e(`settings.language`)}),I(`select`,{id:`ui-language`,className:`settings-input`,value:t,onChange:e=>n(e.target.value),children:Pe.map(({meta:e})=>I(`option`,{value:e.code,lang:e.code,dir:e.dir,children:Ze(e)},e.code))}),I(`span`,{className:`settings-hint`,children:e(`settings.languageHint`)})]}),R(`div`,{className:`settings-field`,children:[I(`span`,{className:`settings-label`,id:`appearance-label`,children:e(`settings.appearance`)}),I(sF,{className:`segmented`,"aria-labelledby":`appearance-label`,children:D$.map(t=>I(`button`,{type:`button`,role:`radio`,"aria-checked":i===t.value,className:i===t.value?`is-active`:``,onClick:()=>a(t.value),children:e(t.label)},t.value))})]}),R(`div`,{className:`settings-field`,children:[R(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`resources.settings`)}),R(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked),"aria-label":e(`resources.settings`),"aria-describedby":`resources-hint`}),I(`span`,{className:`toggle-track`})]})]}),I(`span`,{className:`settings-hint`,id:`resources-hint`,children:e(`resources.settingsHint`)})]}),R(h$,{title:e(`settings.colors`),titleId:`palette-label`,defaultOpen:o===`custom`,children:[R(sF,{className:`palette-grid`,"aria-labelledby":`palette-label`,children:[r.map(t=>R(`button`,{type:`button`,role:`radio`,"aria-checked":o===t.id,className:`palette-tile${o===t.id?` is-active`:``}`,onClick:()=>s(t.id),children:[I(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:t.swatch.map(e=>I(`i`,{style:{background:e}},e))}),e(O$[t.id])]},t.id)),R(`button`,{type:`button`,role:`radio`,"aria-checked":o===`custom`,className:`palette-tile${o===`custom`?` is-active`:``}`,onClick:()=>s(`custom`),children:[R(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:[I(`i`,{style:{background:c.base}}),I(`i`,{style:{background:c.accent}})]}),e(`settings.colors.custom`)]})]}),o===`custom`&&R(`div`,{className:`palette-custom`,children:[R(`label`,{className:`palette-color`,htmlFor:`custom-accent`,children:[I(`input`,{id:`custom-accent`,type:`color`,value:c.accent,onChange:f(`accent`)}),R(`span`,{children:[e(`settings.colors.accent`),I(`small`,{children:e(`settings.colors.accentHint`)})]})]}),R(`label`,{className:`palette-color`,htmlFor:`custom-base`,children:[I(`input`,{id:`custom-base`,type:`color`,value:c.base,onChange:f(`base`)}),R(`span`,{children:[e(`settings.colors.base`),I(`small`,{children:e(`settings.colors.baseHint`)})]})]}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>l(Ae),children:e(`settings.colors.reset`)}),I(`p`,{className:`settings-hint`,children:e(`settings.colors.hint`)})]})]}),I(x$,{}),I(E$,{}),I(h$,{title:e(`settings.shortcuts`),children:I(`dl`,{className:`shortcut-list`,children:_X().map(({label:t,keys:n})=>R(`div`,{className:`shortcut-row`,children:[I(`dt`,{children:I(`kbd`,{children:Gu(n)})}),I(`dd`,{children:e(t)})]},t))})})]})}function A$(e){return/not reachable|not answering|model server at|ConnectionPool|NewConnectionError|Connection refused|Max retries/i.test(e)}function j$(e){return/gaia init/i.test(e??``)}var M$=`GAIA doesn't run this model server, so it can't start it. Start it the way you usually do.`,N$=/^The model server GAIA uses is at (\S+)\. (.*)$/s;function P$(e,t){if(!t)return null;if(t===M$)return e(`server.otherServerStart`);let n=N$.exec(t);return n&&n[2]===M$?`${e(`server.chosenServerAt`,{address:n[1]})} ${e(`server.otherServerStart`)}`:t}function F$(e){return!!e&&!e.lemonade_running&&(j$(e.start_command)||j$(e.start_instruction))}function I$({className:e=`btn-secondary`}){let t=L();return I(`button`,{type:`button`,className:e,onClick:()=>window.dispatchEvent(new CustomEvent(`gaia:set-up-local`)),children:t(`settings.errors.setUpLocal`)})}function L$({message:e,onRetry:t}){let n=L(),r=z(e=>F$(e.systemStatus));return A$(e)?R(`div`,{className:`settings-notice`,role:`alert`,children:[I(`strong`,{children:n(r?`settings.errors.notInstalledTitle`:`settings.errors.serverDownTitle`)}),I(`p`,{children:n(r?`settings.errors.notInstalled`:`settings.errors.serverDown`)}),r&&I(I$,{className:`btn-primary`}),t&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:t,children:n(`settings.key.checkAgain`)}),R(`details`,{className:`settings-more`,children:[R(`summary`,{children:[I(fi,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,n(`settings.errors.details`)]}),I(`bdi`,{dir:`ltr`,className:`settings-notice-raw`,children:e})]})]}):I(`p`,{className:`settings-error`,role:`alert`,children:e})}function R$({onAdded:e}){let t=L(),[n,r]=(0,V.useState)(``),[i,a]=(0,V.useState)(``),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(null),f=(0,V.useRef)(``),p=(0,V.useCallback)(async e=>{let t=n.trim();f.current=t,l(`check`),d(null);try{let n=await ir(t,e);if(f.current!==t)return;s(n),a(n.file??e)}catch(e){if(f.current!==t)return;s(null),d(e instanceof Error?e.message:String(e))}finally{l(null)}},[n]),m=(0,V.useCallback)(async()=>{l(`add`),d(null);try{let{report:o}=await $n(n.trim(),i);r(``),a(``),s(null),e(o.display_name??o.model_id??t(`settings.custom.theModel`))}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(null)}},[e,i,n,t]);return R(`form`,{className:`settings-field custom-model-add`,onSubmit:e=>{e.preventDefault(),p(``)},children:[I(`label`,{className:`visually-hidden`,htmlFor:`custom-model-url`,children:t(`settings.custom.title`)}),I(`span`,{className:`settings-hint`,children:t(`settings.custom.hint`)}),R(`div`,{className:`settings-row`,children:[I(`input`,{id:`custom-model-url`,className:`settings-input`,type:`url`,inputMode:`url`,dir:`ltr`,spellCheck:!1,autoComplete:`off`,value:n,readOnly:c!==null,onChange:e=>{r(e.target.value),s(null),a(``),f.current=``},placeholder:`https://huggingface.co/unsloth/Qwen3-4B-Instruct-2507-GGUF`}),R(`button`,{type:`submit`,className:`btn-secondary`,disabled:c!==null||!n.trim(),children:[c===`check`?I(B,{size:13,className:`spin`}):null,` `,t(`settings.custom.check`)]})]}),o&&(()=>{let e=I(`ul`,{className:`custom-model-checks`,"aria-label":t(`settings.custom.checks`),children:o.checks.map(e=>R(`li`,{className:e.ok?`is-ok`:`is-failed`,children:[e.ok?I(ci,{size:13,"aria-label":t(`settings.custom.passed`)}):I(bc,{size:13,"aria-label":t(`settings.custom.failed`)}),R(`bdi`,{children:[I(`strong`,{children:e.label}),` — `,e.detail]})]},e.id))});return o.ok?R(`details`,{className:`custom-model-checks-summary`,children:[R(`summary`,{children:[I(ci,{size:13,"aria-hidden":`true`}),` `,t(`settings.custom.allPassed`,{n:o.checks.length})]}),e]}):e})(),o&&o.warnings.length>0&&I(`ul`,{className:`custom-model-checks`,"aria-label":t(`settings.custom.warnings`),children:o.warnings.map(e=>R(`li`,{className:`is-warning`,children:[I(cc,{size:13,"aria-label":t(`settings.custom.warning`)}),` `,I(`bdi`,{children:e})]},e))}),o&&o.variants.length>1&&R(`div`,{className:`settings-row`,children:[I(`label`,{className:`settings-hint`,htmlFor:`custom-model-quant`,children:t(`settings.custom.quantization`)}),I(`select`,{id:`custom-model-quant`,className:`settings-input`,value:i,onChange:e=>void p(e.target.value),disabled:c!==null,children:o.variants.map(e=>R(`option`,{value:e.file,children:[e.quant,` · `,e.size_gb,` GB`,e.fits?``:` · ${t.bare(`settings.custom.tooLarge`)}`]},e.file))})]}),o?.ok&&R(`div`,{className:`settings-row`,children:[R(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void m(),disabled:c!==null,children:[c===`add`?I(B,{size:13,className:`spin`}):null,` `,t(`settings.custom.add`,{name:o.display_name??``})]}),I(`span`,{className:`settings-hint`,children:t(`settings.model.sizeDownload`,{size:`${o.size_gb} GB`})})]}),u&&I(L$,{message:u})]})}function z$(e){return e instanceof Error?e.message:String(e)}function B$(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function V$({downloadsSlot:e}){let t=L(),[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)(null),[m,h]=(0,V.useState)(!1),[g,_]=(0,V.useState)(null),[v,y]=(0,V.useState)(null),b=Wl(e=>e.status),x=Wl(e=>e.started),S=(0,V.useMemo)(()=>Vl(b,x),[b,x]),C=Wl(e=>e.error),w=Wl(e=>e.refresh),T=Wl(e=>e.enqueue),E=Wl(e=>e.cancel),ee=(0,V.useCallback)(async(e=!1)=>{a(null);try{let t=await Rn();r(t),s(n=>e||!n?UX(t):n)}catch(e){a(z$(e))}},[]);(0,V.useEffect)(()=>{ee(!0),w(),(async()=>{try{_(await Nt()??null)}catch(e){y(z$(e))}})()},[ee,w]);let D=(S?.models??[]).filter(e=>e.state===`ready`).map(e=>e.id).join(`,`),O=(0,V.useRef)(D);(0,V.useEffect)(()=>{D!==O.current&&(O.current=D,ee(!0))},[D,ee]);let te=(0,V.useMemo)(()=>{let e={};for(let t of S?.models??[])e[t.id]=t;return e},[S]),k=(0,V.useMemo)(()=>{let e={};for(let t of n?.catalog??[])e[t.id]=t.name;return e},[n]),A=(0,V.useMemo)(()=>n?UX(n):null,[n]),ne=DX(n),j=n&&o?JX(ne,o).filter(e=>te[e.id]?.state!==`downloading`):[],M=j.reduce((e,t)=>e+(t.size_gb??0),0),re=!!n&&!!o&&!!A&&(!B$(o.ticked,A.ticked)||o.defaultChat!==A.defaultChat||j.length>0),ie=(0,V.useCallback)(async(e,i)=>{if(!n||!o)return;if(p(null),!e){let e=ZX(ne,o).filter(e=>!e.downloaded||e.id===o.defaultChat);if(e.length>0&&e.every(e=>e.need_gb!=null)){l({kind:`no_fit`,models:e});return}}let a=XX(n,o);if(a&&!i)l({kind:`low_disk`,message:a.drop?t(`setup.summary.shortDrop`,{need:GA(a.needGb),free:GA(a.freeGb),drive:fZ(n.disk?.path??null)??t(`setup.summary.theDrive`),freeUp:GA(a.freeUpGb),name:a.drop.name,saves:GA(a.drop.size_gb??0)}):t(`setup.summary.short`,{need:GA(a.needGb),free:GA(a.freeGb),drive:fZ(n.disk?.path??null)??t(`setup.summary.theDrive`),freeUp:GA(a.freeUpGb)})});else{d(!0);try{let i=n,a=!1;if(o.defaultChat&&o.defaultChat!==i.chat_model.id){a=!0;try{i=await Fn(o.defaultChat,e||m)}catch(e){let t=Xn(e);if(t){l({kind:`server`,detail:t});return}throw e}}for(let e of $X(i,o))i=await kt(e.id,e.skipped);let c=JX(DX(i),o).map(e=>e.id).filter(e=>te[e]?.state!==`downloading`);r(i),s({...o,defaultChat:i.chat_model.id});let u=null;if(a&&i.chat_model.downloaded)try{await il.getState().select(i.chat_model.id)}catch(e){u=z$(e),il.getState().refresh()}else il.getState().refresh();c.length&&await T(c,{acknowledgeLowDisk:!0}),p(u===null?{ok:!0,text:t(`settings.models.applied`)}:{ok:!1,text:t(`settings.models.appliedNotSwitched`,{reason:u})})}catch(e){p({ok:!1,text:z$(e)})}finally{d(!1)}}},[n,o,ne,m,te,T,t]),ae=(0,V.useCallback)(async e=>{l(null),d(!0),p(null);try{let n=await wt(e.id);zc(),r(n),s(UX(n)),p({ok:!0,text:t(`settings.models.removed`,{name:e.name,size:GA(n.freed_gb)})})}catch(e){p({ok:!1,text:z$(e)})}finally{d(!1)}},[t]),oe=(0,V.useCallback)((e,t)=>{(async()=>{try{t===`verify`&&await wt(e),await T([e])}catch(e){p({ok:!1,text:z$(e)})}})()},[T]),se=!!S&&(S.models?.length??0)>0&&(XZ(S)||S.models.some(e=>e.state!==`skipped`))&&S&&R(`section`,{className:`settings-field models-pane-section`,"aria-labelledby":`settings-downloads-title`,children:[I(`span`,{className:`settings-label`,id:`settings-downloads-title`,children:t(`settings.models.downloads`)}),I($Z,{status:S,names:k,freeGb:n?.disk?.free_gb??null,onCancel:()=>void E(),onRetry:oe,onResume:e=>void T([e]),onResumeAll:()=>void T((S.models??[]).filter(e=>e.state===`cancelled`).map(e=>e.id))}),C&&I(`p`,{className:`settings-error`,role:`alert`,children:C})]});return R(F.Fragment,{children:[I(h$,{title:t(`settings.models.manage`),hint:t(`settings.models.manageHint`),forceOpen:!!i||f?.ok===!1,children:R(`section`,{className:`settings-field models-pane-section`,"aria-labelledby":`settings-models-title`,children:[I(`span`,{className:`visually-hidden`,id:`settings-models-title`,children:t(`settings.models.title`)}),I(`p`,{className:`settings-hint`,children:t(`settings.models.lede`)}),i&&I(L$,{message:i}),n&&!n.lemonade.reachable&&I(`p`,{className:`settings-hint`,children:t(`settings.models.unavailable`)}),!n&&!i&&R(`p`,{className:`settings-hint`,children:[I(B,{size:13,className:`spin`,"aria-hidden":`true`}),` `,t(`setup.models.loading`)]}),n&&n.lemonade.reachable&&o&&R(F.Fragment,{children:[I(mZ,{plan:n,selection:o,onToggle:(e,t)=>s(GX(o,ne,e,t)),onDefaultChat:e=>s(KX(o,ne,e)),labelledBy:`settings-models-title`,place:`settings`,disabled:u,progress:te,rowActions:e=>e.downloaded&&e.id!==o.defaultChat?I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>l({kind:`remove`,entry:e}),disabled:u||te[e.id]?.state===`downloading`,"aria-label":t(`settings.models.removeAria`,{name:e.name}),children:t(`settings.models.remove`)}):null}),I(dZ,{plan:n,selection:o}),I(`div`,{className:`models-apply`,children:R(`button`,{type:`button`,className:`btn-primary`,disabled:!re||u,onClick:()=>void ie(!1,!1),children:[u&&I(B,{size:13,className:`spin`,"aria-hidden":`true`}),u?t(`settings.models.applying`):j.length>0?t(`settings.models.applyDownload`,{size:GA(Math.round(M*10)/10)}):t(`settings.models.apply`)]})})]}),f?.ok&&I(`p`,{className:`settings-ok`,role:`status`,children:f.text}),f&&!f.ok&&I(L$,{message:f.text})]})}),(g?.applies||v&&!A$(v))&&I(h$,{title:t(`gpu.settingsTitle`),titleId:`settings-gpu-title`,defaultOpen:!!g?.pending||!!v,children:R(`section`,{className:`settings-field models-pane-section`,"aria-labelledby":`settings-gpu-title`,children:[v&&I(`p`,{className:`settings-error`,role:`alert`,children:v}),g?.applies&&I(NZ,{status:g,onStatus:_,mode:`settings`,names:k,headingId:`settings-gpu-title`})]})}),e?(0,by.createPortal)(se,e):e===void 0&&se,c?.kind===`remove`&&I(wZ,{title:t(`settings.models.removeTitle`,{name:c.entry.name}),confirmLabel:t(`settings.models.removeConfirm`),cancelLabel:t(`settings.models.keep`),danger:!0,onConfirm:()=>void ae(c.entry),onCancel:()=>l(null),children:I(`p`,{children:OX(c.entry)?t(`settings.models.removeVision`,{size:GA(c.entry.full_size_gb??0)}):t(`settings.models.removeBody`,{size:GA(c.entry.full_size_gb??0)})})}),c?.kind===`no_fit`&&I(wZ,{title:QX(c.models)?t(`setup.confirm.tightOne`,{name:c.models[0].name}):c.models.length===1?t(`setup.confirm.noFitOne`,{name:c.models[0].name}):t(`setup.confirm.noFitMany`),confirmLabel:QX(c.models)?t(`setup.confirm.useAnyway`):t(`setup.confirm.downloadAnyway`),cancelLabel:t(`setup.confirm.pickSmaller`),onConfirm:()=>{l(null),h(!0),ie(!0,!1)},onCancel:()=>l(null),children:c.models.map(e=>R(`p`,{children:[I(`bdi`,{children:e.name}),`: `,cZ(e,t)]},e.id))}),c?.kind===`low_disk`&&I(wZ,{title:t(`setup.confirm.lowDiskTitle`),confirmLabel:t(`setup.confirm.downloadAnyway`),cancelLabel:t(`setup.confirm.changeModels`),onConfirm:()=>{l(null),ie(!0,!0)},onCancel:()=>l(null),children:I(`p`,{children:c.message})}),c?.kind===`server`&&I(wZ,{title:t(`setup.confirm.noFitServerTitle`),confirmLabel:t(`setup.confirm.useAnyway`),cancelLabel:t(`setup.confirm.changeModels`),onConfirm:()=>{l(null),h(!0),ie(!0,!1)},onCancel:()=>l(null),children:I(`p`,{children:c.detail.message})})]})}var H$=`auto`;function U$({model:e}){let t=L(),[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(null);(0,V.useEffect)(()=>{r(null),a(null),l(null),_e(e).then(r).catch(e=>a(e instanceof Error?e.message:String(e)))},[e]);let u=(0,V.useCallback)(async n=>{s(!0),a(null),l(null);try{let i=await ae(e,n===H$?null:Number(n));r(i);let a={name:i.display_name,size:i.chosen?xl(i.chosen):de(`settings.ctx.automaticSize`)},o=i.reload?.reason;i.reload?.started?l(t(`settings.ctx.reloading`,a)):l(o===`already_loaded`?t(`settings.ctx.alreadyLoaded`,a):o===`warm_up`?t(`settings.ctx.warmUp`,a):o===`busy`?t(`settings.ctx.busy`,a):o===`not_gaias_server`?t(`settings.ctx.ownServer`,a):t(o===`restarting`?`settings.ctx.restarting`:`settings.ctx.nextLoad`))}catch(e){a(e instanceof Error?e.message:String(e))}finally{s(!1)}},[e,t]);if(i&&!n)return A$(i)?I(`p`,{className:`settings-hint`,children:t(`settings.ctx.serverDown`)}):I(`p`,{className:`settings-error`,role:`alert`,children:i});if(!n)return R(`p`,{className:`settings-hint`,children:[I(B,{size:13,className:`spin`}),` `,t(`settings.ctx.checking`)]});let d=n.chosen==null?H$:String(n.chosen),f=n.chosen!=null&&n.loaded_ctx!=null&&n.loaded_ctx!==n.chosen;return R(F.Fragment,{children:[R(`div`,{className:`model-in-use-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`ctx-size`,children:t(`settings.ctx.label`)}),R(`select`,{id:`ctx-size`,className:`settings-input`,value:d,onChange:e=>void u(e.target.value),disabled:o||n.options.length===0,children:[I(`option`,{value:H$,children:n.automatic?t.bare(`settings.ctx.automaticAt`,{size:xl(n.automatic)}):t.bare(`settings.ctx.automatic`)}),n.options.map(e=>I(`option`,{value:String(e),children:t.bare(`settings.ctx.tokens`,{size:xl(e)})},e))]})]}),n.note&&I(`span`,{className:`settings-hint`,children:I(`bdi`,{children:n.note})}),!n.note&&!!n.max_fit&&R(`details`,{className:`settings-more`,children:[R(`summary`,{children:[I(fi,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,t(`settings.ctx.about`)]}),I(`span`,{className:`settings-hint`,children:t(`settings.ctx.explain`,{size:xl(n.max_fit),name:n.display_name,memory:n.memory_source})})]}),f&&I(`span`,{className:`settings-hint`,children:t(`settings.ctx.loadedAt`,{size:xl(n.loaded_ctx)})}),o&&R(`span`,{className:`settings-hint`,children:[I(B,{size:13,className:`spin`}),` `,t(`settings.ctx.applying`)]}),c&&I(`p`,{className:`settings-ok`,role:`status`,children:c}),i&&I(`p`,{className:`settings-error`,role:`alert`,children:i})]})}function W$({row:e,providerName:t,choices:n,labels:r,disabled:i,onSwitch:a}){let o=L(),s=il(e=>e.active),c=il(e=>e.error),l=s?.model??null,u=!!s?.remote,d=n.some(e=>sl(l,e.id)),f=s?.downloaded??e?.downloaded,p=u?null:e?.state===`loaded`?o(`settings.model.loaded`):f===!0?o(`settings.model.downloaded`):f===!1?o(`settings.model.notDownloaded`):null,m=e?.placement?.device;return R(`section`,{className:`settings-card model-in-use`,"aria-label":o(`settings.model.inUseTitle`),children:[I(`span`,{className:`model-in-use-label`,children:o(`settings.model.inUseTitle`)}),l?I(`bdi`,{className:`model-in-use-name`,title:l,children:e?.display_name||s?.display_name||cl(l)}):s||c?I(`span`,{className:`settings-hint`,children:o(`settings.model.noneInUse`)}):I(`span`,{className:`settings-hint`,children:o(`settings.loading`)}),s?.config_error&&I(`p`,{className:`settings-error`,role:`alert`,children:I(`bdi`,{children:s.config_error})}),l&&!u&&e?.available===!1&&I(`p`,{className:`settings-error`,role:`alert`,children:o(`settings.model.inUseCantRun`)}),l&&R(`span`,{className:`model-chips`,children:[u&&I(`span`,{className:`model-badge is-device`,children:o(`settings.model.cloud`)}),u&&t&&I(`bdi`,{className:`model-badge is-ready`,children:t}),m&&I(`span`,{className:`model-badge is-device`,children:m.toUpperCase()}),p&&I(`span`,{className:`model-badge ${e?.state===`loaded`?`is-loaded`:`is-ready`}`,children:p}),e?.fits===!0&&I(`span`,{className:`model-badge is-fit`,children:o(`settings.model.fits`)}),!!e?.size_gb&&R(`bdi`,{dir:`ltr`,className:`model-badge is-size`,children:[e.size_gb,` GB`]}),u&&!!e?.context_length&&I(`span`,{className:`model-badge is-ready`,children:o(`settings.model.contextChip`,{size:xl(e.context_length)})})]}),(n.length>1||n.length===1&&!d)&&R(`div`,{className:`model-in-use-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`model-switch`,children:o(`settings.model.switch`)}),R(`select`,{id:`model-switch`,className:`settings-input`,value:d?n.find(e=>sl(l,e.id))?.id:``,onChange:e=>a(e.target.value),disabled:i,children:[!d&&I(`option`,{value:``,disabled:!0,children:o.bare(`settings.model.switchPlaceholder`)}),n.map(e=>I(`option`,{value:e.id,children:r[e.id]},e.id))]})]}),l&&!u&&s?.downloaded!==!1&&I(U$,{model:l})]})}var G$=e=>new Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:0}).format(e),K$=/^(\d+\/\d+) tasks · quality ([\d.]+\/5) · (\$[\d.]+) per (\d+)-task run$/;function q$(e,t){let n=K$.exec(t);return e.compose(e=>e(`settings.model.measured`,{evidence:n?e(`settings.model.evidence`,{tasks:n[1],quality:n[2],cost:n[3],n:n[4]}):t}))}function J$({model:e,label:t,current:n,remote:r,busy:i,onUse:a,onDownload:o,onAskRemove:s,onNpuRecheck:c}){let l=L(),u=Tl(e)?e.download_progress:null,d=e.placement?.label,f=l.compose(t=>[d&&(e.placement?.source===`expected`?t(`settings.model.expected`,{label:d}):d),e.size_gb?t(e.downloaded?`settings.model.sizeOnDisk`:`settings.model.sizeDownload`,{size:`${e.size_gb} GB`}):null,e.tokens_per_second?t(`settings.model.speed`,{speed:`${Math.round(e.tokens_per_second)} tok/s`}):null,!e.placement&&e.context_length?t(`settings.model.contextTokens`,{size:G$(e.context_length)}):null].filter(Boolean).join(` · `)),p=!!(e.display_name||f||e.evidence||e.custom&&e.source_url);return R(`li`,{className:`model-row${n?` is-current`:``}`,children:[R(`div`,{className:`model-row-text`,children:[I(`bdi`,{className:`model-row-name`,title:e.id,children:t}),R(`div`,{className:`model-chips`,children:[e.placement?.device&&I(`span`,{className:`model-badge is-device`,children:e.placement.device.toUpperCase()}),e.rank&&R(`span`,{className:`model-badge is-rank`,children:[R(`bdi`,{dir:`ltr`,children:[`#`,e.rank]}),` `,e.note&&(yl[e.note]?l(yl[e.note]):I(`bdi`,{children:e.note}))]}),e.state===`loaded`&&I(`span`,{className:`model-badge is-loaded`,children:l(`settings.model.loaded`)}),e.fits===!0&&e.available!==!1&&!e.tight&&I(`span`,{className:`model-badge is-fit`,children:l(`settings.model.fits`)}),e.fits===!0&&e.available!==!1&&e.tight&&I(`span`,{className:`model-badge is-tight`,title:l(`setup.models.warn.tight`),children:l(`settings.model.tight`)}),!r&&I(zH,{support:e.support}),e.custom&&I(`span`,{className:`model-badge is-custom`,children:l(`settings.model.custom`)}),!!e.size_gb&&R(`bdi`,{dir:`ltr`,className:`model-badge is-size`,children:[e.size_gb,` GB`]}),p&&R(`details`,{className:`settings-more model-row-facts`,children:[R(`summary`,{children:[I(fi,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,l(`settings.model.details`)]}),e.display_name&&I(`span`,{className:`model-row-meta`,children:I(`bdi`,{children:e.id})}),f&&I(`span`,{className:`model-row-meta`,children:f}),e.evidence&&I(`span`,{className:`model-row-meta`,children:q$(l,e.evidence)}),e.custom&&e.source_url&&I(`span`,{className:`model-row-meta`,children:l(`settings.model.from`,{url:e.source_url})})]})]}),r&&I(`span`,{className:`model-row-meta${e.price?``:` is-unknown-price`}`,children:VH(e.price,l)}),e.placement?.warning&&I(`span`,{className:`model-row-meta is-warning`,role:`alert`,children:I(`bdi`,{children:e.placement.warning})}),e.npu_problems?.length?I(uQ,{problems:e.npu_problems,disabled:i!==null,onRecheck:c,id:`npu-problems-${e.id}`}):e.unavailable_reason&&I(`span`,{className:`model-row-meta`,children:l(`settings.model.cantRun`,{reason:e.unavailable_reason})}),u&&I(`progress`,{max:100,value:u.percent,"aria-label":l(`settings.model.downloadingAria`,{name:t})})]}),R(`div`,{className:`model-row-actions`,children:[e.custom&&!n&&!u&&R(`button`,{type:`button`,className:`btn-secondary`,onClick:s,disabled:i!==null,"aria-label":l(`settings.models.removeAria`,{name:t}),children:[i===`rm:${e.id}`?I(B,{size:13,className:`spin`}):null,l(`settings.models.remove`)]}),n&&e.available===!1?I(`span`,{className:`model-row-current is-blocked`,children:l(`settings.model.inUseBlocked`)}):n?R(`span`,{className:`model-row-current`,children:[I(ci,{size:13,"aria-hidden":`true`}),` `,l(`settings.model.inUse`)]}):e.available===!1?null:u?R(`span`,{className:`model-row-current`,children:[I(B,{size:13,className:`spin`}),` `,u.message?I(`bdi`,{children:u.message}):R(`bdi`,{dir:`ltr`,children:[Math.round(u.percent),`%`]})]}):e.downloaded?R(`button`,{type:`button`,className:`btn-secondary`,onClick:a,disabled:i!==null,"aria-label":l(`settings.model.useAria`,{name:t}),children:[i===e.id?I(B,{size:13,className:`spin`}):null,` `,l(`settings.model.use`)]}):R(`button`,{type:`button`,className:`btn-secondary`,onClick:o,disabled:i!==null,"aria-label":l(`settings.model.downloadAria`,{name:t}),children:[i===`dl:${e.id}`?I(B,{size:13,className:`spin`}):null,` `,l(`settings.model.download`)]})]})]})}function Y$(){let e=L(),[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(null),[a,s]=(0,V.useState)(``),[c,l]=(0,V.useState)(!1),u=(0,V.useCallback)(async e=>{l(!0),i(null);try{let t=await e();n(t),s(t.limit_usd==null?``:String(t.limit_usd))}catch(e){i(e instanceof Error?e.message:String(e))}finally{l(!1)}},[]);if((0,V.useEffect)(()=>{u(o)},[u]),!t)return r?I(`p`,{className:`settings-error`,role:`alert`,children:r}):R(`p`,{className:`settings-hint`,children:[I(B,{size:13,className:`spin`}),` `,e(`settings.spend.loading`)]});let d=t.limit_usd,f=a.trim()===``?null:Number(a),p=f===null||Number.isFinite(f)&&f>0,m=f!==d;return R(`section`,{className:`settings-field spending`,"aria-label":e(`settings.spend.aria`),children:[I(`span`,{className:`settings-label`,children:e(`settings.spend.title`)}),R(`p`,{className:`spending-total`,children:[I(`bdi`,{dir:`ltr`,children:I(`strong`,{children:HH(t.total_usd)})}),d!=null&&R(F.Fragment,{children:[` `,e(`settings.spend.ofLimit`,{limit:HH(d)})]}),R(`span`,{className:`settings-hint`,children:[` · `,e.plural(`settings.spend.turns`,t.turns-t.unpriced_turns-t.unreported_turns)]})]}),t.unpriced_turns>0&&I(`p`,{className:`settings-hint`,children:e.plural(`settings.spend.unpriced`,t.unpriced_turns)}),t.unreported_turns>0&&I(`p`,{className:`settings-hint`,children:e.plural(`settings.spend.unreported`,t.unreported_turns)}),t.state===`near`&&R(`p`,{className:`spending-warning`,role:`status`,children:[I(cc,{size:13,"aria-hidden":`true`}),` `,e(`settings.spend.near`)]}),t.state===`reached`&&R(`div`,{className:`spending-warning`,role:`alert`,children:[R(`p`,{children:[I(cc,{size:13,"aria-hidden":`true`}),` `,e(`settings.spend.reached`)]}),I(`button`,{type:`button`,className:`btn-secondary`,disabled:c,onClick:()=>void u(Vt),children:e(`settings.spend.allow`)})]}),t.state===`allowed_over`&&I(`p`,{className:`settings-hint`,children:e(`settings.spend.allowed`)}),R(`form`,{className:`settings-row`,onSubmit:e=>{e.preventDefault(),p&&m&&u(()=>yr(f))},children:[I(`label`,{className:`spending-limit-label`,htmlFor:`spend-limit`,children:e(`settings.spend.limit`)}),I(`input`,{id:`spend-limit`,className:`settings-input`,type:`number`,min:`0.01`,step:`0.01`,inputMode:`decimal`,placeholder:e.bare(`settings.spend.noLimit`),value:a,onChange:e=>s(e.target.value),"aria-invalid":!p}),R(`button`,{type:`submit`,className:`btn-secondary`,disabled:c||!p||!m,children:[c?I(B,{size:13,className:`spin`}):null,` `,e(`settings.advanced.save`)]}),d!=null&&I(`button`,{type:`button`,className:`btn-secondary`,disabled:c,onClick:()=>void u(()=>yr(null)),children:e(`settings.spend.removeLimit`)})]}),I(`span`,{className:`settings-hint`,children:e(`settings.spend.how`)}),r&&I(`p`,{className:`settings-error`,role:`alert`,children:r})]})}var X$=2e3;function Z$(e,t){return e.key_source===`environment`?t(`settings.key.setIn`,{name:e.env_var??``}):`••••••••••••••••••••${e.key_hint?` ${e.key_hint}`:``}`}function Q$(){let e=L(),t=il(e=>e.active),n=il(e=>e.select),r=il(e=>e.refresh),i=il(e=>e.rememberNames),a=z(e=>!!e.systemStatus&&cV(e.systemStatus)===`unresponsive`),[o,s]=(0,V.useState)(null),[u,d]=(0,V.useState)(null),f=z(e=>e.settingsProvider),[p,m]=(0,V.useState)(f??t?.provider??`local`),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(null),[y,b]=(0,V.useState)(``),[x,S]=(0,V.useState)(!1),[C,w]=(0,V.useState)(``),[T,E]=(0,V.useState)(!1),[ee,D]=(0,V.useState)(!1),[O,te]=(0,V.useState)({base_url:``,auth_header_name:``,auth_header_prefix:``}),[k,A]=(0,V.useState)(null),[ne,j]=(0,V.useState)(null),[M,re]=(0,V.useState)(null),[ie,ae]=(0,V.useState)(null),[oe,se]=(0,V.useState)(!1),[ce,le]=(0,V.useState)(null),[ue,de]=(0,V.useState)(null),fe=(0,V.useRef)(p);fe.current=p;let pe=(0,V.useRef)(!0);(0,V.useEffect)(()=>(pe.current=!0,()=>{pe.current=!1}),[]);let me=o?.find(e=>e.id===p)??null,he=e=>e?.network?.reachable===!1,ge=e=>!!e?.blocked,_e=!!me&&!ge(me)&&(!me.remote||!!me.models_discovered),ve=(0,V.useCallback)(async()=>{d(null);try{let e=await At();s(e.providers),e.lemonade_error&&d(e.lemonade_error)}catch(e){d(e instanceof Error?e.message:String(e))}},[]),ye=(0,V.useCallback)(async()=>{try{await c()}catch(e){d(e instanceof Error?e.message:String(e));return}await ve()},[ve]),be=(0,V.useCallback)(async(t,n=!1)=>{n||(g(null),v(null));try{let n=await Zn(t);i(n.models),g(n.models),j(n.memory_gb?`${n.memory_gb} GB (${n.memory_source})`:n.capacity_error??null),n.blocked&&v(e(`settings.privacy.localOnlyBlocked`))}catch(e){v(e instanceof Error?e.message:String(e))}},[i,e]);(0,V.useEffect)(()=>{ve()},[ve]);let xe=!!o?.some(e=>e.key_state===`waiting_for_os_permission`);(0,V.useEffect)(()=>{if(xe)return jl(()=>{ve()},X$)},[xe,ve]);let Se=t?.provider;(0,V.useEffect)(()=>{Se&&!f&&m(Se)},[Se,f]),(0,V.useEffect)(()=>{w(``),E(!1),D(!1),re(null),b(``),S(!1),se(!1)},[p]),(0,V.useEffect)(()=>{_e?be(p):g(null)},[p,_e,be]);let Ce=(0,V.useCallback)(async()=>{if(me){A(`connect`),re(null);try{let t=p===`amd`?{api_key:C||void 0,...Object.fromEntries(Object.entries(O).filter(([,e])=>e!==``))}:{api_key:C||void 0},n=()=>!pe.current||fe.current!==p,r=await _r(p,t,e=>{n()||re({ok:!0,text:e})},n);if(n())return;w(``),E(!1),re({ok:!0,text:r.remember_error?e(`settings.key.sessionOnly`,{reason:r.remember_error}):r.known_models?e(`settings.key.knownModels`,{name:me.name}):r.remembered?e(`settings.key.kept`):e(`settings.key.connectedDone`)}),await ve()}catch(e){pe.current&&fe.current===p&&re({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{pe.current&&A(null)}}},[O,p,C,ve,me,e]),we=(0,V.useCallback)(async()=>{A(`forget`),D(!1),re(null);try{await l(p),re({ok:!0,text:e(`settings.key.cleared`)}),await ve(),await r()}catch(e){re({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{A(null)}},[p,ve,r,e]),N=(0,V.useCallback)(async t=>{A(t),re(null);try{await n(t),re({ok:!0,text:e(`settings.model.switched`,{name:cl(t)})}),await be(p,!0)}catch(e){re({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{A(null)}},[p,be,n,e]),Te=(0,V.useCallback)(async e=>{A(`dl:${e}`),re(null),se(!1);try{await Ee(e),await be(`local`,!0)}catch(e){re({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{A(null)}},[be]),De=(0,V.useCallback)(async t=>{let n=il.getState().active?.model;A(`rm:${t}`),re(null);try{let r=await He(t);ae(null);let i=r.cleared.includes(`last_model`)?`settings.model.removedLast`:r.cleared.includes(`default_model`)?`settings.model.removedDefault`:`settings.model.removed`;re({ok:!0,text:e(i,{name:r.display_name})}),await be(`local`,!0),await al(n)}catch(e){re({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{A(null)}},[be,e]),Oe=(0,V.useCallback)(async t=>{re({ok:!0,text:e(`settings.model.added`,{name:t})}),se(!0),await be(`local`,!0)},[be,e]),ke=!!h?.some(Tl);(0,V.useEffect)(()=>{if(ke)return()=>{r()}},[ke,r]),(0,V.useEffect)(()=>{if(p===`local`&&ke)return jl(()=>{be(`local`,!0)},X$)},[ke,p,be]);let Ae=t?.model,je=h?.find(e=>sl(Ae,e.id));(0,V.useEffect)(()=>{je&&le(je)},[je]);let Me=(0,V.useMemo)(()=>{let e=y.trim().toLowerCase();return(h??[]).filter(t=>!e||t.id.toLowerCase().includes(e)||(t.display_name??``).toLowerCase().includes(e))},[h,y]),Ne=Me.filter(e=>e.available!==!1),Pe=p===`fireworks`&&!x&&!y.trim()&&Ne.some(e=>e.rank!==null),Fe=e=>e.rank!==null||e.id===t?.model,Ie=Pe?Ne.filter(Fe):Ne,Le=Pe?Ne.filter(e=>!Fe(e)):[],Re=Me.filter(e=>e.available===!1),ze=gl(h??[]),Be=!!y.trim(),Ve=e=>sl(t?.model,e.id),Ue=me?.id===`local`,We=Ie.filter(e=>e.downloaded).sort((e,t)=>Number(Ve(t))-Number(Ve(e))),Ge=Ie.filter(e=>!e.downloaded),Ke=(h??[]).filter(e=>e.available!==!1&&e.downloaded),qe=Ke.filter(Fe),Je=ie?(h??[]).find(e=>e.id===ie)??null:null,Ye=p===`fireworks`&&qe.some(e=>e.rank!==null)?qe:Ke,Xe=e=>I(J$,{model:e,label:ze[e.id],current:Ve(e),remote:!!me?.remote,busy:k,onUse:()=>void N(e.id),onDownload:()=>void Te(e.id),onAskRemove:()=>ae(e.id),onNpuRecheck:()=>void be(p,!0)},e.id);return R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.model`)}),I(kW,{inSettings:!0}),I(W$,{row:je??(sl(ce?.id,t?.model)?ce:null),providerName:t?.provider_name??null,choices:_e?Ye:[],labels:ze,disabled:k!==null,onSwitch:e=>void N(e)}),I(sF,{className:`provider-tabs`,"aria-label":e(`settings.model.whereRuns`),children:(o??[{id:`local`,name:`Local`,remote:!1}]).map(t=>R(`button`,{type:`button`,role:`radio`,"aria-checked":p===t.id,className:`provider-tab${p===t.id?` is-active`:``}${he(t)||ge(t)?` is-disabled`:``}`,onClick:()=>m(t.id),disabled:(he(t)||ge(t))&&p!==t.id,title:ge(t)?e(`settings.privacy.localOnlyBlocked`):he(t)?e(`setup.key.gatewayOff`):void 0,children:[t.remote?I(Pi,{size:14,"aria-hidden":`true`}):I(Wi,{size:14,"aria-hidden":`true`}),I(`span`,{children:WH(e,t)}),t.remote&&t.models_discovered&&I(`span`,{className:`provider-tab-dot`,"aria-label":e(`settings.key.connectedDot`)})]},t.id))}),!o&&!u&&R(`p`,{className:`settings-hint`,role:`status`,children:[I(B,{size:13,className:`spin`}),` `,e(a?`settings.model.waitingServer`:`settings.loading`)]}),u&&I(L$,{message:u,onRetry:()=>{ve(),be(p)}}),me&&R(`section`,{className:`settings-card`,"aria-label":WH(e,me),children:[me.remote&&I(`p`,{className:`settings-note`,children:I(`bdi`,{children:GH(e,me)})}),R(`details`,{className:`settings-more`,children:[R(`summary`,{children:[I(fi,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,e(`settings.model.howItWorks`)]}),I(`p`,{className:`settings-hint`,children:e(`settings.model.lede`)}),Ue&&I(`p`,{className:`settings-hint`,children:I(`bdi`,{children:GH(e,me)})}),Ue&&I(`p`,{className:`settings-hint`,children:e(`settings.model.devices`)}),Ue&&ne&&I(`p`,{className:`settings-hint`,children:e(`settings.model.memory`,{memory:ne})})]}),me.remote&&!_e&&R(`div`,{className:`settings-field`,children:[I(`span`,{className:`settings-label`,children:e(`settings.model.prices`)}),I(bX,{provider:me.id})]}),ge(me)&&I(`div`,{className:`settings-field`,children:I(`p`,{className:`settings-error`,role:`alert`,children:e(`settings.privacy.localOnlyBlocked`)})}),he(me)&&R(`div`,{className:`settings-field`,children:[I(`p`,{className:`settings-error`,role:`alert`,children:me.network?.detail}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void ve(),children:e(`settings.key.checkAgain`)})]}),me.remote&&!he(me)&&!ge(me)&&R(`form`,{className:`settings-field`,"data-settings-target":`cloud-key`,onSubmit:e=>{e.preventDefault(),Ce()},children:[R(`div`,{className:`settings-row settings-row-between`,children:[I(`span`,{className:`settings-label`,children:e(`settings.key.title`)}),me.key_source&&I(`span`,{className:`settings-key-status ${_e?`settings-ok`:`settings-error`}`,children:e(_e?`settings.key.connected`:`settings.key.notConnected`)})]}),!me.key_source&&me.key_state===`store_locked`&&R(`span`,{className:`settings-hint`,role:`status`,children:[e(`settings.key.storeLocked`),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>void ye(),children:e(`settings.key.unlockAgain`)})]}),!me.key_source&&me.key_state!==`store_locked`&&I(`span`,{className:`settings-hint`,children:me.key_state===`waiting_for_os_permission`?me.key_message??e(`settings.key.waitingOs`):e(`settings.key.none`)}),me.id===`amd`&&(!me.key_source||T)&&R(`div`,{className:`settings-grid`,children:[I(`input`,{className:`settings-input`,placeholder:e(`settings.key.gatewayPlaceholder`),value:O.base_url,onChange:e=>te({...O,base_url:e.target.value}),"aria-label":e(`settings.key.gatewayUrl`)}),I(`input`,{className:`settings-input`,placeholder:e(`settings.key.headerPlaceholder`),value:O.auth_header_name,onChange:e=>te({...O,auth_header_name:e.target.value}),"aria-label":e(`settings.key.headerName`)})]}),me.key_source&&!T?R(`div`,{className:`settings-row`,children:[I(`input`,{className:`settings-input settings-key-masked`,readOnly:!0,value:Z$(me,e),"aria-label":e(`settings.key.savedAria`,{name:me.name})}),!_e&&R(`button`,{type:`submit`,className:`btn-primary`,disabled:k!==null,children:[k===`connect`?I(B,{size:13,className:`spin`}):null,e(`settings.key.reconnect`)]}),(me.key_source!==`environment`||me.key_from_gaia_env)&&R(F.Fragment,{children:[I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>E(!0),disabled:k!==null,children:e(`settings.key.replace`)}),me.key_source!==`environment`&&I(`button`,{type:`button`,className:`btn-secondary settings-key-remove`,onClick:()=>D(!0),disabled:k!==null,"aria-label":e(`settings.key.remove`),title:e(`settings.key.remove`),children:I(oc,{size:14,"aria-hidden":`true`})})]})]}):R(`div`,{className:`settings-row`,children:[I(`input`,{className:`settings-input`,type:`password`,autoComplete:`off`,spellCheck:!1,autoFocus:T,value:C,onChange:e=>w(e.target.value),placeholder:e(T?`settings.key.pasteNew`:`settings.key.paste`),"aria-label":e(`settings.key.fieldAria`,{name:me.name})}),R(`button`,{type:`submit`,className:`btn-primary`,disabled:k!==null||!C,children:[k===`connect`?I(B,{size:13,className:`spin`}):null,e(T?`settings.key.save`:`settings.key.connect`)]}),T&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{w(``),E(!1)},disabled:k!==null,children:e(`settings.key.cancel`)})]}),me.key_source&&!_e&&!me.error&&!T&&I(`p`,{className:`settings-hint`,children:e(`settings.key.notConnectedHint`,{name:me.name})}),me.error&&I(`p`,{className:`settings-error`,role:`alert`,children:me.error})]}),M?.ok&&I(`p`,{className:`settings-ok`,role:`status`,children:M.text}),M&&!M.ok&&I(L$,{message:M.text}),me.known_models&&I(`p`,{className:`settings-hint`,role:`status`,children:e(`settings.key.knownList`,{name:me.name})}),Ue&&I(`div`,{className:`models-downloads-slot`,ref:de}),_e&&R(`div`,{className:`settings-field`,children:[I(`span`,{className:`settings-label`,children:e(`settings.model.models`)}),(h?.length??0)>6&&I(`input`,{className:`settings-input`,type:`search`,value:y,onChange:e=>b(e.target.value),placeholder:e(`settings.model.search`),"aria-label":e(`settings.model.search`)}),_&&!(u&&A$(_))&&I(L$,{message:_}),!h&&!_&&R(`p`,{className:`settings-hint`,children:[I(B,{size:13,className:`spin`}),` `,e(`settings.loading`)]}),h&&Me.length===0&&!_&&I(`p`,{className:`settings-hint`,children:e(Be||!Ue?`settings.model.noMatch`:`settings.model.noModels`)}),Ue?R(F.Fragment,{children:[We.length>0&&I(h$,{title:e(`settings.model.groupDownloaded`),count:We.length,defaultOpen:!0,forceOpen:Be,targetId:`models-on-pc`,children:I(`ul`,{className:`model-list`,children:We.map(Xe)})}),Ge.length>0&&I(h$,{title:e(`settings.model.groupAvailable`),count:Ge.length,defaultOpen:We.length===0,forceOpen:Be||oe||Ge.some(Tl),children:I(`ul`,{className:`model-list`,children:Ge.map(Xe)})})]}):I(`ul`,{className:`model-list`,children:Ie.map(Xe)}),Pe&&Le.length>0&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>S(!0),children:e(`settings.model.showAll`)}),p===`fireworks`&&x&&!Be&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>S(!1),children:e(`settings.model.showRecommended`)}),Re.length>0&&I(h$,{title:e(`settings.model.groupUnavailable`),count:Re.length,forceOpen:Be,children:I(`ul`,{className:`model-list`,children:Re.map(Xe)})})]}),Ue&&_e&&I(h$,{title:e(`settings.custom.title`),children:I(R$,{onAdded:e=>void Oe(e)})}),Ue&&_e&&I(V$,{downloadsSlot:ue}),me.remote&&I(Y$,{})]}),Je&&I(wZ,{title:e(`settings.models.removeTitle`,{name:ze[Je.id]??Je.id}),confirmLabel:Je.downloaded?e(`settings.model.removeDownload`):e(`settings.models.remove`),cancelLabel:e(`settings.models.keep`),danger:!0,onConfirm:()=>{ae(null),De(Je.id)},onCancel:()=>ae(null),children:Je.downloaded&&I(`p`,{children:e(`settings.model.removeDownloadBody`)})}),ee&&me&&I(wZ,{title:e(`settings.key.removeAsk`),confirmLabel:e(`settings.key.remove`),cancelLabel:e(`settings.models.keep`),danger:!0,onConfirm:()=>void we(),onCancel:()=>D(!1),children:I(`p`,{children:e(`settings.key.removeBody`,{name:me.name})})})]})}async function $$(){return Nn(`GET`,`/images/settings`)}async function e1(e){return Nn(`PUT`,`/images/settings`,e)}var t1=[4,8,12,20,30,50],n1=e=>`⁦${e}⁩`;function r1(e){return e instanceof On?e.detail||e.message:String(e)}function i1(){let e=L(),t=z(e=>e.openSettings),n=pH(e=>e.current)===`gaiacpp`;ol();let[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1),d=()=>{o(null),$$().then(i).catch(e=>o({unreachable:e instanceof On&&e.httpStatus===503,detail:r1(e)}))};(0,V.useEffect)(()=>{n||d()},[n]);let f=e=>{u(!0),c(null),e1(e).then(i).catch(e=>c(r1(e))).finally(()=>u(!1))},p=I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.images`)});if(n)return R(`div`,{className:`settings-pane`,children:[p,R(`div`,{className:`settings-notice`,role:`status`,children:[I(`p`,{children:e(`images.settings.fastAgentCannot`)}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>t(`model`),children:e.compose(e=>e(`mem.store.change`,{tab:e(`settings.section.model`)}))})]})]});if(a)return R(`div`,{className:`settings-pane`,children:[p,a.unreachable?R(F.Fragment,{children:[I(`p`,{className:`settings-error`,role:`alert`,children:e(`images.settings.unreachable`)}),I(`p`,{className:`settings-hint`,children:a.detail}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:d,children:e(`images.settings.retry`)})]}):I(`p`,{className:`settings-error`,role:`alert`,children:e(`images.settings.loadFailed`,{reason:a.detail})})]});if(!r)return R(`p`,{className:`settings-hint`,children:[I(B,{size:13,className:`spin`}),` `,e(`settings.loading`)]});let m=r.models.find(e=>e.id===r.model),h=m?[...new Set([...t1,m.default_steps,...r.steps?[r.steps]:[]])].filter(e=>e<=r.max_steps).sort((e,t)=>e-t):[];return R(`div`,{className:`settings-pane`,children:[p,I(`p`,{className:`settings-pane-lede`,children:e(`images.settings.lede`)}),!r.chat_model_creates_images&&R(`div`,{className:`settings-notice`,role:`status`,children:[I(`p`,{children:e(`images.settings.chatModelCannot`,{model:cl(r.chat_model)})}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>t(`model`),children:e(`images.settings.chooseChatModel`)})]}),!r.model_available&&I(`p`,{className:`settings-error`,role:`alert`,children:e(`images.settings.modelGone`,{model:r.model})}),r.models.length===0?I(`p`,{className:`settings-hint`,children:e(`images.settings.noModels`)}):R(F.Fragment,{children:[R(`div`,{className:`settings-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`image-model`,children:e(`images.settings.model`)}),R(`select`,{id:`image-model`,className:`settings-input`,value:r.model_available?r.model:``,disabled:l,onChange:e=>f({model:e.target.value}),children:[!r.model_available&&I(`option`,{value:``,disabled:!0,children:r.model}),r.models.map(t=>I(`option`,{value:t.id,children:t.downloads_on_first_use?e.bare(`images.settings.downloadsOnFirstUse`,{model:t.id,size:n1(`${t.size_gb??`?`} GB`)}):t.id},t.id))]})]}),m&&R(F.Fragment,{children:[R(`div`,{className:`settings-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`image-size`,children:e(`images.settings.size`)}),R(`select`,{id:`image-size`,className:`settings-input`,value:r.size??``,disabled:l,onChange:e=>f({size:e.target.value||null}),children:[I(`option`,{value:``,children:e.bare(`images.settings.automatic`,{value:n1(m.default_size)})}),m.sizes.map(e=>I(`option`,{value:e,children:n1(e)},e))]})]}),R(`div`,{className:`settings-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`image-steps`,children:e(`images.settings.steps`)}),R(`select`,{id:`image-steps`,className:`settings-input`,value:r.steps??``,disabled:l,onChange:e=>f({steps:e.target.value?Number(e.target.value):null}),children:[I(`option`,{value:``,children:e.bare(`images.settings.automatic`,{value:n1(String(m.default_steps))})}),h.map(e=>I(`option`,{value:e,children:n1(String(e))},e))]}),I(`span`,{className:`settings-hint`,children:e(`images.settings.stepsHint`)})]})]})]}),I(`p`,{className:`settings-hint`,children:e(`images.settings.shared`)}),s&&I(`p`,{className:`settings-error`,role:`alert`,children:e(`images.settings.saveFailed`,{reason:s})})]})}var a1=`[data-settings-target="cloud-key"]`;function o1(e,t){return e.available!==!1&&(t||e.downloaded)}function s1(){let e=L(),t=z(e=>e.openSettings),n=z(e=>e.jumpToSetting),r=z(e=>e.isStreaming),i=il(e=>e.active?.model);il(e=>e.names);let[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)([]),[l,u]=(0,V.useState)(null),[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)(null),h=(0,V.useCallback)(async()=>{u(null);try{let[e,{providers:t}]=await Promise.all([rt(),At()]),n=await Promise.all(t.filter(e=>!e.remote||e.models_discovered||e.id===`fireworks`).map(async e=>{if(e.blocked||e.remote&&!e.models_discovered)return{provider:e,models:[]};try{return{provider:e,models:(await Zn(e.id)).models}}catch(t){return{provider:e,models:[],error:VF(t)}}}));il.getState().rememberNames(n.flatMap(e=>e.models)),c(n),o(e)}catch(e){u(VF(e))}},[]);(0,V.useEffect)(()=>{h()},[h,i]);let g=async(e,t)=>{m(e),f(null);try{o(await t()),await al(i)}catch(t){f({mode:e,text:VF(t)})}finally{m(null)}},_=I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.mode`)});return l?R(`div`,{className:`settings-pane`,children:[_,I(`p`,{className:`settings-error`,role:`alert`,children:e(`runMode.settings.loadFailed`,{reason:l})}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void h(),children:e(`runMode.settings.retry`)})]}):a?R(`div`,{className:`settings-pane`,children:[_,I(`p`,{className:`settings-pane-lede`,children:e(`runMode.settings.lede`)}),r&&I(`p`,{className:`settings-hint`,role:`status`,children:e(`runMode.settings.turnRunning`)}),a.modes.map(i=>{let a=i.id===`cloud`,o=s.filter(e=>e.provider.remote===a),c=a&&o.some(e=>e.provider.blocked),l=o.filter(e=>!e.provider.remote||e.provider.models_discovered),u=a&&!c&&l.length===0,f=u&&o.some(e=>e.provider.key_source),m=l.map(e=>({...e,models:e.models.filter(e=>o1(e,a))})),h=m.flatMap(e=>e.models).find(e=>wl(i.chat.model,e.id)),_=l.length>0&&l.every(e=>!e.error),v=!a&&_&&!h,y=!c&&!u&&!v,b=e(`runMode.${i.id}`),x=i.chat.provider_name??_l(`fireworks`),S=a?Pi:Wi,C=t=>{let n=t.display_name??cl(t.id);return t.rank?e.bare(`runMode.settings.recommended`,{name:n}):t.tight?e.bare(`runMode.settings.tight`,{name:n}):n},w=`run-mode-chat-${i.id}`;return R(`section`,{className:`settings-card run-mode-card${i.active?` is-active`:``}`,"aria-labelledby":`run-mode-${i.id}`,"data-run-mode":i.id,children:[R(`div`,{className:`run-mode-card-head`,children:[R(`h3`,{className:`run-mode-card-title`,id:`run-mode-${i.id}`,children:[I(S,{size:15,"aria-hidden":`true`}),` `,b,i.active&&I(`span`,{className:`run-mode-badge`,children:e(`runMode.settings.inUse`)})]}),R(`div`,{className:`run-mode-card-actions`,children:[!i.active&&R(`button`,{type:`button`,className:`btn-primary`,disabled:!y||r||p!==null,onClick:()=>void g(i.id,()=>Oe(i.id)),children:[p===i.id&&I(B,{size:13,className:`spin`,"aria-hidden":`true`}),e(`runMode.settings.use.${i.id}`)]}),R(`button`,{type:`button`,className:`btn-secondary`,disabled:!i.chat.customized||p!==null||i.active&&r,title:i.chat.customized?e(`runMode.settings.resetTitle`,{name:i.chat.default_display_name}):e(`runMode.settings.resetNothing`),onClick:()=>void g(i.id,()=>Te(i.id)),children:[I(vs,{size:13,"aria-hidden":`true`}),` `,e(`runMode.settings.reset`)]})]})]}),I(`p`,{className:`settings-hint`,children:a?e(`runMode.settings.cloudLede`,{provider:x}):e(`runMode.localNote`)}),c&&R(`div`,{className:`settings-notice`,role:`status`,children:[I(`p`,{children:e(`settings.privacy.localOnlyBlocked`)}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>t(`privacy`),children:e(`runMode.settings.openPrivacy`)})]}),u&&R(`div`,{className:`settings-notice`,role:`status`,children:[I(`p`,{children:e(f?`runMode.settings.keyNotWorking`:`runMode.settings.needsKey`)}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>n({section:`model`,target:a1},`fireworks`),children:e(f?`runMode.settings.checkKey`:`runMode.settings.addKey`)})]}),v&&R(`div`,{className:`settings-notice`,role:`status`,children:[I(`p`,{children:e(`runMode.settings.notDownloaded`,{name:i.chat.display_name})}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>t(`model`,`local`),children:e(`runMode.settings.download`)})]}),o.filter(e=>e.error||e.provider.error).map(e=>I(`p`,{className:`settings-error`,role:`alert`,children:e.error??e.provider.error},e.provider.id)),d?.mode===i.id&&I(`p`,{className:`settings-error`,role:`alert`,children:d.text}),R(`dl`,{className:`run-mode-rows`,children:[R(`div`,{className:`run-mode-row`,children:[I(`dt`,{children:I(`label`,{htmlFor:w,children:e(`runMode.settings.chat`)})}),R(`dd`,{children:[m.some(e=>e.models.length>0)?R(`select`,{id:w,className:`settings-input`,value:h?.id??``,disabled:p!==null||i.active&&r,onChange:e=>void g(i.id,()=>A(i.id,e.target.value)),children:[!h&&I(`option`,{value:``,disabled:!0,children:e.bare(`runMode.settings.notListed`,{name:i.chat.display_name})}),m.map(e=>a?I(`optgroup`,{label:e.provider.name,children:e.models.map(e=>I(`option`,{value:e.id,children:C(e)},e.id))},e.provider.id):e.models.map(e=>I(`option`,{value:e.id,children:C(e)},e.id)))]}):I(`span`,{className:`run-mode-value`,dir:`auto`,children:i.chat.display_name}),I(`button`,{type:`button`,className:`link-btn run-mode-more`,onClick:()=>t(`model`,a?`fireworks`:`local`),children:e(`runMode.settings.moreModels`)})]})]}),i.capabilities.map(n=>R(`div`,{className:`run-mode-row`,children:[I(`dt`,{children:e(`runMode.cap.${n.id}`)}),R(`dd`,{children:[n.unavailable||!n.model?I(`span`,{className:`run-mode-value is-off`,children:e(`runMode.unavailable.${n.unavailable??`platform`}`)}):R(`span`,{className:`run-mode-value`,children:[e(`runMode.settings.onThisPc`),` · `,I(`bdi`,{dir:`ltr`,children:n.display_name})]}),n.settings&&!n.unavailable&&I(`button`,{type:`button`,className:`link-btn run-mode-more`,onClick:()=>t(n.settings),children:e(`runMode.settings.change`)}),n.cloud_note&&I(`span`,{className:`run-mode-why`,children:e(`runMode.cloudWhy.${n.cloud_note}`,{provider:x})})]})]},n.id))]})]},i.id)})]}):R(`p`,{className:`settings-hint`,children:[I(B,{size:13,className:`spin`}),` `,e(`settings.loading`)]})}function c1(){let e=L(),t=z(e=>e.sessions),[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(null),u=(0,V.useCallback)(async()=>{l(null);try{let e=await gr();r(e.sessions),a(e.default_mode),z.getState().setDefaultPermissionMode(e.default_mode)}catch(e){l(e instanceof Error?e.message:String(e))}},[]);(0,V.useEffect)(()=>{u()},[u]);let d=(0,V.useCallback)(async e=>{l(null);try{await e(),await u()}catch(e){l(e instanceof Error?e.message:String(e))}},[u]),f=(0,V.useCallback)(async e=>{s(!1),await d(()=>cr(e))},[d]),p=()=>{i===`full_access`?f(`ask`):s(e=>!e)},m=e=>t.find(t=>t.id===e)?.title??e;return R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.permissions`)}),I(`p`,{className:`settings-pane-lede`,children:e(`settings.permissions.lede`)}),R(`details`,{className:`settings-more`,children:[R(`summary`,{children:[I(fi,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,e(`settings.model.howItWorks`)]}),I(`p`,{className:`settings-hint`,children:e(`settings.permissions.perChat`)})]}),R(`section`,{className:`settings-card`,"aria-label":e(`settings.permissions.newChats`),children:[R(`label`,{className:`setting-row`,children:[I(`span`,{className:`settings-label`,children:e(`settings.permissions.fullAccess`)}),R(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,"data-settings-target":`full-access-default`,checked:i===`full_access`,onChange:p,disabled:i===null,"aria-label":e(`settings.permissions.fullAccess`)}),I(`span`,{className:`toggle-track`})]})]}),I(`p`,{className:`settings-hint`,children:e(i===`full_access`?`settings.permissions.on`:`settings.permissions.off`)}),o&&R(`div`,{className:`settings-warning`,role:`alert`,children:[I(`p`,{children:e(`settings.permissions.warning`)}),R(`div`,{className:`settings-row`,children:[I(`button`,{type:`button`,className:`btn-danger`,onClick:()=>void f(`full_access`),children:e(`settings.permissions.turnOn`)}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>s(!1),children:e(`settings.key.cancel`)})]})]})]}),c&&I(`p`,{className:`settings-error`,role:`alert`,children:c}),n&&n.length===0&&I(`p`,{className:`settings-hint`,children:e(`settings.permissions.none`)}),!!n?.length&&I(h$,{title:e(`settings.permissions.chats`),count:n.length,defaultOpen:!0,children:n.map(t=>R(`section`,{className:`settings-field permission-chat`,"aria-label":m(t.session_id),children:[R(`div`,{className:`settings-row settings-row-between`,children:[I(`bdi`,{className:`settings-label`,children:m(t.session_id)}),t.mode===`full_access`&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>d(async()=>{let e=(await Ue(t.session_id,`ask`)).mode;gU(t.session_id,e)}),children:e(`settings.permissions.turnOff`)})]}),t.grants.length>0&&I(`ul`,{className:`grant-list`,children:t.grants.map(n=>R(`li`,{className:`grant-row`,children:[I(`code`,{children:n.label}),I(`button`,{type:`button`,className:`link-btn`,onClick:()=>d(()=>Re(t.session_id,n.key)),"aria-label":e(`settings.permissions.revokeAria`,{name:n.label}),children:e(`settings.permissions.revoke`)})]},n.key))}),t.grants.length>1&&I(`button`,{type:`button`,className:`link-btn`,onClick:()=>d(()=>Re(t.session_id)),children:e(`settings.permissions.revokeAll`)})]},t.session_id))})]})}function l1({text:e}){let t=L(),n=(0,V.useRef)(null),[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(!1);return(0,V.useLayoutEffect)(()=>{let e=n.current;if(!e||r)return;let t=()=>o(e.scrollHeight>e.clientHeight+1);if(t(),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(t);return i.observe(e),()=>i.disconnect()},[e,r]),R(F.Fragment,{children:[I(`span`,{ref:n,className:`skill-row-desc${r?` is-open`:``}${a||r?` is-toggle`:``}`,dir:`auto`,onClick:a||r?e=>{e.preventDefault(),i(!r)}:void 0,children:I(`bdi`,{children:e})}),(a||r)&&I(`button`,{type:`button`,className:`skill-row-more`,"aria-expanded":r,onClick:()=>i(!r),children:t(r?`settings.skills.less`:`settings.skills.more`)})]})}function u1(e,t){if(e instanceof On&&e.reason===`link_not_found`){let n=e.body?.link;if(typeof n==`string`&&gt(`settings.skills.link.notFound`,{link:n})===e.detail)return t(`settings.skills.link.notFound`,{link:n})}return VF(e,t)}var d1=(e,t)=>!e.error&&(!e.installed||e.update)&&(t||!e.has_code);function f1(e,t){let n=e.added.filter(e=>e.updated).map(e=>e.name),r=e.added.filter(e=>!e.updated).map(e=>e.name),i=(e,n)=>n.length>3?t(`settings.skills.link.${e}Count`,{n:n.length}):t(`settings.skills.link.${e}`,{names:n.join(`, `)});return[r.length?i(`added`,r):``,n.length?i(`updated`,n):``].filter(Boolean).join(` `)}function p1({onAdded:e}){let t=L(),[n,r]=(0,V.useState)(``),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(new Set),[f,p]=(0,V.useState)(!1),[m,h]=(0,V.useState)(null),[_,v]=(0,V.useState)([]);(0,V.useEffect)(()=>{let e=!1;return dn().then(t=>{e||v(t.libraries)}).catch(n=>{e||s(t(`settings.skills.link.featuredFailed`,{error:VF(n,t)}))}),()=>{e=!0}},[t]);let y=async e=>{if(e.trim()){a(`preview`),s(null),l(null),h(null);try{let t=await g(e.trim());l(t),d(new Set(t.skills.filter(e=>d1(e,!1)).map(e=>e.name)))}catch(e){s(u1(e,t))}finally{a(null)}}},b=async()=>{if(c&&u.size!==0){a(`add`),s(null);try{let t=await Mt(c.link,[...u],f,c.pin);h(t),l(null),r(``),t.added.length&&e()}catch(e){s(u1(e,t))}finally{a(null)}}},x=e=>d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),S=e=>{if(p(e),!e&&c){let e=new Set(c.skills.filter(e=>e.has_code).map(e=>e.name));d(t=>new Set([...t].filter(t=>!e.has(t))))}},C=c?.skills.filter(e=>d1(e,f))??[],w=C.length>0&&C.every(e=>u.has(e.name)),T=c?.skills.some(e=>e.has_code&&!e.error)??!1;return R(`div`,{className:`settings-card skill-link`,children:[R(`div`,{className:`skill-link-top`,children:[I(`span`,{className:`settings-label`,children:t(`settings.skills.link.title`)}),_.map(e=>{let n=`settings.skills.link.featured.${e.id}`,a=j(n);return I(`button`,{type:`button`,className:`btn-secondary skill-link-chip`,onClick:()=>{r(e.url),y(e.url)},disabled:i!==null,title:a?t(n):e.description,"aria-label":t(`settings.skills.link.getAria`,{name:e.name,description:a?de(n):e.description}),children:t(`settings.skills.link.get`,{name:e.name})},e.id)})]}),R(`form`,{className:`skill-link-form`,onSubmit:e=>{e.preventDefault(),y(n)},children:[I(`input`,{className:`settings-input`,type:`text`,inputMode:`url`,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Escape`&&i===null&&(c||n)&&(e.preventDefault(),c?l(null):r(``))},...Lt,onPaste:e=>{if(i!==null)return;let t=e.clipboardData.getData(`text`).trim();t&&(e.preventDefault(),r(t),y(t))},placeholder:t.bare(`settings.skills.link.placeholder`),title:t(`settings.skills.link.hint`),"aria-label":t(`settings.skills.link.aria`),readOnly:i!==null,"aria-busy":i===`preview`}),I(`button`,{type:`submit`,className:`btn-secondary`,disabled:!n.trim()||i!==null,children:i===`preview`?R(F.Fragment,{children:[I(B,{size:13,className:`spin`}),` `,t(`settings.skills.link.reading`)]}):t(`settings.skills.link.read`)})]}),o&&I(`p`,{className:`settings-error`,role:`alert`,children:o}),c&&R(`div`,{className:`skill-link-preview`,children:[R(`details`,{className:`skill-link-warning`,role:`note`,children:[R(`summary`,{children:[I(cc,{size:14,"aria-hidden":`true`}),t(`settings.skills.link.trust`)]}),I(`p`,{children:I(`bdi`,{children:c.warning})})]}),R(`div`,{className:`skill-link-head`,children:[I(`span`,{children:t(`settings.skills.link.found`,{n:c.skills.length,source:c.source})}),C.length>1&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>d(w?new Set:new Set(C.map(e=>e.name))),children:t(w?`settings.skills.link.none`:`settings.skills.link.all`)})]}),I(`ul`,{className:`skill-list skill-link-list`,children:c.skills.map(e=>{let n=d1(e,f),r=e.error?e.verdict===`BLOCK`?t(`settings.skills.link.tagBlocked`):t(`settings.skills.link.tagUnreadable`):e.installed&&!e.update?t(`settings.skills.link.tagElsewhere`):e.update?t(`settings.skills.link.tagUpdate`):null,i=e.error??(e.installed&&!e.update?t(`settings.skills.link.whyElsewhere`):e.update?t(`settings.skills.link.whyUpdate`):null),a=!!i||e.findings.length>0||e.has_code&&!f;return I(`li`,{className:`skill-row`,children:R(`label`,{className:`skill-link-pick`,children:[I(`input`,{type:`checkbox`,checked:n&&u.has(e.name),disabled:!n,onChange:()=>x(e.name),"aria-label":t(`settings.skills.link.addAria`,{name:e.name})}),R(`span`,{className:`skill-row-text`,children:[R(`span`,{className:`skill-row-name`,children:[e.name,r&&I(`span`,{className:`skill-link-tag${e.error?` is-bad`:``}`,children:r}),e.has_code&&I(`span`,{className:`skill-link-tag`,children:t(`settings.skills.link.tagCode`)}),e.verdict===`REVIEW`&&I(`span`,{className:`skill-link-tag`,children:t(`settings.skills.link.tagReview`)})]}),e.description&&I(l1,{text:e.description}),e.permissions.length>0?R(`span`,{className:`skill-link-perms`,children:[I(`span`,{className:`skill-link-perms-label`,children:t(`settings.skills.link.can`)}),I(`ul`,{"aria-label":t(`settings.skills.link.permsAria`,{name:e.name}),children:e.permissions.map(e=>R(`li`,{children:[I(`bdi`,{children:e.text}),` `,I(`bdi`,{dir:`ltr`,children:I(`code`,{children:e.grant})})]},e.grant))})]}):I(`span`,{className:`skill-link-perms`,children:t(e.permissions_unreadable?`settings.skills.link.permissionsUnreadable`:`settings.skills.link.noPermissions`)}),a&&R(`details`,{className:`skill-link-findings`,children:[I(`summary`,{children:t(`settings.skills.link.details`)}),i&&I(`p`,{children:I(`bdi`,{children:i})}),e.has_code&&!f&&I(`p`,{children:t(`settings.skills.link.shipsCode`)}),e.findings.length>0&&I(`ul`,{children:e.findings.map(e=>I(`li`,{children:I(`bdi`,{children:e})},e))})]})]})]})},e.path)})}),R(`div`,{className:`skill-link-actions`,children:[T&&R(`label`,{className:`skill-link-code`,title:t(`settings.skills.link.codeHint`),children:[I(`input`,{type:`checkbox`,checked:f,onChange:e=>S(e.target.checked)}),I(`span`,{children:t(`settings.skills.link.includeCode`)})]}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>l(null),disabled:i!==null,children:t(`settings.skills.link.cancel`)}),I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void b(),disabled:u.size===0||i!==null,children:i===`add`?R(F.Fragment,{children:[I(B,{size:13,className:`spin`}),` `,t(`settings.skills.link.adding`)]}):t(`settings.skills.link.add`,{n:u.size})})]})]}),m&&R(`div`,{className:`skill-link-result`,role:`status`,children:[m.added.length>0&&I(`p`,{children:f1(m,t)}),Object.keys(m.failed).length>0&&R(`details`,{children:[I(`summary`,{children:t(`settings.skills.link.notAdded`,{n:Object.keys(m.failed).length})}),I(`ul`,{className:`grant-list`,children:Object.entries(m.failed).map(([e,t])=>R(`li`,{children:[I(`bdi`,{children:I(`strong`,{children:e})}),` — `,I(`bdi`,{children:t})]},e))})]})]})]})}var m1={path:`~/.gaia/skills`},h1=[{source:`agent-bundled`,title:`settings.skills.bundled`,note:`settings.skills.bundledNote`},{source:`user`,title:`settings.skills.yours`,note:`settings.skills.yoursNote`,empty:`settings.skills.yoursEmpty`,params:m1},{source:`claude-project`,title:`settings.skills.project`,note:`settings.skills.projectNote`,params:{path:`.claude/skills`}},{source:`claude-import`,title:`settings.skills.import`,note:`settings.skills.importNote`}];function g1(e){return/description is \d+ characters/.test(e)?`settings.skills.skipped.tooLong`:/'description' is missing/.test(e)?`settings.skills.skipped.noDescription`:`settings.skills.skipped.other`}function _1({onUseSkill:e}){let t=L(),[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)({}),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(``),[u,d]=(0,V.useState)(null),[f,p]=(0,V.useState)(null),m=(0,V.useRef)(null),h=(0,V.useRef)(!0),g=(0,V.useCallback)(()=>{jn().then(e=>{h.current&&(r(e.skills),a(e.invalid),s(null))}).catch(e=>{h.current&&s(e instanceof Error?e.message:String(e))})},[]);(0,V.useEffect)(()=>(h.current=!0,g(),window.addEventListener(`focus`,g),()=>{h.current=!1,window.removeEventListener(`focus`,g)}),[g]);let _=async e=>{d({name:e,busy:!0}),p(null);try{await E(e)}catch(n){h.current&&p(t(`settings.skills.removeFailed`,{name:e,error:VF(n,t)}))}finally{h.current&&d(null),g()}},v=c.trim().toLowerCase(),y=(n??[]).filter(e=>!v||e.name.toLowerCase().includes(v)||e.description.toLowerCase().includes(v)),b=n?.every(e=>h1.some(t=>t.source===e.source))??!1,x=n=>R(`li`,{className:`skill-row`,children:[R(`div`,{className:`skill-row-text`,children:[R(`span`,{className:`skill-row-name`,children:[I(`span`,{title:n.version?`v${n.version}`:void 0,children:n.name}),n.always_on&&R(`span`,{className:`skill-row-meta`,children:[` · `,t(`settings.skills.alwaysOn`)]})]}),I(l1,{text:n.description})]}),R(`div`,{className:`skill-row-actions`,children:[!n.always_on&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>e(n.name),"aria-label":t(`settings.skills.useAria`,{name:n.name}),children:t(`settings.skills.try`)}),n.source===`user`&&I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{p(null),d({name:n.name,busy:!1})},"aria-label":t(`settings.skills.removeAria`,{name:n.name}),children:t(`settings.skills.remove`)})]})]},n.name);return R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:t(`settings.section.skills`)}),I(`p`,{className:`settings-pane-lede`,children:t(`settings.skills.lede`)}),R(`details`,{className:`settings-more`,children:[R(`summary`,{children:[I(fi,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,t(`settings.model.howItWorks`)]}),I(`p`,{className:`settings-hint`,children:t(`settings.skills.how`,m1)})]}),I(p1,{onAdded:g}),o&&I(`p`,{className:`settings-error`,role:`alert`,children:o}),f&&I(`p`,{className:`settings-error`,role:`alert`,children:f}),!n&&!o&&R(`p`,{className:`settings-hint`,children:[I(B,{size:13,className:`spin`}),` `,t(`settings.loading`)]}),n&&n.length>6&&I(`input`,{ref:m,className:`settings-input`,type:`search`,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&c&&(e.preventDefault(),l(``))},...Lt,placeholder:t(`settings.skills.search`),"aria-label":t(`settings.skills.search`)}),n&&n.length===0&&I(`p`,{className:`settings-hint`,children:t(`settings.skills.none`)}),v&&n&&n.length>0&&y.length===0&&R(`p`,{className:`settings-hint`,role:`status`,children:[t(`settings.skills.noMatch`,{query:c.trim()}),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>{l(``),m.current?.focus()},children:t(`settings.skills.clearSearch`)})]}),b?h1.map(e=>{let n=y.filter(t=>t.source===e.source);return n.length===0&&(v||!e.empty)?null:I(h$,{title:t(e.title),count:n.length,hint:t(e.note,e.params),defaultOpen:e.source===`agent-bundled`||e.source===`user`&&n.length>0,forceOpen:!!v,children:I(`section`,{"aria-label":t(e.title),children:n.length===0?I(`p`,{className:`settings-hint`,children:e.empty&&t(e.empty,e.params)}):I(`ul`,{className:`skill-list`,children:n.map(x)})})},e.source)}):I(`ul`,{className:`skill-list`,children:y.map(x)}),Object.keys(i).length>0&&R(`div`,{className:`settings-card`,role:`alert`,children:[I(`span`,{className:`settings-label`,children:t(`settings.skills.skipped`)}),I(`ul`,{className:`grant-list`,children:Object.entries(i).map(([e,n])=>I(`li`,{children:t(g1(n),{name:e.split(/[\\/]/).filter(Boolean).pop()??e})},e))})]}),u&&I(wZ,{title:t(`settings.skills.removeTitle`,{name:u.name}),confirmLabel:t(`settings.skills.remove`),cancelLabel:t(`settings.skills.keep`),danger:!0,busy:u.busy,onConfirm:()=>void _(u.name),onCancel:()=>d(null),children:I(`p`,{children:t(`settings.skills.removeBody`,m1)})})]})}var v1=`profile`;function y1(){let e=L(),[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(!1);(0,V.useEffect)(()=>{HP().then(n).catch(e=>i(e instanceof Error?e.message:String(e)))},[]);let l=(0,V.useCallback)(async e=>{o(!0),i(null),c(!1);try{let t=await UP(e===v1?null:e);n(t),c(t.changed!==!1)}catch(e){i(e instanceof Error?e.message:String(e)),await HP().then(n).catch(()=>void 0)}finally{o(!1)}},[]);if(!t)return r?I(`p`,{className:`settings-error`,role:`alert`,children:r}):R(`p`,{className:`settings-hint`,children:[I(B,{size:13,className:`spin`}),` `,e(`settings.memory.embedder.checking`)]});let u=t.options.find(e=>e.device===t.device),d=t=>e.bare(t===`npu`?`settings.memory.embedder.npu`:`settings.memory.embedder.gpu`);return R(F.Fragment,{children:[R(`div`,{className:`model-in-use-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`embedder-device`,children:e(`settings.memory.embedder.label`)}),R(`select`,{id:`embedder-device`,className:`settings-input`,value:t.chosen?t.device:v1,onChange:e=>void l(e.target.value),disabled:a,children:[I(`option`,{value:v1,children:e.bare(`settings.memory.embedder.default`,{device:d(t.default_device)})}),t.options.map(t=>I(`option`,{value:t.device,disabled:t.available===!1,children:t.present===!1?e.bare(`settings.memory.embedder.unavailable`,{device:d(t.device)}):t.proven?d(t.device):e.bare(`settings.memory.embedder.unproven`,{device:d(t.device)})},t.device))]})]}),R(`span`,{className:`settings-hint`,children:[e(`settings.memory.embedder.runsOn`,{name:Ge(u?.display_name??t.device,`ltr`),device:d(t.device)}),` `,e(`settings.memory.embedder.why`)]}),t.options.some(e=>e.device===`npu`&&!e.proven&&e.present)&&I(`span`,{className:`settings-hint`,children:e(`settings.memory.embedder.npuUnproven`)}),u?.downloaded===!1&&I(`span`,{className:`settings-hint`,children:e(`settings.memory.embedder.notDownloaded`)}),a&&R(`span`,{className:`settings-hint`,children:[I(B,{size:13,className:`spin`}),` `,e(`settings.memory.embedder.applying`)]}),s&&I(`p`,{className:`settings-ok`,role:`status`,children:e(`settings.memory.embedder.changed`)}),r&&I(`p`,{className:`settings-error`,role:`alert`,children:r})]})}function b1(){let e=L(),t=z(e=>e.setShowMemoryDashboard),n=z(e=>e.closeSettings),r=z(e=>e.openSettings),i=pH(e=>e.current)===`gaiacpp`,[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1);(0,V.useEffect)(()=>{BP().then(o).catch(e=>c(e instanceof Error?e.message:String(e)))},[]);let d=(0,V.useCallback)(async()=>{if(a){u(!0),c(null);try{o(await VP({memory_enabled:!a.memory_enabled}))}catch(e){c(e instanceof Error?e.message:String(e))}finally{u(!1)}}},[a]);return R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.memory`)}),I(`p`,{className:`settings-pane-lede`,children:e(`settings.memory.lede`)}),i&&R(`div`,{className:`settings-notice`,role:`status`,children:[I(`p`,{children:e(`settings.memory.fastAgentNotice`)}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>r(`model`),children:e.compose(e=>e(`mem.store.change`,{tab:e(`settings.section.model`)}))})]}),R(`section`,{className:`settings-card`,"aria-label":e(`settings.section.memory`),children:[R(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`settings.memory.remember`)}),R(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,checked:!!a?.memory_enabled,onChange:()=>void d(),disabled:!a||l,"aria-label":e(`settings.memory.remember`)}),I(`span`,{className:`toggle-track`})]})]}),s&&I(`p`,{className:`settings-error`,role:`alert`,children:s}),R(`div`,{className:`settings-row settings-row-between`,children:[I(`span`,{className:`settings-hint`,children:e(`settings.memory.dashboardHint`)}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{n(),t(!0)},children:e(`settings.memory.dashboard`)})]})]}),!i&&I(`section`,{className:`settings-card`,"aria-label":e(`settings.memory.embedder.label`),children:I(y1,{})})]})}function x1(e,t,n){if(!/^\d+$/.test(e.trim()))return!1;let r=Number(e);return r>=t&&r<=n}function S1(e){return e<1048576?`${Math.ceil(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function C1(){let e=L(),[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(``),[a,o]=(0,V.useState)(``),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1);(0,V.useEffect)(()=>{zn().then(e=>{n(e),i(String(e.retention_days)),o(String(e.max_mb))},t=>c({ok:!1,text:e(`settings.undo.readFailed`,{reason:t instanceof Error?t.message:String(t)})}))},[e]);let[d,f]=(0,V.useState)({days:!1,mb:!1}),p=!x1(r,1,365)||d.days,m=!x1(a,10,1e5)||d.mb,h=t!==null&&(r!==String(t.retention_days)||a!==String(t.max_mb)),g=async()=>{if(!(p||m)){u(!0),c(null);try{let t=await ce(Number(r),Number(a));n(t),c({ok:!0,text:e(`settings.undo.saved`)})}catch(t){let n=t instanceof On&&t.httpStatus===422?t.fields:[],r=n.includes(`retention_days`),i=n.includes(`max_mb`);r||i?(f({days:r,mb:i}),c({ok:!1,text:e(`settings.undo.fix`)})):c({ok:!1,text:t instanceof Error?t.message:String(t)})}finally{u(!1)}}};return R(`div`,{className:`settings-field`,"aria-label":e(`settings.privacy.undo`),children:[I(`span`,{className:`settings-label`,children:e(`settings.privacy.undo`)}),I(`p`,{className:`settings-hint`,children:e(`settings.undo.hint`)}),t&&R(F.Fragment,{children:[R(`div`,{className:`setting-row`,children:[I(`label`,{htmlFor:`undo-days`,children:e(`settings.undo.days`)}),I(`input`,{id:`undo-days`,type:`number`,className:`model-input undo-history-input`,min:1,max:365,value:r,"aria-invalid":p,"aria-describedby":p?`undo-days-error`:void 0,onChange:e=>{i(e.target.value),f(e=>({...e,days:!1}))}})]}),p&&I(`p`,{id:`undo-days-error`,className:`settings-error`,children:e(`settings.undo.daysError`)}),R(`div`,{className:`setting-row`,children:[I(`label`,{htmlFor:`undo-mb`,children:e(`settings.undo.mb`)}),I(`input`,{id:`undo-mb`,type:`number`,className:`model-input undo-history-input`,min:10,max:1e5,value:a,"aria-invalid":m,"aria-describedby":m?`undo-mb-error`:void 0,onChange:e=>{o(e.target.value),f(e=>({...e,mb:!1}))}})]}),m&&I(`p`,{id:`undo-mb-error`,className:`settings-error`,children:e(`settings.undo.mbError`)}),R(`div`,{className:`setting-row setting-row-path`,children:[I(`span`,{children:e(`settings.undo.inUse`)}),R(`span`,{children:[e.plural(`settings.undo.used`,t.turns,{size:S1(t.used_bytes)}),` `,I(`bdi`,{dir:`ltr`,children:I(`code`,{className:`setting-path`,children:t.path})})]})]}),I(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void g(),disabled:!h||l||p||m,children:e(l?`settings.models.applying`:`settings.advanced.save`)})]}),s&&I(`p`,{className:s.ok?`settings-ok`:`settings-error`,role:s.ok?`status`:`alert`,children:s.text})]})}var w1={root:`settings-report`,button:`btn-secondary`,hint:`settings-hint`,error:`settings-error`};function T1(){let e=L(),t=z(e=>e.sessions),n=z(e=>e.removeSession),r=fl(),i=z(e=>e.systemStatus?.data_dir),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(null),[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)(!1),[h,g]=(0,V.useState)(null);(0,V.useEffect)(()=>{let e=!0;return Ne().then(t=>{e&&f(t.network_policy===`local_ai_only`)}).catch(t=>{e&&g({ok:!1,text:t instanceof Error?t.message:String(t)})}),()=>{e=!1}},[]);let _=(0,V.useCallback)(async()=>{if(d===null||p)return;let t=d,n=il.getState().active?.model,r=!t;f(r),m(!0),g(null);try{let t=await Pn({network_policy:r?`local_ai_only`:`cloud_allowed`});f(t.network_policy===`local_ai_only`),al(n);let i=t.policy_notices??[],a=i.some(e=>e.severity===`warning`),o=i.length?i.map(t=>t.code===`users_server_keeps_keys`?e(`settings.privacy.usersServerKeepsKeys`,{url:t.url??``}):t.code===`runtime_keys_not_dropped`?e(`settings.privacy.runtimeKeysNotDropped`,{reason:t.reason??``}):t.code===`saved_models_not_checked`&&t.cause===`model_server_down`&&t.models?.length?e.plural(`settings.privacy.savedModelNotCheckedServerDown`,t.models.length,{models:t.models.join(`, `)}):t.code===`saved_models_not_checked`?e(`settings.privacy.savedModelsNotChecked`,{reason:t.reason??``}):e(`settings.privacy.policyNoticeUnknown`)).join(` `):e(r?`settings.privacy.localOnlyOn`:`settings.privacy.localOnlyOff`);g({ok:!a,text:o})}catch(e){f(t),g({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{m(!1)}},[d,p,e]),v=(0,V.useCallback)(async t=>{try{await nr(t,!1)}catch(t){u({ok:!1,text:e(`settings.privacy.openFolderFailed`,{reason:t instanceof Error?t.message:String(t)})})}},[e]),y=(0,V.useCallback)(async()=>{c(!0);let r=[];for(let e of t)try{await lr(e.id),n(e.id)}catch(t){r.push(`${e.title}: ${t instanceof Error?t.message:t}`)}c(!1),o(null),u(r.length?{ok:!1,text:e(`settings.privacy.deleteFailed`,{n:r.length,reason:r.join(`; `)})}:{ok:!0,text:e(`settings.privacy.deleted`)})},[n,t,e]);return R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.privacy`)}),R(`section`,{className:`settings-card`,"aria-label":e(`settings.privacy.localOnlyTitle`),children:[R(`div`,{children:[R(`label`,{className:`setting-row`,children:[I(`strong`,{children:e(`settings.privacy.localOnlyTitle`)}),R(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,role:`switch`,"data-settings-target":`local-only`,checked:d===!0,"aria-label":e(`settings.privacy.localOnlyTitle`),"aria-describedby":`privacy-local-only-hint`,onChange:()=>void _(),disabled:d===null,"aria-busy":p}),I(`span`,{className:`toggle-track`})]})]}),I(`p`,{className:`settings-hint`,id:`privacy-local-only-hint`,children:e(`settings.privacy.localOnlyHint`)})]}),h&&I(`p`,{className:h.ok?`settings-ok`:`settings-error`,role:h.ok?`status`:`alert`,children:h.text})]}),R(`section`,{className:`settings-card`,"aria-labelledby":`privacy-where-title`,children:[I(`h3`,{className:`settings-label`,id:`privacy-where-title`,children:e(`settings.privacy.whereTitle`)}),I(`p`,{className:`settings-note`,children:e(`settings.privacy.stays`)}),I(`p`,{className:r?.remote?`settings-note`:`settings-hint`,children:r?.remote?e(`settings.privacy.remote`,{name:r.label}):e(r?`settings.privacy.local`:`settings.privacy.unknown`)}),i&&R(`div`,{className:`setting-row setting-row-path`,children:[I(`span`,{children:e(`settings.privacy.dataFolder`)}),R(`span`,{className:`setting-path-actions`,children:[I(`bdi`,{dir:`ltr`,className:`setting-path`,children:i}),I(`button`,{type:`button`,className:`link-btn`,onClick:()=>void v(i),children:e(`settings.privacy.openFolder`)})]})]})]}),R(`section`,{className:`settings-card`,"aria-labelledby":`privacy-report-title`,children:[I(`h3`,{className:`settings-label`,id:`privacy-report-title`,children:e(`settings.privacy.reportTitle`)}),I(`p`,{className:`settings-note`,children:e(`settings.privacy.reportNote`)}),I(fR,{classes:w1})]}),I(h$,{title:e(`settings.privacy.undo`),children:I(C1,{})}),R(`section`,{className:`settings-card`,"aria-labelledby":`privacy-delete-title`,children:[I(`h3`,{className:`settings-label`,id:`privacy-delete-title`,children:e(`settings.privacy.deleteTitle`)}),I(`p`,{className:`danger-warning`,children:t.length===0?e(`settings.privacy.nothingToDelete`):e(`settings.privacy.deleteWarning`)}),I(`button`,{type:`button`,className:`btn-danger`,onClick:()=>{u(null),o(t.length)},disabled:t.length===0,children:e(`settings.privacy.delete`)})]}),a!==null&&R(wZ,{title:e.plural(`settings.privacy.deleteAsk`,a),confirmLabel:e.plural(`settings.privacy.deleteYes`,a),cancelLabel:e(`settings.privacy.deleteCancel`),onConfirm:()=>void y(),onCancel:()=>o(null),danger:!0,busy:s,children:[I(`p`,{children:e(`settings.privacy.deleteWarning`)}),I(`p`,{children:e(`settings.privacy.deleteFinal`)})]}),l&&I(`p`,{className:l.ok?`settings-ok`:`settings-error`,role:l.ok?`status`:`alert`,children:l.text})]})}var E1=[{id:`needs_approval`,label:`settings.alerts.approval`},{id:`question`,label:`settings.alerts.question`},{id:`finished`,label:`settings.alerts.finished`}],D1=[{value:`banner`,label:`settings.alerts.banner`},{value:`badge`,label:`settings.alerts.badge`},{value:`off`,label:`settings.alerts.off`}],O1=[0,10,20,30,50];function k1(){return typeof Notification>`u`?`unsupported`:Notification.permission}function A1(){let e=L(),t=wu(),n=!!window.gaiaAPI,[r,i]=(0,V.useState)(k1),a=Object.values(t.modes).includes(`banner`);return R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.notifications`)}),I(`p`,{className:`settings-pane-lede`,children:e(`settings.alerts.lede`)}),R(`section`,{className:`settings-card`,"aria-label":e(`settings.alerts.when`),children:[E1.map(n=>R(`div`,{className:`setting-row`,children:[I(`span`,{id:`alert-${n.id}`,children:e(n.label)}),I(sF,{className:`segmented`,"aria-labelledby":`alert-${n.id}`,children:D1.map(r=>I(`button`,{type:`button`,role:`radio`,"aria-checked":t.modes[n.id]===r.value,className:t.modes[n.id]===r.value?`is-active`:``,onClick:()=>t.setMode(n.id,r.value),children:e(r.label)},r.value))})]},n.id)),!n&&a&&r!==`granted`&&(r==="default"?I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{Notification.requestPermission().then(i).catch(e=>{console.error(`[alerts] Notification permission request failed`,e),i(k1())})},children:e(`settings.alerts.allow`)}):I(`p`,{className:`settings-error`,role:`alert`,children:e(r===`unsupported`?`settings.alerts.unsupported`:`settings.alerts.blocked`)})),R(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`settings.alerts.sound`)}),R(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,checked:t.sound,onChange:()=>t.update({sound:!t.sound}),"aria-label":e(`settings.alerts.sound`)}),I(`span`,{className:`toggle-track`})]})]}),n&&R(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`settings.alerts.flash`)}),R(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,checked:t.flash,onChange:()=>t.update({flash:!t.flash}),"aria-label":e(`settings.alerts.flash`)}),I(`span`,{className:`toggle-track`})]})]})]}),R(`section`,{className:`settings-card`,"aria-labelledby":`keep-awake-title`,children:[I(`h3`,{className:`settings-label`,id:`keep-awake-title`,children:e(`settings.alerts.keepAwakeTitle`)}),n?R(F.Fragment,{children:[R(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`settings.alerts.keepAwake`)}),R(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,checked:t.keepAwake,onChange:()=>t.update({keepAwake:!t.keepAwake}),"aria-label":e(`settings.alerts.keepAwake`)}),I(`span`,{className:`toggle-track`})]})]}),R(`div`,{className:`setting-row`,children:[I(`label`,{htmlFor:`battery-floor`,children:e(`settings.alerts.battery`)}),I(`select`,{id:`battery-floor`,className:`settings-input settings-select-compact`,value:t.batteryFloor,disabled:!t.keepAwake,onChange:e=>t.update({batteryFloor:Number(e.target.value)}),children:O1.map(t=>I(`option`,{value:t,children:t===0?e.bare(`settings.alerts.never`):`${t}%`},t))})]}),I(`p`,{className:`settings-hint`,children:e(`settings.alerts.screen`)})]}):I(`p`,{className:`settings-hint`,children:e(`settings.alerts.desktopOnly`)})]})]})}var j1=[50,75,100,125,150,175,200],M1=[{accent:`american`,gender:`female`},{accent:`american`,gender:`male`},{accent:`british`,gender:`female`},{accent:`british`,gender:`male`}],N1=`settings:preview`,P1=`Hello, I'm GAIA. This is how I'll read my replies to you.`;function F1(e){return e instanceof On?e.detail||e.message:String(e)}function I1(){let e=L(),t=GL(e=>e.settings),n=GL(e=>e.setSettings),r=GL(e=>e.read),i=GL(e=>e.stop),a=GL(e=>e.messageId===N1),o=GL(e=>e.messageId===N1&&e.status===`loading`),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(null),[d,f]=(0,V.useState)(!1);(0,V.useEffect)(()=>{ML().then(n).catch(e=>c(F1(e)))},[n]);let p=e=>{f(!0),u(null),GL.getState().messageId===N1&&i(),NL(e).then(n).catch(e=>u(F1(e))).finally(()=>f(!1))};return s?R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.voice`)}),I(`p`,{className:`settings-error`,role:`alert`,children:e(`readAloud.settings.loadFailed`,{reason:s})})]}):t?t.available===!1?R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.voice`)}),I(`p`,{className:`settings-pane-lede`,role:`status`,children:e(`readAloud.settings.unavailable`)})]}):R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.voice`)}),I(`p`,{className:`settings-pane-lede`,children:e(`readAloud.settings.lede`)}),R(`div`,{className:`settings-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`read-aloud-voice`,children:e(`readAloud.settings.voice`)}),R(`div`,{className:`read-aloud-voice-row`,children:[I(`select`,{id:`read-aloud-voice`,className:`settings-input`,value:t.voice,disabled:d,onChange:e=>p({voice:e.target.value}),children:M1.map(n=>I(`optgroup`,{label:e(`readAloud.group.${n.accent}.${n.gender}`),children:t.voices.filter(e=>e.accent===n.accent&&e.gender===n.gender).map(e=>I(`option`,{value:e.id,lang:`en`,children:e.name},e.id))},`${n.accent}-${n.gender}`))}),R(`button`,{type:`button`,className:`btn-secondary`,"aria-pressed":a,disabled:d,onClick:()=>a?i():void r(N1,P1),children:[o?I(B,{size:13,className:`spin`}):I(a?ec:mc,{size:13}),e(a?`readAloud.stop`:`readAloud.settings.preview`)]})]}),I(`span`,{className:`settings-hint`,children:e(`readAloud.settings.englishOnly`)}),I(JL,{messageId:N1})]}),R(`div`,{className:`settings-field`,children:[I(`label`,{className:`settings-label`,htmlFor:`read-aloud-speed`,children:e(`readAloud.settings.speed`)}),I(`select`,{id:`read-aloud-speed`,className:`settings-input`,value:t.speed,disabled:d,onChange:e=>p({speed:Number(e.target.value)}),children:(j1.includes(t.speed)?j1:[...j1,t.speed].sort((e,t)=>e-t)).map(t=>I(`option`,{value:t,children:t===100?e.bare(`readAloud.settings.normalSpeed`):`⁦${(t/100).toLocaleString(e.locale)}×⁩`},t))})]}),R(`label`,{className:`setting-row`,children:[I(`span`,{children:e(`readAloud.settings.auto`)}),R(`span`,{className:`toggle-switch`,children:[I(`input`,{type:`checkbox`,checked:t.auto,disabled:d,onChange:()=>p({auto:!t.auto}),"aria-label":e(`readAloud.settings.auto`)}),I(`span`,{className:`toggle-track`})]})]}),I(`p`,{className:`settings-hint`,children:e(`readAloud.settings.shared`)}),l&&I(`p`,{className:`settings-error`,role:`alert`,children:e(`readAloud.settings.saveFailed`,{reason:l})})]}):R(`p`,{className:`settings-hint`,children:[I(B,{size:13,className:`spin`}),` `,e(`settings.loading`)]})}function L1(e,{message:t,model:n,reason:r,reasonCode:i}){if(!n||!r||gt(`model.restore.failed`,{model:n,reason:r})!==t)return Ge(t,`ltr`);let a=`model.restore.reason.${i}`;return e(`model.restore.failed`,{model:n,reason:i&&j(a)&&gt(a)===r?de(a):r})}function R1(){let e=L(),t=z(e=>e.jumpToSetting),n=z(e=>e.closeSettings),r=z(e=>e.runSetupAgain),i=il(e=>e.active),a=z(e=>e.systemStatus?.lemonade_running===!1),o=i?.restore?.status===`failed`&&!!i.model&&i.restore.model_id===i.model,s=i?.restore,c=o&&s?.message?L1(e,{message:s.message,model:s.model,reason:s.reason,reasonCode:s.reason_code}):null,l=!a&&o,[u,d]=(0,V.useState)(null),[f,p]=(0,V.useState)(null),[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)(null),[v,y]=(0,V.useState)(null),[b,x]=(0,V.useState)(!1);(0,V.useEffect)(()=>{Rn().then(d).catch(e=>y(e instanceof Error?e.message:String(e))),bn().then(p).catch(e=>y(e instanceof Error?e.message:String(e))),Nt().then(e=>h(e??null)).catch(e=>_(e instanceof Error?e.message:String(e)))},[]);let S=u?.catalog?.find(e=>e.id===u.chat_model.id),C=(i?.model?i.remote?i.label??cl(i.model):cl(i.model):null)??S?.name??null,w=(u?.catalog??[]).filter(e=>e.downloaded),T=w.reduce((e,t)=>e+(t.full_size_gb??0),0),E=[f?.gpu_name,f?.npu_detected?e(`setup.checks.npu`):null].filter(Boolean).join(` · `),ee=JA(u?.system?.physical_memory,f?.ram_gb),D=ee&&QA(e.locale,ee),O=u?.capacity_gb==null?null:QA(e.locale,GA(u.capacity_gb)),te=O?D?e(`settings.setup.memoryOf`,{size:O,total:D}):e(`settings.setup.memoryFor`,{size:O}):D,k=[{title:e(`settings.setup.where`),rows:[{label:e(`settings.setup.chatRuns`),value:C,section:`model`,target:`.model-in-use`},{label:e(`settings.setup.cloudKeys`),value:null,section:`model`,target:`[data-settings-target="cloud-key"]`,provider:`fireworks`}]},{title:e(`setup.pc.step`),rows:[{label:e(`settings.setup.detected`),value:[E,te].filter(Boolean).join(` · `)||null},{label:e(`settings.setup.server`),value:u?.lemonade.mode===`external`?e(`settings.setup.serverYours`):e(`settings.setup.serverOwn`),section:`advanced`,target:`[data-settings-target="model-server"]`},{label:e(`setup.gpu.title`),value:null,section:`model`,target:`#settings-gpu-title`,provider:`local`,shown:!!m?.applies||!!g&&!A$(g)}]},{title:e(`setup.models.step`),rows:[{label:e(`settings.setup.models`),value:u?.catalog?e(`settings.setup.modelsValue`,{n:String(w.length),size:GA(T)}):null,section:`model`,target:`[data-settings-target="models-on-pc"]`,provider:`local`},{label:e(`settings.setup.context`),value:null,section:`model`,target:`#ctx-size`,shown:!!i?.model&&!i.remote&&i.downloaded!==!1}]},{title:e(`settings.setup.after`),rows:[{label:e(`settings.section.connectors`),value:null,section:`connectors`},{label:e(`settings.section.memory`),value:null,section:`memory`},{label:e(`settings.language`),value:null,section:`general`,target:`#ui-language`},{label:e(`settings.setup.signIn`),value:null,section:`general`,target:`#desktop-startOnLogin`,shown:!!window.gaiaAPI?.tray}]}];return R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.setup`)}),I(`p`,{className:`settings-hint`,children:e(`settings.setup.lede`)}),R(`div`,{className:`settings-setup-status`,children:[R(`span`,{children:[I(`strong`,{children:e(a?`settings.setup.serverDown`:l?`settings.setup.chatUnusable`:`settings.setup.ready`)}),l&&c&&R(`span`,{className:`settings-hint`,children:[` `,I(`bdi`,{children:c})]}),C&&!a&&!l&&R(`span`,{className:`settings-hint`,children:[` `,I(`bdi`,{children:e(`settings.setup.running`,{name:C})})]})]}),I(`button`,{type:`button`,className:`btn-secondary`,"data-testid":`setup-run-again`,onClick:()=>x(!0),children:e(`settings.setup.runAgain`)})]}),v&&I(`p`,{className:`setup-error`,role:`alert`,children:v}),k.map(e=>R(`section`,{className:`settings-setup-group`,"aria-label":e.title,children:[I(`h3`,{className:`settings-label`,children:e.title}),e.rows.filter(e=>e.shown!==!1).map(e=>{let n=R(`span`,{children:[I(`span`,{className:`settings-setup-row-label`,children:e.label}),e.value&&I(`bdi`,{className:`settings-hint settings-setup-row-value`,children:e.value})]}),r=e.section;return r?R(`button`,{type:`button`,className:`settings-setup-row`,onClick:()=>t({section:r,target:e.target??`.settings-pane-title`,from:`setup`},e.provider),children:[n,I(gi,{size:14,className:`settings-setup-chevron`,"aria-hidden":`true`})]},e.label):I(`div`,{className:`settings-setup-row is-fact`,children:n},e.label)})]},e.title)),b&&I(wZ,{title:e(`settings.setup.confirmTitle`),confirmLabel:e(`settings.setup.confirmYes`),cancelLabel:e(`setup.again.notNow`),onConfirm:()=>{x(!1),n(),r(!0)},onCancel:()=>x(!1),children:I(`p`,{children:e(`settings.setup.confirmBody`)})})]})}var z1=[{label:`settings.about.whatsNew`,href:`https://github.com/amd/gaia/releases`},{label:`settings.about.docs`,href:`https://amd-gaia.ai/docs/guides/agent-ui`},{label:`settings.about.report`,href:`https://github.com/amd/gaia/issues/new/choose`},{label:`settings.about.license`,href:`https://github.com/amd/gaia/blob/main/LICENSE.md`}];function B1(){let e=L(),t=z(e=>e.openSettings),n=`GAIA v0.27.1rc1`,[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(null),s=(0,V.useRef)(null);(0,V.useEffect)(()=>()=>{s.current&&clearTimeout(s.current)},[]);let c=(0,V.useCallback)(async()=>{o(null);try{await navigator.clipboard.writeText(n),i(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>i(!1),2e3)}catch(t){o(e(`settings.about.copyFailed`,{reason:t instanceof Error?t.message:String(t)}))}},[e,n]);return R(`div`,{className:`settings-pane`,children:[I(`h2`,{className:`settings-pane-title`,children:e(`settings.section.about`)}),R(`section`,{className:`settings-card`,"aria-labelledby":`about-version`,children:[R(`div`,{className:`settings-row settings-row-between`,children:[R(`span`,{children:[I(`strong`,{id:`about-version`,children:I(`bdi`,{dir:`ltr`,children:n})}),` `,I(`span`,{className:`beta-badge`,children:`BETA`})]}),R(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void c(),children:[I(r?ci:Bi,{size:13,"aria-hidden":`true`}),e(r?`settings.about.copied`:`settings.about.copy`)]})]}),I(`p`,{className:`settings-hint`,children:e(`settings.advanced.about`)}),a&&I(`p`,{className:`settings-error`,role:`alert`,children:a})]}),R(`section`,{className:`settings-card`,"aria-label":e(`settings.about.links`),children:[I(`ul`,{className:`settings-about-links`,children:z1.map(t=>I(`li`,{children:R(`a`,{href:t.href,target:`_blank`,rel:`noopener noreferrer`,children:[e(t.label),` `,I(na,{size:12,"aria-hidden":`true`})]})},t.href))}),R(`p`,{className:`settings-hint`,children:[e(`settings.about.reportHint`),` `,I(`button`,{type:`button`,className:`link-btn`,onClick:()=>t(`privacy`),children:e(`settings.about.reportWhere`)})]})]})]})}var V1=class extends V.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidUpdate(e){this.state.hasError&&e.resetKey!==this.props.resetKey&&this.setState({hasError:!1})}componentDidCatch(e,t){console.error(`[ErrorBoundary] ${this.props.area} failed to render:`,e,t.componentStack)}render(){return this.state.hasError?I(H1,{variant:this.props.variant??`fill`,onRetry:()=>this.setState({hasError:!1})}):this.props.children}};function H1({onRetry:e,variant:t}){let n=L();return R(`div`,{role:`alert`,className:`error-boundary error-boundary-${t}`,children:[I(`p`,{className:`error-boundary-title`,children:n(`errorBoundary.title`)}),I(`p`,{className:`error-boundary-body`,children:n(t===`window`?`errorBoundary.bodyWindow`:`errorBoundary.body`)}),R(`div`,{className:`error-boundary-actions`,children:[I(`button`,{type:`button`,className:`btn-primary`,onClick:e,children:n(`errorBoundary.retry`)}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>window.location.reload(),children:n(`errorBoundary.reload`)})]})]})}var U1=`modulepreload`,W1=function(e,t){return new URL(e,t).href},G1={},K1=function(e){return e.pathname.endsWith(`.css`)},q1=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},J1=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=W1(t,n);let r=s(t),i=K1(r);return q1(G1,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`:U1,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{let i=a=>{t.removeEventListener(`load`,i),t.removeEventListener(`error`,i),a.type===`error`?n(Error(`Unable to preload CSS for ${r}`)):e(a)};t.addEventListener(`load`,i),t.addEventListener(`error`,i)})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Y1=(0,V.lazy)(()=>J1(()=>import(`./ConnectorsPane-CtN8iyjY.js`).then(e=>({default:e.ConnectorsPane})),__vite__mapDeps([0,1,2,3]),import.meta.url)),X1=(0,V.lazy)(()=>J1(()=>import(`./MessagingSettings-BrLW4gLV.js`).then(e=>({default:e.MessagingSettings})),__vite__mapDeps([4,1,2]),import.meta.url)),Z1=(0,V.lazy)(()=>J1(()=>import(`./AutomationsSettings-DZP1wPWZ.js`).then(e=>({default:e.AutomationsSettings})),__vite__mapDeps([5,1,2]),import.meta.url)),Q1=(0,V.lazy)(()=>J1(()=>import(`./AdvancedSettings-CJxSdclz.js`).then(e=>({default:e.AdvancedSettings})),__vite__mapDeps([6,1,2]),import.meta.url)),$1=[`general`,`setup`,`mode`,`model`,`images`,`permissions`,`skills`,`connectors`,`messaging`,`automations`,`memory`,`notifications`,`voice`,`privacy`,`advanced`,`about`];function e0({onUseSkill:e}){let t=L(),n=z(e=>e.settingsSection),r=z(e=>e.openSettings),i=z(e=>e.closeSettings),a=z(e=>e.settingsJump),o=(0,V.useRef)(null),s=(0,V.useRef)(null),c=n!==null;if(er(c,i),yn(o,c),rX(o,c,()=>o.current?.querySelector(`.settings-nav-item.is-active`)),(0,V.useLayoutEffect)(()=>{s.current&&(s.current.scrollTop=0)},[n]),(0,V.useEffect)(()=>{let e=s.current;if(!a||a.section!==n||!e)return;o.current?.querySelector(`[data-section="${n}"]`)?.focus();let t,r=null,i=()=>r?.scrollIntoView({block:`start`}),c=typeof ResizeObserver>`u`?null:new ResizeObserver(i),l=()=>c?.disconnect(),u=[`wheel`,`touchstart`,`pointerdown`,`keydown`],d=()=>{let n=e.querySelector(a.target);if(!n||n.disabled)return!1;for(let e=n.closest(`details`);e;e=e.parentElement?.closest(`details`)??null)e.open=!0;r=n.closest(`.model-in-use-field, .settings-field, details, .settings-card`)??n,r.classList.add(`settings-target-hit`),i();let o=n instanceof HTMLDetailsElement?n.querySelector(`summary`):n.closest(`summary`)??n;o&&(o.matches(`summary, button, input, select, textarea, a[href], [tabindex]`)||(o.tabIndex=-1),o.focus({preventScroll:!0}));let s=n.closest(`.settings-pane`);return s&&c?.observe(s),t=setTimeout(()=>r?.classList.remove(`settings-target-hit`),1600),!0},f=new MutationObserver(()=>{d()&&f.disconnect()});d()||f.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`disabled`]}),u.forEach(t=>e.addEventListener(t,l,{passive:!0}));let p=setTimeout(()=>f.disconnect(),5e3);return()=>{f.disconnect(),l(),u.forEach(t=>e.removeEventListener(t,l)),clearTimeout(p),clearTimeout(t)}},[a,n]),!n)return null;let l=a&&a.section===n?a.from:void 0,u=e=>{let t=$1.indexOf(n),i=e.key===`ArrowDown`?(t+1)%$1.length:e.key===`ArrowUp`?(t-1+$1.length)%$1.length:e.key===`Home`?0:e.key===`End`?$1.length-1:null;i!==null&&(e.preventDefault(),r($1[i]),o.current?.querySelector(`[data-section="${$1[i]}"]`)?.focus())},d=(()=>{switch(n){case`general`:return I(k$,{});case`setup`:return I(R1,{});case`model`:return I(Q$,{});case`mode`:return I(s1,{});case`images`:return I(i1,{});case`permissions`:return I(c1,{});case`skills`:return I(_1,{onUseSkill:t=>{i(),e(t)}});case`connectors`:return I(Y1,{});case`messaging`:return I(X1,{});case`automations`:return I(Z1,{});case`memory`:return I(b1,{});case`notifications`:return I(A1,{});case`voice`:return I(I1,{});case`privacy`:return I(T1,{});case`advanced`:return I(Q1,{});case`about`:return I(B1,{})}})();return I(`div`,{className:`settings-overlay`,onMouseDown:e=>{e.target===e.currentTarget&&i()},children:R(`div`,{ref:o,className:`settings-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`settings.title`),children:[R(`nav`,{className:`settings-nav`,"aria-label":t(`settings.sections`),onKeyDown:u,children:[I(`h1`,{className:`settings-nav-title`,children:t(`settings.title`)}),$1.map(e=>I(`button`,{type:`button`,"data-section":e,className:`settings-nav-item${n===e?` is-active`:``}`,"aria-current":n===e?`page`:void 0,tabIndex:n===e?0:-1,onClick:t=>{t.currentTarget.focus(),r(e)},children:t(`settings.section.${e}`)},e))]}),R(`div`,{className:`settings-body`,children:[I(`button`,{type:`button`,className:`settings-close`,onClick:i,"aria-label":t(`settings.close`),children:I(bc,{size:18})}),l&&R(`button`,{type:`button`,className:`settings-back`,onClick:()=>{r(l),o.current?.querySelector(`[data-section="${l}"]`)?.focus()},children:[I(mi,{size:14,"aria-hidden":`true`}),t.compose(e=>e(`settings.backTo`,{section:e(`settings.section.${l}`)}))]}),I(`div`,{ref:s,className:`settings-scroll`,children:I(V1,{area:`settings.${n}`,children:I(V.Suspense,{fallback:R(`p`,{className:`settings-hint`,children:[I(B,{size:13,className:`spin`}),` `,t(`settings.loading`)]}),children:d})},n)})]})]})})}var t0=`gaia:personalize-connector`,n0=[[`google`,`my last two weeks of Gmail (and Google Calendar, if it is connected)`],[`microsoft`,`my last two weeks of Outlook mail (and calendar, if it is connected)`],[`slack`,`my recent Slack channels and direct messages`],[`github`,`my recent GitHub activity: open PRs, review requests, issues and notifications`]];function r0(e,t){let n=e.toLowerCase().replace(/^mcp-/,``),r=n0.find(([e])=>n.startsWith(e));return r?r[1]:`my recent activity in ${t}`}function i0(e){let t=e.toLowerCase().replace(/^mcp-/,``),n=n0.find(([e])=>t.startsWith(e));return n?n[0]:null}function a0({connectorId:e,displayName:t}){return[`I just connected ${t}. Get to know me from ${r0(e,t)}.`,`Read only — do not send, delete, label or change anything.`,`If you have no tools that read it, or they fail, tell me you couldn't reach it and stop. Never guess or count what it holds.`,`1. Skim the recent items and work out who I deal with most, what I work on, recurring meetings or threads, and what keeps landing on my plate.`,`2. Save the durable facts to memory (people, projects, preferences, routines). Skip one-off details and anything sensitive like passwords, codes or financial numbers.`,`3. Recommend up to five automations you could run for me on a schedule, each with what it does, how often, and why it fits what you saw.`,`Don't create any schedules yet — tell me what you saved and list the automations so I can pick which to set up.`].join(`
217
+ `)}function o0(e){window.dispatchEvent(new CustomEvent(t0,{detail:e}))}function s0(e,t){let[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(!1),[o,s]=(0,V.useState)(null),c=(0,V.useRef)(null),l=(0,V.useRef)(null),u=(0,V.useRef)(null),d=(0,V.useCallback)(()=>{c.current&&=(clearTimeout(c.current),null),l.current&&=(clearTimeout(l.current),null),u.current&&=(clearInterval(u.current),null)},[]);(0,V.useEffect)(()=>d,[d]);let f=(0,V.useCallback)((e,t)=>{u.current&&clearInterval(u.current),u.current=setInterval(async()=>{try{let n=await Pt();t===`load`?sl(n.model_loaded,e)&&(r(!1),c.current&&=(clearTimeout(c.current),null),u.current&&=(clearInterval(u.current),null)):(n.model_downloaded===!0||sl(n.model_loaded,e))&&(a(!1),l.current&&=(clearTimeout(l.current),null),u.current&&=(clearInterval(u.current),null))}catch{}},$u)},[]),p=e??`Gemma-4-E4B-it-GGUF`;return(0,V.useEffect)(()=>s(null),[p]),{isLoadingModel:n,isDownloadingModel:i,downloadError:o,loadModel:(0,V.useCallback)(async(e,n)=>{let i=e??p,a=n??t;r(!0);try{if(!await Yt(i,a)){r(!1);return}P.system.info(`Load model triggered: ${i} (ctx=${a??`server default`})`),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>r(!1),Zu),f(i,`load`)}catch(e){P.system.error(`Failed to trigger model load`,e),r(!1)}},[p,t,f]),downloadModel:(0,V.useCallback)(async(e=!1,t,n=!1)=>{let r=t??p;a(!0),s(null);try{await Ee(r,e,n),P.system.info(`Download model triggered: ${r} (force=${e})`),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>a(!1),Qu),f(r,`download`)}catch(e){P.system.error(`Failed to trigger model download`,e),s(e instanceof Error?e.message:String(e)),a(!1)}},[p,f])}}function c0({onRetry:e,label:t,busyLabel:n}){let r=L(),[i,a]=(0,V.useState)(!1);return I(`button`,{className:`connection-banner__retry`,onClick:()=>{a(!0),Promise.resolve(e()).finally(()=>a(!1))},disabled:i,children:i?n??r(`banner.checking`):t})}function l0(e){return`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)}`}function u0({lifecycle:e}){let t=L(),n=LB(e=>e.restart),r=LB(e=>e.restartError),i=e.status===`restarting`,[a,o]=(0,V.useState)(()=>Date.now());if((0,V.useEffect)(()=>{if(!i)return;o(Date.now());let e=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(e)},[i]),i){let n=e.since?Math.max(0,Math.floor((a-e.since)/1e3)):0;return R(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(B,{size:16,className:`connection-banner__spinner`})}),R(`div`,{className:`connection-banner__text`,dir:`auto`,children:[t(`banner.restarting`),` `,I(`bdi`,{dir:`ltr`,className:`connection-banner__timer`,children:l0(n)}),` `,I(`span`,{className:`connection-banner__hint`,children:t(`banner.restartingHint`)})]})]})}return R(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[I(`div`,{className:`connection-banner__icon`,children:I(cc,{size:16})}),R(`div`,{className:`connection-banner__text`,dir:`auto`,children:[t(`banner.restartStopped`),` `,I(`span`,{className:`connection-banner__hint`,children:r?t(`banner.restartFailed`,{error:r}):t(`banner.restartStoppedHint`)})]}),I(c0,{onRetry:n,label:t(`banner.restartButton`),busyLabel:t(`banner.restartingShort`)})]})}function d0({onRetry:e,backendSlow:t=!1,backendError:n=null}){let r=L(),{backendConnected:i,systemStatus:a,currentSessionId:o,messages:s}=z(),c=z(e=>e.backendStalled),l=z(e=>e.isStreaming),u=LB(e=>e.lifecycle),d=LB(e=>e.restart),f=LB(e=>e.restartError),p=u!==null,[m,h]=(0,V.useState)(!1),g=!!o&&s.length>0,_=a?.default_model_name??`Gemma-4-E4B-it-GGUF`,{isDownloadingModel:v,downloadError:y,downloadModel:b}=s0(_),x=il(e=>e.pickLoad),S=il(e=>e.retryPickLoad),C=il(e=>e.dismissPickLoad);ol();let w=(0,V.useRef)(a?.lemonade_running),T=(0,V.useRef)(a?.model_downloaded),E=(0,V.useRef)(a?.context_size_sufficient),ee=(0,V.useRef)(a?.expected_model_loaded);(0,V.useEffect)(()=>{if(g)return;let e=a?.lemonade_running,t=a?.model_downloaded,n=a?.context_size_sufficient,r=a?.expected_model_loaded,i=!1;w.current!==e&&(w.current=e,e===!1&&(i=!0)),T.current!==t&&(T.current=t,t===!1&&(i=!0)),E.current!==n&&(E.current=n,n===!1&&(i=!0)),ee.current!==r&&(ee.current=r,r===!1&&(i=!0)),i&&h(!1)},[a,g]);let D=a?.download_progress??null,O=v||D?.state===`downloading`||D?.state===`starting`,te=z(e=>e.dismissDownloadFailure);if(u&&u.status!==`running`)return I(u0,{lifecycle:u});let k=D?.model_name||_,A=async()=>{try{await te(D?.model_name??k)}catch{}};if(O||D?.state===`error`){let e=cl(k),t=D?.total_bytes?QA(r.locale,`${(D.total_bytes/1e9).toFixed(1)} GB`):r(`banner.download.sizeUnknown`),n=D?.state===`error`;return R(`div`,{className:`connection-banner ${n?`connection-banner--error`:`connection-banner--warning`}`,role:n?`alert`:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(n?cc:Ji,{size:16})}),I(`div`,{className:`connection-banner__text`,dir:`auto`,children:n?R(F.Fragment,{children:[r(`banner.download.failed`,{model:e}),` `,(y??D?.message)&&I(`span`,{className:`connection-banner__hint`,children:y??D?.message})]}):R(F.Fragment,{children:[r(`banner.download.running`,{model:e,size:t}),D?.state===`downloading`&&D.file&&R(F.Fragment,{children:[` `,R(`span`,{className:`connection-banner__hint`,children:[r(`banner.download.file`,{index:D.file_index,total:D.total_files}),` `,I(`code`,{children:D.file})]})]})]})}),n?I(`button`,{className:`connection-banner__retry`,onClick:()=>b(!1,k,!a?.model_loaded),children:r(`banner.download.retry`)}):I(`span`,{className:`connection-banner__loading connection-banner__progress`,children:D&&D.state===`downloading`&&D.total_bytes>0?R(F.Fragment,{children:[I(`span`,{className:`connection-banner__progress-bar`,role:`progressbar`,"aria-valuenow":D.percent,"aria-valuemin":0,"aria-valuemax":100,"aria-label":r(`banner.download.progress`),children:I(`span`,{className:`connection-banner__progress-fill`,style:{width:`${D.percent}%`}})}),R(`bdi`,{className:`connection-banner__progress-label`,dir:`ltr`,children:[D.percent,`% ·`,` `,(D.downloaded_bytes/1e9).toFixed(2),` /`,` `,(D.total_bytes/1e9).toFixed(2),` GB`]})]}):R(F.Fragment,{children:[I(B,{size:13,className:`connection-banner__spinner`}),D?.state===`starting`?D.message??r(`banner.download.starting`):r(`banner.download.downloading`)]})}),n&&I(`button`,{className:`connection-banner__dismiss`,onClick:()=>void A(),"aria-label":r(`banner.dismiss`),children:I(bc,{size:14})})]})}if(x){let e=cl(x.model);return x.error?R(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[I(`div`,{className:`connection-banner__icon`,children:I(cc,{size:16})}),R(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.pickLoad.failed`,{model:e}),` `,I(`span`,{className:`connection-banner__hint`,dir:`auto`,children:x.error.key?r(x.error.key,{reason:x.error.reason}):x.error.reason})]}),I(c0,{onRetry:S,label:r(`banner.pickLoad.retry`)}),I(`button`,{className:`connection-banner__dismiss`,onClick:C,"aria-label":r(`banner.dismiss`),children:I(bc,{size:14})})]}):R(`div`,{className:`connection-banner connection-banner--init`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(B,{size:16,className:`connection-banner__spinner`})}),R(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.pickLoad.loading`,{model:e}),` `,I(`bdi`,{dir:`ltr`,children:r(`banner.pickLoad.seconds`,{s:x.seconds})}),` `,I(`span`,{className:`connection-banner__hint`,children:r(`banner.pickLoad.canType`)})]})]})}let ne=a?.init_tasks?.find(e=>e.step===`check_server`),M=a?.lemonade_running===!1&&!!ne&&ne.status!==`pending`&&ne.status!==`running`;if(sV(a)&&!t&&!n&&!M){let e=a?.init_tasks?.find(e=>e.status===`running`)?.step,t=`banner.boot.${e}`,n=e&&j(t)?r(t):r(`banner.boot.generic`);return R(`div`,{className:`connection-banner connection-banner--init`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(B,{size:16,className:`connection-banner__spinner`})}),R(`div`,{className:`connection-banner__text`,dir:`auto`,children:[n,R(`span`,{className:`thinking-dots`,children:[I(`span`,{children:`.`}),I(`span`,{children:`.`}),I(`span`,{children:`.`})]})]})]})}if(!i)return R(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[I(`div`,{className:`connection-banner__icon`,children:I(gc,{size:16})}),R(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.unreachable`),` `,I(`span`,{className:`connection-banner__hint`,children:f?r(`banner.restartFailed`,{error:f}):r(`banner.unreachableHint`)})]}),e&&I(c0,{onRetry:e,label:r(`banner.retry`)}),p&&I(c0,{onRetry:d,label:r(`banner.restartButton`),busyLabel:r(`banner.restartingShort`)})]});if(n)return R(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(cc,{size:16})}),R(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.backendError`,{error:n}),` `,I(`span`,{className:`connection-banner__hint`,children:r(`banner.backendErrorHint`)})]}),e&&I(c0,{onRetry:e,label:r(`settings.key.checkAgain`)})]});if(t||c)return R(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(cc,{size:16})}),R(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.backendSlow`),` `,I(`span`,{className:`connection-banner__hint`,children:f?r(`banner.restartFailed`,{error:f}):r(`banner.backendSlowHint`)})]}),e&&I(c0,{onRetry:e,label:r(`settings.key.checkAgain`)}),p&&(c||!l)&&I(c0,{onRetry:d,label:r(`banner.restartButton`),busyLabel:r(`banner.restartingShort`)})]});if(m||g)return null;if(a?.config_error)return R(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[I(`div`,{className:`connection-banner__icon`,children:I(cc,{size:16})}),R(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.configError`),` `,I(`span`,{className:`connection-banner__hint`,children:a.config_error})]}),e&&I(c0,{onRetry:e,label:r(`settings.key.checkAgain`)})]});if(a&&!a.lemonade_running){let t=cV(a)===`unresponsive`,n=!t&&F$(a),i=t&&j$(a.start_command)?null:a.start_command,o=t&&j$(a.start_instruction)?null:a.start_instruction;return R(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(cc,{size:16})}),R(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(t?`banner.serverHung`:`banner.serverStopped`),` `,n?I(`span`,{className:`connection-banner__hint`,children:r(`banner.finishSetup`)}):i?R(`span`,{className:`connection-banner__hint`,children:[r(t?`banner.restartHint`:`banner.startHint`),` `,I(`code`,{dir:`ltr`,children:i})]}):o&&I(`span`,{className:`connection-banner__hint`,children:P$(r,o)})]}),n&&I(I$,{className:`connection-banner__retry`}),e&&I(c0,{onRetry:e,label:r(`settings.key.checkAgain`)}),I(`button`,{className:`connection-banner__dismiss`,onClick:()=>h(!0),"aria-label":r(`banner.dismiss`),children:I(bc,{size:14})})]})}if(a&&a.lemonade_running&&a.model_loaded&&a.context_size_sufficient===!1){let t=a.model_context_size??0;return R(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[I(`div`,{className:`connection-banner__icon`,children:I(eo,{size:16})}),R(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.contextTooSmall`,{current:QA(r.locale,t.toLocaleString()),required:QA(r.locale,Yu.toLocaleString())}),` `,I(`span`,{className:`connection-banner__hint`,children:r(`banner.contextTooSmallHint`)})]}),e&&I(c0,{onRetry:e,label:r(`settings.key.checkAgain`)}),I(`button`,{className:`connection-banner__dismiss`,onClick:()=>h(!0),"aria-label":r(`banner.dismiss`),children:I(bc,{size:14})})]})}return null}var f0=`https://github.com/amd/gaia/releases`;function p0(){let e=kQ(),t=L(),[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(null),o=(0,V.useCallback)(e=>{let n=DQ();n&&(a(null),n[e]().catch(n=>{P.system.error(`Update ${e} failed`,n),a(NQ(n,t))}))},[t]);if(n)return null;let s=e.installFailed?t(`update.chip.installFailedDetail`,e.installFailed):null,c=e.status===`downloading`||e.status===`downloaded`;if(e.startFailed&&e.previousVersion&&!c)return R(`div`,{className:`update-chip update-chip--error`,role:`status`,children:[I(cc,{size:13,className:`update-chip__icon`}),I(`span`,{className:`update-chip__label`,title:i??void 0,children:t(i?`update.chip.updateFailed`:`update.chip.startFailed`)}),I(`button`,{type:`button`,className:`update-chip__action`,onClick:()=>o(`revertUpdate`),children:t(`update.chip.goBack`,{version:e.previousVersion})}),I(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>r(!0),"aria-label":t(`update.chip.dismissError`),children:I(bc,{size:11})})]});let l=e.status===`available`||e.status===`downloaded`;if(s&&!l)return R(`div`,{className:`update-chip update-chip--error`,role:`status`,title:s??void 0,children:[I(cc,{size:13,className:`update-chip__icon`}),I(`span`,{className:`update-chip__label`,children:t(`update.chip.installFailed`)}),I(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>r(!0),"aria-label":t(`update.chip.dismissError`),children:I(bc,{size:11})})]});if(e.status===`idle`||e.status===`checking`||e.status===`disabled`||e.status===`no-channel`)return null;if(e.status===`downloading`){let n=Math.max(0,Math.min(100,e.progress));return R(`div`,{className:`update-chip update-chip--downloading`,role:`status`,"aria-live":`polite`,title:t(`update.chip.downloadingTitle`,{version:e.version??``}),children:[I(Ji,{size:13,className:`update-chip__icon`}),I(`span`,{className:`update-chip__label`,children:e.preparing?t(`update.chip.preparing`):t(`update.chip.downloading`,{pct:n})})]})}return e.status===`available`?R(`div`,{className:`update-chip update-chip--available`,role:`status`,title:e.manualInstall?t(`update.chip.manualTitle`,{version:e.version??``}):i||s||e.releaseNotes||t(`update.chip.availableTitle`),children:[I(Ji,{size:13,className:`update-chip__icon`}),I(`span`,{className:`update-chip__label`,children:i?t(`update.chip.updateFailed`):s?t(`update.chip.installFailed`):t(`update.chip.available`,{version:e.version??``})}),e.manualInstall?I(`a`,{className:`update-chip__action`,href:e.downloadUrl??f0,target:`_blank`,rel:`noopener noreferrer`,children:t(`update.chip.download`)}):!e.pinnedVersion&&I(`button`,{type:`button`,className:`update-chip__action`,onClick:()=>o(`downloadUpdate`),children:t(`update.chip.updateNow`)}),I(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>r(!0),"aria-label":t(`update.chip.dismiss`),children:I(bc,{size:11})})]}):e.status===`downloaded`?R(`div`,{className:`update-chip update-chip--ready`,role:`status`,"aria-live":`polite`,children:[I(fs,{size:13,className:`update-chip__icon`}),I(`button`,{type:`button`,className:`update-chip__action`,onClick:()=>o(`restart`),title:i||s||t(`update.chip.restartTitle`),children:t(i?`update.chip.restartFailed`:s?`update.chip.installFailedRetry`:`update.chip.ready`)})]}):e.status===`error`?R(`div`,{className:`update-chip update-chip--error`,role:`status`,title:e.error||t(`update.chip.checkFailed`),children:[I(cc,{size:13,className:`update-chip__icon`}),I(`span`,{className:`update-chip__label`,children:t(`update.chip.checkFailed`)}),I(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>r(!0),"aria-label":t(`update.chip.dismissError`),children:I(bc,{size:11})})]}):null}var m0={permission_request:{icon:I(Is,{size:16}),colorClass:`notif-type-permission`},policy_alert:{icon:I(Is,{size:16}),colorClass:`notif-type-policy`},security_alert:{icon:I(cc,{size:16}),colorClass:`notif-type-security`},status_change:{icon:I(bi,{size:16}),colorClass:`notif-type-status`},info:{icon:I(Ja,{size:16}),colorClass:`notif-type-info`},error:{icon:I(wi,{size:16}),colorClass:`notif-type-error`}},h0=/([⁦-⁩])/;function g0(e){return e.split(h0).map((e,t)=>t%2?e:bd(e,!0)).join(``)}function _0(e,t){let n=Date.now()-e,r=Math.floor(n/1e3);if(r<60)return t(`time.justNow`);let i=Math.floor(r/60);if(i<60)return t(`time.minutesAgo`,{n:i});let a=Math.floor(i/60);if(a<24)return t(`time.hoursAgo`,{n:a});let o=Math.floor(a/24);return o<7?t(`time.daysAgo`,{n:o}):new Date(e).toLocaleDateString(Ln(t),{month:`short`,day:`numeric`})}function v0({onClose:e,onOpenChat:t}){let n=L(),r=fu(kc(mu)),i=fu(pu),a=fu(e=>e.markRead),o=fu(e=>e.markAllRead),s=fu(e=>e.clearAll),c=fu(e=>e.dismiss),l=fu(e=>e.respondToPermission),u=fu(e=>e.typeFilter),d=fu(kc(hu)),f=fu(e=>e.setTypeFilter),p=(0,V.useCallback)(e=>{a(e.id),e.sessionId&&e.type!==`permission_request`&&t?.(e.sessionId)},[a,t]),m=(0,V.useCallback)(e=>{l(e.id,`allow`).catch(e=>console.error(`[NotificationCenter] allow failed:`,e))},[l]),h=(0,V.useCallback)(e=>{l(e.id,`deny`).catch(e=>console.error(`[NotificationCenter] deny failed:`,e))},[l]);er(!0,e);let g=[{key:null,label:n(`notifications.filter.all`)},{key:`permission_request`,label:n(`notifications.filter.permissions`)},{key:`policy_alert`,label:n(`notifications.filter.policy`)},{key:`error`,label:n(`notifications.filter.errors`)},{key:`security_alert`,label:n(`notifications.filter.security`)},{key:`status_change`,label:n(`notifications.filter.status`)},{key:`info`,label:n(`notifications.filter.info`)}].filter(e=>e.key===null||e.key===u||d.includes(e.key)),_=g.length>2||u!==null;return R(`div`,{className:`notification-center`,role:`dialog`,"aria-label":n(`notifications.dialogAria`),children:[R(`div`,{className:`notification-center-header`,children:[R(`div`,{className:`notification-center-title-row`,children:[I(`h2`,{className:`notification-center-title`,children:n(`notifications.title`)}),i>0&&I(`span`,{className:`notification-center-badge`,children:i})]}),I(`button`,{className:`btn-icon notification-center-close`,onClick:e,"aria-label":n(`notifications.close`),children:I(bc,{size:18})})]}),_&&I(`div`,{className:`notification-filter-bar`,role:`tablist`,"aria-label":n(`notifications.filterAria`),children:g.map(e=>I(`button`,{role:`tab`,"aria-selected":u===e.key,className:`notification-filter-tab ${u===e.key?`active`:``}`,onClick:()=>f(e.key),children:e.label},e.key??`all`))}),I(`div`,{className:`notification-list`,children:r.length===0?R(`div`,{className:`notification-empty`,children:[I(Kr,{size:40,strokeWidth:1.2}),I(`span`,{children:n(`notifications.empty`)})]}):r.map(e=>{let t=m0[e.type],r=e.type===`permission_request`&&e.tool?eu(e,n,e=>El(Td(e))):null;return R(`div`,{className:`notification-item ${e.read?``:`unread`} ${t.colorClass}`,id:e.type===`policy_alert`&&e.receiptId?`policy-receipt-${encodeURIComponent(e.receiptId)}`:void 0,onClick:()=>p(e),role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&p(e)},children:[!e.read&&I(`span`,{className:`notification-unread-dot`}),I(`span`,{className:`notification-icon`,children:t.icon}),R(`div`,{className:`notification-content`,children:[R(`div`,{className:`notification-content-header`,children:[I(`span`,{className:`notification-agent`,dir:`auto`,children:e.agentName}),I(`span`,{className:`notification-time`,children:_0(e.timestamp,n)})]}),r?R(F.Fragment,{children:[I(`span`,{className:`notification-title`,children:I(kl,{text:r.heading})}),I(`span`,{className:`notification-message`,dir:`auto`,children:I(kl,{text:r.question})})]}):R(F.Fragment,{children:[e.title&&I(`span`,{className:`notification-title`,children:g0(e.title)}),I(`span`,{className:`notification-message`,dir:`auto`,children:g0(e.message)})]}),e.type===`policy_alert`&&R(`div`,{className:`notification-policy-details`,children:[e.tool&&R(`span`,{className:`notification-tool`,children:[n(`activity.policy.tool`),`: `,I(`code`,{dir:`ltr`,children:e.tool})]}),e.reason&&R(`span`,{className:`notification-policy-reason`,children:[n(`notifications.reason`),`: `,e.reason]}),e.ruleIds&&e.ruleIds.length>0&&R(`span`,{className:`notification-tool`,children:[n(`activity.policy.rules`),`: `,I(`code`,{dir:`ltr`,children:e.ruleIds.join(`, `)})]}),e.policyVersion&&R(`span`,{className:`notification-tool`,children:[n(`activity.policy.policy`),`: `,I(`code`,{dir:`ltr`,children:e.policyVersion})]}),R(`span`,{className:`notification-tool`,children:[n(`activity.policy.receipt`),`:`,` `,e.receiptId?I(`code`,{dir:`ltr`,children:e.receiptId}):I(`em`,{children:n(`activity.policy.receiptUnavailable`)})]})]}),e.type===`permission_request`&&!e.response&&R(`div`,{className:`notification-actions`,children:[R(`button`,{className:`notification-action-btn notification-action-allow`,onClick:t=>{t.stopPropagation(),m(e)},children:[I(ci,{size:14}),n(`notifications.approve`)]}),R(`button`,{className:`notification-action-btn notification-action-deny`,onClick:t=>{t.stopPropagation(),h(e)},children:[I(bc,{size:14}),n(`notifications.deny`)]})]}),e.type===`permission_request`&&e.response&&I(`span`,{className:`notification-response-badge ${e.response===`allow`?`response-allow`:`response-deny`}`,children:e.response===`allow`?n(`notifications.approved`):n(`notifications.denied`)})]}),I(`button`,{className:`notification-dismiss`,onClick:t=>{t.stopPropagation(),c(e.id)},"aria-label":n(`notifications.dismiss`),children:I(bc,{size:14})})]},e.id)})}),r.length>0&&R(`div`,{className:`notification-center-footer`,children:[R(`button`,{className:`notification-footer-btn`,onClick:o,disabled:i===0,children:[I(ci,{size:14}),n(`notifications.markAllRead`)]}),R(`button`,{className:`notification-footer-btn notification-footer-clear`,onClick:s,children:[I(oc,{size:14}),n(`notifications.clear`)]})]})]})}var y0=1500,b0=e=>new Promise(t=>setTimeout(t,e));async function x0({onProgress:e,isCancelled:t=()=>!1,pollMs:n=y0}={}){try{await En(CA)}catch(e){if(e?.httpStatus!==409)throw e;let t=await Ce(CA).catch(()=>null);if(!t||t.status===`completed`||t.status===`failed`)throw e}for(;!t();){let t=await Ce(CA);if(e?.(t),t.status===`completed`)return;if(t.status===`failed`)throw Error(t.error||`The GAIA agent could not be installed.`);await b0(n)}}function S0({onInstalled:e,noBuild:t=!1}){let n=L(),[r,i]=(0,V.useState)({kind:`idle`}),a=(0,V.useRef)(!1);(0,V.useEffect)(()=>()=>{a.current=!0},[]);let o=(0,V.useCallback)(async()=>{i({kind:`installing`,percent:0});try{if(await x0({isCancelled:()=>a.current,onProgress:e=>{a.current||i({kind:`installing`,percent:e.percent??0})}}),a.current)return;await e(),a.current||i({kind:`idle`})}catch(e){a.current||i({kind:`failed`,error:e instanceof Error?e.message:String(e)})}},[e]);return t?I(`div`,{className:`app-notice is-warning`,role:`status`,children:I(`span`,{children:n(`agentNotice.noBuild`)})}):R(`div`,{className:`app-notice is-warning`,role:`status`,children:[r.kind===`installing`?I(`span`,{children:n(`agentNotice.installing`,{percent:Math.round(r.percent)})}):r.kind===`failed`?I(`span`,{children:n(`agentNotice.failed`,{error:r.error})}):I(`span`,{children:n(`agentNotice.missing`)}),r.kind!==`installing`&&I(`button`,{type:`button`,className:`link-btn`,onClick:()=>void o(),children:r.kind===`failed`?n(`agentNotice.retry`):n(`agentNotice.install`)})]})}var C0=4e6;function w0(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;let r=0;for(;r<e.length-n&&r<t.length-n&&e[e.length-1-r]===t[t.length-1-r];)r++;let i=e.slice(n,e.length-r),a=t.slice(n,t.length-r);if(i.length===0&&a.length===0)return[];if(i.length*a.length>C0)return null;let o=a.length+1,s=new Uint32Array((i.length+1)*o);for(let e=i.length-1;e>=0;e--)for(let t=a.length-1;t>=0;t--)s[e*o+t]=i[e]===a[t]?s[(e+1)*o+t+1]+1:Math.max(s[(e+1)*o+t],s[e*o+t+1]);let c=[],l=0,u=0,d=null,f=()=>d??={start:n+l,end:n+l,lines:[]};for(;l<i.length||u<a.length;)if(l<i.length&&u<a.length&&i[l]===a[u])d&&c.push(d),d=null,l++,u++;else if(u<a.length&&(l===i.length||s[l*o+u+1]>=s[(l+1)*o+u]))f().lines.push(a[u++]);else{let e=f();l++,e.end=n+l}return d&&c.push(d),c}var T0=(e,t)=>e.start===t.start&&e.end===t.end&&e.lines.length===t.lines.length&&e.lines.every((e,n)=>e===t.lines[n]),E0=e=>e.start===e.end,D0=(e,t)=>e.start<t.end&&t.start<e.end||E0(e)&&E0(t)&&e.start===t.start;function O0(e,t,n){if(t===e)return{text:n,locate:e=>Math.min(e,n.length)};if(n===e||n===t)return{text:t,locate:e=>e};let r=e.split(`
218
+ `),i=t.split(`
219
+ `),a=w0(r,i),o=w0(r,n.split(`
220
+ `));if(a===null||o===null)return null;for(let e of a)for(let t of o)if(D0(e,t)&&!T0(e,t))return null;let s=[...a.map(e=>({h:e,mine:!0})),...o.filter(e=>!a.some(t=>T0(t,e))).map(e=>({h:e,mine:!1}))].sort((e,t)=>e.h.start-t.h.start||e.h.end-t.h.end),c=[],l=[],u=0,d=e=>{for(;u<e;u++)l.push(c.length),c.push(r[u])};for(let{h:e,mine:t}of s){d(e.start);for(let n of e.lines)t&&l.push(c.length),c.push(n);u=e.end}d(r.length);let f=c.join(`
221
+ `),p=[],m=0;for(let e of c)p.push(m),m+=e.length+1;return{text:f,locate:e=>{let t=0,n=0;for(;t<i.length-1&&n+i[t].length<e;)n+=i[t++].length+1;let r=l[t];return r===void 0?f.length:Math.min(p[r]+(e-n),f.length)}}}var k0={not_in_chat:`docPane.error.notInChat`,gone:`docPane.error.gone`,too_large:`docPane.error.tooLarge`,not_text:`docPane.error.notText`,protected:`docPane.error.protected`,symlink:`docPane.error.symlink`,outside:`docPane.error.outside`,locked:`docPane.error.locked`,read_only_encoding:`docPane.readOnly.encoding`,read_only_hard_link:`docPane.readOnly.hard_link`};function A0(e,t){let n=t instanceof On&&t.reason?k0[t.reason]:void 0;return n?e(n):e(`docPane.error.other`,{error:BF(t)})}var j0=e=>e instanceof On?e.reason:null;function M0(e,t,n){let r=pL(e=>e.refresh),i=pL(e=>e.flush),[a,o]=(0,V.useState)({state:`loading`}),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(`idle`),[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(!1),_=(0,V.useRef)(null),v=(0,V.useRef)(a),y=(0,V.useRef)(s),b=(0,V.useRef)(p),x=e=>{v.current=e,o(e)},S=e=>{y.current=e,c(e)},C=e=>{b.current=e,m(e)},w=(0,V.useRef)(null),T=(0,V.useRef)(!1),E=(0,V.useRef)(null),ee=(0,V.useRef)(!0),D=(0,V.useCallback)((r=!1)=>{let i=!0;return CI(e,t).then(e=>{if(!i)return;let t=v.current,a=y.current;if(!r&&a!==null&&t.state===`ready`){if(t.doc.version===e.version)return;let r=O0(t.doc.content,a,e.content);if(r===null){C(e.version);return}let i=n.current;_.current=i?{start:r.locate(i.selectionStart),end:r.locate(i.selectionEnd)}:null,x({state:`ready`,doc:e}),S(r.text===e.content?null:r.text),C(null),g(!0)}else x({state:`ready`,doc:e}),(r||a===null)&&(S(null),C(null),u(`idle`),f(null))}).catch(e=>{i&&(P.ui.warn(`Could not open the document ${t}`,e),x({state:`failed`,error:e}))}),()=>{i=!1}},[e,t,n]);(0,V.useEffect)(()=>{ee.current=!0;let n=!0,r=wL(e,t);return CI(e,t).then(e=>{n&&(x({state:`ready`,doc:e}),r&&r.text!==e.content&&(S(r.text),r.base!==e.version&&C(e.version)))}).catch(i=>{n&&(P.ui.warn(`Could not open the document ${t}`,i),r&&CL(e,t,r),x({state:`failed`,error:i}))}),()=>{n=!1}},[e,t]),(0,V.useEffect)(()=>{if(r!==0)return v.current.state===`failed`&&x({state:`loading`}),D()},[r,D]);let O=(0,V.useCallback)(n=>{let r=y.current,i=v.current;r!==null&&i.state===`ready`&&(n!==void 0||b.current===null)&&(w.current===null?(w.current=r,E.current=null,ee.current&&(u(`saving`),f(null)),wI(e,t,r,n??i.doc.version).then(n=>{TL(e,t),ee.current&&(x({state:`ready`,doc:{...i.doc,content:r,version:n.version,size:n.size,modified:n.modified}}),y.current===r&&S(null),C(null),u(`saved`),E.current!==null&&E.current!==n.version&&D())}).catch(e=>{ee.current?j0(e)===`conflict`&&e instanceof On&&typeof e.body?.version==`string`?(C(e.body.version),u(`idle`)):(P.ui.error(`Could not save the document ${t}`,e),f(e),u(`failed`)):P.ui.error(`Could not save the document ${t} while leaving it; the text is kept for when it is reopened`,e)}).finally(()=>{w.current=null;let e=T.current;T.current=!1,e&&ee.current&&y.current!==null&&b.current===null&&O()})):T.current=!0)},[e,t,D]),te=a.state===`ready`||a.state===`deleted`;(0,V.useEffect)(()=>{if(te)return TI(e,t,e=>{let t=v.current;(t.state===`ready`||t.state===`deleted`)&&(e.type===`deleted`?x({state:`deleted`,doc:t.doc}):e.type===`error`?y.current===null&&D():w.current===null?(t.state!==`ready`||e.version!==t.doc.version)&&D():E.current=e.version)})},[e,t,te,D]);let k=a.state===`ready`?a.doc:null,A=k?.version;return(0,V.useEffect)(()=>{if(s===null||p!==null||A===void 0)return;let e=setTimeout(()=>O(),800);return()=>clearTimeout(e)},[s,p,A,O]),(0,V.useEffect)(()=>{i!==0&&O()},[i,O]),(0,V.useEffect)(()=>()=>{ee.current=!1;let n=y.current,r=v.current;n!==null&&r.state===`ready`&&(CL(e,t,{text:n,base:r.doc.version}),O())},[e,t,O]),{loaded:a,doc:k,draft:s,setDraft:e=>{S(k&&e===k.content?null:e),u(`idle`),g(!1)},saving:l,saveError:d,conflict:p,merged:h,caretAfterMerge:_,saveNow:()=>O(),keepMine:()=>{b.current&&O(b.current)},useTheirs:()=>{TL(e,t),D(!0)},retry:()=>{x({state:`loading`}),D()}}}function N0(e,t,n){return t?{key:`docPane.status.writing`,tone:`live`}:n?.status===`stopped`&&e.loaded.state!==`ready`?{key:`docPane.status.stopped`,tone:`warn`}:e.loaded.state===`deleted`?{key:`docPane.status.deleted`,tone:`warn`}:e.conflict?{key:`docPane.status.changedOnDisk`,tone:`warn`}:e.saving===`failed`?{key:`docPane.status.notSaved`,tone:`warn`}:e.saving===`saving`?{key:`docPane.status.saving`,tone:`quiet`}:e.merged?{key:`docPane.status.merged`,tone:`ok`}:e.draft===null?e.saving===`saved`?{key:`docPane.status.saved`,tone:`ok`}:null:{key:`docPane.status.unsaved`,tone:`quiet`}}function P0({kind:e,text:t,streaming:n}){let r=(0,V.useDeferredValue)(t),i=n?r:t;return e===`text`?R(`pre`,{className:`dp-plain`,dir:`auto`,children:[i,n&&I(`span`,{className:`cursor`})]}):I(mB,{content:i,showCursor:n,isStreaming:n})}function F0({chat:e,path:t,overlay:n}){let r=L(),i=pL(n=>{let r=n.live[e];return r&&iL(r.path,t)?r:void 0}),a=(0,V.useRef)(null),o=M0(e,t,a),[s,c]=(0,V.useState)(`preview`),[l,u]=YO(),[d,f]=(0,V.useState)(null),p=(0,V.useRef)(null),m=(0,V.useRef)(!0),h=i?.status===`writing`,g=o.doc?.kind??(/\.txt$/i.test(t)?`text`:`markdown`),_=o.doc?.read_only_reason??null,v=o.loaded.state===`ready`&&_===null,y=h?i.text:o.draft??o.doc?.content??(o.loaded.state===`deleted`?o.loaded.doc.content:null),b=N0(o,h,i),x=kd(rL(t));(0,V.useLayoutEffect)(()=>{let e=p.current;e&&h&&m.current&&(e.scrollTop=e.scrollHeight)},[h,i?.text]);let S=()=>{let e=p.current;e&&(m.current=e.scrollHeight-e.scrollTop-e.clientHeight<40)};(0,V.useLayoutEffect)(()=>{let e=o.caretAfterMerge.current,t=a.current;e&&t&&(o.caretAfterMerge.current=null,t.setSelectionRange(e.start,e.end))},[o.draft,o.doc?.version,o.caretAfterMerge]),(0,V.useEffect)(()=>{s===`edit`&&!v&&o.draft===null&&c(`preview`)},[s,v,o.draft]);let C=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`s`?(e.preventDefault(),o.saveNow()):e.key===`Escape`&&!n&&(e.stopPropagation(),c(`preview`))},w=()=>{f(null),nr(t,!0).catch(e=>f(r(`sp.couldntOpen`,{name:x,error:BF(e)})))},T=o.loaded.state===`failed`&&!h&&i?.status!==`stopped`;return R(F.Fragment,{children:[R(`div`,{className:`dp-bar`,children:[b&&R(`span`,{className:`dp-status is-${b.tone}`,children:[b.tone===`live`&&I(`span`,{className:`dp-dot`,"aria-hidden":`true`}),b.tone===`ok`&&I(ci,{size:12,"aria-hidden":`true`}),b.tone===`warn`&&I(cc,{size:12,"aria-hidden":`true`}),r(b.key)]}),I(`span`,{className:`dp-bar-space`}),R(`div`,{className:`dp-views`,role:`group`,"aria-label":r(`docPane.view.label`),children:[I(`button`,{type:`button`,className:`dp-view${s===`preview`?` active`:``}`,"aria-pressed":s===`preview`,onClick:()=>c(`preview`),children:r(`docPane.view.preview`)}),I(`button`,{type:`button`,className:`dp-view${s===`edit`?` active`:``}`,"aria-pressed":s===`edit`,onClick:()=>c(`edit`),disabled:!v||h,title:_?r(`docPane.readOnly.${_}`):void 0,children:r(`docPane.view.edit`)})]}),I(`button`,{type:`button`,className:`btn-icon-sm`,onClick:()=>y!==null&&u(y),disabled:y===null,"aria-label":r(l===`copied`?`docPane.copied`:l===`failed`?`docPane.copyFailed`:`docPane.copy`),title:r(l===`copied`?`docPane.copied`:l===`failed`?`docPane.copyFailed`:`docPane.copy`),children:I(l===`copied`?ci:Bi,{size:15})}),I(`button`,{type:`button`,className:`btn-icon-sm`,onClick:w,disabled:o.loaded.state!==`ready`,"aria-label":r(`sp.showInFolder`),title:r(`sp.showInFolder`),children:I(Ea,{size:15})})]}),o.conflict&&R(`div`,{className:`dp-notice is-warn`,role:`alert`,children:[I(`span`,{children:r(`docPane.conflict.message`)}),R(`span`,{className:`dp-notice-actions`,children:[I(`button`,{type:`button`,className:`btn-secondary dp-notice-btn`,onClick:o.keepMine,children:r(`docPane.conflict.keepMine`)}),I(`button`,{type:`button`,className:`btn-secondary dp-notice-btn`,onClick:o.useTheirs,children:r(`docPane.conflict.useTheirs`)})]})]}),o.saving===`failed`&&R(`div`,{className:`dp-notice is-warn`,role:`alert`,children:[I(`span`,{children:A0(r,o.saveError)}),I(`span`,{className:`dp-notice-actions`,children:I(`button`,{type:`button`,className:`btn-secondary dp-notice-btn`,onClick:o.saveNow,children:r(`docPane.saveAgain`)})})]}),h&&s===`edit`&&I(`p`,{className:`dp-notice`,role:`status`,children:r(`docPane.paused`)}),i?.status===`stopped`&&I(`p`,{className:`dp-notice is-warn`,role:`status`,children:r(`docPane.stoppedNote`)}),o.loaded.state===`deleted`&&I(`p`,{className:`dp-notice is-warn`,role:`status`,children:r(`docPane.deletedNote`)}),_&&s===`preview`&&I(`p`,{className:`dp-notice`,role:`status`,children:r(`docPane.readOnly.${_}`)}),d&&I(`p`,{className:`dp-notice is-warn`,role:`alert`,children:d}),I(`div`,{className:`dp-scroll`,ref:p,onScroll:S,children:T?R(`div`,{className:`dp-empty`,role:`alert`,children:[I(`p`,{children:A0(r,o.loaded.state===`failed`?o.loaded.error:null)}),R(`span`,{className:`dp-notice-actions`,children:[I(`button`,{type:`button`,className:`btn-secondary dp-notice-btn`,onClick:o.retry,children:r(`docPane.retry`)}),I(`button`,{type:`button`,className:`btn-secondary dp-notice-btn`,onClick:w,children:r(`sp.showInFolder`)})]})]}):y===null?I(`p`,{className:`dp-empty`,role:`status`,children:r(`docPane.loading`)}):s===`edit`&&!h?I(`textarea`,{ref:a,className:`dp-editor`,dir:`auto`,spellCheck:!1,value:y,readOnly:!v,"data-claims-escape":``,"aria-label":r(`docPane.editorLabel`,{name:x}),onChange:e=>o.setDraft(e.target.value),onBlur:e=>{o.draft!==null&&!o.conflict&&!e.currentTarget.closest(`.document-pane`)?.contains(e.relatedTarget)&&o.saveNow()},onKeyDown:C}):y.trim()===``?I(`p`,{className:`dp-empty`,children:r(`docPane.emptyDocument`)}):I(`div`,{className:`dp-page`,dir:`auto`,children:I(P0,{kind:g,text:y,streaming:h})})})]})}function I0({chat:e}){let t=L(),n=pL(t=>t.live[e]),[r,i]=(0,V.useState)(``),a=(0,V.useRef)(null);return(0,V.useEffect)(()=>{n?.status===`writing`&&a.current!==n.path?(a.current=n.path,i(t(`docPane.announce.writing`,{name:kd(rL(n.path))}))):n?.status===`stopped`?a.current=null:!n&&a.current&&(i(t(`docPane.announce.ready`,{name:kd(rL(a.current))})),a.current=null)},[n,t]),I(`span`,{className:`dp-sr-only`,role:`status`,"aria-live":`polite`,children:r})}function L0(){let e=L(),t=z(e=>e.currentSessionId),n=mL(t),r=Yd(ZI),i=pL(e=>e.overlayOpen),a=pL(e=>e.width),o=pL(e=>e.setWidth),s=(0,V.useRef)(null),c=(0,V.useRef)(null),l=RW({width:a,setWidth:o,clamp:cL,min:360,max:XI,defaultWidth:560}),u=!!t&&n.active!==null&&(r?i:n.open),d=(0,V.useCallback)(()=>{t&&pL.getState().close(t)},[t]);er(u&&r,d),yn(s,u&&r),(0,V.useEffect)(()=>{if(!(u&&r))return;let e=document.activeElement instanceof HTMLElement?document.activeElement:null;return c.current?.focus(),()=>{e?.isConnected&&e.focus()}},[u,r]);let f=u&&!r;if((0,V.useEffect)(()=>{if(!f)return;let e=document.documentElement;return e.style.setProperty(`--browser-pane-inset`,`${l.width}px`),()=>{e.style.removeProperty(`--browser-pane-inset`)}},[f,l.width]),!t)return null;if(!u||n.active===null)return I(I0,{chat:t});let p=n.active;return R(F.Fragment,{children:[r&&I(`div`,{className:`dp-backdrop`,onClick:d,"aria-hidden":`true`}),R(`aside`,{ref:s,className:`document-pane ${r?`is-overlay`:`is-docked`}`,style:r?void 0:{width:l.width},"aria-label":e(`docPane.label`),role:r?`dialog`:`complementary`,"aria-modal":r?!0:void 0,children:[!r&&I(`div`,{className:`dp-resize${l.dragging?` is-dragging`:``}`,"aria-label":e(`docPane.resize`),...l.separatorProps}),R(`header`,{className:`dp-header`,children:[I(`div`,{className:`dp-tabs`,role:`group`,"aria-label":e(`docPane.tabs`),children:n.tabs.map(r=>{let i=iL(r,p),a=kd(rL(r));return R(`span`,{className:`dp-tab${i?` active`:``}`,children:[R(`button`,{type:`button`,"aria-current":i?`true`:void 0,className:`dp-tab-name`,title:kd(r),onClick:()=>pL.getState().show(t,r),children:[I(Sa,{size:13,"aria-hidden":`true`}),I(`span`,{dir:`ltr`,children:a})]}),n.tabs.length>1&&I(`button`,{type:`button`,className:`dp-tab-close`,onClick:()=>pL.getState().closeTab(t,r),"aria-label":e(`docPane.closeTab`,{name:a}),children:I(bc,{size:11})})]},r)})}),I(`button`,{ref:c,type:`button`,className:`btn-icon-sm`,onClick:d,"aria-label":e(`docPane.close`),title:e(`docPane.close`),children:I(bc,{size:16})})]}),I(F0,{chat:t,path:p,overlay:r},`${t}:${p}`),I(I0,{chat:t})]})]})}var R0=`goal-store-error-`,z0=0;function B0(){let e=fu.getState();for(let t of e.notifications)t.id.startsWith(R0)&&!t.read&&e.markRead(t.id)}var V0=or((e,t)=>({error:null,damaged:!1,check:async()=>{let n,r;try{({error:n,damaged:r}=await KP())}catch(e){P.api.error(`Could not check the goal store`,e);return}n&&n!==t().error&&(z0+=1,fu.getState().addNotification({id:`${R0}${z0}`,type:`error`,agentId:`goals`,agentName:`GAIA`,title:Qt()(`mem.goals.storeError`),message:n,timestamp:Date.now(),read:!1,dismissed:!1,priority:`high`})),n||B0(),e({error:n,damaged:!!r})}})),H0=new Set([`loading_model`,`downloading_model`,`model_retry`,`waiting`]),U0=5;function W0(e,t){return{id:e,title:t.get(e)?.title??`Untitled chat`}}function G0(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=>({...W0(e,t),reason:`approval`}));n&&e.awaitingUser&&!a.has(e.currentSessionId)&&o.push({...W0(e.currentSessionId,t),reason:`answer`});for(let[n,r]of Object.entries(e.awaitingBySession))o.some(e=>e.id===n)||o.push({...W0(n,t),reason:r===`question`?`answer`:`approval`});let s=n&&!e.awaitingUser&&e.livePhase&&H0.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,U0).map(e=>W0(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=>W0(e,t)),needsYou:o,recent:u}}function K0(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=z.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:fu.getState().notifications},a=r;if(r=i,a&&Object.keys(i).every(e=>i[e]===a[e]))return;let o=G0(i),s=JSON.stringify(o);s!==n&&(n=s,e.setActivity(o).catch(e=>{n=``,P.system.error(`The tray could not take the app state`,e)}))};i();let a=z.subscribe(i),o=fu.subscribe(i),s=e.onCommand(e=>{switch(e.type){case`open-chat`:t.current.openChat(e.sessionId);break;case`new-chat`:t.current.newChat();break;case`open-settings`:z.getState().openSettings(e.section);break;case`refresh-status`:t.current.refreshStatus();break;default:P.system.error(`Unknown tray command`,e)}});return()=>{a(),o(),s()}},[])}function q0(){(0,V.useEffect)(()=>{let e=window.gaiaAPI;if(!e)return;let t=fu.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=z.getState();n.currentSessionId!==t&&n.setMessages([]),n.setCurrentSession(t)})];return()=>n.forEach(e=>e())},[])}function J0(e,t,n){let r=window.gaiaAPI;if(r){r.notification.show({title:t,body:n,sessionId:e}).then(e=>{e||P.system.warn(`This OS has no desktop notifications; the badge still counts it.`)}).catch(e=>P.system.error(`Could not show the desktop notification`,e));return}if(typeof Notification>`u`){P.system.warn(`This browser has no notifications; the alert was not shown.`);return}if(Notification.permission!==`granted`){P.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(),z.getState().setCurrentSession(e)}}function Y0(){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=>P.system.warn(`Battery level unavailable; keep-awake ignores the battery policy.`,e)),()=>{n?.removeEventListener(`levelchange`,r),n?.removeEventListener(`chargingchange`,r)}},[]),e}function X0(){q0();let e=z(e=>e.runningSessionIds),t=z(e=>e.awaitingBySession),n=z(e=>e.sessions),r=z(e=>e.currentSessionId),i=fu(kc(_u)),a=wu(),o=Y0(),s=(0,V.useRef)(null),c=ju(e,t,i),l=JSON.stringify(c);(0,V.useEffect)(()=>{let e=JSON.parse(l),t=s.current;if(s.current=e,t===null)return;let{sessions:n,currentSessionId:r}=z.getState(),i=document.hasFocus(),o=!1;for(let{sessionId:s,event:c}of Mu(t,e)){let e=n.find(e=>e.id===s);if(e?.kind===`eval`||e?.kind===`scheduled`)continue;let t=a.modes[c];if(!(t===`off`||Fu(s,r,i))&&(o=!0,t===`banner`)){if(c!==`finished`){let{title:t,body:n}=Pu(c,e);J0(s,t,n)}else dt(s).then(e=>{z.getState().updateSessionInList(s,e);let{title:t,body:n}=Pu(c,e);J0(s,t,n)}).catch(t=>{P.system.error(`Could not read how chat ${s} ended`,t);let{title:n,body:r}=Pu(c,{...e,last_run_status:null});J0(s,n,r)})}}if(o){if(a.sound)try{Ru()}catch(e){P.system.warn(`Alert sound not played`,e)}a.flash&&!i&&window.gaiaAPI&&window.gaiaAPI.notification.flash().catch(e=>P.system.error(`Could not flash the taskbar button`,e))}},[l,a.modes,a.sound,a.flash]);let u=Iu(n,c,a.modes,r);(0,V.useEffect)(()=>{window.gaiaAPI?.notification.setAttentionCount(u).catch(e=>P.system.error(`Could not update the taskbar badge`,e))},[u]);let d=a.keepAwake&&e.length>0&&Lu(o,a.batteryFloor);(0,V.useEffect)(()=>{window.gaiaAPI?.power.setKeepAwake(d).catch(e=>P.system.error(`Could not change keep-awake`,e))},[d])}function Z0(e){return e.indexing_status===`failed`&&YV(e.error_kind)}var Q0=1e4,$0=6e4;function e2(){let e=z(e=>e.systemStatus?.lemonade_running===!0),t=z(e=>e.documents.some(Z0)),n=z(e=>e.setDocuments),r=(0,V.useRef)(!1),i=(0,V.useRef)(0),a=(0,V.useRef)(0),[o,s]=(0,V.useState)(0),c=(0,V.useRef)(()=>{}),l=(0,V.useRef)(!1);c.current=()=>{let e=async()=>{i.current=Date.now();let{documents:e}=await Tt(),t=(e||[]).filter(Z0).map(e=>e.id);if(t.length===0){a.current=0,z.getState().documents.some(Z0)&&n(e||[]);return}P.doc.info(`Model server is back; retrying ${t.length} document(s) that were waiting for it`);for(let e of t){let t=(await Tt()).documents||[],r=t.find(t=>t.id===e);if(r&&Z0(r)){n(t.map(t=>t.id===e?{...t,indexing_status:`indexing`}:t));try{await sr(e),P.doc.info(`Indexed "${r.filename}" now the model server is back`)}catch(e){P.doc.warn(`"${r.filename}" still couldn't be indexed after the model server came back`,e)}}}let r=(await Tt()).documents||[];a.current=r.some(Z0)?a.current+1:0,i.current=Date.now(),n(r)};r.current=!0,(async()=>{try{do{l.current=!1;try{await e()}catch(e){a.current+=1,i.current=Date.now(),P.doc.warn(`Could not retry the documents waiting for the model server`,e)}}while(l.current&&z.getState().systemStatus?.lemonade_running===!0)}finally{r.current=!1,s(e=>e+1)}})()},(0,V.useEffect)(()=>{e&&(a.current=0,r.current?l.current=!0:c.current())},[e]),(0,V.useEffect)(()=>{if(!e||!t||r.current)return;let n=a.current===0?0:Math.min(Q0*2**(a.current-1),$0),o=setTimeout(()=>{r.current||c.current()},Math.max(0,i.current+n-Date.now()));return()=>clearTimeout(o)},[e,t,o])}var t2=`GAIA Agent UI`;function n2(){let e=L(),t=z(e=>e.sessions.find(t=>t.id===e.currentSessionId)),n=t?.title,r=t?.kind;(0,V.useEffect)(()=>{let t=n?.trim()?Jd(e,{title:n.trim(),kind:r}):``;document.title=t?`${t} - GAIA`:t2},[n,r,e])}function r2(e,t,n){return!e||t&&(e===t||e===_H(t))?null:n.some(t=>t.id===e)?e:vH(n,e)}function i2(e){return new URLSearchParams(e.search).get(`session`)||e.hash.replace(/^#/,``)||null}var a2=`gaia:last-session`;function o2(e){try{e?localStorage.setItem(a2,e):localStorage.removeItem(a2)}catch(e){P.ui.warn(`Could not save the open chat for the next launch`,e)}}function s2(){try{return localStorage.getItem(a2)}catch(e){return P.ui.warn(`Could not read the chat open at last launch`,e),null}}var c2=1e3,l2=3e4;function u2(e,{initialMs:t=c2,maxMs:n=l2,onError:r}={}){let i=t,a=0,o=null,s=!1,c=!1,l=!1,u=()=>{l||c||s||(o&&=(clearTimeout(o),null),s=!0,a+=1,e().then(()=>{c=!0}).catch(e=>{l||(r?.(e,a),o=setTimeout(()=>{o=null,u()},i),i=Math.min(i*2,n))}).finally(()=>{s=!1}))};return u(),{kick:()=>{o&&u()},stop:()=>{l=!0,o&&clearTimeout(o),o=null},done:()=>c}}function d2(e,t,n){return e&&!t&&!n}function f2(){let e=L(),[t]=(0,V.useState)(()=>Date.now()),[n,r]=(0,V.useState)(t);(0,V.useEffect)(()=>{let e=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(e)},[]);let i=n-t;return R(`main`,{className:`startup`,role:`status`,"aria-label":e(`app.startingAria`),children:[I(`div`,{className:`loading-spinner`,"aria-hidden":`true`}),I(`p`,{className:`startup-text`,dir:`auto`,children:e(`app.starting`)}),i>=1e4&&R(`p`,{className:`startup-elapsed`,dir:`auto`,children:[e(`app.stillStarting`),` · `,I(`bdi`,{dir:`ltr`,children:e(`app.startingSeconds`,{s:Math.floor(i/1e3)})})]})]})}function p2({error:e,onCheckAgain:t}){let n=L(),r=LB(e=>e.lifecycle),i=LB(e=>e.restart),a=LB(e=>e.restartError),o=r?.status===`stopped`||r?.status===`restarting`||r?.status===`running`,s=r?.status===`restarting`,c=[...new Set([a,r?.lastError,e].filter(e=>!!e))];return I(`main`,{className:`startup startup--failed`,role:`alert`,children:R(`div`,{className:`startup-failed`,children:[I(`h1`,{className:`startup-failed-title`,dir:`auto`,children:n(`startup.failed.title`)}),I(`p`,{className:`startup-failed-hint`,dir:`auto`,children:n(o?`startup.failed.hintRestart`:`startup.failed.hintReopen`)}),R(`div`,{className:`startup-failed-actions`,children:[o&&I(`button`,{type:`button`,className:`btn-primary`,disabled:s,onClick:()=>void i(),children:n(s?`banner.restartingShort`:`banner.restartButton`)}),I(`button`,{type:`button`,className:o?`btn-secondary`:`btn-primary`,onClick:t,children:n(`setup.unknown.retry`)})]}),R(`details`,{className:`startup-failed-details`,children:[I(`summary`,{children:n(`startup.failed.details`)}),I(`pre`,{className:`startup-failed-log`,dir:`ltr`,children:c.join(`
222
+ `)})]})]})})}var m2=(0,V.lazy)(()=>J1(()=>import(`./MemoryDashboard-gFulbynO.js`).then(e=>({default:e.MemoryDashboard})),__vite__mapDeps([7,1,2,8]),import.meta.url)),h2=(0,V.lazy)(()=>J1(()=>import(`./ScheduleManager-7tRAmOEB.js`).then(e=>({default:e.ScheduleManager})),__vite__mapDeps([9,1,2,10]),import.meta.url)),g2=(0,V.lazy)(()=>J1(()=>import(`./DocumentLibrary-CC2YsO-O.js`).then(e=>({default:e.DocumentLibrary})),__vite__mapDeps([11,1,2,12,13]),import.meta.url)),_2=(0,V.lazy)(()=>J1(()=>import(`./FileBrowser-BhArokri.js`).then(e=>({default:e.FileBrowser})),__vite__mapDeps([14,1,2,12,15]),import.meta.url)),v2=(0,V.lazy)(()=>J1(()=>import(`./MobileAccessModal-QheAv8eE.js`).then(e=>({default:e.MobileAccessModal})),__vite__mapDeps([16,1,2,17]),import.meta.url)),y2=3,b2=3e5,x2=4e3,S2=6e4,C2=e=>e instanceof TypeError,w2=e=>new Promise(t=>setTimeout(t,e)),T2=3e5,E2=class extends Error{},D2=class extends Error{refusal;constructor(e){super(e.message),this.refusal=e}},O2=class extends Error{constructor(e){super(Qt().bare(`setup.unknown.modelUnread`,{error:e}))}};async function k2(){let e=Date.now()+T2;for(;;){let t=await $t();if(t.state===`ready`)return;if(t.state===`failed`||t.state===`cancelled`)throw new E2(t.error||Qt().bare(`setup.upgrading.stopped`));if(Date.now()>=e)throw Error(Qt().bare(`setup.upgrading.slow`));await w2(c2)}}function A2(){let e=L();return I(`div`,{className:`loading-spinner`,role:`status`,"aria-label":e(`app.loading`)})}var j2=e=>e===1||e%10==0;function M2(){il.getState().active?.remote||DQ()?.markSetupWorked().catch(e=>{P.system.warn(`Couldn't record that setup works on this version`,e)})}function N2(){let e=L(),t=mr(e=>e.signInRequired);n2();let n=z(e=>e.currentSessionId),r=z(e=>e.setSessions),i=z(e=>e.setCurrentSession),a=z(e=>e.addSession),o=z(e=>e.setMessages),s=z(e=>e.showDocLibrary),c=z(e=>e.showFileBrowser),l=z(e=>e.showMemoryDashboard),u=z(e=>e.showSchedules),d=z(e=>e.sidebarOpen),f=z(e=>e.sidebarCollapsed),p=z(e=>e.setSidebarOpen),m=z(e=>e.setSystemStatus),h=z(e=>e.setBackendConnected),g=z(e=>e.setAgents),_=z(e=>e.agents),v=z(e=>e.setPendingPrompt),y=z(e=>e.setDefaultPermissionMode),b=z(e=>e.openSettings),x=z(e=>e.settingsSection),S=z(e=>e.syncSystemTheme),C=il(e=>e.restoreNotice),w=il(e=>e.dismissRestoreNotice),T=fu(e=>e.showPanel),E=z(e=>e.systemStatus?.initialized===!0),ee=(0,V.useRef)(!1),D=fu(e=>e.setShowPanel);(0,V.useEffect)(()=>{if(!C?.ok)return;let e=setTimeout(w,x2);return()=>clearTimeout(e)},[C,w]);let[O,te]=(0,V.useState)({state:`checking`}),k=z(e=>e.setupAgain),A=z(e=>e.runSetupAgain),ne=(0,V.useRef)(O);ne.current=O;let[j,re]=(0,V.useState)(!1),ie=(0,V.useRef)(j);ie.current=j;let[ae,oe]=(0,V.useState)(!1),[se,ce]=(0,V.useState)(!1),le=ae||j&&!wA(_),ue=(0,V.useRef)(le);ue.current=le;let[de,fe]=(0,V.useState)(null),[me,he]=(0,V.useState)(!1),[ge,_e]=(0,V.useState)(``),[ve,ye]=(0,V.useState)(0),[be,xe]=(0,V.useState)(0),[Se,Ce]=(0,V.useState)(!1),[we,N]=(0,V.useState)(!1),[Te,Ee]=(0,V.useState)(null),[De,Oe]=(0,V.useState)(null),ke=(0,V.useRef)(async()=>{}),Ae=(0,V.useRef)(async()=>{}),je=(0,V.useCallback)(async(e=!1,t=!1)=>{e||te({state:`checking`});let n=0;try{for(;;){await il.getState().refresh();let e=il.getState().active,r=!!e?.remote,i;try{if(i=await pe(r),!e&&!i.ready)throw new O2(il.getState().error??`no answer`)}catch(e){let r=C2(e)||e instanceof O2,i=LB.getState().lifecycle?.status===`stopped`;if(!t||!r||i||n>=S2)throw C2(e)&&(t||ne.current.state===`backendDown`)?new D2(e):e;await w2(c2),n+=c2;continue}if(!i.ready&&i.stage===`upgrade`){te({state:`upgrading`});let e=await $t();(!e.upgrade_embedded||e.state!==`running`&&e.state!==`verifying`)&&await Rt(r,!1,{upgradeEmbedded:!0}),await k2(),i=await pe(r)}(n>0||ne.current.state===`backendDown`)&&await Promise.all([ke.current(),Ae.current()]),ce(!!i.no_agent_build),i.ready&&M2();let a=!i.ready&&i.stage===`server`&&!!i.initialized;te(i.ready?{state:`ready`}:a?{state:`serverDown`,modelListUnread:!!i.model_list_unread}:{state:`needed`,check:i});return}}catch(e){let t=e instanceof Error?e.message:String(e);if(e instanceof E2){P.system.warn(`Updating the local model server failed`,e),te({state:`unknown`,error:t,upgradeFailed:!0});return}if(e instanceof D2){P.system.error(`GAIA's backend did not start`,e.refusal),te({state:`backendDown`,error:t});return}P.system.warn(`Setup check could not be answered`,e),te({state:`unknown`,error:t})}},[]),Me=z(e=>!!e.systemStatus&&cV(e.systemStatus)===`unresponsive`),Ne=z(e=>e.systemStatus?.lemonade_running===!0);(0,V.useEffect)(()=>{O.state===`serverDown`&&Ne&&je(!0)},[O.state,Ne,je]);let Pe=z(e=>e.systemStatus?.lemonade_running===!1);(0,V.useEffect)(()=>{if(O.state!==`ready`||!Pe)return;let e=!1;return pe(!!il.getState().active?.remote).then(t=>{!e&&!t.ready&&t.stage===`server`&&t.initialized&&te({state:`serverDown`,modelListUnread:!!t.model_list_unread})}).catch(e=>P.system.warn(`Could not confirm the model server is down`,e)),()=>{e=!0}},[O.state,Pe]);let Fe=(0,V.useRef)(0),Ie=(0,V.useCallback)(async()=>{let e=++Fe.current,t=(await Un()).agents||[];e===Fe.current&&(g(t),re(!0),wA(t)&&oe(!1))},[g]),Re=(0,V.useCallback)(()=>{let e=ie.current;re(!1),Ie().catch(t=>{P.api.warn(`Agent list unavailable after setup`,t),e&&re(!0)})},[Ie]);(0,V.useEffect)(()=>{let e=()=>{ue.current&&Ie().catch(e=>P.api.warn(`Agent list unavailable`,e))};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[Ie]);let ze=(0,V.useCallback)(async()=>{y((await gr()).default_mode)},[y]),Be=(0,V.useRef)([]);(0,V.useEffect)(()=>{ur(`0.27.1rc1`),je(!1,!0);let e=[u2(Ie,{onError:(e,t)=>{j2(t)&&P.api.warn(`Agent list unavailable (attempt ${t}); retrying`,e)}}),u2(ze,{onError:(e,t)=>{j2(t)&&P.api.warn(`Default permission mode unavailable (attempt ${t}); retrying`,e)}})];return Be.current=e,()=>e.forEach(e=>e.stop())},[je,Ie,ze]);let Ve=(0,V.useCallback)(()=>{Be.current.forEach(e=>e.kick()),il.getState().retryNow(),Ae.current();let e=ne.current;(e.state===`unknown`&&!e.upgradeFailed||e.state===`backendDown`)&&je(!0)},[je]),He=(0,V.useRef)(Ve);He.current=Ve;let We=(0,V.useRef)(!1);(0,V.useEffect)(()=>{t?We.current=!0:We.current&&(We.current=!1,Ve())},[t,Ve]);let Ge=(0,V.useRef)(0),Ke=(0,V.useRef)(0),qe=(0,V.useRef)(null),Je=(0,V.useRef)(!1),[Xe,Ze]=(0,V.useState)(!1),[Qe,$e]=(0,V.useState)(null),et=(0,V.useCallback)(e=>{if(e.kind===`unreachable`){P.system.warn(`System status check failed`,e.error),RB(),Je.current=!0,Ke.current=0,qe.current=null,Ze(!1),$e(null),z.getState().setBackendStalled(!1),h(!1),m(null);return}if(e.kind===`error`){P.system.warn(`System status answered HTTP ${e.httpStatus}`,e.message),Je.current&&He.current(),Je.current=!1,Ke.current=0,qe.current=null,Ze(!1),$e(`HTTP ${e.httpStatus}: ${e.message}`),z.getState().setBackendStalled(!1),h(!0);return}if(e.kind===`slow`){if(Ke.current+=1,qe.current??=Date.now(),$e(null),P.system.warn(`System status did not answer in time (${Ke.current} in a row)`),Date.now()-qe.current>=b2){Ze(!1),h(!1),m(null);return}h(!0),(Je.current||Ke.current>=y2)&&Ze(!0);return}let{status:t}=e;Je.current&&He.current(),Je.current=!1,Ke.current=0,qe.current=null,Ze(!1),$e(null),z.getState().setBackendStalled(!1),h(!0),Ge.current=t.lemonade_running?0:Ge.current+1;let n=z.getState().systemStatus;t.lemonade_running||Ge.current>=y2||!n?.lemonade_running?m(t):m({...n,download_progress:t.download_progress})},[h,m]),tt=(0,V.useRef)(et);tt.current=et;let[nt]=(0,V.useState)(()=>dV(e=>tt.current(e))),rt=nt.check;ke.current=rt,(0,V.useEffect)(()=>Ml(nt.start),[nt]),(0,V.useEffect)(()=>zB(()=>{rt()}),[rt]);let it=(0,V.useRef)(``);(0,V.useEffect)(()=>{let e=e=>zt().then(t=>{let n=t.sessions||[];if(!e&&n.length===0&&z.getState().sessions.length>0)return;let i=n.map(e=>`${e.id}|${e.updated_at}|${e.title}|${e.inference_remote}|${e.inference_provider}|${e.inference_description}|${e.effective_model}|${e.unread}|${e.pinned}|${e.last_run_status}|${e.kind}`).join(`
223
+ `);if(i===it.current)return;it.current=i,r(n);let a=il.getState().active?.model;a&&n.some(e=>e.effective_model&&e.effective_model!==a)&&il.getState().refresh()}).catch(t=>{e&&P.system.error(`Could not load chats`,t)});Ae.current=()=>e(!1),e(!0);let t=setInterval(()=>void e(!1),5e3);return()=>clearInterval(t)},[r]),(0,V.useEffect)(()=>wV(),[]),(0,V.useEffect)(()=>{let e=()=>{aK.getState().loadSchedules()};e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[]),(0,V.useEffect)(()=>{let e=()=>{V0.getState().check()};e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[]),(0,V.useEffect)(()=>HV(),[]),X0(),e2();let at=(0,V.useRef)(!1),ot=(0,V.useRef)(!1);(0,V.useEffect)(()=>{let e=()=>{let e=i2(window.location),{currentSessionId:t,sessions:n}=z.getState(),r=r2(e,t,n);return r&&(i(r),o([])),r},t=()=>{if(at.current||(at.current=!0,e()||z.getState().currentSessionId))return;if(window.location.hash){window.history.replaceState(null,``,window.location.pathname+window.location.search);return}if(ot.current||Ut(`new-chat`))return;let{sessions:t}=z.getState(),n=r2(s2(),null,t);n&&(i(n),o([]))},n=z.subscribe(e=>{e.sessions.length>0&&t()});return z.getState().sessions.length>0&&t(),window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{n(),window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[i,o]),(0,V.useEffect)(()=>{let e=null,t=2e3,n=!1,r=null,a=()=>{n||(e=new EventSource(`${Le()}/sessions/events`),e.onopen=()=>{t=2e3},e.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch(e){P.api.warn(`Malformed session event`,e);return}t.type===`set_active_session`&&t.session_id&&t.session_id!==z.getState().currentSessionId&&(i(t.session_id),o([]))},e.onerror=()=>{e?.close(),e=null,n||(r=setTimeout(a,t),t=Math.min(t*2,3e4))})};return a(),()=>{n=!0,r&&clearTimeout(r),e?.close()}},[i,o]),(0,V.useEffect)(()=>{if(at.current&&o2(n),n){let e=_H(n);window.location.hash!==`#${e}`&&window.history.replaceState(null,``,`#${e}`)}else at.current&&window.location.hash&&window.history.replaceState(null,``,window.location.pathname+window.location.search)},[n]);let st=(0,V.useCallback)(async e=>{if(fe(null),he(!1),!await Vc(`chat`))return _e(e),!1;let t=z.getState(),n;try{n=await Ct({title:`New chat`,agent_type:CA,document_ids:t.draftDocumentIds,private:t.draftPrivate,folders:t.draftFolder?[t.draftFolder]:[]})}catch(e){throw EA(e)?(oe(!0),new TA):e}ue.current&&(oe(!1),Ie().catch(e=>P.api.warn(`Agent list unavailable`,e))),t.defaultPermissionModeKnown||(await ze().catch(e=>P.api.warn(`Default permission mode unavailable; using the chip's mode`,e)),t=z.getState()),t.clearDraftDocuments(),t.setDraftPrivate(!1),t.adoptDraftResearch(n.id,e),t.setDraftFolder(null);let r=null;try{await Ue(n.id,t.draftPermissionMode)}catch(e){r=e}return Jt(An),r&&!n.private&&pt(hn(n.id),e),a(n),qI.getState().claimDraft(n.id),i(n.id),o([]),_e(``),r?(fe(`The chat was created, but its permission mode could not be set, so your message was not sent${n.private?``:` — it is in the chat's box`}: ${r instanceof Error?r.message:r}`),!1):(t.resetDraftPermissionMode(),v({sessionId:n.id,text:e}),!0)},[a,i,o,v,Ie,ze]),ct=(0,V.useCallback)(async e=>{try{return await st(e)}catch(t){if(!(t instanceof TA))throw t;let n=Ut(An),r=n.trimEnd().endsWith(e)?n:[n,e].filter(Boolean).join(`
224
+
225
+ `);return pt(An,r),_e(r),he(!0),xe(e=>e+1),!1}},[st]),lt=(0,V.useCallback)(()=>{let e=z.getState(),t=e.currentSessionId,n=e.pendingPrompt?.sessionId===t?e.pendingPrompt:null;n&&(e.setPendingPrompt(null),_e(n.text)),t&&qu(t,z.getState())&&Ju(t),e.setShowMemoryDashboard(!1),e.setShowSchedules(!1),ot.current=!0,he(!1),i(null),o([]),ye(e=>e+1)},[i,o]),ut=(0,V.useCallback)(e=>{let t=z.getState();t.closeSettings(),e!==t.currentSessionId&&(Ju(t.currentSessionId),o([])),i(e)},[i,o]),dt=(0,V.useCallback)(e=>{let t=z.getState();t.setShowMemoryDashboard(!1),t.setShowSchedules(!1),D(!1),ut(e)},[ut]);K0({openChat:ut,newChat:(0,V.useCallback)(()=>{z.getState().closeSettings(),lt()},[lt]),refreshStatus:()=>void rt()});let ft=(0,V.useCallback)(t=>{let n=z.getState(),r=n.pendingPrompt?.sessionId===n.currentSessionId?n.pendingPrompt?.text:null;lt();let i=e.bare(`settings.skills.tryPrompt`,{name:t}),a=[Ut(An),r].filter(Boolean).join(`
226
+
227
+ `),o=a.trimEnd().endsWith(i)?a:[a,i].filter(Boolean).join(`
228
+
229
+ `);pt(An,o),_e(o),xe(e=>e+1)},[lt,e]);(0,V.useEffect)(()=>{let e=e=>{let t=e.detail;z.getState().closeSettings(),lt(),ct(a0(t)).catch(e=>fe(e instanceof Error?e.message:String(e)))};return window.addEventListener(t0,e),()=>window.removeEventListener(t0,e)},[lt,ct]);let mt=(0,V.useCallback)(e=>{M2(),te({state:`ready`}),Re(),rt(),e&&(e.needs_input?_e(e.prompt):ct(e.prompt).catch(e=>fe(e instanceof Error?e.message:String(e))))},[rt,ct,Re]),ht=(0,V.useCallback)(()=>{te({state:`ready`}),rt()},[rt]);(0,V.useEffect)(()=>{let e=()=>{z.getState().closeSettings(),te({state:`addingLocal`})};return window.addEventListener(`gaia:set-up-local`,e),()=>window.removeEventListener(`gaia:set-up-local`,e)},[]);let[gt,_t]=(0,V.useState)(!1);(0,V.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&(mn()?e.key===`/`&&(e.preventDefault(),_t(!1)):e.shiftKey&&e.key.toLowerCase()===`o`?(e.preventDefault(),lt()):!e.shiftKey&&e.key.toLowerCase()===`k`?(e.preventDefault(),window.dispatchEvent(new CustomEvent(`gaia:focus-search`))):!e.shiftKey&&e.key.toLowerCase()===`b`?(e.preventDefault(),z.getState().toggleSidebarCollapsed()):!e.shiftKey&&e.key===`,`?(e.preventDefault(),b()):e.key===`/`&&(e.preventDefault(),_t(e=>!e)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[lt,b]),(0,V.useEffect)(()=>{let e=window.matchMedia?.(`(max-width: 768px)`);if(!e)return;let t=()=>p(!e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[p]),(0,V.useEffect)(()=>{if(typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(prefers-color-scheme: light)`);return e.addEventListener(`change`,S),()=>e.removeEventListener(`change`,S)},[S]),(0,V.useEffect)(()=>{qn().then(e=>N(e.active===!0)).catch(e=>P.system.debug(`Mobile access unavailable`,e))},[]);let vt=(0,V.useCallback)(async()=>{if(Ce(!0),Ee(null),we)Oe(null);else try{let e=await Ye(),t=e.reason===`ngrok_not_installed`;if(Oe(t?e.installCommands??[]:null),t)return;e.error?Ee(e.error):N(!0)}catch(e){Oe(null),Ee(e instanceof Error?e.message:`Could not start mobile access`)}},[we]),yt=(0,V.useCallback)(async()=>{try{await M(),N(!1),Ce(!1)}catch(e){Ee(e instanceof Error?e.message:`Could not stop mobile access`)}},[]);fG(e=>{e?vt():yt()}),(0,V.useEffect)(()=>{uG(we)},[we]);let bt=Yd(`(max-width: 768px)`),xt=d2(O.state===`checking`,E,ee.current);if(!xt&&O.state!==`needed`&&O.state!==`backendDown`&&(ee.current=!0),t)return I(`div`,{className:`app`,children:R(`main`,{className:`startup`,role:`alert`,children:[I(`p`,{className:`startup-text`,dir:`auto`,children:e(`auth.signIn.title`)}),I(`p`,{className:`startup-text`,dir:`auto`,children:e(`auth.signIn.hint`,{command:`gaia chat --ui`})})]})});if(xt)return I(`div`,{className:`app`,children:I(f2,{})});if(O.state===`backendDown`)return I(`div`,{className:`app`,children:I(p2,{error:O.error,onCheckAgain:()=>void je(!0)})});if(O.state===`upgrading`)return I(`div`,{className:`app`,children:R(`main`,{className:`startup`,role:`status`,"aria-live":`polite`,"aria-label":e(`setup.upgrading.notice`),children:[I(`div`,{className:`loading-spinner`,"aria-hidden":`true`}),I(`p`,{className:`startup-text`,children:e(`setup.upgrading.notice`)})]})});if(O.state===`needed`||O.state===`addingLocal`||k){let e=k?()=>A(!1):O.state===`addingLocal`?ht:void 0;return R(`div`,{className:`app`,children:[I(m$,{onReady:e=>{A(!1),mt(e)},onClose:e}),I(nX,{}),I(p0,{})]})}let St=!l&&!u?zI():void 0,wt=l?I(V.Suspense,{fallback:I(A2,{}),children:I(m2,{})}):n?I(hY,{sessionId:n},n):I(ZY,{onSend:st,initialText:ge,focusRequest:ve,agentMissing:le,agentRefused:me},`${be}:${ge}`);return R(`div`,{className:`app`,children:[!d&&I(`button`,{className:`sidebar-toggle`,onClick:()=>p(!0),"aria-label":e(`sidebar.open`),children:I(bo,{size:18})}),I(`div`,{className:`sidebar-overlay ${d?`visible`:``}`,onClick:()=>p(!1),"aria-hidden":`true`}),I(V1,{area:`sidebar`,variant:`compact`,children:I(yf,{onNewChat:lt,onMobileAccess:bt?void 0:()=>void vt(),tunnelActive:we})}),R(`div`,{className:`main-content`,children:[(O.state===`ready`||O.state===`checking`||O.state===`serverDown`&&Me)&&I(d0,{onRetry:rt,backendSlow:Xe,backendError:Qe}),O.state===`serverDown`&&!Me&&R(`div`,{className:`app-notice is-warning`,role:`status`,children:[I(`span`,{children:e(O.modelListUnread?`setup.modelListUnread.notice`:`setup.serverDown.notice`)}),I(`button`,{type:`button`,className:`link-btn`,onClick:()=>void je(!0),children:e(`setup.unknown.retry`)}),!O.modelListUnread&&I(`button`,{type:`button`,className:`link-btn`,onClick:()=>A(!0),children:e(`setup.serverDown.setup`)})]}),O.state===`unknown`&&(O.upgradeFailed?R(F.Fragment,{children:[R(`div`,{className:`app-notice is-warning`,role:`status`,children:[I(`span`,{children:e(`setup.upgrading.failed`,{error:O.error})}),I(`button`,{type:`button`,className:`link-btn`,onClick:()=>void je(),children:e(`setup.upgrading.retry`)})]}),I(PQ,{className:`app-go-back`})]}):R(`div`,{className:`app-notice is-warning`,role:`status`,children:[I(`span`,{children:e(`setup.unknown.failed`,{error:O.error})}),I(`button`,{type:`button`,className:`link-btn`,onClick:()=>void je(),children:e(`setup.unknown.retry`)})]})),(!d||f)&&I(Gl,{placement:`main`}),le&&I(S0,{onInstalled:Ie,noBuild:se}),C?.ok&&I(`div`,{className:`toast app-restore-toast`,role:`status`,children:e(`model.restore.done`)}),C&&!C.ok&&R(`div`,{className:`app-notice is-warning`,role:`status`,children:[I(`span`,{children:L1(e,C)}),I(`button`,{type:`button`,className:`link-btn`,onClick:()=>{w(),b(`model`)},children:e(`model.restore.pick`)}),I(`button`,{type:`button`,className:`app-notice-close`,onClick:w,"aria-label":e(`banner.dismiss`),children:I(bc,{size:14})})]}),I(V1,{resetKey:l?`memory`:n??`new-${ve}`,area:`main`,children:wt})]}),St&&I(pq,{api:St}),!l&&!u&&I(L0,{}),u&&I(V.Suspense,{fallback:null,children:I(h2,{})}),s&&I(V.Suspense,{fallback:null,children:I(g2,{})}),c&&I(V.Suspense,{fallback:null,children:I(_2,{onStartChat:ct})}),T&&I(`div`,{className:`notification-center-popover`,children:I(v0,{onClose:()=>D(!1),onOpenChat:dt})}),Se&&I(V.Suspense,{fallback:null,children:I(v2,{isOpen:Se,onClose:()=>Ce(!1),onStop:()=>void yt(),error:Te,setupCommands:De,onRetry:()=>void vt()})}),x&&I(e0,{onUseSkill:ft}),I(nX,{}),I(hX,{}),gt&&I(vX,{onClose:()=>_t(!1)}),I(p0,{}),de&&R(`div`,{className:`toast toast-dismissible`,role:`alert`,children:[I(`span`,{children:de}),I(`button`,{type:`button`,className:`toast-dismiss`,onClick:()=>fe(null),"aria-label":e(`banner.dismiss`),children:I(bc,{size:14,"aria-hidden":`true`})})]})]})}var P2=`agent-refresh`,F2={"pre-checks":`engine.stage.preChecks`,"ensure-uv":`engine.stage.ensureUv`,"create-venv":`engine.stage.createVenv`,"install-package":`engine.stage.installPackage`,verify:`engine.stage.verify`,[P2]:`engine.stage.agentRefresh`,start:`engine.stage.start`},I2={disk:`engine.hint.disk`,network:`engine.hint.network`,tls:`engine.hint.tls`,locked:`engine.hint.locked`,daemon:`engine.hint.daemon`};function L2(e,t){if(!e)return t(`engine.stage.neutral`);let n=F2[e];return n?t(n):(console.warn(`[EngineInstallScreen] install stage "${e}" has no label`),t(`engine.stage.neutral`))}function R2(e,t){return e.reason?t(I2[e.reason]):t(e.stage===P2?`engine.hint.agent`:`engine.hint.other`)}function z2(e){return e.reason===`locked`&&e.lockedBy?.length?e.lockedBy:null}function B2(e,t){let n=e.name??String(e.pid),r=e.folder;return e.isGaia?r?t(`engine.locked.gaia`,{name:n,folder:r}):t(`engine.locked.gaiaNoFolder`,{name:n}):r?t(`engine.locked.other`,{name:n,folder:r}):t(`engine.locked.otherNoFolder`,{name:n})}function V2({status:e}){let t=L(),n=L2(e.stage,t);return R(`div`,{className:`engine-progress`,role:`status`,children:[R(`div`,{className:`engine-progress-head`,children:[I(`span`,{children:n}),e.percent!==null&&R(`bdi`,{dir:`ltr`,children:[e.percent,`%`]})]}),I(`progress`,{className:`engine-bar`,"aria-label":n,max:100,value:e.percent??void 0})]})}function H2({error:e,busy:t,notice:n,onRetry:r,onCloseLockers:i,onContinue:a,onRevert:o,onOpenLog:s}){let c=L(),l=z2(e),u=l!==null&&l.every(e=>e.isGaia),d=(l?.length??0)>1;return R(`div`,{className:`engine-failure`,children:[R(`div`,{role:`alert`,children:[l?R(F.Fragment,{children:[l.map(e=>I(`p`,{className:`engine-hint`,children:B2(e,c)},e.pid)),!u&&I(`p`,{className:`engine-hint`,children:c(d?`engine.locked.closeThenMany`:`engine.locked.closeThen`)})]}):I(`p`,{className:`engine-hint`,children:R2(e,c)}),I(`p`,{className:`engine-error`,children:I(`bdi`,{dir:`ltr`,children:e.message})})]}),u&&I(`button`,{type:`button`,className:`btn-primary engine-retry`,disabled:t,onClick:i,autoFocus:!0,children:c(d?`engine.locked.closeMany`:`engine.locked.close`)}),I(`button`,{type:`button`,className:`${u?`btn-secondary`:`btn-primary`} engine-retry`,disabled:t,onClick:r,autoFocus:!u,children:c(`engine.tryAgain`)}),e.stage===P2&&I(`button`,{type:`button`,className:`btn-secondary engine-retry`,disabled:t,onClick:a,children:c(`engine.continueWithout`)}),e.previousVersion&&I(`button`,{type:`button`,className:`btn-secondary engine-retry`,disabled:t,onClick:o,children:c(`update.chip.goBack`,{version:e.previousVersion})}),n&&I(`p`,{className:`engine-error`,role:`alert`,children:I(`bdi`,{dir:`ltr`,children:n})}),R(`details`,{className:`engine-details`,children:[I(`summary`,{children:c(`engine.details`)}),I(`pre`,{className:`engine-log`,dir:`ltr`,children:e.logTail.join(`
230
+ `)}),I(`button`,{type:`button`,className:`btn-secondary`,onClick:s,children:c(`engine.openLog`)})]})]})}function U2(){let e=L(),[t,n]=(0,V.useState)({phase:`running`,stage:null,percent:null,message:``,error:null}),[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(null),s=(0,V.useCallback)(e=>{console.error(`[EngineInstallScreen] the desktop app did not answer`,e),o(e instanceof Error?e.message:String(e))},[]);(0,V.useEffect)(()=>{let e=window.gaiaInstall,t=e.onProgress(n);return e.status().then(n).catch(s),t},[s]);let c=(0,V.useCallback)(()=>{i(!0),o(null),window.gaiaInstall.retry().catch(s).finally(()=>i(!1))},[s]),l=(0,V.useCallback)(()=>{i(!0),o(null),window.gaiaInstall.closeLockingPrograms().catch(s).finally(()=>i(!1))},[s]),u=(0,V.useCallback)(()=>{i(!0),o(null),window.gaiaInstall.continueWithoutAgentUpdate().catch(s).finally(()=>i(!1))},[s]),d=(0,V.useCallback)(()=>{i(!0),o(null),window.gaiaInstall.revert().then(e=>{e||i(!1)}).catch(e=>{s(e),i(!1)})},[s]),f=(0,V.useCallback)(()=>{o(null),window.gaiaInstall.openLogFile().then(e=>{e.ok||o(e.message)}).catch(s)},[s]),{error:p}=t,m=t.phase===`failed`&&p,h=e(m?p.stage===P2?`engine.failed.agentTitle`:`engine.failed.title`:`engine.title`);return I(`div`,{className:`app`,children:I(`main`,{className:`engine`,children:R(`div`,{className:`engine-inner`,children:[I(`h1`,{className:`engine-title`,children:h}),m?I(H2,{error:p,busy:r,notice:a,onRetry:c,onCloseLockers:l,onContinue:u,onRevert:d,onOpenLog:f}):R(F.Fragment,{children:[I(`p`,{className:`engine-lede`,children:e(`engine.lede`)}),I(V2,{status:t}),a&&I(`p`,{className:`engine-error`,role:`alert`,children:I(`bdi`,{dir:`ltr`,children:a})})]})]})})})}function W2(){return!!window.gaiaInstall&&new URLSearchParams(window.location.search).get(`engine`)===`install`}async function G2(e){if(!e.isProduction||e.protocol!==`https:`&&e.protocol!==`http:`||!e.serviceWorker)return!1;try{return await e.serviceWorker.register(`./sw.js`,{scope:`./`}),!0}catch(e){return console.error(`[pwa] Service worker registration failed, so the UI is not cached for an installed app:`,e),!1}}Jl(),Cn();var K2=localStorage.getItem(`gaia-chat-theme`);Yn(Vn(K2===`light`||K2===`dark`?K2:`system`));var q2=z.getState();It(q2.palette,q2.customColors,q2.theme),vr(q2.locale),nn(),yt(),Cc.createRoot(document.getElementById(`root`)).render(I(V.StrictMode,{children:I(V1,{area:`app`,variant:`window`,children:W2()?I(U2,{}):I(N2,{})})})),window.addEventListener(`load`,()=>{G2({isProduction:!0,protocol:window.location.protocol,serviceWorker:`serviceWorker`in navigator?navigator.serviceWorker:void 0})});export{yP as $,Es as $t,XV as A,bi as An,ay as At,RP as B,ol as Bt,aK as C,Bi as Cn,jA as Ct,sH as D,Oi as Dn,YO as Dt,oH as E,Ai as En,kA as Et,sF as F,ci as Fn,Hu as Ft,tF as G,bc as Gt,jP as H,Vc as Ht,hP as I,Xr as In,Vu as It,OP as J,uc as Jt,CP as K,vc as Kt,ZP as L,Br as Ln,jl as Lt,ZV as M,gi as Mn,Nd as Mt,YV as N,mi as Nn,kd as Nt,eH as O,wi as On,uy as Ot,BF as P,fi as Pn,Xu as Pt,bP as Q,Ws as Qt,$P as R,Pr as Rn,cl as Rt,Pq as S,Wi as Sn,LA as St,gH as T,Mi as Tn,OA as Tt,XP as U,Pc as Ut,zP as V,il as Vt,xP as W,Sc as Wt,wP as X,oc as Xt,AP as Y,cc as Yt,JP as Z,Ks as Zt,Hq as _,oa as _n,DP as _t,J1 as a,Xo as an,kP as at,Mq as b,Ji as bn,HA as bt,j$ as c,wo as cn,LP as ct,h$ as d,oo as dn,NP as dt,ws as en,EP as et,wZ as f,Wa as fn,FP as ft,VY as g,Sa as gn,eF as gt,rX as h,wa as hn,qP as ht,o0 as i,ns as in,TP as it,JV as j,vi as jn,Jd as jt,nH as k,Si as kn,yy as kt,F$ as l,B as ln,MP as lt,mX as m,Ea as mn,QP as mt,s0 as n,fs as nn,vP as nt,L$ as o,Ko as on,YP as ot,yX as p,Ma as pn,GP as pt,SP as q,fc as qt,i0 as r,os as rn,_P as rt,I$ as s,Ao as sn,IP as st,V0 as t,bs as tn,BP as tt,P$ as u,uo as un,PP as ut,Fq as v,na as vn,VP as vt,XG as w,Ri as wn,IA as wt,Iq as x,Ki as xn,zA as xt,Nq as y,Qi as yn,QA as yt,WP as z,al as zt};