diff --git a/backend/app_settings.py b/backend/app_settings.py index 0a3ab8c..55c2b12 100644 --- a/backend/app_settings.py +++ b/backend/app_settings.py @@ -11,11 +11,17 @@ APP_NAME = "Heimgeist" DEFAULT_BACKEND_API_URL = "http://127.0.0.1:8000" DEFAULT_OLLAMA_API_URL = "http://127.0.0.1:11434" DEFAULT_EMBED_MODEL = "nomic-embed-text:latest" +DEFAULT_RERANK_MODEL = DEFAULT_EMBED_MODEL +DEFAULT_TRANSCRIPTION_MODEL = "base" BGE_EMBED_MODEL = "bge-m3:latest" DEFAULT_SETTINGS: Dict[str, Any] = { "backendApiUrl": DEFAULT_BACKEND_API_URL, "ollamaApiUrl": DEFAULT_OLLAMA_API_URL, + "chatModel": "llama3", + "visionModel": "", "embedModel": DEFAULT_EMBED_MODEL, + "rerankModel": DEFAULT_RERANK_MODEL, + "transcriptionModel": DEFAULT_TRANSCRIPTION_MODEL, } @@ -63,10 +69,31 @@ def normalize_embed_model(value: Any) -> str: if not isinstance(value, str): return DEFAULT_EMBED_MODEL - trimmed = value.strip().lower() - if trimmed in {"bge", "bge-m3", BGE_EMBED_MODEL}: + trimmed = value.strip() + if not trimmed: + return DEFAULT_EMBED_MODEL + + lowered = trimmed.lower() + if lowered in {"bge", "bge-m3", BGE_EMBED_MODEL}: return BGE_EMBED_MODEL - return DEFAULT_EMBED_MODEL + if lowered in {"nomic", "nomic-embed-text", DEFAULT_EMBED_MODEL}: + return DEFAULT_EMBED_MODEL + return trimmed + + +def normalize_rerank_model(value: Any) -> str: + return normalize_embed_model(value) + + +def normalize_model_name(value: Any, fallback: str = "") -> str: + if not isinstance(value, str): + return fallback + trimmed = value.strip() + return trimmed or fallback + + +def normalize_transcription_model(value: Any) -> str: + return normalize_model_name(value, DEFAULT_TRANSCRIPTION_MODEL) def load_app_settings() -> Dict[str, Any]: @@ -92,7 +119,15 @@ def load_app_settings() -> Dict[str, Any]: else: settings["backendApiUrl"] = _normalize_url(settings.get("backendApiUrl"), DEFAULT_BACKEND_API_URL) settings["ollamaApiUrl"] = _normalize_url(settings.get("ollamaApiUrl"), DEFAULT_OLLAMA_API_URL) + if "rerankModel" not in raw: + settings["rerankModel"] = settings.get("embedModel") + if "visionModel" not in raw: + settings["visionModel"] = settings.get("chatModel", "") settings["embedModel"] = normalize_embed_model(settings.get("embedModel")) + settings["rerankModel"] = normalize_rerank_model(settings.get("rerankModel")) + settings["chatModel"] = normalize_model_name(settings.get("chatModel")) + settings["visionModel"] = normalize_model_name(settings.get("visionModel")) + settings["transcriptionModel"] = normalize_transcription_model(settings.get("transcriptionModel")) return settings @@ -105,3 +140,13 @@ def get_ollama_api_url() -> str: def get_embed_model_preference() -> str: settings = load_app_settings() return normalize_embed_model(settings.get("embedModel")) + + +def get_rerank_model_preference() -> str: + settings = load_app_settings() + return normalize_rerank_model(settings.get("rerankModel")) + + +def get_transcription_model_preference() -> str: + settings = load_app_settings() + return normalize_transcription_model(settings.get("transcriptionModel")) diff --git a/dist/assets/index-BOZc6wlT.js b/dist/assets/index-BOZc6wlT.js deleted file mode 100644 index 102f9c2..0000000 --- a/dist/assets/index-BOZc6wlT.js +++ /dev/null @@ -1,78 +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 im(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Rd={exports:{}},ni={},Ld={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 El=Symbol.for("react.element"),sm=Symbol.for("react.portal"),am=Symbol.for("react.fragment"),um=Symbol.for("react.strict_mode"),cm=Symbol.for("react.profiler"),dm=Symbol.for("react.provider"),fm=Symbol.for("react.context"),pm=Symbol.for("react.forward_ref"),hm=Symbol.for("react.suspense"),mm=Symbol.for("react.memo"),gm=Symbol.for("react.lazy"),Qu=Symbol.iterator;function vm(e){return e===null||typeof e!="object"?null:(e=Qu&&e[Qu]||e["@@iterator"],typeof e=="function"?e:null)}var jd={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Td=Object.assign,Pd={};function Sr(e,t,n){this.props=e,this.context=t,this.refs=Pd,this.updater=n||jd}Sr.prototype.isReactComponent={};Sr.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")};Sr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Id(){}Id.prototype=Sr.prototype;function ya(e,t,n){this.props=e,this.context=t,this.refs=Pd,this.updater=n||jd}var wa=ya.prototype=new Id;wa.constructor=ya;Td(wa,Sr.prototype);wa.isPureReactComponent=!0;var Gu=Array.isArray,$d=Object.prototype.hasOwnProperty,Sa={current:null},Md={key:!0,ref:!0,__self:!0,__source:!0};function Ad(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)$d.call(t,r)&&!Md.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}}}})(Ud);zd.exports=Ud;var Lm=zd.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 jm=f,it=Lm;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"),ws=Object.prototype.hasOwnProperty,Tm=/^[: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]*$/,Ju={},Xu={};function Pm(e){return ws.call(Xu,e)?!0:ws.call(Ju,e)?!1:Tm.test(e)?Xu[e]=!0:(Ju[e]=!0,!1)}function Im(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 $m(e,t,n,r){if(t===null||typeof t>"u"||Im(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 De={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){De[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];De[t]=new Ye(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){De[e]=new Ye(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){De[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){De[e]=new Ye(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){De[e]=new Ye(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){De[e]=new Ye(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){De[e]=new Ye(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){De[e]=new Ye(e,5,!1,e.toLowerCase(),null,!1,!1)});var ka=/[\-:]([a-z])/g;function Ea(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(ka,Ea);De[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(ka,Ea);De[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(ka,Ea);De[t]=new Ye(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){De[e]=new Ye(e,1,!1,e.toLowerCase(),null,!1,!1)});De.xlinkHref=new Ye("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){De[e]=new Ye(e,1,!1,e.toLowerCase(),null,!0,!0)});function Ca(e,t,n,r){var l=De.hasOwnProperty(t)?De[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{bi=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Vr(e):""}function Mm(e){switch(e.tag){case 5:return Vr(e.type);case 16:return Vr("Lazy");case 13:return Vr("Suspense");case 19:return Vr("SuspenseList");case 0:case 2:case 15:return e=Bi(e.type,!1),e;case 11:return e=Bi(e.type.render,!1),e;case 1:return e=Bi(e.type,!0),e;default:return""}}function Es(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 Jn:return"Fragment";case Yn:return"Portal";case Ss:return"Profiler";case Na:return"StrictMode";case xs:return"Suspense";case ks:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Hd:return(e.displayName||"Context")+".Consumer";case Bd:return(e._context.displayName||"Context")+".Provider";case _a:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ra:return t=e.displayName||null,t!==null?t:Es(e.type)||"Memo";case Zt:t=e._payload,e=e._init;try{return Es(e(t))}catch{}}return null}function Am(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 Es(t);case 8:return t===Na?"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 Vd(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Dm(e){var t=Vd(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 Jl(e){e._valueTracker||(e._valueTracker=Dm(e))}function Kd(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Vd(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function To(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 Cs(e,t){var n=t.checked;return ye({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Zu(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 Qd(e,t){t=t.checked,t!=null&&Ca(e,"checked",t,!1)}function Ns(e,t){Qd(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")?_s(e,t.type,n):t.hasOwnProperty("defaultValue")&&_s(e,t.type,hn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function ec(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 _s(e,t,n){(t!=="number"||To(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Kr=Array.isArray;function sr(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=Xl.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function ol(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Yr={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},Om=["Webkit","ms","Moz","O"];Object.keys(Yr).forEach(function(e){Om.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Yr[t]=Yr[e]})});function Xd(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Yr.hasOwnProperty(e)&&Yr[e]?(""+t).trim():t+"px"}function qd(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=Xd(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var Fm=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 js(e,t){if(t){if(Fm[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 Ts(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 Ps=null;function La(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Is=null,ar=null,ur=null;function rc(e){if(e=_l(e)){if(typeof Is!="function")throw Error(j(280));var t=e.stateNode;t&&(t=si(t),Is(e.stateNode,e.type,t))}}function Zd(e){ar?ur?ur.push(e):ur=[e]:ar=e}function ef(){if(ar){var e=ar,t=ur;if(ur=ar=null,rc(e),t)for(e=0;e>>=0,e===0?32:31-(Ym(e)/Jm|0)|0}var ql=64,Zl=4194304;function Qr(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 Mo(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=Qr(s):(o&=i,o!==0&&(r=Qr(o)))}else i=n&~l,i!==0?r=Qr(i):o!==0&&(r=Qr(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 Cl(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 eg(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=Xr),fc=" ",pc=!1;function xf(e,t){switch(e){case"keyup":return Lg.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function kf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Xn=!1;function Tg(e,t){switch(e){case"compositionend":return kf(t);case"keypress":return t.which!==32?null:(pc=!0,fc);case"textInput":return e=t.data,e===fc&&pc?null:e;default:return null}}function Pg(e,t){if(Xn)return e==="compositionend"||!Da&&xf(e,t)?(e=wf(),yo=$a=rn=null,Xn=!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=vc(n)}}function _f(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?_f(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Rf(){for(var e=window,t=To();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=To(e.document)}return t}function Oa(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 Ug(e){var t=Rf(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&_f(n.ownerDocument.documentElement,n)){if(r!==null&&Oa(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=yc(n,o);var i=yc(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,qn=null,Fs=null,Zr=null,zs=!1;function wc(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;zs||qn==null||qn!==To(r)||(r=qn,"selectionStart"in r&&Oa(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}),Zr&&dl(Zr,r)||(Zr=r,r=Oo(Fs,"onSelect"),0tr||(e.current=Vs[tr],Vs[tr]=null,tr--)}function ie(e,t){tr++,Vs[tr]=e.current,e.current=t}var mn={},Be=vn(mn),qe=vn(!1),In=mn;function hr(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 zo(){de(qe),de(Be)}function _c(e,t,n){if(Be.current!==mn)throw Error(j(168));ie(Be,t),ie(qe,n)}function Df(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,Am(e)||"Unknown",l));return ye({},n,r)}function Uo(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||mn,In=Be.current,ie(Be,e),ie(qe,qe.current),!0}function Rc(e,t,n){var r=e.stateNode;if(!r)throw Error(j(169));n?(e=Df(e,t,In),r.__reactInternalMemoizedMergedChildContext=e,de(qe),de(Be),ie(Be,e)):de(qe),ie(qe,n)}var Dt=null,ai=!1,ns=!1;function Of(e){Dt===null?Dt=[e]:Dt.push(e)}function qg(e){ai=!0,Of(e)}function yn(){if(!ns&&Dt!==null){ns=!0;var e=0,t=ne;try{var n=Dt;for(ne=1;e>=i,l-=i,Ot=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===Jn&&m.key===null&&(m=m.props.children),typeof m=="object"&&m!==null){switch(m.$$typeof){case Yl:e:{for(var T=m.key,I=h;I!==null;){if(I.key===T){if(T=m.type,T===Jn){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&&Tc(T)===I.type){n(v,I.sibling),h=l(I,m.props),h.ref=Ur(v,I,m),h.return=v,v=h;break e}n(v,I);break}else t(v,I);I=I.sibling}m.type===Jn?(h=Pn(m.props.children,v.mode,C,m.key),h.return=v,v=h):(C=_o(m.type,m.key,m.props,null,v.mode,C),C.ref=Ur(v,h,m),C.return=v,v=C)}return i(v);case Yn: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=cs(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(Kr(m))return E(v,h,m,C);if(Ar(m))return N(v,h,m,C);io(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=us(m,v.mode,C),h.return=v,v=h),i(v)):n(v,h)}return L}var gr=bf(!0),Bf=bf(!1),Ho=vn(null),Wo=null,lr=null,ba=null;function Ba(){ba=lr=Wo=null}function Ha(e){var t=Ho.current;de(Ho),e._currentValue=t}function Gs(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 dr(e,t){Wo=e,ba=lr=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(ba!==e)if(e={context:e,memoizedValue:t,next:null},lr===null){if(Wo===null)throw Error(j(308));lr=e,Wo.dependencies={lanes:0,firstContext:e}}else lr=lr.next=e;return t}var Ln=null;function Wa(e){Ln===null?Ln=[e]:Ln.push(e)}function Hf(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,Wa(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 Va(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Wf(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,Wa(r)):(t.next=l.next,l.next=t),r.interleaved=t,Ht(e,n)}function So(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,Ta(e,n)}}function Pc(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 Vo(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 Ic(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=ls.transition;ls.transition={};try{e(!1),t()}finally{ne=n,ls.transition=r}}function sp(){return mt().memoizedState}function nv(e,t,n){var r=fn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},ap(e))up(t,n);else if(n=Hf(e,t,n,r),n!==null){var l=Qe();Et(n,e,r,l),cp(n,t,r)}}function rv(e,t,n){var r=fn(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(ap(e))up(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,Wa(t)):(l.next=a.next,a.next=l),t.interleaved=l;return}}catch{}finally{}n=Hf(e,t,l,r),n!==null&&(l=Qe(),Et(n,e,r,l),cp(n,t,r))}}function ap(e){var t=e.alternate;return e===ge||t!==null&&t===ge}function up(e,t){el=Qo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function cp(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ta(e,n)}}var Go={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},lv={readContext:ht,useCallback:function(e,t){return Lt().memoizedState=[e,t===void 0?null:t],e},useContext:ht,useEffect:Mc,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,ko(4194308,4,np.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ko(4194308,4,e,t)},useInsertionEffect:function(e,t){return ko(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=nv.bind(null,ge,e),[r.memoizedState,e]},useRef:function(e){var t=Lt();return e={current:e},t.memoizedState=e},useState:$c,useDebugValue:Za,useDeferredValue:function(e){return Lt().memoizedState=e},useTransition:function(){var e=$c(!1),t=e[0];return e=tv.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||Gf(r,t,n)}l.memoizedState=n;var o={value:n,getSnapshot:t};return l.queue=o,Mc(Jf.bind(null,r,o,e),[e]),r.flags|=2048,wl(9,Yf.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=Lt(),t=Ie.identifierPrefix;if(pe){var n=Ft,r=Ot;n=(r&~(1<<32-kt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=vl++,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[hl]=r,Sp(e,t,!1,!1),t.stateNode=e;e:{switch(i=Ts(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;lwr&&(t.flags|=128,r=!0,br(o,!1),t.lanes=4194304)}else{if(!r)if(e=Ko(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>wr&&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 ou(),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 fv(e,t){switch(za(t),t.tag){case 1:return Ze(t.type)&&zo(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return vr(),de(qe),de(Be),Ga(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Qa(t),null;case 13:if(de(me),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(j(340));mr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return de(me),null;case 4:return vr(),null;case 10:return Ha(t.type._context),null;case 22:case 23:return ou(),null;case 24:return null;default:return null}}var ao=!1,be=!1,pv=typeof WeakSet=="function"?WeakSet:Set,D=null;function or(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 ra(e,t,n){try{n()}catch(r){Se(e,t,r)}}var Vc=!1;function hv(e,t){if(Us=Ao,e=Rf(),Oa(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(bs={focusedElem:e,selectionRange:n},Ao=!1,D=t;D!==null;)if(t=D,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,D=e;else for(;D!==null;){t=D;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,D=e;break}D=t.return}return E=Vc,Vc=!1,E}function tl(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&&ra(t,n,o)}l=l.next}while(l!==r)}}function di(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 la(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 Ep(e){var t=e.alternate;t!==null&&(e.alternate=null,Ep(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[jt],delete t[hl],delete t[Ws],delete t[Jg],delete t[Xg])),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 Cp(e){return e.tag===5||e.tag===3||e.tag===4}function Kc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Cp(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 oa(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=Fo));else if(r!==4&&(e=e.child,e!==null))for(oa(e,t,n),e=e.sibling;e!==null;)oa(e,t,n),e=e.sibling}function ia(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(ia(e,t,n),e=e.sibling;e!==null;)ia(e,t,n),e=e.sibling}var Me=null,St=!1;function qt(e,t,n){for(n=n.child;n!==null;)Np(e,t,n),n=n.sibling}function Np(e,t,n){if(Tt&&typeof Tt.onCommitFiberUnmount=="function")try{Tt.onCommitFiberUnmount(ri,n)}catch{}switch(n.tag){case 5:be||or(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?ts(e.parentNode,n):e.nodeType===1&&ts(e,n),ul(e)):ts(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)&&ra(n,t,i),l=l.next}while(l!==r)}qt(e,t,n);break;case 1:if(!be&&(or(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 Qc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new pv),t.forEach(function(r){var l=Ev.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*gv(r/1960))-r,10e?16:e,ln===null)var r=!1;else{if(e=ln,ln=null,Xo=0,ee&6)throw Error(j(331));var l=ee;for(ee|=4,D=e.current;D!==null;){var o=D,i=o.child;if(D.flags&16){var s=o.deletions;if(s!==null){for(var a=0;ake()-ru?Tn(e,0):nu|=n),et(e,t)}function $p(e,t){t===0&&(e.mode&1?(t=Zl,Zl<<=1,!(Zl&130023424)&&(Zl=4194304)):t=1);var n=Qe();e=Ht(e,t),e!==null&&(Cl(e,t,n),et(e,n))}function kv(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),$p(e,n)}function Ev(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),$p(e,n)}var Mp;Mp=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,cv(e,t,n);Xe=!!(e.flags&131072)}else Xe=!1,pe&&t.flags&1048576&&Ff(t,Bo,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Eo(e,t),e=t.pendingProps;var l=hr(t,Be.current);dr(t,n),l=Ja(null,t,r,e,l,n);var o=Xa();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,Uo(t)):o=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,Va(t),l.updater=ci,t.stateNode=l,l._reactInternals=t,Js(t,r,e,n),t=Zs(null,t,r,!0,o,n)):(t.tag=0,pe&&o&&Fa(t),Ke(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Eo(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=Nv(r),e=wt(r,e),l){case 0:t=qs(null,t,r,e,n);break e;case 1:t=Bc(null,t,r,e,n);break e;case 11:t=Uc(null,t,r,e,n);break e;case 14:t=bc(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),qs(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:wt(r,l),Bc(e,t,r,l,n);case 3:e:{if(vp(t),e===null)throw Error(j(387));r=t.pendingProps,o=t.memoizedState,l=o.element,Wf(e,t),Vo(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=yr(Error(j(423)),t),t=Hc(e,t,r,n,l);break e}else if(r!==l){l=yr(Error(j(424)),t),t=Hc(e,t,r,n,l);break e}else for(lt=un(t.stateNode.containerInfo.firstChild),ot=t,pe=!0,xt=null,n=Bf(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(mr(),r===l){t=Wt(e,t,n);break e}Ke(e,t,r,n)}t=t.child}return t;case 5:return Vf(t),e===null&&Qs(t),r=t.type,l=t.pendingProps,o=e!==null?e.memoizedProps:null,i=l.children,Bs(r,l)?i=null:o!==null&&Bs(r,o)&&(t.flags|=32),gp(e,t),Ke(e,t,i,n),t.child;case 6:return e===null&&Qs(t),null;case 13:return yp(e,t,n);case 4:return Ka(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=gr(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),Uc(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(Ho,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),Gs(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),Gs(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,dr(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),bc(e,t,r,l,n);case 15:return hp(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:wt(r,l),Eo(e,t),t.tag=1,Ze(r)?(e=!0,Uo(t)):e=!1,dr(t,n),dp(t,r,l),Js(t,r,l,n),Zs(null,t,r,!0,e,n);case 19:return wp(e,t,n);case 22:return mp(e,t,n)}throw Error(j(156,t.tag))};function Ap(e,t){return af(e,t)}function Cv(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 Cv(e,t,n,r)}function su(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Nv(e){if(typeof e=="function")return su(e)?1:0;if(e!=null){if(e=e.$$typeof,e===_a)return 11;if(e===Ra)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 _o(e,t,n,r,l,o){var i=2;if(r=e,typeof e=="function")su(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case Jn:return Pn(n.children,l,o,t);case Na:i=8,l|=8;break;case Ss:return e=ft(12,n,t,l|2),e.elementType=Ss,e.lanes=o,e;case xs:return e=ft(13,n,t,l),e.elementType=xs,e.lanes=o,e;case ks:return e=ft(19,n,t,l),e.elementType=ks,e.lanes=o,e;case Wd:return pi(n,l,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Bd:i=10;break e;case Hd:i=9;break e;case _a:i=11;break e;case Ra: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 pi(e,t,n,r){return e=ft(22,e,r,t),e.elementType=Wd,e.lanes=n,e.stateNode={isHidden:!1},e}function us(e,t,n){return e=ft(6,e,null,t),e.lanes=n,e}function cs(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 _v(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=Wi(0),this.expirationTimes=Wi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Wi(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function au(e,t,n,r,l,o,i,s,a){return e=new _v(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},Va(o),e}function Rv(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(zp)}catch(e){console.error(e)}}zp(),Fd.exports=st;var Up=Fd.exports,bp,td=Up;bp=td.createRoot,td.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 nd="popstate";function Iv(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),da("",{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:xl(o))}function r(l,o){Nt(l.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(o)})`)}return Mv(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 $v(){return Math.random().toString(36).substring(2,10)}function rd(e,t){return{usr:e.state,key:e.key,idx:t}}function da(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||$v()}}function xl({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 Mv(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=da(N.location,L,v);n&&n(h,L),c=g()+1;let m=rd(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=da(N.location,L,v);n&&n(h,L),c=g();let m=rd(h,c),C=N.createHref(h);i.replaceState(m,"",C),o&&a&&a({action:s,location:N.location,delta:0})}function E(L){return Av(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(nd,y),a=L,()=>{l.removeEventListener(nd,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 Av(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:xl(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function Bp(e,t,n="/"){return Dv(e,t,n,!1)}function Dv(e,t,n,r){let l=typeof t=="string"?zn(t):t,o=Vt(l.pathname||"/",n);if(o==null)return null;let i=Hp(e);Ov(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}".`),Hp(i.children,t,w,y,a)),!(i.path==null&&!i.index)&&t.push({path:y,score:Wv(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 Wp(i.path))o(i,s,!0,c)}),t}function Wp(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=Wp(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 Ov(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Vv(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Fv=/^:[\w-]+$/,zv=3,Uv=2,bv=1,Bv=10,Hv=-2,ld=e=>e==="*";function Wv(e,t){let n=e.split("/"),r=n.length;return n.some(ld)&&(r+=Hv),t&&(r+=Uv),n.filter(l=>!ld(l)).reduce((l,o)=>l+(Fv.test(o)?zv:o===""?bv:Bv),r)}function Vv(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 Kv(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 Qv(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 Gv(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 Yv(e,t="/"){let{pathname:n,search:r="",hash:l=""}=typeof e=="string"?zn(e):e;return{pathname:n?n.startsWith("/")?n:Jv(n,t):t,search:Zv(r),hash:ey(l)}}function Jv(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 ds(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 Xv(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Vp(e){let t=Xv(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Kp(e,t,n,r=!1){let l;typeof e=="string"?l=zn(e):(l={...e},ve(!l.pathname||!l.pathname.includes("?"),ds("?","pathname","search",l)),ve(!l.pathname||!l.pathname.includes("#"),ds("#","pathname","hash",l)),ve(!l.search||!l.search.includes("#"),ds("#","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=Yv(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,"/"),qv=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Zv=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,ey=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function ty(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}var Qp=["POST","PUT","PATCH","DELETE"];new Set(Qp);var ny=["GET",...Qp];new Set(ny);var Er=f.createContext(null);Er.displayName="DataRouter";var yi=f.createContext(null);yi.displayName="DataRouterState";f.createContext(!1);var Gp=f.createContext({isTransitioning:!1});Gp.displayName="ViewTransition";var ry=f.createContext(new Map);ry.displayName="Fetchers";var ly=f.createContext(null);ly.displayName="Await";var It=f.createContext(null);It.displayName="Navigation";var Ll=f.createContext(null);Ll.displayName="Location";var Qt=f.createContext({outlet:null,matches:[],isDataRoute:!1});Qt.displayName="Route";var fu=f.createContext(null);fu.displayName="RouteError";function oy(e,{relative:t}={}){ve(jl(),"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}=Tl(e,{relative:t}),s=o;return n!=="/"&&(s=o==="/"?n:Ut([n,o])),r.createHref({pathname:s,search:i,hash:l})}function jl(){return f.useContext(Ll)!=null}function Un(){return ve(jl(),"useLocation() may be used only in the context of a component."),f.useContext(Ll).location}var Yp="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Jp(e){f.useContext(It).static||f.useLayoutEffect(e)}function iy(){let{isDataRoute:e}=f.useContext(Qt);return e?wy():sy()}function sy(){ve(jl(),"useNavigate() may be used only in the context of a component.");let e=f.useContext(Er),{basename:t,navigator:n}=f.useContext(It),{matches:r}=f.useContext(Qt),{pathname:l}=Un(),o=JSON.stringify(Vp(r)),i=f.useRef(!1);return Jp(()=>{i.current=!0}),f.useCallback((a,c={})=>{if(Nt(i.current,Yp),!i.current)return;if(typeof a=="number"){n.go(a);return}let g=Kp(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 Tl(e,{relative:t}={}){let{matches:n}=f.useContext(Qt),{pathname:r}=Un(),l=JSON.stringify(Vp(n));return f.useMemo(()=>Kp(e,JSON.parse(l),r,t==="path"),[e,l,r,t])}function ay(e,t){return Xp(e,t)}function Xp(e,t,n,r,l){var h;ve(jl(),"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||"";qp(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=Bp(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=py(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(Ll.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...k},navigationType:"POP"}},v):v}function uy(){let e=yy(),t=ty(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 cy=f.createElement(uy,null),dy=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(fu.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function fy({routeContext:e,match:t,children:n}){let r=f.useContext(Er);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 py(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||cy,s&&(a<0&&y===0?(qp("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(fy,{match:g,routeContext:{outlet:c,matches:L,isDataRoute:n!=null},children:h})};return n&&(g.route.ErrorBoundary||g.route.errorElement||y===0)?f.createElement(dy,{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 pu(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function hy(e){let t=f.useContext(Er);return ve(t,pu(e)),t}function my(e){let t=f.useContext(yi);return ve(t,pu(e)),t}function gy(e){let t=f.useContext(Qt);return ve(t,pu(e)),t}function hu(e){let t=gy(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 vy(){return hu("useRouteId")}function yy(){var r;let e=f.useContext(fu),t=my("useRouteError"),n=hu("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function wy(){let{router:e}=hy("useNavigate"),t=hu("useNavigate"),n=f.useRef(!1);return Jp(()=>{n.current=!0}),f.useCallback(async(l,o={})=>{Nt(n.current,Yp),n.current&&(typeof l=="number"?e.navigate(l):await e.navigate(l,{fromRouteId:t,...o}))},[e,t])}var od={};function qp(e,t,n){!t&&!od[e]&&(od[e]=!0,Nt(!1,n))}f.memo(Sy);function Sy({routes:e,future:t,state:n,unstable_onError:r}){return Xp(e,void 0,n,r,t)}function Zp(e){ve(!1,"A is only ever to be used as the child of element, never rendered directly. Please wrap your in a .")}function xy({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:l,static:o=!1}){ve(!jl(),"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(Ll.Provider,{children:t,value:k}))}function ky({children:e,location:t}){return ay(fa(e),t)}function fa(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,fa(r.props.children,o));return}ve(r.type===Zp,`[${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=fa(r.props.children,o)),n.push(i)}),n}var Ro="get",Lo="application/x-www-form-urlencoded";function wi(e){return e!=null&&typeof e.tagName=="string"}function Ey(e){return wi(e)&&e.tagName.toLowerCase()==="button"}function Cy(e){return wi(e)&&e.tagName.toLowerCase()==="form"}function Ny(e){return wi(e)&&e.tagName.toLowerCase()==="input"}function _y(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Ry(e,t){return e.button===0&&(!t||t==="_self")&&!_y(e)}var fo=null;function Ly(){if(fo===null)try{new FormData(document.createElement("form"),0),fo=!1}catch{fo=!0}return fo}var jy=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function fs(e){return e!=null&&!jy.has(e)?(Nt(!1,`"${e}" is not a valid \`encType\` for \`
\`/\`\` and will default to "${Lo}"`),null):e}function Ty(e,t){let n,r,l,o,i;if(Cy(e)){let s=e.getAttribute("action");r=s?Vt(s,t):null,n=e.getAttribute("method")||Ro,l=fs(e.getAttribute("enctype"))||Lo,o=new FormData(e)}else if(Ey(e)||Ny(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 H0(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 V0(e){const t=String(e||""),n=t.trim();if(!n||/[\r\n]/.test(n))return t;const r=n.toLowerCase();return r.includes("error")&&r.includes("http")&&r.includes("502")?`${n} - -Ollama returned HTTP 502. This usually means Ollama stopped responding or crashed while handling the request. - -If other models still work, try updating Ollama. Newer models may require a newer Ollama release.`:t}function ch(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 K0({content:e,streamOutput:t,sources:n}){const r=V0(e||""),{think:l,answer:o}=ch(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:Sd(l)}})]}),d.jsx("div",{className:"msg-content",dangerouslySetInnerHTML:{__html:Sd(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 gs({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 xd="websearch.searxUrl",kd="websearch.engines",Ed="chat.libraryBySession",Cd="http://127.0.0.1:8888",vs=6,ys=20*1024*1024,Q0=5*60*1e3,G0=200;let dh="http://127.0.0.1:8000";const Y0=48,J0=24;function X0(e){return e.backendApiUrl||e.ollamaApiUrl||dh}function q0(e){const t=typeof e=="string"?e.trim():"";return!t||t==="http://localhost:8888"?Cd:t}function ho(e){var n;return Array.from(((n=e==null?void 0:e.dataTransfer)==null?void 0:n.types)||[]).includes("Files")}function va(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 Nd(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"&&va((i=o.getAsFile)==null?void 0:i.call(o))}):Array.from(((l=e==null?void 0:e.dataTransfer)==null?void 0:l.files)||[]).some(va)}function _d(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 Z0(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 ew(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 tw(){var Ku;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(Ed);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,Cr]=f.useState(!1),[xi,Pl]=f.useState(""),[ki,Il]=f.useState(""),[Yt,wn]=f.useState(!0),[Ei,Nr]=f.useState(""),[xe,F]=f.useState(!1),[O,ae]=f.useState(!1),[Te,_r]=f.useState(0),$l=f.useRef(null),Rr=f.useRef(null),Ml=f.useRef([]),Ci=f.useRef(null),Al=f.useRef(""),Dl=f.useRef(null),Ol=f.useRef(null),Ni=f.useRef(0),Fl=f.useRef(null),[Q,yu]=f.useState(dh),[wu,fh]=f.useState("Default"),[zl,Su]=f.useState(!1),[xu,Lr]=f.useState(""),[ph,_i]=f.useState(!1),[jr,hh]=f.useState(()=>q0(localStorage.getItem(xd))),[Sn,mh]=f.useState(()=>b0(localStorage.getItem(kd)));f.useEffect(()=>{localStorage.setItem(xd,jr||"")},[jr]),f.useEffect(()=>{try{localStorage.setItem(kd,JSON.stringify(ti(Sn)))}catch{}},[Sn]);const[Ul,gh]=f.useState(!1),[gt,Ri]=f.useState(!1),[ku,Li]=f.useState(!0),[vh,Bn]=f.useState([]),[bl,Eu]=f.useState({}),[Cu,yh]=f.useState(!1),Nu=f.useRef(!1),[wh,ji]=f.useState(null),[Ti,Bl]=f.useState("");function Sh(u){const p=u.content||"";if(u.role==="assistant")try{const{answer:S}=ch(p);return(S||p).trim()}catch{return p.trim()}return p}async function _u(u){try{await navigator.clipboard.writeText(Sh(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 Tr(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 xh(u,p){const S=await fetch(`${Q}/models/capabilities?name=${encodeURIComponent(u)}`,{signal:p});return Tr(S)}async function kh(){const u=await fetch(`${Q}/ollama/startup-status`);return Tr(u)}async function Eh(){const u=await fetch(`${Q}/startup/prepare-models`,{method:"POST"});return Tr(u)}function Ru(u){if(!!(u!=null&&u.whisper_model_available)){wn(!0),Nr("");return}const S=(u==null?void 0:u.whisper_model)||"base",x=String((u==null?void 0:u.whisper_error)||"").trim();wn(!1),Nr(x||`Whisper ${S} is not available.`)}async function Lu(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 ju(u){const p=Array.from(u||[]).filter(va);if(!p.length||!R)return;const S=Math.max(0,vs-B.length);if(S<=0){window.alert(`You can attach up to ${vs} images per message.`);return}const x=p.slice(0,S),_=x.filter(z=>Number(z.size)>ys),$=x.filter(z=>Number(z.size)<=ys);if(_.length>0&&window.alert(`Images must be ${Math.round(ys/(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 _d(H)})));W(H=>[...H,...z]),p.length>S&&window.alert(`Only the first ${vs} images can be attached.`)}catch(z){console.error("Failed to load image attachments",z),window.alert(`Image import failed: ${$t(z)}`)}}function Ch(u){W(p=>p.filter(S=>S.id!==u))}function Nh(){var u;R&&((u=ut.current)==null||u.click())}function Pi(){Dl.current&&(window.clearInterval(Dl.current),Dl.current=null),Ol.current&&(window.clearTimeout(Ol.current),Ol.current=null)}function Ii(u=Rr.current){Pi(),ha(u),Rr.current===u&&(Rr.current=null),$l.current=null}async function _h(u,p){if(!Q)throw new Error("The Heimgeist backend is not configured.");const S=new AbortController;Fl.current=S,ae(!0);try{const x=await _d(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:ki||null})}),le=await Tr(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=>Z0(he,te)),requestAnimationFrame(()=>{var he;return(he=$e.current)==null?void 0:he.focus()})}catch(x){if(_t(x))return;throw x}finally{Fl.current===S&&(Fl.current=null),ae(!1)}}async function Pr(u={}){const{shouldTranscribe:p=!0}=u,S=$l.current,x=Ci.current,_=Al.current||(S==null?void 0:S.mimeType)||"audio/webm";if(!(!S||!x)){F(!1),Pi();try{S.state!=="inactive"&&S.stop();const $=await x;if(!p)return;if(!$||$.size<=0)throw new Error("Recorded audio was empty.");await _h($,_)}catch($){p&&(console.error("Failed to stop microphone recording",$),window.alert(`Microphone transcription failed: ${$t($)}`))}finally{Ci.current=null,Ml.current=[],Al.current="",Ni.current=0,_r(0)}}}async function Rh(){if(!bn||!Yt||xe||O||gt)return;if(!Si()){window.alert("Microphone capture is not available in this environment.");return}let u=null;try{u=await navigator.mediaDevices.getUserMedia(k0(xi))}catch(x){console.error("Failed to access microphone",x),window.alert(`Microphone access failed: ${$t(x)}`);return}const p=C0();let S=null;try{S=p?new MediaRecorder(u,{mimeType:p}):new MediaRecorder(u)}catch(x){Ii(u),console.error("Failed to create audio recorder",x),window.alert(`Microphone recording is not available: ${$t(x)}`);return}Rr.current=u,$l.current=S,Ml.current=[],Al.current=S.mimeType||p||"audio/webm",Ni.current=Date.now(),_r(0),F(!0),S.ondataavailable=x=>{x.data&&x.data.size>0&&Ml.current.push(x.data)},Ci.current=new Promise((x,_)=>{S.onstop=()=>{const $=new Blob(Ml.current,{type:S.mimeType||Al.current||"audio/webm"});Ii(u),x($)},S.onerror=$=>{Ii(u),_(($==null?void 0:$.error)||new Error("Audio recording failed."))}}),Dl.current=window.setInterval(()=>{_r(Date.now()-Ni.current)},G0),Ol.current=window.setTimeout(()=>{Pr()},Q0),S.start()}async function Lh(){if(!O){if(xe){await Pr();return}await Rh()}}async function jh(u){var S;const p=(S=u.target)==null?void 0:S.files;try{await ju(p)}finally{u.target&&(u.target.value="")}}function Th(u,p){ji(u),Bl(p||"")}function Hl(){ji(null),Bl("")}async function Ph(u){var $;const p=((($=Kn[u])==null?void 0:$.content)||"").trim(),x=(Ti??"").trim();if(x.length===0){Hl();return}if(x===p){Hl();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}})),ji(null),Bl(""),requestAnimationFrame(()=>Oi("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 Tu(u,x)}}async function Tu(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 $=Du(S);let z=p??(((he=x[_])==null?void 0:he.content)||""),H=[];const Z=[];try{const J=Uu(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 Lu(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&&Ul)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:jr||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,zl){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(`HTTP ${oe.status}`);const Ee=(G=oe.body)==null?void 0:G.getReader();if(!Ee)throw new Error("Missing response body");const Xt=new TextDecoder;let Ql=!1;for(;;){const{value:He,done:lm}=await Ee.read();if(lm)break;const om=Xt.decode(He,{stream:!0});nt+=om,xn(S,K,nt),!Ql&&Oe.current!==S&&(Ql=!0,kn(Fi=>({...Fi,[S]:K})),Bn(Fi=>[...new Set([...Fi,S])]))}Oe.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(`HTTP ${K.status}`);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)),Oe.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{$i($)}}const[Pu,Ih]=f.useState({}),Hn=f.useRef({}),[$h,kn]=f.useState({}),En=f.useRef({}),Iu=f.useRef({}),[$u,Wn]=f.useState({}),[Mh,Mu]=f.useState({});f.useEffect(()=>{i.current=l},[l]);const Au=(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)||[];Mu(S=>{const x={};return u.forEach((_,$)=>{if(_.role!=="user")return;const z=Au(_,$,n),Z=(_.content||"").split(/\r\n|\r|\n/).length>30;x[z]=Z?S[z]??!0:!1}),x})},[e,n]);function Ah(u){Mu(p=>({...p,[u]:!(p[u]??!0)}))}const Ir=Ve.useCallback((u,p)=>{Ih(S=>{const x={...S,[u]:p};return Hn.current=x,x})},[]),Vn=f.useRef(null),Dh=f.useRef(!1),Oh=f.useRef(null),Oe=f.useRef(n);f.useEffect(()=>{Oe.current=n},[n]);const Du=Ve.useCallback(u=>{const p=new AbortController;return Vn.current={controller:p,sessionId:u},Ri(!0),p},[]),$i=Ve.useCallback(u=>{var p;((p=Vn.current)==null?void 0:p.controller)===u&&(Vn.current=null,Ri(!1))},[]),Fh=Ve.useCallback(()=>{const u=Vn.current;u&&(Vn.current=null,u.controller.abort(),Ri(!1))},[]);f.useEffect(()=>()=>{var u;(u=Vn.current)==null||u.controller.abort()},[]);const Jt=f.useRef(null),[zh,Uh]=f.useState(230),[Wl,Ou]=f.useState(!1),bh=Ve.useCallback(u=>{Ou(!0)},[]),$r=Ve.useCallback(()=>{Ou(!1)},[]),Mi=Ve.useCallback(u=>{if(Wl){const p=Math.max(230,Math.min(500,u.clientX));Uh(p)}},[Wl]);Ve.useEffect(()=>(window.addEventListener("mousemove",Mi),window.addEventListener("mouseup",$r),window.addEventListener("blur",$r),()=>{window.removeEventListener("mousemove",Mi),window.removeEventListener("mouseup",$r),window.removeEventListener("blur",$r)}),[Mi,$r]),Ve.useEffect(()=>(Wl?document.body.classList.add("no-select"):document.body.classList.remove("no-select"),()=>{document.body.classList.remove("no-select")}),[Wl]),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||(yu(X0(p)),fh(p.colorScheme||"Default"),je(p.chatModel||""),Su(p.streamOutput||!1),Cr(p.audioInputEnabled===!0),Pl(typeof p.audioInputDeviceId=="string"?p.audioInputDeviceId:""),Il(typeof p.audioInputLanguage=="string"?p.audioInputLanguage:""),Eu(p.scrollPositions||{}),kl(p.colorScheme||"Default"))}).finally(()=>{u||yh(!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 xh(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||Pr({shouldTranscribe:!1})},[bn,xe]),f.useEffect(()=>{Yt||!xe||Pr({shouldTranscribe:!1})},[Yt,xe]),f.useEffect(()=>{l==="chats"||!xe||Pr()},[l,xe]),f.useEffect(()=>()=>{var p;(p=Fl.current)==null||p.abort(),Pi();const u=$l.current;if(u){u.ondataavailable=null,u.onstop=null,u.onerror=null;try{u.state!=="inactive"&&u.stop()}catch{}}ha(Rr.current)},[]),f.useEffect(()=>{if(!Cu||ku||!Q||Nu.current)return;Nu.current=!0;let u=!1;const p=window.setTimeout(()=>{(async()=>{let S=!1;try{let x=await kh();if(u)return;if(Ru(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,_i(!0),Lr("Starting Ollama in the background...");const H=await fetch(`${Q}/ollama/start`,{method:"POST"});if(x=await Tr(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,_i(!0),Lr(_&&$?`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 Eh();if(u)return;Ru((z==null?void 0:z.ollama)||x)}}catch(x){u||(console.warn("startup Ollama check failed",x),wn(!1),Nr(`Whisper availability could not be verified: ${$t(x)}`),S&&window.alert(`Startup action failed: ${$t(x)}`))}finally{u||(_i(!1),Lr(""))}})()},1200);return()=>{u=!0,window.clearTimeout(p)}},[Q,ku,Cu]),f.useEffect(()=>{kl(wu)},[wu]);const Bh=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 Mr(){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 Vl(){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 Fu(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 Mr(),_!=null&&_.slug&&h(_.slug)}catch(x){console.error("Failed to create library",x),U(String((x==null?void 0:x.message)||x))}}async function Hh(){E([]),L([]),h(null),w(null),Le(!1),C({}),await Mr(),await Vl()}f.useEffect(()=>{Q&&(Li(!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),Li(!1)}).catch(()=>{Li(!1)}))},[Q]),f.useEffect(()=>{Q&&(Mr(),Vl())},[Q]),f.useEffect(()=>{try{localStorage.setItem(Ed,JSON.stringify(m||{}))}catch{}},[m]),f.useEffect(()=>{if(!Q)return;const u=setInterval(()=>{Mr(),Vl()},3e3);return()=>clearInterval(u)},[Q,l,v]),f.useEffect(()=>{Bh(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 Ai=u=>{o(u)},Wh=u=>{Zh(u)},Kn=f.useMemo(()=>{var u;return((u=e.find(p=>p.session_id===n))==null?void 0:u.messages)||[]},[n,e]),Kl=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]),zu=f.useMemo(()=>Mt?N.some(u=>u.slug===Mt&&(u.status==="queued"||u.status==="running")):!1,[Mt,N]),Di=f.useMemo(()=>{var u,p;return vt?(u=vt.files)!=null&&u.length?(p=vt.states)!=null&&p.is_indexed?"":zu?" (syncing)":" (needs sync)":" (empty)":""},[vt,zu]);function Vh(u){return u&&m[u]||null}function Uu(u){const p=Vh(u);return p&&k.find(S=>S.slug===p)||null}function bu(u){return u?N.some(p=>p.slug===u&&(p.status==="queued"||p.status==="running")):!1}function Bu(u,p){u&&C(S=>{const x={...S||{}};return p?x[u]=p:delete x[u],x})}function Kh(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;Eu(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-_<=J0;if(n){const z=Iu.current[n],H=typeof z=="number"&&Su.removeEventListener("scroll",p)},[n,Ir]),f.useEffect(()=>{const u=n;u&&Pu[u]===!1&&Wn(p=>{if(!(u in p))return p;const S={...p};return delete S[u],S})},[n,Pu]),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 Oi=(u="smooth",p=null)=>{const S=we.current;if(!S)return;const x=p??Oe.current;Oe.current===x&&(S.scrollTo({top:S.scrollHeight,behavior:u}),Ir(x,!1))},Qn=(u,p="auto",S=null)=>{const x=we.current;if(!x)return;const _=S??Oe.current;if(Oe.current!==_)return;const $=document.getElementById(u);if($){const z=Math.max(0,$.offsetTop-Y0);x.scrollTo({top:z,behavior:p})}},Qh=()=>{const u=Oe.current,p=$u[u];p&&(Qn(p,"smooth",u),Wn(S=>{const{[u]:x,..._}=S;return _}))},Gh=u=>{l!=="chats"||!ho(u)||(u.preventDefault(),tt.current+=1,R&&Nd(u)&&re(!0))},Yh=u=>{l!=="chats"||!ho(u)||(u.preventDefault(),u.dataTransfer.dropEffect=R?"copy":"none",R&&Nd(u)&&!q&&re(!0))},Jh=u=>{l!=="chats"||!ho(u)||(tt.current=Math.max(0,tt.current-1),tt.current===0&&re(!1))},Xh=async u=>{var p,S;l!=="chats"||!ho(u)||(u.preventDefault(),tt.current=0,re(!1),R&&(await ju((p=u.dataTransfer)==null?void 0:p.files),(S=$e.current)==null||S.focus()))};async function Hu(){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 Wu();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()}`};Dh.current=!0,Oh.current=p,Ir(p,!1),Oe.current===p&&(Jt.current=Oe.current),Up.flushSync(()=>{t(le=>le.map(te=>te.session_id===p?{...te,messages:[...te.messages||[],_]}:te)),P(""),W([])}),requestAnimationFrame(()=>Oi("auto",p));const $=Du(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=Uu(p);if(_.content&&((H=Cn==null?void 0:Cn.states)!=null&&H.is_indexed))try{const G=await Lu(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&&Ul)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:jr||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(` - -`)}`),zl){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(`HTTP ${Ne.status}`);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),Oe.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 Ql=nt.decode(Ee,{stream:!0});J+=Ql,xn(p,G,J),Oe.current===p&&!Hn.current[p]&&Oi("auto",p),Oe.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(`HTTP ${G.status}`);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&&(Oe.current===p?Hn.current[p]?Wn(K=>({...K,[p]:ue})):requestAnimationFrame(()=>Qn(ue,"smooth",p)):kn(K=>({...K,[p]:ue})))}Oe.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=W0(G.title);t(ue=>ue.map(Ne=>Ne.session_id===p?{...Ne,name:J}:Ne))})}catch(le){if(_t(le)){$i($);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{$i($)}}function qh(){gh(u=>!u)}async function Wu(){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 Zh(u){r(u),Bn(S=>S.filter(x=>x!==u));const p=$h[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 em(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 tm(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 Vu(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 nm(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),Kh(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=>{Vu(p.session_id)})},[n,e,Q]);const rm=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:`${zh}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:()=>Ai("chats"),children:"Chats"}),d.jsx("div",{className:`sidebar-tab ${l==="dbs"?"active":""}`,onClick:()=>Ai("dbs"),children:"DBs"}),d.jsx("div",{className:`sidebar-tab ${l==="settings"?"active":""}`,onClick:()=>Ai("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:()=>Wh(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"?em(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:[vh.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(),Vu(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"?tm(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"}),bu(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(),nm(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:Wu,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"?Fu():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:()=>Fu(),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:bh})]}),d.jsxs("div",{className:`main-content${l==="chats"&&q?" main-content--drag-active":""}`,onDragEnter:Gh,onDragOver:Yh,onDragLeave:Jh,onDrop:Xh,children:[xu&&d.jsxs("div",{className:"startup-task-banner",role:"status","aria-live":"polite",children:[ph&&d.jsx("div",{className:"spinner startup-task-banner__spinner"}),d.jsx("div",{className:"startup-task-banner__text",children:xu})]}),l==="chats"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"header",children:[d.jsxs("strong",{children:["Chat - ",((Ku=e.find(u=>u.session_id===n))==null?void 0:Ku.name)||"New Chat"]}),vt&&d.jsx("span",{className:"header-subtle",children:`DB: ${vt.name}${Di}`})]}),d.jsx("div",{className:`chat${q?" chat--drag-active":""}`,ref:we,onClick:rm,children:Kn.map((u,p)=>{const S=u.role==="user"&&wh===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(K0,{content:u.content,streamOutput:zl,sources:u.sources}),!gt&&d.jsxs("div",{className:"message-options-bar assistant-options",children:[d.jsx("button",{className:"icon-button",title:"Copy message",onClick:()=>_u(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:()=>Tu(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(gs,{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:Ti}),d.jsx(fd,{className:"edit-message-input edit-overlay",value:Ti,onChange:x=>Bl(x.target.value),onBlur:Hl,onKeyDown:x=>{x.key==="Escape"&&(x.preventDefault(),Hl()),x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),Ph(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=Au(u,p,n),Z=z?Mh[H]??!0:!1,le=Z?$.slice(0,30).join(` -`)+` -…`:x,te=!!x.trim();return d.jsxs(d.Fragment,{children:[d.jsx(gs,{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:()=>Ah(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:()=>Th(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:()=>_u(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),$u[n]&&d.jsxs("button",{className:"new-msg-tip",onClick:Qh,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:jh,tabIndex:-1}),d.jsx(gs,{attachments:B,className:"composer-attachment-strip",removable:!0,onRemove:Ch}),(xe||O)&&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 ${ew(Te)}`:"Transcribing audio…"})]}),d.jsxs("div",{className:"footer-content-wrapper",children:[d.jsx(fd,{ref:$e,className:"input",value:X,onChange:u=>P(u.target.value),onKeyDown:u=>{u.key==="Enter"&&!u.shiftKey&&!xe&&!O&&(u.preventDefault(),Hu())},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}${Di}`:"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:()=>{Bu(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=bu(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:()=>{Bu(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:Nh,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||O?" active":"")+(xe?" recording":"")+(O?" transcribing":""),onClick:Lh,title:Yt?xe?"Stop voice input":O?"Transcribing audio":"Start voice input":Ei||"Whisper is not available for audio input.","aria-label":Yt?xe?"Stop voice input":O?"Transcribing audio":"Start voice input":Ei||"Whisper is not available for audio input.","aria-pressed":xe,disabled:!Yt||O||gt,children:O?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"+(Ul?" active":""),onClick:qh,title:"Toggle web search","aria-pressed":Ul,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?Fh:Hu,title:gt?"Cancel generation":"Send","aria-label":gt?"Cancel generation":"Send",disabled:!gt&&(xe||O),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:(Kl==null?void 0:Kl.name)||"Databases"}),vt&&d.jsx("span",{className:"header-subtle",children:`Current chat DB: ${vt.name}${Di}`})]}),d.jsx(F0,{apiBase:Q,library:Kl,jobs:N,onRefresh:async()=>{await Mr(),await Vl()}})]}),l==="settings"&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"header",children:d.jsxs("strong",{children:[s," Settings"]})}),s==="General"&&d.jsx(P0,{onModelChange:je,onBackendApiUrlChange:yu,streamOutput:zl,onStreamOutputChange:Su,onAudioInputEnabledChange:Cr,onAudioInputDeviceChange:Pl,onAudioInputLanguageChange:Il,onLibrariesPurged:Hh}),s==="Interface"&&d.jsx(D0,{}),s==="Websearch"&&d.jsx(B0,{searxUrl:jr,setSearxUrl:hh,engines:Sn,setEngines:u=>mh(ti(u))})]})]})]})}function nw(){return f.useEffect(()=>{window.electronAPI.getSettings().then(e=>{kl(e.colorScheme||"Default")})},[]),d.jsx(Ve.StrictMode,{children:d.jsx(Vy,{children:d.jsx(ky,{children:d.jsx(Zp,{path:"/",element:d.jsx(tw,{})})})})})}const rw=bp(document.getElementById("root"));rw.render(d.jsx(nw,{})); diff --git a/dist/assets/index-g7N0HjkK.js b/dist/assets/index-g7N0HjkK.js new file mode 100644 index 0000000..ea44a81 --- /dev/null +++ b/dist/assets/index-g7N0HjkK.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 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 8410f52..ead9d3e 100644 --- a/dist/index.html +++ b/dist/index.html @@ -5,7 +5,7 @@ LLM Desktop - +