diff --git a/dist/assets/index-BvwmOKz6.js b/dist/assets/index-BvwmOKz6.js new file mode 100644 index 0000000..2b484a3 --- /dev/null +++ b/dist/assets/index-BvwmOKz6.js @@ -0,0 +1,74 @@ +(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 om(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var _d={exports:{}},ni={},Rd={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 Sl=Symbol.for("react.element"),im=Symbol.for("react.portal"),sm=Symbol.for("react.fragment"),am=Symbol.for("react.strict_mode"),um=Symbol.for("react.profiler"),cm=Symbol.for("react.provider"),dm=Symbol.for("react.context"),fm=Symbol.for("react.forward_ref"),pm=Symbol.for("react.suspense"),hm=Symbol.for("react.memo"),mm=Symbol.for("react.lazy"),Ku=Symbol.iterator;function gm(e){return e===null||typeof e!="object"?null:(e=Ku&&e[Ku]||e["@@iterator"],typeof e=="function"?e:null)}var jd={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Ld=Object.assign,Td={};function Sr(e,t,n){this.props=e,this.context=t,this.refs=Td,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 Pd(){}Pd.prototype=Sr.prototype;function va(e,t,n){this.props=e,this.context=t,this.refs=Td,this.updater=n||jd}var ya=va.prototype=new Pd;ya.constructor=va;Ld(ya,Sr.prototype);ya.isPureReactComponent=!0;var Qu=Array.isArray,Id=Object.prototype.hasOwnProperty,wa={current:null},$d={key:!0,ref:!0,__self:!0,__source:!0};function Md(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)Id.call(t,r)&&!$d.hasOwnProperty(r)&&(l[r]=t[r]);var s=arguments.length-2;if(s===1)l.children=n;else if(1>>1,te=P[q];if(0>>1;ql(Gt,W))Ael(mt,Gt)?(P[q]=mt,P[Ae]=W,q=Ae):(P[q]=Gt,P[at]=W,q=at);else if(Ael(mt,W))P[q]=mt,P[Ae]=W,q=Ae;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,R=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,h=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function m(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(j);else{var B=n(c);B!==null&&X(C,B.startTime-P)}}function j(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&&!le());){var q=y.callback;if(typeof q=="function"){y.callback=null,w=y.priorityLevel;var te=q(y.expirationTime<=B);B=e.unstable_now(),typeof te=="function"?y.callback=te:y===n(a)&&r(a),m(B)}else r(a);y=n(a)}if(y!==null)var Ee=!0;else{var at=n(c);at!==null&&X(C,at.startTime-B),Ee=!1}return Ee}finally{y=null,w=W,k=!1}}var I=!1,M=null,A=-1,H=5,U=-1;function le(){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=te,t(a,P),E||k||(E=!0,b(j))),P},e.unstable_shouldYield=le,e.unstable_wrapCallback=function(P){var B=w;return function(){var W=w;w=B;try{return P.apply(this,arguments)}finally{w=W}}}})(zd);Fd.exports=zd;var Rm=Fd.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,ot=Rm;function T(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"),ys=Object.prototype.hasOwnProperty,Lm=/^[: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]*$/,Yu={},Ju={};function Tm(e){return ys.call(Ju,e)?!0:ys.call(Yu,e)?!1:Lm.test(e)?Ju[e]=!0:(Yu[e]=!0,!1)}function Pm(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 Im(e,t,n,r){if(t===null||typeof t>"u"||Pm(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 Me={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Me[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];Me[t]=new Ye(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Me[e]=new Ye(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Me[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){Me[e]=new Ye(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Me[e]=new Ye(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Me[e]=new Ye(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Me[e]=new Ye(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Me[e]=new Ye(e,5,!1,e.toLowerCase(),null,!1,!1)});var xa=/[\-:]([a-z])/g;function ka(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(xa,ka);Me[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(xa,ka);Me[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(xa,ka);Me[t]=new Ye(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Me[e]=new Ye(e,1,!1,e.toLowerCase(),null,!1,!1)});Me.xlinkHref=new Ye("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Me[e]=new Ye(e,1,!1,e.toLowerCase(),null,!0,!0)});function Ea(e,t,n,r){var l=Me.hasOwnProperty(t)?Me[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{Ui=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Br(e):""}function $m(e){switch(e.tag){case 5:return Br(e.type);case 16:return Br("Lazy");case 13:return Br("Suspense");case 19:return Br("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 ks(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 ws:return"Profiler";case Ca:return"StrictMode";case Ss:return"Suspense";case xs:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Bd:return(e.displayName||"Context")+".Consumer";case bd:return(e._context.displayName||"Context")+".Provider";case Na:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case _a:return t=e.displayName||null,t!==null?t:ks(e.type)||"Memo";case Zt:t=e._payload,e=e._init;try{return ks(e(t))}catch{}}return null}function Mm(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 ks(t);case 8:return t===Ca?"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 Wd(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Am(e){var t=Wd(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=Am(e))}function Vd(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Wd(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 Es(e,t){var n=t.checked;return we({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function qu(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 Kd(e,t){t=t.checked,t!=null&&Ea(e,"checked",t,!1)}function Cs(e,t){Kd(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")?Ns(e,t.type,n):t.hasOwnProperty("defaultValue")&&Ns(e,t.type,hn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Zu(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 Ns(e,t,n){(t!=="number"||To(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Hr=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 nl(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Kr={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},Dm=["Webkit","ms","Moz","O"];Object.keys(Kr).forEach(function(e){Dm.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Kr[t]=Kr[e]})});function Jd(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Kr.hasOwnProperty(e)&&Kr[e]?(""+t).trim():t+"px"}function Xd(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=Jd(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var Om=we({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(Om[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(T(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(T(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(T(61))}if(t.style!=null&&typeof t.style!="object")throw Error(T(62))}}function Ls(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 Ts=null;function Ra(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ps=null,ar=null,ur=null;function nc(e){if(e=El(e)){if(typeof Ps!="function")throw Error(T(280));var t=e.stateNode;t&&(t=si(t),Ps(e.stateNode,e.type,t))}}function qd(e){ar?ur?ur.push(e):ur=[e]:ar=e}function Zd(){if(ar){var e=ar,t=ur;if(ur=ar=null,nc(e),t)for(e=0;e>>=0,e===0?32:31-(Gm(e)/Ym|0)|0}var ql=64,Zl=4194304;function Wr(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=Wr(s):(o&=i,o!==0&&(r=Wr(o)))}else i=n&~l,i!==0?r=Wr(i):o!==0&&(r=Wr(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 xl(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 Zm(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=Gr),dc=" ",fc=!1;function Sf(e,t){switch(e){case"keyup":return Rg.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function xf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Xn=!1;function Lg(e,t){switch(e){case"compositionend":return xf(t);case"keypress":return t.which!==32?null:(fc=!0,dc);case"textInput":return e=t.data,e===dc&&fc?null:e;default:return null}}function Tg(e,t){if(Xn)return e==="compositionend"||!Aa&&Sf(e,t)?(e=yf(),yo=Ia=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=gc(n)}}function Nf(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Nf(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function _f(){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 Da(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 zg(e){var t=_f(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Nf(n.ownerDocument.documentElement,n)){if(r!==null&&Da(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=vc(n,o);var i=vc(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,Os=null,Jr=null,Fs=!1;function yc(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Fs||qn==null||qn!==To(r)||(r=qn,"selectionStart"in r&&Da(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}),Jr&&al(Jr,r)||(Jr=r,r=Oo(Os,"onSelect"),0tr||(e.current=Ws[tr],Ws[tr]=null,tr--)}function se(e,t){tr++,Ws[tr]=e.current,e.current=t}var mn={},be=vn(mn),qe=vn(!1),Pn=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 Nc(e,t,n){if(be.current!==mn)throw Error(T(168));se(be,t),se(qe,n)}function Af(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(T(108,Mm(e)||"Unknown",l));return we({},n,r)}function Uo(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||mn,Pn=be.current,se(be,e),se(qe,qe.current),!0}function _c(e,t,n){var r=e.stateNode;if(!r)throw Error(T(169));n?(e=Af(e,t,Pn),r.__reactInternalMemoizedMergedChildContext=e,de(qe),de(be),se(be,e)):de(qe),se(qe,n)}var Dt=null,ai=!1,ts=!1;function Df(e){Dt===null?Dt=[e]:Dt.push(e)}function Xg(e){ai=!0,Df(e)}function yn(){if(!ts&&Dt!==null){ts=!0;var e=0,t=re;try{var n=Dt;for(re=1;e>=i,l-=i,Ot=1<<32-kt(t)+l|n<A?(H=M,M=null):H=M.sibling;var U=w(v,M,m[A],C);if(U===null){M===null&&(M=H);break}e&&M&&U.alternate===null&&t(v,M),h=o(U,h,A),I===null?j=U:I.sibling=U,I=U,M=H}if(A===m.length)return n(v,M),pe&&Cn(v,A),j;if(M===null){for(;AA?(H=M,M=null):H=M.sibling;var le=w(v,M,U.value,C);if(le===null){M===null&&(M=H);break}e&&M&&le.alternate===null&&t(v,M),h=o(le,h,A),I===null?j=le:I.sibling=le,I=le,M=H}if(U.done)return n(v,M),pe&&Cn(v,A),j;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?j=U:I.sibling=U,I=U);return pe&&Cn(v,A),j}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?j=U:I.sibling=U,I=U);return e&&M.forEach(function(he){return t(v,he)}),pe&&Cn(v,A),j}function R(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 j=m.key,I=h;I!==null;){if(I.key===j){if(j=m.type,j===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===j||typeof j=="object"&&j!==null&&j.$$typeof===Zt&&Lc(j)===I.type){n(v,I.sibling),h=l(I,m.props),h.ref=Or(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=Tn(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=Or(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=us(m,v.mode,C),h.return=v,v=h}return i(v);case Zt:return I=m._init,R(v,h,I(m._payload),C)}if(Hr(m))return E(v,h,m,C);if(Ir(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=as(m,v.mode,C),h.return=v,v=h),i(v)):n(v,h)}return R}var gr=Uf(!0),bf=Uf(!1),Ho=vn(null),Wo=null,lr=null,Ua=null;function ba(){Ua=lr=Wo=null}function Ba(e){var t=Ho.current;de(Ho),e._currentValue=t}function Qs(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,Ua=lr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Xe=!0),e.firstContext=null)}function pt(e){var t=e._currentValue;if(Ua!==e)if(e={context:e,memoizedValue:t,next:null},lr===null){if(Wo===null)throw Error(T(308));lr=e,Wo.dependencies={lanes:0,firstContext:e}}else lr=lr.next=e;return t}var Rn=null;function Ha(e){Rn===null?Rn=[e]:Rn.push(e)}function Bf(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,Ha(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 Wa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Hf(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,Ha(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,La(e,n)}}function Tc(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=we({},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);Mn|=i,e.lanes=i,e.memoizedState=y}}function Pc(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=rs.transition;rs.transition={};try{e(!1),t()}finally{re=n,rs.transition=r}}function ip(){return ht().memoizedState}function tv(e,t,n){var r=fn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},sp(e))ap(t,n);else if(n=Bf(e,t,n,r),n!==null){var l=Qe();Et(n,e,r,l),up(n,t,r)}}function nv(e,t,n){var r=fn(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(sp(e))ap(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,Ha(t)):(l.next=a.next,a.next=l),t.interleaved=l;return}}catch{}finally{}n=Bf(e,t,l,r),n!==null&&(l=Qe(),Et(n,e,r,l),up(n,t,r))}}function sp(e){var t=e.alternate;return e===ve||t!==null&&t===ve}function ap(e,t){Xr=Qo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function up(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,La(e,n)}}var Go={readContext:pt,useCallback:Fe,useContext:Fe,useEffect:Fe,useImperativeHandle:Fe,useInsertionEffect:Fe,useLayoutEffect:Fe,useMemo:Fe,useReducer:Fe,useRef:Fe,useState:Fe,useDebugValue:Fe,useDeferredValue:Fe,useTransition:Fe,useMutableSource:Fe,useSyncExternalStore:Fe,useId:Fe,unstable_isNewReconciler:!1},rv={readContext:pt,useCallback:function(e,t){return jt().memoizedState=[e,t===void 0?null:t],e},useContext:pt,useEffect:$c,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,ko(4194308,4,tp.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=jt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=jt();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=tv.bind(null,ve,e),[r.memoizedState,e]},useRef:function(e){var t=jt();return e={current:e},t.memoizedState=e},useState:Ic,useDebugValue:qa,useDeferredValue:function(e){return jt().memoizedState=e},useTransition:function(){var e=Ic(!1),t=e[0];return e=ev.bind(null,e[1]),jt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=ve,l=jt();if(pe){if(n===void 0)throw Error(T(407));n=n()}else{if(n=t(),Pe===null)throw Error(T(349));$n&30||Qf(r,t,n)}l.memoizedState=n;var o={value:n,getSnapshot:t};return l.queue=o,$c(Yf.bind(null,r,o,e),[e]),r.flags|=2048,gl(9,Gf.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=jt(),t=Pe.identifierPrefix;if(pe){var n=Ft,r=Ot;n=(r&~(1<<32-kt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=hl++,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[Lt]=t,e[dl]=r,wp(e,t,!1,!1),t.stateNode=e;e:{switch(i=Ls(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,Fr(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),Fr(o,!0),o.tail===null&&o.tailMode==="hidden"&&!i.alternate&&!pe)return ze(t),null}else 2*ke()-o.renderingStartTime>wr&&n!==1073741824&&(t.flags|=128,r=!0,Fr(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=ge.current,se(ge,r?n&1|2:n&1),t):(ze(t),null);case 22:case 23:return lu(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?nt&1073741824&&(ze(t),t.subtreeFlags&6&&(t.flags|=8192)):ze(t),null;case 24:return null;case 25:return null}throw Error(T(156,t.tag))}function dv(e,t){switch(Fa(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),Qa(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Ka(t),null;case 13:if(de(ge),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(T(340));mr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return de(ge),null;case 4:return vr(),null;case 10:return Ba(t.type._context),null;case 22:case 23:return lu(),null;case 24:return null;default:return null}}var ao=!1,Ue=!1,fv=typeof WeakSet=="function"?WeakSet:Set,O=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 na(e,t,n){try{n()}catch(r){Se(e,t,r)}}var Wc=!1;function pv(e,t){if(zs=Ao,e=_f(),Da(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(Us={focusedElem:e,selectionRange:n},Ao=!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,R=E.memoizedState,v=t.stateNode,h=v.getSnapshotBeforeUpdate(t.elementType===t.type?N:wt(t.type,N),R);v.__reactInternalSnapshotBeforeUpdate=h}break;case 3:var m=t.stateNode.containerInfo;m.nodeType===1?m.textContent="":m.nodeType===9&&m.documentElement&&m.removeChild(m.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(T(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=Wc,Wc=!1,E}function qr(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&&na(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 ra(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 kp(e){var t=e.alternate;t!==null&&(e.alternate=null,kp(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Lt],delete t[dl],delete t[Hs],delete t[Yg],delete t[Jg])),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 Ep(e){return e.tag===5||e.tag===3||e.tag===4}function Vc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Ep(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 la(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(la(e,t,n),e=e.sibling;e!==null;)la(e,t,n),e=e.sibling}function oa(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(oa(e,t,n),e=e.sibling;e!==null;)oa(e,t,n),e=e.sibling}var Ie=null,St=!1;function qt(e,t,n){for(n=n.child;n!==null;)Cp(e,t,n),n=n.sibling}function Cp(e,t,n){if(Tt&&typeof Tt.onCommitFiberUnmount=="function")try{Tt.onCommitFiberUnmount(ri,n)}catch{}switch(n.tag){case 5:Ue||or(n,t);case 6:var r=Ie,l=St;Ie=null,qt(e,t,n),Ie=r,St=l,Ie!==null&&(St?(e=Ie,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ie.removeChild(n.stateNode));break;case 18:Ie!==null&&(St?(e=Ie,n=n.stateNode,e.nodeType===8?es(e.parentNode,n):e.nodeType===1&&es(e,n),il(e)):es(Ie,n.stateNode));break;case 4:r=Ie,l=St,Ie=n.stateNode.containerInfo,St=!0,qt(e,t,n),Ie=r,St=l;break;case 0:case 11:case 14:case 15:if(!Ue&&(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)&&na(n,t,i),l=l.next}while(l!==r)}qt(e,t,n);break;case 1:if(!Ue&&(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?(Ue=(r=Ue)||n.memoizedState!==null,qt(e,t,n),Ue=r):qt(e,t,n);break;default:qt(e,t,n)}}function Kc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new fv),t.forEach(function(r){var l=kv.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*mv(r/1960))-r,10e?16:e,ln===null)var r=!1;else{if(e=ln,ln=null,Xo=0,ee&6)throw Error(T(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()-nu?Ln(e,0):tu|=n),et(e,t)}function Ip(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&&(xl(e,t,n),et(e,n))}function xv(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ip(e,n)}function kv(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(T(314))}r!==null&&r.delete(t),Ip(e,n)}var $p;$p=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,uv(e,t,n);Xe=!!(e.flags&131072)}else Xe=!1,pe&&t.flags&1048576&&Of(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=Ya(null,t,r,e,l,n);var o=Ja();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,Wa(t),l.updater=ci,t.stateNode=l,l._reactInternals=t,Ys(t,r,e,n),t=qs(null,t,r,!0,o,n)):(t.tag=0,pe&&o&&Oa(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=Cv(r),e=wt(r,e),l){case 0:t=Xs(null,t,r,e,n);break e;case 1:t=bc(null,t,r,e,n);break e;case 11:t=zc(null,t,r,e,n);break e;case 14:t=Uc(null,t,r,wt(r.type,e),n);break e}throw Error(T(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:wt(r,l),Xs(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(gp(t),e===null)throw Error(T(387));r=t.pendingProps,o=t.memoizedState,l=o.element,Hf(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(T(423)),t),t=Bc(e,t,r,n,l);break e}else if(r!==l){l=yr(Error(T(424)),t),t=Bc(e,t,r,n,l);break e}else for(rt=un(t.stateNode.containerInfo.firstChild),lt=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 Wf(t),e===null&&Ks(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),mp(e,t),Ke(e,t,i,n),t.child;case 6:return e===null&&Ks(t),null;case 13:return vp(e,t,n);case 4:return Va(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),zc(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,se(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),Qs(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(T(341));i.lanes|=n,s=i.alternate,s!==null&&(s.lanes|=n),Qs(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=pt(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),Uc(e,t,r,l,n);case 15:return pp(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),cp(t,r,l),Ys(t,r,l,n),qs(null,t,r,!0,e,n);case 19:return yp(e,t,n);case 22:return hp(e,t,n)}throw Error(T(156,t.tag))};function Mp(e,t){return sf(e,t)}function Ev(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 dt(e,t,n,r){return new Ev(e,t,n,r)}function iu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Cv(e){if(typeof e=="function")return iu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Na)return 11;if(e===_a)return 14}return 2}function pn(e,t){var n=e.alternate;return n===null?(n=dt(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")iu(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case Jn:return Tn(n.children,l,o,t);case Ca:i=8,l|=8;break;case ws:return e=dt(12,n,t,l|2),e.elementType=ws,e.lanes=o,e;case Ss:return e=dt(13,n,t,l),e.elementType=Ss,e.lanes=o,e;case xs:return e=dt(19,n,t,l),e.elementType=xs,e.lanes=o,e;case Hd:return pi(n,l,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case bd:i=10;break e;case Bd:i=9;break e;case Na:i=11;break e;case _a:i=14;break e;case Zt:i=16,r=null;break e}throw Error(T(130,e==null?e:typeof e,""))}return t=dt(i,n,t,l),t.elementType=e,t.type=r,t.lanes=o,t}function Tn(e,t,n,r){return e=dt(7,e,r,t),e.lanes=n,e}function pi(e,t,n,r){return e=dt(22,e,r,t),e.elementType=Hd,e.lanes=n,e.stateNode={isHidden:!1},e}function as(e,t,n){return e=dt(6,e,null,t),e.lanes=n,e}function us(e,t,n){return t=dt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Nv(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=Hi(0),this.expirationTimes=Hi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Hi(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function su(e,t,n,r,l,o,i,s,a){return e=new Nv(e,t,n,s,a),t===1?(t=1,o===!0&&(t|=8)):t=0,o=dt(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Wa(o),e}function _v(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Fp)}catch(e){console.error(e)}}Fp(),Od.exports=it;var zp=Od.exports,Up,ed=zp;Up=ed.createRoot,ed.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 td="popstate";function Pv(e={}){function t(l,o){let{pathname:i="/",search:s="",hash:a=""}=Fn(l.location.hash.substring(1));return!i.startsWith("/")&&!i.startsWith(".")&&(i="/"+i),ca("",{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:yl(o))}function r(l,o){Nt(l.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(o)})`)}return $v(t,n,r,e)}function ye(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 Iv(){return Math.random().toString(36).substring(2,10)}function nd(e,t){return{usr:e.state,key:e.key,idx:t}}function ca(e,t,n=null,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Fn(t):t,state:n,key:t&&t.key||r||Iv()}}function yl({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 Fn(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 $v(e,t,n,r={}){let{window:l=document.defaultView,v5Compat:o=!1}=r,i=l.history,s="POP",a=null,c=g();c==null&&(c=0,i.replaceState({...i.state,idx:c},""));function g(){return(i.state||{idx:null}).idx}function y(){s="POP";let R=g(),v=R==null?null:R-c;c=R,a&&a({action:s,location:N.location,delta:v})}function w(R,v){s="PUSH";let h=ca(N.location,R,v);n&&n(h,R),c=g()+1;let m=nd(h,c),C=N.createHref(h);try{i.pushState(m,"",C)}catch(j){if(j instanceof DOMException&&j.name==="DataCloneError")throw j;l.location.assign(C)}o&&a&&a({action:s,location:N.location,delta:1})}function k(R,v){s="REPLACE";let h=ca(N.location,R,v);n&&n(h,R),c=g();let m=nd(h,c),C=N.createHref(h);i.replaceState(m,"",C),o&&a&&a({action:s,location:N.location,delta:0})}function E(R){return Mv(R)}let N={get action(){return s},get location(){return e(l,i)},listen(R){if(a)throw new Error("A history only accepts one active listener");return l.addEventListener(td,y),a=R,()=>{l.removeEventListener(td,y),a=null}},createHref(R){return t(l,R)},createURL:E,encodeLocation(R){let v=E(R);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:w,replace:k,go(R){return i.go(R)}};return N}function Mv(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),ye(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:yl(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function bp(e,t,n="/"){return Av(e,t,n,!1)}function Av(e,t,n,r){let l=typeof t=="string"?Fn(t):t,o=Vt(l.pathname||"/",n);if(o==null)return null;let i=Bp(e);Dv(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;ye(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&&(ye(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${y}".`),Bp(i.children,t,w,y,a)),!(i.path==null&&!i.index)&&t.push({path:y,score:Hv(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 Hp(i.path))o(i,s,!0,c)}),t}function Hp(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=Hp(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 Dv(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Wv(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Ov=/^:[\w-]+$/,Fv=3,zv=2,Uv=1,bv=10,Bv=-2,rd=e=>e==="*";function Hv(e,t){let n=e.split("/"),r=n.length;return n.some(rd)&&(r+=Bv),t&&(r+=zv),n.filter(l=>!rd(l)).reduce((l,o)=>l+(Ov.test(o)?Fv:o===""?Uv:bv),r)}function Wv(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 Vv(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 Kv(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 Qv(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 Gv(e,t="/"){let{pathname:n,search:r="",hash:l=""}=typeof e=="string"?Fn(e):e;return{pathname:n?n.startsWith("/")?n:Yv(n,t):t,search:qv(r),hash:Zv(l)}}function Yv(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 cs(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 Jv(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Wp(e){let t=Jv(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Vp(e,t,n,r=!1){let l;typeof e=="string"?l=Fn(e):(l={...e},ye(!l.pathname||!l.pathname.includes("?"),cs("?","pathname","search",l)),ye(!l.pathname||!l.pathname.includes("#"),cs("#","pathname","hash",l)),ye(!l.search||!l.search.includes("#"),cs("#","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=Gv(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,"/"),Xv=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),qv=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Zv=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function ey(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}var Kp=["POST","PUT","PATCH","DELETE"];new Set(Kp);var ty=["GET",...Kp];new Set(ty);var Er=f.createContext(null);Er.displayName="DataRouter";var yi=f.createContext(null);yi.displayName="DataRouterState";f.createContext(!1);var Qp=f.createContext({isTransitioning:!1});Qp.displayName="ViewTransition";var ny=f.createContext(new Map);ny.displayName="Fetchers";var ry=f.createContext(null);ry.displayName="Await";var It=f.createContext(null);It.displayName="Navigation";var Nl=f.createContext(null);Nl.displayName="Location";var Qt=f.createContext({outlet:null,matches:[],isDataRoute:!1});Qt.displayName="Route";var du=f.createContext(null);du.displayName="RouteError";function ly(e,{relative:t}={}){ye(_l(),"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}=Rl(e,{relative:t}),s=o;return n!=="/"&&(s=o==="/"?n:Ut([n,o])),r.createHref({pathname:s,search:i,hash:l})}function _l(){return f.useContext(Nl)!=null}function zn(){return ye(_l(),"useLocation() may be used only in the context of a component."),f.useContext(Nl).location}var Gp="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Yp(e){f.useContext(It).static||f.useLayoutEffect(e)}function oy(){let{isDataRoute:e}=f.useContext(Qt);return e?yy():iy()}function iy(){ye(_l(),"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}=zn(),o=JSON.stringify(Wp(r)),i=f.useRef(!1);return Yp(()=>{i.current=!0}),f.useCallback((a,c={})=>{if(Nt(i.current,Gp),!i.current)return;if(typeof a=="number"){n.go(a);return}let g=Vp(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 Rl(e,{relative:t}={}){let{matches:n}=f.useContext(Qt),{pathname:r}=zn(),l=JSON.stringify(Wp(n));return f.useMemo(()=>Vp(e,JSON.parse(l),r,t==="path"),[e,l,r,t])}function sy(e,t){return Jp(e,t)}function Jp(e,t,n,r,l){var h;ye(_l(),"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||"";Xp(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=zn(),k;if(t){let m=typeof t=="string"?Fn(t):t;ye(g==="/"||((h=m.pathname)==null?void 0:h.startsWith(g)),`When overriding the location using \`\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${g}" but pathname "${m.pathname}" was given in the \`location\` prop.`),k=m}else k=w;let E=k.pathname||"/",N=E;if(g!=="/"){let m=g.replace(/^\//,"").split("/");N="/"+E.replace(/^\//,"").split("/").slice(m.length).join("/")}let R=bp(e,{pathname:N});Nt(y||R!=null,`No routes matched location "${k.pathname}${k.search}${k.hash}" `),Nt(R==null||R[R.length-1].route.element!==void 0||R[R.length-1].route.Component!==void 0||R[R.length-1].route.lazy!==void 0,`Matched leaf route at location "${k.pathname}${k.search}${k.hash}" does not have an element or Component. This means it will render an with a null value by default resulting in an "empty" page.`);let v=fy(R&&R.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(Nl.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...k},navigationType:"POP"}},v):v}function ay(){let e=vy(),t=ey(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 uy=f.createElement(ay,null),cy=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(du.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function dy({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 fy(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);ye(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||uy,s&&(a<0&&y===0?(Xp("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),k=!0,N=null):a===y&&(k=!0,N=g.route.hydrateFallbackElement||null)));let R=t.concat(o.slice(0,y+1)),v=()=>{let h;return w?h=E:k?h=N:g.route.Component?h=f.createElement(g.route.Component,null):g.route.element?h=g.route.element:h=c,f.createElement(dy,{match:g,routeContext:{outlet:c,matches:R,isDataRoute:n!=null},children:h})};return n&&(g.route.ErrorBoundary||g.route.errorElement||y===0)?f.createElement(cy,{location:n.location,revalidation:n.revalidation,component:E,error:w,children:v(),routeContext:{outlet:null,matches:R,isDataRoute:!0},unstable_onError:r}):v()},null)}function fu(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function py(e){let t=f.useContext(Er);return ye(t,fu(e)),t}function hy(e){let t=f.useContext(yi);return ye(t,fu(e)),t}function my(e){let t=f.useContext(Qt);return ye(t,fu(e)),t}function pu(e){let t=my(e),n=t.matches[t.matches.length-1];return ye(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function gy(){return pu("useRouteId")}function vy(){var r;let e=f.useContext(du),t=hy("useRouteError"),n=pu("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function yy(){let{router:e}=py("useNavigate"),t=pu("useNavigate"),n=f.useRef(!1);return Yp(()=>{n.current=!0}),f.useCallback(async(l,o={})=>{Nt(n.current,Gp),n.current&&(typeof l=="number"?e.navigate(l):await e.navigate(l,{fromRouteId:t,...o}))},[e,t])}var ld={};function Xp(e,t,n){!t&&!ld[e]&&(ld[e]=!0,Nt(!1,n))}f.memo(wy);function wy({routes:e,future:t,state:n,unstable_onError:r}){return Jp(e,void 0,n,r,t)}function qp(e){ye(!1,"A is only ever to be used as the child of element, never rendered directly. Please wrap your in a .")}function Sy({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:l,static:o=!1}){ye(!_l(),"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=Fn(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(Nl.Provider,{children:t,value:k}))}function xy({children:e,location:t}){return sy(da(e),t)}function da(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,da(r.props.children,o));return}ye(r.type===qp,`[${typeof r.type=="string"?r.type:r.type.name}] is not a component. All component children of must be a or `),ye(!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=da(r.props.children,o)),n.push(i)}),n}var Ro="get",jo="application/x-www-form-urlencoded";function wi(e){return e!=null&&typeof e.tagName=="string"}function ky(e){return wi(e)&&e.tagName.toLowerCase()==="button"}function Ey(e){return wi(e)&&e.tagName.toLowerCase()==="form"}function Cy(e){return wi(e)&&e.tagName.toLowerCase()==="input"}function Ny(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function _y(e,t){return e.button===0&&(!t||t==="_self")&&!Ny(e)}var fo=null;function Ry(){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 ds(e){return e!=null&&!jy.has(e)?(Nt(!1,`"${e}" is not a valid \`encType\` for \`
\`/\`\` and will default to "${jo}"`),null):e}function Ly(e,t){let n,r,l,o,i;if(Ey(e)){let s=e.getAttribute("action");r=s?Vt(s,t):null,n=e.getAttribute("method")||Ro,l=ds(e.getAttribute("enctype"))||jo,o=new FormData(e)}else if(ky(e)||Cy(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 B0(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 uh(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 W0({content:e,streamOutput:t,sources:n}){const{think:r,answer:l}=uh(e||""),[o,i]=Ve.useState(!1),s=!!r;return d.jsxs("div",{className:"assistant-message",children:[s&&d.jsxs("div",{className:"assistant-thoughts",children:[d.jsxs("button",{className:"think-toggle",onClick:()=>i(a=>!a),"aria-expanded":o?"true":"false","aria-controls":"think-content",children:[d.jsx("span",{className:"think-toggle-icon","aria-hidden":"true",children:o?"▾":"▸"}),"Thoughts"]}),o&&d.jsx("div",{id:"think-content",className:"think-content",dangerouslySetInnerHTML:{__html:wd(r)}})]}),d.jsx("div",{className:"msg-content",dangerouslySetInnerHTML:{__html:wd(l||e||"")}}),Array.isArray(n)&&n.length>0&&d.jsx("div",{className:"msg-sources chips",children:n.map((a,c)=>{let g=a,y=!1;try{const w=new URL(a);if(w.protocol==="file:"){y=!0;const k=w.pathname.split("/").filter(Boolean);g=decodeURIComponent(k[k.length-1]||a)}else g=(w.hostname||a).replace(/^www\./i,"")}catch{}return d.jsx("a",{className:"chip",href:a,target:"_blank",rel:"noreferrer",title:a,onClick:w=>{var k,E;if(y){w.preventDefault();try{const N=new URL(a);(E=(k=window.electronAPI)==null?void 0:k.openPath)==null||E.call(k,decodeURIComponent(N.pathname))}catch{}}},children:g},a+c)})})]})}function ms({attachments:e,className:t="",removable:n=!1,onRemove:r}){return!Array.isArray(e)||e.length===0?null:d.jsx("div",{className:`image-attachment-strip ${t}`.trim(),children:e.map((l,o)=>{const i=l==null?void 0:l.data_url;if(!i)return null;const s=l.id||`${l.name||"image"}-${o}-${i.length}`;return d.jsxs("div",{className:"image-attachment-card",children:[n&&d.jsx("button",{type:"button",className:"image-attachment-remove",onClick:()=>r==null?void 0:r(l.id),"aria-label":`Remove ${l.name||"image"}`,title:"Remove image",children:"×"}),d.jsx("img",{className:"image-attachment-thumb",src:i,alt:l.name||`Attachment ${o+1}`,loading:"lazy"})]},s)})})}const Sd="websearch.searxUrl",xd="websearch.engines",kd="chat.libraryBySession",Ed="http://127.0.0.1:8888",gs=6,vs=20*1024*1024,V0=5*60*1e3,K0=200;let ch="http://127.0.0.1:8000";const Q0=48,G0=24;function Y0(e){return e.backendApiUrl||e.ollamaApiUrl||ch}function J0(e){const t=typeof e=="string"?e.trim():"";return!t||t==="http://localhost:8888"?Ed:t}function ho(e){var n;return Array.from(((n=e==null?void 0:e.dataTransfer)==null?void 0:n.types)||[]).includes("Files")}function ga(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 Cd(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"&&ga((i=o.getAsFile)==null?void 0:i.call(o))}):Array.from(((l=e==null?void 0:e.dataTransfer)==null?void 0:l.files)||[]).some(ga)}function Nd(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 X0(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 q0(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 Z0(){var Vu;const[e,t]=f.useState([]),[n,r]=f.useState(null),[l,o]=f.useState("chats"),[i,s]=f.useState("General"),[a,c]=f.useState(null),[g,y]=f.useState(null),[w,k]=f.useState([]),[E,N]=f.useState([]),[R,v]=f.useState(null),[h,m]=f.useState(()=>{try{const u=localStorage.getItem(kd);return u?JSON.parse(u):{}}catch{return{}}}),[C,j]=f.useState(!1),[I,M]=f.useState(""),[A,H]=f.useState(""),[U,le]=f.useState(!1),[he,Be]=f.useState(""),[ae,L]=f.useState(!1),[b,X]=f.useState(""),[P,B]=f.useState([]),[W,q]=f.useState(!1),te=f.useRef(null),Ee=f.useRef(null),at=f.useRef(null),Gt=f.useRef(null),Ae=f.useRef(0),[mt,jl]=f.useState(!1),[Ll,Tl]=f.useState(""),[xi,Pl]=f.useState(""),[Yt,Cr]=f.useState(!0),[Un,Il]=f.useState(""),[xe,$l]=f.useState(!1),[D,z]=f.useState(!1),[fe,Ce]=f.useState(0),bn=f.useRef(null),Nr=f.useRef(null),Ml=f.useRef([]),ki=f.useRef(null),Al=f.useRef(""),Dl=f.useRef(null),Ol=f.useRef(null),Ei=f.useRef(0),Fl=f.useRef(null),[Q,vu]=f.useState(ch),[yu,dh]=f.useState("Default"),[zl,wu]=f.useState(!1),[Su,_r]=f.useState(""),[fh,Ci]=f.useState(!1),[Rr,ph]=f.useState(()=>J0(localStorage.getItem(Sd))),[wn,hh]=f.useState(()=>U0(localStorage.getItem(xd)));f.useEffect(()=>{localStorage.setItem(Sd,Rr||"")},[Rr]),f.useEffect(()=>{try{localStorage.setItem(xd,JSON.stringify(ti(wn)))}catch{}},[wn]);const[Ul,mh]=f.useState(!1),[gt,Ni]=f.useState(!1),[xu,_i]=f.useState(!0),[gh,Bn]=f.useState([]),[bl,ku]=f.useState({}),[Eu,vh]=f.useState(!1),Cu=f.useRef(!1),[yh,Ri]=f.useState(null),[ji,Bl]=f.useState("");function wh(u){const p=u.content||"";if(u.role==="assistant")try{const{answer:S}=uh(p);return(S||p).trim()}catch{return p.trim()}return p}async function Nu(u){try{await navigator.clipboard.writeText(wh(u))}catch(p){console.error("Failed to copy message:",p)}}function Sn(u,p,S,x={}){const{removeIfEmpty:_=!1}=x;t($=>$.map(F=>{if(F.session_id!==u)return F;const V=[];for(const Z of F.messages||[]){if(Z.id!==p){V.push(Z);continue}_&&!S||V.push({...Z,content:S})}return{...F,messages:V}}))}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 jr(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 Sh(u,p){const S=await fetch(`${Q}/models/capabilities?name=${encodeURIComponent(u)}`,{signal:p});return jr(S)}async function xh(){const u=await fetch(`${Q}/ollama/startup-status`);return jr(u)}async function kh(){const u=await fetch(`${Q}/startup/prepare-models`,{method:"POST"});return jr(u)}function _u(u){if(!!(u!=null&&u.whisper_model_available)){Cr(!0),Il("");return}const S=(u==null?void 0:u.whisper_model)||"base",x=String((u==null?void 0:u.whisper_error)||"").trim();Cr(!1),Il(x||`Whisper ${S} is not available.`)}async function Ru(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(ga);if(!p.length||!ae)return;const S=Math.max(0,gs-P.length);if(S<=0){window.alert(`You can attach up to ${gs} images per message.`);return}const x=p.slice(0,S),_=x.filter(F=>Number(F.size)>vs),$=x.filter(F=>Number(F.size)<=vs);if(_.length>0&&window.alert(`Images must be ${Math.round(vs/(1024*1024))} MB or smaller.`),!!$.length)try{const F=await Promise.all($.map(async(V,Z)=>({id:`attachment-${Date.now()}-${Z}-${Math.random().toString(36).slice(2)}`,name:V.name||"image",mime_type:V.type||"image/*",data_url:await Nd(V)})));B(V=>[...V,...F]),p.length>S&&window.alert(`Only the first ${gs} images can be attached.`)}catch(F){console.error("Failed to load image attachments",F),window.alert(`Image import failed: ${$t(F)}`)}}function Eh(u){B(p=>p.filter(S=>S.id!==u))}function Ch(){var u;ae&&((u=Gt.current)==null||u.click())}function Li(){Dl.current&&(window.clearInterval(Dl.current),Dl.current=null),Ol.current&&(window.clearTimeout(Ol.current),Ol.current=null)}function Ti(u=Nr.current){Li(),pa(u),Nr.current===u&&(Nr.current=null),bn.current=null}async function Nh(u,p){if(!Q)throw new Error("The Heimgeist backend is not configured.");const S=new AbortController;Fl.current=S,z(!0);try{const x=await Nd(u),_=x.indexOf(",");if(_<=5)throw new Error("Recorded audio could not be encoded for upload.");const $=x.slice(0,_),F=x.slice(_+1);if(!/^data:[^,]+;base64$/i.test($)||!F)throw new Error("Recorded audio could not be encoded for upload.");const V=$.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||V||"audio/webm",audio_base64:F,language:xi||null})}),oe=await jr(Z),ne=String((oe==null?void 0:oe.text)||"").trim();if(!ne){window.alert("No speech was detected. Try again and speak closer to the selected microphone.");return}X(me=>X0(me,ne)),requestAnimationFrame(()=>{var me;return(me=Ee.current)==null?void 0:me.focus()})}catch(x){if(_t(x))return;throw x}finally{Fl.current===S&&(Fl.current=null),z(!1)}}async function Lr(u={}){const{shouldTranscribe:p=!0}=u,S=bn.current,x=ki.current,_=Al.current||(S==null?void 0:S.mimeType)||"audio/webm";if(!(!S||!x)){$l(!1),Li();try{S.state!=="inactive"&&S.stop();const $=await x;if(!p)return;if(!$||$.size<=0)throw new Error("Recorded audio was empty.");await Nh($,_)}catch($){p&&(console.error("Failed to stop microphone recording",$),window.alert(`Microphone transcription failed: ${$t($)}`))}finally{ki.current=null,Ml.current=[],Al.current="",Ei.current=0,Ce(0)}}}async function _h(){if(!mt||!Yt||xe||D||gt)return;if(!Si()){window.alert("Microphone capture is not available in this environment.");return}let u=null;try{u=await navigator.mediaDevices.getUserMedia(x0(Ll))}catch(x){console.error("Failed to access microphone",x),window.alert(`Microphone access failed: ${$t(x)}`);return}const p=E0();let S=null;try{S=p?new MediaRecorder(u,{mimeType:p}):new MediaRecorder(u)}catch(x){Ti(u),console.error("Failed to create audio recorder",x),window.alert(`Microphone recording is not available: ${$t(x)}`);return}Nr.current=u,bn.current=S,Ml.current=[],Al.current=S.mimeType||p||"audio/webm",Ei.current=Date.now(),Ce(0),$l(!0),S.ondataavailable=x=>{x.data&&x.data.size>0&&Ml.current.push(x.data)},ki.current=new Promise((x,_)=>{S.onstop=()=>{const $=new Blob(Ml.current,{type:S.mimeType||Al.current||"audio/webm"});Ti(u),x($)},S.onerror=$=>{Ti(u),_(($==null?void 0:$.error)||new Error("Audio recording failed."))}}),Dl.current=window.setInterval(()=>{Ce(Date.now()-Ei.current)},K0),Ol.current=window.setTimeout(()=>{Lr()},V0),S.start()}async function Rh(){if(!D){if(xe){await Lr();return}await _h()}}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 Lh(u,p){Ri(u),Bl(p||"")}function Hl(){Ri(null),Bl("")}async function Th(u){var $;const p=((($=Kn[u])==null?void 0:$.content)||"").trim(),x=(ji??"").trim();if(x.length===0){Hl();return}if(x===p){Hl();return}const _=n;if(_){t(F=>F.map(V=>{if(V.session_id!==_)return V;const oe=(V.messages||[]).slice(0,u+1).map((ne,me)=>me===u?{...ne,content:x}:ne);return{...V,messages:oe}})),Ri(null),Bl(""),requestAnimationFrame(()=>Di("auto",_));try{const F=await fetch(`${Q}/sessions/${_}/messages/${u}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:x})});if(!F.ok)throw new Error(`HTTP ${F.status}`)}catch(F){console.error("Failed to update message:",F),t(V=>V.map(Z=>{if(Z.session_id!==_)return Z;const ne=(Z.messages||[]).map((me,Oe)=>Oe===u?{...me,content:p}:me);return{...Z,messages:ne}}));return}await Lu(u,x)}}async function Lu(u,p=null){var oe,ne,me,Oe,En,G;const S=n;if(gt||!S||typeof u!="number")return;const x=((oe=e.find(J=>J.session_id===S))==null?void 0:oe.messages)||[];let _=u;for(let J=u;J>=0;J--)if(((ne=x[J])==null?void 0:ne.role)==="user"){_=J;break}t(J=>J.map(ue=>ue.session_id===S?{...ue,messages:(ue.messages||[]).slice(0,_+1)}:ue));const $=Au(S);let F=p??(((me=x[_])==null?void 0:me.content)||""),V=[];const Z=[];try{const J=zu(S),ue=p??(((Oe=x[_])==null?void 0:Oe.content)||""),Re=!!(ue||"").trim();if(Re&&((En=J==null?void 0:J.states)!=null&&En.is_indexed))try{const K=await Ru(J.slug,ue,$.signal);K.contextBlock&&Z.push(K.contextBlock),Array.isArray(K.sources)&&V.push(...K.sources)}catch(K){if(_t(K))throw K;console.warn("local library enrichment (regenerate) failed",K)}if(Re&&Ul)try{const K=x.slice(Math.max(0,_-7),_+1).map(Ne=>({role:Ne.role,content:Ne.content||""}));K.length>0&&(K[K.length-1]={role:"user",content:ue});const ie=await(await fetch(`${Q}/websearch`,{method:"POST",headers:{"Content-Type":"application/json"},signal:$.signal,body:JSON.stringify({prompt:ue,model:he,messages:K,history_limit:8,searx_url:Rr||null,engines:Array.isArray(wn)?wn:null})})).json();ie&&typeof ie.context_block=="string"&&ie.context_block.trim()&&Z.push(ie.context_block.trim()),Array.isArray(ie==null?void 0:ie.sources)&&V.push(...ie.sources)}catch(K){if(_t(K))throw K;console.warn("web search enrichment (regenerate) failed",K)}if(V=[...new Set(V)],Re&&Z.length>0?F=`${ue} + +${Z.join(` + +`)}`:F=null,zl){const K=`msg-${Date.now()}-${Math.random()}`;let tt="";t(ie=>ie.map(Ne=>Ne.session_id===S?{...Ne,messages:[...Ne.messages||[],{id:K,role:"assistant",content:"",sources:V}]}:Ne));try{const ie=await fetch(`${Q}/sessions/${S}/regenerate`,{method:"POST",headers:{"Content-Type":"application/json"},signal:$.signal,body:JSON.stringify({index:u,model:he,stream:!0,enriched_message:F,sources:V||[]})});if(!ie.ok)throw new Error(`HTTP ${ie.status}`);const Ne=(G=ie.body)==null?void 0:G.getReader();if(!Ne)throw new Error("Missing response body");const Xt=new TextDecoder;let Ql=!1;for(;;){const{value:He,done:rm}=await Ne.read();if(rm)break;const lm=Xt.decode(He,{stream:!0});tt+=lm,Sn(S,K,tt),!Ql&&De.current!==S&&(Ql=!0,xn(Oi=>({...Oi,[S]:K})),Bn(Oi=>[...new Set([...Oi,S])]))}De.current!==S?(xn(He=>({...He,[S]:K})),Bn(He=>[...new Set([...He,S])])):Hn.current[S]?Wn(He=>({...He,[S]:K})):requestAnimationFrame(()=>Qn(K,"smooth",S))}catch(ie){if(_t(ie)){Sn(S,K,tt,{removeIfEmpty:!0});return}console.error(ie),Sn(S,K,`Error: ${$t(ie)}`,{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:he,stream:!1,enriched_message:F,sources:V||[]})});if(!K.ok)throw new Error(`HTTP ${K.status}`);const tt=await K.json(),ie=`msg-${Date.now()}`;t(Ne=>Ne.map(Xt=>Xt.session_id===S?{...Xt,messages:[...Xt.messages||[],{role:"assistant",content:tt.reply,id:ie,sources:V}]}:Xt)),De.current!==S?(xn(Ne=>({...Ne,[S]:ie})),Bn(Ne=>[...new Set([...Ne,S])])):Hn.current[S]?Wn(Ne=>({...Ne,[S]:ie})):requestAnimationFrame(()=>Qn(ie,"smooth",S))}}catch(J){_t(J)||console.error(J)}finally{Pi($)}}const[Tu,Ph]=f.useState({}),Hn=f.useRef({}),[Ih,xn]=f.useState({}),kn=f.useRef({}),Pu=f.useRef({}),[Iu,Wn]=f.useState({}),[$h,$u]=f.useState({}),Mu=(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)||[];$u(S=>{const x={};return u.forEach((_,$)=>{if(_.role!=="user")return;const F=Mu(_,$,n),Z=(_.content||"").split(/\r\n|\r|\n/).length>30;x[F]=Z?S[F]??!0:!1}),x})},[e,n]);function Mh(u){$u(p=>({...p,[u]:!(p[u]??!0)}))}const Tr=Ve.useCallback((u,p)=>{Ph(S=>{const x={...S,[u]:p};return Hn.current=x,x})},[]),Vn=f.useRef(null),Ah=f.useRef(!1),Dh=f.useRef(null),De=f.useRef(n);f.useEffect(()=>{De.current=n},[n]);const Au=Ve.useCallback(u=>{const p=new AbortController;return Vn.current={controller:p,sessionId:u},Ni(!0),p},[]),Pi=Ve.useCallback(u=>{var p;((p=Vn.current)==null?void 0:p.controller)===u&&(Vn.current=null,Ni(!1))},[]),Oh=Ve.useCallback(()=>{const u=Vn.current;u&&(Vn.current=null,u.controller.abort(),Ni(!1))},[]);f.useEffect(()=>()=>{var u;(u=Vn.current)==null||u.controller.abort()},[]);const Jt=f.useRef(null),[Fh,zh]=f.useState(230),[Wl,Du]=f.useState(!1),Uh=Ve.useCallback(u=>{Du(!0)},[]),Ii=Ve.useCallback(()=>{Du(!1)},[]),$i=Ve.useCallback(u=>{if(Wl){const p=Math.max(230,Math.min(500,u.clientX));zh(p)}},[Wl]);Ve.useEffect(()=>(window.addEventListener("mousemove",$i),window.addEventListener("mouseup",Ii),()=>{window.removeEventListener("mousemove",$i),window.removeEventListener("mouseup",Ii)}),[$i,Ii]),Ve.useEffect(()=>{Wl?document.body.classList.add("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(()=>{window.electronAPI.getSettings().then(p=>{vu(Y0(p)),dh(p.colorScheme||"Default"),Be(p.chatModel||""),wu(p.streamOutput||!1),jl(p.audioInputEnabled===!0),Tl(typeof p.audioInputDeviceId=="string"?p.audioInputDeviceId:""),Pl(typeof p.audioInputLanguage=="string"?p.audioInputLanguage:""),ku(p.scrollPositions||{}),wl(p.colorScheme||"Default")}).finally(()=>{vh(!0)});const u=()=>{var p;l==="chats"&&((p=Ee.current)==null||p.focus())};return window.electronAPI.onWindowFocus(u),()=>{}},[l]),f.useEffect(()=>{let u=!1;const p=new AbortController;return!Q||!he?(L(!1),()=>{p.abort()}):((async()=>{try{const S=await Sh(he,p.signal);u||L(!!(S!=null&&S.supports_vision))}catch(S){!u&&!_t(S)&&(console.warn("Failed to load model capabilities",S),L(!1))}})(),()=>{u=!0,p.abort()})},[Q,he]),f.useEffect(()=>{Ae.current=0,q(!1)},[ae,l]),f.useEffect(()=>{mt||!xe||Lr({shouldTranscribe:!1})},[mt,xe]),f.useEffect(()=>{Yt||!xe||Lr({shouldTranscribe:!1})},[Yt,xe]),f.useEffect(()=>{l==="chats"||!xe||Lr()},[l,xe]),f.useEffect(()=>()=>{var p;(p=Fl.current)==null||p.abort(),Li();const u=bn.current;if(u){u.ondataavailable=null,u.onstop=null,u.onerror=null;try{u.state!=="inactive"&&u.stop()}catch{}}pa(Nr.current)},[]),f.useEffect(()=>{if(!Eu||xu||!Q||Cu.current)return;Cu.current=!0;let u=!1;const p=window.setTimeout(()=>{(async()=>{let S=!1;try{let x=await xh();if(u)return;if(_u(x),!(x!=null&&x.ollama_running)&&(x!=null&&x.can_manage_locally)){const F=window.confirm(`Ollama is not running at ${x.ollama_url}. Start it in the background now with "ollama serve"?`);if(u)return;if(F){S=!0,Ci(!0),_r("Starting Ollama in the background...");const V=await fetch(`${Q}/ollama/start`,{method:"POST"});if(x=await jr(V),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,Ci(!0),_r(_&&$?`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 F=await kh();if(u)return;_u((F==null?void 0:F.ollama)||x)}}catch(x){u||(console.warn("startup Ollama check failed",x),Cr(!1),Il(`Whisper availability could not be verified: ${$t(x)}`),S&&window.alert(`Startup action failed: ${$t(x)}`))}finally{u||(Ci(!1),_r(""))}})()},1200);return()=>{u=!0,window.clearTimeout(p)}},[Q,xu,Eu]),f.useEffect(()=>{wl(yu)},[yu]);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 Pr(){if(Q)try{const p=await(await fetch(`${Q}/libraries`)).json(),S=Array.isArray(p.libraries)?p.libraries:[];if(k(S),S.length===0){v(null);return}S.some(x=>x.slug===R)||v(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();N(Array.isArray(p.jobs)?p.jobs:[])}catch(u){console.warn("Failed to load library jobs",u)}}async function Ou(u=null){const S=(typeof u=="string"?u:I).trim();if(!S){H("Name is required.");return}try{H("");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();j(!1),M(""),await Pr(),_!=null&&_.slug&&v(_.slug)}catch(x){console.error("Failed to create library",x),H(String((x==null?void 0:x.message)||x))}}async function Bh(){k([]),N([]),v(null),y(null),le(!1),m({}),await Pr(),await Vl()}f.useEffect(()=>{Q&&(_i(!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),_i(!1)}).catch(()=>{_i(!1)}))},[Q]),f.useEffect(()=>{Q&&(Pr(),Vl())},[Q]),f.useEffect(()=>{try{localStorage.setItem(kd,JSON.stringify(h||{}))}catch{}},[h]),f.useEffect(()=>{if(!Q)return;const u=setInterval(()=>{Pr(),Vl()},3e3);return()=>clearInterval(u)},[Q,l,R]),f.useEffect(()=>{bh(n)},[n,Q]),f.useEffect(()=>{const u=new Set(w.map(p=>p.slug));m(p=>{let S=!1;const x={};for(const[_,$]of Object.entries(p||{}))u.has($)?x[_]=$:S=!0;return S?x:p})},[w]);const Mi=u=>{o(u)},Hh=u=>{qh(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(()=>w.find(u=>u.slug===R)||null,[R,w]),Mt=n&&h[n]||null,vt=f.useMemo(()=>w.find(u=>u.slug===Mt)||null,[Mt,w]),Fu=f.useMemo(()=>Mt?E.some(u=>u.slug===Mt&&(u.status==="queued"||u.status==="running")):!1,[Mt,E]),Ai=f.useMemo(()=>{var u,p;return vt?(u=vt.files)!=null&&u.length?(p=vt.states)!=null&&p.is_indexed?"":Fu?" (syncing)":" (needs sync)":" (empty)":""},[vt,Fu]);function Wh(u){return u&&h[u]||null}function zu(u){const p=Wh(u);return p&&w.find(S=>S.slug===p)||null}function Uu(u){return u?E.some(p=>p.slug===u&&(p.status==="queued"||p.status==="running")):!1}function bu(u,p){u&&m(S=>{const x={...S||{}};return p?x[u]=p:delete x[u],x})}function Vh(u){u&&m(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(!U)return;const u=p=>{var S;(S=at.current)!=null&&S.contains(p.target)||le(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[U]),f.useEffect(()=>{le(!1)},[n,l]),f.useEffect(()=>{const u=n,p=l;return()=>{if(p==="chats"&&u){const S=typeof kn.current[u]=="number"?kn.current[u]:te.current?te.current.scrollTop:0;ku(x=>{const _={...x,[u]:S};return window.electronAPI.updateSettings({scrollPositions:_}),_})}}},[n,l]),f.useEffect(()=>{const u=te.current;if(!u)return;const p=()=>{const{scrollTop:S,scrollHeight:x,clientHeight:_}=u,$=x-S-_<=G0;if(n){const F=Pu.current[n],V=typeof F=="number"&&Su.removeEventListener("scroll",p)},[n,Tr]),f.useEffect(()=>{const u=n;u&&Tu[u]===!1&&Wn(p=>{if(!(u in p))return p;const S={...p};return delete S[u],S})},[n,Tu]),f.useLayoutEffect(()=>{if(l!=="chats"||!n)return;const u=te.current;if(!u)return;Jt.current=null;const p=()=>{if(Jt.current===n)return;const F=typeof kn.current[n]=="number"?kn.current[n]:void 0,V=typeof F=="number"?F:bl[n];if(typeof V=="number"){u.scrollTop=V,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 kn.current[n]=="number"?kn.current[n]:void 0;typeof(typeof u=="number"?u:bl[n])!="number"&&Kn.length>0&&requestAnimationFrame(()=>{const S=te.current;S&&(S.scrollTop=S.scrollHeight,Jt.current=n)})},[Kn.length,n,l,bl]);const Di=(u="smooth",p=null)=>{const S=te.current;if(!S)return;const x=p??De.current;De.current===x&&(S.scrollTo({top:S.scrollHeight,behavior:u}),Tr(x,!1))},Qn=(u,p="auto",S=null)=>{const x=te.current;if(!x)return;const _=S??De.current;if(De.current!==_)return;const $=document.getElementById(u);if($){const F=Math.max(0,$.offsetTop-Q0);x.scrollTo({top:F,behavior:p})}},Kh=()=>{const u=De.current,p=Iu[u];p&&(Qn(p,"smooth",u),Wn(S=>{const{[u]:x,..._}=S;return _}))},Qh=u=>{l!=="chats"||!ho(u)||(u.preventDefault(),Ae.current+=1,ae&&Cd(u)&&q(!0))},Gh=u=>{l!=="chats"||!ho(u)||(u.preventDefault(),u.dataTransfer.dropEffect=ae?"copy":"none",ae&&Cd(u)&&!W&&q(!0))},Yh=u=>{l!=="chats"||!ho(u)||(Ae.current=Math.max(0,Ae.current-1),Ae.current===0&&q(!1))},Jh=async u=>{var p,S;l!=="chats"||!ho(u)||(u.preventDefault(),Ae.current=0,q(!1),ae&&(await ju((p=u.dataTransfer)==null?void 0:p.files),(S=Ee.current)==null||S.focus()))};async function Bu(){var F,V,Z;const u=b.trim();if(gt||!u&&P.length===0||!he)return;if(P.length>0&&!ae){window.alert("The selected model does not support image inputs.");return}let p=n,S=!1;if(p){const oe=e.find(ne=>ne.session_id===p);S=oe&&oe.name==="New Chat"&&oe.messages.length===0}else{const oe=await Hu();await new Promise(ne=>setTimeout(ne,200)),p=oe.session_id,S=!0}const x=P.map(({id:oe,...ne})=>({...ne})),_={role:"user",content:u,attachments:x,id:`msg-${Date.now()}-${Math.random()}`};Ah.current=!0,Dh.current=p,Tr(p,!1),De.current===p&&(Jt.current=De.current),zp.flushSync(()=>{t(oe=>oe.map(ne=>ne.session_id===p?{...ne,messages:[...ne.messages||[],_]}:ne)),X(""),B([])}),requestAnimationFrame(()=>Di("auto",p));const $=Au(p);try{let oe=[];if(_.content)try{oe=[...(((F=e.find(ue=>ue.session_id===p))==null?void 0:F.messages)||[]).slice(-8).map(ue=>({role:ue.role,content:ue.content||""})),{role:"user",content:_.content}]}catch{}let ne=_.content||null,me=[];const Oe=[],En=zu(p);if(_.content&&((V=En==null?void 0:En.states)!=null&&V.is_indexed))try{const G=await Ru(En.slug,_.content,$.signal);G.contextBlock&&Oe.push(G.contextBlock),Array.isArray(G.sources)&&me.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:he,messages:oe,history_limit:8,searx_url:Rr||null,engines:Array.isArray(wn)?wn:null})})).json();J&&typeof J.context_block=="string"&&J.context_block.trim()&&Oe.push(J.context_block.trim()),Array.isArray(J==null?void 0:J.sources)&&me.push(...J.sources)}catch(G){if(_t(G))throw G;console.warn("web search enrichment failed",G)}if(me=[...new Set(me)],_.content&&Oe.length>0&&(ne=`${_.content} + +${Oe.join(` + +`)}`),zl){const G=`msg-${Date.now()}-${Math.random()}`;let J="";const ue={role:"assistant",content:"",id:G,sources:me};t(Re=>Re.map(K=>K.session_id===p?{...K,messages:[...K.messages||[],ue]}:K));try{const Re=await fetch(`${Q}/chat`,{method:"POST",headers:{"Content-Type":"application/json"},signal:$.signal,body:JSON.stringify({session_id:p,model:he,message:_.content,enriched_message:_.content&&Oe.length>0?ne:null,stream:!0,sources:me||[],attachments:x})});if(!Re.ok)throw new Error(`HTTP ${Re.status}`);const K=(Z=Re.body)==null?void 0:Z.getReader();if(!K)throw new Error("Missing response body");const tt=new TextDecoder;let ie=!1;for(;;){const{value:Ne,done:Xt}=await K.read();if(Xt){Sn(p,G,J),De.current===p?Hn.current[p]?Wn(He=>({...He,[p]:G})):requestAnimationFrame(()=>Qn(G,"smooth",p)):(xn(He=>({...He,[p]:G})),Bn(He=>[...new Set([...He,p])]));break}const Ql=tt.decode(Ne,{stream:!0});J+=Ql,Sn(p,G,J),De.current===p&&!Hn.current[p]&&Di("auto",p),De.current!==p&&!ie&&(xn(He=>({...He,[p]:G})),ie=!0)}}catch(Re){if(_t(Re)){Sn(p,G,J,{removeIfEmpty:!0});return}console.error("Failed to send message:",Re),Sn(p,G,"Error: "+$t(Re),{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:he,message:_.content,enriched_message:_.content&&Oe.length>0?ne:null,stream:!1,sources:me||[],attachments:x})});if(!G.ok)throw new Error(`HTTP ${G.status}`);const J=await G.json(),ue=`msg-${Date.now()}`,Re={role:"assistant",content:J.reply,id:ue,sources:me};t(K=>K.map(tt=>tt.session_id===p?{...tt,messages:[...tt.messages||[],Re]}:tt)),ue&&(De.current===p?Hn.current[p]?Wn(K=>({...K,[p]:ue})):requestAnimationFrame(()=>Qn(ue,"smooth",p)):xn(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:he})}).then(G=>G.json()).then(G=>{const J=H0(G.title);t(ue=>ue.map(Re=>Re.session_id===p?{...Re,name:J}:Re))})}catch(oe){if(_t(oe)){Pi($);return}console.error("Failed to send message:",oe);const ne={role:"assistant",content:"Error: "+$t(oe),id:`msg-${Date.now()}-${Math.random()}`};t(me=>me.map(Oe=>Oe.session_id===p?{...Oe,messages:[...Oe.messages,ne]}:Oe))}finally{Pi($)}}function Xh(){mh(u=>!u)}async function Hu(){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),(_=Ee.current)==null||_.focus(),S}function qh(u){r(u),Bn(S=>S.filter(x=>x!==u));const p=Ih[u];p&&requestAnimationFrame(()=>{let S=12;const x=()=>{if(!te.current)return;let $=document.getElementById(p);if(!$){const F=e.find(V=>V.session_id===u);if(F&&Array.isArray(F.messages))for(let V=F.messages.length-1;V>=0;V--){const Z=F.messages[V];if(Z.role==="assistant"&&Z.id){$=document.getElementById(Z.id);break}}}$?(Qn($.id,"smooth",u),xn(F=>{const{[u]:V,...Z}=F;return Z})):S-- >0&&requestAnimationFrame(x)};requestAnimationFrame(x)})}function Zh(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)),c(null)})}function em(u,p){const S=(p||"").trim(),x=w.find(_=>_.slug===u);if(!x){y(null);return}if(!S||S===x.name){y(null);return}fetch(`${Q}/libraries/${u}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:S})}).then(()=>{k(_=>_.map($=>$.slug===u?{...$,name:S}:$)),y(null)})}function Wu(u){fetch(`${Q}/sessions/${u}`,{method:"DELETE"}).then(()=>{const p=e.filter(S=>S.session_id!==u);t(p),m(S=>{const x={...S||{}};return delete x[u],x}),n===u&&r(p.length>0?p[0].session_id:null)})}function tm(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=w.filter(_=>_.slug!==u);k(S),N(_=>_.filter($=>$.slug!==u)),y(_=>_===u?null:_),R===u&&v(((x=S[0])==null?void 0:x.slug)||null),Vh(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=>{Wu(p.session_id)})},[n,e,Q]);const nm=u=>{var S;window.getSelection().toString().length>0||document.activeElement!==Ee.current&&(u.target.closest(".msg")||(S=Ee.current)==null||S.focus())};return d.jsxs("div",{className:"app",style:{gridTemplateColumns:`${Fh}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:()=>Mi("chats"),children:"Chats"}),d.jsx("div",{className:`sidebar-tab ${l==="dbs"?"active":""}`,onClick:()=>Mi("dbs"),children:"DBs"}),d.jsx("div",{className:`sidebar-tab ${l==="settings"?"active":""}`,onClick:()=>Mi("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:()=>Hh(u.session_id),children:a===u.session_id?d.jsx("input",{type:"text",className:"rename-input",defaultValue:u.name,onBlur:()=>c(null),onKeyDown:p=>{p.key==="Enter"?Zh(u.session_id,p.target.value):p.key==="Escape"&&c(null)},autoFocus:!0}):d.jsxs(d.Fragment,{children:[d.jsx("span",{children:u.name}),d.jsxs("div",{className:"chat-item-buttons",children:[gh.includes(u.session_id)&&d.jsx("div",{className:"unread-dot"}),d.jsx("button",{className:"icon-button",onClick:p=>{p.stopPropagation(),c(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(),Wu(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:w.length===0?d.jsx("div",{className:"empty-list-message",children:"No databases yet."}):w.map(u=>d.jsx("div",{className:`chat-item ${u.slug===R?"active":""}`,onClick:()=>v(u.slug),children:g===u.slug?d.jsx("input",{type:"text",className:"rename-input",defaultValue:u.name,onBlur:()=>y(null),onKeyDown:p=>{p.key==="Enter"?em(u.slug,p.target.value):p.key==="Escape"&&y(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"}),Uu(u.slug)&&d.jsx("div",{className:"db-active-badge",children:"Syncing"}),d.jsx("button",{className:"icon-button",onClick:p=>{p.stopPropagation(),y(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(),tm(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 ${i==="General"?"active":""}`,onClick:()=>s("General"),children:"General"}),d.jsx("div",{className:`settings-item ${i==="Interface"?"active":""}`,onClick:()=>s("Interface"),children:"Interface"}),d.jsx("div",{className:`settings-item ${i==="Websearch"?"active":""}`,onClick:()=>s("Websearch"),children:"Websearch"})]})]}),l!=="settings"&&d.jsxs("div",{className:"sidebar-footer",children:[l==="chats"&&d.jsx("button",{className:"button new-chat-button",onClick:Hu,children:"New Chat"}),l==="dbs"&&(C?d.jsxs("div",{className:"new-db-form",children:[d.jsx("input",{type:"text",className:"rename-input",value:I,onChange:u=>M(u.target.value),onKeyDown:u=>{u.key==="Enter"?Ou():u.key==="Escape"&&(j(!1),M(""),H(""))},placeholder:"Database name",autoFocus:!0}),A&&d.jsx("div",{className:"form-error",children:A}),d.jsxs("div",{className:"new-db-actions",children:[d.jsx("button",{className:"button new-db-button",onClick:()=>Ou(),children:"Create"}),d.jsx("button",{className:"button ghost",onClick:()=>{j(!1),M(""),H("")},children:"Cancel"})]})]}):d.jsx("button",{className:"button new-db-button",onClick:()=>{j(!0),H("")},children:"New Database"}))]}),d.jsx("div",{className:"resizer",onMouseDown:Uh})]}),d.jsxs("div",{className:`main-content${l==="chats"&&W?" main-content--drag-active":""}`,onDragEnter:Qh,onDragOver:Gh,onDragLeave:Yh,onDrop:Jh,children:[Su&&d.jsxs("div",{className:"startup-task-banner",role:"status","aria-live":"polite",children:[fh&&d.jsx("div",{className:"spinner startup-task-banner__spinner"}),d.jsx("div",{className:"startup-task-banner__text",children:Su})]}),l==="chats"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"header",children:[d.jsxs("strong",{children:["Chat - ",((Vu=e.find(u=>u.session_id===n))==null?void 0:Vu.name)||"New Chat"]}),vt&&d.jsx("span",{className:"header-subtle",children:`DB: ${vt.name}${Ai}`})]}),d.jsx("div",{className:`chat${W?" chat--drag-active":""}`,ref:te,onClick:nm,children:Kn.map((u,p)=>{const S=u.role==="user"&&yh===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(W0,{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:()=>Nu(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:()=>Lu(p),children:d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:"M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.3"})})})]})]}):d.jsxs("div",{className:"user-message-wrapper",children:[S?d.jsxs(d.Fragment,{children:[d.jsx(ms,{attachments:u.attachments,className:"message-attachment-strip"}),d.jsxs("div",{className:"msg-content msg-content--user editing",children:[d.jsx("div",{className:"user-edit-shadow","aria-hidden":"true",children:ji}),d.jsx(dd,{className:"edit-message-input edit-overlay",value:ji,onChange:x=>Bl(x.target.value),onBlur:Hl,onKeyDown:x=>{x.key==="Escape"&&(x.preventDefault(),Hl()),x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),Th(p))},autoFocus:!0,minRows:1})]})]}):(()=>{const x=u.content||"",_=Array.isArray(u.attachments)?u.attachments:[],$=x.split(/\r\n|\r|\n/),F=$.length>30,V=Mu(u,p,n),Z=F?$h[V]??!0:!1,oe=Z?$.slice(0,30).join(` +`)+` +…`:x,ne=!!x.trim();return d.jsxs(d.Fragment,{children:[d.jsx(ms,{attachments:_,className:"message-attachment-strip"}),ne&&d.jsx("div",{className:"msg-content msg-content--user",children:oe}),ne&&F&&d.jsx("button",{className:"user-msg-expand",onClick:()=>Mh(V),"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:()=>Lh(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:()=>Nu(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),Iu[n]&&d.jsxs("button",{className:"new-msg-tip",onClick:Kh,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${W?" footer-inner--drag-active":""}`,children:[d.jsx("input",{ref:Gt,type:"file",accept:"image/*",multiple:!0,className:"composer-image-input",onChange:jh,tabIndex:-1}),d.jsx(ms,{attachments:P,className:"composer-attachment-strip",removable:!0,onRemove:Eh}),(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 ${q0(fe)}`:"Transcribing audio…"})]}),d.jsxs("div",{className:"footer-content-wrapper",children:[d.jsx(dd,{ref:Ee,className:"input",value:b,onChange:u=>X(u.target.value),onKeyDown:u=>{u.key==="Enter"&&!u.shiftKey&&!xe&&!D&&(u.preventDefault(),Bu())},placeholder:"Ask any question...",maxRows:13}),d.jsxs("div",{className:"footer-tool-group",ref:at,children:[d.jsx("button",{type:"button",className:"db-picker-toggle"+(vt?" active":""),onClick:()=>{n&&le(u=>!u)},title:vt?`Database: ${vt.name}${Ai}`:"Select database for this chat","aria-haspopup":"menu","aria-expanded":U,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"})]})}),U&&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"})]}),w.length===0?d.jsx("div",{className:"db-picker-empty",children:"No databases yet."}):w.map(u=>{var _,$,F;const p=Mt===u.slug,S=Uu(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:!((F=u.files)!=null&&F.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)})]})]}),ae&&d.jsx("button",{type:"button",className:"image-attach-toggle"+(P.length>0?" active":""),onClick:Ch,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"})]})}),mt&&d.jsx("button",{type:"button",className:"audio-input-toggle"+(xe||D?" active":"")+(xe?" recording":"")+(D?" transcribing":""),onClick:Rh,title:Yt?xe?"Stop voice input":D?"Transcribing audio":"Start voice input":Un||"Whisper is not available for audio input.","aria-label":Yt?xe?"Stop voice input":D?"Transcribing audio":"Start voice input":Un||"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"+(Ul?" active":""),onClick:Xh,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?Oh:Bu,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:(Kl==null?void 0:Kl.name)||"Databases"}),vt&&d.jsx("span",{className:"header-subtle",children:`Current chat DB: ${vt.name}${Ai}`})]}),d.jsx(O0,{apiBase:Q,library:Kl,jobs:E,onRefresh:async()=>{await Pr(),await Vl()}})]}),l==="settings"&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"header",children:d.jsxs("strong",{children:[i," Settings"]})}),i==="General"&&d.jsx(T0,{onModelChange:Be,onBackendApiUrlChange:vu,streamOutput:zl,onStreamOutputChange:wu,onAudioInputEnabledChange:jl,onAudioInputDeviceChange:Tl,onAudioInputLanguageChange:Pl,onLibrariesPurged:Bh}),i==="Interface"&&d.jsx(A0,{}),i==="Websearch"&&d.jsx(b0,{searxUrl:Rr,setSearxUrl:ph,engines:wn,setEngines:u=>hh(ti(u))})]})]})]})}function ew(){return f.useEffect(()=>{window.electronAPI.getSettings().then(e=>{wl(e.colorScheme||"Default")})},[]),d.jsx(Ve.StrictMode,{children:d.jsx(Wy,{children:d.jsx(xy,{children:d.jsx(qp,{path:"/",element:d.jsx(Z0,{})})})})})}const tw=Up(document.getElementById("root"));tw.render(d.jsx(ew,{})); diff --git a/dist/assets/index-Ctu3w7qr.js b/dist/assets/index-Ctu3w7qr.js deleted file mode 100644 index 411fb51..0000000 --- a/dist/assets/index-Ctu3w7qr.js +++ /dev/null @@ -1,74 +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 em(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var xd={exports:{}},Xo={},kd={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 vl=Symbol.for("react.element"),tm=Symbol.for("react.portal"),nm=Symbol.for("react.fragment"),rm=Symbol.for("react.strict_mode"),lm=Symbol.for("react.profiler"),om=Symbol.for("react.provider"),im=Symbol.for("react.context"),sm=Symbol.for("react.forward_ref"),am=Symbol.for("react.suspense"),um=Symbol.for("react.memo"),cm=Symbol.for("react.lazy"),bu=Symbol.iterator;function dm(e){return e===null||typeof e!="object"?null:(e=bu&&e[bu]||e["@@iterator"],typeof e=="function"?e:null)}var Ed={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Cd=Object.assign,Nd={};function wr(e,t,n){this.props=e,this.context=t,this.refs=Nd,this.updater=n||Ed}wr.prototype.isReactComponent={};wr.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")};wr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function _d(){}_d.prototype=wr.prototype;function pa(e,t,n){this.props=e,this.context=t,this.refs=Nd,this.updater=n||Ed}var ha=pa.prototype=new _d;ha.constructor=pa;Cd(ha,wr.prototype);ha.isPureReactComponent=!0;var Bu=Array.isArray,jd=Object.prototype.hasOwnProperty,ma={current:null},Ld={key:!0,ref:!0,__self:!0,__source:!0};function Rd(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)jd.call(t,r)&&!Ld.hasOwnProperty(r)&&(l[r]=t[r]);var s=arguments.length-2;if(s===1)l.children=n;else if(1>>1,te=P[q];if(0>>1;ql(Gt,W))Ael(gt,Gt)?(P[q]=gt,P[Ae]=W,q=Ae):(P[q]=Gt,P[ut]=W,q=ut);else if(Ael(gt,W))P[q]=gt,P[Ae]=W,q=Ae;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,j=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(L);else{var B=n(c);B!==null&&X(C,B.startTime-P)}}function L(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&&!le());){var q=y.callback;if(typeof q=="function"){y.callback=null,w=y.priorityLevel;var te=q(y.expirationTime<=B);B=e.unstable_now(),typeof te=="function"?y.callback=te:y===n(a)&&r(a),m(B)}else r(a);y=n(a)}if(y!==null)var ke=!0;else{var ut=n(c);ut!==null&&X(C,ut.startTime-B),ke=!1}return ke}finally{y=null,w=W,k=!1}}var I=!1,M=null,A=-1,H=5,U=-1;function le(){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=te,t(a,P),E||k||(E=!0,b(L))),P},e.unstable_shouldYield=le,e.unstable_wrapCallback=function(P){var B=w;return function(){var W=w;w=B;try{return P.apply(this,arguments)}finally{w=W}}}})(Md);$d.exports=Md;var km=$d.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 Em=f,it=km;function T(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"),hs=Object.prototype.hasOwnProperty,Cm=/^[: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]*$/,Wu={},Vu={};function Nm(e){return hs.call(Vu,e)?!0:hs.call(Wu,e)?!1:Cm.test(e)?Vu[e]=!0:(Wu[e]=!0,!1)}function _m(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 jm(e,t,n,r){if(t===null||typeof t>"u"||_m(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 Je(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 Me={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Me[e]=new Je(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Me[t]=new Je(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Me[e]=new Je(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Me[e]=new Je(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){Me[e]=new Je(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Me[e]=new Je(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Me[e]=new Je(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Me[e]=new Je(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Me[e]=new Je(e,5,!1,e.toLowerCase(),null,!1,!1)});var va=/[\-:]([a-z])/g;function ya(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(va,ya);Me[t]=new Je(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(va,ya);Me[t]=new Je(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(va,ya);Me[t]=new Je(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Me[e]=new Je(e,1,!1,e.toLowerCase(),null,!1,!1)});Me.xlinkHref=new Je("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Me[e]=new Je(e,1,!1,e.toLowerCase(),null,!0,!0)});function wa(e,t,n,r){var l=Me.hasOwnProperty(t)?Me[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{Di=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?zr(e):""}function Lm(e){switch(e.tag){case 5:return zr(e.type);case 16:return zr("Lazy");case 13:return zr("Suspense");case 19:return zr("SuspenseList");case 0:case 2:case 15:return e=Oi(e.type,!1),e;case 11:return e=Oi(e.type.render,!1),e;case 1:return e=Oi(e.type,!0),e;default:return""}}function ys(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 Yn:return"Fragment";case Gn:return"Portal";case ms:return"Profiler";case Sa:return"StrictMode";case gs:return"Suspense";case vs:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Od:return(e.displayName||"Context")+".Consumer";case Dd:return(e._context.displayName||"Context")+".Provider";case xa:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ka:return t=e.displayName||null,t!==null?t:ys(e.type)||"Memo";case Zt:t=e._payload,e=e._init;try{return ys(e(t))}catch{}}return null}function Rm(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 ys(t);case 8:return t===Sa?"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 zd(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Tm(e){var t=zd(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 Vl(e){e._valueTracker||(e._valueTracker=Tm(e))}function Ud(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=zd(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function No(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 ws(e,t){var n=t.checked;return we({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Qu(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 bd(e,t){t=t.checked,t!=null&&wa(e,"checked",t,!1)}function Ss(e,t){bd(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")?xs(e,t.type,n):t.hasOwnProperty("defaultValue")&&xs(e,t.type,hn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Gu(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 xs(e,t,n){(t!=="number"||No(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Ur=Array.isArray;function ir(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=Kl.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Zr(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Hr={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},Pm=["Webkit","ms","Moz","O"];Object.keys(Hr).forEach(function(e){Pm.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Hr[t]=Hr[e]})});function Vd(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Hr.hasOwnProperty(e)&&Hr[e]?(""+t).trim():t+"px"}function Kd(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=Vd(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var Im=we({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 Cs(e,t){if(t){if(Im[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(T(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(T(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(T(61))}if(t.style!=null&&typeof t.style!="object")throw Error(T(62))}}function Ns(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 Ea(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var js=null,sr=null,ar=null;function Xu(e){if(e=Sl(e)){if(typeof js!="function")throw Error(T(280));var t=e.stateNode;t&&(t=ni(t),js(e.stateNode,e.type,t))}}function Qd(e){sr?ar?ar.push(e):ar=[e]:sr=e}function Gd(){if(sr){var e=sr,t=ar;if(ar=sr=null,Xu(e),t)for(e=0;e>>=0,e===0?32:31-(Hm(e)/Wm|0)|0}var Ql=64,Gl=4194304;function br(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 Ro(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=br(s):(o&=i,o!==0&&(r=br(o)))}else i=n&~l,i!==0?r=br(i):o!==0&&(r=br(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 yl(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Et(t),e[t]=n}function Gm(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=Vr),ic=" ",sc=!1;function mf(e,t){switch(e){case"keyup":return kg.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function gf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Jn=!1;function Cg(e,t){switch(e){case"compositionend":return gf(t);case"keypress":return t.which!==32?null:(sc=!0,ic);case"textInput":return e=t.data,e===ic&&sc?null:e;default:return null}}function Ng(e,t){if(Jn)return e==="compositionend"||!Pa&&mf(e,t)?(e=pf(),po=La=rn=null,Jn=!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=dc(n)}}function Sf(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Sf(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function xf(){for(var e=window,t=No();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=No(e.document)}return t}function Ia(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 Mg(e){var t=xf(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Sf(n.ownerDocument.documentElement,n)){if(r!==null&&Ia(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=fc(n,o);var i=fc(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,Xn=null,$s=null,Qr=null,Ms=!1;function pc(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Ms||Xn==null||Xn!==No(r)||(r=Xn,"selectionStart"in r&&Ia(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Qr&&ol(Qr,r)||(Qr=r,r=Io($s,"onSelect"),0er||(e.current=Us[er],Us[er]=null,er--)}function ae(e,t){er++,Us[er]=e.current,e.current=t}var mn={},be=vn(mn),Ze=vn(!1),Pn=mn;function pr(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 et(e){return e=e.childContextTypes,e!=null}function Mo(){fe(Ze),fe(be)}function Sc(e,t,n){if(be.current!==mn)throw Error(T(168));ae(be,t),ae(Ze,n)}function Tf(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(T(108,Rm(e)||"Unknown",l));return we({},n,r)}function Ao(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||mn,Pn=be.current,ae(be,e),ae(Ze,Ze.current),!0}function xc(e,t,n){var r=e.stateNode;if(!r)throw Error(T(169));n?(e=Tf(e,t,Pn),r.__reactInternalMemoizedMergedChildContext=e,fe(Ze),fe(be),ae(be,e)):fe(Ze),ae(Ze,n)}var Dt=null,ri=!1,Xi=!1;function Pf(e){Dt===null?Dt=[e]:Dt.push(e)}function Kg(e){ri=!0,Pf(e)}function yn(){if(!Xi&&Dt!==null){Xi=!0;var e=0,t=re;try{var n=Dt;for(re=1;e>=i,l-=i,Ot=1<<32-Et(t)+l|n<A?(H=M,M=null):H=M.sibling;var U=w(v,M,m[A],C);if(U===null){M===null&&(M=H);break}e&&M&&U.alternate===null&&t(v,M),h=o(U,h,A),I===null?L=U:I.sibling=U,I=U,M=H}if(A===m.length)return n(v,M),pe&&Cn(v,A),L;if(M===null){for(;AA?(H=M,M=null):H=M.sibling;var le=w(v,M,U.value,C);if(le===null){M===null&&(M=H);break}e&&M&&le.alternate===null&&t(v,M),h=o(le,h,A),I===null?L=le:I.sibling=le,I=le,M=H}if(U.done)return n(v,M),pe&&Cn(v,A),L;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?L=U:I.sibling=U,I=U);return pe&&Cn(v,A),L}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?L=U:I.sibling=U,I=U);return e&&M.forEach(function(he){return t(v,he)}),pe&&Cn(v,A),L}function j(v,h,m,C){if(typeof m=="object"&&m!==null&&m.type===Yn&&m.key===null&&(m=m.props.children),typeof m=="object"&&m!==null){switch(m.$$typeof){case Wl:e:{for(var L=m.key,I=h;I!==null;){if(I.key===L){if(L=m.type,L===Yn){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===L||typeof L=="object"&&L!==null&&L.$$typeof===Zt&&Cc(L)===I.type){n(v,I.sibling),h=l(I,m.props),h.ref=Mr(v,I,m),h.return=v,v=h;break e}n(v,I);break}else t(v,I);I=I.sibling}m.type===Yn?(h=Tn(m.props.children,v.mode,C,m.key),h.return=v,v=h):(C=xo(m.type,m.key,m.props,null,v.mode,C),C.ref=Mr(v,h,m),C.return=v,v=C)}return i(v);case Gn: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=os(m,v.mode,C),h.return=v,v=h}return i(v);case Zt:return I=m._init,j(v,h,I(m._payload),C)}if(Ur(m))return E(v,h,m,C);if(Rr(m))return N(v,h,m,C);to(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=ls(m,v.mode,C),h.return=v,v=h),i(v)):n(v,h)}return j}var mr=Af(!0),Df=Af(!1),Fo=vn(null),zo=null,rr=null,Da=null;function Oa(){Da=rr=zo=null}function Fa(e){var t=Fo.current;fe(Fo),e._currentValue=t}function Hs(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 cr(e,t){zo=e,Da=rr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(qe=!0),e.firstContext=null)}function ht(e){var t=e._currentValue;if(Da!==e)if(e={context:e,memoizedValue:t,next:null},rr===null){if(zo===null)throw Error(T(308));rr=e,zo.dependencies={lanes:0,firstContext:e}}else rr=rr.next=e;return t}var jn=null;function za(e){jn===null?jn=[e]:jn.push(e)}function Of(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,za(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 Ua(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ff(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,za(r)):(t.next=l.next,l.next=t),r.interleaved=t,Ht(e,n)}function mo(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,Na(e,n)}}function Nc(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 Uo(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=we({},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);Mn|=i,e.lanes=i,e.memoizedState=y}}function _c(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Zi.transition;Zi.transition={};try{e(!1),t()}finally{re=n,Zi.transition=r}}function tp(){return mt().memoizedState}function Jg(e,t,n){var r=fn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},np(e))rp(t,n);else if(n=Of(e,t,n,r),n!==null){var l=Ge();Ct(n,e,r,l),lp(n,t,r)}}function Xg(e,t,n){var r=fn(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(np(e))rp(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,Nt(s,i)){var a=t.interleaved;a===null?(l.next=l,za(t)):(l.next=a.next,a.next=l),t.interleaved=l;return}}catch{}finally{}n=Of(e,t,l,r),n!==null&&(l=Ge(),Ct(n,e,r,l),lp(n,t,r))}}function np(e){var t=e.alternate;return e===ve||t!==null&&t===ve}function rp(e,t){Gr=Bo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function lp(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Na(e,n)}}var Ho={readContext:ht,useCallback:Fe,useContext:Fe,useEffect:Fe,useImperativeHandle:Fe,useInsertionEffect:Fe,useLayoutEffect:Fe,useMemo:Fe,useReducer:Fe,useRef:Fe,useState:Fe,useDebugValue:Fe,useDeferredValue:Fe,useTransition:Fe,useMutableSource:Fe,useSyncExternalStore:Fe,useId:Fe,unstable_isNewReconciler:!1},qg={readContext:ht,useCallback:function(e,t){return Rt().memoizedState=[e,t===void 0?null:t],e},useContext:ht,useEffect:Lc,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,vo(4194308,4,Jf.bind(null,t,e),n)},useLayoutEffect:function(e,t){return vo(4194308,4,e,t)},useInsertionEffect:function(e,t){return vo(4,2,e,t)},useMemo:function(e,t){var n=Rt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Rt();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=Jg.bind(null,ve,e),[r.memoizedState,e]},useRef:function(e){var t=Rt();return e={current:e},t.memoizedState=e},useState:jc,useDebugValue:Ga,useDeferredValue:function(e){return Rt().memoizedState=e},useTransition:function(){var e=jc(!1),t=e[0];return e=Yg.bind(null,e[1]),Rt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=ve,l=Rt();if(pe){if(n===void 0)throw Error(T(407));n=n()}else{if(n=t(),Pe===null)throw Error(T(349));$n&30||Bf(r,t,n)}l.memoizedState=n;var o={value:n,getSnapshot:t};return l.queue=o,Lc(Wf.bind(null,r,o,e),[e]),r.flags|=2048,pl(9,Hf.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=Rt(),t=Pe.identifierPrefix;if(pe){var n=Ft,r=Ot;n=(r&~(1<<32-Et(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=dl++,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[Tt]=t,e[al]=r,hp(e,t,!1,!1),t.stateNode=e;e:{switch(i=Ns(n,r),n){case"dialog":de("cancel",e),de("close",e),l=r;break;case"iframe":case"object":case"embed":de("load",e),l=r;break;case"video":case"audio":for(l=0;lyr&&(t.flags|=128,r=!0,Ar(o,!1),t.lanes=4194304)}else{if(!r)if(e=bo(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Ar(o,!0),o.tail===null&&o.tailMode==="hidden"&&!i.alternate&&!pe)return ze(t),null}else 2*xe()-o.renderingStartTime>yr&&n!==1073741824&&(t.flags|=128,r=!0,Ar(o,!1),t.lanes=4194304);o.isBackwards?(i.sibling=t.child,t.child=i):(n=o.last,n!==null?n.sibling=i:t.child=i,o.last=i)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=xe(),t.sibling=null,n=ge.current,ae(ge,r?n&1|2:n&1),t):(ze(t),null);case 22:case 23:return eu(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?rt&1073741824&&(ze(t),t.subtreeFlags&6&&(t.flags|=8192)):ze(t),null;case 24:return null;case 25:return null}throw Error(T(156,t.tag))}function iv(e,t){switch(Ma(t),t.tag){case 1:return et(t.type)&&Mo(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return gr(),fe(Ze),fe(be),Ha(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Ba(t),null;case 13:if(fe(ge),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(T(340));hr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return fe(ge),null;case 4:return gr(),null;case 10:return Fa(t.type._context),null;case 22:case 23:return eu(),null;case 24:return null;default:return null}}var ro=!1,Ue=!1,sv=typeof WeakSet=="function"?WeakSet:Set,D=null;function lr(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 qs(e,t,n){try{n()}catch(r){Se(e,t,r)}}var zc=!1;function av(e,t){if(As=To,e=xf(),Ia(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(Ds={focusedElem:e,selectionRange:n},To=!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,j=E.memoizedState,v=t.stateNode,h=v.getSnapshotBeforeUpdate(t.elementType===t.type?N:St(t.type,N),j);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(T(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=zc,zc=!1,E}function Yr(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&&qs(t,n,o)}l=l.next}while(l!==r)}}function ii(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 Zs(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 vp(e){var t=e.alternate;t!==null&&(e.alternate=null,vp(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Tt],delete t[al],delete t[zs],delete t[Wg],delete t[Vg])),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 yp(e){return e.tag===5||e.tag===3||e.tag===4}function Uc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||yp(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 ea(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=$o));else if(r!==4&&(e=e.child,e!==null))for(ea(e,t,n),e=e.sibling;e!==null;)ea(e,t,n),e=e.sibling}function ta(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(ta(e,t,n),e=e.sibling;e!==null;)ta(e,t,n),e=e.sibling}var Ie=null,xt=!1;function qt(e,t,n){for(n=n.child;n!==null;)wp(e,t,n),n=n.sibling}function wp(e,t,n){if(Pt&&typeof Pt.onCommitFiberUnmount=="function")try{Pt.onCommitFiberUnmount(qo,n)}catch{}switch(n.tag){case 5:Ue||lr(n,t);case 6:var r=Ie,l=xt;Ie=null,qt(e,t,n),Ie=r,xt=l,Ie!==null&&(xt?(e=Ie,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ie.removeChild(n.stateNode));break;case 18:Ie!==null&&(xt?(e=Ie,n=n.stateNode,e.nodeType===8?Ji(e.parentNode,n):e.nodeType===1&&Ji(e,n),rl(e)):Ji(Ie,n.stateNode));break;case 4:r=Ie,l=xt,Ie=n.stateNode.containerInfo,xt=!0,qt(e,t,n),Ie=r,xt=l;break;case 0:case 11:case 14:case 15:if(!Ue&&(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)&&qs(n,t,i),l=l.next}while(l!==r)}qt(e,t,n);break;case 1:if(!Ue&&(lr(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?(Ue=(r=Ue)||n.memoizedState!==null,qt(e,t,n),Ue=r):qt(e,t,n);break;default:qt(e,t,n)}}function bc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new sv),t.forEach(function(r){var l=vv.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function wt(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=i),r&=~o}if(r=l,r=xe()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*cv(r/1960))-r,10e?16:e,ln===null)var r=!1;else{if(e=ln,ln=null,Ko=0,ee&6)throw Error(T(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;axe()-qa?Rn(e,0):Xa|=n),tt(e,t)}function jp(e,t){t===0&&(e.mode&1?(t=Gl,Gl<<=1,!(Gl&130023424)&&(Gl=4194304)):t=1);var n=Ge();e=Ht(e,t),e!==null&&(yl(e,t,n),tt(e,n))}function gv(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),jp(e,n)}function vv(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(T(314))}r!==null&&r.delete(t),jp(e,n)}var Lp;Lp=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Ze.current)qe=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return qe=!1,lv(e,t,n);qe=!!(e.flags&131072)}else qe=!1,pe&&t.flags&1048576&&If(t,Oo,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;yo(e,t),e=t.pendingProps;var l=pr(t,be.current);cr(t,n),l=Va(null,t,r,e,l,n);var o=Ka();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,et(r)?(o=!0,Ao(t)):o=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,Ua(t),l.updater=oi,t.stateNode=l,l._reactInternals=t,Vs(t,r,e,n),t=Gs(null,t,r,!0,o,n)):(t.tag=0,pe&&o&&$a(t),Qe(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(yo(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=wv(r),e=St(r,e),l){case 0:t=Qs(null,t,r,e,n);break e;case 1:t=Dc(null,t,r,e,n);break e;case 11:t=Mc(null,t,r,e,n);break e;case 14:t=Ac(null,t,r,St(r.type,e),n);break e}throw Error(T(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:St(r,l),Qs(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:St(r,l),Dc(e,t,r,l,n);case 3:e:{if(dp(t),e===null)throw Error(T(387));r=t.pendingProps,o=t.memoizedState,l=o.element,Ff(e,t),Uo(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=vr(Error(T(423)),t),t=Oc(e,t,r,n,l);break e}else if(r!==l){l=vr(Error(T(424)),t),t=Oc(e,t,r,n,l);break e}else for(lt=un(t.stateNode.containerInfo.firstChild),ot=t,pe=!0,kt=null,n=Df(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(hr(),r===l){t=Wt(e,t,n);break e}Qe(e,t,r,n)}t=t.child}return t;case 5:return zf(t),e===null&&Bs(t),r=t.type,l=t.pendingProps,o=e!==null?e.memoizedProps:null,i=l.children,Os(r,l)?i=null:o!==null&&Os(r,o)&&(t.flags|=32),cp(e,t),Qe(e,t,i,n),t.child;case 6:return e===null&&Bs(t),null;case 13:return fp(e,t,n);case 4:return ba(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=mr(t,null,r,n):Qe(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:St(r,l),Mc(e,t,r,l,n);case 7:return Qe(e,t,t.pendingProps,n),t.child;case 8:return Qe(e,t,t.pendingProps.children,n),t.child;case 12:return Qe(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,ae(Fo,r._currentValue),r._currentValue=i,o!==null)if(Nt(o.value,i)){if(o.children===l.children&&!Ze.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),Hs(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(T(341));i.lanes|=n,s=i.alternate,s!==null&&(s.lanes|=n),Hs(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}Qe(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,cr(t,n),l=ht(l),r=r(l),t.flags|=1,Qe(e,t,r,n),t.child;case 14:return r=t.type,l=St(r,t.pendingProps),l=St(r.type,l),Ac(e,t,r,l,n);case 15:return ap(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:St(r,l),yo(e,t),t.tag=1,et(r)?(e=!0,Ao(t)):e=!1,cr(t,n),op(t,r,l),Vs(t,r,l,n),Gs(null,t,r,!0,e,n);case 19:return pp(e,t,n);case 22:return up(e,t,n)}throw Error(T(156,t.tag))};function Rp(e,t){return tf(e,t)}function yv(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 yv(e,t,n,r)}function nu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function wv(e){if(typeof e=="function")return nu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===xa)return 11;if(e===ka)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 xo(e,t,n,r,l,o){var i=2;if(r=e,typeof e=="function")nu(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case Yn:return Tn(n.children,l,o,t);case Sa:i=8,l|=8;break;case ms:return e=ft(12,n,t,l|2),e.elementType=ms,e.lanes=o,e;case gs:return e=ft(13,n,t,l),e.elementType=gs,e.lanes=o,e;case vs:return e=ft(19,n,t,l),e.elementType=vs,e.lanes=o,e;case Fd:return ai(n,l,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Dd:i=10;break e;case Od:i=9;break e;case xa:i=11;break e;case ka:i=14;break e;case Zt:i=16,r=null;break e}throw Error(T(130,e==null?e:typeof e,""))}return t=ft(i,n,t,l),t.elementType=e,t.type=r,t.lanes=o,t}function Tn(e,t,n,r){return e=ft(7,e,r,t),e.lanes=n,e}function ai(e,t,n,r){return e=ft(22,e,r,t),e.elementType=Fd,e.lanes=n,e.stateNode={isHidden:!1},e}function ls(e,t,n){return e=ft(6,e,null,t),e.lanes=n,e}function os(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 Sv(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=zi(0),this.expirationTimes=zi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=zi(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function ru(e,t,n,r,l,o,i,s,a){return e=new Sv(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},Ua(o),e}function xv(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE($p)}catch(e){console.error(e)}}$p(),Id.exports=st;var Mp=Id.exports,Ap,Yc=Mp;Ap=Yc.createRoot,Yc.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 Jc="popstate";function _v(e={}){function t(l,o){let{pathname:i="/",search:s="",hash:a=""}=Fn(l.location.hash.substring(1));return!i.startsWith("/")&&!i.startsWith(".")&&(i="/"+i),ia("",{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:ml(o))}function r(l,o){_t(l.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(o)})`)}return Lv(t,n,r,e)}function ye(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function _t(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function jv(){return Math.random().toString(36).substring(2,10)}function Xc(e,t){return{usr:e.state,key:e.key,idx:t}}function ia(e,t,n=null,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Fn(t):t,state:n,key:t&&t.key||r||jv()}}function ml({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 Fn(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 Lv(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 j=g(),v=j==null?null:j-c;c=j,a&&a({action:s,location:N.location,delta:v})}function w(j,v){s="PUSH";let h=ia(N.location,j,v);n&&n(h,j),c=g()+1;let m=Xc(h,c),C=N.createHref(h);try{i.pushState(m,"",C)}catch(L){if(L instanceof DOMException&&L.name==="DataCloneError")throw L;l.location.assign(C)}o&&a&&a({action:s,location:N.location,delta:1})}function k(j,v){s="REPLACE";let h=ia(N.location,j,v);n&&n(h,j),c=g();let m=Xc(h,c),C=N.createHref(h);i.replaceState(m,"",C),o&&a&&a({action:s,location:N.location,delta:0})}function E(j){return Rv(j)}let N={get action(){return s},get location(){return e(l,i)},listen(j){if(a)throw new Error("A history only accepts one active listener");return l.addEventListener(Jc,y),a=j,()=>{l.removeEventListener(Jc,y),a=null}},createHref(j){return t(l,j)},createURL:E,encodeLocation(j){let v=E(j);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:w,replace:k,go(j){return i.go(j)}};return N}function Rv(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),ye(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:ml(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function Dp(e,t,n="/"){return Tv(e,t,n,!1)}function Tv(e,t,n,r){let l=typeof t=="string"?Fn(t):t,o=Vt(l.pathname||"/",n);if(o==null)return null;let i=Op(e);Pv(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;ye(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&&(ye(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${y}".`),Op(i.children,t,w,y,a)),!(i.path==null&&!i.index)&&t.push({path:y,score:Fv(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 Fp(i.path))o(i,s,!0,c)}),t}function Fp(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=Fp(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 Pv(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:zv(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Iv=/^:[\w-]+$/,$v=3,Mv=2,Av=1,Dv=10,Ov=-2,qc=e=>e==="*";function Fv(e,t){let n=e.split("/"),r=n.length;return n.some(qc)&&(r+=Ov),t&&(r+=Mv),n.filter(l=>!qc(l)).reduce((l,o)=>l+(Iv.test(o)?$v:o===""?Av:Dv),r)}function zv(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 Uv(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 bv(e,t=!1,n=!0){_t(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 Bv(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return _t(!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 Hv(e,t="/"){let{pathname:n,search:r="",hash:l=""}=typeof e=="string"?Fn(e):e;return{pathname:n?n.startsWith("/")?n:Wv(n,t):t,search:Qv(r),hash:Gv(l)}}function Wv(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 is(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 Vv(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function zp(e){let t=Vv(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Up(e,t,n,r=!1){let l;typeof e=="string"?l=Fn(e):(l={...e},ye(!l.pathname||!l.pathname.includes("?"),is("?","pathname","search",l)),ye(!l.pathname||!l.pathname.includes("#"),is("#","pathname","hash",l)),ye(!l.search||!l.search.includes("#"),is("#","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=Hv(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,"/"),Kv=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Qv=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Gv=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Yv(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}var bp=["POST","PUT","PATCH","DELETE"];new Set(bp);var Jv=["GET",...bp];new Set(Jv);var kr=f.createContext(null);kr.displayName="DataRouter";var pi=f.createContext(null);pi.displayName="DataRouterState";f.createContext(!1);var Bp=f.createContext({isTransitioning:!1});Bp.displayName="ViewTransition";var Xv=f.createContext(new Map);Xv.displayName="Fetchers";var qv=f.createContext(null);qv.displayName="Await";var $t=f.createContext(null);$t.displayName="Navigation";var kl=f.createContext(null);kl.displayName="Location";var Qt=f.createContext({outlet:null,matches:[],isDataRoute:!1});Qt.displayName="Route";var su=f.createContext(null);su.displayName="RouteError";function Zv(e,{relative:t}={}){ye(El(),"useHref() may be used only in the context of a component.");let{basename:n,navigator:r}=f.useContext($t),{hash:l,pathname:o,search:i}=Cl(e,{relative:t}),s=o;return n!=="/"&&(s=o==="/"?n:Ut([n,o])),r.createHref({pathname:s,search:i,hash:l})}function El(){return f.useContext(kl)!=null}function zn(){return ye(El(),"useLocation() may be used only in the context of a component."),f.useContext(kl).location}var Hp="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Wp(e){f.useContext($t).static||f.useLayoutEffect(e)}function ey(){let{isDataRoute:e}=f.useContext(Qt);return e?py():ty()}function ty(){ye(El(),"useNavigate() may be used only in the context of a component.");let e=f.useContext(kr),{basename:t,navigator:n}=f.useContext($t),{matches:r}=f.useContext(Qt),{pathname:l}=zn(),o=JSON.stringify(zp(r)),i=f.useRef(!1);return Wp(()=>{i.current=!0}),f.useCallback((a,c={})=>{if(_t(i.current,Hp),!i.current)return;if(typeof a=="number"){n.go(a);return}let g=Up(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 Cl(e,{relative:t}={}){let{matches:n}=f.useContext(Qt),{pathname:r}=zn(),l=JSON.stringify(zp(n));return f.useMemo(()=>Up(e,JSON.parse(l),r,t==="path"),[e,l,r,t])}function ny(e,t){return Vp(e,t)}function Vp(e,t,n,r,l){var h;ye(El(),"useRoutes() may be used only in the context of a component.");let{navigator:o}=f.useContext($t),{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||"";Kp(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=zn(),k;if(t){let m=typeof t=="string"?Fn(t):t;ye(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 j=Dp(e,{pathname:N});_t(y||j!=null,`No routes matched location "${k.pathname}${k.search}${k.hash}" `),_t(j==null||j[j.length-1].route.element!==void 0||j[j.length-1].route.Component!==void 0||j[j.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=sy(j&&j.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(kl.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...k},navigationType:"POP"}},v):v}function ry(){let e=fy(),t=Yv(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 ly=f.createElement(ry,null),oy=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(su.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function iy({routeContext:e,match:t,children:n}){let r=f.useContext(kr);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 sy(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);ye(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||ly,s&&(a<0&&y===0?(Kp("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 j=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(iy,{match:g,routeContext:{outlet:c,matches:j,isDataRoute:n!=null},children:h})};return n&&(g.route.ErrorBoundary||g.route.errorElement||y===0)?f.createElement(oy,{location:n.location,revalidation:n.revalidation,component:E,error:w,children:v(),routeContext:{outlet:null,matches:j,isDataRoute:!0},unstable_onError:r}):v()},null)}function au(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ay(e){let t=f.useContext(kr);return ye(t,au(e)),t}function uy(e){let t=f.useContext(pi);return ye(t,au(e)),t}function cy(e){let t=f.useContext(Qt);return ye(t,au(e)),t}function uu(e){let t=cy(e),n=t.matches[t.matches.length-1];return ye(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function dy(){return uu("useRouteId")}function fy(){var r;let e=f.useContext(su),t=uy("useRouteError"),n=uu("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function py(){let{router:e}=ay("useNavigate"),t=uu("useNavigate"),n=f.useRef(!1);return Wp(()=>{n.current=!0}),f.useCallback(async(l,o={})=>{_t(n.current,Hp),n.current&&(typeof l=="number"?e.navigate(l):await e.navigate(l,{fromRouteId:t,...o}))},[e,t])}var Zc={};function Kp(e,t,n){!t&&!Zc[e]&&(Zc[e]=!0,_t(!1,n))}f.memo(hy);function hy({routes:e,future:t,state:n,unstable_onError:r}){return Vp(e,void 0,n,r,t)}function Qp(e){ye(!1,"A is only ever to be used as the child of element, never rendered directly. Please wrap your in a .")}function my({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:l,static:o=!1}){ye(!El(),"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=Fn(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 _t(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($t.Provider,{value:s},f.createElement(kl.Provider,{children:t,value:k}))}function gy({children:e,location:t}){return ny(sa(e),t)}function sa(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,sa(r.props.children,o));return}ye(r.type===Qp,`[${typeof r.type=="string"?r.type:r.type.name}] is not a component. All component children of must be a or `),ye(!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=sa(r.props.children,o)),n.push(i)}),n}var ko="get",Eo="application/x-www-form-urlencoded";function hi(e){return e!=null&&typeof e.tagName=="string"}function vy(e){return hi(e)&&e.tagName.toLowerCase()==="button"}function yy(e){return hi(e)&&e.tagName.toLowerCase()==="form"}function wy(e){return hi(e)&&e.tagName.toLowerCase()==="input"}function Sy(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function xy(e,t){return e.button===0&&(!t||t==="_self")&&!Sy(e)}var io=null;function ky(){if(io===null)try{new FormData(document.createElement("form"),0),io=!1}catch{io=!0}return io}var Ey=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function ss(e){return e!=null&&!Ey.has(e)?(_t(!1,`"${e}" is not a valid \`encType\` for \`\`/\`\` and will default to "${Eo}"`),null):e}function Cy(e,t){let n,r,l,o,i;if(yy(e)){let s=e.getAttribute("action");r=s?Vt(s,t):null,n=e.getAttribute("method")||ko,l=ss(e.getAttribute("enctype"))||Eo,o=new FormData(e)}else if(vy(e)||wy(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 O0(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 lh(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 z0({content:e,streamOutput:t,sources:n}){const{think:r,answer:l}=lh(e||""),[o,i]=Ke.useState(!1),s=!!r;return d.jsxs("div",{className:"assistant-message",children:[s&&d.jsxs("div",{className:"assistant-thoughts",children:[d.jsxs("button",{className:"think-toggle",onClick:()=>i(a=>!a),"aria-expanded":o?"true":"false","aria-controls":"think-content",children:[d.jsx("span",{className:"think-toggle-icon","aria-hidden":"true",children:o?"▾":"▸"}),"Thoughts"]}),o&&d.jsx("div",{id:"think-content",className:"think-content",dangerouslySetInnerHTML:{__html:hd(r)}})]}),d.jsx("div",{className:"msg-content",dangerouslySetInnerHTML:{__html:hd(l||e||"")}}),Array.isArray(n)&&n.length>0&&d.jsx("div",{className:"msg-sources chips",children:n.map((a,c)=>{let g=a,y=!1;try{const w=new URL(a);if(w.protocol==="file:"){y=!0;const k=w.pathname.split("/").filter(Boolean);g=decodeURIComponent(k[k.length-1]||a)}else g=(w.hostname||a).replace(/^www\./i,"")}catch{}return d.jsx("a",{className:"chip",href:a,target:"_blank",rel:"noreferrer",title:a,onClick:w=>{var k,E;if(y){w.preventDefault();try{const N=new URL(a);(E=(k=window.electronAPI)==null?void 0:k.openPath)==null||E.call(k,decodeURIComponent(N.pathname))}catch{}}},children:g},a+c)})})]})}function ds({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 md="websearch.searxUrl",gd="websearch.engines",vd="chat.libraryBySession",yd="http://127.0.0.1:8888",fs=6,ps=20*1024*1024,U0=5*60*1e3,b0=200;let oh="http://127.0.0.1:8000";const B0=48,H0=24;function W0(e){return e.backendApiUrl||e.ollamaApiUrl||oh}function V0(e){const t=typeof e=="string"?e.trim():"";return!t||t==="http://localhost:8888"?yd:t}function ao(e){var n;return Array.from(((n=e==null?void 0:e.dataTransfer)==null?void 0:n.types)||[]).includes("Files")}function fa(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 wd(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"&&fa((i=o.getAsFile)==null?void 0:i.call(o))}):Array.from(((l=e==null?void 0:e.dataTransfer)==null?void 0:l.files)||[]).some(fa)}function Sd(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 K0(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 Q0(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 G0(){var Uu;const[e,t]=f.useState([]),[n,r]=f.useState(null),[l,o]=f.useState("chats"),[i,s]=f.useState("General"),[a,c]=f.useState(null),[g,y]=f.useState(null),[w,k]=f.useState([]),[E,N]=f.useState([]),[j,v]=f.useState(null),[h,m]=f.useState(()=>{try{const u=localStorage.getItem(vd);return u?JSON.parse(u):{}}catch{return{}}}),[C,L]=f.useState(!1),[I,M]=f.useState(""),[A,H]=f.useState(""),[U,le]=f.useState(!1),[he,Be]=f.useState(""),[ue,R]=f.useState(!1),[b,X]=f.useState(""),[P,B]=f.useState([]),[W,q]=f.useState(!1),te=f.useRef(null),ke=f.useRef(null),ut=f.useRef(null),Gt=f.useRef(null),Ae=f.useRef(0),[gt,Nl]=f.useState(!1),[_l,jl]=f.useState(""),[gi,Ll]=f.useState(""),[_e,Rl]=f.useState(!1),[He,vi]=f.useState(!1),[yi,Er]=f.useState(0),O=f.useRef(null),F=f.useRef(null),oe=f.useRef([]),Ee=f.useRef(null),Un=f.useRef(""),Tl=f.useRef(null),Pl=f.useRef(null),wi=f.useRef(0),Il=f.useRef(null),[Q,pu]=f.useState(oh),[hu,ih]=f.useState("Default"),[$l,mu]=f.useState(!1),[gu,Cr]=f.useState(""),[sh,Si]=f.useState(!1),[Nr,ah]=f.useState(()=>V0(localStorage.getItem(md))),[wn,uh]=f.useState(()=>A0(localStorage.getItem(gd)));f.useEffect(()=>{localStorage.setItem(md,Nr||"")},[Nr]),f.useEffect(()=>{try{localStorage.setItem(gd,JSON.stringify(Jo(wn)))}catch{}},[wn]);const[Ml,ch]=f.useState(!1),[vt,xi]=f.useState(!1),[vu,ki]=f.useState(!0),[dh,bn]=f.useState([]),[Al,yu]=f.useState({}),[wu,fh]=f.useState(!1),Su=f.useRef(!1),[ph,Ei]=f.useState(null),[Ci,Dl]=f.useState("");function hh(u){const p=u.content||"";if(u.role==="assistant")try{const{answer:S}=lh(p);return(S||p).trim()}catch{return p.trim()}return p}async function xu(u){try{await navigator.clipboard.writeText(hh(u))}catch(p){console.error("Failed to copy message:",p)}}function Sn(u,p,S,x={}){const{removeIfEmpty:_=!1}=x;t($=>$.map(z=>{if(z.session_id!==u)return z;const V=[];for(const Z of z.messages||[]){if(Z.id!==p){V.push(Z);continue}_&&!S||V.push({...Z,content:S})}return{...z,messages:V}}))}function jt(u){return(u==null?void 0:u.name)==="AbortError"}function Yt(u){return u instanceof Error&&u.message?u.message:String(u)}async function _r(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 mh(u,p){const S=await fetch(`${Q}/models/capabilities?name=${encodeURIComponent(u)}`,{signal:p});return _r(S)}async function gh(){const u=await fetch(`${Q}/ollama/startup-status`);return _r(u)}async function vh(){const u=await fetch(`${Q}/startup/prepare-models`,{method:"POST"});return _r(u)}async function ku(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 Eu(u){const p=Array.from(u||[]).filter(fa);if(!p.length||!ue)return;const S=Math.max(0,fs-P.length);if(S<=0){window.alert(`You can attach up to ${fs} images per message.`);return}const x=p.slice(0,S),_=x.filter(z=>Number(z.size)>ps),$=x.filter(z=>Number(z.size)<=ps);if(_.length>0&&window.alert(`Images must be ${Math.round(ps/(1024*1024))} MB or smaller.`),!!$.length)try{const z=await Promise.all($.map(async(V,Z)=>({id:`attachment-${Date.now()}-${Z}-${Math.random().toString(36).slice(2)}`,name:V.name||"image",mime_type:V.type||"image/*",data_url:await Sd(V)})));B(V=>[...V,...z]),p.length>S&&window.alert(`Only the first ${fs} images can be attached.`)}catch(z){console.error("Failed to load image attachments",z),window.alert(`Image import failed: ${Yt(z)}`)}}function yh(u){B(p=>p.filter(S=>S.id!==u))}function wh(){var u;ue&&((u=Gt.current)==null||u.click())}function Ni(){Tl.current&&(window.clearInterval(Tl.current),Tl.current=null),Pl.current&&(window.clearTimeout(Pl.current),Pl.current=null)}function _i(u=F.current){Ni(),ua(u),F.current===u&&(F.current=null),O.current=null}async function Sh(u,p){if(!Q)throw new Error("The Heimgeist backend is not configured.");const S=new AbortController;Il.current=S,vi(!0);try{const x=await Sd(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 V=$.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||V||"audio/webm",audio_base64:z,language:gi||null})}),ie=await _r(Z),ne=String((ie==null?void 0:ie.text)||"").trim();if(!ne){window.alert("No speech was detected. Try again and speak closer to the selected microphone.");return}X(me=>K0(me,ne)),requestAnimationFrame(()=>{var me;return(me=ke.current)==null?void 0:me.focus()})}catch(x){if(jt(x))return;throw x}finally{Il.current===S&&(Il.current=null),vi(!1)}}async function Ol(u={}){const{shouldTranscribe:p=!0}=u,S=O.current,x=Ee.current,_=Un.current||(S==null?void 0:S.mimeType)||"audio/webm";if(!(!S||!x)){Rl(!1),Ni();try{S.state!=="inactive"&&S.stop();const $=await x;if(!p)return;if(!$||$.size<=0)throw new Error("Recorded audio was empty.");await Sh($,_)}catch($){p&&(console.error("Failed to stop microphone recording",$),window.alert(`Microphone transcription failed: ${Yt($)}`))}finally{Ee.current=null,oe.current=[],Un.current="",wi.current=0,Er(0)}}}async function xh(){if(!gt||_e||He||vt)return;if(!mi()){window.alert("Microphone capture is not available in this environment.");return}let u=null;try{u=await navigator.mediaDevices.getUserMedia(g0(_l))}catch(x){console.error("Failed to access microphone",x),window.alert(`Microphone access failed: ${Yt(x)}`);return}const p=y0();let S=null;try{S=p?new MediaRecorder(u,{mimeType:p}):new MediaRecorder(u)}catch(x){_i(u),console.error("Failed to create audio recorder",x),window.alert(`Microphone recording is not available: ${Yt(x)}`);return}F.current=u,O.current=S,oe.current=[],Un.current=S.mimeType||p||"audio/webm",wi.current=Date.now(),Er(0),Rl(!0),S.ondataavailable=x=>{x.data&&x.data.size>0&&oe.current.push(x.data)},Ee.current=new Promise((x,_)=>{S.onstop=()=>{const $=new Blob(oe.current,{type:S.mimeType||Un.current||"audio/webm"});_i(u),x($)},S.onerror=$=>{_i(u),_(($==null?void 0:$.error)||new Error("Audio recording failed."))}}),Tl.current=window.setInterval(()=>{Er(Date.now()-wi.current)},b0),Pl.current=window.setTimeout(()=>{Ol()},U0),S.start()}async function kh(){if(!He){if(_e){await Ol();return}await xh()}}async function Eh(u){var S;const p=(S=u.target)==null?void 0:S.files;try{await Eu(p)}finally{u.target&&(u.target.value="")}}function Ch(u,p){Ei(u),Dl(p||"")}function Fl(){Ei(null),Dl("")}async function Nh(u){var $;const p=((($=Vn[u])==null?void 0:$.content)||"").trim(),x=(Ci??"").trim();if(x.length===0){Fl();return}if(x===p){Fl();return}const _=n;if(_){t(z=>z.map(V=>{if(V.session_id!==_)return V;const ie=(V.messages||[]).slice(0,u+1).map((ne,me)=>me===u?{...ne,content:x}:ne);return{...V,messages:ie}})),Ei(null),Dl(""),requestAnimationFrame(()=>Ii("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(V=>V.map(Z=>{if(Z.session_id!==_)return Z;const ne=(Z.messages||[]).map((me,Oe)=>Oe===u?{...me,content:p}:me);return{...Z,messages:ne}}));return}await Cu(u,x)}}async function Cu(u,p=null){var ie,ne,me,Oe,En,G;const S=n;if(vt||!S||typeof u!="number")return;const x=((ie=e.find(J=>J.session_id===S))==null?void 0:ie.messages)||[];let _=u;for(let J=u;J>=0;J--)if(((ne=x[J])==null?void 0:ne.role)==="user"){_=J;break}t(J=>J.map(ce=>ce.session_id===S?{...ce,messages:(ce.messages||[]).slice(0,_+1)}:ce));const $=Tu(S);let z=p??(((me=x[_])==null?void 0:me.content)||""),V=[];const Z=[];try{const J=Mu(S),ce=p??(((Oe=x[_])==null?void 0:Oe.content)||""),je=!!(ce||"").trim();if(je&&((En=J==null?void 0:J.states)!=null&&En.is_indexed))try{const K=await ku(J.slug,ce,$.signal);K.contextBlock&&Z.push(K.contextBlock),Array.isArray(K.sources)&&V.push(...K.sources)}catch(K){if(jt(K))throw K;console.warn("local library enrichment (regenerate) failed",K)}if(je&&Ml)try{const K=x.slice(Math.max(0,_-7),_+1).map(Ce=>({role:Ce.role,content:Ce.content||""}));K.length>0&&(K[K.length-1]={role:"user",content:ce});const se=await(await fetch(`${Q}/websearch`,{method:"POST",headers:{"Content-Type":"application/json"},signal:$.signal,body:JSON.stringify({prompt:ce,model:he,messages:K,history_limit:8,searx_url:Nr||null,engines:Array.isArray(wn)?wn:null})})).json();se&&typeof se.context_block=="string"&&se.context_block.trim()&&Z.push(se.context_block.trim()),Array.isArray(se==null?void 0:se.sources)&&V.push(...se.sources)}catch(K){if(jt(K))throw K;console.warn("web search enrichment (regenerate) failed",K)}if(V=[...new Set(V)],je&&Z.length>0?z=`${ce} - -${Z.join(` - -`)}`:z=null,$l){const K=`msg-${Date.now()}-${Math.random()}`;let nt="";t(se=>se.map(Ce=>Ce.session_id===S?{...Ce,messages:[...Ce.messages||[],{id:K,role:"assistant",content:"",sources:V}]}:Ce));try{const se=await fetch(`${Q}/sessions/${S}/regenerate`,{method:"POST",headers:{"Content-Type":"application/json"},signal:$.signal,body:JSON.stringify({index:u,model:he,stream:!0,enriched_message:z,sources:V||[]})});if(!se.ok)throw new Error(`HTTP ${se.status}`);const Ce=(G=se.body)==null?void 0:G.getReader();if(!Ce)throw new Error("Missing response body");const Xt=new TextDecoder;let Bl=!1;for(;;){const{value:We,done:qh}=await Ce.read();if(qh)break;const Zh=Xt.decode(We,{stream:!0});nt+=Zh,Sn(S,K,nt),!Bl&&De.current!==S&&(Bl=!0,xn($i=>({...$i,[S]:K})),bn($i=>[...new Set([...$i,S])]))}De.current!==S?(xn(We=>({...We,[S]:K})),bn(We=>[...new Set([...We,S])])):Bn.current[S]?Hn(We=>({...We,[S]:K})):requestAnimationFrame(()=>Kn(K,"smooth",S))}catch(se){if(jt(se)){Sn(S,K,nt,{removeIfEmpty:!0});return}console.error(se),Sn(S,K,`Error: ${Yt(se)}`,{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:he,stream:!1,enriched_message:z,sources:V||[]})});if(!K.ok)throw new Error(`HTTP ${K.status}`);const nt=await K.json(),se=`msg-${Date.now()}`;t(Ce=>Ce.map(Xt=>Xt.session_id===S?{...Xt,messages:[...Xt.messages||[],{role:"assistant",content:nt.reply,id:se,sources:V}]}:Xt)),De.current!==S?(xn(Ce=>({...Ce,[S]:se})),bn(Ce=>[...new Set([...Ce,S])])):Bn.current[S]?Hn(Ce=>({...Ce,[S]:se})):requestAnimationFrame(()=>Kn(se,"smooth",S))}}catch(J){jt(J)||console.error(J)}finally{ji($)}}const[Nu,_h]=f.useState({}),Bn=f.useRef({}),[jh,xn]=f.useState({}),kn=f.useRef({}),_u=f.useRef({}),[ju,Hn]=f.useState({}),[Lh,Lu]=f.useState({}),Ru=(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)||[];Lu(S=>{const x={};return u.forEach((_,$)=>{if(_.role!=="user")return;const z=Ru(_,$,n),Z=(_.content||"").split(/\r\n|\r|\n/).length>30;x[z]=Z?S[z]??!0:!1}),x})},[e,n]);function Rh(u){Lu(p=>({...p,[u]:!(p[u]??!0)}))}const jr=Ke.useCallback((u,p)=>{_h(S=>{const x={...S,[u]:p};return Bn.current=x,x})},[]),Wn=f.useRef(null),Th=f.useRef(!1),Ph=f.useRef(null),De=f.useRef(n);f.useEffect(()=>{De.current=n},[n]);const Tu=Ke.useCallback(u=>{const p=new AbortController;return Wn.current={controller:p,sessionId:u},xi(!0),p},[]),ji=Ke.useCallback(u=>{var p;((p=Wn.current)==null?void 0:p.controller)===u&&(Wn.current=null,xi(!1))},[]),Ih=Ke.useCallback(()=>{const u=Wn.current;u&&(Wn.current=null,u.controller.abort(),xi(!1))},[]);f.useEffect(()=>()=>{var u;(u=Wn.current)==null||u.controller.abort()},[]);const Jt=f.useRef(null),[$h,Mh]=f.useState(230),[zl,Pu]=f.useState(!1),Ah=Ke.useCallback(u=>{Pu(!0)},[]),Li=Ke.useCallback(()=>{Pu(!1)},[]),Ri=Ke.useCallback(u=>{if(zl){const p=Math.max(230,Math.min(500,u.clientX));Mh(p)}},[zl]);Ke.useEffect(()=>(window.addEventListener("mousemove",Ri),window.addEventListener("mouseup",Li),()=>{window.removeEventListener("mousemove",Ri),window.removeEventListener("mouseup",Li)}),[Ri,Li]),Ke.useEffect(()=>{zl?document.body.classList.add("no-select"):document.body.classList.remove("no-select")},[zl]),Ke.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(()=>{window.electronAPI.getSettings().then(p=>{pu(W0(p)),ih(p.colorScheme||"Default"),Be(p.chatModel||""),mu(p.streamOutput||!1),Nl(p.audioInputEnabled===!0),jl(typeof p.audioInputDeviceId=="string"?p.audioInputDeviceId:""),Ll(typeof p.audioInputLanguage=="string"?p.audioInputLanguage:""),yu(p.scrollPositions||{}),gl(p.colorScheme||"Default")}).finally(()=>{fh(!0)});const u=()=>{var p;l==="chats"&&((p=ke.current)==null||p.focus())};return window.electronAPI.onWindowFocus(u),()=>{}},[l]),f.useEffect(()=>{let u=!1;const p=new AbortController;return!Q||!he?(R(!1),()=>{p.abort()}):((async()=>{try{const S=await mh(he,p.signal);u||R(!!(S!=null&&S.supports_vision))}catch(S){!u&&!jt(S)&&(console.warn("Failed to load model capabilities",S),R(!1))}})(),()=>{u=!0,p.abort()})},[Q,he]),f.useEffect(()=>{Ae.current=0,q(!1)},[ue,l]),f.useEffect(()=>{gt||!_e||Ol({shouldTranscribe:!1})},[gt,_e]),f.useEffect(()=>{l==="chats"||!_e||Ol()},[l,_e]),f.useEffect(()=>()=>{var p;(p=Il.current)==null||p.abort(),Ni();const u=O.current;if(u){u.ondataavailable=null,u.onstop=null,u.onerror=null;try{u.state!=="inactive"&&u.stop()}catch{}}ua(F.current)},[]),f.useEffect(()=>{if(!wu||vu||!Q||Su.current)return;Su.current=!0;let u=!1;const p=window.setTimeout(()=>{(async()=>{let S=!1;try{let x=await gh();if(u)return;if(!(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,Si(!0),Cr("Starting Ollama in the background...");const V=await fetch(`${Q}/ollama/start`,{method:"POST"});if(x=await _r(V),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,Si(!0),Cr(_&&$?`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.`),await vh(),u))return}catch(x){u||(console.warn("startup Ollama check failed",x),S&&window.alert(`Startup action failed: ${Yt(x)}`))}finally{u||(Si(!1),Cr(""))}})()},1200);return()=>{u=!0,window.clearTimeout(p)}},[Q,vu,wu]),f.useEffect(()=>{gl(hu)},[hu]);const Dh=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 Lr(){if(Q)try{const p=await(await fetch(`${Q}/libraries`)).json(),S=Array.isArray(p.libraries)?p.libraries:[];if(k(S),S.length===0){v(null);return}S.some(x=>x.slug===j)||v(S[0].slug)}catch(u){console.warn("Failed to load libraries",u)}}async function Ul(){if(Q)try{const p=await(await fetch(`${Q}/jobs`)).json();N(Array.isArray(p.jobs)?p.jobs:[])}catch(u){console.warn("Failed to load library jobs",u)}}async function Iu(u=null){const S=(typeof u=="string"?u:I).trim();if(!S){H("Name is required.");return}try{H("");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();L(!1),M(""),await Lr(),_!=null&&_.slug&&v(_.slug)}catch(x){console.error("Failed to create library",x),H(String((x==null?void 0:x.message)||x))}}async function Oh(){k([]),N([]),v(null),y(null),le(!1),m({}),await Lr(),await Ul()}f.useEffect(()=>{Q&&(ki(!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),ki(!1)}).catch(()=>{ki(!1)}))},[Q]),f.useEffect(()=>{Q&&(Lr(),Ul())},[Q]),f.useEffect(()=>{try{localStorage.setItem(vd,JSON.stringify(h||{}))}catch{}},[h]),f.useEffect(()=>{if(!Q)return;const u=setInterval(()=>{Lr(),Ul()},3e3);return()=>clearInterval(u)},[Q,l,j]),f.useEffect(()=>{Dh(n)},[n,Q]),f.useEffect(()=>{const u=new Set(w.map(p=>p.slug));m(p=>{let S=!1;const x={};for(const[_,$]of Object.entries(p||{}))u.has($)?x[_]=$:S=!0;return S?x:p})},[w]);const Ti=u=>{o(u)},Fh=u=>{Qh(u)},Vn=f.useMemo(()=>{var u;return((u=e.find(p=>p.session_id===n))==null?void 0:u.messages)||[]},[n,e]),bl=f.useMemo(()=>w.find(u=>u.slug===j)||null,[j,w]),Mt=n&&h[n]||null,yt=f.useMemo(()=>w.find(u=>u.slug===Mt)||null,[Mt,w]),$u=f.useMemo(()=>Mt?E.some(u=>u.slug===Mt&&(u.status==="queued"||u.status==="running")):!1,[Mt,E]),Pi=f.useMemo(()=>{var u,p;return yt?(u=yt.files)!=null&&u.length?(p=yt.states)!=null&&p.is_indexed?"":$u?" (syncing)":" (needs sync)":" (empty)":""},[yt,$u]);function zh(u){return u&&h[u]||null}function Mu(u){const p=zh(u);return p&&w.find(S=>S.slug===p)||null}function Au(u){return u?E.some(p=>p.slug===u&&(p.status==="queued"||p.status==="running")):!1}function Du(u,p){u&&m(S=>{const x={...S||{}};return p?x[u]=p:delete x[u],x})}function Uh(u){u&&m(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(!U)return;const u=p=>{var S;(S=ut.current)!=null&&S.contains(p.target)||le(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[U]),f.useEffect(()=>{le(!1)},[n,l]),f.useEffect(()=>{const u=n,p=l;return()=>{if(p==="chats"&&u){const S=typeof kn.current[u]=="number"?kn.current[u]:te.current?te.current.scrollTop:0;yu(x=>{const _={...x,[u]:S};return window.electronAPI.updateSettings({scrollPositions:_}),_})}}},[n,l]),f.useEffect(()=>{const u=te.current;if(!u)return;const p=()=>{const{scrollTop:S,scrollHeight:x,clientHeight:_}=u,$=x-S-_<=H0;if(n){const z=_u.current[n],V=typeof z=="number"&&Su.removeEventListener("scroll",p)},[n,jr]),f.useEffect(()=>{const u=n;u&&Nu[u]===!1&&Hn(p=>{if(!(u in p))return p;const S={...p};return delete S[u],S})},[n,Nu]),f.useLayoutEffect(()=>{if(l!=="chats"||!n)return;const u=te.current;if(!u)return;Jt.current=null;const p=()=>{if(Jt.current===n)return;const z=typeof kn.current[n]=="number"?kn.current[n]:void 0,V=typeof z=="number"?z:Al[n];if(typeof V=="number"){u.scrollTop=V,Jt.current=n;return}Vn.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,Vn.length,Al]),f.useEffect(()=>{if(l!=="chats"||!n||Jt.current===n)return;const u=typeof kn.current[n]=="number"?kn.current[n]:void 0;typeof(typeof u=="number"?u:Al[n])!="number"&&Vn.length>0&&requestAnimationFrame(()=>{const S=te.current;S&&(S.scrollTop=S.scrollHeight,Jt.current=n)})},[Vn.length,n,l,Al]);const Ii=(u="smooth",p=null)=>{const S=te.current;if(!S)return;const x=p??De.current;De.current===x&&(S.scrollTo({top:S.scrollHeight,behavior:u}),jr(x,!1))},Kn=(u,p="auto",S=null)=>{const x=te.current;if(!x)return;const _=S??De.current;if(De.current!==_)return;const $=document.getElementById(u);if($){const z=Math.max(0,$.offsetTop-B0);x.scrollTo({top:z,behavior:p})}},bh=()=>{const u=De.current,p=ju[u];p&&(Kn(p,"smooth",u),Hn(S=>{const{[u]:x,..._}=S;return _}))},Bh=u=>{l!=="chats"||!ao(u)||(u.preventDefault(),Ae.current+=1,ue&&wd(u)&&q(!0))},Hh=u=>{l!=="chats"||!ao(u)||(u.preventDefault(),u.dataTransfer.dropEffect=ue?"copy":"none",ue&&wd(u)&&!W&&q(!0))},Wh=u=>{l!=="chats"||!ao(u)||(Ae.current=Math.max(0,Ae.current-1),Ae.current===0&&q(!1))},Vh=async u=>{var p,S;l!=="chats"||!ao(u)||(u.preventDefault(),Ae.current=0,q(!1),ue&&(await Eu((p=u.dataTransfer)==null?void 0:p.files),(S=ke.current)==null||S.focus()))};async function Ou(){var z,V,Z;const u=b.trim();if(vt||!u&&P.length===0||!he)return;if(P.length>0&&!ue){window.alert("The selected model does not support image inputs.");return}let p=n,S=!1;if(p){const ie=e.find(ne=>ne.session_id===p);S=ie&&ie.name==="New Chat"&&ie.messages.length===0}else{const ie=await Fu();await new Promise(ne=>setTimeout(ne,200)),p=ie.session_id,S=!0}const x=P.map(({id:ie,...ne})=>({...ne})),_={role:"user",content:u,attachments:x,id:`msg-${Date.now()}-${Math.random()}`};Th.current=!0,Ph.current=p,jr(p,!1),De.current===p&&(Jt.current=De.current),Mp.flushSync(()=>{t(ie=>ie.map(ne=>ne.session_id===p?{...ne,messages:[...ne.messages||[],_]}:ne)),X(""),B([])}),requestAnimationFrame(()=>Ii("auto",p));const $=Tu(p);try{let ie=[];if(_.content)try{ie=[...(((z=e.find(ce=>ce.session_id===p))==null?void 0:z.messages)||[]).slice(-8).map(ce=>({role:ce.role,content:ce.content||""})),{role:"user",content:_.content}]}catch{}let ne=_.content||null,me=[];const Oe=[],En=Mu(p);if(_.content&&((V=En==null?void 0:En.states)!=null&&V.is_indexed))try{const G=await ku(En.slug,_.content,$.signal);G.contextBlock&&Oe.push(G.contextBlock),Array.isArray(G.sources)&&me.push(...G.sources)}catch(G){if(jt(G))throw G;console.warn("local library enrichment failed",G)}if(_.content&&Ml)try{const J=await(await fetch(`${Q}/websearch`,{method:"POST",headers:{"Content-Type":"application/json"},signal:$.signal,body:JSON.stringify({prompt:_.content,model:he,messages:ie,history_limit:8,searx_url:Nr||null,engines:Array.isArray(wn)?wn:null})})).json();J&&typeof J.context_block=="string"&&J.context_block.trim()&&Oe.push(J.context_block.trim()),Array.isArray(J==null?void 0:J.sources)&&me.push(...J.sources)}catch(G){if(jt(G))throw G;console.warn("web search enrichment failed",G)}if(me=[...new Set(me)],_.content&&Oe.length>0&&(ne=`${_.content} - -${Oe.join(` - -`)}`),$l){const G=`msg-${Date.now()}-${Math.random()}`;let J="";const ce={role:"assistant",content:"",id:G,sources:me};t(je=>je.map(K=>K.session_id===p?{...K,messages:[...K.messages||[],ce]}:K));try{const je=await fetch(`${Q}/chat`,{method:"POST",headers:{"Content-Type":"application/json"},signal:$.signal,body:JSON.stringify({session_id:p,model:he,message:_.content,enriched_message:_.content&&Oe.length>0?ne:null,stream:!0,sources:me||[],attachments:x})});if(!je.ok)throw new Error(`HTTP ${je.status}`);const K=(Z=je.body)==null?void 0:Z.getReader();if(!K)throw new Error("Missing response body");const nt=new TextDecoder;let se=!1;for(;;){const{value:Ce,done:Xt}=await K.read();if(Xt){Sn(p,G,J),De.current===p?Bn.current[p]?Hn(We=>({...We,[p]:G})):requestAnimationFrame(()=>Kn(G,"smooth",p)):(xn(We=>({...We,[p]:G})),bn(We=>[...new Set([...We,p])]));break}const Bl=nt.decode(Ce,{stream:!0});J+=Bl,Sn(p,G,J),De.current===p&&!Bn.current[p]&&Ii("auto",p),De.current!==p&&!se&&(xn(We=>({...We,[p]:G})),se=!0)}}catch(je){if(jt(je)){Sn(p,G,J,{removeIfEmpty:!0});return}console.error("Failed to send message:",je),Sn(p,G,"Error: "+Yt(je),{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:he,message:_.content,enriched_message:_.content&&Oe.length>0?ne:null,stream:!1,sources:me||[],attachments:x})});if(!G.ok)throw new Error(`HTTP ${G.status}`);const J=await G.json(),ce=`msg-${Date.now()}`,je={role:"assistant",content:J.reply,id:ce,sources:me};t(K=>K.map(nt=>nt.session_id===p?{...nt,messages:[...nt.messages||[],je]}:nt)),ce&&(De.current===p?Bn.current[p]?Hn(K=>({...K,[p]:ce})):requestAnimationFrame(()=>Kn(ce,"smooth",p)):xn(K=>({...K,[p]:ce})))}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:he})}).then(G=>G.json()).then(G=>{const J=F0(G.title);t(ce=>ce.map(je=>je.session_id===p?{...je,name:J}:je))})}catch(ie){if(jt(ie)){ji($);return}console.error("Failed to send message:",ie);const ne={role:"assistant",content:"Error: "+Yt(ie),id:`msg-${Date.now()}-${Math.random()}`};t(me=>me.map(Oe=>Oe.session_id===p?{...Oe,messages:[...Oe.messages,ne]}:Oe))}finally{ji($)}}function Kh(){ch(u=>!u)}async function Fu(){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),(_=ke.current)==null||_.focus(),S}function Qh(u){r(u),bn(S=>S.filter(x=>x!==u));const p=jh[u];p&&requestAnimationFrame(()=>{let S=12;const x=()=>{if(!te.current)return;let $=document.getElementById(p);if(!$){const z=e.find(V=>V.session_id===u);if(z&&Array.isArray(z.messages))for(let V=z.messages.length-1;V>=0;V--){const Z=z.messages[V];if(Z.role==="assistant"&&Z.id){$=document.getElementById(Z.id);break}}}$?(Kn($.id,"smooth",u),xn(z=>{const{[u]:V,...Z}=z;return Z})):S-- >0&&requestAnimationFrame(x)};requestAnimationFrame(x)})}function Gh(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)),c(null)})}function Yh(u,p){const S=(p||"").trim(),x=w.find(_=>_.slug===u);if(!x){y(null);return}if(!S||S===x.name){y(null);return}fetch(`${Q}/libraries/${u}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:S})}).then(()=>{k(_=>_.map($=>$.slug===u?{...$,name:S}:$)),y(null)})}function zu(u){fetch(`${Q}/sessions/${u}`,{method:"DELETE"}).then(()=>{const p=e.filter(S=>S.session_id!==u);t(p),m(S=>{const x={...S||{}};return delete x[u],x}),n===u&&r(p.length>0?p[0].session_id:null)})}function Jh(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=w.filter(_=>_.slug!==u);k(S),N(_=>_.filter($=>$.slug!==u)),y(_=>_===u?null:_),j===u&&v(((x=S[0])==null?void 0:x.slug)||null),Uh(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=>{zu(p.session_id)})},[n,e,Q]);const Xh=u=>{var S;window.getSelection().toString().length>0||document.activeElement!==ke.current&&(u.target.closest(".msg")||(S=ke.current)==null||S.focus())};return d.jsxs("div",{className:"app",style:{gridTemplateColumns:`${$h}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:()=>Ti("chats"),children:"Chats"}),d.jsx("div",{className:`sidebar-tab ${l==="dbs"?"active":""}`,onClick:()=>Ti("dbs"),children:"DBs"}),d.jsx("div",{className:`sidebar-tab ${l==="settings"?"active":""}`,onClick:()=>Ti("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:()=>Fh(u.session_id),children:a===u.session_id?d.jsx("input",{type:"text",className:"rename-input",defaultValue:u.name,onBlur:()=>c(null),onKeyDown:p=>{p.key==="Enter"?Gh(u.session_id,p.target.value):p.key==="Escape"&&c(null)},autoFocus:!0}):d.jsxs(d.Fragment,{children:[d.jsx("span",{children:u.name}),d.jsxs("div",{className:"chat-item-buttons",children:[dh.includes(u.session_id)&&d.jsx("div",{className:"unread-dot"}),d.jsx("button",{className:"icon-button",onClick:p=>{p.stopPropagation(),c(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(),zu(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:w.length===0?d.jsx("div",{className:"empty-list-message",children:"No databases yet."}):w.map(u=>d.jsx("div",{className:`chat-item ${u.slug===j?"active":""}`,onClick:()=>v(u.slug),children:g===u.slug?d.jsx("input",{type:"text",className:"rename-input",defaultValue:u.name,onBlur:()=>y(null),onKeyDown:p=>{p.key==="Enter"?Yh(u.slug,p.target.value):p.key==="Escape"&&y(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"}),Au(u.slug)&&d.jsx("div",{className:"db-active-badge",children:"Syncing"}),d.jsx("button",{className:"icon-button",onClick:p=>{p.stopPropagation(),y(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(),Jh(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 ${i==="General"?"active":""}`,onClick:()=>s("General"),children:"General"}),d.jsx("div",{className:`settings-item ${i==="Interface"?"active":""}`,onClick:()=>s("Interface"),children:"Interface"}),d.jsx("div",{className:`settings-item ${i==="Websearch"?"active":""}`,onClick:()=>s("Websearch"),children:"Websearch"})]})]}),l!=="settings"&&d.jsxs("div",{className:"sidebar-footer",children:[l==="chats"&&d.jsx("button",{className:"button new-chat-button",onClick:Fu,children:"New Chat"}),l==="dbs"&&(C?d.jsxs("div",{className:"new-db-form",children:[d.jsx("input",{type:"text",className:"rename-input",value:I,onChange:u=>M(u.target.value),onKeyDown:u=>{u.key==="Enter"?Iu():u.key==="Escape"&&(L(!1),M(""),H(""))},placeholder:"Database name",autoFocus:!0}),A&&d.jsx("div",{className:"form-error",children:A}),d.jsxs("div",{className:"new-db-actions",children:[d.jsx("button",{className:"button new-db-button",onClick:()=>Iu(),children:"Create"}),d.jsx("button",{className:"button ghost",onClick:()=>{L(!1),M(""),H("")},children:"Cancel"})]})]}):d.jsx("button",{className:"button new-db-button",onClick:()=>{L(!0),H("")},children:"New Database"}))]}),d.jsx("div",{className:"resizer",onMouseDown:Ah})]}),d.jsxs("div",{className:`main-content${l==="chats"&&W?" main-content--drag-active":""}`,onDragEnter:Bh,onDragOver:Hh,onDragLeave:Wh,onDrop:Vh,children:[gu&&d.jsxs("div",{className:"startup-task-banner",role:"status","aria-live":"polite",children:[sh&&d.jsx("div",{className:"spinner startup-task-banner__spinner"}),d.jsx("div",{className:"startup-task-banner__text",children:gu})]}),l==="chats"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"header",children:[d.jsxs("strong",{children:["Chat - ",((Uu=e.find(u=>u.session_id===n))==null?void 0:Uu.name)||"New Chat"]}),yt&&d.jsx("span",{className:"header-subtle",children:`DB: ${yt.name}${Pi}`})]}),d.jsx("div",{className:`chat${W?" chat--drag-active":""}`,ref:te,onClick:Xh,children:Vn.map((u,p)=>{const S=u.role==="user"&&ph===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(z0,{content:u.content,streamOutput:$l,sources:u.sources}),!vt&&d.jsxs("div",{className:"message-options-bar assistant-options",children:[d.jsx("button",{className:"icon-button",title:"Copy message",onClick:()=>xu(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:()=>Cu(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(ds,{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:Ci}),d.jsx(id,{className:"edit-message-input edit-overlay",value:Ci,onChange:x=>Dl(x.target.value),onBlur:Fl,onKeyDown:x=>{x.key==="Escape"&&(x.preventDefault(),Fl()),x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),Nh(p))},autoFocus:!0,minRows:1})]})]}):(()=>{const x=u.content||"",_=Array.isArray(u.attachments)?u.attachments:[],$=x.split(/\r\n|\r|\n/),z=$.length>30,V=Ru(u,p,n),Z=z?Lh[V]??!0:!1,ie=Z?$.slice(0,30).join(` -`)+` -…`:x,ne=!!x.trim();return d.jsxs(d.Fragment,{children:[d.jsx(ds,{attachments:_,className:"message-attachment-strip"}),ne&&d.jsx("div",{className:"msg-content msg-content--user",children:ie}),ne&&z&&d.jsx("button",{className:"user-msg-expand",onClick:()=>Rh(V),"aria-expanded":Z?"false":"true",children:Z?"Show entire message":"Collapse"})]})})(),!vt&&!S&&d.jsxs("div",{className:"message-options-bar user-options",children:[d.jsx("button",{className:"icon-button",title:"Edit message",onClick:()=>Ch(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:()=>xu(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),ju[n]&&d.jsxs("button",{className:"new-msg-tip",onClick:bh,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${W?" footer-inner--drag-active":""}`,children:[d.jsx("input",{ref:Gt,type:"file",accept:"image/*",multiple:!0,className:"composer-image-input",onChange:Eh,tabIndex:-1}),d.jsx(ds,{attachments:P,className:"composer-attachment-strip",removable:!0,onRemove:yh}),(_e||He)&&d.jsxs("div",{className:"composer-audio-status"+(_e?" composer-audio-status--recording":" composer-audio-status--transcribing"),role:"status","aria-live":"polite",children:[_e?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:_e?`Listening ${Q0(yi)}`:"Transcribing audio…"})]}),d.jsxs("div",{className:"footer-content-wrapper",children:[d.jsx(id,{ref:ke,className:"input",value:b,onChange:u=>X(u.target.value),onKeyDown:u=>{u.key==="Enter"&&!u.shiftKey&&!_e&&!He&&(u.preventDefault(),Ou())},placeholder:"Ask any question...",maxRows:13}),d.jsxs("div",{className:"footer-tool-group",ref:ut,children:[d.jsx("button",{type:"button",className:"db-picker-toggle"+(yt?" active":""),onClick:()=>{n&&le(u=>!u)},title:yt?`Database: ${yt.name}${Pi}`:"Select database for this chat","aria-haspopup":"menu","aria-expanded":U,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"})]})}),U&&d.jsxs("div",{className:"db-picker-menu",role:"menu",children:[d.jsxs("button",{type:"button",className:"db-picker-option"+(Mt?"":" selected"),onClick:()=>{Du(n,null),le(!1)},children:[d.jsx("span",{children:"No database"}),!Mt&&d.jsx("span",{className:"db-picker-status",children:"Selected"})]}),w.length===0?d.jsx("div",{className:"db-picker-empty",children:"No databases yet."}):w.map(u=>{var _,$,z;const p=Mt===u.slug,S=Au(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:()=>{Du(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)})]})]}),ue&&d.jsx("button",{type:"button",className:"image-attach-toggle"+(P.length>0?" active":""),onClick:wh,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"})]})}),gt&&d.jsx("button",{type:"button",className:"audio-input-toggle"+(_e||He?" active":"")+(_e?" recording":"")+(He?" transcribing":""),onClick:kh,title:_e?"Stop voice input":He?"Transcribing audio":"Start voice input","aria-label":_e?"Stop voice input":He?"Transcribing audio":"Start voice input","aria-pressed":_e,disabled:He||vt,children:He?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"+(Ml?" active":""),onClick:Kh,title:"Toggle web search","aria-pressed":Ml,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:vt?Ih:Ou,title:vt?"Cancel generation":"Send","aria-label":vt?"Cancel generation":"Send",disabled:!vt&&(_e||He),children:vt?d.jsx("div",{className:"spinner"}):"Send"})]})]})})]}),l==="dbs"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"header",children:[d.jsx("strong",{children:(bl==null?void 0:bl.name)||"Databases"}),yt&&d.jsx("span",{className:"header-subtle",children:`Current chat DB: ${yt.name}${Pi}`})]}),d.jsx(I0,{apiBase:Q,library:bl,jobs:E,onRefresh:async()=>{await Lr(),await Ul()}})]}),l==="settings"&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"header",children:d.jsxs("strong",{children:[i," Settings"]})}),i==="General"&&d.jsx(N0,{onModelChange:Be,onBackendApiUrlChange:pu,streamOutput:$l,onStreamOutputChange:mu,onAudioInputEnabledChange:Nl,onAudioInputDeviceChange:jl,onAudioInputLanguageChange:Ll,onLibrariesPurged:Oh}),i==="Interface"&&d.jsx(T0,{}),i==="Websearch"&&d.jsx(D0,{searxUrl:Nr,setSearxUrl:ah,engines:wn,setEngines:u=>uh(Jo(u))})]})]})]})}function Y0(){return f.useEffect(()=>{window.electronAPI.getSettings().then(e=>{gl(e.colorScheme||"Default")})},[]),d.jsx(Ke.StrictMode,{children:d.jsx(zy,{children:d.jsx(gy,{children:d.jsx(Qp,{path:"/",element:d.jsx(G0,{})})})})})}const J0=Ap(document.getElementById("root"));J0.render(d.jsx(Y0,{})); diff --git a/dist/index.html b/dist/index.html index 09436a4..3302441 100644 --- a/dist/index.html +++ b/dist/index.html @@ -5,7 +5,7 @@ LLM Desktop - + diff --git a/src/App.jsx b/src/App.jsx index 92e2f44..0ff79b5 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -638,7 +638,7 @@ export default function App() { } async function startAudioRecording() { - if (!audioInputEnabled || isRecordingAudio || isTranscribingAudio || isSending) { + if (!audioInputEnabled || !audioInputRuntimeReady || isRecordingAudio || isTranscribingAudio || isSending) { return } if (!supportsAudioInputCapture()) { @@ -1229,6 +1229,13 @@ async function regenerateFromIndex(index, overrideUserText = null) { stopAudioRecording({ shouldTranscribe: false }) }, [audioInputEnabled, isRecordingAudio]) + useEffect(() => { + if (audioInputRuntimeReady || !isRecordingAudio) { + return + } + stopAudioRecording({ shouldTranscribe: false }) + }, [audioInputRuntimeReady, isRecordingAudio]) + useEffect(() => { if (activeSidebarMode === 'chats' || !isRecordingAudio) { return @@ -1265,6 +1272,7 @@ async function regenerateFromIndex(index, overrideUserText = null) { try { let status = await fetchStartupOllamaStatus() if (cancelled) return + syncAudioInputRuntimeFromStartupStatus(status) if (!status?.ollama_running && status?.can_manage_locally) { const confirmed = window.confirm( @@ -1296,12 +1304,15 @@ async function regenerateFromIndex(index, overrideUserText = null) { } else { setStartupTaskMessage(`Downloading ${status.selected_embed_model} from Ollama. This can take a while on first install.`) } - await prepareStartupModels() + const prepared = await prepareStartupModels() if (cancelled) return + syncAudioInputRuntimeFromStartupStatus(prepared?.ollama || status) } } catch (error) { if (!cancelled) { console.warn('startup Ollama check failed', error) + setAudioInputRuntimeReady(false) + setAudioInputRuntimeMessage(`Whisper availability could not be verified: ${getErrorText(error)}`) if (actionStarted) { window.alert(`Startup action failed: ${getErrorText(error)}`) } @@ -2718,17 +2729,21 @@ async function createNewChat() { } onClick={toggleAudioRecording} title={ - isRecordingAudio + !audioInputRuntimeReady + ? (audioInputRuntimeMessage || 'Whisper is not available for audio input.') + : isRecordingAudio ? 'Stop voice input' : (isTranscribingAudio ? 'Transcribing audio' : 'Start voice input') } aria-label={ - isRecordingAudio + !audioInputRuntimeReady + ? (audioInputRuntimeMessage || 'Whisper is not available for audio input.') + : isRecordingAudio ? 'Stop voice input' : (isTranscribingAudio ? 'Transcribing audio' : 'Start voice input') } aria-pressed={isRecordingAudio} - disabled={isTranscribingAudio || isSending} + disabled={!audioInputRuntimeReady || isTranscribingAudio || isSending} > {isTranscribingAudio ? (