From d8a8e9be20967a6d245aa1fc49cea27c5c7490a2 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Fri, 17 Apr 2026 08:41:26 +0200 Subject: [PATCH] auto-git: [add] dist/assets/index-Bt01BsHn.js [change] dist/index.html [unlink] dist/assets/index-g7N0HjkK.js --- dist/assets/index-Bt01BsHn.js | 88 +++++++++++++++++++++++++++++++++++ dist/assets/index-g7N0HjkK.js | 88 ----------------------------------- dist/index.html | 2 +- 3 files changed, 89 insertions(+), 89 deletions(-) create mode 100644 dist/assets/index-Bt01BsHn.js delete mode 100644 dist/assets/index-g7N0HjkK.js diff --git a/dist/assets/index-Bt01BsHn.js b/dist/assets/index-Bt01BsHn.js new file mode 100644 index 0000000..e5dcd83 --- /dev/null +++ b/dist/assets/index-Bt01BsHn.js @@ -0,0 +1,88 @@ +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const o of l)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(l){const o={};return l.integrity&&(o.integrity=l.integrity),l.referrerPolicy&&(o.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?o.credentials="include":l.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(l){if(l.ep)return;l.ep=!0;const o=n(l);fetch(l.href,o)}})();function xm(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Hd={exports:{}},Ei={},Wd={exports:{}},G={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Vl=Symbol.for("react.element"),km=Symbol.for("react.portal"),Em=Symbol.for("react.fragment"),Cm=Symbol.for("react.strict_mode"),Nm=Symbol.for("react.profiler"),_m=Symbol.for("react.provider"),Rm=Symbol.for("react.context"),jm=Symbol.for("react.forward_ref"),Lm=Symbol.for("react.suspense"),Tm=Symbol.for("react.memo"),Pm=Symbol.for("react.lazy"),oc=Symbol.iterator;function Mm(e){return e===null||typeof e!="object"?null:(e=oc&&e[oc]||e["@@iterator"],typeof e=="function"?e:null)}var Vd={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Kd=Object.assign,Qd={};function Ur(e,t,n){this.props=e,this.context=t,this.refs=Qd,this.updater=n||Vd}Ur.prototype.isReactComponent={};Ur.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Ur.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Yd(){}Yd.prototype=Ur.prototype;function Aa(e,t,n){this.props=e,this.context=t,this.refs=Qd,this.updater=n||Vd}var $a=Aa.prototype=new Yd;$a.constructor=Aa;Kd($a,Ur.prototype);$a.isPureReactComponent=!0;var ic=Array.isArray,Gd=Object.prototype.hasOwnProperty,Oa={current:null},Jd={key:!0,ref:!0,__self:!0,__source:!0};function Xd(e,t,n){var r,l={},o=null,i=null;if(t!=null)for(r in t.ref!==void 0&&(i=t.ref),t.key!==void 0&&(o=""+t.key),t)Gd.call(t,r)&&!Jd.hasOwnProperty(r)&&(l[r]=t[r]);var s=arguments.length-2;if(s===1)l.children=n;else if(1>>1,se=I[Z];if(0>>1;Zl(lt,H))Oel(Pe,lt)?(I[Z]=Pe,I[Oe]=H,Z=Oe):(I[Z]=lt,I[Ge]=H,Z=Ge);else if(Oel(Pe,H))I[Z]=Pe,I[Oe]=H,Z=Oe;else break e}}return b}function l(I,b){var H=I.sortIndex-b.sortIndex;return H!==0?H:I.id-b.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var i=Date,s=i.now();e.unstable_now=function(){return i.now()-s}}var a=[],c=[],g=1,y=null,w=3,k=!1,E=!1,N=!1,R=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,h=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function m(I){for(var b=n(c);b!==null;){if(b.callback===null)r(c);else if(b.startTime<=I)r(c),b.sortIndex=b.expirationTime,t(a,b);else break;b=n(c)}}function C(I){if(N=!1,m(I),!E)if(n(a)!==null)E=!0,B(L);else{var b=n(c);b!==null&&q(C,b.startTime-I)}}function L(I,b){E=!1,N&&(N=!1,v(D),D=-1),k=!0;var H=w;try{for(m(b),y=n(a);y!==null&&(!(y.expirationTime>b)||I&&!ne());){var Z=y.callback;if(typeof Z=="function"){y.callback=null,w=y.priorityLevel;var se=Z(y.expirationTime<=b);b=e.unstable_now(),typeof se=="function"?y.callback=se:y===n(a)&&r(a),m(b)}else r(a);y=n(a)}if(y!==null)var rt=!0;else{var Ge=n(c);Ge!==null&&q(C,Ge.startTime-b),rt=!1}return rt}finally{y=null,w=H,k=!1}}var A=!1,$=null,D=-1,V=5,U=-1;function ne(){return!(e.unstable_now()-UI||125Z?(I.sortIndex=H,t(c,I),n(a)===null&&I===n(c)&&(N?(v(D),D=-1):N=!0,q(C,H-Z))):(I.sortIndex=se,t(a,I),E||k||(E=!0,B(L))),I},e.unstable_shouldYield=ne,e.unstable_wrapCallback=function(I){var b=w;return function(){var H=w;w=b;try{return I.apply(this,arguments)}finally{w=H}}}})(nf);tf.exports=nf;var Hm=tf.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Wm=f,ut=Hm;function j(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),$s=Object.prototype.hasOwnProperty,Vm=/^[: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]*$/,ac={},uc={};function Km(e){return $s.call(uc,e)?!0:$s.call(ac,e)?!1:Vm.test(e)?uc[e]=!0:(ac[e]=!0,!1)}function Qm(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Ym(e,t,n,r){if(t===null||typeof t>"u"||Qm(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Ye(e,t,n,r,l,o,i){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=i}var $e={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){$e[e]=new Ye(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];$e[t]=new Ye(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){$e[e]=new Ye(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){$e[e]=new Ye(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){$e[e]=new Ye(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){$e[e]=new Ye(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){$e[e]=new Ye(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){$e[e]=new Ye(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){$e[e]=new Ye(e,5,!1,e.toLowerCase(),null,!1,!1)});var Fa=/[\-:]([a-z])/g;function za(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Fa,za);$e[t]=new Ye(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Fa,za);$e[t]=new Ye(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Fa,za);$e[t]=new Ye(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){$e[e]=new Ye(e,1,!1,e.toLowerCase(),null,!1,!1)});$e.xlinkHref=new Ye("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){$e[e]=new Ye(e,1,!1,e.toLowerCase(),null,!0,!0)});function ba(e,t,n,r){var l=$e.hasOwnProperty(t)?$e[t]:null;(l!==null?l.type!==0:r||!(2s||l[i]!==o[s]){var a=` +`+l[i].replace(" at new "," at ");return e.displayName&&a.includes("")&&(a=a.replace("",e.displayName)),a}while(1<=i&&0<=s);break}}}finally{rs=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?pl(e):""}function Gm(e){switch(e.tag){case 5:return pl(e.type);case 16:return pl("Lazy");case 13:return pl("Suspense");case 19:return pl("SuspenseList");case 0:case 2:case 15:return e=ls(e.type,!1),e;case 11:return e=ls(e.type.render,!1),e;case 1:return e=ls(e.type,!0),e;default:return""}}function zs(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case vr:return"Fragment";case gr:return"Portal";case Os:return"Profiler";case Ua:return"StrictMode";case Ds:return"Suspense";case Fs:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case of:return(e.displayName||"Context")+".Consumer";case lf:return(e._context.displayName||"Context")+".Provider";case Ba:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ha:return t=e.displayName||null,t!==null?t:zs(e.type)||"Memo";case fn:t=e._payload,e=e._init;try{return zs(e(t))}catch{}}return null}function Jm(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return zs(t);case 8:return t===Ua?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function _n(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function af(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Xm(e){var t=af(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var l=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(i){r=""+i,o.call(this,i)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(i){r=""+i},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function yo(e){e._valueTracker||(e._valueTracker=Xm(e))}function uf(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=af(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Xo(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function bs(e,t){var n=t.checked;return ve({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function dc(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=_n(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function cf(e,t){t=t.checked,t!=null&&ba(e,"checked",t,!1)}function Us(e,t){cf(e,t);var n=_n(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Bs(e,t.type,n):t.hasOwnProperty("defaultValue")&&Bs(e,t.type,_n(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function fc(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Bs(e,t,n){(t!=="number"||Xo(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var hl=Array.isArray;function jr(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=wo.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Rl(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var vl={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},qm=["Webkit","ms","Moz","O"];Object.keys(vl).forEach(function(e){qm.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),vl[t]=vl[e]})});function hf(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||vl.hasOwnProperty(e)&&vl[e]?(""+t).trim():t+"px"}function mf(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=hf(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var Zm=ve({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Vs(e,t){if(t){if(Zm[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(j(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(j(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(j(61))}if(t.style!=null&&typeof t.style!="object")throw Error(j(62))}}function Ks(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";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 Qs=null;function Wa(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ys=null,Lr=null,Tr=null;function mc(e){if(e=Yl(e)){if(typeof Ys!="function")throw Error(j(280));var t=e.stateNode;t&&(t=ji(t),Ys(e.stateNode,e.type,t))}}function gf(e){Lr?Tr?Tr.push(e):Tr=[e]:Lr=e}function vf(){if(Lr){var e=Lr,t=Tr;if(Tr=Lr=null,mc(e),t)for(e=0;e>>=0,e===0?32:31-(cg(e)/dg|0)|0}var So=64,xo=4194304;function ml(e){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: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 e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function ti(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,o=e.pingedLanes,i=n&268435455;if(i!==0){var s=i&~l;s!==0?r=ml(s):(o&=i,o!==0&&(r=ml(o)))}else i=n&~l,i!==0?r=ml(i):o!==0&&(r=ml(o));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,o=t&-t,l>=o||l===16&&(o&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Kl(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-jt(t),e[t]=n}function mg(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=wl),Cc=" ",Nc=!1;function Df(e,t){switch(e){case"keyup":return Hg.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ff(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var yr=!1;function Vg(e,t){switch(e){case"compositionend":return Ff(t);case"keypress":return t.which!==32?null:(Nc=!0,Cc);case"textInput":return e=t.data,e===Cc&&Nc?null:e;default:return null}}function Kg(e,t){if(yr)return e==="compositionend"||!qa&&Df(e,t)?(e=$f(),zo=Ga=gn=null,yr=!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)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Lc(n)}}function Bf(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Bf(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Hf(){for(var e=window,t=Xo();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Xo(e.document)}return t}function Za(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")}function tv(e){var t=Hf(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Bf(n.ownerDocument.documentElement,n)){if(r!==null&&Za(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=n.textContent.length,o=Math.min(r.start,l);r=r.end===void 0?o:Math.min(r.end,l),!e.extend&&o>r&&(l=r,r=o,o=l),l=Tc(n,o);var i=Tc(n,r);l&&i&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==i.node||e.focusOffset!==i.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(i.node,i.offset)):(t.setEnd(i.node,i.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,wr=null,ea=null,xl=null,ta=!1;function Pc(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ta||wr==null||wr!==Xo(r)||(r=wr,"selectionStart"in r&&Za(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}),xl&&Il(xl,r)||(xl=r,r=li(ea,"onSelect"),0kr||(e.current=sa[kr],sa[kr]=null,kr--)}function ie(e,t){kr++,sa[kr]=e.current,e.current=t}var Rn={},Ue=Ln(Rn),et=Ln(!1),Kn=Rn;function $r(e,t){var n=e.type.contextTypes;if(!n)return Rn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},o;for(o in n)l[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function tt(e){return e=e.childContextTypes,e!=null}function ii(){de(et),de(Ue)}function Fc(e,t,n){if(Ue.current!==Rn)throw Error(j(168));ie(Ue,t),ie(et,n)}function qf(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(j(108,Jm(e)||"Unknown",l));return ve({},n,r)}function si(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Rn,Kn=Ue.current,ie(Ue,e),ie(et,et.current),!0}function zc(e,t,n){var r=e.stateNode;if(!r)throw Error(j(169));n?(e=qf(e,t,Kn),r.__reactInternalMemoizedMergedChildContext=e,de(et),de(Ue),ie(Ue,e)):de(et),ie(et,n)}var Qt=null,Li=!1,ys=!1;function Zf(e){Qt===null?Qt=[e]:Qt.push(e)}function pv(e){Li=!0,Zf(e)}function Tn(){if(!ys&&Qt!==null){ys=!0;var e=0,t=le;try{var n=Qt;for(le=1;e>=i,l-=i,Yt=1<<32-jt(t)+l|n<D?(V=$,$=null):V=$.sibling;var U=w(v,$,m[D],C);if(U===null){$===null&&($=V);break}e&&$&&U.alternate===null&&t(v,$),h=o(U,h,D),A===null?L=U:A.sibling=U,A=U,$=V}if(D===m.length)return n(v,$),pe&&zn(v,D),L;if($===null){for(;DD?(V=$,$=null):V=$.sibling;var ne=w(v,$,U.value,C);if(ne===null){$===null&&($=V);break}e&&$&&ne.alternate===null&&t(v,$),h=o(ne,h,D),A===null?L=ne:A.sibling=ne,A=ne,$=V}if(U.done)return n(v,$),pe&&zn(v,D),L;if($===null){for(;!U.done;D++,U=m.next())U=y(v,U.value,C),U!==null&&(h=o(U,h,D),A===null?L=U:A.sibling=U,A=U);return pe&&zn(v,D),L}for($=r(v,$);!U.done;D++,U=m.next())U=k($,v,D,U.value,C),U!==null&&(e&&U.alternate!==null&&$.delete(U.key===null?D:U.key),h=o(U,h,D),A===null?L=U:A.sibling=U,A=U);return e&&$.forEach(function(Ne){return t(v,Ne)}),pe&&zn(v,D),L}function R(v,h,m,C){if(typeof m=="object"&&m!==null&&m.type===vr&&m.key===null&&(m=m.props.children),typeof m=="object"&&m!==null){switch(m.$$typeof){case vo:e:{for(var L=m.key,A=h;A!==null;){if(A.key===L){if(L=m.type,L===vr){if(A.tag===7){n(v,A.sibling),h=l(A,m.props.children),h.return=v,v=h;break e}}else if(A.elementType===L||typeof L=="object"&&L!==null&&L.$$typeof===fn&&Bc(L)===A.type){n(v,A.sibling),h=l(A,m.props),h.ref=al(v,A,m),h.return=v,v=h;break e}n(v,A);break}else t(v,A);A=A.sibling}m.type===vr?(h=Vn(m.props.children,v.mode,C,m.key),h.return=v,v=h):(C=Qo(m.type,m.key,m.props,null,v.mode,C),C.ref=al(v,h,m),C.return=v,v=C)}return i(v);case gr:e:{for(A=m.key;h!==null;){if(h.key===A)if(h.tag===4&&h.stateNode.containerInfo===m.containerInfo&&h.stateNode.implementation===m.implementation){n(v,h.sibling),h=l(h,m.children||[]),h.return=v,v=h;break e}else{n(v,h);break}else t(v,h);h=h.sibling}h=_s(m,v.mode,C),h.return=v,v=h}return i(v);case fn:return A=m._init,R(v,h,A(m._payload),C)}if(hl(m))return E(v,h,m,C);if(rl(m))return N(v,h,m,C);jo(v,m)}return typeof m=="string"&&m!==""||typeof m=="number"?(m=""+m,h!==null&&h.tag===6?(n(v,h.sibling),h=l(h,m),h.return=v,v=h):(n(v,h),h=Ns(m,v.mode,C),h.return=v,v=h),i(v)):n(v,h)}return R}var Dr=rp(!0),lp=rp(!1),ci=Ln(null),di=null,Nr=null,ru=null;function lu(){ru=Nr=di=null}function ou(e){var t=ci.current;de(ci),e._currentValue=t}function ca(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Mr(e,t){di=e,ru=Nr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Ze=!0),e.firstContext=null)}function St(e){var t=e._currentValue;if(ru!==e)if(e={context:e,memoizedValue:t,next:null},Nr===null){if(di===null)throw Error(j(308));Nr=e,di.dependencies={lanes:0,firstContext:e}}else Nr=Nr.next=e;return t}var Bn=null;function iu(e){Bn===null?Bn=[e]:Bn.push(e)}function op(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,iu(t)):(n.next=l.next,l.next=n),t.interleaved=n,en(e,r)}function en(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var pn=!1;function su(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ip(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Jt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function kn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,X&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,en(e,n)}return l=r.interleaved,l===null?(t.next=t,iu(r)):(t.next=l.next,l.next=t),r.interleaved=t,en(e,n)}function Uo(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ka(e,n)}}function Hc(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var i={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?l=o=i:o=o.next=i,n=n.next}while(n!==null);o===null?l=o=t:o=o.next=t}else l=o=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:o,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function fi(e,t,n,r){var l=e.updateQueue;pn=!1;var o=l.firstBaseUpdate,i=l.lastBaseUpdate,s=l.shared.pending;if(s!==null){l.shared.pending=null;var a=s,c=a.next;a.next=null,i===null?o=c:i.next=c,i=a;var g=e.alternate;g!==null&&(g=g.updateQueue,s=g.lastBaseUpdate,s!==i&&(s===null?g.firstBaseUpdate=c:s.next=c,g.lastBaseUpdate=a))}if(o!==null){var y=l.baseState;i=0,g=c=a=null,s=o;do{var w=s.lane,k=s.eventTime;if((r&w)===w){g!==null&&(g=g.next={eventTime:k,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});e:{var E=e,N=s;switch(w=t,k=n,N.tag){case 1:if(E=N.payload,typeof E=="function"){y=E.call(k,y,w);break e}y=E;break e;case 3:E.flags=E.flags&-65537|128;case 0:if(E=N.payload,w=typeof E=="function"?E.call(k,y,w):E,w==null)break e;y=ve({},y,w);break e;case 2:pn=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,w=l.effects,w===null?l.effects=[s]:w.push(s))}else k={eventTime:k,lane:w,tag:s.tag,payload:s.payload,callback:s.callback,next:null},g===null?(c=g=k,a=y):g=g.next=k,i|=w;if(s=s.next,s===null){if(s=l.shared.pending,s===null)break;w=s,s=w.next,w.next=null,l.lastBaseUpdate=w,l.shared.pending=null}}while(!0);if(g===null&&(a=y),l.baseState=a,l.firstBaseUpdate=c,l.lastBaseUpdate=g,t=l.shared.interleaved,t!==null){l=t;do i|=l.lane,l=l.next;while(l!==t)}else o===null&&(l.shared.lanes=0);Gn|=i,e.lanes=i,e.memoizedState=y}}function Wc(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Ss.transition;Ss.transition={};try{e(!1),t()}finally{le=n,Ss.transition=r}}function Ep(){return xt().memoizedState}function vv(e,t,n){var r=Cn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Cp(e))Np(t,n);else if(n=op(e,t,n,r),n!==null){var l=Ke();Lt(n,e,r,l),_p(n,t,r)}}function yv(e,t,n){var r=Cn(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Cp(e))Np(t,l);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var i=t.lastRenderedState,s=o(i,n);if(l.hasEagerState=!0,l.eagerState=s,Tt(s,i)){var a=t.interleaved;a===null?(l.next=l,iu(t)):(l.next=a.next,a.next=l),t.interleaved=l;return}}catch{}finally{}n=op(e,t,l,r),n!==null&&(l=Ke(),Lt(n,e,r,l),_p(n,t,r))}}function Cp(e){var t=e.alternate;return e===me||t!==null&&t===me}function Np(e,t){kl=hi=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function _p(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ka(e,n)}}var mi={readContext:St,useCallback:Fe,useContext:Fe,useEffect:Fe,useImperativeHandle:Fe,useInsertionEffect:Fe,useLayoutEffect:Fe,useMemo:Fe,useReducer:Fe,useRef:Fe,useState:Fe,useDebugValue:Fe,useDeferredValue:Fe,useTransition:Fe,useMutableSource:Fe,useSyncExternalStore:Fe,useId:Fe,unstable_isNewReconciler:!1},wv={readContext:St,useCallback:function(e,t){return Dt().memoizedState=[e,t===void 0?null:t],e},useContext:St,useEffect:Kc,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Ho(4194308,4,yp.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ho(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ho(4,2,e,t)},useMemo:function(e,t){var n=Dt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Dt();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=vv.bind(null,me,e),[r.memoizedState,e]},useRef:function(e){var t=Dt();return e={current:e},t.memoizedState=e},useState:Vc,useDebugValue:mu,useDeferredValue:function(e){return Dt().memoizedState=e},useTransition:function(){var e=Vc(!1),t=e[0];return e=gv.bind(null,e[1]),Dt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=me,l=Dt();if(pe){if(n===void 0)throw Error(j(407));n=n()}else{if(n=t(),Te===null)throw Error(j(349));Yn&30||cp(r,t,n)}l.memoizedState=n;var o={value:n,getSnapshot:t};return l.queue=o,Kc(fp.bind(null,r,o,e),[e]),r.flags|=2048,Ul(9,dp.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=Dt(),t=Te.identifierPrefix;if(pe){var n=Gt,r=Yt;n=(r&~(1<<32-jt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=zl++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=i.createElement(n,{is:r.is}):(e=i.createElement(n),n==="select"&&(i=e,r.multiple?i.multiple=!0:r.size&&(i.size=r.size))):e=i.createElementNS(e,n),e[Ft]=t,e[Ol]=r,Op(e,t,!1,!1),t.stateNode=e;e:{switch(i=Ks(n,r),n){case"dialog":ce("cancel",e),ce("close",e),l=r;break;case"iframe":case"object":case"embed":ce("load",e),l=r;break;case"video":case"audio":for(l=0;lbr&&(t.flags|=128,r=!0,ul(o,!1),t.lanes=4194304)}else{if(!r)if(e=pi(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),ul(o,!0),o.tail===null&&o.tailMode==="hidden"&&!i.alternate&&!pe)return ze(t),null}else 2*xe()-o.renderingStartTime>br&&n!==1073741824&&(t.flags|=128,r=!0,ul(o,!1),t.lanes=4194304);o.isBackwards?(i.sibling=t.child,t.child=i):(n=o.last,n!==null?n.sibling=i:t.child=i,o.last=i)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=xe(),t.sibling=null,n=he.current,ie(he,r?n&1|2:n&1),t):(ze(t),null);case 22:case 23:return xu(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?it&1073741824&&(ze(t),t.subtreeFlags&6&&(t.flags|=8192)):ze(t),null;case 24:return null;case 25:return null}throw Error(j(156,t.tag))}function Rv(e,t){switch(tu(t),t.tag){case 1:return tt(t.type)&&ii(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Fr(),de(et),de(Ue),cu(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return uu(t),null;case 13:if(de(he),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(j(340));Or()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return de(he),null;case 4:return Fr(),null;case 10:return ou(t.type._context),null;case 22:case 23:return xu(),null;case 24:return null;default:return null}}var To=!1,be=!1,jv=typeof WeakSet=="function"?WeakSet:Set,F=null;function _r(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ye(e,t,r)}else n.current=null}function wa(e,t,n){try{n()}catch(r){ye(e,t,r)}}var rd=!1;function Lv(e,t){if(na=ni,e=Hf(),Za(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var i=0,s=-1,a=-1,c=0,g=0,y=e,w=null;t:for(;;){for(var k;y!==n||l!==0&&y.nodeType!==3||(s=i+l),y!==o||r!==0&&y.nodeType!==3||(a=i+r),y.nodeType===3&&(i+=y.nodeValue.length),(k=y.firstChild)!==null;)w=y,y=k;for(;;){if(y===e)break t;if(w===n&&++c===l&&(s=i),w===o&&++g===r&&(a=i),(k=y.nextSibling)!==null)break;y=w,w=y.parentNode}y=k}n=s===-1||a===-1?null:{start:s,end:a}}else n=null}n=n||{start:0,end:0}}else n=null;for(ra={focusedElem:e,selectionRange:n},ni=!1,F=t;F!==null;)if(t=F,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,F=e;else for(;F!==null;){t=F;try{var E=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(E!==null){var N=E.memoizedProps,R=E.memoizedState,v=t.stateNode,h=v.getSnapshotBeforeUpdate(t.elementType===t.type?N:Nt(t.type,N),R);v.__reactInternalSnapshotBeforeUpdate=h}break;case 3:var m=t.stateNode.containerInfo;m.nodeType===1?m.textContent="":m.nodeType===9&&m.documentElement&&m.removeChild(m.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(j(163))}}catch(C){ye(t,t.return,C)}if(e=t.sibling,e!==null){e.return=t.return,F=e;break}F=t.return}return E=rd,rd=!1,E}function El(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var o=l.destroy;l.destroy=void 0,o!==void 0&&wa(t,n,o)}l=l.next}while(l!==r)}}function Mi(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Sa(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function zp(e){var t=e.alternate;t!==null&&(e.alternate=null,zp(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ft],delete t[Ol],delete t[ia],delete t[dv],delete t[fv])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function bp(e){return e.tag===5||e.tag===3||e.tag===4}function ld(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||bp(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.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function xa(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=oi));else if(r!==4&&(e=e.child,e!==null))for(xa(e,t,n),e=e.sibling;e!==null;)xa(e,t,n),e=e.sibling}function ka(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(ka(e,t,n),e=e.sibling;e!==null;)ka(e,t,n),e=e.sibling}var Ie=null,_t=!1;function dn(e,t,n){for(n=n.child;n!==null;)Up(e,t,n),n=n.sibling}function Up(e,t,n){if(zt&&typeof zt.onCommitFiberUnmount=="function")try{zt.onCommitFiberUnmount(Ci,n)}catch{}switch(n.tag){case 5:be||_r(n,t);case 6:var r=Ie,l=_t;Ie=null,dn(e,t,n),Ie=r,_t=l,Ie!==null&&(_t?(e=Ie,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ie.removeChild(n.stateNode));break;case 18:Ie!==null&&(_t?(e=Ie,n=n.stateNode,e.nodeType===8?vs(e.parentNode,n):e.nodeType===1&&vs(e,n),Pl(e)):vs(Ie,n.stateNode));break;case 4:r=Ie,l=_t,Ie=n.stateNode.containerInfo,_t=!0,dn(e,t,n),Ie=r,_t=l;break;case 0:case 11:case 14:case 15:if(!be&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var o=l,i=o.destroy;o=o.tag,i!==void 0&&(o&2||o&4)&&wa(n,t,i),l=l.next}while(l!==r)}dn(e,t,n);break;case 1:if(!be&&(_r(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(s){ye(n,t,s)}dn(e,t,n);break;case 21:dn(e,t,n);break;case 22:n.mode&1?(be=(r=be)||n.memoizedState!==null,dn(e,t,n),be=r):dn(e,t,n);break;default:dn(e,t,n)}}function od(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new jv),t.forEach(function(r){var l=Fv.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Ct(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=i),r&=~o}if(r=l,r=xe()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Pv(r/1960))-r,10e?16:e,vn===null)var r=!1;else{if(e=vn,vn=null,yi=0,X&6)throw Error(j(331));var l=X;for(X|=4,F=e.current;F!==null;){var o=F,i=o.child;if(F.flags&16){var s=o.deletions;if(s!==null){for(var a=0;axe()-wu?Wn(e,0):yu|=n),nt(e,t)}function Gp(e,t){t===0&&(e.mode&1?(t=xo,xo<<=1,!(xo&130023424)&&(xo=4194304)):t=1);var n=Ke();e=en(e,t),e!==null&&(Kl(e,t,n),nt(e,n))}function Dv(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Gp(e,n)}function Fv(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(j(314))}r!==null&&r.delete(t),Gp(e,n)}var Jp;Jp=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||et.current)Ze=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Ze=!1,Nv(e,t,n);Ze=!!(e.flags&131072)}else Ze=!1,pe&&t.flags&1048576&&ep(t,ui,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Wo(e,t),e=t.pendingProps;var l=$r(t,Ue.current);Mr(t,n),l=fu(null,t,r,e,l,n);var o=pu();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,tt(r)?(o=!0,si(t)):o=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,su(t),l.updater=Pi,t.stateNode=l,l._reactInternals=t,fa(t,r,e,n),t=ma(null,t,r,!0,o,n)):(t.tag=0,pe&&o&&eu(t),Ve(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Wo(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=bv(r),e=Nt(r,e),l){case 0:t=ha(null,t,r,e,n);break e;case 1:t=ed(null,t,r,e,n);break e;case 11:t=qc(null,t,r,e,n);break e;case 14:t=Zc(null,t,r,Nt(r.type,e),n);break e}throw Error(j(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Nt(r,l),ha(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Nt(r,l),ed(e,t,r,l,n);case 3:e:{if(Ip(t),e===null)throw Error(j(387));r=t.pendingProps,o=t.memoizedState,l=o.element,ip(e,t),fi(t,r,null,n);var i=t.memoizedState;if(r=i.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){l=zr(Error(j(423)),t),t=td(e,t,r,n,l);break e}else if(r!==l){l=zr(Error(j(424)),t),t=td(e,t,r,n,l);break e}else for(st=xn(t.stateNode.containerInfo.firstChild),at=t,pe=!0,Rt=null,n=lp(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Or(),r===l){t=tn(e,t,n);break e}Ve(e,t,r,n)}t=t.child}return t;case 5:return sp(t),e===null&&ua(t),r=t.type,l=t.pendingProps,o=e!==null?e.memoizedProps:null,i=l.children,la(r,l)?i=null:o!==null&&la(r,o)&&(t.flags|=32),Mp(e,t),Ve(e,t,i,n),t.child;case 6:return e===null&&ua(t),null;case 13:return Ap(e,t,n);case 4:return au(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Dr(t,null,r,n):Ve(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Nt(r,l),qc(e,t,r,l,n);case 7:return Ve(e,t,t.pendingProps,n),t.child;case 8:return Ve(e,t,t.pendingProps.children,n),t.child;case 12:return Ve(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,o=t.memoizedProps,i=l.value,ie(ci,r._currentValue),r._currentValue=i,o!==null)if(Tt(o.value,i)){if(o.children===l.children&&!et.current){t=tn(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var s=o.dependencies;if(s!==null){i=o.child;for(var a=s.firstContext;a!==null;){if(a.context===r){if(o.tag===1){a=Jt(-1,n&-n),a.tag=2;var c=o.updateQueue;if(c!==null){c=c.shared;var g=c.pending;g===null?a.next=a:(a.next=g.next,g.next=a),c.pending=a}}o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),ca(o.return,n,t),s.lanes|=n;break}a=a.next}}else if(o.tag===10)i=o.type===t.type?null:o.child;else if(o.tag===18){if(i=o.return,i===null)throw Error(j(341));i.lanes|=n,s=i.alternate,s!==null&&(s.lanes|=n),ca(i,n,t),i=o.sibling}else i=o.child;if(i!==null)i.return=o;else for(i=o;i!==null;){if(i===t){i=null;break}if(o=i.sibling,o!==null){o.return=i.return,i=o;break}i=i.return}o=i}Ve(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,Mr(t,n),l=St(l),r=r(l),t.flags|=1,Ve(e,t,r,n),t.child;case 14:return r=t.type,l=Nt(r,t.pendingProps),l=Nt(r.type,l),Zc(e,t,r,l,n);case 15:return Tp(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Nt(r,l),Wo(e,t),t.tag=1,tt(r)?(e=!0,si(t)):e=!1,Mr(t,n),Rp(t,r,l),fa(t,r,l,n),ma(null,t,r,!0,e,n);case 19:return $p(e,t,n);case 22:return Pp(e,t,n)}throw Error(j(156,t.tag))};function Xp(e,t){return Cf(e,t)}function zv(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.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 yt(e,t,n,r){return new zv(e,t,n,r)}function Eu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function bv(e){if(typeof e=="function")return Eu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Ba)return 11;if(e===Ha)return 14}return 2}function Nn(e,t){var n=e.alternate;return n===null?(n=yt(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&14680064,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}function Qo(e,t,n,r,l,o){var i=2;if(r=e,typeof e=="function")Eu(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case vr:return Vn(n.children,l,o,t);case Ua:i=8,l|=8;break;case Os:return e=yt(12,n,t,l|2),e.elementType=Os,e.lanes=o,e;case Ds:return e=yt(13,n,t,l),e.elementType=Ds,e.lanes=o,e;case Fs:return e=yt(19,n,t,l),e.elementType=Fs,e.lanes=o,e;case sf:return Ai(n,l,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case lf:i=10;break e;case of:i=9;break e;case Ba:i=11;break e;case Ha:i=14;break e;case fn:i=16,r=null;break e}throw Error(j(130,e==null?e:typeof e,""))}return t=yt(i,n,t,l),t.elementType=e,t.type=r,t.lanes=o,t}function Vn(e,t,n,r){return e=yt(7,e,r,t),e.lanes=n,e}function Ai(e,t,n,r){return e=yt(22,e,r,t),e.elementType=sf,e.lanes=n,e.stateNode={isHidden:!1},e}function Ns(e,t,n){return e=yt(6,e,null,t),e.lanes=n,e}function _s(e,t,n){return t=yt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Uv(e,t,n,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=is(0),this.expirationTimes=is(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=is(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function Cu(e,t,n,r,l,o,i,s,a){return e=new Uv(e,t,n,s,a),t===1?(t=1,o===!0&&(t|=8)):t=0,o=yt(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},su(o),e}function Bv(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(th)}catch(e){console.error(e)}}th(),ef.exports=ct;var nh=ef.exports,rh,pd=nh;rh=pd.createRoot,pd.hydrateRoot;/** + * react-router v7.8.2 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */var hd="popstate";function Qv(e={}){function t(l,o){let{pathname:i="/",search:s="",hash:a=""}=Zn(l.location.hash.substring(1));return!i.startsWith("/")&&!i.startsWith(".")&&(i="/"+i),Ra("",{pathname:i,search:s,hash:a},o.state&&o.state.usr||null,o.state&&o.state.key||"default")}function n(l,o){let i=l.document.querySelector("base"),s="";if(i&&i.getAttribute("href")){let a=l.location.href,c=a.indexOf("#");s=c===-1?a:a.slice(0,c)}return s+"#"+(typeof o=="string"?o:Hl(o))}function r(l,o){Pt(l.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(o)})`)}return Gv(t,n,r,e)}function ge(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Pt(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Yv(){return Math.random().toString(36).substring(2,10)}function md(e,t){return{usr:e.state,key:e.key,idx:t}}function Ra(e,t,n=null,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Zn(t):t,state:n,key:t&&t.key||r||Yv()}}function Hl({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function Zn(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function Gv(e,t,n,r={}){let{window:l=document.defaultView,v5Compat:o=!1}=r,i=l.history,s="POP",a=null,c=g();c==null&&(c=0,i.replaceState({...i.state,idx:c},""));function g(){return(i.state||{idx:null}).idx}function y(){s="POP";let R=g(),v=R==null?null:R-c;c=R,a&&a({action:s,location:N.location,delta:v})}function w(R,v){s="PUSH";let h=Ra(N.location,R,v);n&&n(h,R),c=g()+1;let m=md(h,c),C=N.createHref(h);try{i.pushState(m,"",C)}catch(L){if(L instanceof DOMException&&L.name==="DataCloneError")throw L;l.location.assign(C)}o&&a&&a({action:s,location:N.location,delta:1})}function k(R,v){s="REPLACE";let h=Ra(N.location,R,v);n&&n(h,R),c=g();let m=md(h,c),C=N.createHref(h);i.replaceState(m,"",C),o&&a&&a({action:s,location:N.location,delta:0})}function E(R){return Jv(R)}let N={get action(){return s},get location(){return e(l,i)},listen(R){if(a)throw new Error("A history only accepts one active listener");return l.addEventListener(hd,y),a=R,()=>{l.removeEventListener(hd,y),a=null}},createHref(R){return t(l,R)},createURL:E,encodeLocation(R){let v=E(R);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:w,replace:k,go(R){return i.go(R)}};return N}function Jv(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),ge(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:Hl(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function lh(e,t,n="/"){return Xv(e,t,n,!1)}function Xv(e,t,n,r){let l=typeof t=="string"?Zn(t):t,o=nn(l.pathname||"/",n);if(o==null)return null;let i=oh(e);qv(i);let s=null;for(let a=0;s==null&&a{let g={relativePath:c===void 0?i.path||"":c,caseSensitive:i.caseSensitive===!0,childrenIndex:s,route:i};if(g.relativePath.startsWith("/")){if(!g.relativePath.startsWith(r)&&a)return;ge(g.relativePath.startsWith(r),`Absolute route path "${g.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),g.relativePath=g.relativePath.slice(r.length)}let y=Xt([r,g.relativePath]),w=n.concat(g);i.children&&i.children.length>0&&(ge(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${y}".`),oh(i.children,t,w,y,a)),!(i.path==null&&!i.index)&&t.push({path:y,score:oy(y,i.index),routesMeta:w})};return e.forEach((i,s)=>{var a;if(i.path===""||!((a=i.path)!=null&&a.includes("?")))o(i,s);else for(let c of ih(i.path))o(i,s,!0,c)}),t}function ih(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,l=n.endsWith("?"),o=n.replace(/\?$/,"");if(r.length===0)return l?[o,""]:[o];let i=ih(r.join("/")),s=[];return s.push(...i.map(a=>a===""?o:[o,a].join("/"))),l&&s.push(...i),s.map(a=>e.startsWith("/")&&a===""?"/":a)}function qv(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:iy(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Zv=/^:[\w-]+$/,ey=3,ty=2,ny=1,ry=10,ly=-2,gd=e=>e==="*";function oy(e,t){let n=e.split("/"),r=n.length;return n.some(gd)&&(r+=ly),t&&(r+=ty),n.filter(l=>!gd(l)).reduce((l,o)=>l+(Zv.test(o)?ey:o===""?ny:ry),r)}function iy(e,t){return e.length===t.length&&e.slice(0,-1).every((r,l)=>r===t[l])?e[e.length-1]-t[t.length-1]:0}function sy(e,t,n=!1){let{routesMeta:r}=e,l={},o="/",i=[];for(let s=0;s{if(g==="*"){let E=s[w]||"";i=o.slice(0,o.length-E.length).replace(/(.)\/+$/,"$1")}const k=s[w];return y&&!k?c[g]=void 0:c[g]=(k||"").replace(/%2F/g,"/"),c},{}),pathname:o,pathnameBase:i,pattern:e}}function ay(e,t=!1,n=!0){Pt(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],l="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,s,a)=>(r.push({paramName:s,isOptional:a!=null}),a?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),l+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?l+="\\/*$":e!==""&&e!=="/"&&(l+="(?:(?=\\/|$))"),[new RegExp(l,t?void 0:"i"),r]}function uy(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Pt(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function nn(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}function cy(e,t="/"){let{pathname:n,search:r="",hash:l=""}=typeof e=="string"?Zn(e):e;return{pathname:n?n.startsWith("/")?n:dy(n,t):t,search:hy(r),hash:my(l)}}function dy(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(l=>{l===".."?n.length>1&&n.pop():l!=="."&&n.push(l)}),n.length>1?n.join("/"):"/"}function Rs(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in and the router will parse it for you.`}function fy(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function sh(e){let t=fy(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function ah(e,t,n,r=!1){let l;typeof e=="string"?l=Zn(e):(l={...e},ge(!l.pathname||!l.pathname.includes("?"),Rs("?","pathname","search",l)),ge(!l.pathname||!l.pathname.includes("#"),Rs("#","pathname","hash",l)),ge(!l.search||!l.search.includes("#"),Rs("#","search","hash",l)));let o=e===""||l.pathname==="",i=o?"/":l.pathname,s;if(i==null)s=n;else{let y=t.length-1;if(!r&&i.startsWith("..")){let w=i.split("/");for(;w[0]==="..";)w.shift(),y-=1;l.pathname=w.join("/")}s=y>=0?t[y]:"/"}let a=cy(l,s),c=i&&i!=="/"&&i.endsWith("/"),g=(o||i===".")&&n.endsWith("/");return!a.pathname.endsWith("/")&&(c||g)&&(a.pathname+="/"),a}var Xt=e=>e.join("/").replace(/\/\/+/g,"/"),py=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),hy=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,my=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function gy(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}var uh=["POST","PUT","PATCH","DELETE"];new Set(uh);var vy=["GET",...uh];new Set(vy);var Wr=f.createContext(null);Wr.displayName="DataRouter";var zi=f.createContext(null);zi.displayName="DataRouterState";f.createContext(!1);var ch=f.createContext({isTransitioning:!1});ch.displayName="ViewTransition";var yy=f.createContext(new Map);yy.displayName="Fetchers";var wy=f.createContext(null);wy.displayName="Await";var Ut=f.createContext(null);Ut.displayName="Navigation";var Jl=f.createContext(null);Jl.displayName="Location";var ln=f.createContext({outlet:null,matches:[],isDataRoute:!1});ln.displayName="Route";var ju=f.createContext(null);ju.displayName="RouteError";function Sy(e,{relative:t}={}){ge(Xl(),"useHref() may be used only in the context of a component.");let{basename:n,navigator:r}=f.useContext(Ut),{hash:l,pathname:o,search:i}=ql(e,{relative:t}),s=o;return n!=="/"&&(s=o==="/"?n:Xt([n,o])),r.createHref({pathname:s,search:i,hash:l})}function Xl(){return f.useContext(Jl)!=null}function er(){return ge(Xl(),"useLocation() may be used only in the context of a component."),f.useContext(Jl).location}var dh="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function fh(e){f.useContext(Ut).static||f.useLayoutEffect(e)}function xy(){let{isDataRoute:e}=f.useContext(ln);return e?Ay():ky()}function ky(){ge(Xl(),"useNavigate() may be used only in the context of a component.");let e=f.useContext(Wr),{basename:t,navigator:n}=f.useContext(Ut),{matches:r}=f.useContext(ln),{pathname:l}=er(),o=JSON.stringify(sh(r)),i=f.useRef(!1);return fh(()=>{i.current=!0}),f.useCallback((a,c={})=>{if(Pt(i.current,dh),!i.current)return;if(typeof a=="number"){n.go(a);return}let g=ah(a,JSON.parse(o),l,c.relative==="path");e==null&&t!=="/"&&(g.pathname=g.pathname==="/"?t:Xt([t,g.pathname])),(c.replace?n.replace:n.push)(g,c.state,c)},[t,n,o,l,e])}f.createContext(null);function ql(e,{relative:t}={}){let{matches:n}=f.useContext(ln),{pathname:r}=er(),l=JSON.stringify(sh(n));return f.useMemo(()=>ah(e,JSON.parse(l),r,t==="path"),[e,l,r,t])}function Ey(e,t){return ph(e,t)}function ph(e,t,n,r,l){var h;ge(Xl(),"useRoutes() may be used only in the context of a component.");let{navigator:o}=f.useContext(Ut),{matches:i}=f.useContext(ln),s=i[i.length-1],a=s?s.params:{},c=s?s.pathname:"/",g=s?s.pathnameBase:"/",y=s&&s.route;{let m=y&&y.path||"";hh(c,!y||m.endsWith("*")||m.endsWith("*?"),`You rendered descendant (or called \`useRoutes()\`) at "${c}" (under ) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render. + +Please change the parent to .`)}let w=er(),k;if(t){let m=typeof t=="string"?Zn(t):t;ge(g==="/"||((h=m.pathname)==null?void 0:h.startsWith(g)),`When overriding the location using \`\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${g}" but pathname "${m.pathname}" was given in the \`location\` prop.`),k=m}else k=w;let E=k.pathname||"/",N=E;if(g!=="/"){let m=g.replace(/^\//,"").split("/");N="/"+E.replace(/^\//,"").split("/").slice(m.length).join("/")}let R=lh(e,{pathname:N});Pt(y||R!=null,`No routes matched location "${k.pathname}${k.search}${k.hash}" `),Pt(R==null||R[R.length-1].route.element!==void 0||R[R.length-1].route.Component!==void 0||R[R.length-1].route.lazy!==void 0,`Matched leaf route at location "${k.pathname}${k.search}${k.hash}" does not have an element or Component. This means it will render an with a null value by default resulting in an "empty" page.`);let v=jy(R&&R.map(m=>Object.assign({},m,{params:Object.assign({},a,m.params),pathname:Xt([g,o.encodeLocation?o.encodeLocation(m.pathname).pathname:m.pathname]),pathnameBase:m.pathnameBase==="/"?g:Xt([g,o.encodeLocation?o.encodeLocation(m.pathnameBase).pathname:m.pathnameBase])})),i,n,r,l);return t&&v?f.createElement(Jl.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...k},navigationType:"POP"}},v):v}function Cy(){let e=Iy(),t=gy(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",l={padding:"0.5rem",backgroundColor:r},o={padding:"2px 4px",backgroundColor:r},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=f.createElement(f.Fragment,null,f.createElement("p",null,"💿 Hey developer 👋"),f.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",f.createElement("code",{style:o},"ErrorBoundary")," or"," ",f.createElement("code",{style:o},"errorElement")," prop on your route.")),f.createElement(f.Fragment,null,f.createElement("h2",null,"Unexpected Application Error!"),f.createElement("h3",{style:{fontStyle:"italic"}},t),n?f.createElement("pre",{style:l},n):null,i)}var Ny=f.createElement(Cy,null),_y=class extends f.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.unstable_onError?this.props.unstable_onError(e,t):console.error("React Router caught the following error during render",e)}render(){return this.state.error!==void 0?f.createElement(ln.Provider,{value:this.props.routeContext},f.createElement(ju.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function Ry({routeContext:e,match:t,children:n}){let r=f.useContext(Wr);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),f.createElement(ln.Provider,{value:e},n)}function jy(e,t=[],n=null,r=null,l=null){if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let o=e,i=n==null?void 0:n.errors;if(i!=null){let c=o.findIndex(g=>g.route.id&&(i==null?void 0:i[g.route.id])!==void 0);ge(c>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),o=o.slice(0,Math.min(o.length,c+1))}let s=!1,a=-1;if(n)for(let c=0;c=0?o=o.slice(0,a+1):o=[o[0]];break}}}return o.reduceRight((c,g,y)=>{let w,k=!1,E=null,N=null;n&&(w=i&&g.route.id?i[g.route.id]:void 0,E=g.route.errorElement||Ny,s&&(a<0&&y===0?(hh("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),k=!0,N=null):a===y&&(k=!0,N=g.route.hydrateFallbackElement||null)));let R=t.concat(o.slice(0,y+1)),v=()=>{let h;return w?h=E:k?h=N:g.route.Component?h=f.createElement(g.route.Component,null):g.route.element?h=g.route.element:h=c,f.createElement(Ry,{match:g,routeContext:{outlet:c,matches:R,isDataRoute:n!=null},children:h})};return n&&(g.route.ErrorBoundary||g.route.errorElement||y===0)?f.createElement(_y,{location:n.location,revalidation:n.revalidation,component:E,error:w,children:v(),routeContext:{outlet:null,matches:R,isDataRoute:!0},unstable_onError:r}):v()},null)}function Lu(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ly(e){let t=f.useContext(Wr);return ge(t,Lu(e)),t}function Ty(e){let t=f.useContext(zi);return ge(t,Lu(e)),t}function Py(e){let t=f.useContext(ln);return ge(t,Lu(e)),t}function Tu(e){let t=Py(e),n=t.matches[t.matches.length-1];return ge(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function My(){return Tu("useRouteId")}function Iy(){var r;let e=f.useContext(ju),t=Ty("useRouteError"),n=Tu("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function Ay(){let{router:e}=Ly("useNavigate"),t=Tu("useNavigate"),n=f.useRef(!1);return fh(()=>{n.current=!0}),f.useCallback(async(l,o={})=>{Pt(n.current,dh),n.current&&(typeof l=="number"?e.navigate(l):await e.navigate(l,{fromRouteId:t,...o}))},[e,t])}var vd={};function hh(e,t,n){!t&&!vd[e]&&(vd[e]=!0,Pt(!1,n))}f.memo($y);function $y({routes:e,future:t,state:n,unstable_onError:r}){return ph(e,void 0,n,r,t)}function mh(e){ge(!1,"A is only ever to be used as the child of element, never rendered directly. Please wrap your in a .")}function Oy({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:l,static:o=!1}){ge(!Xl(),"You cannot render a inside another . You should never have more than one in your app.");let i=e.replace(/^\/*/,"/"),s=f.useMemo(()=>({basename:i,navigator:l,static:o,future:{}}),[i,l,o]);typeof n=="string"&&(n=Zn(n));let{pathname:a="/",search:c="",hash:g="",state:y=null,key:w="default"}=n,k=f.useMemo(()=>{let E=nn(a,i);return E==null?null:{location:{pathname:E,search:c,hash:g,state:y,key:w},navigationType:r}},[i,a,c,g,y,w,r]);return Pt(k!=null,` is not able to match the URL "${a}${c}${g}" because it does not start with the basename, so the won't render anything.`),k==null?null:f.createElement(Ut.Provider,{value:s},f.createElement(Jl.Provider,{children:t,value:k}))}function Dy({children:e,location:t}){return Ey(ja(e),t)}function ja(e,t=[]){let n=[];return f.Children.forEach(e,(r,l)=>{if(!f.isValidElement(r))return;let o=[...t,l];if(r.type===f.Fragment){n.push.apply(n,ja(r.props.children,o));return}ge(r.type===mh,`[${typeof r.type=="string"?r.type:r.type.name}] is not a component. All component children of must be a or `),ge(!r.props.index||!r.props.children,"An index route cannot have child routes.");let i={id:r.props.id||o.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(i.children=ja(r.props.children,o)),n.push(i)}),n}var Yo="get",Go="application/x-www-form-urlencoded";function bi(e){return e!=null&&typeof e.tagName=="string"}function Fy(e){return bi(e)&&e.tagName.toLowerCase()==="button"}function zy(e){return bi(e)&&e.tagName.toLowerCase()==="form"}function by(e){return bi(e)&&e.tagName.toLowerCase()==="input"}function Uy(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function By(e,t){return e.button===0&&(!t||t==="_self")&&!Uy(e)}var Io=null;function Hy(){if(Io===null)try{new FormData(document.createElement("form"),0),Io=!1}catch{Io=!0}return Io}var Wy=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function js(e){return e!=null&&!Wy.has(e)?(Pt(!1,`"${e}" is not a valid \`encType\` for \`
\`/\`\` and will default to "${Go}"`),null):e}function Vy(e,t){let n,r,l,o,i;if(zy(e)){let s=e.getAttribute("action");r=s?nn(s,t):null,n=e.getAttribute("method")||Yo,l=js(e.getAttribute("enctype"))||Go,o=new FormData(e)}else if(Fy(e)||by(e)&&(e.type==="submit"||e.type==="image")){let s=e.form;if(s==null)throw new Error('Cannot submit a `,E=`
${w}
`;return`
${k}${E}
`}),i=i.replace(/
\s*(?=
]*>[\s\S]*?<\/div>)\s*
/g,"$1"),i}function rw(e){const t=e.split(/\r?\n/);let n=null;for(let r=0;r[\s\S]*?<\/think(?:ing)?>/gi,"").replace(/[*#]/g,"").replace(/\s+/g," ").trim()}function mr(e,t,n){return e.includes(t)?e:`${e} + +${n}`}function ow(e){const t=String(e||""),n=t.trim();if(!n)return t;const r=n.toLowerCase();return r.startsWith("error:")||r.startsWith("ollama error:")||r.includes("client error '")||r.includes("server error '")||r.includes("http")&&r.includes("error")||r.includes("unknown model architecture")||r.includes("out of memory")?r.includes("unknown model architecture")?mr(t,"[ERROR - Unsupported Model]",`[ERROR - Unsupported Model] +This Ollama version does not support the model. +Update Ollama.`):r.includes("out of memory")?mr(t,"[ERROR - Out of Memory]",`[ERROR - Out of Memory] +The model is too large for available memory. +Use a smaller or quantized model.`):r.includes("502")?mr(t,"[ERROR 502 - Bad Gateway]",`[ERROR 502 - Bad Gateway] +Ollama did not return a valid response. +Try restarting or updating Ollama.`):r.includes("500")?mr(t,"[ERROR 500 - Internal Server Error]",`[ERROR 500 - Internal Server Error] +Ollama crashed while processing the request. +Check 'ollama logs' and memory usage.`):r.includes("404")?mr(t,"[ERROR 404 - Not Found]",`[ERROR 404 - Not Found] +The model or endpoint was not found. +Check the model name or run 'ollama pull '.`):r.includes("400")?mr(t,"[ERROR 400 - Bad Request]",`[ERROR 400 - Bad Request] +The request sent to Ollama was invalid. +Check parameters or payload format.`):t:t}function _h(e){if(!e)return{think:null,answer:""};const t=//i,n=/<\/think(?:ing)?>/i,r=e.match(t);if(!r)return{think:null,answer:e};const l=r.index,o=r[0].length,i=e.substring(0,l).trim();let s=e.substring(l+o);const a=s.match(n);let c=null,g=i;return a?(c=s.substring(0,a.index).trim(),g+=s.substring(a.index+a[0].length)):c=s.trim(),{think:c||null,answer:g.trim()}}function iw({content:e,streamOutput:t,sources:n}){const r=ow(e||""),{think:l,answer:o}=_h(r),[i,s]=We.useState(!1),a=!!l;return d.jsxs("div",{className:"assistant-message",children:[a&&d.jsxs("div",{className:"assistant-thoughts",children:[d.jsxs("button",{className:"think-toggle",onClick:()=>s(c=>!c),"aria-expanded":i?"true":"false","aria-controls":"think-content",children:[d.jsx("span",{className:"think-toggle-icon","aria-hidden":"true",children:i?"▾":"▸"}),"Thoughts"]}),i&&d.jsx("div",{id:"think-content",className:"think-content",dangerouslySetInnerHTML:{__html:Od(l)}})]}),d.jsx("div",{className:"msg-content",dangerouslySetInnerHTML:{__html:Od(o||r||"")}}),Array.isArray(n)&&n.length>0&&d.jsx("div",{className:"msg-sources chips",children:n.map((c,g)=>{let y=c,w=!1;try{const k=new URL(c);if(k.protocol==="file:"){w=!0;const E=k.pathname.split("/").filter(Boolean);y=decodeURIComponent(E[E.length-1]||c)}else y=(k.hostname||c).replace(/^www\./i,"")}catch{}return d.jsx("a",{className:"chip",href:c,target:"_blank",rel:"noreferrer",title:c,onClick:k=>{var E,N;if(w){k.preventDefault();try{const R=new URL(c);(N=(E=window.electronAPI)==null?void 0:E.openPath)==null||N.call(E,decodeURIComponent(R.pathname))}catch{}}},children:y},c+g)})})]})}function Ms({attachments:e,className:t="",removable:n=!1,onRemove:r}){return!Array.isArray(e)||e.length===0?null:d.jsx("div",{className:`image-attachment-strip ${t}`.trim(),children:e.map((l,o)=>{const i=l==null?void 0:l.data_url;if(!i)return null;const s=l.id||`${l.name||"image"}-${o}-${i.length}`;return d.jsxs("div",{className:"image-attachment-card",children:[n&&d.jsx("button",{type:"button",className:"image-attachment-remove",onClick:()=>r==null?void 0:r(l.id),"aria-label":`Remove ${l.name||"image"}`,title:"Remove image",children:"×"}),d.jsx("img",{className:"image-attachment-thumb",src:i,alt:l.name||`Attachment ${o+1}`,loading:"lazy"})]},s)})})}const Dd="websearch.searxUrl",Fd="websearch.engines",zd="chat.libraryBySession",bd="http://127.0.0.1:8888",Is=6,As=20*1024*1024,sw=5*60*1e3,aw=200;let Rh="http://127.0.0.1:8000";const uw=48,cw=24;function dw(e){return e.backendApiUrl||e.ollamaApiUrl||Rh}function fw(e){const t=typeof e=="string"?e.trim():"";return!t||t==="http://localhost:8888"?bd:t}function $o(e){var n;return Array.from(((n=e==null?void 0:e.dataTransfer)==null?void 0:n.types)||[]).includes("Files")}function Ia(e){return e?typeof e.type=="string"&&e.type.toLowerCase().startsWith("image/")?!0:/\.(png|jpe?g|gif|bmp|webp|tiff?|heic|avif)$/i.test(e.name||""):!1}function Ud(e){var r,l;const t=Array.from(((r=e==null?void 0:e.dataTransfer)==null?void 0:r.items)||[]);return t.length>0?t.some(o=>{var i;return o.kind==="file"&&Ia((i=o.getAsFile)==null?void 0:i.call(o))}):Array.from(((l=e==null?void 0:e.dataTransfer)==null?void 0:l.files)||[]).some(Ia)}function Bd(e){return new Promise((t,n)=>{const r=new FileReader;r.onerror=()=>n(r.error||new Error(`Failed to read ${(e==null?void 0:e.name)||"image"}`)),r.onload=()=>t(String(r.result||"")),r.readAsDataURL(e)})}function pw(e,t){const n=String(t||"").trim();if(!n)return e||"";const r=String(e||"");if(!r.trim())return n;const l=/[\s\n]$/.test(r)?"":` +`;return`${r}${l}${n}`}function hw(e){const t=Math.max(0,Math.floor(Number(e||0)/1e3)),n=Math.floor(t/60),r=t%60;return`${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`}function mw(){var lc;const[e,t]=f.useState([]),[n,r]=f.useState(null),[l,o]=f.useState("chats"),i=f.useRef(l),[s,a]=f.useState("General"),[c,g]=f.useState(null),[y,w]=f.useState(null),[k,E]=f.useState([]),[N,R]=f.useState([]),[v,h]=f.useState(null),[m,C]=f.useState(()=>{try{const u=localStorage.getItem(zd);return u?JSON.parse(u):{}}catch{return{}}}),[L,A]=f.useState(!1),[$,D]=f.useState(""),[V,U]=f.useState(""),[ne,Ne]=f.useState(!1),[fe,ft]=f.useState(""),[P,B]=f.useState(""),[q,I]=f.useState("base"),[b,H]=f.useState(!1),[Z,se]=f.useState(""),[rt,Ge]=f.useState([]),[lt,Oe]=f.useState(!1),Pe=f.useRef(null),Mt=f.useRef(null),tr=f.useRef(null),pt=f.useRef(null),je=f.useRef(0),[on,Vr]=f.useState(!1),[Zl,Kr]=f.useState(""),[eo,nr]=f.useState(""),[It,Je]=f.useState(!0),[to,ht]=f.useState(""),[we,no]=f.useState(!1),[ot,ro]=f.useState(!1),[Bi,Qr]=f.useState(0),rr=f.useRef(null),Pn=f.useRef(null),Mn=f.useRef([]),Yr=f.useRef(null),lr=f.useRef(""),or=f.useRef(null),ir=f.useRef(null),Gr=f.useRef(0),sn=f.useRef(null),[K,lo]=f.useState(Rh),[oo,io]=f.useState("Default"),[In,Jr]=f.useState(!1),[Xr,an]=f.useState(""),[_,O]=f.useState(!1),[ae,mt]=f.useState(()=>fw(localStorage.getItem(Dd))),[Bt,jh]=f.useState(()=>tw(localStorage.getItem(Fd)));f.useEffect(()=>{localStorage.setItem(Dd,ae||"")},[ae]),f.useEffect(()=>{try{localStorage.setItem(Fd,JSON.stringify(ki(Bt)))}catch{}},[Bt]);const[so,Lh]=f.useState(!1),[kt,Hi]=f.useState(!1),[Au,Wi]=f.useState(!0),[Th,sr]=f.useState([]),[ao,$u]=f.useState({}),[Ou,Ph]=f.useState(!1),Du=f.useRef(!1),[Mh,Vi]=f.useState(null),[Ki,uo]=f.useState("");function Ih(u){const p=u.content||"";if(u.role==="assistant")try{const{answer:S}=_h(p);return(S||p).trim()}catch{return p.trim()}return p}async function Fu(u){try{await navigator.clipboard.writeText(Ih(u))}catch(p){console.error("Failed to copy message:",p)}}function An(u,p,S,x={}){const{removeIfEmpty:T=!1}=x;t(M=>M.map(z=>{if(z.session_id!==u)return z;const W=[];for(const J of z.messages||[]){if(J.id!==p){W.push(J);continue}T&&!S||W.push({...J,content:S})}return{...z,messages:W}}))}function At(u){return(u==null?void 0:u.name)==="AbortError"}function Ah(u){return Array.isArray(u==null?void 0:u.attachments)&&u.attachments.length>0}function $h(u=[]){return Array.isArray(u)&&u.length>0&&P||fe}function Ht(u){return u instanceof Error&&u.message?u.message:String(u)}async function co(u){const p=await u.text().catch(()=>"");if(p){try{const S=JSON.parse(p);if(typeof(S==null?void 0:S.detail)=="string"&&S.detail.trim())return S.detail.trim();if(typeof(S==null?void 0:S.message)=="string"&&S.message.trim())return S.message.trim()}catch{}return p.trim()}return`HTTP ${u.status}`}async function qr(u){const p=await u.json().catch(()=>null);if(u.ok)return p;const S=typeof(p==null?void 0:p.detail)=="string"?p.detail:typeof(p==null?void 0:p.message)=="string"?p.message:"";throw new Error(S||`HTTP ${u.status}`)}async function Oh(u,p){const S=await fetch(`${K}/models/capabilities?name=${encodeURIComponent(u)}`,{signal:p});return qr(S)}async function Dh(){const u=await fetch(`${K}/ollama/startup-status`);return qr(u)}async function Fh(){const u=await fetch(`${K}/startup/prepare-models`,{method:"POST"});return qr(u)}function zu(u){if(!!(u!=null&&u.whisper_model_available)){Je(!0),ht("");return}const S=(u==null?void 0:u.whisper_model)||"base",x=String((u==null?void 0:u.whisper_error)||"").trim();Je(!1),ht(x||`Whisper ${S} is not available.`)}async function bu(u,p,S){if(!u)return{contextBlock:null,sources:[]};const T=await(await fetch(`${K}/libraries/${u}/context`,{method:"POST",headers:{"Content-Type":"application/json"},signal:S,body:JSON.stringify({prompt:p,top_k:5})})).json();return{contextBlock:typeof(T==null?void 0:T.context_block)=="string"&&T.context_block.trim()?T.context_block.trim():null,sources:Array.isArray(T==null?void 0:T.sources)?T.sources:[]}}async function Uu(u){const p=Array.from(u||[]).filter(Ia);if(!p.length||!b)return;const S=Math.max(0,Is-rt.length);if(S<=0){window.alert(`You can attach up to ${Is} images per message.`);return}const x=p.slice(0,S),T=x.filter(z=>Number(z.size)>As),M=x.filter(z=>Number(z.size)<=As);if(T.length>0&&window.alert(`Images must be ${Math.round(As/(1024*1024))} MB or smaller.`),!!M.length)try{const z=await Promise.all(M.map(async(W,J)=>({id:`attachment-${Date.now()}-${J}-${Math.random().toString(36).slice(2)}`,name:W.name||"image",mime_type:W.type||"image/*",data_url:await Bd(W)})));Ge(W=>[...W,...z]),p.length>S&&window.alert(`Only the first ${Is} images can be attached.`)}catch(z){console.error("Failed to load image attachments",z),window.alert(`Image import failed: ${Ht(z)}`)}}function zh(u){Ge(p=>p.filter(S=>S.id!==u))}function bh(){var u;b&&((u=pt.current)==null||u.click())}function Qi(){or.current&&(window.clearInterval(or.current),or.current=null),ir.current&&(window.clearTimeout(ir.current),ir.current=null)}function Yi(u=Pn.current){Qi(),Ta(u),Pn.current===u&&(Pn.current=null),rr.current=null}async function Uh(u,p){if(!K)throw new Error("The Heimgeist backend is not configured.");const S=new AbortController;sn.current=S,ro(!0);try{const x=await Bd(u),T=x.indexOf(",");if(T<=5)throw new Error("Recorded audio could not be encoded for upload.");const M=x.slice(0,T),z=x.slice(T+1);if(!/^data:[^,]+;base64$/i.test(M)||!z)throw new Error("Recorded audio could not be encoded for upload.");const W=M.slice(5).replace(/;base64$/i,"").trim(),J=await fetch(`${K}/audio/transcribe`,{method:"POST",headers:{"Content-Type":"application/json"},signal:S.signal,body:JSON.stringify({mime_type:p||W||"audio/webm",audio_base64:z,model:q||null,language:eo||null})}),ke=await qr(J),ee=String((ke==null?void 0:ke.text)||"").trim();if(!ee){window.alert("No speech was detected. Try again and speak closer to the selected microphone.");return}se(re=>pw(re,ee)),requestAnimationFrame(()=>{var re;return(re=Mt.current)==null?void 0:re.focus()})}catch(x){if(At(x))return;throw x}finally{sn.current===S&&(sn.current=null),ro(!1)}}async function Zr(u={}){const{shouldTranscribe:p=!0}=u,S=rr.current,x=Yr.current,T=lr.current||(S==null?void 0:S.mimeType)||"audio/webm";if(!(!S||!x)){no(!1),Qi();try{S.state!=="inactive"&&S.stop();const M=await x;if(!p)return;if(!M||M.size<=0)throw new Error("Recorded audio was empty.");await Uh(M,T)}catch(M){p&&(console.error("Failed to stop microphone recording",M),window.alert(`Microphone transcription failed: ${Ht(M)}`))}finally{Yr.current=null,Mn.current=[],lr.current="",Gr.current=0,Qr(0)}}}async function Bh(){if(!on||!It||we||ot||kt)return;if(!Ui()){window.alert("Microphone capture is not available in this environment.");return}let u=null;try{u=await navigator.mediaDevices.getUserMedia(D0(Zl))}catch(x){console.error("Failed to access microphone",x),window.alert(`Microphone access failed: ${Ht(x)}`);return}const p=z0();let S=null;try{S=p?new MediaRecorder(u,{mimeType:p}):new MediaRecorder(u)}catch(x){Yi(u),console.error("Failed to create audio recorder",x),window.alert(`Microphone recording is not available: ${Ht(x)}`);return}Pn.current=u,rr.current=S,Mn.current=[],lr.current=S.mimeType||p||"audio/webm",Gr.current=Date.now(),Qr(0),no(!0),S.ondataavailable=x=>{x.data&&x.data.size>0&&Mn.current.push(x.data)},Yr.current=new Promise((x,T)=>{S.onstop=()=>{const M=new Blob(Mn.current,{type:S.mimeType||lr.current||"audio/webm"});Yi(u),x(M)},S.onerror=M=>{Yi(u),T((M==null?void 0:M.error)||new Error("Audio recording failed."))}}),or.current=window.setInterval(()=>{Qr(Date.now()-Gr.current)},aw),ir.current=window.setTimeout(()=>{Zr()},sw),S.start()}async function Hh(){if(!ot){if(we){await Zr();return}await Bh()}}async function Wh(u){var S;const p=(S=u.target)==null?void 0:S.files;try{await Uu(p)}finally{u.target&&(u.target.value="")}}function Vh(u,p){Vi(u),uo(p||"")}function fo(){Vi(null),uo("")}async function Kh(u){var M;const p=(((M=dr[u])==null?void 0:M.content)||"").trim(),x=(Ki??"").trim();if(x.length===0){fo();return}if(x===p){fo();return}const T=n;if(T){t(z=>z.map(W=>{if(W.session_id!==T)return W;const ke=(W.messages||[]).slice(0,u+1).map((ee,re)=>re===u?{...ee,content:x}:ee);return{...W,messages:ke}})),Vi(null),uo(""),requestAnimationFrame(()=>Zi("auto",T));try{const z=await fetch(`${K}/sessions/${T}/messages/${u}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:x})});if(!z.ok)throw new Error(`HTTP ${z.status}`)}catch(z){console.error("Failed to update message:",z),t(W=>W.map(J=>{if(J.session_id!==T)return J;const ee=(J.messages||[]).map((re,Be)=>Be===u?{...re,content:p}:re);return{...J,messages:ee}}));return}await Bu(u,x)}}async function Bu(u,p=null){var re,Be,Xe,Dn,Q,Se;const S=n;if(kt||!S||typeof u!="number")return;const x=((re=e.find(te=>te.session_id===S))==null?void 0:re.messages)||[];let T=u;for(let te=u;te>=0;te--)if(((Be=x[te])==null?void 0:Be.role)==="user"){T=te;break}t(te=>te.map(oe=>oe.session_id===S?{...oe,messages:(oe.messages||[]).slice(0,T+1)}:oe));const M=x.slice(0,T+1).some(Ah),z=M&&P||fe;if(M&&!b){window.alert("The selected vision model does not support image inputs.");return}const W=Yu(S);let J=p??(((Xe=x[T])==null?void 0:Xe.content)||""),ke=[];const ee=[];try{const te=qu(S),oe=p??(((Dn=x[T])==null?void 0:Dn.content)||""),Me=!!(oe||"").trim();if(Me&&((Q=te==null?void 0:te.states)!=null&&Q.is_indexed))try{const Y=await bu(te.slug,oe,W.signal);Y.contextBlock&&ee.push(Y.contextBlock),Array.isArray(Y.sources)&&ke.push(...Y.sources)}catch(Y){if(At(Y))throw Y;console.warn("local library enrichment (regenerate) failed",Y)}if(Me&&so)try{const Y=x.slice(Math.max(0,T-7),T+1).map(Ee=>({role:Ee.role,content:Ee.content||""}));Y.length>0&&(Y[Y.length-1]={role:"user",content:oe});const ue=await(await fetch(`${K}/websearch`,{method:"POST",headers:{"Content-Type":"application/json"},signal:W.signal,body:JSON.stringify({prompt:oe,model:fe,messages:Y,history_limit:8,searx_url:ae||null,engines:Array.isArray(Bt)?Bt:null})})).json();ue&&typeof ue.context_block=="string"&&ue.context_block.trim()&&ee.push(ue.context_block.trim()),Array.isArray(ue==null?void 0:ue.sources)&&ke.push(...ue.sources)}catch(Y){if(At(Y))throw Y;console.warn("web search enrichment (regenerate) failed",Y)}if(ke=[...new Set(ke)],Me&&ee.length>0?J=`${oe} + +${ee.join(` + +`)}`:J=null,In){const Y=`msg-${Date.now()}-${Math.random()}`;let Vt="";t(ue=>ue.map(Ee=>Ee.session_id===S?{...Ee,messages:[...Ee.messages||[],{id:Y,role:"assistant",content:"",sources:ke}]}:Ee));try{const ue=await fetch(`${K}/sessions/${S}/regenerate`,{method:"POST",headers:{"Content-Type":"application/json"},signal:W.signal,body:JSON.stringify({index:u,model:z,stream:!0,enriched_message:J,sources:ke||[]})});if(!ue.ok)throw new Error(await co(ue));const Ee=(Se=ue.body)==null?void 0:Se.getReader();if(!Ee)throw new Error("Missing response body");const cn=new TextDecoder;let $t=!1;for(;;){const{value:Fn,done:wm}=await Ee.read();if(wm)break;const Sm=cn.decode(Fn,{stream:!0});Vt+=Sm,An(S,Y,Vt),!$t&&De.current!==S&&($t=!0,$n(es=>({...es,[S]:Y})),sr(es=>[...new Set([...es,S])]))}De.current!==S?($n(Fn=>({...Fn,[S]:Y})),sr(Fn=>[...new Set([...Fn,S])])):ar.current[S]?ur(Fn=>({...Fn,[S]:Y})):requestAnimationFrame(()=>fr(Y,"smooth",S))}catch(ue){if(At(ue)){An(S,Y,Vt,{removeIfEmpty:!0});return}console.error(ue),An(S,Y,`Error: ${Ht(ue)}`,{removeIfEmpty:!0});return}}else{const Y=await fetch(`${K}/sessions/${S}/regenerate`,{method:"POST",headers:{"Content-Type":"application/json"},signal:W.signal,body:JSON.stringify({index:u,model:z,stream:!1,enriched_message:J,sources:ke||[]})});if(!Y.ok)throw new Error(await co(Y));const Vt=await Y.json(),ue=`msg-${Date.now()}`;t(Ee=>Ee.map(cn=>cn.session_id===S?{...cn,messages:[...cn.messages||[],{role:"assistant",content:Vt.reply,id:ue,sources:ke}]}:cn)),De.current!==S?($n(Ee=>({...Ee,[S]:ue})),sr(Ee=>[...new Set([...Ee,S])])):ar.current[S]?ur(Ee=>({...Ee,[S]:ue})):requestAnimationFrame(()=>fr(ue,"smooth",S))}}catch(te){At(te)||console.error(te)}finally{Gi(W)}}const[Hu,Qh]=f.useState({}),ar=f.useRef({}),[Yh,$n]=f.useState({}),On=f.useRef({}),Wu=f.useRef({}),[Vu,ur]=f.useState({}),[Gh,Ku]=f.useState({});f.useEffect(()=>{i.current=l},[l]);const Qu=(u,p,S)=>u!=null&&u.id?u.id:`${S}:${p}`;f.useEffect(()=>{var p;if(!n)return;const u=((p=e.find(S=>S.session_id===n))==null?void 0:p.messages)||[];Ku(S=>{const x={};return u.forEach((T,M)=>{if(T.role!=="user")return;const z=Qu(T,M,n),J=(T.content||"").split(/\r\n|\r|\n/).length>30;x[z]=J?S[z]??!0:!1}),x})},[e,n]);function Jh(u){Ku(p=>({...p,[u]:!(p[u]??!0)}))}const el=We.useCallback((u,p)=>{Qh(S=>{const x={...S,[u]:p};return ar.current=x,x})},[]),cr=f.useRef(null),Xh=f.useRef(!1),qh=f.useRef(null),De=f.useRef(n);f.useEffect(()=>{De.current=n},[n]);const Yu=We.useCallback(u=>{const p=new AbortController;return cr.current={controller:p,sessionId:u},Hi(!0),p},[]),Gi=We.useCallback(u=>{var p;((p=cr.current)==null?void 0:p.controller)===u&&(cr.current=null,Hi(!1))},[]),Zh=We.useCallback(()=>{const u=cr.current;u&&(cr.current=null,u.controller.abort(),Hi(!1))},[]);f.useEffect(()=>()=>{var u;(u=cr.current)==null||u.controller.abort()},[]);const un=f.useRef(null),[em,tm]=f.useState(230),[po,Gu]=f.useState(!1),nm=We.useCallback(u=>{Gu(!0)},[]),tl=We.useCallback(()=>{Gu(!1)},[]),Ji=We.useCallback(u=>{if(po){const p=Math.max(230,Math.min(500,u.clientX));tm(p)}},[po]);We.useEffect(()=>(window.addEventListener("mousemove",Ji),window.addEventListener("mouseup",tl),window.addEventListener("blur",tl),()=>{window.removeEventListener("mousemove",Ji),window.removeEventListener("mouseup",tl),window.removeEventListener("blur",tl)}),[Ji,tl]),We.useEffect(()=>(po?document.body.classList.add("no-select"):document.body.classList.remove("no-select"),()=>{document.body.classList.remove("no-select")}),[po]),We.useEffect(()=>{const u=async p=>{const S=p.target.closest(".codeblock__copy");if(!S)return;const x=S.closest(".codeblock"),T=x==null?void 0:x.querySelector("pre > code");if(T)try{await navigator.clipboard.writeText(T.textContent||""),S.classList.add("copied"),setTimeout(()=>S.classList.remove("copied"),800)}catch(M){console.error("Copy failed:",M)}};return document.addEventListener("click",u),()=>document.removeEventListener("click",u)},[]),f.useEffect(()=>{let u=!1;return window.electronAPI.getSettings().then(p=>{u||(lo(dw(p)),io(p.colorScheme||"Default"),ft(p.chatModel||""),B(p.visionModel||p.chatModel||""),I(p.transcriptionModel||"base"),Jr(p.streamOutput||!1),Vr(p.audioInputEnabled===!0),Kr(typeof p.audioInputDeviceId=="string"?p.audioInputDeviceId:""),nr(typeof p.audioInputLanguage=="string"?p.audioInputLanguage:""),$u(p.scrollPositions||{}),Wl(p.colorScheme||"Default"))}).finally(()=>{u||Ph(!0)}),()=>{u=!0}},[]),f.useEffect(()=>{const u=()=>{var p;i.current==="chats"&&((p=Mt.current)==null||p.focus())};return window.electronAPI.onWindowFocus(u),()=>{window.electronAPI.offWindowFocus(u)}},[]),f.useEffect(()=>{let u=!1;const p=new AbortController;return!K||!P?(H(!1),()=>{p.abort()}):((async()=>{try{const S=await Oh(P,p.signal);u||H(!!(S!=null&&S.supports_vision))}catch(S){!u&&!At(S)&&(console.warn("Failed to load model capabilities",S),H(!1))}})(),()=>{u=!0,p.abort()})},[K,P]),f.useEffect(()=>{je.current=0,Oe(!1)},[b,l]),f.useEffect(()=>{on||!we||Zr({shouldTranscribe:!1})},[on,we]),f.useEffect(()=>{It||!we||Zr({shouldTranscribe:!1})},[It,we]),f.useEffect(()=>{l==="chats"||!we||Zr()},[l,we]),f.useEffect(()=>()=>{var p;(p=sn.current)==null||p.abort(),Qi();const u=rr.current;if(u){u.ondataavailable=null,u.onstop=null,u.onerror=null;try{u.state!=="inactive"&&u.stop()}catch{}}Ta(Pn.current)},[]),f.useEffect(()=>{if(!Ou||Au||!K||Du.current)return;Du.current=!0;let u=!1;const p=window.setTimeout(()=>{(async()=>{let S=!1;try{let x=await Dh();if(u)return;if(zu(x),!(x!=null&&x.ollama_running)&&(x!=null&&x.can_manage_locally)){const z=window.confirm(`Ollama is not running at ${x.ollama_url}. Start it in the background now with "ollama serve"?`);if(u)return;if(z){S=!0,O(!0),an("Starting Ollama in the background...");const W=await fetch(`${K}/ollama/start`,{method:"POST"});if(x=await qr(W),u)return}}const T=!(x!=null&&x.whisper_model_available),M=!!(x!=null&&x.ollama_running&&(x!=null&&x.can_manage_locally)&&!(x!=null&&x.embedding_model_available));if(T||M){S=!0,O(!0),an(T&&M?`Downloading Whisper ${(x==null?void 0:x.whisper_model)||"base"} and ${x.selected_embed_model}. This can take a while on first install.`:T?`Downloading Whisper ${(x==null?void 0:x.whisper_model)||"base"}. This can take a while on first install.`:`Downloading ${x.selected_embed_model} from Ollama. This can take a while on first install.`);const z=await Fh();if(u)return;zu((z==null?void 0:z.ollama)||x)}}catch(x){u||(console.warn("startup Ollama check failed",x),Je(!1),ht(`Whisper availability could not be verified: ${Ht(x)}`),S&&window.alert(`Startup action failed: ${Ht(x)}`))}finally{u||(O(!1),an(""))}})()},1200);return()=>{u=!0,window.clearTimeout(p)}},[K,Au,Ou]),f.useEffect(()=>{Wl(oo)},[oo]);const rm=u=>{!u||!K||fetch(`${K}/history?session_id=${encodeURIComponent(u)}`).then(p=>p.json()).then(p=>{t(S=>S.map(x=>x.session_id===u?{...x,messages:p.messages||[]}:x))}).catch(()=>{})};async function nl(){if(K)try{const p=await(await fetch(`${K}/libraries`)).json(),S=Array.isArray(p.libraries)?p.libraries:[];if(E(S),S.length===0){h(null);return}S.some(x=>x.slug===v)||h(S[0].slug)}catch(u){console.warn("Failed to load libraries",u)}}async function ho(){if(K)try{const p=await(await fetch(`${K}/jobs`)).json();R(Array.isArray(p.jobs)?p.jobs:[])}catch(u){console.warn("Failed to load library jobs",u)}}async function Ju(u=null){const S=(typeof u=="string"?u:$).trim();if(!S){U("Name is required.");return}try{U("");const x=await fetch(`${K}/libraries`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:S})});if(!x.ok){const M=await x.text();throw new Error(M||`HTTP ${x.status}`)}const T=await x.json();A(!1),D(""),await nl(),T!=null&&T.slug&&h(T.slug)}catch(x){console.error("Failed to create library",x),U(String((x==null?void 0:x.message)||x))}}async function lm(){E([]),R([]),h(null),w(null),Ne(!1),C({}),await nl(),await ho()}f.useEffect(()=>{K&&(Wi(!0),fetch(`${K}/sessions`).then(u=>u.json()).then(u=>{const p=u.sessions.map(S=>({...S,messages:[]}));t(p),p.length>0?r(p[0].session_id):r(null),Wi(!1)}).catch(()=>{Wi(!1)}))},[K]),f.useEffect(()=>{K&&(nl(),ho())},[K]),f.useEffect(()=>{try{localStorage.setItem(zd,JSON.stringify(m||{}))}catch{}},[m]),f.useEffect(()=>{if(!K)return;const u=setInterval(()=>{nl(),ho()},3e3);return()=>clearInterval(u)},[K,l,v]),f.useEffect(()=>{rm(n)},[n,K]),f.useEffect(()=>{const u=new Set(k.map(p=>p.slug));C(p=>{let S=!1;const x={};for(const[T,M]of Object.entries(p||{}))u.has(M)?x[T]=M:S=!0;return S?x:p})},[k]);const Xi=u=>{o(u)},om=u=>{hm(u)},dr=f.useMemo(()=>{var u;return((u=e.find(p=>p.session_id===n))==null?void 0:u.messages)||[]},[n,e]),mo=f.useMemo(()=>k.find(u=>u.slug===v)||null,[v,k]),Wt=n&&m[n]||null,Et=f.useMemo(()=>k.find(u=>u.slug===Wt)||null,[Wt,k]),Xu=f.useMemo(()=>Wt?N.some(u=>u.slug===Wt&&(u.status==="queued"||u.status==="running")):!1,[Wt,N]),qi=f.useMemo(()=>{var u,p;return Et?(u=Et.files)!=null&&u.length?(p=Et.states)!=null&&p.is_indexed?"":Xu?" (syncing)":" (needs sync)":" (empty)":""},[Et,Xu]);function im(u){return u&&m[u]||null}function qu(u){const p=im(u);return p&&k.find(S=>S.slug===p)||null}function Zu(u){return u?N.some(p=>p.slug===u&&(p.status==="queued"||p.status==="running")):!1}function ec(u,p){u&&C(S=>{const x={...S||{}};return p?x[u]=p:delete x[u],x})}function sm(u){u&&C(p=>{let S=!1;const x={};for(const[T,M]of Object.entries(p||{})){if(M===u){S=!0;continue}x[T]=M}return S?x:p})}f.useEffect(()=>{if(!ne)return;const u=p=>{var S;(S=tr.current)!=null&&S.contains(p.target)||Ne(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[ne]),f.useEffect(()=>{Ne(!1)},[n,l]),f.useEffect(()=>{const u=n,p=l;return()=>{if(p==="chats"&&u){const S=typeof On.current[u]=="number"?On.current[u]:Pe.current?Pe.current.scrollTop:0;$u(x=>{const T={...x,[u]:S};return window.electronAPI.updateSettings({scrollPositions:T}),T})}}},[n,l]),f.useEffect(()=>{const u=Pe.current;if(!u)return;const p=()=>{const{scrollTop:S,scrollHeight:x,clientHeight:T}=u,M=x-S-T<=cw;if(n){const z=Wu.current[n],W=typeof z=="number"&&Su.removeEventListener("scroll",p)},[n,el]),f.useEffect(()=>{const u=n;u&&Hu[u]===!1&&ur(p=>{if(!(u in p))return p;const S={...p};return delete S[u],S})},[n,Hu]),f.useLayoutEffect(()=>{if(l!=="chats"||!n)return;const u=Pe.current;if(!u)return;un.current=null;const p=()=>{if(un.current===n)return;const z=typeof On.current[n]=="number"?On.current[n]:void 0,W=typeof z=="number"?z:ao[n];if(typeof W=="number"){u.scrollTop=W,un.current=n;return}dr.length>0&&(u.scrollTop=u.scrollHeight,un.current=n)};p();const S=requestAnimationFrame(p),x=()=>{un.current!==n&&requestAnimationFrame(p)},T=new MutationObserver(x);T.observe(u,{childList:!0,subtree:!0});const M=new ResizeObserver(x);return M.observe(u),()=>{cancelAnimationFrame(S),T.disconnect(),M.disconnect()}},[n,l,dr.length,ao]),f.useEffect(()=>{if(l!=="chats"||!n||un.current===n)return;const u=typeof On.current[n]=="number"?On.current[n]:void 0;typeof(typeof u=="number"?u:ao[n])!="number"&&dr.length>0&&requestAnimationFrame(()=>{const S=Pe.current;S&&(S.scrollTop=S.scrollHeight,un.current=n)})},[dr.length,n,l,ao]);const Zi=(u="smooth",p=null)=>{const S=Pe.current;if(!S)return;const x=p??De.current;De.current===x&&(S.scrollTo({top:S.scrollHeight,behavior:u}),el(x,!1))},fr=(u,p="auto",S=null)=>{const x=Pe.current;if(!x)return;const T=S??De.current;if(De.current!==T)return;const M=document.getElementById(u);if(M){const z=Math.max(0,M.offsetTop-uw);x.scrollTo({top:z,behavior:p})}},am=()=>{const u=De.current,p=Vu[u];p&&(fr(p,"smooth",u),ur(S=>{const{[u]:x,...T}=S;return T}))},um=u=>{l!=="chats"||!$o(u)||(u.preventDefault(),je.current+=1,b&&Ud(u)&&Oe(!0))},cm=u=>{l!=="chats"||!$o(u)||(u.preventDefault(),u.dataTransfer.dropEffect=b?"copy":"none",b&&Ud(u)&&!lt&&Oe(!0))},dm=u=>{l!=="chats"||!$o(u)||(je.current=Math.max(0,je.current-1),je.current===0&&Oe(!1))},fm=async u=>{var p,S;l!=="chats"||!$o(u)||(u.preventDefault(),je.current=0,Oe(!1),b&&(await Uu((p=u.dataTransfer)==null?void 0:p.files),(S=Mt.current)==null||S.focus()))};async function tc(){var W,J,ke;const u=Z.trim();if(kt||!u&&rt.length===0||!fe)return;if(rt.length>0&&!b){window.alert("The selected vision model does not support image inputs.");return}let p=n,S=!1;if(p){const ee=e.find(re=>re.session_id===p);S=ee&&ee.name==="New Chat"&&ee.messages.length===0}else{const ee=await nc();await new Promise(re=>setTimeout(re,200)),p=ee.session_id,S=!0}const x=rt.map(({id:ee,...re})=>({...re})),T=$h(x),M={role:"user",content:u,attachments:x,id:`msg-${Date.now()}-${Math.random()}`};Xh.current=!0,qh.current=p,el(p,!1),De.current===p&&(un.current=De.current),nh.flushSync(()=>{t(ee=>ee.map(re=>re.session_id===p?{...re,messages:[...re.messages||[],M]}:re)),se(""),Ge([])}),requestAnimationFrame(()=>Zi("auto",p));const z=Yu(p);try{let ee=[];if(M.content)try{ee=[...(((W=e.find(te=>te.session_id===p))==null?void 0:W.messages)||[]).slice(-8).map(te=>({role:te.role,content:te.content||""})),{role:"user",content:M.content}]}catch{}let re=M.content||null,Be=[];const Xe=[],Dn=qu(p);if(M.content&&((J=Dn==null?void 0:Dn.states)!=null&&J.is_indexed))try{const Q=await bu(Dn.slug,M.content,z.signal);Q.contextBlock&&Xe.push(Q.contextBlock),Array.isArray(Q.sources)&&Be.push(...Q.sources)}catch(Q){if(At(Q))throw Q;console.warn("local library enrichment failed",Q)}if(M.content&&so)try{const Se=await(await fetch(`${K}/websearch`,{method:"POST",headers:{"Content-Type":"application/json"},signal:z.signal,body:JSON.stringify({prompt:M.content,model:fe,messages:ee,history_limit:8,searx_url:ae||null,engines:Array.isArray(Bt)?Bt:null})})).json();Se&&typeof Se.context_block=="string"&&Se.context_block.trim()&&Xe.push(Se.context_block.trim()),Array.isArray(Se==null?void 0:Se.sources)&&Be.push(...Se.sources)}catch(Q){if(At(Q))throw Q;console.warn("web search enrichment failed",Q)}if(Be=[...new Set(Be)],M.content&&Xe.length>0&&(re=`${M.content} + +${Xe.join(` + +`)}`),In){const Q=`msg-${Date.now()}-${Math.random()}`;let Se="";const te={role:"assistant",content:"",id:Q,sources:Be};t(oe=>oe.map(Me=>Me.session_id===p?{...Me,messages:[...Me.messages||[],te]}:Me));try{const oe=await fetch(`${K}/chat`,{method:"POST",headers:{"Content-Type":"application/json"},signal:z.signal,body:JSON.stringify({session_id:p,model:T,message:M.content,enriched_message:M.content&&Xe.length>0?re:null,stream:!0,sources:Be||[],attachments:x})});if(!oe.ok)throw new Error(await co(oe));const Me=(ke=oe.body)==null?void 0:ke.getReader();if(!Me)throw new Error("Missing response body");const Y=new TextDecoder;let Vt=!1;for(;;){const{value:ue,done:Ee}=await Me.read();if(Ee){An(p,Q,Se),De.current===p?ar.current[p]?ur($t=>({...$t,[p]:Q})):requestAnimationFrame(()=>fr(Q,"smooth",p)):($n($t=>({...$t,[p]:Q})),sr($t=>[...new Set([...$t,p])]));break}const cn=Y.decode(ue,{stream:!0});Se+=cn,An(p,Q,Se),De.current===p&&!ar.current[p]&&Zi("auto",p),De.current!==p&&!Vt&&($n($t=>({...$t,[p]:Q})),Vt=!0)}}catch(oe){if(At(oe)){An(p,Q,Se,{removeIfEmpty:!0});return}console.error("Failed to send message:",oe),An(p,Q,"Error: "+Ht(oe),{removeIfEmpty:!0});return}}else{const Q=await fetch(`${K}/chat`,{method:"POST",headers:{"Content-Type":"application/json"},signal:z.signal,body:JSON.stringify({session_id:p,model:T,message:M.content,enriched_message:M.content&&Xe.length>0?re:null,stream:!1,sources:Be||[],attachments:x})});if(!Q.ok)throw new Error(await co(Q));const Se=await Q.json(),te=`msg-${Date.now()}`,oe={role:"assistant",content:Se.reply,id:te,sources:Be};t(Me=>Me.map(Y=>Y.session_id===p?{...Y,messages:[...Y.messages||[],oe]}:Y)),te&&(De.current===p?ar.current[p]?ur(Me=>({...Me,[p]:te})):requestAnimationFrame(()=>fr(te,"smooth",p)):$n(Me=>({...Me,[p]:te})))}De.current!==p&&sr(Q=>[...new Set([...Q,p])]),S&&fetch(`${K}/generate-title`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:p,message:M.content||(x.length>0?"Image attachment":M.content),model:fe})}).then(Q=>Q.json()).then(Q=>{const Se=lw(Q.title);t(te=>te.map(oe=>oe.session_id===p?{...oe,name:Se}:oe))})}catch(ee){if(At(ee)){Gi(z);return}console.error("Failed to send message:",ee);const re={role:"assistant",content:"Error: "+Ht(ee),id:`msg-${Date.now()}-${Math.random()}`};t(Be=>Be.map(Xe=>Xe.session_id===p?{...Xe,messages:[...Xe.messages,re]}:Xe))}finally{Gi(z)}}function pm(){Lh(u=>!u)}async function nc(){var T;const u="sess-"+Math.random().toString(36).slice(2)+Date.now().toString(36),S=await(await fetch(`${K}/sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:u})})).json(),x={...S,messages:[]};return t(M=>[x,...M]),r(S.session_id),(T=Mt.current)==null||T.focus(),S}function hm(u){r(u),sr(S=>S.filter(x=>x!==u));const p=Yh[u];p&&requestAnimationFrame(()=>{let S=12;const x=()=>{if(!Pe.current)return;let M=document.getElementById(p);if(!M){const z=e.find(W=>W.session_id===u);if(z&&Array.isArray(z.messages))for(let W=z.messages.length-1;W>=0;W--){const J=z.messages[W];if(J.role==="assistant"&&J.id){M=document.getElementById(J.id);break}}}M?(fr(M.id,"smooth",u),$n(z=>{const{[u]:W,...J}=z;return J})):S-- >0&&requestAnimationFrame(x)};requestAnimationFrame(x)})}function mm(u,p){fetch(`${K}/sessions/${u}/rename`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:p})}).then(()=>{t(S=>S.map(x=>x.session_id===u?{...x,name:p}:x)),g(null)})}function gm(u,p){const S=(p||"").trim(),x=k.find(T=>T.slug===u);if(!x){w(null);return}if(!S||S===x.name){w(null);return}fetch(`${K}/libraries/${u}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:S})}).then(()=>{E(T=>T.map(M=>M.slug===u?{...M,name:S}:M)),w(null)})}function rc(u){fetch(`${K}/sessions/${u}`,{method:"DELETE"}).then(()=>{const p=e.filter(S=>S.session_id!==u);t(p),C(S=>{const x={...S||{}};return delete x[u],x}),n===u&&r(p.length>0?p[0].session_id:null)})}function vm(u){fetch(`${K}/libraries/${u}`,{method:"DELETE"}).then(async p=>{var x;if(!p.ok){const T=await p.text();throw new Error(T||`HTTP ${p.status}`)}const S=k.filter(T=>T.slug!==u);E(S),R(T=>T.filter(M=>M.slug!==u)),w(T=>T===u?null:T),v===u&&h(((x=S[0])==null?void 0:x.slug)||null),sm(u)}).catch(p=>{console.error("Failed to delete library",p)})}f.useEffect(()=>{const u=e.filter(p=>p.name==="New Chat"&&p.session_id!==n&&p.messages.length===0);u.length>0&&u.forEach(p=>{rc(p.session_id)})},[n,e,K]);const ym=u=>{var S;window.getSelection().toString().length>0||document.activeElement!==Mt.current&&(u.target.closest(".msg")||(S=Mt.current)==null||S.focus())};return d.jsxs("div",{className:"app",style:{gridTemplateColumns:`${em}px 1fr`},children:[d.jsxs("div",{className:"sidebar",children:[d.jsxs("div",{className:"sidebar-header",children:[d.jsx("div",{className:`sidebar-tab ${l==="chats"?"active":""}`,onClick:()=>Xi("chats"),children:"Chats"}),d.jsx("div",{className:`sidebar-tab ${l==="dbs"?"active":""}`,onClick:()=>Xi("dbs"),children:"DBs"}),d.jsx("div",{className:`sidebar-tab ${l==="settings"?"active":""}`,onClick:()=>Xi("settings"),children:"Settings"})]}),d.jsxs("div",{className:"sidebar-content",children:[l==="chats"&&d.jsx("div",{className:"chat-list",children:e.map(u=>d.jsx("div",{className:`chat-item ${u.session_id===n?"active":""}`,onClick:()=>om(u.session_id),children:c===u.session_id?d.jsx("input",{type:"text",className:"rename-input",defaultValue:u.name,onBlur:()=>g(null),onKeyDown:p=>{p.key==="Enter"?mm(u.session_id,p.target.value):p.key==="Escape"&&g(null)},autoFocus:!0}):d.jsxs(d.Fragment,{children:[d.jsx("span",{children:u.name}),d.jsxs("div",{className:"chat-item-buttons",children:[Th.includes(u.session_id)&&d.jsx("div",{className:"unread-dot"}),d.jsx("button",{className:"icon-button",onClick:p=>{p.stopPropagation(),g(u.session_id)},children:d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"feather feather-edit-2",children:d.jsx("path",{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}),d.jsx("button",{className:"icon-button",onClick:p=>{p.stopPropagation(),rc(u.session_id)},children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"feather feather-x",children:[d.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),d.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})},u.session_id))}),l==="dbs"&&d.jsx("div",{className:"db-list",children:k.length===0?d.jsx("div",{className:"empty-list-message",children:"No databases yet."}):k.map(u=>d.jsx("div",{className:`chat-item ${u.slug===v?"active":""}`,onClick:()=>h(u.slug),children:y===u.slug?d.jsx("input",{type:"text",className:"rename-input",defaultValue:u.name,onBlur:()=>w(null),onKeyDown:p=>{p.key==="Enter"?gm(u.slug,p.target.value):p.key==="Escape"&&w(null)},autoFocus:!0}):d.jsxs(d.Fragment,{children:[d.jsx("span",{children:u.name}),d.jsxs("div",{className:"chat-item-buttons",children:[Wt===u.slug&&d.jsx("div",{className:"db-active-badge",children:"Chat"}),Zu(u.slug)&&d.jsx("div",{className:"db-active-badge",children:"Syncing"}),d.jsx("button",{className:"icon-button",onClick:p=>{p.stopPropagation(),w(u.slug)},children:d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"feather feather-edit-2",children:d.jsx("path",{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}),d.jsx("button",{className:"icon-button",onClick:p=>{p.stopPropagation(),vm(u.slug)},children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"feather feather-x",children:[d.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),d.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})},u.slug))}),l==="settings"&&d.jsxs("div",{className:"settings-list",children:[d.jsx("div",{className:`settings-item ${s==="General"?"active":""}`,onClick:()=>a("General"),children:"General"}),d.jsx("div",{className:`settings-item ${s==="Interface"?"active":""}`,onClick:()=>a("Interface"),children:"Interface"}),d.jsx("div",{className:`settings-item ${s==="Websearch"?"active":""}`,onClick:()=>a("Websearch"),children:"Websearch"})]})]}),l!=="settings"&&d.jsxs("div",{className:"sidebar-footer",children:[l==="chats"&&d.jsx("button",{className:"button new-chat-button",onClick:nc,children:"New Chat"}),l==="dbs"&&(L?d.jsxs("div",{className:"new-db-form",children:[d.jsx("input",{type:"text",className:"rename-input",value:$,onChange:u=>D(u.target.value),onKeyDown:u=>{u.key==="Enter"?Ju():u.key==="Escape"&&(A(!1),D(""),U(""))},placeholder:"Database name",autoFocus:!0}),V&&d.jsx("div",{className:"form-error",children:V}),d.jsxs("div",{className:"new-db-actions",children:[d.jsx("button",{className:"button new-db-button",onClick:()=>Ju(),children:"Create"}),d.jsx("button",{className:"button ghost",onClick:()=>{A(!1),D(""),U("")},children:"Cancel"})]})]}):d.jsx("button",{className:"button new-db-button",onClick:()=>{A(!0),U("")},children:"New Database"}))]}),d.jsx("div",{className:"resizer",onMouseDown:nm})]}),d.jsxs("div",{className:`main-content${l==="chats"&<?" main-content--drag-active":""}`,onDragEnter:um,onDragOver:cm,onDragLeave:dm,onDrop:fm,children:[Xr&&d.jsxs("div",{className:"startup-task-banner",role:"status","aria-live":"polite",children:[_&&d.jsx("div",{className:"spinner startup-task-banner__spinner"}),d.jsx("div",{className:"startup-task-banner__text",children:Xr})]}),l==="chats"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"header",children:[d.jsxs("strong",{children:["Chat - ",((lc=e.find(u=>u.session_id===n))==null?void 0:lc.name)||"New Chat"]}),Et&&d.jsx("span",{className:"header-subtle",children:`DB: ${Et.name}${qi}`})]}),d.jsx("div",{className:`chat${lt?" chat--drag-active":""}`,ref:Pe,onClick:ym,children:dr.map((u,p)=>{const S=u.role==="user"&&Mh===p;return d.jsx("div",{id:u.id,className:"msg "+(u.role==="user"?"user":"assistant")+(S?" editing":""),children:u.role==="assistant"?d.jsxs("div",{className:"assistant-message-wrapper",children:[d.jsx(iw,{content:u.content,streamOutput:In,sources:u.sources}),!kt&&d.jsxs("div",{className:"message-options-bar assistant-options",children:[d.jsx("button",{className:"icon-button",title:"Copy message",onClick:()=>Fu(u),children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),d.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}),d.jsx("button",{className:"icon-button",title:"Regenerate response",onClick:()=>Bu(p),children:d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:"M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.3"})})})]})]}):d.jsxs("div",{className:"user-message-wrapper",children:[S?d.jsxs(d.Fragment,{children:[d.jsx(Ms,{attachments:u.attachments,className:"message-attachment-strip"}),d.jsxs("div",{className:"msg-content msg-content--user editing",children:[d.jsx("div",{className:"user-edit-shadow","aria-hidden":"true",children:Ki}),d.jsx(Cd,{className:"edit-message-input edit-overlay",value:Ki,onChange:x=>uo(x.target.value),onBlur:fo,onKeyDown:x=>{x.key==="Escape"&&(x.preventDefault(),fo()),x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),Kh(p))},autoFocus:!0,minRows:1})]})]}):(()=>{const x=u.content||"",T=Array.isArray(u.attachments)?u.attachments:[],M=x.split(/\r\n|\r|\n/),z=M.length>30,W=Qu(u,p,n),J=z?Gh[W]??!0:!1,ke=J?M.slice(0,30).join(` +`)+` +…`:x,ee=!!x.trim();return d.jsxs(d.Fragment,{children:[d.jsx(Ms,{attachments:T,className:"message-attachment-strip"}),ee&&d.jsx("div",{className:"msg-content msg-content--user",children:ke}),ee&&z&&d.jsx("button",{className:"user-msg-expand",onClick:()=>Jh(W),"aria-expanded":J?"false":"true",children:J?"Show entire message":"Collapse"})]})})(),!kt&&!S&&d.jsxs("div",{className:"message-options-bar user-options",children:[d.jsx("button",{className:"icon-button",title:"Edit message",onClick:()=>Vh(p,u.content),children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M12 20h9"}),d.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"})]})}),d.jsx("button",{className:"icon-button",title:"Copy message",onClick:()=>Fu(u),children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),d.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})]})]})},u.id||p)})},n),Vu[n]&&d.jsxs("button",{className:"new-msg-tip",onClick:am,title:"Jump to the new message","aria-label":"Jump to the new message",children:["New message",d.jsx("span",{style:{marginLeft:6},children:"↓"})]}),d.jsx("div",{className:"footer",children:d.jsxs("div",{className:`footer-inner${lt?" footer-inner--drag-active":""}`,children:[d.jsx("input",{ref:pt,type:"file",accept:"image/*",multiple:!0,className:"composer-image-input",onChange:Wh,tabIndex:-1}),d.jsx(Ms,{attachments:rt,className:"composer-attachment-strip",removable:!0,onRemove:zh}),(we||ot)&&d.jsxs("div",{className:"composer-audio-status"+(we?" composer-audio-status--recording":" composer-audio-status--transcribing"),role:"status","aria-live":"polite",children:[we?d.jsx("span",{className:"composer-audio-status__dot","aria-hidden":"true"}):d.jsx("div",{className:"spinner composer-audio-status__spinner","aria-hidden":"true"}),d.jsx("span",{children:we?`Listening ${hw(Bi)}`:"Transcribing audio…"})]}),d.jsxs("div",{className:"footer-content-wrapper",children:[d.jsx(Cd,{ref:Mt,className:"input",value:Z,onChange:u=>se(u.target.value),onKeyDown:u=>{u.key==="Enter"&&!u.shiftKey&&!we&&!ot&&(u.preventDefault(),tc())},placeholder:"Ask any question...",maxRows:13}),d.jsxs("div",{className:"footer-tool-group",ref:tr,children:[d.jsx("button",{type:"button",className:"db-picker-toggle"+(Et?" active":""),onClick:()=>{n&&Ne(u=>!u)},title:Et?`Database: ${Et.name}${qi}`:"Select database for this chat","aria-haspopup":"menu","aria-expanded":ne,disabled:!n,children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("ellipse",{cx:"12",cy:"5",rx:"8",ry:"3"}),d.jsx("path",{d:"M4 5v6c0 1.7 3.6 3 8 3s8-1.3 8-3V5"}),d.jsx("path",{d:"M4 11v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6"})]})}),ne&&d.jsxs("div",{className:"db-picker-menu",role:"menu",children:[d.jsxs("button",{type:"button",className:"db-picker-option"+(Wt?"":" selected"),onClick:()=>{ec(n,null),Ne(!1)},children:[d.jsx("span",{children:"No database"}),!Wt&&d.jsx("span",{className:"db-picker-status",children:"Selected"})]}),k.length===0?d.jsx("div",{className:"db-picker-empty",children:"No databases yet."}):k.map(u=>{var T,M,z;const p=Wt===u.slug,S=Zu(u.slug),x=(T=u.files)!=null&&T.length?(M=u.states)!=null&&M.is_indexed?"Ready":S?"Syncing":"Needs sync":"Empty";return d.jsxs("button",{type:"button",className:"db-picker-option"+(p?" selected":""),disabled:!((z=u.files)!=null&&z.length),onClick:()=>{ec(n,u.slug),Ne(!1)},children:[d.jsx("span",{children:u.name}),d.jsx("span",{className:"db-picker-status",children:p?"Selected":x})]},u.slug)})]})]}),b&&d.jsx("button",{type:"button",className:"image-attach-toggle"+(rt.length>0?" active":""),onClick:bh,title:"Attach images","aria-label":"Attach images",children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),d.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),d.jsx("path",{d:"M21 15l-5-5L5 21"})]})}),on&&d.jsx("button",{type:"button",className:"audio-input-toggle"+(we||ot?" active":"")+(we?" recording":"")+(ot?" transcribing":""),onClick:Hh,title:It?we?"Stop voice input":ot?"Transcribing audio":"Start voice input":to||"Whisper is not available for audio input.","aria-label":It?we?"Stop voice input":ot?"Transcribing audio":"Start voice input":to||"Whisper is not available for audio input.","aria-pressed":we,disabled:!It||ot||kt,children:ot?d.jsx("div",{className:"spinner composer-audio-icon-spinner","aria-hidden":"true"}):d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("path",{d:"M12 3a3 3 0 0 1 3 3v6a3 3 0 0 1-6 0V6a3 3 0 0 1 3-3z"}),d.jsx("path",{d:"M19 10a7 7 0 0 1-14 0"}),d.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"22"}),d.jsx("line",{x1:"8",y1:"22",x2:"16",y2:"22"})]})}),d.jsx("button",{type:"button",className:"websearch-toggle"+(so?" active":""),onClick:pm,title:"Toggle web search","aria-pressed":so,children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("circle",{cx:"12",cy:"12",r:"10"}),d.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),d.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})}),d.jsx("button",{className:"button",onClick:kt?Zh:tc,title:kt?"Cancel generation":"Send","aria-label":kt?"Cancel generation":"Send",disabled:!kt&&(we||ot),children:kt?d.jsx("div",{className:"spinner"}):"Send"})]})]})})]}),l==="dbs"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"header",children:[d.jsx("strong",{children:(mo==null?void 0:mo.name)||"Databases"}),Et&&d.jsx("span",{className:"header-subtle",children:`Current chat DB: ${Et.name}${qi}`})]}),d.jsx(q0,{apiBase:K,library:mo,jobs:N,onRefresh:async()=>{await nl(),await ho()}})]}),l==="settings"&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"header",children:d.jsxs("strong",{children:[s," Settings"]})}),s==="General"&&d.jsx(V0,{onModelChange:ft,onVisionModelChange:B,onTranscriptionModelChange:I,onBackendApiUrlChange:lo,streamOutput:In,onStreamOutputChange:Jr,onAudioInputEnabledChange:Vr,onAudioInputDeviceChange:Kr,onAudioInputLanguageChange:nr,onLibrariesPurged:lm}),s==="Interface"&&d.jsx(J0,{}),s==="Websearch"&&d.jsx(nw,{searxUrl:ae,setSearxUrl:mt,engines:Bt,setEngines:u=>jh(ki(u))})]})]})]})}function gw(){return f.useEffect(()=>{window.electronAPI.getSettings().then(e=>{Wl(e.colorScheme||"Default")})},[]),d.jsx(We.StrictMode,{children:d.jsx(i0,{children:d.jsx(Dy,{children:d.jsx(mh,{path:"/",element:d.jsx(mw,{})})})})})}const vw=rh(document.getElementById("root"));vw.render(d.jsx(gw,{})); diff --git a/dist/assets/index-g7N0HjkK.js b/dist/assets/index-g7N0HjkK.js deleted file mode 100644 index ea44a81..0000000 --- a/dist/assets/index-g7N0HjkK.js +++ /dev/null @@ -1,88 +0,0 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const o of l)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(l){const o={};return l.integrity&&(o.integrity=l.integrity),l.referrerPolicy&&(o.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?o.credentials="include":l.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(l){if(l.ep)return;l.ep=!0;const o=n(l);fetch(l.href,o)}})();function am(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var jd={exports:{}},li={},Td={exports:{}},Y={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Cl=Symbol.for("react.element"),um=Symbol.for("react.portal"),cm=Symbol.for("react.fragment"),dm=Symbol.for("react.strict_mode"),fm=Symbol.for("react.profiler"),pm=Symbol.for("react.provider"),hm=Symbol.for("react.context"),mm=Symbol.for("react.forward_ref"),gm=Symbol.for("react.suspense"),vm=Symbol.for("react.memo"),ym=Symbol.for("react.lazy"),Yu=Symbol.iterator;function wm(e){return e===null||typeof e!="object"?null:(e=Yu&&e[Yu]||e["@@iterator"],typeof e=="function"?e:null)}var Pd={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Id=Object.assign,$d={};function xr(e,t,n){this.props=e,this.context=t,this.refs=$d,this.updater=n||Pd}xr.prototype.isReactComponent={};xr.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};xr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Md(){}Md.prototype=xr.prototype;function Sa(e,t,n){this.props=e,this.context=t,this.refs=$d,this.updater=n||Pd}var xa=Sa.prototype=new Md;xa.constructor=Sa;Id(xa,xr.prototype);xa.isPureReactComponent=!0;var Ju=Array.isArray,Ad=Object.prototype.hasOwnProperty,ka={current:null},Od={key:!0,ref:!0,__self:!0,__source:!0};function Dd(e,t,n){var r,l={},o=null,i=null;if(t!=null)for(r in t.ref!==void 0&&(i=t.ref),t.key!==void 0&&(o=""+t.key),t)Ad.call(t,r)&&!Od.hasOwnProperty(r)&&(l[r]=t[r]);var s=arguments.length-2;if(s===1)l.children=n;else if(1>>1,re=P[q];if(0>>1;ql(Gt,W))utl(tt,Gt)?(P[q]=tt,P[ut]=W,q=ut):(P[q]=Gt,P[$e]=W,q=$e);else if(utl(tt,W))P[q]=tt,P[ut]=W,q=ut;else break e}}return B}function l(P,B){var W=P.sortIndex-B.sortIndex;return W!==0?W:P.id-B.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var i=Date,s=i.now();e.unstable_now=function(){return i.now()-s}}var a=[],c=[],g=1,y=null,w=3,k=!1,E=!1,N=!1,L=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,h=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function m(P){for(var B=n(c);B!==null;){if(B.callback===null)r(c);else if(B.startTime<=P)r(c),B.sortIndex=B.expirationTime,t(a,B);else break;B=n(c)}}function C(P){if(N=!1,m(P),!E)if(n(a)!==null)E=!0,b(T);else{var B=n(c);B!==null&&X(C,B.startTime-P)}}function T(P,B){E=!1,N&&(N=!1,v(A),A=-1),k=!0;var W=w;try{for(m(B),y=n(a);y!==null&&(!(y.expirationTime>B)||P&&!se());){var q=y.callback;if(typeof q=="function"){y.callback=null,w=y.priorityLevel;var re=q(y.expirationTime<=B);B=e.unstable_now(),typeof re=="function"?y.callback=re:y===n(a)&&r(a),m(B)}else r(a);y=n(a)}if(y!==null)var we=!0;else{var $e=n(c);$e!==null&&X(C,$e.startTime-B),we=!1}return we}finally{y=null,w=W,k=!1}}var I=!1,M=null,A=-1,V=5,U=-1;function se(){return!(e.unstable_now()-UP||125q?(P.sortIndex=W,t(c,P),n(a)===null&&P===n(c)&&(N?(v(A),A=-1):N=!0,X(C,W-q))):(P.sortIndex=re,t(a,P),E||k||(E=!0,b(T))),P},e.unstable_shouldYield=se,e.unstable_wrapCallback=function(P){var B=w;return function(){var W=w;w=B;try{return P.apply(this,arguments)}finally{w=W}}}})(Bd);bd.exports=Bd;var Tm=bd.exports;/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Pm=f,it=Tm;function j(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),xs=Object.prototype.hasOwnProperty,Im=/^[: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]*$/,qu={},Zu={};function $m(e){return xs.call(Zu,e)?!0:xs.call(qu,e)?!1:Im.test(e)?Zu[e]=!0:(qu[e]=!0,!1)}function Mm(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Am(e,t,n,r){if(t===null||typeof t>"u"||Mm(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Ye(e,t,n,r,l,o,i){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=i}var Oe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Oe[e]=new Ye(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Oe[t]=new Ye(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Oe[e]=new Ye(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Oe[e]=new Ye(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Oe[e]=new Ye(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Oe[e]=new Ye(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Oe[e]=new Ye(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Oe[e]=new Ye(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Oe[e]=new Ye(e,5,!1,e.toLowerCase(),null,!1,!1)});var Ca=/[\-:]([a-z])/g;function Na(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Ca,Na);Oe[t]=new Ye(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Ca,Na);Oe[t]=new Ye(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Ca,Na);Oe[t]=new Ye(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Oe[e]=new Ye(e,1,!1,e.toLowerCase(),null,!1,!1)});Oe.xlinkHref=new Ye("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Oe[e]=new Ye(e,1,!1,e.toLowerCase(),null,!0,!0)});function _a(e,t,n,r){var l=Oe.hasOwnProperty(t)?Oe[t]:null;(l!==null?l.type!==0:r||!(2s||l[i]!==o[s]){var a=` -`+l[i].replace(" at new "," at ");return e.displayName&&a.includes("")&&(a=a.replace("",e.displayName)),a}while(1<=i&&0<=s);break}}}finally{Hi=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Kr(e):""}function Om(e){switch(e.tag){case 5:return Kr(e.type);case 16:return Kr("Lazy");case 13:return Kr("Suspense");case 19:return Kr("SuspenseList");case 0:case 2:case 15:return e=Wi(e.type,!1),e;case 11:return e=Wi(e.type.render,!1),e;case 1:return e=Wi(e.type,!0),e;default:return""}}function Ns(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Xn:return"Fragment";case Jn:return"Portal";case ks:return"Profiler";case Ra:return"StrictMode";case Es:return"Suspense";case Cs:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Vd:return(e.displayName||"Context")+".Consumer";case Wd:return(e._context.displayName||"Context")+".Provider";case La:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ja:return t=e.displayName||null,t!==null?t:Ns(e.type)||"Memo";case Zt:t=e._payload,e=e._init;try{return Ns(e(t))}catch{}}return null}function Dm(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Ns(t);case 8:return t===Ra?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function hn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Qd(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Fm(e){var t=Qd(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var l=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(i){r=""+i,o.call(this,i)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(i){r=""+i},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function ql(e){e._valueTracker||(e._valueTracker=Fm(e))}function Gd(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Qd(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Io(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function _s(e,t){var n=t.checked;return ye({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function tc(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=hn(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Yd(e,t){t=t.checked,t!=null&&_a(e,"checked",t,!1)}function Rs(e,t){Yd(e,t);var n=hn(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Ls(e,t.type,n):t.hasOwnProperty("defaultValue")&&Ls(e,t.type,hn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function nc(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Ls(e,t,n){(t!=="number"||Io(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Qr=Array.isArray;function ar(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=Zl.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function il(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Jr={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},zm=["Webkit","ms","Moz","O"];Object.keys(Jr).forEach(function(e){zm.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Jr[t]=Jr[e]})});function Zd(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Jr.hasOwnProperty(e)&&Jr[e]?(""+t).trim():t+"px"}function ef(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=Zd(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var Um=ye({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ps(e,t){if(t){if(Um[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(j(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(j(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(j(61))}if(t.style!=null&&typeof t.style!="object")throw Error(j(62))}}function Is(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";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 $s=null;function Ta(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ms=null,ur=null,cr=null;function oc(e){if(e=Rl(e)){if(typeof Ms!="function")throw Error(j(280));var t=e.stateNode;t&&(t=ui(t),Ms(e.stateNode,e.type,t))}}function tf(e){ur?cr?cr.push(e):cr=[e]:ur=e}function nf(){if(ur){var e=ur,t=cr;if(cr=ur=null,oc(e),t)for(e=0;e>>=0,e===0?32:31-(Xm(e)/qm|0)|0}var eo=64,to=4194304;function Gr(e){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: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 e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Oo(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,o=e.pingedLanes,i=n&268435455;if(i!==0){var s=i&~l;s!==0?r=Gr(s):(o&=i,o!==0&&(r=Gr(o)))}else i=n&~l,i!==0?r=Gr(i):o!==0&&(r=Gr(o));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,o=t&-t,l>=o||l===16&&(o&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Nl(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-kt(t),e[t]=n}function ng(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=qr),hc=" ",mc=!1;function Ef(e,t){switch(e){case"keyup":return Tg.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Cf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var qn=!1;function Ig(e,t){switch(e){case"compositionend":return Cf(t);case"keypress":return t.which!==32?null:(mc=!0,hc);case"textInput":return e=t.data,e===hc&&mc?null:e;default:return null}}function $g(e,t){if(qn)return e==="compositionend"||!Fa&&Ef(e,t)?(e=xf(),So=Aa=rn=null,qn=!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)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=wc(n)}}function Lf(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Lf(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function jf(){for(var e=window,t=Io();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Io(e.document)}return t}function za(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")}function Bg(e){var t=jf(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Lf(n.ownerDocument.documentElement,n)){if(r!==null&&za(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=n.textContent.length,o=Math.min(r.start,l);r=r.end===void 0?o:Math.min(r.end,l),!e.extend&&o>r&&(l=r,r=o,o=l),l=Sc(n,o);var i=Sc(n,r);l&&i&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==i.node||e.focusOffset!==i.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(i.node,i.offset)):(t.setEnd(i.node,i.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Zn=null,Us=null,el=null,bs=!1;function xc(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;bs||Zn==null||Zn!==Io(r)||(r=Zn,"selectionStart"in r&&za(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}),el&&fl(el,r)||(el=r,r=zo(Us,"onSelect"),0nr||(e.current=Qs[nr],Qs[nr]=null,nr--)}function ie(e,t){nr++,Qs[nr]=e.current,e.current=t}var mn={},Be=vn(mn),qe=vn(!1),In=mn;function mr(e,t){var n=e.type.contextTypes;if(!n)return mn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},o;for(o in n)l[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function Ze(e){return e=e.childContextTypes,e!=null}function bo(){de(qe),de(Be)}function Lc(e,t,n){if(Be.current!==mn)throw Error(j(168));ie(Be,t),ie(qe,n)}function Ff(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(j(108,Dm(e)||"Unknown",l));return ye({},n,r)}function Bo(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||mn,In=Be.current,ie(Be,e),ie(qe,qe.current),!0}function jc(e,t,n){var r=e.stateNode;if(!r)throw Error(j(169));n?(e=Ff(e,t,In),r.__reactInternalMemoizedMergedChildContext=e,de(qe),de(Be),ie(Be,e)):de(qe),ie(qe,n)}var Ot=null,ci=!1,ls=!1;function zf(e){Ot===null?Ot=[e]:Ot.push(e)}function ev(e){ci=!0,zf(e)}function yn(){if(!ls&&Ot!==null){ls=!0;var e=0,t=ne;try{var n=Ot;for(ne=1;e>=i,l-=i,Dt=1<<32-kt(t)+l|n<A?(V=M,M=null):V=M.sibling;var U=w(v,M,m[A],C);if(U===null){M===null&&(M=V);break}e&&M&&U.alternate===null&&t(v,M),h=o(U,h,A),I===null?T=U:I.sibling=U,I=U,M=V}if(A===m.length)return n(v,M),pe&&Nn(v,A),T;if(M===null){for(;AA?(V=M,M=null):V=M.sibling;var se=w(v,M,U.value,C);if(se===null){M===null&&(M=V);break}e&&M&&se.alternate===null&&t(v,M),h=o(se,h,A),I===null?T=se:I.sibling=se,I=se,M=V}if(U.done)return n(v,M),pe&&Nn(v,A),T;if(M===null){for(;!U.done;A++,U=m.next())U=y(v,U.value,C),U!==null&&(h=o(U,h,A),I===null?T=U:I.sibling=U,I=U);return pe&&Nn(v,A),T}for(M=r(v,M);!U.done;A++,U=m.next())U=k(M,v,A,U.value,C),U!==null&&(e&&U.alternate!==null&&M.delete(U.key===null?A:U.key),h=o(U,h,A),I===null?T=U:I.sibling=U,I=U);return e&&M.forEach(function(Le){return t(v,Le)}),pe&&Nn(v,A),T}function L(v,h,m,C){if(typeof m=="object"&&m!==null&&m.type===Xn&&m.key===null&&(m=m.props.children),typeof m=="object"&&m!==null){switch(m.$$typeof){case Xl:e:{for(var T=m.key,I=h;I!==null;){if(I.key===T){if(T=m.type,T===Xn){if(I.tag===7){n(v,I.sibling),h=l(I,m.props.children),h.return=v,v=h;break e}}else if(I.elementType===T||typeof T=="object"&&T!==null&&T.$$typeof===Zt&&Ic(T)===I.type){n(v,I.sibling),h=l(I,m.props),h.ref=br(v,I,m),h.return=v,v=h;break e}n(v,I);break}else t(v,I);I=I.sibling}m.type===Xn?(h=Pn(m.props.children,v.mode,C,m.key),h.return=v,v=h):(C=Lo(m.type,m.key,m.props,null,v.mode,C),C.ref=br(v,h,m),C.return=v,v=C)}return i(v);case Jn:e:{for(I=m.key;h!==null;){if(h.key===I)if(h.tag===4&&h.stateNode.containerInfo===m.containerInfo&&h.stateNode.implementation===m.implementation){n(v,h.sibling),h=l(h,m.children||[]),h.return=v,v=h;break e}else{n(v,h);break}else t(v,h);h=h.sibling}h=fs(m,v.mode,C),h.return=v,v=h}return i(v);case Zt:return I=m._init,L(v,h,I(m._payload),C)}if(Qr(m))return E(v,h,m,C);if(Or(m))return N(v,h,m,C);ao(v,m)}return typeof m=="string"&&m!==""||typeof m=="number"?(m=""+m,h!==null&&h.tag===6?(n(v,h.sibling),h=l(h,m),h.return=v,v=h):(n(v,h),h=ds(m,v.mode,C),h.return=v,v=h),i(v)):n(v,h)}return L}var vr=Hf(!0),Wf=Hf(!1),Vo=vn(null),Ko=null,or=null,Ha=null;function Wa(){Ha=or=Ko=null}function Va(e){var t=Vo.current;de(Vo),e._currentValue=t}function Js(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function fr(e,t){Ko=e,Ha=or=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Xe=!0),e.firstContext=null)}function ht(e){var t=e._currentValue;if(Ha!==e)if(e={context:e,memoizedValue:t,next:null},or===null){if(Ko===null)throw Error(j(308));or=e,Ko.dependencies={lanes:0,firstContext:e}}else or=or.next=e;return t}var Ln=null;function Ka(e){Ln===null?Ln=[e]:Ln.push(e)}function Vf(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,Ka(t)):(n.next=l.next,l.next=n),t.interleaved=n,Ht(e,r)}function Ht(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var en=!1;function Qa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Kf(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function zt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function cn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,ee&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,Ht(e,n)}return l=r.interleaved,l===null?(t.next=t,Ka(r)):(t.next=l.next,l.next=t),r.interleaved=t,Ht(e,n)}function ko(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ia(e,n)}}function $c(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var i={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?l=o=i:o=o.next=i,n=n.next}while(n!==null);o===null?l=o=t:o=o.next=t}else l=o=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:o,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Qo(e,t,n,r){var l=e.updateQueue;en=!1;var o=l.firstBaseUpdate,i=l.lastBaseUpdate,s=l.shared.pending;if(s!==null){l.shared.pending=null;var a=s,c=a.next;a.next=null,i===null?o=c:i.next=c,i=a;var g=e.alternate;g!==null&&(g=g.updateQueue,s=g.lastBaseUpdate,s!==i&&(s===null?g.firstBaseUpdate=c:s.next=c,g.lastBaseUpdate=a))}if(o!==null){var y=l.baseState;i=0,g=c=a=null,s=o;do{var w=s.lane,k=s.eventTime;if((r&w)===w){g!==null&&(g=g.next={eventTime:k,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});e:{var E=e,N=s;switch(w=t,k=n,N.tag){case 1:if(E=N.payload,typeof E=="function"){y=E.call(k,y,w);break e}y=E;break e;case 3:E.flags=E.flags&-65537|128;case 0:if(E=N.payload,w=typeof E=="function"?E.call(k,y,w):E,w==null)break e;y=ye({},y,w);break e;case 2:en=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,w=l.effects,w===null?l.effects=[s]:w.push(s))}else k={eventTime:k,lane:w,tag:s.tag,payload:s.payload,callback:s.callback,next:null},g===null?(c=g=k,a=y):g=g.next=k,i|=w;if(s=s.next,s===null){if(s=l.shared.pending,s===null)break;w=s,s=w.next,w.next=null,l.lastBaseUpdate=w,l.shared.pending=null}}while(!0);if(g===null&&(a=y),l.baseState=a,l.firstBaseUpdate=c,l.lastBaseUpdate=g,t=l.shared.interleaved,t!==null){l=t;do i|=l.lane,l=l.next;while(l!==t)}else o===null&&(l.shared.lanes=0);An|=i,e.lanes=i,e.memoizedState=y}}function Mc(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=is.transition;is.transition={};try{e(!1),t()}finally{ne=n,is.transition=r}}function up(){return mt().memoizedState}function lv(e,t,n){var r=fn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},cp(e))dp(t,n);else if(n=Vf(e,t,n,r),n!==null){var l=Qe();Et(n,e,r,l),fp(n,t,r)}}function ov(e,t,n){var r=fn(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(cp(e))dp(t,l);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var i=t.lastRenderedState,s=o(i,n);if(l.hasEagerState=!0,l.eagerState=s,Ct(s,i)){var a=t.interleaved;a===null?(l.next=l,Ka(t)):(l.next=a.next,a.next=l),t.interleaved=l;return}}catch{}finally{}n=Vf(e,t,l,r),n!==null&&(l=Qe(),Et(n,e,r,l),fp(n,t,r))}}function cp(e){var t=e.alternate;return e===ge||t!==null&&t===ge}function dp(e,t){tl=Yo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function fp(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ia(e,n)}}var Jo={readContext:ht,useCallback:ze,useContext:ze,useEffect:ze,useImperativeHandle:ze,useInsertionEffect:ze,useLayoutEffect:ze,useMemo:ze,useReducer:ze,useRef:ze,useState:ze,useDebugValue:ze,useDeferredValue:ze,useTransition:ze,useMutableSource:ze,useSyncExternalStore:ze,useId:ze,unstable_isNewReconciler:!1},iv={readContext:ht,useCallback:function(e,t){return Lt().memoizedState=[e,t===void 0?null:t],e},useContext:ht,useEffect:Oc,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Co(4194308,4,lp.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Co(4194308,4,e,t)},useInsertionEffect:function(e,t){return Co(4,2,e,t)},useMemo:function(e,t){var n=Lt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Lt();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=lv.bind(null,ge,e),[r.memoizedState,e]},useRef:function(e){var t=Lt();return e={current:e},t.memoizedState=e},useState:Ac,useDebugValue:tu,useDeferredValue:function(e){return Lt().memoizedState=e},useTransition:function(){var e=Ac(!1),t=e[0];return e=rv.bind(null,e[1]),Lt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=ge,l=Lt();if(pe){if(n===void 0)throw Error(j(407));n=n()}else{if(n=t(),Ie===null)throw Error(j(349));Mn&30||Jf(r,t,n)}l.memoizedState=n;var o={value:n,getSnapshot:t};return l.queue=o,Oc(qf.bind(null,r,o,e),[e]),r.flags|=2048,Sl(9,Xf.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=Lt(),t=Ie.identifierPrefix;if(pe){var n=Ft,r=Dt;n=(r&~(1<<32-kt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=yl++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=i.createElement(n,{is:r.is}):(e=i.createElement(n),n==="select"&&(i=e,r.multiple?i.multiple=!0:r.size&&(i.size=r.size))):e=i.createElementNS(e,n),e[jt]=t,e[ml]=r,kp(e,t,!1,!1),t.stateNode=e;e:{switch(i=Is(n,r),n){case"dialog":ce("cancel",e),ce("close",e),l=r;break;case"iframe":case"object":case"embed":ce("load",e),l=r;break;case"video":case"audio":for(l=0;lSr&&(t.flags|=128,r=!0,Br(o,!1),t.lanes=4194304)}else{if(!r)if(e=Go(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Br(o,!0),o.tail===null&&o.tailMode==="hidden"&&!i.alternate&&!pe)return Ue(t),null}else 2*ke()-o.renderingStartTime>Sr&&n!==1073741824&&(t.flags|=128,r=!0,Br(o,!1),t.lanes=4194304);o.isBackwards?(i.sibling=t.child,t.child=i):(n=o.last,n!==null?n.sibling=i:t.child=i,o.last=i)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=ke(),t.sibling=null,n=me.current,ie(me,r?n&1|2:n&1),t):(Ue(t),null);case 22:case 23:return su(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?rt&1073741824&&(Ue(t),t.subtreeFlags&6&&(t.flags|=8192)):Ue(t),null;case 24:return null;case 25:return null}throw Error(j(156,t.tag))}function hv(e,t){switch(ba(t),t.tag){case 1:return Ze(t.type)&&bo(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return yr(),de(qe),de(Be),Ja(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Ya(t),null;case 13:if(de(me),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(j(340));gr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return de(me),null;case 4:return yr(),null;case 10:return Va(t.type._context),null;case 22:case 23:return su(),null;case 24:return null;default:return null}}var co=!1,be=!1,mv=typeof WeakSet=="function"?WeakSet:Set,O=null;function ir(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Se(e,t,r)}else n.current=null}function oa(e,t,n){try{n()}catch(r){Se(e,t,r)}}var Qc=!1;function gv(e,t){if(Bs=Do,e=jf(),za(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var i=0,s=-1,a=-1,c=0,g=0,y=e,w=null;t:for(;;){for(var k;y!==n||l!==0&&y.nodeType!==3||(s=i+l),y!==o||r!==0&&y.nodeType!==3||(a=i+r),y.nodeType===3&&(i+=y.nodeValue.length),(k=y.firstChild)!==null;)w=y,y=k;for(;;){if(y===e)break t;if(w===n&&++c===l&&(s=i),w===o&&++g===r&&(a=i),(k=y.nextSibling)!==null)break;y=w,w=y.parentNode}y=k}n=s===-1||a===-1?null:{start:s,end:a}}else n=null}n=n||{start:0,end:0}}else n=null;for(Hs={focusedElem:e,selectionRange:n},Do=!1,O=t;O!==null;)if(t=O,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,O=e;else for(;O!==null;){t=O;try{var E=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(E!==null){var N=E.memoizedProps,L=E.memoizedState,v=t.stateNode,h=v.getSnapshotBeforeUpdate(t.elementType===t.type?N:wt(t.type,N),L);v.__reactInternalSnapshotBeforeUpdate=h}break;case 3:var m=t.stateNode.containerInfo;m.nodeType===1?m.textContent="":m.nodeType===9&&m.documentElement&&m.removeChild(m.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(j(163))}}catch(C){Se(t,t.return,C)}if(e=t.sibling,e!==null){e.return=t.return,O=e;break}O=t.return}return E=Qc,Qc=!1,E}function nl(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var o=l.destroy;l.destroy=void 0,o!==void 0&&oa(t,n,o)}l=l.next}while(l!==r)}}function pi(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function ia(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Np(e){var t=e.alternate;t!==null&&(e.alternate=null,Np(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[jt],delete t[ml],delete t[Ks],delete t[qg],delete t[Zg])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function _p(e){return e.tag===5||e.tag===3||e.tag===4}function Gc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||_p(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.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function sa(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Uo));else if(r!==4&&(e=e.child,e!==null))for(sa(e,t,n),e=e.sibling;e!==null;)sa(e,t,n),e=e.sibling}function aa(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(aa(e,t,n),e=e.sibling;e!==null;)aa(e,t,n),e=e.sibling}var Me=null,St=!1;function qt(e,t,n){for(n=n.child;n!==null;)Rp(e,t,n),n=n.sibling}function Rp(e,t,n){if(Tt&&typeof Tt.onCommitFiberUnmount=="function")try{Tt.onCommitFiberUnmount(oi,n)}catch{}switch(n.tag){case 5:be||ir(n,t);case 6:var r=Me,l=St;Me=null,qt(e,t,n),Me=r,St=l,Me!==null&&(St?(e=Me,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Me.removeChild(n.stateNode));break;case 18:Me!==null&&(St?(e=Me,n=n.stateNode,e.nodeType===8?rs(e.parentNode,n):e.nodeType===1&&rs(e,n),cl(e)):rs(Me,n.stateNode));break;case 4:r=Me,l=St,Me=n.stateNode.containerInfo,St=!0,qt(e,t,n),Me=r,St=l;break;case 0:case 11:case 14:case 15:if(!be&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var o=l,i=o.destroy;o=o.tag,i!==void 0&&(o&2||o&4)&&oa(n,t,i),l=l.next}while(l!==r)}qt(e,t,n);break;case 1:if(!be&&(ir(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(s){Se(n,t,s)}qt(e,t,n);break;case 21:qt(e,t,n);break;case 22:n.mode&1?(be=(r=be)||n.memoizedState!==null,qt(e,t,n),be=r):qt(e,t,n);break;default:qt(e,t,n)}}function Yc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new mv),t.forEach(function(r){var l=Nv.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function yt(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=i),r&=~o}if(r=l,r=ke()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*yv(r/1960))-r,10e?16:e,ln===null)var r=!1;else{if(e=ln,ln=null,Zo=0,ee&6)throw Error(j(331));var l=ee;for(ee|=4,O=e.current;O!==null;){var o=O,i=o.child;if(O.flags&16){var s=o.deletions;if(s!==null){for(var a=0;ake()-ou?Tn(e,0):lu|=n),et(e,t)}function Ap(e,t){t===0&&(e.mode&1?(t=to,to<<=1,!(to&130023424)&&(to=4194304)):t=1);var n=Qe();e=Ht(e,t),e!==null&&(Nl(e,t,n),et(e,n))}function Cv(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ap(e,n)}function Nv(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(j(314))}r!==null&&r.delete(t),Ap(e,n)}var Op;Op=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||qe.current)Xe=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Xe=!1,fv(e,t,n);Xe=!!(e.flags&131072)}else Xe=!1,pe&&t.flags&1048576&&Uf(t,Wo,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;No(e,t),e=t.pendingProps;var l=mr(t,Be.current);fr(t,n),l=qa(null,t,r,e,l,n);var o=Za();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Ze(r)?(o=!0,Bo(t)):o=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,Qa(t),l.updater=fi,t.stateNode=l,l._reactInternals=t,qs(t,r,e,n),t=ta(null,t,r,!0,o,n)):(t.tag=0,pe&&o&&Ua(t),Ke(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(No(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=Rv(r),e=wt(r,e),l){case 0:t=ea(null,t,r,e,n);break e;case 1:t=Wc(null,t,r,e,n);break e;case 11:t=Bc(null,t,r,e,n);break e;case 14:t=Hc(null,t,r,wt(r.type,e),n);break e}throw Error(j(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:wt(r,l),ea(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:wt(r,l),Wc(e,t,r,l,n);case 3:e:{if(wp(t),e===null)throw Error(j(387));r=t.pendingProps,o=t.memoizedState,l=o.element,Kf(e,t),Qo(t,r,null,n);var i=t.memoizedState;if(r=i.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){l=wr(Error(j(423)),t),t=Vc(e,t,r,n,l);break e}else if(r!==l){l=wr(Error(j(424)),t),t=Vc(e,t,r,n,l);break e}else for(lt=un(t.stateNode.containerInfo.firstChild),ot=t,pe=!0,xt=null,n=Wf(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(gr(),r===l){t=Wt(e,t,n);break e}Ke(e,t,r,n)}t=t.child}return t;case 5:return Qf(t),e===null&&Ys(t),r=t.type,l=t.pendingProps,o=e!==null?e.memoizedProps:null,i=l.children,Ws(r,l)?i=null:o!==null&&Ws(r,o)&&(t.flags|=32),yp(e,t),Ke(e,t,i,n),t.child;case 6:return e===null&&Ys(t),null;case 13:return Sp(e,t,n);case 4:return Ga(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=vr(t,null,r,n):Ke(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:wt(r,l),Bc(e,t,r,l,n);case 7:return Ke(e,t,t.pendingProps,n),t.child;case 8:return Ke(e,t,t.pendingProps.children,n),t.child;case 12:return Ke(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,o=t.memoizedProps,i=l.value,ie(Vo,r._currentValue),r._currentValue=i,o!==null)if(Ct(o.value,i)){if(o.children===l.children&&!qe.current){t=Wt(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var s=o.dependencies;if(s!==null){i=o.child;for(var a=s.firstContext;a!==null;){if(a.context===r){if(o.tag===1){a=zt(-1,n&-n),a.tag=2;var c=o.updateQueue;if(c!==null){c=c.shared;var g=c.pending;g===null?a.next=a:(a.next=g.next,g.next=a),c.pending=a}}o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),Js(o.return,n,t),s.lanes|=n;break}a=a.next}}else if(o.tag===10)i=o.type===t.type?null:o.child;else if(o.tag===18){if(i=o.return,i===null)throw Error(j(341));i.lanes|=n,s=i.alternate,s!==null&&(s.lanes|=n),Js(i,n,t),i=o.sibling}else i=o.child;if(i!==null)i.return=o;else for(i=o;i!==null;){if(i===t){i=null;break}if(o=i.sibling,o!==null){o.return=i.return,i=o;break}i=i.return}o=i}Ke(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,fr(t,n),l=ht(l),r=r(l),t.flags|=1,Ke(e,t,r,n),t.child;case 14:return r=t.type,l=wt(r,t.pendingProps),l=wt(r.type,l),Hc(e,t,r,l,n);case 15:return gp(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:wt(r,l),No(e,t),t.tag=1,Ze(r)?(e=!0,Bo(t)):e=!1,fr(t,n),pp(t,r,l),qs(t,r,l,n),ta(null,t,r,!0,e,n);case 19:return xp(e,t,n);case 22:return vp(e,t,n)}throw Error(j(156,t.tag))};function Dp(e,t){return cf(e,t)}function _v(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.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 ft(e,t,n,r){return new _v(e,t,n,r)}function uu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Rv(e){if(typeof e=="function")return uu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===La)return 11;if(e===ja)return 14}return 2}function pn(e,t){var n=e.alternate;return n===null?(n=ft(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&14680064,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}function Lo(e,t,n,r,l,o){var i=2;if(r=e,typeof e=="function")uu(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case Xn:return Pn(n.children,l,o,t);case Ra:i=8,l|=8;break;case ks:return e=ft(12,n,t,l|2),e.elementType=ks,e.lanes=o,e;case Es:return e=ft(13,n,t,l),e.elementType=Es,e.lanes=o,e;case Cs:return e=ft(19,n,t,l),e.elementType=Cs,e.lanes=o,e;case Kd:return mi(n,l,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Wd:i=10;break e;case Vd:i=9;break e;case La:i=11;break e;case ja:i=14;break e;case Zt:i=16,r=null;break e}throw Error(j(130,e==null?e:typeof e,""))}return t=ft(i,n,t,l),t.elementType=e,t.type=r,t.lanes=o,t}function Pn(e,t,n,r){return e=ft(7,e,r,t),e.lanes=n,e}function mi(e,t,n,r){return e=ft(22,e,r,t),e.elementType=Kd,e.lanes=n,e.stateNode={isHidden:!1},e}function ds(e,t,n){return e=ft(6,e,null,t),e.lanes=n,e}function fs(e,t,n){return t=ft(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Lv(e,t,n,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ki(0),this.expirationTimes=Ki(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ki(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function cu(e,t,n,r,l,o,i,s,a){return e=new Lv(e,t,n,s,a),t===1?(t=1,o===!0&&(t|=8)):t=0,o=ft(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Qa(o),e}function jv(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(bp)}catch(e){console.error(e)}}bp(),Ud.exports=st;var Bp=Ud.exports,Hp,rd=Bp;Hp=rd.createRoot,rd.hydrateRoot;/** - * react-router v7.8.2 - * - * Copyright (c) Remix Software Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE.md file in the root directory of this source tree. - * - * @license MIT - */var ld="popstate";function Mv(e={}){function t(l,o){let{pathname:i="/",search:s="",hash:a=""}=zn(l.location.hash.substring(1));return!i.startsWith("/")&&!i.startsWith(".")&&(i="/"+i),pa("",{pathname:i,search:s,hash:a},o.state&&o.state.usr||null,o.state&&o.state.key||"default")}function n(l,o){let i=l.document.querySelector("base"),s="";if(i&&i.getAttribute("href")){let a=l.location.href,c=a.indexOf("#");s=c===-1?a:a.slice(0,c)}return s+"#"+(typeof o=="string"?o:kl(o))}function r(l,o){Nt(l.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(o)})`)}return Ov(t,n,r,e)}function ve(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Nt(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Av(){return Math.random().toString(36).substring(2,10)}function od(e,t){return{usr:e.state,key:e.key,idx:t}}function pa(e,t,n=null,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?zn(t):t,state:n,key:t&&t.key||r||Av()}}function kl({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function zn(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function Ov(e,t,n,r={}){let{window:l=document.defaultView,v5Compat:o=!1}=r,i=l.history,s="POP",a=null,c=g();c==null&&(c=0,i.replaceState({...i.state,idx:c},""));function g(){return(i.state||{idx:null}).idx}function y(){s="POP";let L=g(),v=L==null?null:L-c;c=L,a&&a({action:s,location:N.location,delta:v})}function w(L,v){s="PUSH";let h=pa(N.location,L,v);n&&n(h,L),c=g()+1;let m=od(h,c),C=N.createHref(h);try{i.pushState(m,"",C)}catch(T){if(T instanceof DOMException&&T.name==="DataCloneError")throw T;l.location.assign(C)}o&&a&&a({action:s,location:N.location,delta:1})}function k(L,v){s="REPLACE";let h=pa(N.location,L,v);n&&n(h,L),c=g();let m=od(h,c),C=N.createHref(h);i.replaceState(m,"",C),o&&a&&a({action:s,location:N.location,delta:0})}function E(L){return Dv(L)}let N={get action(){return s},get location(){return e(l,i)},listen(L){if(a)throw new Error("A history only accepts one active listener");return l.addEventListener(ld,y),a=L,()=>{l.removeEventListener(ld,y),a=null}},createHref(L){return t(l,L)},createURL:E,encodeLocation(L){let v=E(L);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:w,replace:k,go(L){return i.go(L)}};return N}function Dv(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),ve(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:kl(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function Wp(e,t,n="/"){return Fv(e,t,n,!1)}function Fv(e,t,n,r){let l=typeof t=="string"?zn(t):t,o=Vt(l.pathname||"/",n);if(o==null)return null;let i=Vp(e);zv(i);let s=null;for(let a=0;s==null&&a{let g={relativePath:c===void 0?i.path||"":c,caseSensitive:i.caseSensitive===!0,childrenIndex:s,route:i};if(g.relativePath.startsWith("/")){if(!g.relativePath.startsWith(r)&&a)return;ve(g.relativePath.startsWith(r),`Absolute route path "${g.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),g.relativePath=g.relativePath.slice(r.length)}let y=Ut([r,g.relativePath]),w=n.concat(g);i.children&&i.children.length>0&&(ve(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${y}".`),Vp(i.children,t,w,y,a)),!(i.path==null&&!i.index)&&t.push({path:y,score:Kv(y,i.index),routesMeta:w})};return e.forEach((i,s)=>{var a;if(i.path===""||!((a=i.path)!=null&&a.includes("?")))o(i,s);else for(let c of Kp(i.path))o(i,s,!0,c)}),t}function Kp(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,l=n.endsWith("?"),o=n.replace(/\?$/,"");if(r.length===0)return l?[o,""]:[o];let i=Kp(r.join("/")),s=[];return s.push(...i.map(a=>a===""?o:[o,a].join("/"))),l&&s.push(...i),s.map(a=>e.startsWith("/")&&a===""?"/":a)}function zv(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Qv(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Uv=/^:[\w-]+$/,bv=3,Bv=2,Hv=1,Wv=10,Vv=-2,id=e=>e==="*";function Kv(e,t){let n=e.split("/"),r=n.length;return n.some(id)&&(r+=Vv),t&&(r+=Bv),n.filter(l=>!id(l)).reduce((l,o)=>l+(Uv.test(o)?bv:o===""?Hv:Wv),r)}function Qv(e,t){return e.length===t.length&&e.slice(0,-1).every((r,l)=>r===t[l])?e[e.length-1]-t[t.length-1]:0}function Gv(e,t,n=!1){let{routesMeta:r}=e,l={},o="/",i=[];for(let s=0;s{if(g==="*"){let E=s[w]||"";i=o.slice(0,o.length-E.length).replace(/(.)\/+$/,"$1")}const k=s[w];return y&&!k?c[g]=void 0:c[g]=(k||"").replace(/%2F/g,"/"),c},{}),pathname:o,pathnameBase:i,pattern:e}}function Yv(e,t=!1,n=!0){Nt(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],l="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,s,a)=>(r.push({paramName:s,isOptional:a!=null}),a?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),l+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?l+="\\/*$":e!==""&&e!=="/"&&(l+="(?:(?=\\/|$))"),[new RegExp(l,t?void 0:"i"),r]}function Jv(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Nt(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Vt(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}function Xv(e,t="/"){let{pathname:n,search:r="",hash:l=""}=typeof e=="string"?zn(e):e;return{pathname:n?n.startsWith("/")?n:qv(n,t):t,search:ty(r),hash:ny(l)}}function qv(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(l=>{l===".."?n.length>1&&n.pop():l!=="."&&n.push(l)}),n.length>1?n.join("/"):"/"}function ps(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in and the router will parse it for you.`}function Zv(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Qp(e){let t=Zv(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Gp(e,t,n,r=!1){let l;typeof e=="string"?l=zn(e):(l={...e},ve(!l.pathname||!l.pathname.includes("?"),ps("?","pathname","search",l)),ve(!l.pathname||!l.pathname.includes("#"),ps("#","pathname","hash",l)),ve(!l.search||!l.search.includes("#"),ps("#","search","hash",l)));let o=e===""||l.pathname==="",i=o?"/":l.pathname,s;if(i==null)s=n;else{let y=t.length-1;if(!r&&i.startsWith("..")){let w=i.split("/");for(;w[0]==="..";)w.shift(),y-=1;l.pathname=w.join("/")}s=y>=0?t[y]:"/"}let a=Xv(l,s),c=i&&i!=="/"&&i.endsWith("/"),g=(o||i===".")&&n.endsWith("/");return!a.pathname.endsWith("/")&&(c||g)&&(a.pathname+="/"),a}var Ut=e=>e.join("/").replace(/\/\/+/g,"/"),ey=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),ty=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,ny=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function ry(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}var Yp=["POST","PUT","PATCH","DELETE"];new Set(Yp);var ly=["GET",...Yp];new Set(ly);var Cr=f.createContext(null);Cr.displayName="DataRouter";var Si=f.createContext(null);Si.displayName="DataRouterState";f.createContext(!1);var Jp=f.createContext({isTransitioning:!1});Jp.displayName="ViewTransition";var oy=f.createContext(new Map);oy.displayName="Fetchers";var iy=f.createContext(null);iy.displayName="Await";var It=f.createContext(null);It.displayName="Navigation";var jl=f.createContext(null);jl.displayName="Location";var Qt=f.createContext({outlet:null,matches:[],isDataRoute:!1});Qt.displayName="Route";var hu=f.createContext(null);hu.displayName="RouteError";function sy(e,{relative:t}={}){ve(Tl(),"useHref() may be used only in the context of a component.");let{basename:n,navigator:r}=f.useContext(It),{hash:l,pathname:o,search:i}=Pl(e,{relative:t}),s=o;return n!=="/"&&(s=o==="/"?n:Ut([n,o])),r.createHref({pathname:s,search:i,hash:l})}function Tl(){return f.useContext(jl)!=null}function Un(){return ve(Tl(),"useLocation() may be used only in the context of a component."),f.useContext(jl).location}var Xp="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function qp(e){f.useContext(It).static||f.useLayoutEffect(e)}function ay(){let{isDataRoute:e}=f.useContext(Qt);return e?xy():uy()}function uy(){ve(Tl(),"useNavigate() may be used only in the context of a component.");let e=f.useContext(Cr),{basename:t,navigator:n}=f.useContext(It),{matches:r}=f.useContext(Qt),{pathname:l}=Un(),o=JSON.stringify(Qp(r)),i=f.useRef(!1);return qp(()=>{i.current=!0}),f.useCallback((a,c={})=>{if(Nt(i.current,Xp),!i.current)return;if(typeof a=="number"){n.go(a);return}let g=Gp(a,JSON.parse(o),l,c.relative==="path");e==null&&t!=="/"&&(g.pathname=g.pathname==="/"?t:Ut([t,g.pathname])),(c.replace?n.replace:n.push)(g,c.state,c)},[t,n,o,l,e])}f.createContext(null);function Pl(e,{relative:t}={}){let{matches:n}=f.useContext(Qt),{pathname:r}=Un(),l=JSON.stringify(Qp(n));return f.useMemo(()=>Gp(e,JSON.parse(l),r,t==="path"),[e,l,r,t])}function cy(e,t){return Zp(e,t)}function Zp(e,t,n,r,l){var h;ve(Tl(),"useRoutes() may be used only in the context of a component.");let{navigator:o}=f.useContext(It),{matches:i}=f.useContext(Qt),s=i[i.length-1],a=s?s.params:{},c=s?s.pathname:"/",g=s?s.pathnameBase:"/",y=s&&s.route;{let m=y&&y.path||"";eh(c,!y||m.endsWith("*")||m.endsWith("*?"),`You rendered descendant (or called \`useRoutes()\`) at "${c}" (under ) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render. - -Please change the parent to .`)}let w=Un(),k;if(t){let m=typeof t=="string"?zn(t):t;ve(g==="/"||((h=m.pathname)==null?void 0:h.startsWith(g)),`When overriding the location using \`\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${g}" but pathname "${m.pathname}" was given in the \`location\` prop.`),k=m}else k=w;let E=k.pathname||"/",N=E;if(g!=="/"){let m=g.replace(/^\//,"").split("/");N="/"+E.replace(/^\//,"").split("/").slice(m.length).join("/")}let L=Wp(e,{pathname:N});Nt(y||L!=null,`No routes matched location "${k.pathname}${k.search}${k.hash}" `),Nt(L==null||L[L.length-1].route.element!==void 0||L[L.length-1].route.Component!==void 0||L[L.length-1].route.lazy!==void 0,`Matched leaf route at location "${k.pathname}${k.search}${k.hash}" does not have an element or Component. This means it will render an with a null value by default resulting in an "empty" page.`);let v=my(L&&L.map(m=>Object.assign({},m,{params:Object.assign({},a,m.params),pathname:Ut([g,o.encodeLocation?o.encodeLocation(m.pathname).pathname:m.pathname]),pathnameBase:m.pathnameBase==="/"?g:Ut([g,o.encodeLocation?o.encodeLocation(m.pathnameBase).pathname:m.pathnameBase])})),i,n,r,l);return t&&v?f.createElement(jl.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...k},navigationType:"POP"}},v):v}function dy(){let e=Sy(),t=ry(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",l={padding:"0.5rem",backgroundColor:r},o={padding:"2px 4px",backgroundColor:r},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=f.createElement(f.Fragment,null,f.createElement("p",null,"💿 Hey developer 👋"),f.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",f.createElement("code",{style:o},"ErrorBoundary")," or"," ",f.createElement("code",{style:o},"errorElement")," prop on your route.")),f.createElement(f.Fragment,null,f.createElement("h2",null,"Unexpected Application Error!"),f.createElement("h3",{style:{fontStyle:"italic"}},t),n?f.createElement("pre",{style:l},n):null,i)}var fy=f.createElement(dy,null),py=class extends f.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.unstable_onError?this.props.unstable_onError(e,t):console.error("React Router caught the following error during render",e)}render(){return this.state.error!==void 0?f.createElement(Qt.Provider,{value:this.props.routeContext},f.createElement(hu.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function hy({routeContext:e,match:t,children:n}){let r=f.useContext(Cr);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),f.createElement(Qt.Provider,{value:e},n)}function my(e,t=[],n=null,r=null,l=null){if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let o=e,i=n==null?void 0:n.errors;if(i!=null){let c=o.findIndex(g=>g.route.id&&(i==null?void 0:i[g.route.id])!==void 0);ve(c>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),o=o.slice(0,Math.min(o.length,c+1))}let s=!1,a=-1;if(n)for(let c=0;c=0?o=o.slice(0,a+1):o=[o[0]];break}}}return o.reduceRight((c,g,y)=>{let w,k=!1,E=null,N=null;n&&(w=i&&g.route.id?i[g.route.id]:void 0,E=g.route.errorElement||fy,s&&(a<0&&y===0?(eh("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),k=!0,N=null):a===y&&(k=!0,N=g.route.hydrateFallbackElement||null)));let L=t.concat(o.slice(0,y+1)),v=()=>{let h;return w?h=E:k?h=N:g.route.Component?h=f.createElement(g.route.Component,null):g.route.element?h=g.route.element:h=c,f.createElement(hy,{match:g,routeContext:{outlet:c,matches:L,isDataRoute:n!=null},children:h})};return n&&(g.route.ErrorBoundary||g.route.errorElement||y===0)?f.createElement(py,{location:n.location,revalidation:n.revalidation,component:E,error:w,children:v(),routeContext:{outlet:null,matches:L,isDataRoute:!0},unstable_onError:r}):v()},null)}function mu(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function gy(e){let t=f.useContext(Cr);return ve(t,mu(e)),t}function vy(e){let t=f.useContext(Si);return ve(t,mu(e)),t}function yy(e){let t=f.useContext(Qt);return ve(t,mu(e)),t}function gu(e){let t=yy(e),n=t.matches[t.matches.length-1];return ve(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function wy(){return gu("useRouteId")}function Sy(){var r;let e=f.useContext(hu),t=vy("useRouteError"),n=gu("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function xy(){let{router:e}=gy("useNavigate"),t=gu("useNavigate"),n=f.useRef(!1);return qp(()=>{n.current=!0}),f.useCallback(async(l,o={})=>{Nt(n.current,Xp),n.current&&(typeof l=="number"?e.navigate(l):await e.navigate(l,{fromRouteId:t,...o}))},[e,t])}var sd={};function eh(e,t,n){!t&&!sd[e]&&(sd[e]=!0,Nt(!1,n))}f.memo(ky);function ky({routes:e,future:t,state:n,unstable_onError:r}){return Zp(e,void 0,n,r,t)}function th(e){ve(!1,"A is only ever to be used as the child of element, never rendered directly. Please wrap your in a .")}function Ey({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:l,static:o=!1}){ve(!Tl(),"You cannot render a inside another . You should never have more than one in your app.");let i=e.replace(/^\/*/,"/"),s=f.useMemo(()=>({basename:i,navigator:l,static:o,future:{}}),[i,l,o]);typeof n=="string"&&(n=zn(n));let{pathname:a="/",search:c="",hash:g="",state:y=null,key:w="default"}=n,k=f.useMemo(()=>{let E=Vt(a,i);return E==null?null:{location:{pathname:E,search:c,hash:g,state:y,key:w},navigationType:r}},[i,a,c,g,y,w,r]);return Nt(k!=null,` is not able to match the URL "${a}${c}${g}" because it does not start with the basename, so the won't render anything.`),k==null?null:f.createElement(It.Provider,{value:s},f.createElement(jl.Provider,{children:t,value:k}))}function Cy({children:e,location:t}){return cy(ha(e),t)}function ha(e,t=[]){let n=[];return f.Children.forEach(e,(r,l)=>{if(!f.isValidElement(r))return;let o=[...t,l];if(r.type===f.Fragment){n.push.apply(n,ha(r.props.children,o));return}ve(r.type===th,`[${typeof r.type=="string"?r.type:r.type.name}] is not a component. All component children of must be a or `),ve(!r.props.index||!r.props.children,"An index route cannot have child routes.");let i={id:r.props.id||o.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(i.children=ha(r.props.children,o)),n.push(i)}),n}var jo="get",To="application/x-www-form-urlencoded";function xi(e){return e!=null&&typeof e.tagName=="string"}function Ny(e){return xi(e)&&e.tagName.toLowerCase()==="button"}function _y(e){return xi(e)&&e.tagName.toLowerCase()==="form"}function Ry(e){return xi(e)&&e.tagName.toLowerCase()==="input"}function Ly(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function jy(e,t){return e.button===0&&(!t||t==="_self")&&!Ly(e)}var ho=null;function Ty(){if(ho===null)try{new FormData(document.createElement("form"),0),ho=!1}catch{ho=!0}return ho}var Py=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function hs(e){return e!=null&&!Py.has(e)?(Nt(!1,`"${e}" is not a valid \`encType\` for \`\`/\`\` and will default to "${To}"`),null):e}function Iy(e,t){let n,r,l,o,i;if(_y(e)){let s=e.getAttribute("action");r=s?Vt(s,t):null,n=e.getAttribute("method")||jo,l=hs(e.getAttribute("enctype"))||To,o=new FormData(e)}else if(Ny(e)||Ry(e)&&(e.type==="submit"||e.type==="image")){let s=e.form;if(s==null)throw new Error('Cannot submit a
`,E=`
${w}
`;return`
${k}${E}
`}),i=i.replace(/
\s*(?=
]*>[\s\S]*?<\/div>)\s*
/g,"$1"),i}function V0(e){const t=e.split(/\r?\n/);let n=null;for(let r=0;r[\s\S]*?<\/think(?:ing)?>/gi,"").replace(/[*#]/g,"").replace(/\s+/g," ").trim()}function Yn(e,t,n){return e.includes(t)?e:`${e} - -${n}`}function Q0(e){const t=String(e||""),n=t.trim();if(!n)return t;const r=n.toLowerCase();return r.startsWith("error:")||r.startsWith("ollama error:")||r.includes("client error '")||r.includes("server error '")||r.includes("http")&&r.includes("error")||r.includes("unknown model architecture")||r.includes("out of memory")?r.includes("unknown model architecture")?Yn(t,"[ERROR - Unsupported Model]",`[ERROR - Unsupported Model] -This Ollama version does not support the model. -Update Ollama.`):r.includes("out of memory")?Yn(t,"[ERROR - Out of Memory]",`[ERROR - Out of Memory] -The model is too large for available memory. -Use a smaller or quantized model.`):r.includes("502")?Yn(t,"[ERROR 502 - Bad Gateway]",`[ERROR 502 - Bad Gateway] -Ollama did not return a valid response. -Try restarting or updating Ollama.`):r.includes("500")?Yn(t,"[ERROR 500 - Internal Server Error]",`[ERROR 500 - Internal Server Error] -Ollama crashed while processing the request. -Check 'ollama logs' and memory usage.`):r.includes("404")?Yn(t,"[ERROR 404 - Not Found]",`[ERROR 404 - Not Found] -The model or endpoint was not found. -Check the model name or run 'ollama pull '.`):r.includes("400")?Yn(t,"[ERROR 400 - Bad Request]",`[ERROR 400 - Bad Request] -The request sent to Ollama was invalid. -Check parameters or payload format.`):t:t}function fh(e){if(!e)return{think:null,answer:""};const t=//i,n=/<\/think(?:ing)?>/i,r=e.match(t);if(!r)return{think:null,answer:e};const l=r.index,o=r[0].length,i=e.substring(0,l).trim();let s=e.substring(l+o);const a=s.match(n);let c=null,g=i;return a?(c=s.substring(0,a.index).trim(),g+=s.substring(a.index+a[0].length)):c=s.trim(),{think:c||null,answer:g.trim()}}function G0({content:e,streamOutput:t,sources:n}){const r=Q0(e||""),{think:l,answer:o}=fh(r),[i,s]=Ve.useState(!1),a=!!l;return d.jsxs("div",{className:"assistant-message",children:[a&&d.jsxs("div",{className:"assistant-thoughts",children:[d.jsxs("button",{className:"think-toggle",onClick:()=>s(c=>!c),"aria-expanded":i?"true":"false","aria-controls":"think-content",children:[d.jsx("span",{className:"think-toggle-icon","aria-hidden":"true",children:i?"▾":"▸"}),"Thoughts"]}),i&&d.jsx("div",{id:"think-content",className:"think-content",dangerouslySetInnerHTML:{__html:kd(l)}})]}),d.jsx("div",{className:"msg-content",dangerouslySetInnerHTML:{__html:kd(o||r||"")}}),Array.isArray(n)&&n.length>0&&d.jsx("div",{className:"msg-sources chips",children:n.map((c,g)=>{let y=c,w=!1;try{const k=new URL(c);if(k.protocol==="file:"){w=!0;const E=k.pathname.split("/").filter(Boolean);y=decodeURIComponent(E[E.length-1]||c)}else y=(k.hostname||c).replace(/^www\./i,"")}catch{}return d.jsx("a",{className:"chip",href:c,target:"_blank",rel:"noreferrer",title:c,onClick:k=>{var E,N;if(w){k.preventDefault();try{const L=new URL(c);(N=(E=window.electronAPI)==null?void 0:E.openPath)==null||N.call(E,decodeURIComponent(L.pathname))}catch{}}},children:y},c+g)})})]})}function ys({attachments:e,className:t="",removable:n=!1,onRemove:r}){return!Array.isArray(e)||e.length===0?null:d.jsx("div",{className:`image-attachment-strip ${t}`.trim(),children:e.map((l,o)=>{const i=l==null?void 0:l.data_url;if(!i)return null;const s=l.id||`${l.name||"image"}-${o}-${i.length}`;return d.jsxs("div",{className:"image-attachment-card",children:[n&&d.jsx("button",{type:"button",className:"image-attachment-remove",onClick:()=>r==null?void 0:r(l.id),"aria-label":`Remove ${l.name||"image"}`,title:"Remove image",children:"×"}),d.jsx("img",{className:"image-attachment-thumb",src:i,alt:l.name||`Attachment ${o+1}`,loading:"lazy"})]},s)})})}const Ed="websearch.searxUrl",Cd="websearch.engines",Nd="chat.libraryBySession",_d="http://127.0.0.1:8888",ws=6,Ss=20*1024*1024,Y0=5*60*1e3,J0=200;let ph="http://127.0.0.1:8000";const X0=48,q0=24;function Z0(e){return e.backendApiUrl||e.ollamaApiUrl||ph}function ew(e){const t=typeof e=="string"?e.trim():"";return!t||t==="http://localhost:8888"?_d:t}function go(e){var n;return Array.from(((n=e==null?void 0:e.dataTransfer)==null?void 0:n.types)||[]).includes("Files")}function wa(e){return e?typeof e.type=="string"&&e.type.toLowerCase().startsWith("image/")?!0:/\.(png|jpe?g|gif|bmp|webp|tiff?|heic|avif)$/i.test(e.name||""):!1}function Rd(e){var r,l;const t=Array.from(((r=e==null?void 0:e.dataTransfer)==null?void 0:r.items)||[]);return t.length>0?t.some(o=>{var i;return o.kind==="file"&&wa((i=o.getAsFile)==null?void 0:i.call(o))}):Array.from(((l=e==null?void 0:e.dataTransfer)==null?void 0:l.files)||[]).some(wa)}function Ld(e){return new Promise((t,n)=>{const r=new FileReader;r.onerror=()=>n(r.error||new Error(`Failed to read ${(e==null?void 0:e.name)||"image"}`)),r.onload=()=>t(String(r.result||"")),r.readAsDataURL(e)})}function tw(e,t){const n=String(t||"").trim();if(!n)return e||"";const r=String(e||"");if(!r.trim())return n;const l=/[\s\n]$/.test(r)?"":` -`;return`${r}${l}${n}`}function nw(e){const t=Math.max(0,Math.floor(Number(e||0)/1e3)),n=Math.floor(t/60),r=t%60;return`${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`}function rw(){var Gu;const[e,t]=f.useState([]),[n,r]=f.useState(null),[l,o]=f.useState("chats"),i=f.useRef(l),[s,a]=f.useState("General"),[c,g]=f.useState(null),[y,w]=f.useState(null),[k,E]=f.useState([]),[N,L]=f.useState([]),[v,h]=f.useState(null),[m,C]=f.useState(()=>{try{const u=localStorage.getItem(Nd);return u?JSON.parse(u):{}}catch{return{}}}),[T,I]=f.useState(!1),[M,A]=f.useState(""),[V,U]=f.useState(""),[se,Le]=f.useState(!1),[fe,je]=f.useState(""),[R,b]=f.useState(!1),[X,P]=f.useState(""),[B,W]=f.useState([]),[q,re]=f.useState(!1),we=f.useRef(null),$e=f.useRef(null),Gt=f.useRef(null),ut=f.useRef(null),tt=f.useRef(0),[bn,Nr]=f.useState(!1),[Ei,Il]=f.useState(""),[Ci,$l]=f.useState(""),[Yt,wn]=f.useState(!0),[Ni,_r]=f.useState(""),[xe,F]=f.useState(!1),[D,ae]=f.useState(!1),[Te,Rr]=f.useState(0),Ml=f.useRef(null),Lr=f.useRef(null),Al=f.useRef([]),_i=f.useRef(null),Ol=f.useRef(""),Dl=f.useRef(null),Fl=f.useRef(null),Ri=f.useRef(0),zl=f.useRef(null),[Q,Su]=f.useState(ph),[xu,hh]=f.useState("Default"),[Ul,ku]=f.useState(!1),[Eu,jr]=f.useState(""),[mh,Li]=f.useState(!1),[Tr,gh]=f.useState(()=>ew(localStorage.getItem(Ed))),[Sn,vh]=f.useState(()=>H0(localStorage.getItem(Cd)));f.useEffect(()=>{localStorage.setItem(Ed,Tr||"")},[Tr]),f.useEffect(()=>{try{localStorage.setItem(Cd,JSON.stringify(ri(Sn)))}catch{}},[Sn]);const[bl,yh]=f.useState(!1),[gt,ji]=f.useState(!1),[Cu,Ti]=f.useState(!0),[wh,Bn]=f.useState([]),[Bl,Nu]=f.useState({}),[_u,Sh]=f.useState(!1),Ru=f.useRef(!1),[xh,Pi]=f.useState(null),[Ii,Hl]=f.useState("");function kh(u){const p=u.content||"";if(u.role==="assistant")try{const{answer:S}=fh(p);return(S||p).trim()}catch{return p.trim()}return p}async function Lu(u){try{await navigator.clipboard.writeText(kh(u))}catch(p){console.error("Failed to copy message:",p)}}function xn(u,p,S,x={}){const{removeIfEmpty:_=!1}=x;t($=>$.map(z=>{if(z.session_id!==u)return z;const H=[];for(const Z of z.messages||[]){if(Z.id!==p){H.push(Z);continue}_&&!S||H.push({...Z,content:S})}return{...z,messages:H}}))}function _t(u){return(u==null?void 0:u.name)==="AbortError"}function $t(u){return u instanceof Error&&u.message?u.message:String(u)}async function Wl(u){const p=await u.text().catch(()=>"");if(p){try{const S=JSON.parse(p);if(typeof(S==null?void 0:S.detail)=="string"&&S.detail.trim())return S.detail.trim();if(typeof(S==null?void 0:S.message)=="string"&&S.message.trim())return S.message.trim()}catch{}return p.trim()}return`HTTP ${u.status}`}async function Pr(u){const p=await u.json().catch(()=>null);if(u.ok)return p;const S=typeof(p==null?void 0:p.detail)=="string"?p.detail:typeof(p==null?void 0:p.message)=="string"?p.message:"";throw new Error(S||`HTTP ${u.status}`)}async function Eh(u,p){const S=await fetch(`${Q}/models/capabilities?name=${encodeURIComponent(u)}`,{signal:p});return Pr(S)}async function Ch(){const u=await fetch(`${Q}/ollama/startup-status`);return Pr(u)}async function Nh(){const u=await fetch(`${Q}/startup/prepare-models`,{method:"POST"});return Pr(u)}function ju(u){if(!!(u!=null&&u.whisper_model_available)){wn(!0),_r("");return}const S=(u==null?void 0:u.whisper_model)||"base",x=String((u==null?void 0:u.whisper_error)||"").trim();wn(!1),_r(x||`Whisper ${S} is not available.`)}async function Tu(u,p,S){if(!u)return{contextBlock:null,sources:[]};const _=await(await fetch(`${Q}/libraries/${u}/context`,{method:"POST",headers:{"Content-Type":"application/json"},signal:S,body:JSON.stringify({prompt:p,top_k:5})})).json();return{contextBlock:typeof(_==null?void 0:_.context_block)=="string"&&_.context_block.trim()?_.context_block.trim():null,sources:Array.isArray(_==null?void 0:_.sources)?_.sources:[]}}async function Pu(u){const p=Array.from(u||[]).filter(wa);if(!p.length||!R)return;const S=Math.max(0,ws-B.length);if(S<=0){window.alert(`You can attach up to ${ws} images per message.`);return}const x=p.slice(0,S),_=x.filter(z=>Number(z.size)>Ss),$=x.filter(z=>Number(z.size)<=Ss);if(_.length>0&&window.alert(`Images must be ${Math.round(Ss/(1024*1024))} MB or smaller.`),!!$.length)try{const z=await Promise.all($.map(async(H,Z)=>({id:`attachment-${Date.now()}-${Z}-${Math.random().toString(36).slice(2)}`,name:H.name||"image",mime_type:H.type||"image/*",data_url:await Ld(H)})));W(H=>[...H,...z]),p.length>S&&window.alert(`Only the first ${ws} images can be attached.`)}catch(z){console.error("Failed to load image attachments",z),window.alert(`Image import failed: ${$t(z)}`)}}function _h(u){W(p=>p.filter(S=>S.id!==u))}function Rh(){var u;R&&((u=ut.current)==null||u.click())}function $i(){Dl.current&&(window.clearInterval(Dl.current),Dl.current=null),Fl.current&&(window.clearTimeout(Fl.current),Fl.current=null)}function Mi(u=Lr.current){$i(),ga(u),Lr.current===u&&(Lr.current=null),Ml.current=null}async function Lh(u,p){if(!Q)throw new Error("The Heimgeist backend is not configured.");const S=new AbortController;zl.current=S,ae(!0);try{const x=await Ld(u),_=x.indexOf(",");if(_<=5)throw new Error("Recorded audio could not be encoded for upload.");const $=x.slice(0,_),z=x.slice(_+1);if(!/^data:[^,]+;base64$/i.test($)||!z)throw new Error("Recorded audio could not be encoded for upload.");const H=$.slice(5).replace(/;base64$/i,"").trim(),Z=await fetch(`${Q}/audio/transcribe`,{method:"POST",headers:{"Content-Type":"application/json"},signal:S.signal,body:JSON.stringify({mime_type:p||H||"audio/webm",audio_base64:z,language:Ci||null})}),le=await Pr(Z),te=String((le==null?void 0:le.text)||"").trim();if(!te){window.alert("No speech was detected. Try again and speak closer to the selected microphone.");return}P(he=>tw(he,te)),requestAnimationFrame(()=>{var he;return(he=$e.current)==null?void 0:he.focus()})}catch(x){if(_t(x))return;throw x}finally{zl.current===S&&(zl.current=null),ae(!1)}}async function Ir(u={}){const{shouldTranscribe:p=!0}=u,S=Ml.current,x=_i.current,_=Ol.current||(S==null?void 0:S.mimeType)||"audio/webm";if(!(!S||!x)){F(!1),$i();try{S.state!=="inactive"&&S.stop();const $=await x;if(!p)return;if(!$||$.size<=0)throw new Error("Recorded audio was empty.");await Lh($,_)}catch($){p&&(console.error("Failed to stop microphone recording",$),window.alert(`Microphone transcription failed: ${$t($)}`))}finally{_i.current=null,Al.current=[],Ol.current="",Ri.current=0,Rr(0)}}}async function jh(){if(!bn||!Yt||xe||D||gt)return;if(!ki()){window.alert("Microphone capture is not available in this environment.");return}let u=null;try{u=await navigator.mediaDevices.getUserMedia(C0(Ei))}catch(x){console.error("Failed to access microphone",x),window.alert(`Microphone access failed: ${$t(x)}`);return}const p=_0();let S=null;try{S=p?new MediaRecorder(u,{mimeType:p}):new MediaRecorder(u)}catch(x){Mi(u),console.error("Failed to create audio recorder",x),window.alert(`Microphone recording is not available: ${$t(x)}`);return}Lr.current=u,Ml.current=S,Al.current=[],Ol.current=S.mimeType||p||"audio/webm",Ri.current=Date.now(),Rr(0),F(!0),S.ondataavailable=x=>{x.data&&x.data.size>0&&Al.current.push(x.data)},_i.current=new Promise((x,_)=>{S.onstop=()=>{const $=new Blob(Al.current,{type:S.mimeType||Ol.current||"audio/webm"});Mi(u),x($)},S.onerror=$=>{Mi(u),_(($==null?void 0:$.error)||new Error("Audio recording failed."))}}),Dl.current=window.setInterval(()=>{Rr(Date.now()-Ri.current)},J0),Fl.current=window.setTimeout(()=>{Ir()},Y0),S.start()}async function Th(){if(!D){if(xe){await Ir();return}await jh()}}async function Ph(u){var S;const p=(S=u.target)==null?void 0:S.files;try{await Pu(p)}finally{u.target&&(u.target.value="")}}function Ih(u,p){Pi(u),Hl(p||"")}function Vl(){Pi(null),Hl("")}async function $h(u){var $;const p=((($=Kn[u])==null?void 0:$.content)||"").trim(),x=(Ii??"").trim();if(x.length===0){Vl();return}if(x===p){Vl();return}const _=n;if(_){t(z=>z.map(H=>{if(H.session_id!==_)return H;const le=(H.messages||[]).slice(0,u+1).map((te,he)=>he===u?{...te,content:x}:te);return{...H,messages:le}})),Pi(null),Hl(""),requestAnimationFrame(()=>zi("auto",_));try{const z=await fetch(`${Q}/sessions/${_}/messages/${u}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:x})});if(!z.ok)throw new Error(`HTTP ${z.status}`)}catch(z){console.error("Failed to update message:",z),t(H=>H.map(Z=>{if(Z.session_id!==_)return Z;const te=(Z.messages||[]).map((he,Fe)=>Fe===u?{...he,content:p}:he);return{...Z,messages:te}}));return}await Iu(u,x)}}async function Iu(u,p=null){var le,te,he,Fe,Cn,G;const S=n;if(gt||!S||typeof u!="number")return;const x=((le=e.find(J=>J.session_id===S))==null?void 0:le.messages)||[];let _=u;for(let J=u;J>=0;J--)if(((te=x[J])==null?void 0:te.role)==="user"){_=J;break}t(J=>J.map(ue=>ue.session_id===S?{...ue,messages:(ue.messages||[]).slice(0,_+1)}:ue));const $=Fu(S);let z=p??(((he=x[_])==null?void 0:he.content)||""),H=[];const Z=[];try{const J=Bu(S),ue=p??(((Fe=x[_])==null?void 0:Fe.content)||""),Ne=!!(ue||"").trim();if(Ne&&((Cn=J==null?void 0:J.states)!=null&&Cn.is_indexed))try{const K=await Tu(J.slug,ue,$.signal);K.contextBlock&&Z.push(K.contextBlock),Array.isArray(K.sources)&&H.push(...K.sources)}catch(K){if(_t(K))throw K;console.warn("local library enrichment (regenerate) failed",K)}if(Ne&&bl)try{const K=x.slice(Math.max(0,_-7),_+1).map(Ee=>({role:Ee.role,content:Ee.content||""}));K.length>0&&(K[K.length-1]={role:"user",content:ue});const oe=await(await fetch(`${Q}/websearch`,{method:"POST",headers:{"Content-Type":"application/json"},signal:$.signal,body:JSON.stringify({prompt:ue,model:fe,messages:K,history_limit:8,searx_url:Tr||null,engines:Array.isArray(Sn)?Sn:null})})).json();oe&&typeof oe.context_block=="string"&&oe.context_block.trim()&&Z.push(oe.context_block.trim()),Array.isArray(oe==null?void 0:oe.sources)&&H.push(...oe.sources)}catch(K){if(_t(K))throw K;console.warn("web search enrichment (regenerate) failed",K)}if(H=[...new Set(H)],Ne&&Z.length>0?z=`${ue} - -${Z.join(` - -`)}`:z=null,Ul){const K=`msg-${Date.now()}-${Math.random()}`;let nt="";t(oe=>oe.map(Ee=>Ee.session_id===S?{...Ee,messages:[...Ee.messages||[],{id:K,role:"assistant",content:"",sources:H}]}:Ee));try{const oe=await fetch(`${Q}/sessions/${S}/regenerate`,{method:"POST",headers:{"Content-Type":"application/json"},signal:$.signal,body:JSON.stringify({index:u,model:fe,stream:!0,enriched_message:z,sources:H||[]})});if(!oe.ok)throw new Error(await Wl(oe));const Ee=(G=oe.body)==null?void 0:G.getReader();if(!Ee)throw new Error("Missing response body");const Xt=new TextDecoder;let Yl=!1;for(;;){const{value:He,done:im}=await Ee.read();if(im)break;const sm=Xt.decode(He,{stream:!0});nt+=sm,xn(S,K,nt),!Yl&&De.current!==S&&(Yl=!0,kn(Ui=>({...Ui,[S]:K})),Bn(Ui=>[...new Set([...Ui,S])]))}De.current!==S?(kn(He=>({...He,[S]:K})),Bn(He=>[...new Set([...He,S])])):Hn.current[S]?Wn(He=>({...He,[S]:K})):requestAnimationFrame(()=>Qn(K,"smooth",S))}catch(oe){if(_t(oe)){xn(S,K,nt,{removeIfEmpty:!0});return}console.error(oe),xn(S,K,`Error: ${$t(oe)}`,{removeIfEmpty:!0});return}}else{const K=await fetch(`${Q}/sessions/${S}/regenerate`,{method:"POST",headers:{"Content-Type":"application/json"},signal:$.signal,body:JSON.stringify({index:u,model:fe,stream:!1,enriched_message:z,sources:H||[]})});if(!K.ok)throw new Error(await Wl(K));const nt=await K.json(),oe=`msg-${Date.now()}`;t(Ee=>Ee.map(Xt=>Xt.session_id===S?{...Xt,messages:[...Xt.messages||[],{role:"assistant",content:nt.reply,id:oe,sources:H}]}:Xt)),De.current!==S?(kn(Ee=>({...Ee,[S]:oe})),Bn(Ee=>[...new Set([...Ee,S])])):Hn.current[S]?Wn(Ee=>({...Ee,[S]:oe})):requestAnimationFrame(()=>Qn(oe,"smooth",S))}}catch(J){_t(J)||console.error(J)}finally{Ai($)}}const[$u,Mh]=f.useState({}),Hn=f.useRef({}),[Ah,kn]=f.useState({}),En=f.useRef({}),Mu=f.useRef({}),[Au,Wn]=f.useState({}),[Oh,Ou]=f.useState({});f.useEffect(()=>{i.current=l},[l]);const Du=(u,p,S)=>u!=null&&u.id?u.id:`${S}:${p}`;f.useEffect(()=>{var p;if(!n)return;const u=((p=e.find(S=>S.session_id===n))==null?void 0:p.messages)||[];Ou(S=>{const x={};return u.forEach((_,$)=>{if(_.role!=="user")return;const z=Du(_,$,n),Z=(_.content||"").split(/\r\n|\r|\n/).length>30;x[z]=Z?S[z]??!0:!1}),x})},[e,n]);function Dh(u){Ou(p=>({...p,[u]:!(p[u]??!0)}))}const $r=Ve.useCallback((u,p)=>{Mh(S=>{const x={...S,[u]:p};return Hn.current=x,x})},[]),Vn=f.useRef(null),Fh=f.useRef(!1),zh=f.useRef(null),De=f.useRef(n);f.useEffect(()=>{De.current=n},[n]);const Fu=Ve.useCallback(u=>{const p=new AbortController;return Vn.current={controller:p,sessionId:u},ji(!0),p},[]),Ai=Ve.useCallback(u=>{var p;((p=Vn.current)==null?void 0:p.controller)===u&&(Vn.current=null,ji(!1))},[]),Uh=Ve.useCallback(()=>{const u=Vn.current;u&&(Vn.current=null,u.controller.abort(),ji(!1))},[]);f.useEffect(()=>()=>{var u;(u=Vn.current)==null||u.controller.abort()},[]);const Jt=f.useRef(null),[bh,Bh]=f.useState(230),[Kl,zu]=f.useState(!1),Hh=Ve.useCallback(u=>{zu(!0)},[]),Mr=Ve.useCallback(()=>{zu(!1)},[]),Oi=Ve.useCallback(u=>{if(Kl){const p=Math.max(230,Math.min(500,u.clientX));Bh(p)}},[Kl]);Ve.useEffect(()=>(window.addEventListener("mousemove",Oi),window.addEventListener("mouseup",Mr),window.addEventListener("blur",Mr),()=>{window.removeEventListener("mousemove",Oi),window.removeEventListener("mouseup",Mr),window.removeEventListener("blur",Mr)}),[Oi,Mr]),Ve.useEffect(()=>(Kl?document.body.classList.add("no-select"):document.body.classList.remove("no-select"),()=>{document.body.classList.remove("no-select")}),[Kl]),Ve.useEffect(()=>{const u=async p=>{const S=p.target.closest(".codeblock__copy");if(!S)return;const x=S.closest(".codeblock"),_=x==null?void 0:x.querySelector("pre > code");if(_)try{await navigator.clipboard.writeText(_.textContent||""),S.classList.add("copied"),setTimeout(()=>S.classList.remove("copied"),800)}catch($){console.error("Copy failed:",$)}};return document.addEventListener("click",u),()=>document.removeEventListener("click",u)},[]),f.useEffect(()=>{let u=!1;return window.electronAPI.getSettings().then(p=>{u||(Su(Z0(p)),hh(p.colorScheme||"Default"),je(p.chatModel||""),ku(p.streamOutput||!1),Nr(p.audioInputEnabled===!0),Il(typeof p.audioInputDeviceId=="string"?p.audioInputDeviceId:""),$l(typeof p.audioInputLanguage=="string"?p.audioInputLanguage:""),Nu(p.scrollPositions||{}),El(p.colorScheme||"Default"))}).finally(()=>{u||Sh(!0)}),()=>{u=!0}},[]),f.useEffect(()=>{const u=()=>{var p;i.current==="chats"&&((p=$e.current)==null||p.focus())};return window.electronAPI.onWindowFocus(u),()=>{window.electronAPI.offWindowFocus(u)}},[]),f.useEffect(()=>{let u=!1;const p=new AbortController;return!Q||!fe?(b(!1),()=>{p.abort()}):((async()=>{try{const S=await Eh(fe,p.signal);u||b(!!(S!=null&&S.supports_vision))}catch(S){!u&&!_t(S)&&(console.warn("Failed to load model capabilities",S),b(!1))}})(),()=>{u=!0,p.abort()})},[Q,fe]),f.useEffect(()=>{tt.current=0,re(!1)},[R,l]),f.useEffect(()=>{bn||!xe||Ir({shouldTranscribe:!1})},[bn,xe]),f.useEffect(()=>{Yt||!xe||Ir({shouldTranscribe:!1})},[Yt,xe]),f.useEffect(()=>{l==="chats"||!xe||Ir()},[l,xe]),f.useEffect(()=>()=>{var p;(p=zl.current)==null||p.abort(),$i();const u=Ml.current;if(u){u.ondataavailable=null,u.onstop=null,u.onerror=null;try{u.state!=="inactive"&&u.stop()}catch{}}ga(Lr.current)},[]),f.useEffect(()=>{if(!_u||Cu||!Q||Ru.current)return;Ru.current=!0;let u=!1;const p=window.setTimeout(()=>{(async()=>{let S=!1;try{let x=await Ch();if(u)return;if(ju(x),!(x!=null&&x.ollama_running)&&(x!=null&&x.can_manage_locally)){const z=window.confirm(`Ollama is not running at ${x.ollama_url}. Start it in the background now with "ollama serve"?`);if(u)return;if(z){S=!0,Li(!0),jr("Starting Ollama in the background...");const H=await fetch(`${Q}/ollama/start`,{method:"POST"});if(x=await Pr(H),u)return}}const _=!(x!=null&&x.whisper_model_available),$=!!(x!=null&&x.ollama_running&&(x!=null&&x.can_manage_locally)&&!(x!=null&&x.embedding_model_available));if(_||$){S=!0,Li(!0),jr(_&&$?`Downloading Whisper ${(x==null?void 0:x.whisper_model)||"base"} and ${x.selected_embed_model}. This can take a while on first install.`:_?`Downloading Whisper ${(x==null?void 0:x.whisper_model)||"base"}. This can take a while on first install.`:`Downloading ${x.selected_embed_model} from Ollama. This can take a while on first install.`);const z=await Nh();if(u)return;ju((z==null?void 0:z.ollama)||x)}}catch(x){u||(console.warn("startup Ollama check failed",x),wn(!1),_r(`Whisper availability could not be verified: ${$t(x)}`),S&&window.alert(`Startup action failed: ${$t(x)}`))}finally{u||(Li(!1),jr(""))}})()},1200);return()=>{u=!0,window.clearTimeout(p)}},[Q,Cu,_u]),f.useEffect(()=>{El(xu)},[xu]);const Wh=u=>{!u||!Q||fetch(`${Q}/history?session_id=${encodeURIComponent(u)}`).then(p=>p.json()).then(p=>{t(S=>S.map(x=>x.session_id===u?{...x,messages:p.messages||[]}:x))}).catch(()=>{})};async function Ar(){if(Q)try{const p=await(await fetch(`${Q}/libraries`)).json(),S=Array.isArray(p.libraries)?p.libraries:[];if(E(S),S.length===0){h(null);return}S.some(x=>x.slug===v)||h(S[0].slug)}catch(u){console.warn("Failed to load libraries",u)}}async function Ql(){if(Q)try{const p=await(await fetch(`${Q}/jobs`)).json();L(Array.isArray(p.jobs)?p.jobs:[])}catch(u){console.warn("Failed to load library jobs",u)}}async function Uu(u=null){const S=(typeof u=="string"?u:M).trim();if(!S){U("Name is required.");return}try{U("");const x=await fetch(`${Q}/libraries`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:S})});if(!x.ok){const $=await x.text();throw new Error($||`HTTP ${x.status}`)}const _=await x.json();I(!1),A(""),await Ar(),_!=null&&_.slug&&h(_.slug)}catch(x){console.error("Failed to create library",x),U(String((x==null?void 0:x.message)||x))}}async function Vh(){E([]),L([]),h(null),w(null),Le(!1),C({}),await Ar(),await Ql()}f.useEffect(()=>{Q&&(Ti(!0),fetch(`${Q}/sessions`).then(u=>u.json()).then(u=>{const p=u.sessions.map(S=>({...S,messages:[]}));t(p),p.length>0?r(p[0].session_id):r(null),Ti(!1)}).catch(()=>{Ti(!1)}))},[Q]),f.useEffect(()=>{Q&&(Ar(),Ql())},[Q]),f.useEffect(()=>{try{localStorage.setItem(Nd,JSON.stringify(m||{}))}catch{}},[m]),f.useEffect(()=>{if(!Q)return;const u=setInterval(()=>{Ar(),Ql()},3e3);return()=>clearInterval(u)},[Q,l,v]),f.useEffect(()=>{Wh(n)},[n,Q]),f.useEffect(()=>{const u=new Set(k.map(p=>p.slug));C(p=>{let S=!1;const x={};for(const[_,$]of Object.entries(p||{}))u.has($)?x[_]=$:S=!0;return S?x:p})},[k]);const Di=u=>{o(u)},Kh=u=>{tm(u)},Kn=f.useMemo(()=>{var u;return((u=e.find(p=>p.session_id===n))==null?void 0:u.messages)||[]},[n,e]),Gl=f.useMemo(()=>k.find(u=>u.slug===v)||null,[v,k]),Mt=n&&m[n]||null,vt=f.useMemo(()=>k.find(u=>u.slug===Mt)||null,[Mt,k]),bu=f.useMemo(()=>Mt?N.some(u=>u.slug===Mt&&(u.status==="queued"||u.status==="running")):!1,[Mt,N]),Fi=f.useMemo(()=>{var u,p;return vt?(u=vt.files)!=null&&u.length?(p=vt.states)!=null&&p.is_indexed?"":bu?" (syncing)":" (needs sync)":" (empty)":""},[vt,bu]);function Qh(u){return u&&m[u]||null}function Bu(u){const p=Qh(u);return p&&k.find(S=>S.slug===p)||null}function Hu(u){return u?N.some(p=>p.slug===u&&(p.status==="queued"||p.status==="running")):!1}function Wu(u,p){u&&C(S=>{const x={...S||{}};return p?x[u]=p:delete x[u],x})}function Gh(u){u&&C(p=>{let S=!1;const x={};for(const[_,$]of Object.entries(p||{})){if($===u){S=!0;continue}x[_]=$}return S?x:p})}f.useEffect(()=>{if(!se)return;const u=p=>{var S;(S=Gt.current)!=null&&S.contains(p.target)||Le(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[se]),f.useEffect(()=>{Le(!1)},[n,l]),f.useEffect(()=>{const u=n,p=l;return()=>{if(p==="chats"&&u){const S=typeof En.current[u]=="number"?En.current[u]:we.current?we.current.scrollTop:0;Nu(x=>{const _={...x,[u]:S};return window.electronAPI.updateSettings({scrollPositions:_}),_})}}},[n,l]),f.useEffect(()=>{const u=we.current;if(!u)return;const p=()=>{const{scrollTop:S,scrollHeight:x,clientHeight:_}=u,$=x-S-_<=q0;if(n){const z=Mu.current[n],H=typeof z=="number"&&Su.removeEventListener("scroll",p)},[n,$r]),f.useEffect(()=>{const u=n;u&&$u[u]===!1&&Wn(p=>{if(!(u in p))return p;const S={...p};return delete S[u],S})},[n,$u]),f.useLayoutEffect(()=>{if(l!=="chats"||!n)return;const u=we.current;if(!u)return;Jt.current=null;const p=()=>{if(Jt.current===n)return;const z=typeof En.current[n]=="number"?En.current[n]:void 0,H=typeof z=="number"?z:Bl[n];if(typeof H=="number"){u.scrollTop=H,Jt.current=n;return}Kn.length>0&&(u.scrollTop=u.scrollHeight,Jt.current=n)};p();const S=requestAnimationFrame(p),x=()=>{Jt.current!==n&&requestAnimationFrame(p)},_=new MutationObserver(x);_.observe(u,{childList:!0,subtree:!0});const $=new ResizeObserver(x);return $.observe(u),()=>{cancelAnimationFrame(S),_.disconnect(),$.disconnect()}},[n,l,Kn.length,Bl]),f.useEffect(()=>{if(l!=="chats"||!n||Jt.current===n)return;const u=typeof En.current[n]=="number"?En.current[n]:void 0;typeof(typeof u=="number"?u:Bl[n])!="number"&&Kn.length>0&&requestAnimationFrame(()=>{const S=we.current;S&&(S.scrollTop=S.scrollHeight,Jt.current=n)})},[Kn.length,n,l,Bl]);const zi=(u="smooth",p=null)=>{const S=we.current;if(!S)return;const x=p??De.current;De.current===x&&(S.scrollTo({top:S.scrollHeight,behavior:u}),$r(x,!1))},Qn=(u,p="auto",S=null)=>{const x=we.current;if(!x)return;const _=S??De.current;if(De.current!==_)return;const $=document.getElementById(u);if($){const z=Math.max(0,$.offsetTop-X0);x.scrollTo({top:z,behavior:p})}},Yh=()=>{const u=De.current,p=Au[u];p&&(Qn(p,"smooth",u),Wn(S=>{const{[u]:x,..._}=S;return _}))},Jh=u=>{l!=="chats"||!go(u)||(u.preventDefault(),tt.current+=1,R&&Rd(u)&&re(!0))},Xh=u=>{l!=="chats"||!go(u)||(u.preventDefault(),u.dataTransfer.dropEffect=R?"copy":"none",R&&Rd(u)&&!q&&re(!0))},qh=u=>{l!=="chats"||!go(u)||(tt.current=Math.max(0,tt.current-1),tt.current===0&&re(!1))},Zh=async u=>{var p,S;l!=="chats"||!go(u)||(u.preventDefault(),tt.current=0,re(!1),R&&(await Pu((p=u.dataTransfer)==null?void 0:p.files),(S=$e.current)==null||S.focus()))};async function Vu(){var z,H,Z;const u=X.trim();if(gt||!u&&B.length===0||!fe)return;if(B.length>0&&!R){window.alert("The selected model does not support image inputs.");return}let p=n,S=!1;if(p){const le=e.find(te=>te.session_id===p);S=le&&le.name==="New Chat"&&le.messages.length===0}else{const le=await Ku();await new Promise(te=>setTimeout(te,200)),p=le.session_id,S=!0}const x=B.map(({id:le,...te})=>({...te})),_={role:"user",content:u,attachments:x,id:`msg-${Date.now()}-${Math.random()}`};Fh.current=!0,zh.current=p,$r(p,!1),De.current===p&&(Jt.current=De.current),Bp.flushSync(()=>{t(le=>le.map(te=>te.session_id===p?{...te,messages:[...te.messages||[],_]}:te)),P(""),W([])}),requestAnimationFrame(()=>zi("auto",p));const $=Fu(p);try{let le=[];if(_.content)try{le=[...(((z=e.find(ue=>ue.session_id===p))==null?void 0:z.messages)||[]).slice(-8).map(ue=>({role:ue.role,content:ue.content||""})),{role:"user",content:_.content}]}catch{}let te=_.content||null,he=[];const Fe=[],Cn=Bu(p);if(_.content&&((H=Cn==null?void 0:Cn.states)!=null&&H.is_indexed))try{const G=await Tu(Cn.slug,_.content,$.signal);G.contextBlock&&Fe.push(G.contextBlock),Array.isArray(G.sources)&&he.push(...G.sources)}catch(G){if(_t(G))throw G;console.warn("local library enrichment failed",G)}if(_.content&&bl)try{const J=await(await fetch(`${Q}/websearch`,{method:"POST",headers:{"Content-Type":"application/json"},signal:$.signal,body:JSON.stringify({prompt:_.content,model:fe,messages:le,history_limit:8,searx_url:Tr||null,engines:Array.isArray(Sn)?Sn:null})})).json();J&&typeof J.context_block=="string"&&J.context_block.trim()&&Fe.push(J.context_block.trim()),Array.isArray(J==null?void 0:J.sources)&&he.push(...J.sources)}catch(G){if(_t(G))throw G;console.warn("web search enrichment failed",G)}if(he=[...new Set(he)],_.content&&Fe.length>0&&(te=`${_.content} - -${Fe.join(` - -`)}`),Ul){const G=`msg-${Date.now()}-${Math.random()}`;let J="";const ue={role:"assistant",content:"",id:G,sources:he};t(Ne=>Ne.map(K=>K.session_id===p?{...K,messages:[...K.messages||[],ue]}:K));try{const Ne=await fetch(`${Q}/chat`,{method:"POST",headers:{"Content-Type":"application/json"},signal:$.signal,body:JSON.stringify({session_id:p,model:fe,message:_.content,enriched_message:_.content&&Fe.length>0?te:null,stream:!0,sources:he||[],attachments:x})});if(!Ne.ok)throw new Error(await Wl(Ne));const K=(Z=Ne.body)==null?void 0:Z.getReader();if(!K)throw new Error("Missing response body");const nt=new TextDecoder;let oe=!1;for(;;){const{value:Ee,done:Xt}=await K.read();if(Xt){xn(p,G,J),De.current===p?Hn.current[p]?Wn(He=>({...He,[p]:G})):requestAnimationFrame(()=>Qn(G,"smooth",p)):(kn(He=>({...He,[p]:G})),Bn(He=>[...new Set([...He,p])]));break}const Yl=nt.decode(Ee,{stream:!0});J+=Yl,xn(p,G,J),De.current===p&&!Hn.current[p]&&zi("auto",p),De.current!==p&&!oe&&(kn(He=>({...He,[p]:G})),oe=!0)}}catch(Ne){if(_t(Ne)){xn(p,G,J,{removeIfEmpty:!0});return}console.error("Failed to send message:",Ne),xn(p,G,"Error: "+$t(Ne),{removeIfEmpty:!0});return}}else{const G=await fetch(`${Q}/chat`,{method:"POST",headers:{"Content-Type":"application/json"},signal:$.signal,body:JSON.stringify({session_id:p,model:fe,message:_.content,enriched_message:_.content&&Fe.length>0?te:null,stream:!1,sources:he||[],attachments:x})});if(!G.ok)throw new Error(await Wl(G));const J=await G.json(),ue=`msg-${Date.now()}`,Ne={role:"assistant",content:J.reply,id:ue,sources:he};t(K=>K.map(nt=>nt.session_id===p?{...nt,messages:[...nt.messages||[],Ne]}:nt)),ue&&(De.current===p?Hn.current[p]?Wn(K=>({...K,[p]:ue})):requestAnimationFrame(()=>Qn(ue,"smooth",p)):kn(K=>({...K,[p]:ue})))}De.current!==p&&Bn(G=>[...new Set([...G,p])]),S&&fetch(`${Q}/generate-title`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:p,message:_.content||(x.length>0?"Image attachment":_.content),model:fe})}).then(G=>G.json()).then(G=>{const J=K0(G.title);t(ue=>ue.map(Ne=>Ne.session_id===p?{...Ne,name:J}:Ne))})}catch(le){if(_t(le)){Ai($);return}console.error("Failed to send message:",le);const te={role:"assistant",content:"Error: "+$t(le),id:`msg-${Date.now()}-${Math.random()}`};t(he=>he.map(Fe=>Fe.session_id===p?{...Fe,messages:[...Fe.messages,te]}:Fe))}finally{Ai($)}}function em(){yh(u=>!u)}async function Ku(){var _;const u="sess-"+Math.random().toString(36).slice(2)+Date.now().toString(36),S=await(await fetch(`${Q}/sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:u})})).json(),x={...S,messages:[]};return t($=>[x,...$]),r(S.session_id),(_=$e.current)==null||_.focus(),S}function tm(u){r(u),Bn(S=>S.filter(x=>x!==u));const p=Ah[u];p&&requestAnimationFrame(()=>{let S=12;const x=()=>{if(!we.current)return;let $=document.getElementById(p);if(!$){const z=e.find(H=>H.session_id===u);if(z&&Array.isArray(z.messages))for(let H=z.messages.length-1;H>=0;H--){const Z=z.messages[H];if(Z.role==="assistant"&&Z.id){$=document.getElementById(Z.id);break}}}$?(Qn($.id,"smooth",u),kn(z=>{const{[u]:H,...Z}=z;return Z})):S-- >0&&requestAnimationFrame(x)};requestAnimationFrame(x)})}function nm(u,p){fetch(`${Q}/sessions/${u}/rename`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:p})}).then(()=>{t(S=>S.map(x=>x.session_id===u?{...x,name:p}:x)),g(null)})}function rm(u,p){const S=(p||"").trim(),x=k.find(_=>_.slug===u);if(!x){w(null);return}if(!S||S===x.name){w(null);return}fetch(`${Q}/libraries/${u}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:S})}).then(()=>{E(_=>_.map($=>$.slug===u?{...$,name:S}:$)),w(null)})}function Qu(u){fetch(`${Q}/sessions/${u}`,{method:"DELETE"}).then(()=>{const p=e.filter(S=>S.session_id!==u);t(p),C(S=>{const x={...S||{}};return delete x[u],x}),n===u&&r(p.length>0?p[0].session_id:null)})}function lm(u){fetch(`${Q}/libraries/${u}`,{method:"DELETE"}).then(async p=>{var x;if(!p.ok){const _=await p.text();throw new Error(_||`HTTP ${p.status}`)}const S=k.filter(_=>_.slug!==u);E(S),L(_=>_.filter($=>$.slug!==u)),w(_=>_===u?null:_),v===u&&h(((x=S[0])==null?void 0:x.slug)||null),Gh(u)}).catch(p=>{console.error("Failed to delete library",p)})}f.useEffect(()=>{const u=e.filter(p=>p.name==="New Chat"&&p.session_id!==n&&p.messages.length===0);u.length>0&&u.forEach(p=>{Qu(p.session_id)})},[n,e,Q]);const om=u=>{var S;window.getSelection().toString().length>0||document.activeElement!==$e.current&&(u.target.closest(".msg")||(S=$e.current)==null||S.focus())};return d.jsxs("div",{className:"app",style:{gridTemplateColumns:`${bh}px 1fr`},children:[d.jsxs("div",{className:"sidebar",children:[d.jsxs("div",{className:"sidebar-header",children:[d.jsx("div",{className:`sidebar-tab ${l==="chats"?"active":""}`,onClick:()=>Di("chats"),children:"Chats"}),d.jsx("div",{className:`sidebar-tab ${l==="dbs"?"active":""}`,onClick:()=>Di("dbs"),children:"DBs"}),d.jsx("div",{className:`sidebar-tab ${l==="settings"?"active":""}`,onClick:()=>Di("settings"),children:"Settings"})]}),d.jsxs("div",{className:"sidebar-content",children:[l==="chats"&&d.jsx("div",{className:"chat-list",children:e.map(u=>d.jsx("div",{className:`chat-item ${u.session_id===n?"active":""}`,onClick:()=>Kh(u.session_id),children:c===u.session_id?d.jsx("input",{type:"text",className:"rename-input",defaultValue:u.name,onBlur:()=>g(null),onKeyDown:p=>{p.key==="Enter"?nm(u.session_id,p.target.value):p.key==="Escape"&&g(null)},autoFocus:!0}):d.jsxs(d.Fragment,{children:[d.jsx("span",{children:u.name}),d.jsxs("div",{className:"chat-item-buttons",children:[wh.includes(u.session_id)&&d.jsx("div",{className:"unread-dot"}),d.jsx("button",{className:"icon-button",onClick:p=>{p.stopPropagation(),g(u.session_id)},children:d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"feather feather-edit-2",children:d.jsx("path",{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}),d.jsx("button",{className:"icon-button",onClick:p=>{p.stopPropagation(),Qu(u.session_id)},children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"feather feather-x",children:[d.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),d.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})},u.session_id))}),l==="dbs"&&d.jsx("div",{className:"db-list",children:k.length===0?d.jsx("div",{className:"empty-list-message",children:"No databases yet."}):k.map(u=>d.jsx("div",{className:`chat-item ${u.slug===v?"active":""}`,onClick:()=>h(u.slug),children:y===u.slug?d.jsx("input",{type:"text",className:"rename-input",defaultValue:u.name,onBlur:()=>w(null),onKeyDown:p=>{p.key==="Enter"?rm(u.slug,p.target.value):p.key==="Escape"&&w(null)},autoFocus:!0}):d.jsxs(d.Fragment,{children:[d.jsx("span",{children:u.name}),d.jsxs("div",{className:"chat-item-buttons",children:[Mt===u.slug&&d.jsx("div",{className:"db-active-badge",children:"Chat"}),Hu(u.slug)&&d.jsx("div",{className:"db-active-badge",children:"Syncing"}),d.jsx("button",{className:"icon-button",onClick:p=>{p.stopPropagation(),w(u.slug)},children:d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"feather feather-edit-2",children:d.jsx("path",{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}),d.jsx("button",{className:"icon-button",onClick:p=>{p.stopPropagation(),lm(u.slug)},children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"feather feather-x",children:[d.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),d.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})},u.slug))}),l==="settings"&&d.jsxs("div",{className:"settings-list",children:[d.jsx("div",{className:`settings-item ${s==="General"?"active":""}`,onClick:()=>a("General"),children:"General"}),d.jsx("div",{className:`settings-item ${s==="Interface"?"active":""}`,onClick:()=>a("Interface"),children:"Interface"}),d.jsx("div",{className:`settings-item ${s==="Websearch"?"active":""}`,onClick:()=>a("Websearch"),children:"Websearch"})]})]}),l!=="settings"&&d.jsxs("div",{className:"sidebar-footer",children:[l==="chats"&&d.jsx("button",{className:"button new-chat-button",onClick:Ku,children:"New Chat"}),l==="dbs"&&(T?d.jsxs("div",{className:"new-db-form",children:[d.jsx("input",{type:"text",className:"rename-input",value:M,onChange:u=>A(u.target.value),onKeyDown:u=>{u.key==="Enter"?Uu():u.key==="Escape"&&(I(!1),A(""),U(""))},placeholder:"Database name",autoFocus:!0}),V&&d.jsx("div",{className:"form-error",children:V}),d.jsxs("div",{className:"new-db-actions",children:[d.jsx("button",{className:"button new-db-button",onClick:()=>Uu(),children:"Create"}),d.jsx("button",{className:"button ghost",onClick:()=>{I(!1),A(""),U("")},children:"Cancel"})]})]}):d.jsx("button",{className:"button new-db-button",onClick:()=>{I(!0),U("")},children:"New Database"}))]}),d.jsx("div",{className:"resizer",onMouseDown:Hh})]}),d.jsxs("div",{className:`main-content${l==="chats"&&q?" main-content--drag-active":""}`,onDragEnter:Jh,onDragOver:Xh,onDragLeave:qh,onDrop:Zh,children:[Eu&&d.jsxs("div",{className:"startup-task-banner",role:"status","aria-live":"polite",children:[mh&&d.jsx("div",{className:"spinner startup-task-banner__spinner"}),d.jsx("div",{className:"startup-task-banner__text",children:Eu})]}),l==="chats"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"header",children:[d.jsxs("strong",{children:["Chat - ",((Gu=e.find(u=>u.session_id===n))==null?void 0:Gu.name)||"New Chat"]}),vt&&d.jsx("span",{className:"header-subtle",children:`DB: ${vt.name}${Fi}`})]}),d.jsx("div",{className:`chat${q?" chat--drag-active":""}`,ref:we,onClick:om,children:Kn.map((u,p)=>{const S=u.role==="user"&&xh===p;return d.jsx("div",{id:u.id,className:"msg "+(u.role==="user"?"user":"assistant")+(S?" editing":""),children:u.role==="assistant"?d.jsxs("div",{className:"assistant-message-wrapper",children:[d.jsx(G0,{content:u.content,streamOutput:Ul,sources:u.sources}),!gt&&d.jsxs("div",{className:"message-options-bar assistant-options",children:[d.jsx("button",{className:"icon-button",title:"Copy message",onClick:()=>Lu(u),children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),d.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}),d.jsx("button",{className:"icon-button",title:"Regenerate response",onClick:()=>Iu(p),children:d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:"M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.3"})})})]})]}):d.jsxs("div",{className:"user-message-wrapper",children:[S?d.jsxs(d.Fragment,{children:[d.jsx(ys,{attachments:u.attachments,className:"message-attachment-strip"}),d.jsxs("div",{className:"msg-content msg-content--user editing",children:[d.jsx("div",{className:"user-edit-shadow","aria-hidden":"true",children:Ii}),d.jsx(hd,{className:"edit-message-input edit-overlay",value:Ii,onChange:x=>Hl(x.target.value),onBlur:Vl,onKeyDown:x=>{x.key==="Escape"&&(x.preventDefault(),Vl()),x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),$h(p))},autoFocus:!0,minRows:1})]})]}):(()=>{const x=u.content||"",_=Array.isArray(u.attachments)?u.attachments:[],$=x.split(/\r\n|\r|\n/),z=$.length>30,H=Du(u,p,n),Z=z?Oh[H]??!0:!1,le=Z?$.slice(0,30).join(` -`)+` -…`:x,te=!!x.trim();return d.jsxs(d.Fragment,{children:[d.jsx(ys,{attachments:_,className:"message-attachment-strip"}),te&&d.jsx("div",{className:"msg-content msg-content--user",children:le}),te&&z&&d.jsx("button",{className:"user-msg-expand",onClick:()=>Dh(H),"aria-expanded":Z?"false":"true",children:Z?"Show entire message":"Collapse"})]})})(),!gt&&!S&&d.jsxs("div",{className:"message-options-bar user-options",children:[d.jsx("button",{className:"icon-button",title:"Edit message",onClick:()=>Ih(p,u.content),children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M12 20h9"}),d.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"})]})}),d.jsx("button",{className:"icon-button",title:"Copy message",onClick:()=>Lu(u),children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),d.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})]})]})},u.id||p)})},n),Au[n]&&d.jsxs("button",{className:"new-msg-tip",onClick:Yh,title:"Jump to the new message","aria-label":"Jump to the new message",children:["New message",d.jsx("span",{style:{marginLeft:6},children:"↓"})]}),d.jsx("div",{className:"footer",children:d.jsxs("div",{className:`footer-inner${q?" footer-inner--drag-active":""}`,children:[d.jsx("input",{ref:ut,type:"file",accept:"image/*",multiple:!0,className:"composer-image-input",onChange:Ph,tabIndex:-1}),d.jsx(ys,{attachments:B,className:"composer-attachment-strip",removable:!0,onRemove:_h}),(xe||D)&&d.jsxs("div",{className:"composer-audio-status"+(xe?" composer-audio-status--recording":" composer-audio-status--transcribing"),role:"status","aria-live":"polite",children:[xe?d.jsx("span",{className:"composer-audio-status__dot","aria-hidden":"true"}):d.jsx("div",{className:"spinner composer-audio-status__spinner","aria-hidden":"true"}),d.jsx("span",{children:xe?`Listening ${nw(Te)}`:"Transcribing audio…"})]}),d.jsxs("div",{className:"footer-content-wrapper",children:[d.jsx(hd,{ref:$e,className:"input",value:X,onChange:u=>P(u.target.value),onKeyDown:u=>{u.key==="Enter"&&!u.shiftKey&&!xe&&!D&&(u.preventDefault(),Vu())},placeholder:"Ask any question...",maxRows:13}),d.jsxs("div",{className:"footer-tool-group",ref:Gt,children:[d.jsx("button",{type:"button",className:"db-picker-toggle"+(vt?" active":""),onClick:()=>{n&&Le(u=>!u)},title:vt?`Database: ${vt.name}${Fi}`:"Select database for this chat","aria-haspopup":"menu","aria-expanded":se,disabled:!n,children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("ellipse",{cx:"12",cy:"5",rx:"8",ry:"3"}),d.jsx("path",{d:"M4 5v6c0 1.7 3.6 3 8 3s8-1.3 8-3V5"}),d.jsx("path",{d:"M4 11v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6"})]})}),se&&d.jsxs("div",{className:"db-picker-menu",role:"menu",children:[d.jsxs("button",{type:"button",className:"db-picker-option"+(Mt?"":" selected"),onClick:()=>{Wu(n,null),Le(!1)},children:[d.jsx("span",{children:"No database"}),!Mt&&d.jsx("span",{className:"db-picker-status",children:"Selected"})]}),k.length===0?d.jsx("div",{className:"db-picker-empty",children:"No databases yet."}):k.map(u=>{var _,$,z;const p=Mt===u.slug,S=Hu(u.slug),x=(_=u.files)!=null&&_.length?($=u.states)!=null&&$.is_indexed?"Ready":S?"Syncing":"Needs sync":"Empty";return d.jsxs("button",{type:"button",className:"db-picker-option"+(p?" selected":""),disabled:!((z=u.files)!=null&&z.length),onClick:()=>{Wu(n,u.slug),Le(!1)},children:[d.jsx("span",{children:u.name}),d.jsx("span",{className:"db-picker-status",children:p?"Selected":x})]},u.slug)})]})]}),R&&d.jsx("button",{type:"button",className:"image-attach-toggle"+(B.length>0?" active":""),onClick:Rh,title:"Attach images","aria-label":"Attach images",children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),d.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),d.jsx("path",{d:"M21 15l-5-5L5 21"})]})}),bn&&d.jsx("button",{type:"button",className:"audio-input-toggle"+(xe||D?" active":"")+(xe?" recording":"")+(D?" transcribing":""),onClick:Th,title:Yt?xe?"Stop voice input":D?"Transcribing audio":"Start voice input":Ni||"Whisper is not available for audio input.","aria-label":Yt?xe?"Stop voice input":D?"Transcribing audio":"Start voice input":Ni||"Whisper is not available for audio input.","aria-pressed":xe,disabled:!Yt||D||gt,children:D?d.jsx("div",{className:"spinner composer-audio-icon-spinner","aria-hidden":"true"}):d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("path",{d:"M12 3a3 3 0 0 1 3 3v6a3 3 0 0 1-6 0V6a3 3 0 0 1 3-3z"}),d.jsx("path",{d:"M19 10a7 7 0 0 1-14 0"}),d.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"22"}),d.jsx("line",{x1:"8",y1:"22",x2:"16",y2:"22"})]})}),d.jsx("button",{type:"button",className:"websearch-toggle"+(bl?" active":""),onClick:em,title:"Toggle web search","aria-pressed":bl,children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("circle",{cx:"12",cy:"12",r:"10"}),d.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),d.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})}),d.jsx("button",{className:"button",onClick:gt?Uh:Vu,title:gt?"Cancel generation":"Send","aria-label":gt?"Cancel generation":"Send",disabled:!gt&&(xe||D),children:gt?d.jsx("div",{className:"spinner"}):"Send"})]})]})})]}),l==="dbs"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"header",children:[d.jsx("strong",{children:(Gl==null?void 0:Gl.name)||"Databases"}),vt&&d.jsx("span",{className:"header-subtle",children:`Current chat DB: ${vt.name}${Fi}`})]}),d.jsx(U0,{apiBase:Q,library:Gl,jobs:N,onRefresh:async()=>{await Ar(),await Ql()}})]}),l==="settings"&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"header",children:d.jsxs("strong",{children:[s," Settings"]})}),s==="General"&&d.jsx($0,{onModelChange:je,onBackendApiUrlChange:Su,streamOutput:Ul,onStreamOutputChange:ku,onAudioInputEnabledChange:Nr,onAudioInputDeviceChange:Il,onAudioInputLanguageChange:$l,onLibrariesPurged:Vh}),s==="Interface"&&d.jsx(F0,{}),s==="Websearch"&&d.jsx(W0,{searxUrl:Tr,setSearxUrl:gh,engines:Sn,setEngines:u=>vh(ri(u))})]})]})]})}function lw(){return f.useEffect(()=>{window.electronAPI.getSettings().then(e=>{El(e.colorScheme||"Default")})},[]),d.jsx(Ve.StrictMode,{children:d.jsx(Qy,{children:d.jsx(Cy,{children:d.jsx(th,{path:"/",element:d.jsx(rw,{})})})})})}const ow=Hp(document.getElementById("root"));ow.render(d.jsx(lw,{})); diff --git a/dist/index.html b/dist/index.html index ead9d3e..a0ae6cd 100644 --- a/dist/index.html +++ b/dist/index.html @@ -5,7 +5,7 @@ LLM Desktop - +