var J0=Object.defineProperty;var $0=(r,c,f)=>c in r?J0(r,c,{enumerable:!0,configurable:!0,writable:!0,value:f}):r[c]=f;var Nt=(r,c,f)=>$0(r,typeof c!="symbol"?c+"":c,f);(function(){const c=document.createElement("link").relList;if(c&&c.supports&&c.supports("modulepreload"))return;for(const h of document.querySelectorAll('link[rel="modulepreload"]'))s(h);new MutationObserver(h=>{for(const v of h)if(v.type==="childList")for(const A of v.addedNodes)A.tagName==="LINK"&&A.rel==="modulepreload"&&s(A)}).observe(document,{childList:!0,subtree:!0});function f(h){const v={};return h.integrity&&(v.integrity=h.integrity),h.referrerPolicy&&(v.referrerPolicy=h.referrerPolicy),h.crossOrigin==="use-credentials"?v.credentials="include":h.crossOrigin==="anonymous"?v.credentials="omit":v.credentials="same-origin",v}function s(h){if(h.ep)return;h.ep=!0;const v=f(h);fetch(h.href,v)}})();var Gs={exports:{}},$n={};/** * @license React * react-jsx-runtime.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var id;function W0(){if(id)return $n;id=1;var r=Symbol.for("react.transitional.element"),c=Symbol.for("react.fragment");function f(s,h,v){var A=null;if(v!==void 0&&(A=""+v),h.key!==void 0&&(A=""+h.key),"key"in h){v={};for(var j in h)j!=="key"&&(v[j]=h[j])}else v=h;return h=v.ref,{$$typeof:r,type:s,key:A,ref:h!==void 0?h:null,props:v}}return $n.Fragment=c,$n.jsx=f,$n.jsxs=f,$n}var cd;function F0(){return cd||(cd=1,Gs.exports=W0()),Gs.exports}var m=F0(),Xs={exports:{}},P={};/** * @license React * react.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var sd;function I0(){if(sd)return P;sd=1;var r=Symbol.for("react.transitional.element"),c=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),h=Symbol.for("react.profiler"),v=Symbol.for("react.consumer"),A=Symbol.for("react.context"),j=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),b=Symbol.for("react.memo"),E=Symbol.for("react.lazy"),C=Symbol.for("react.activity"),H=Symbol.iterator;function J(y){return y===null||typeof y!="object"?null:(y=H&&y[H]||y["@@iterator"],typeof y=="function"?y:null)}var U={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},F=Object.assign,nt={};function Yt(y,M,B){this.props=y,this.context=M,this.refs=nt,this.updater=B||U}Yt.prototype.isReactComponent={},Yt.prototype.setState=function(y,M){if(typeof y!="object"&&typeof y!="function"&&y!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,y,M,"setState")},Yt.prototype.forceUpdate=function(y){this.updater.enqueueForceUpdate(this,y,"forceUpdate")};function Qt(){}Qt.prototype=Yt.prototype;function Ct(y,M,B){this.props=y,this.context=M,this.refs=nt,this.updater=B||U}var ft=Ct.prototype=new Qt;ft.constructor=Ct,F(ft,Yt.prototype),ft.isPureReactComponent=!0;var Vt=Array.isArray;function jt(){}var $={H:null,A:null,T:null,S:null},le=Object.prototype.hasOwnProperty;function Ae(y,M,B){var Q=B.ref;return{$$typeof:r,type:y,key:M,ref:Q!==void 0?Q:null,props:B}}function vl(y,M){return Ae(y.type,M,y.props)}function Ne(y){return typeof y=="object"&&y!==null&&y.$$typeof===r}function Wt(y){var M={"=":"=0",":":"=2"};return"$"+y.replace(/[=:]/g,function(B){return M[B]})}var Ie=/\/+/g;function je(y,M){return typeof y=="object"&&y!==null&&y.key!=null?Wt(""+y.key):M.toString(36)}function ve(y){switch(y.status){case"fulfilled":return y.value;case"rejected":throw y.reason;default:switch(typeof y.status=="string"?y.then(jt,jt):(y.status="pending",y.then(function(M){y.status==="pending"&&(y.status="fulfilled",y.value=M)},function(M){y.status==="pending"&&(y.status="rejected",y.reason=M)})),y.status){case"fulfilled":return y.value;case"rejected":throw y.reason}}throw y}function D(y,M,B,Q,W){var I=typeof y;(I==="undefined"||I==="boolean")&&(y=null);var dt=!1;if(y===null)dt=!0;else switch(I){case"bigint":case"string":case"number":dt=!0;break;case"object":switch(y.$$typeof){case r:case c:dt=!0;break;case E:return dt=y._init,D(dt(y._payload),M,B,Q,W)}}if(dt)return W=W(y),dt=Q===""?"."+je(y,0):Q,Vt(W)?(B="",dt!=null&&(B=dt.replace(Ie,"$&/")+"/"),D(W,M,B,"",function(Pe){return Pe})):W!=null&&(Ne(W)&&(W=vl(W,B+(W.key==null||y&&y.key===W.key?"":(""+W.key).replace(Ie,"$&/")+"/")+dt)),M.push(W)),1;dt=0;var Kt=Q===""?".":Q+":";if(Vt(y))for(var kt=0;kt>>1,St=D[ot];if(0>>1;oth(B,K))Qh(W,B)?(D[ot]=W,D[Q]=K,ot=Q):(D[ot]=B,D[M]=K,ot=M);else if(Qh(W,K))D[ot]=W,D[Q]=K,ot=Q;else break t}}return q}function h(D,q){var K=D.sortIndex-q.sortIndex;return K!==0?K:D.id-q.id}if(r.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var v=performance;r.unstable_now=function(){return v.now()}}else{var A=Date,j=A.now();r.unstable_now=function(){return A.now()-j}}var g=[],b=[],E=1,C=null,H=3,J=!1,U=!1,F=!1,nt=!1,Yt=typeof setTimeout=="function"?setTimeout:null,Qt=typeof clearTimeout=="function"?clearTimeout:null,Ct=typeof setImmediate<"u"?setImmediate:null;function ft(D){for(var q=f(b);q!==null;){if(q.callback===null)s(b);else if(q.startTime<=D)s(b),q.sortIndex=q.expirationTime,c(g,q);else break;q=f(b)}}function Vt(D){if(F=!1,ft(D),!U)if(f(g)!==null)U=!0,jt||(jt=!0,Wt());else{var q=f(b);q!==null&&ve(Vt,q.startTime-D)}}var jt=!1,$=-1,le=5,Ae=-1;function vl(){return nt?!0:!(r.unstable_now()-AeD&&vl());){var ot=C.callback;if(typeof ot=="function"){C.callback=null,H=C.priorityLevel;var St=ot(C.expirationTime<=D);if(D=r.unstable_now(),typeof St=="function"){C.callback=St,ft(D),q=!0;break e}C===f(g)&&s(g),ft(D)}else s(g);C=f(g)}if(C!==null)q=!0;else{var y=f(b);y!==null&&ve(Vt,y.startTime-D),q=!1}}break t}finally{C=null,H=K,J=!1}q=void 0}}finally{q?Wt():jt=!1}}}var Wt;if(typeof Ct=="function")Wt=function(){Ct(Ne)};else if(typeof MessageChannel<"u"){var Ie=new MessageChannel,je=Ie.port2;Ie.port1.onmessage=Ne,Wt=function(){je.postMessage(null)}}else Wt=function(){Yt(Ne,0)};function ve(D,q){$=Yt(function(){D(r.unstable_now())},q)}r.unstable_IdlePriority=5,r.unstable_ImmediatePriority=1,r.unstable_LowPriority=4,r.unstable_NormalPriority=3,r.unstable_Profiling=null,r.unstable_UserBlockingPriority=2,r.unstable_cancelCallback=function(D){D.callback=null},r.unstable_forceFrameRate=function(D){0>D||125ot?(D.sortIndex=K,c(b,D),f(g)===null&&D===f(b)&&(F?(Qt($),$=-1):F=!0,ve(Vt,K-ot))):(D.sortIndex=St,c(g,D),U||J||(U=!0,jt||(jt=!0,Wt()))),D},r.unstable_shouldYield=vl,r.unstable_wrapCallback=function(D){var q=H;return function(){var K=H;H=q;try{return D.apply(this,arguments)}finally{H=K}}}})(Ls)),Ls}var od;function tg(){return od||(od=1,Zs.exports=P0()),Zs.exports}var Vs={exports:{}},ne={};/** * @license React * react-dom.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var hd;function eg(){if(hd)return ne;hd=1;var r=Ws();function c(g){var b="https://react.dev/errors/"+g;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(r)}catch(c){console.error(c)}}return r(),Vs.exports=eg(),Vs.exports}/** * @license React * react-dom-client.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var md;function ag(){if(md)return Wn;md=1;var r=tg(),c=Ws(),f=lg();function s(t){var e="https://react.dev/errors/"+t;if(1St||(t.current=ot[St],ot[St]=null,St--)}function B(t,e){St++,ot[St]=t.current,t.current=e}var Q=y(null),W=y(null),I=y(null),dt=y(null);function Kt(t,e){switch(B(I,e),B(W,t),B(Q,null),e.nodeType){case 9:case 11:t=(t=e.documentElement)&&(t=t.namespaceURI)?Oh(t):0;break;default:if(t=e.tagName,e=e.namespaceURI)e=Oh(e),t=Dh(e,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}M(Q),B(Q,t)}function kt(){M(Q),M(W),M(I)}function Pe(t){t.memoizedState!==null&&B(dt,t);var e=Q.current,l=Dh(e,t.type);e!==l&&(B(W,t),B(Q,l))}function Qe(t){W.current===t&&(M(Q),M(W)),dt.current===t&&(M(dt),Ln._currentValue=K)}var ie,re;function Ve(t){if(ie===void 0)try{throw Error()}catch(l){var e=l.stack.trim().match(/\n( *(at )?)/);ie=e&&e[1]||"",re=-1)":-1n||d[a]!==z[n]){var O=` `+d[a].replace(" at new "," at ");return t.displayName&&O.includes("")&&(O=O.replace("",t.displayName)),O}while(1<=a&&0<=n);break}}}finally{ma=!1,Error.prepareStackTrace=l}return(l=t?t.displayName||t.name:"")?Ve(l):""}function Ai(t,e){switch(t.tag){case 26:case 27:case 5:return Ve(t.type);case 16:return Ve("Lazy");case 13:return t.child!==e&&e!==null?Ve("Suspense Fallback"):Ve("Suspense");case 19:return Ve("SuspenseList");case 0:case 15:return ga(t.type,!1);case 11:return ga(t.type.render,!1);case 1:return ga(t.type,!0);case 31:return Ve("Activity");default:return""}}function Oe(t){try{var e="",l=null;do e+=Ai(t,l),l=t,t=t.return;while(t);return e}catch(a){return` Error generating stack: `+a.message+` `+a.stack}}var Z=Object.prototype.hasOwnProperty,gt=r.unstable_scheduleCallback,pa=r.unstable_cancelCallback,Ni=r.unstable_shouldYield,tu=r.unstable_requestPaint,ce=r.unstable_now,ji=r.unstable_getCurrentPriorityLevel,eu=r.unstable_ImmediatePriority,lu=r.unstable_UserBlockingPriority,Vl=r.unstable_NormalPriority,T=r.unstable_LowPriority,lt=r.unstable_IdlePriority,Y=r.log,tt=r.unstable_setDisableYieldValue,vt=null,mt=null;function ae(t){if(typeof Y=="function"&&tt(t),mt&&typeof mt.setStrictMode=="function")try{mt.setStrictMode(vt,t)}catch{}}var se=Math.clz32?Math.clz32:kd,bl=Math.log,Cd=Math.LN2;function kd(t){return t>>>=0,t===0?32:31-(bl(t)/Cd|0)|0}var au=256,nu=262144,uu=4194304;function Kl(t){var e=t&42;if(e!==0)return e;switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function iu(t,e,l){var a=t.pendingLanes;if(a===0)return 0;var n=0,u=t.suspendedLanes,i=t.pingedLanes;t=t.warmLanes;var o=a&134217727;return o!==0?(a=o&~u,a!==0?n=Kl(a):(i&=o,i!==0?n=Kl(i):l||(l=o&~t,l!==0&&(n=Kl(l))))):(o=a&~u,o!==0?n=Kl(o):i!==0?n=Kl(i):l||(l=a&~t,l!==0&&(n=Kl(l)))),n===0?0:e!==0&&e!==n&&(e&u)===0&&(u=n&-n,l=e&-e,u>=l||u===32&&(l&4194048)!==0)?e:n}function an(t,e){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&e)===0}function Ud(t,e){switch(t){case 1:case 2:case 4:case 8:case 64:return e+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ff(){var t=uu;return uu<<=1,(uu&62914560)===0&&(uu=4194304),t}function Oi(t){for(var e=[],l=0;31>l;l++)e.push(t);return e}function nn(t,e){t.pendingLanes|=e,e!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function Hd(t,e,l,a,n,u){var i=t.pendingLanes;t.pendingLanes=l,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=l,t.entangledLanes&=l,t.errorRecoveryDisabledLanes&=l,t.shellSuspendCounter=0;var o=t.entanglements,d=t.expirationTimes,z=t.hiddenUpdates;for(l=i&~l;0"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var Xd=/[\n"\\]/g;function Me(t){return t.replace(Xd,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})}function Ui(t,e,l,a,n,u,i,o){t.name="",i!=null&&typeof i!="function"&&typeof i!="symbol"&&typeof i!="boolean"?t.type=i:t.removeAttribute("type"),e!=null?i==="number"?(e===0&&t.value===""||t.value!=e)&&(t.value=""+De(e)):t.value!==""+De(e)&&(t.value=""+De(e)):i!=="submit"&&i!=="reset"||t.removeAttribute("value"),e!=null?Hi(t,i,De(e)):l!=null?Hi(t,i,De(l)):a!=null&&t.removeAttribute("value"),n==null&&u!=null&&(t.defaultChecked=!!u),n!=null&&(t.checked=n&&typeof n!="function"&&typeof n!="symbol"),o!=null&&typeof o!="function"&&typeof o!="symbol"&&typeof o!="boolean"?t.name=""+De(o):t.removeAttribute("name")}function zf(t,e,l,a,n,u,i,o){if(u!=null&&typeof u!="function"&&typeof u!="symbol"&&typeof u!="boolean"&&(t.type=u),e!=null||l!=null){if(!(u!=="submit"&&u!=="reset"||e!=null)){ki(t);return}l=l!=null?""+De(l):"",e=e!=null?""+De(e):l,o||e===t.value||(t.value=e),t.defaultValue=e}a=a??n,a=typeof a!="function"&&typeof a!="symbol"&&!!a,t.checked=o?t.checked:!!a,t.defaultChecked=!!a,i!=null&&typeof i!="function"&&typeof i!="symbol"&&typeof i!="boolean"&&(t.name=i),ki(t)}function Hi(t,e,l){e==="number"&&fu(t.ownerDocument)===t||t.defaultValue===""+l||(t.defaultValue=""+l)}function za(t,e,l,a){if(t=t.options,e){e={};for(var n=0;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Gi=!1;if(ll)try{var fn={};Object.defineProperty(fn,"passive",{get:function(){Gi=!0}}),window.addEventListener("test",fn,fn),window.removeEventListener("test",fn,fn)}catch{Gi=!1}var xl=null,Xi=null,ou=null;function Of(){if(ou)return ou;var t,e=Xi,l=e.length,a,n="value"in xl?xl.value:xl.textContent,u=n.length;for(t=0;t=hn),Uf=" ",Hf=!1;function qf(t,e){switch(t){case"keyup":return pm.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Bf(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Aa=!1;function vm(t,e){switch(t){case"compositionend":return Bf(e);case"keypress":return e.which!==32?null:(Hf=!0,Uf);case"textInput":return t=e.data,t===Uf&&Hf?null:t;default:return null}}function bm(t,e){if(Aa)return t==="compositionend"||!Ki&&qf(t,e)?(t=Of(),ou=Xi=xl=null,Aa=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:l,offset:e-t};t=a}t:{for(;l;){if(l.nextSibling){l=l.nextSibling;break t}l=l.parentNode}l=void 0}l=Vf(l)}}function Jf(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?Jf(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function $f(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var e=fu(t.document);e instanceof t.HTMLIFrameElement;){try{var l=typeof e.contentWindow.location.href=="string"}catch{l=!1}if(l)t=e.contentWindow;else break;e=fu(t.document)}return e}function Wi(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}var Nm=ll&&"documentMode"in document&&11>=document.documentMode,Na=null,Fi=null,pn=null,Ii=!1;function Wf(t,e,l){var a=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Ii||Na==null||Na!==fu(a)||(a=Na,"selectionStart"in a&&Wi(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),pn&&gn(pn,a)||(pn=a,a=ni(Fi,"onSelect"),0>=i,n-=i,Ke=1<<32-se(e)+n|l<at?(st=X,X=null):st=X.sibling;var yt=_(S,X,x[at],R);if(yt===null){X===null&&(X=st);break}t&&X&&yt.alternate===null&&e(S,X),p=u(yt,p,at),pt===null?L=yt:pt.sibling=yt,pt=yt,X=st}if(at===x.length)return l(S,X),rt&&nl(S,at),L;if(X===null){for(;atat?(st=X,X=null):st=X.sibling;var wl=_(S,X,yt.value,R);if(wl===null){X===null&&(X=st);break}t&&X&&wl.alternate===null&&e(S,X),p=u(wl,p,at),pt===null?L=wl:pt.sibling=wl,pt=wl,X=st}if(yt.done)return l(S,X),rt&&nl(S,at),L;if(X===null){for(;!yt.done;at++,yt=x.next())yt=k(S,yt.value,R),yt!==null&&(p=u(yt,p,at),pt===null?L=yt:pt.sibling=yt,pt=yt);return rt&&nl(S,at),L}for(X=a(X);!yt.done;at++,yt=x.next())yt=N(X,S,at,yt.value,R),yt!==null&&(t&&yt.alternate!==null&&X.delete(yt.key===null?at:yt.key),p=u(yt,p,at),pt===null?L=yt:pt.sibling=yt,pt=yt);return t&&X.forEach(function(K0){return e(S,K0)}),rt&&nl(S,at),L}function At(S,p,x,R){if(typeof x=="object"&&x!==null&&x.type===F&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case J:t:{for(var L=x.key;p!==null;){if(p.key===L){if(L=x.type,L===F){if(p.tag===7){l(S,p.sibling),R=n(p,x.props.children),R.return=S,S=R;break t}}else if(p.elementType===L||typeof L=="object"&&L!==null&&L.$$typeof===le&&na(L)===p.type){l(S,p.sibling),R=n(p,x.props),zn(R,x),R.return=S,S=R;break t}l(S,p);break}else e(S,p);p=p.sibling}x.type===F?(R=Pl(x.props.children,S.mode,R,x.key),R.return=S,S=R):(R=xu(x.type,x.key,x.props,null,S.mode,R),zn(R,x),R.return=S,S=R)}return i(S);case U:t:{for(L=x.key;p!==null;){if(p.key===L)if(p.tag===4&&p.stateNode.containerInfo===x.containerInfo&&p.stateNode.implementation===x.implementation){l(S,p.sibling),R=n(p,x.children||[]),R.return=S,S=R;break t}else{l(S,p);break}else e(S,p);p=p.sibling}R=uc(x,S.mode,R),R.return=S,S=R}return i(S);case le:return x=na(x),At(S,p,x,R)}if(ve(x))return G(S,p,x,R);if(Wt(x)){if(L=Wt(x),typeof L!="function")throw Error(s(150));return x=L.call(x),V(S,p,x,R)}if(typeof x.then=="function")return At(S,p,ju(x),R);if(x.$$typeof===Ct)return At(S,p,_u(S,x),R);Ou(S,x)}return typeof x=="string"&&x!==""||typeof x=="number"||typeof x=="bigint"?(x=""+x,p!==null&&p.tag===6?(l(S,p.sibling),R=n(p,x),R.return=S,S=R):(l(S,p),R=nc(x,S.mode,R),R.return=S,S=R),i(S)):l(S,p)}return function(S,p,x,R){try{xn=0;var L=At(S,p,x,R);return Ba=null,L}catch(X){if(X===qa||X===Au)throw X;var pt=Se(29,X,null,S.mode);return pt.lanes=R,pt.return=S,pt}finally{}}}var ia=br(!0),Sr=br(!1),Al=!1;function yc(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function vc(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function Nl(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function jl(t,e,l){var a=t.updateQueue;if(a===null)return null;if(a=a.shared,(bt&2)!==0){var n=a.pending;return n===null?e.next=e:(e.next=n.next,n.next=e),a.pending=e,e=Su(t),ar(t,null,l),e}return bu(t,a,e,l),Su(t)}function Tn(t,e,l){if(e=e.updateQueue,e!==null&&(e=e.shared,(l&4194048)!==0)){var a=e.lanes;a&=t.pendingLanes,l|=a,e.lanes=l,of(t,l)}}function bc(t,e){var l=t.updateQueue,a=t.alternate;if(a!==null&&(a=a.updateQueue,l===a)){var n=null,u=null;if(l=l.firstBaseUpdate,l!==null){do{var i={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};u===null?n=u=i:u=u.next=i,l=l.next}while(l!==null);u===null?n=u=e:u=u.next=e}else n=u=e;l={baseState:a.baseState,firstBaseUpdate:n,lastBaseUpdate:u,shared:a.shared,callbacks:a.callbacks},t.updateQueue=l;return}t=l.lastBaseUpdate,t===null?l.firstBaseUpdate=e:t.next=e,l.lastBaseUpdate=e}var Sc=!1;function _n(){if(Sc){var t=Ha;if(t!==null)throw t}}function En(t,e,l,a){Sc=!1;var n=t.updateQueue;Al=!1;var u=n.firstBaseUpdate,i=n.lastBaseUpdate,o=n.shared.pending;if(o!==null){n.shared.pending=null;var d=o,z=d.next;d.next=null,i===null?u=z:i.next=z,i=d;var O=t.alternate;O!==null&&(O=O.updateQueue,o=O.lastBaseUpdate,o!==i&&(o===null?O.firstBaseUpdate=z:o.next=z,O.lastBaseUpdate=d))}if(u!==null){var k=n.baseState;i=0,O=z=d=null,o=u;do{var _=o.lane&-536870913,N=_!==o.lane;if(N?(ct&_)===_:(a&_)===_){_!==0&&_===Ua&&(Sc=!0),O!==null&&(O=O.next={lane:0,tag:o.tag,payload:o.payload,callback:null,next:null});t:{var G=t,V=o;_=e;var At=l;switch(V.tag){case 1:if(G=V.payload,typeof G=="function"){k=G.call(At,k,_);break t}k=G;break t;case 3:G.flags=G.flags&-65537|128;case 0:if(G=V.payload,_=typeof G=="function"?G.call(At,k,_):G,_==null)break t;k=C({},k,_);break t;case 2:Al=!0}}_=o.callback,_!==null&&(t.flags|=64,N&&(t.flags|=8192),N=n.callbacks,N===null?n.callbacks=[_]:N.push(_))}else N={lane:_,tag:o.tag,payload:o.payload,callback:o.callback,next:null},O===null?(z=O=N,d=k):O=O.next=N,i|=_;if(o=o.next,o===null){if(o=n.shared.pending,o===null)break;N=o,o=N.next,N.next=null,n.lastBaseUpdate=N,n.shared.pending=null}}while(!0);O===null&&(d=k),n.baseState=d,n.firstBaseUpdate=z,n.lastBaseUpdate=O,u===null&&(n.shared.lanes=0),Cl|=i,t.lanes=i,t.memoizedState=k}}function xr(t,e){if(typeof t!="function")throw Error(s(191,t));t.call(e)}function zr(t,e){var l=t.callbacks;if(l!==null)for(t.callbacks=null,t=0;tu?u:8;var i=D.T,o={};D.T=o,Yc(t,!1,e,l);try{var d=n(),z=D.S;if(z!==null&&z(o,d),d!==null&&typeof d=="object"&&typeof d.then=="function"){var O=Hm(d,a);jn(t,e,O,Ee(t))}else jn(t,e,a,Ee(t))}catch(k){jn(t,e,{then:function(){},status:"rejected",reason:k},Ee())}finally{q.p=u,i!==null&&o.types!==null&&(i.types=o.types),D.T=i}}function Xm(){}function qc(t,e,l,a){if(t.tag!==5)throw Error(s(476));var n=to(t).queue;Pr(t,n,e,K,l===null?Xm:function(){return eo(t),l(a)})}function to(t){var e=t.memoizedState;if(e!==null)return e;e={memoizedState:K,baseState:K,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:sl,lastRenderedState:K},next:null};var l={};return e.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:sl,lastRenderedState:l},next:null},t.memoizedState=e,t=t.alternate,t!==null&&(t.memoizedState=e),e}function eo(t){var e=to(t);e.next===null&&(e=t.alternate.memoizedState),jn(t,e.next.queue,{},Ee())}function Bc(){return Pt(Ln)}function lo(){return Bt().memoizedState}function ao(){return Bt().memoizedState}function wm(t){for(var e=t.return;e!==null;){switch(e.tag){case 24:case 3:var l=Ee();t=Nl(l);var a=jl(e,t,l);a!==null&&(ye(a,e,l),Tn(a,e,l)),e={cache:dc()},t.payload=e;return}e=e.return}}function Zm(t,e,l){var a=Ee();l={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Yu(t)?uo(e,l):(l=lc(t,e,l,a),l!==null&&(ye(l,t,a),io(l,e,a)))}function no(t,e,l){var a=Ee();jn(t,e,l,a)}function jn(t,e,l,a){var n={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Yu(t))uo(e,n);else{var u=t.alternate;if(t.lanes===0&&(u===null||u.lanes===0)&&(u=e.lastRenderedReducer,u!==null))try{var i=e.lastRenderedState,o=u(i,l);if(n.hasEagerState=!0,n.eagerState=o,be(o,i))return bu(t,e,n,0),Ot===null&&vu(),!1}catch{}finally{}if(l=lc(t,e,n,a),l!==null)return ye(l,t,a),io(l,e,a),!0}return!1}function Yc(t,e,l,a){if(a={lane:2,revertLane:ys(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Yu(t)){if(e)throw Error(s(479))}else e=lc(t,l,a,2),e!==null&&ye(e,t,2)}function Yu(t){var e=t.alternate;return t===et||e!==null&&e===et}function uo(t,e){Qa=Ru=!0;var l=t.pending;l===null?e.next=e:(e.next=l.next,l.next=e),t.pending=e}function io(t,e,l){if((l&4194048)!==0){var a=e.lanes;a&=t.pendingLanes,l|=a,e.lanes=l,of(t,l)}}var On={readContext:Pt,use:Uu,useCallback:Ut,useContext:Ut,useEffect:Ut,useImperativeHandle:Ut,useLayoutEffect:Ut,useInsertionEffect:Ut,useMemo:Ut,useReducer:Ut,useRef:Ut,useState:Ut,useDebugValue:Ut,useDeferredValue:Ut,useTransition:Ut,useSyncExternalStore:Ut,useId:Ut,useHostTransitionStatus:Ut,useFormState:Ut,useActionState:Ut,useOptimistic:Ut,useMemoCache:Ut,useCacheRefresh:Ut};On.useEffectEvent=Ut;var co={readContext:Pt,use:Uu,useCallback:function(t,e){return fe().memoizedState=[t,e===void 0?null:e],t},useContext:Pt,useEffect:Zr,useImperativeHandle:function(t,e,l){l=l!=null?l.concat([t]):null,qu(4194308,4,Jr.bind(null,e,t),l)},useLayoutEffect:function(t,e){return qu(4194308,4,t,e)},useInsertionEffect:function(t,e){qu(4,2,t,e)},useMemo:function(t,e){var l=fe();e=e===void 0?null:e;var a=t();if(ca){ae(!0);try{t()}finally{ae(!1)}}return l.memoizedState=[a,e],a},useReducer:function(t,e,l){var a=fe();if(l!==void 0){var n=l(e);if(ca){ae(!0);try{l(e)}finally{ae(!1)}}}else n=e;return a.memoizedState=a.baseState=n,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:n},a.queue=t,t=t.dispatch=Zm.bind(null,et,t),[a.memoizedState,t]},useRef:function(t){var e=fe();return t={current:t},e.memoizedState=t},useState:function(t){t=Rc(t);var e=t.queue,l=no.bind(null,et,e);return e.dispatch=l,[t.memoizedState,l]},useDebugValue:Uc,useDeferredValue:function(t,e){var l=fe();return Hc(l,t,e)},useTransition:function(){var t=Rc(!1);return t=Pr.bind(null,et,t.queue,!0,!1),fe().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,e,l){var a=et,n=fe();if(rt){if(l===void 0)throw Error(s(407));l=l()}else{if(l=e(),Ot===null)throw Error(s(349));(ct&127)!==0||jr(a,e,l)}n.memoizedState=l;var u={value:l,getSnapshot:e};return n.queue=u,Zr(Dr.bind(null,a,u,t),[t]),a.flags|=2048,Xa(9,{destroy:void 0},Or.bind(null,a,u,l,e),null),l},useId:function(){var t=fe(),e=Ot.identifierPrefix;if(rt){var l=Je,a=Ke;l=(a&~(1<<32-se(a)-1)).toString(32)+l,e="_"+e+"R_"+l,l=Cu++,0<\/script>",u=u.removeChild(u.firstChild);break;case"select":u=typeof a.is=="string"?i.createElement("select",{is:a.is}):i.createElement("select"),a.multiple?u.multiple=!0:a.size&&(u.size=a.size);break;default:u=typeof a.is=="string"?i.createElement(n,{is:a.is}):i.createElement(n)}}u[Ft]=e,u[oe]=a;t:for(i=e.child;i!==null;){if(i.tag===5||i.tag===6)u.appendChild(i.stateNode);else if(i.tag!==4&&i.tag!==27&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===e)break t;for(;i.sibling===null;){if(i.return===null||i.return===e)break t;i=i.return}i.sibling.return=i.return,i=i.sibling}e.stateNode=u;t:switch(ee(u,n,a),n){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break t;case"img":a=!0;break t;default:a=!1}a&&rl(e)}}return Mt(e),Pc(e,e.type,t===null?null:t.memoizedProps,e.pendingProps,l),null;case 6:if(t&&e.stateNode!=null)t.memoizedProps!==a&&rl(e);else{if(typeof a!="string"&&e.stateNode===null)throw Error(s(166));if(t=I.current,Ca(e)){if(t=e.stateNode,l=e.memoizedProps,a=null,n=It,n!==null)switch(n.tag){case 27:case 5:a=n.memoizedProps}t[Ft]=e,t=!!(t.nodeValue===l||a!==null&&a.suppressHydrationWarning===!0||Nh(t.nodeValue,l)),t||_l(e,!0)}else t=ui(t).createTextNode(a),t[Ft]=e,e.stateNode=t}return Mt(e),null;case 31:if(l=e.memoizedState,t===null||t.memoizedState!==null){if(a=Ca(e),l!==null){if(t===null){if(!a)throw Error(s(318));if(t=e.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(557));t[Ft]=e}else ta(),(e.flags&128)===0&&(e.memoizedState=null),e.flags|=4;Mt(e),t=!1}else l=fc(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=l),t=!0;if(!t)return e.flags&256?(ze(e),e):(ze(e),null);if((e.flags&128)!==0)throw Error(s(558))}return Mt(e),null;case 13:if(a=e.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(n=Ca(e),a!==null&&a.dehydrated!==null){if(t===null){if(!n)throw Error(s(318));if(n=e.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(s(317));n[Ft]=e}else ta(),(e.flags&128)===0&&(e.memoizedState=null),e.flags|=4;Mt(e),n=!1}else n=fc(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=n),n=!0;if(!n)return e.flags&256?(ze(e),e):(ze(e),null)}return ze(e),(e.flags&128)!==0?(e.lanes=l,e):(l=a!==null,t=t!==null&&t.memoizedState!==null,l&&(a=e.child,n=null,a.alternate!==null&&a.alternate.memoizedState!==null&&a.alternate.memoizedState.cachePool!==null&&(n=a.alternate.memoizedState.cachePool.pool),u=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(u=a.memoizedState.cachePool.pool),u!==n&&(a.flags|=2048)),l!==t&&l&&(e.child.flags|=8192),Zu(e,e.updateQueue),Mt(e),null);case 4:return kt(),t===null&&xs(e.stateNode.containerInfo),Mt(e),null;case 10:return il(e.type),Mt(e),null;case 19:if(M(qt),a=e.memoizedState,a===null)return Mt(e),null;if(n=(e.flags&128)!==0,u=a.rendering,u===null)if(n)Mn(a,!1);else{if(Ht!==0||t!==null&&(t.flags&128)!==0)for(t=e.child;t!==null;){if(u=Mu(t),u!==null){for(e.flags|=128,Mn(a,!1),t=u.updateQueue,e.updateQueue=t,Zu(e,t),e.subtreeFlags=0,t=l,l=e.child;l!==null;)nr(l,t),l=l.sibling;return B(qt,qt.current&1|2),rt&&nl(e,a.treeForkCount),e.child}t=t.sibling}a.tail!==null&&ce()>$u&&(e.flags|=128,n=!0,Mn(a,!1),e.lanes=4194304)}else{if(!n)if(t=Mu(u),t!==null){if(e.flags|=128,n=!0,t=t.updateQueue,e.updateQueue=t,Zu(e,t),Mn(a,!0),a.tail===null&&a.tailMode==="hidden"&&!u.alternate&&!rt)return Mt(e),null}else 2*ce()-a.renderingStartTime>$u&&l!==536870912&&(e.flags|=128,n=!0,Mn(a,!1),e.lanes=4194304);a.isBackwards?(u.sibling=e.child,e.child=u):(t=a.last,t!==null?t.sibling=u:e.child=u,a.last=u)}return a.tail!==null?(t=a.tail,a.rendering=t,a.tail=t.sibling,a.renderingStartTime=ce(),t.sibling=null,l=qt.current,B(qt,n?l&1|2:l&1),rt&&nl(e,a.treeForkCount),t):(Mt(e),null);case 22:case 23:return ze(e),zc(),a=e.memoizedState!==null,t!==null?t.memoizedState!==null!==a&&(e.flags|=8192):a&&(e.flags|=8192),a?(l&536870912)!==0&&(e.flags&128)===0&&(Mt(e),e.subtreeFlags&6&&(e.flags|=8192)):Mt(e),l=e.updateQueue,l!==null&&Zu(e,l.retryQueue),l=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(l=t.memoizedState.cachePool.pool),a=null,e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),a!==l&&(e.flags|=2048),t!==null&&M(aa),null;case 24:return l=null,t!==null&&(l=t.memoizedState.cache),e.memoizedState.cache!==l&&(e.flags|=2048),il(Gt),Mt(e),null;case 25:return null;case 30:return null}throw Error(s(156,e.tag))}function $m(t,e){switch(cc(e),e.tag){case 1:return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return il(Gt),kt(),t=e.flags,(t&65536)!==0&&(t&128)===0?(e.flags=t&-65537|128,e):null;case 26:case 27:case 5:return Qe(e),null;case 31:if(e.memoizedState!==null){if(ze(e),e.alternate===null)throw Error(s(340));ta()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 13:if(ze(e),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(s(340));ta()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return M(qt),null;case 4:return kt(),null;case 10:return il(e.type),null;case 22:case 23:return ze(e),zc(),t!==null&&M(aa),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 24:return il(Gt),null;case 25:return null;default:return null}}function Ro(t,e){switch(cc(e),e.tag){case 3:il(Gt),kt();break;case 26:case 27:case 5:Qe(e);break;case 4:kt();break;case 31:e.memoizedState!==null&&ze(e);break;case 13:ze(e);break;case 19:M(qt);break;case 10:il(e.type);break;case 22:case 23:ze(e),zc(),t!==null&&M(aa);break;case 24:il(Gt)}}function Rn(t,e){try{var l=e.updateQueue,a=l!==null?l.lastEffect:null;if(a!==null){var n=a.next;l=n;do{if((l.tag&t)===t){a=void 0;var u=l.create,i=l.inst;a=u(),i.destroy=a}l=l.next}while(l!==n)}}catch(o){zt(e,e.return,o)}}function Ml(t,e,l){try{var a=e.updateQueue,n=a!==null?a.lastEffect:null;if(n!==null){var u=n.next;a=u;do{if((a.tag&t)===t){var i=a.inst,o=i.destroy;if(o!==void 0){i.destroy=void 0,n=e;var d=l,z=o;try{z()}catch(O){zt(n,d,O)}}}a=a.next}while(a!==u)}}catch(O){zt(e,e.return,O)}}function Co(t){var e=t.updateQueue;if(e!==null){var l=t.stateNode;try{zr(e,l)}catch(a){zt(t,t.return,a)}}}function ko(t,e,l){l.props=sa(t.type,t.memoizedProps),l.state=t.memoizedState;try{l.componentWillUnmount()}catch(a){zt(t,e,a)}}function Cn(t,e){try{var l=t.ref;if(l!==null){switch(t.tag){case 26:case 27:case 5:var a=t.stateNode;break;case 30:a=t.stateNode;break;default:a=t.stateNode}typeof l=="function"?t.refCleanup=l(a):l.current=a}}catch(n){zt(t,e,n)}}function $e(t,e){var l=t.ref,a=t.refCleanup;if(l!==null)if(typeof a=="function")try{a()}catch(n){zt(t,e,n)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(n){zt(t,e,n)}else l.current=null}function Uo(t){var e=t.type,l=t.memoizedProps,a=t.stateNode;try{t:switch(e){case"button":case"input":case"select":case"textarea":l.autoFocus&&a.focus();break t;case"img":l.src?a.src=l.src:l.srcSet&&(a.srcset=l.srcSet)}}catch(n){zt(t,t.return,n)}}function ts(t,e,l){try{var a=t.stateNode;y0(a,t.type,l,e),a[oe]=e}catch(n){zt(t,t.return,n)}}function Ho(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&Bl(t.type)||t.tag===4}function es(t){t:for(;;){for(;t.sibling===null;){if(t.return===null||Ho(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&Bl(t.type)||t.flags&2||t.child===null||t.tag===4)continue t;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function ls(t,e,l){var a=t.tag;if(a===5||a===6)t=t.stateNode,e?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(t,e):(e=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,e.appendChild(t),l=l._reactRootContainer,l!=null||e.onclick!==null||(e.onclick=el));else if(a!==4&&(a===27&&Bl(t.type)&&(l=t.stateNode,e=null),t=t.child,t!==null))for(ls(t,e,l),t=t.sibling;t!==null;)ls(t,e,l),t=t.sibling}function Lu(t,e,l){var a=t.tag;if(a===5||a===6)t=t.stateNode,e?l.insertBefore(t,e):l.appendChild(t);else if(a!==4&&(a===27&&Bl(t.type)&&(l=t.stateNode),t=t.child,t!==null))for(Lu(t,e,l),t=t.sibling;t!==null;)Lu(t,e,l),t=t.sibling}function qo(t){var e=t.stateNode,l=t.memoizedProps;try{for(var a=t.type,n=e.attributes;n.length;)e.removeAttributeNode(n[0]);ee(e,a,l),e[Ft]=t,e[oe]=l}catch(u){zt(t,t.return,u)}}var ol=!1,Zt=!1,as=!1,Bo=typeof WeakSet=="function"?WeakSet:Set,$t=null;function Wm(t,e){if(t=t.containerInfo,_s=hi,t=$f(t),Wi(t)){if("selectionStart"in t)var l={start:t.selectionStart,end:t.selectionEnd};else t:{l=(l=t.ownerDocument)&&l.defaultView||window;var a=l.getSelection&&l.getSelection();if(a&&a.rangeCount!==0){l=a.anchorNode;var n=a.anchorOffset,u=a.focusNode;a=a.focusOffset;try{l.nodeType,u.nodeType}catch{l=null;break t}var i=0,o=-1,d=-1,z=0,O=0,k=t,_=null;e:for(;;){for(var N;k!==l||n!==0&&k.nodeType!==3||(o=i+n),k!==u||a!==0&&k.nodeType!==3||(d=i+a),k.nodeType===3&&(i+=k.nodeValue.length),(N=k.firstChild)!==null;)_=k,k=N;for(;;){if(k===t)break e;if(_===l&&++z===n&&(o=i),_===u&&++O===a&&(d=i),(N=k.nextSibling)!==null)break;k=_,_=k.parentNode}k=N}l=o===-1||d===-1?null:{start:o,end:d}}else l=null}l=l||{start:0,end:0}}else l=null;for(Es={focusedElem:t,selectionRange:l},hi=!1,$t=e;$t!==null;)if(e=$t,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,$t=t;else for(;$t!==null;){switch(e=$t,u=e.alternate,t=e.flags,e.tag){case 0:if((t&4)!==0&&(t=e.updateQueue,t=t!==null?t.events:null,t!==null))for(l=0;l title"))),ee(u,a,l),u[Ft]=t,Jt(u),a=u;break t;case"link":var i=Zh("link","href",n).get(a+(l.href||""));if(i){for(var o=0;oAt&&(i=At,At=V,V=i);var S=Kf(o,V),p=Kf(o,At);if(S&&p&&(N.rangeCount!==1||N.anchorNode!==S.node||N.anchorOffset!==S.offset||N.focusNode!==p.node||N.focusOffset!==p.offset)){var x=k.createRange();x.setStart(S.node,S.offset),N.removeAllRanges(),V>At?(N.addRange(x),N.extend(p.node,p.offset)):(x.setEnd(p.node,p.offset),N.addRange(x))}}}}for(k=[],N=o;N=N.parentNode;)N.nodeType===1&&k.push({element:N,left:N.scrollLeft,top:N.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;ol?32:l,D.T=null,l=rs,rs=null;var u=Ul,i=pl;if(Lt=0,Ka=Ul=null,pl=0,(bt&6)!==0)throw Error(s(331));var o=bt;if(bt|=4,$o(u.current),Vo(u,u.current,i,l),bt=o,Yn(0,!1),mt&&typeof mt.onPostCommitFiberRoot=="function")try{mt.onPostCommitFiberRoot(vt,u)}catch{}return!0}finally{q.p=n,D.T=a,dh(t,e)}}function gh(t,e,l){e=Ce(l,e),e=wc(t.stateNode,e,2),t=jl(t,e,2),t!==null&&(nn(t,2),We(t))}function zt(t,e,l){if(t.tag===3)gh(t,t,l);else for(;e!==null;){if(e.tag===3){gh(e,t,l);break}else if(e.tag===1){var a=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(kl===null||!kl.has(a))){t=Ce(l,t),l=po(2),a=jl(e,l,2),a!==null&&(yo(l,a,e,t),nn(a,2),We(a));break}}e=e.return}}function ms(t,e,l){var a=t.pingCache;if(a===null){a=t.pingCache=new Pm;var n=new Set;a.set(e,n)}else n=a.get(e),n===void 0&&(n=new Set,a.set(e,n));n.has(l)||(is=!0,n.add(l),t=n0.bind(null,t,e,l),e.then(t,t))}function n0(t,e,l){var a=t.pingCache;a!==null&&a.delete(e),t.pingedLanes|=t.suspendedLanes&l,t.warmLanes&=~l,Ot===t&&(ct&l)===l&&(Ht===4||Ht===3&&(ct&62914560)===ct&&300>ce()-Ju?(bt&2)===0&&Ja(t,0):cs|=l,Va===ct&&(Va=0)),We(t)}function ph(t,e){e===0&&(e=ff()),t=Il(t,e),t!==null&&(nn(t,e),We(t))}function u0(t){var e=t.memoizedState,l=0;e!==null&&(l=e.retryLane),ph(t,l)}function i0(t,e){var l=0;switch(t.tag){case 31:case 13:var a=t.stateNode,n=t.memoizedState;n!==null&&(l=n.retryLane);break;case 19:a=t.stateNode;break;case 22:a=t.stateNode._retryCache;break;default:throw Error(s(314))}a!==null&&a.delete(e),ph(t,l)}function c0(t,e){return gt(t,e)}var ei=null,Wa=null,gs=!1,li=!1,ps=!1,ql=0;function We(t){t!==Wa&&t.next===null&&(Wa===null?ei=Wa=t:Wa=Wa.next=t),li=!0,gs||(gs=!0,f0())}function Yn(t,e){if(!ps&&li){ps=!0;do for(var l=!1,a=ei;a!==null;){if(t!==0){var n=a.pendingLanes;if(n===0)var u=0;else{var i=a.suspendedLanes,o=a.pingedLanes;u=(1<<31-se(42|t)+1)-1,u&=n&~(i&~o),u=u&201326741?u&201326741|1:u?u|2:0}u!==0&&(l=!0,Sh(a,u))}else u=ct,u=iu(a,a===Ot?u:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(u&3)===0||an(a,u)||(l=!0,Sh(a,u));a=a.next}while(l);ps=!1}}function s0(){yh()}function yh(){li=gs=!1;var t=0;ql!==0&&b0()&&(t=ql);for(var e=ce(),l=null,a=ei;a!==null;){var n=a.next,u=vh(a,e);u===0?(a.next=null,l===null?ei=n:l.next=n,n===null&&(Wa=l)):(l=a,(t!==0||(u&3)!==0)&&(li=!0)),a=n}Lt!==0&&Lt!==5||Yn(t),ql!==0&&(ql=0)}function vh(t,e){for(var l=t.suspendedLanes,a=t.pingedLanes,n=t.expirationTimes,u=t.pendingLanes&-62914561;0o)break;var O=d.transferSize,k=d.initiatorType;O&&jh(k)&&(d=d.responseEnd,i+=O*(d"u"?null:document;function Qh(t,e,l){var a=Fa;if(a&&typeof e=="string"&&e){var n=Me(e);n='link[rel="'+t+'"][href="'+n+'"]',typeof l=="string"&&(n+='[crossorigin="'+l+'"]'),Yh.has(n)||(Yh.add(n),t={rel:t,crossOrigin:l,href:e},a.querySelector(n)===null&&(e=a.createElement("link"),ee(e,"link",t),Jt(e),a.head.appendChild(e)))}}function j0(t){yl.D(t),Qh("dns-prefetch",t,null)}function O0(t,e){yl.C(t,e),Qh("preconnect",t,e)}function D0(t,e,l){yl.L(t,e,l);var a=Fa;if(a&&t&&e){var n='link[rel="preload"][as="'+Me(e)+'"]';e==="image"&&l&&l.imageSrcSet?(n+='[imagesrcset="'+Me(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(n+='[imagesizes="'+Me(l.imageSizes)+'"]')):n+='[href="'+Me(t)+'"]';var u=n;switch(e){case"style":u=Ia(t);break;case"script":u=Pa(t)}Ye.has(u)||(t=C({rel:"preload",href:e==="image"&&l&&l.imageSrcSet?void 0:t,as:e},l),Ye.set(u,t),a.querySelector(n)!==null||e==="style"&&a.querySelector(wn(u))||e==="script"&&a.querySelector(Zn(u))||(e=a.createElement("link"),ee(e,"link",t),Jt(e),a.head.appendChild(e)))}}function M0(t,e){yl.m(t,e);var l=Fa;if(l&&t){var a=e&&typeof e.as=="string"?e.as:"script",n='link[rel="modulepreload"][as="'+Me(a)+'"][href="'+Me(t)+'"]',u=n;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":u=Pa(t)}if(!Ye.has(u)&&(t=C({rel:"modulepreload",href:t},e),Ye.set(u,t),l.querySelector(n)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Zn(u)))return}a=l.createElement("link"),ee(a,"link",t),Jt(a),l.head.appendChild(a)}}}function R0(t,e,l){yl.S(t,e,l);var a=Fa;if(a&&t){var n=Sa(a).hoistableStyles,u=Ia(t);e=e||"default";var i=n.get(u);if(!i){var o={loading:0,preload:null};if(i=a.querySelector(wn(u)))o.loading=5;else{t=C({rel:"stylesheet",href:t,"data-precedence":e},l),(l=Ye.get(u))&&Rs(t,l);var d=i=a.createElement("link");Jt(d),ee(d,"link",t),d._p=new Promise(function(z,O){d.onload=z,d.onerror=O}),d.addEventListener("load",function(){o.loading|=1}),d.addEventListener("error",function(){o.loading|=2}),o.loading|=4,ci(i,e,a)}i={type:"stylesheet",instance:i,count:1,state:o},n.set(u,i)}}}function C0(t,e){yl.X(t,e);var l=Fa;if(l&&t){var a=Sa(l).hoistableScripts,n=Pa(t),u=a.get(n);u||(u=l.querySelector(Zn(n)),u||(t=C({src:t,async:!0},e),(e=Ye.get(n))&&Cs(t,e),u=l.createElement("script"),Jt(u),ee(u,"link",t),l.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},a.set(n,u))}}function k0(t,e){yl.M(t,e);var l=Fa;if(l&&t){var a=Sa(l).hoistableScripts,n=Pa(t),u=a.get(n);u||(u=l.querySelector(Zn(n)),u||(t=C({src:t,async:!0,type:"module"},e),(e=Ye.get(n))&&Cs(t,e),u=l.createElement("script"),Jt(u),ee(u,"link",t),l.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},a.set(n,u))}}function Gh(t,e,l,a){var n=(n=I.current)?ii(n):null;if(!n)throw Error(s(446));switch(t){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(e=Ia(l.href),l=Sa(n).hoistableStyles,a=l.get(e),a||(a={type:"style",instance:null,count:0,state:null},l.set(e,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){t=Ia(l.href);var u=Sa(n).hoistableStyles,i=u.get(t);if(i||(n=n.ownerDocument||n,i={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(t,i),(u=n.querySelector(wn(t)))&&!u._p&&(i.instance=u,i.state.loading=5),Ye.has(t)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Ye.set(t,l),u||U0(n,t,l,i.state))),e&&a===null)throw Error(s(528,""));return i}if(e&&a!==null)throw Error(s(529,""));return null;case"script":return e=l.async,l=l.src,typeof l=="string"&&e&&typeof e!="function"&&typeof e!="symbol"?(e=Pa(l),l=Sa(n).hoistableScripts,a=l.get(e),a||(a={type:"script",instance:null,count:0,state:null},l.set(e,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,t))}}function Ia(t){return'href="'+Me(t)+'"'}function wn(t){return'link[rel="stylesheet"]['+t+"]"}function Xh(t){return C({},t,{"data-precedence":t.precedence,precedence:null})}function U0(t,e,l,a){t.querySelector('link[rel="preload"][as="style"]['+e+"]")?a.loading=1:(e=t.createElement("link"),a.preload=e,e.addEventListener("load",function(){return a.loading|=1}),e.addEventListener("error",function(){return a.loading|=2}),ee(e,"link",l),Jt(e),t.head.appendChild(e))}function Pa(t){return'[src="'+Me(t)+'"]'}function Zn(t){return"script[async]"+t}function wh(t,e,l){if(e.count++,e.instance===null)switch(e.type){case"style":var a=t.querySelector('style[data-href~="'+Me(l.href)+'"]');if(a)return e.instance=a,Jt(a),a;var n=C({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return a=(t.ownerDocument||t).createElement("style"),Jt(a),ee(a,"style",n),ci(a,l.precedence,t),e.instance=a;case"stylesheet":n=Ia(l.href);var u=t.querySelector(wn(n));if(u)return e.state.loading|=4,e.instance=u,Jt(u),u;a=Xh(l),(n=Ye.get(n))&&Rs(a,n),u=(t.ownerDocument||t).createElement("link"),Jt(u);var i=u;return i._p=new Promise(function(o,d){i.onload=o,i.onerror=d}),ee(u,"link",a),e.state.loading|=4,ci(u,l.precedence,t),e.instance=u;case"script":return u=Pa(l.src),(n=t.querySelector(Zn(u)))?(e.instance=n,Jt(n),n):(a=l,(n=Ye.get(u))&&(a=C({},l),Cs(a,n)),t=t.ownerDocument||t,n=t.createElement("script"),Jt(n),ee(n,"link",a),t.head.appendChild(n),e.instance=n);case"void":return null;default:throw Error(s(443,e.type))}else e.type==="stylesheet"&&(e.state.loading&4)===0&&(a=e.instance,e.state.loading|=4,ci(a,l.precedence,t));return e.instance}function ci(t,e,l){for(var a=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),n=a.length?a[a.length-1]:null,u=n,i=0;i title"):null)}function H0(t,e,l){if(l===1||e.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof e.precedence!="string"||typeof e.href!="string"||e.href==="")break;return!0;case"link":if(typeof e.rel!="string"||typeof e.href!="string"||e.href===""||e.onLoad||e.onError)break;switch(e.rel){case"stylesheet":return t=e.disabled,typeof e.precedence=="string"&&t==null;default:return!0}case"script":if(e.async&&typeof e.async!="function"&&typeof e.async!="symbol"&&!e.onLoad&&!e.onError&&e.src&&typeof e.src=="string")return!0}return!1}function Vh(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function q0(t,e,l,a){if(l.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var n=Ia(a.href),u=e.querySelector(wn(n));if(u){e=u._p,e!==null&&typeof e=="object"&&typeof e.then=="function"&&(t.count++,t=fi.bind(t),e.then(t,t)),l.state.loading|=4,l.instance=u,Jt(u);return}u=e.ownerDocument||e,a=Xh(a),(n=Ye.get(n))&&Rs(a,n),u=u.createElement("link"),Jt(u);var i=u;i._p=new Promise(function(o,d){i.onload=o,i.onerror=d}),ee(u,"link",a),l.instance=u}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(l,e),(e=l.state.preload)&&(l.state.loading&3)===0&&(t.count++,l=fi.bind(t),e.addEventListener("load",l),e.addEventListener("error",l))}}var ks=0;function B0(t,e){return t.stylesheets&&t.count===0&&oi(t,t.stylesheets),0ks?50:800)+e);return t.unsuspend=l,function(){t.unsuspend=null,clearTimeout(a),clearTimeout(n)}}:null}function fi(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)oi(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var ri=null;function oi(t,e){t.stylesheets=null,t.unsuspend!==null&&(t.count++,ri=new Map,e.forEach(Y0,t),ri=null,fi.call(t))}function Y0(t,e){if(!(e.state.loading&4)){var l=ri.get(t);if(l)var a=l.get(null);else{l=new Map,ri.set(t,l);for(var n=t.querySelectorAll("link[data-precedence],style[data-precedence]"),u=0;u"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(r)}catch(c){console.error(c)}}return r(),ws.exports=ag(),ws.exports}var ug=ng();function ig({onSend:r,disabled:c,userId:f}){const[s,h]=w.useState(""),[v,A]=w.useState([]),j=w.useRef(null),g=E=>{E.preventDefault();const C=s.trim();if(!C&&v.length===0)return;const H=v.length?v.map(J=>({filename:J.filename,size:J.size,mime_type:J.mime_type,download_url:"/files/"+J.workspace_path})):void 0;r(C,H),h(""),A([])},b=async E=>{var J;const C=(J=E.target.files)==null?void 0:J[0];if(!C||!f)return;const H=new FormData;H.append("file",C);try{const F=await(await fetch("/upload?user_id="+f,{method:"POST",body:H})).json();F.attachment_id&&A(nt=>[...nt,{filename:C.name,workspace_path:F.workspace_path,mime_type:C.type,size:C.size}])}catch(U){console.error("upload",U)}E.target.value=""};return m.jsxs("div",{className:"input-area",children:[v.length>0&&m.jsx("div",{className:"attach-bar",children:v.map((E,C)=>m.jsxs("span",{className:"attach-tag",children:["📎 ",E.filename,m.jsx("span",{className:"remove",onClick:()=>A(H=>H.filter((J,U)=>U!==C)),children:"×"})]},C))}),m.jsxs("form",{className:"chat-input",onSubmit:g,children:[m.jsx("button",{type:"button",className:"file-btn",onClick:()=>{var E;return(E=j.current)==null?void 0:E.click()},title:"Прикрепить файл",children:"📎"}),m.jsx("input",{ref:j,type:"file",hidden:!0,onChange:b}),m.jsx("input",{type:"text",value:s,onChange:E=>h(E.target.value),placeholder:"Напишите сообщение...",disabled:c,autoFocus:!0}),m.jsx("button",{type:"submit",className:"btn-send",disabled:c||!s.trim()&&v.length===0,children:"Отправить"})]})]})}function Fs(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var da=Fs();function Td(r){da=r}var oa={exec:()=>null};function en(r){let c=[];return f=>{let s=Math.max(0,Math.min(3,f-1)),h=c[s];return h||(h=r(s),c[s]=h),h}}function ht(r,c=""){let f=typeof r=="string"?r:r.source,s={replace:(h,v)=>{let A=typeof v=="string"?v:v.source;return A=A.replace(ue.caret,"$1"),f=f.replace(h,A),s},getRegex:()=>new RegExp(f,c)};return s}var cg=((r="")=>{try{return!!new RegExp("(?<=1)(?/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:r=>new RegExp(`^( {0,3}${r})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:en(r=>new RegExp(`^ {0,${r}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:en(r=>new RegExp(`^ {0,${r}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:en(r=>new RegExp(`^ {0,${r}}(?:\`\`\`|~~~)`)),headingBeginRegex:en(r=>new RegExp(`^ {0,${r}}#`)),htmlBeginRegex:en(r=>new RegExp(`^ {0,${r}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:en(r=>new RegExp(`^ {0,${r}}>`))},sg=/^(?:[ \t]*(?:\n|$))+/,fg=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,rg=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Pn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,og=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Is=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,_d=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ed=ht(_d).replace(/bull/g,Is).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),hg=ht(_d).replace(/bull/g,Is).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Ps=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,dg=/^[^\n]+/,tf=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,mg=ht(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",tf).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),gg=ht(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Is).getRegex(),_i="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ef=/|$))/,pg=ht("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",ef).replace("tag",_i).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ad=ht(Ps).replace("hr",Pn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",_i).getRegex(),yg=ht(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ad).getRegex(),lf={blockquote:yg,code:fg,def:mg,fences:rg,heading:og,hr:Pn,html:pg,lheading:Ed,list:gg,newline:sg,paragraph:Ad,table:oa,text:dg},pd=ht("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Pn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",_i).getRegex(),vg={...lf,lheading:hg,table:pd,paragraph:ht(Ps).replace("hr",Pn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",pd).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",_i).getRegex()},bg={...lf,html:ht(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ef).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:oa,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ht(Ps).replace("hr",Pn).replace("heading",` *#{1,6} *[^ ]`).replace("lheading",Ed).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Sg=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,xg=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Nd=/^( {2,}|\\)\n(?!\s*$)/,zg=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\`+)[^`]+\k(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",cg?"(?`+)[^`]+\k(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Od=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Ng=ht(Od,"u").replace(/punct/g,ln).getRegex(),jg=ht(Od,"u").replace(/punct/g,jd).getRegex(),Dd="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Og=ht(Dd,"gu").replace(/notPunctSpace/g,af).replace(/punctSpace/g,Ei).replace(/punct/g,ln).getRegex(),Dg=ht(Dd,"gu").replace(/notPunctSpace/g,Eg).replace(/punctSpace/g,_g).replace(/punct/g,jd).getRegex(),Mg=ht("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,af).replace(/punctSpace/g,Ei).replace(/punct/g,ln).getRegex(),Rg=ht(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,ln).getRegex(),Cg="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",kg=ht(Cg,"gu").replace(/notPunctSpace/g,af).replace(/punctSpace/g,Ei).replace(/punct/g,ln).getRegex(),Ug=ht(/\\(punct)/,"gu").replace(/punct/g,ln).getRegex(),Hg=ht(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),qg=ht(ef).replace("(?:-->|$)","-->").getRegex(),Bg=ht("^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^").replace("comment",qg).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),xi=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Yg=ht(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",xi).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Md=ht(/^!?\[(label)\]\[(ref)\]/).replace("label",xi).replace("ref",tf).getRegex(),Rd=ht(/^!?\[(ref)\](?:\[\])?/).replace("ref",tf).getRegex(),Qg=ht("reflink|nolink(?!\\()","g").replace("reflink",Md).replace("nolink",Rd).getRegex(),yd=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,nf={_backpedal:oa,anyPunctuation:Ug,autolink:Hg,blockSkip:Ag,br:Nd,code:xg,del:oa,delLDelim:oa,delRDelim:oa,emStrongLDelim:Ng,emStrongRDelimAst:Og,emStrongRDelimUnd:Mg,escape:Sg,link:Yg,nolink:Rd,punctuation:Tg,reflink:Md,reflinkSearch:Qg,tag:Bg,text:zg,url:oa},Gg={...nf,link:ht(/^!?\[(label)\]\((.*?)\)/).replace("label",xi).getRegex(),reflink:ht(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",xi).getRegex()},Ks={...nf,emStrongRDelimAst:Dg,emStrongLDelim:jg,delLDelim:Rg,delRDelim:kg,url:ht(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",yd).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:ht(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\":">",'"':""","'":"'"},vd=r=>wg[r];function Fe(r,c){if(c){if(ue.escapeTest.test(r))return r.replace(ue.escapeReplace,vd)}else if(ue.escapeTestNoEncode.test(r))return r.replace(ue.escapeReplaceNoEncode,vd);return r}function bd(r){try{r=encodeURI(r).replace(ue.percentDecode,"%")}catch{return null}return r}function Sd(r,c){var v;let f=r.replace(ue.findPipe,(A,j,g)=>{let b=!1,E=j;for(;--E>=0&&g[E]==="\\";)b=!b;return b?"|":" |"}),s=f.split(ue.splitPipe),h=0;if(s[0].trim()||s.shift(),s.length>0&&!((v=s.at(-1))!=null&&v.trim())&&s.pop(),c)if(s.length>c)s.splice(c);else for(;s.length=0&&ue.blankLine.test(c[f]);)f--;return c.length-f<=2?r:c.slice(0,f+1).join(` `)}function Zg(r,c){if(r.indexOf(c[1])===-1)return-1;let f=0;for(let s=0;s0?-2:-1}function Lg(r,c=0){let f=c,s="";for(let h of r)if(h===" "){let v=4-f%4;s+=" ".repeat(v),f+=v}else s+=h,f++;return s}function zd(r,c,f,s,h){let v=c.href,A=c.title||null,j=r[1].replace(h.other.outputLinkReplace,"$1");s.state.inLink=!0;let g={type:r[0].charAt(0)==="!"?"image":"link",raw:f,href:v,title:A,text:j,tokens:s.inlineTokens(j)};return s.state.inLink=!1,g}function Vg(r,c,f){let s=r.match(f.other.indentCodeCompensation);if(s===null)return c;let h=s[1];return c.split(` `).map(v=>{let A=v.match(f.other.beginningSpace);if(A===null)return v;let[j]=A;return j.length>=h.length?v.slice(h.length):v}).join(` `)}var zi=class{constructor(r){Nt(this,"options");Nt(this,"rules");Nt(this,"lexer");this.options=r||da}space(r){let c=this.rules.block.newline.exec(r);if(c&&c[0].length>0)return{type:"space",raw:c[0]}}code(r){let c=this.rules.block.code.exec(r);if(c){let f=this.options.pedantic?c[0]:xd(c[0]),s=f.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:f,codeBlockStyle:"indented",text:s}}}fences(r){let c=this.rules.block.fences.exec(r);if(c){let f=c[0],s=Vg(f,c[3]||"",this.rules);return{type:"code",raw:f,lang:c[2]?c[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):c[2],text:s}}}heading(r){let c=this.rules.block.heading.exec(r);if(c){let f=c[2].trim();if(this.rules.other.endingHash.test(f)){let s=Zl(f,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(f=s.trim())}return{type:"heading",raw:Zl(c[0],` `),depth:c[1].length,text:f,tokens:this.lexer.inline(f)}}}hr(r){let c=this.rules.block.hr.exec(r);if(c)return{type:"hr",raw:Zl(c[0],` `)}}blockquote(r){let c=this.rules.block.blockquote.exec(r);if(c){let f=Zl(c[0],` `).split(` `),s="",h="",v=[];for(;f.length>0;){let A=!1,j=[],g;for(g=0;g1,h={type:"list",raw:"",ordered:s,start:s?+f.slice(0,-1):"",loose:!1,items:[]};f=s?`\\d{1,9}\\${f.slice(-1)}`:`\\${f}`,this.options.pedantic&&(f=s?f:"[*+-]");let v=this.rules.other.listItemRegex(f),A=!1;for(;r;){let g=!1,b="",E="";if(!(c=v.exec(r))||this.rules.block.hr.test(r))break;b=c[0],r=r.substring(b.length);let C=Lg(c[2].split(` `,1)[0],c[1].length),H=r.split(` `,1)[0],J=!C.trim(),U=0;if(this.options.pedantic?(U=2,E=C.trimStart()):J?U=c[1].length+1:(U=C.search(this.rules.other.nonSpaceChar),U=U>4?1:U,E=C.slice(U),U+=c[1].length),J&&this.rules.other.blankLine.test(H)&&(b+=H+` `,r=r.substring(H.length+1),g=!0),!g){let F=this.rules.other.nextBulletRegex(U),nt=this.rules.other.hrRegex(U),Yt=this.rules.other.fencesBeginRegex(U),Qt=this.rules.other.headingBeginRegex(U),Ct=this.rules.other.htmlBeginRegex(U),ft=this.rules.other.blockquoteBeginRegex(U);for(;r;){let Vt=r.split(` `,1)[0],jt;if(H=Vt,this.options.pedantic?(H=H.replace(this.rules.other.listReplaceNesting," "),jt=H):jt=H.replace(this.rules.other.tabCharGlobal," "),Yt.test(H)||Qt.test(H)||Ct.test(H)||ft.test(H)||F.test(H)||nt.test(H))break;if(jt.search(this.rules.other.nonSpaceChar)>=U||!H.trim())E+=` `+jt.slice(U);else{if(J||C.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||Yt.test(C)||Qt.test(C)||nt.test(C))break;E+=` `+H}J=!H.trim(),b+=Vt+` `,r=r.substring(Vt.length+1),C=jt.slice(U)}}h.loose||(A?h.loose=!0:this.rules.other.doubleBlankLine.test(b)&&(A=!0)),h.items.push({type:"list_item",raw:b,task:!!this.options.gfm&&this.rules.other.listIsTask.test(E),loose:!1,text:E,tokens:[]}),h.raw+=b}let j=h.items.at(-1);if(j)j.raw=j.raw.trimEnd(),j.text=j.text.trimEnd();else return;h.raw=h.raw.trimEnd();for(let g of h.items){this.lexer.state.top=!1,g.tokens=this.lexer.blockTokens(g.text,[]);let b=g.tokens[0];if(g.task&&((b==null?void 0:b.type)==="text"||(b==null?void 0:b.type)==="paragraph")){g.text=g.text.replace(this.rules.other.listReplaceTask,""),b.raw=b.raw.replace(this.rules.other.listReplaceTask,""),b.text=b.text.replace(this.rules.other.listReplaceTask,"");for(let C=this.lexer.inlineQueue.length-1;C>=0;C--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[C].src)){this.lexer.inlineQueue[C].src=this.lexer.inlineQueue[C].src.replace(this.rules.other.listReplaceTask,"");break}let E=this.rules.other.listTaskCheckbox.exec(g.raw);if(E){let C={type:"checkbox",raw:E[0]+" ",checked:E[0]!=="[ ]"};g.checked=C.checked,h.loose?g.tokens[0]&&["paragraph","text"].includes(g.tokens[0].type)&&"tokens"in g.tokens[0]&&g.tokens[0].tokens?(g.tokens[0].raw=C.raw+g.tokens[0].raw,g.tokens[0].text=C.raw+g.tokens[0].text,g.tokens[0].tokens.unshift(C)):g.tokens.unshift({type:"paragraph",raw:C.raw,text:C.raw,tokens:[C]}):g.tokens.unshift(C)}}else g.task&&(g.task=!1);if(!h.loose){let E=g.tokens.filter(H=>H.type==="space"),C=E.length>0&&E.some(H=>this.rules.other.anyLine.test(H.raw));h.loose=C}}if(h.loose)for(let g of h.items){g.loose=!0;for(let b of g.tokens)b.type==="text"&&(b.type="paragraph")}return h}}html(r){let c=this.rules.block.html.exec(r);if(c){let f=xd(c[0]);return{type:"html",block:!0,raw:f,pre:c[1]==="pre"||c[1]==="script"||c[1]==="style",text:f}}}def(r){let c=this.rules.block.def.exec(r);if(c){let f=c[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=c[2]?c[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",h=c[3]?c[3].substring(1,c[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):c[3];return{type:"def",tag:f,raw:Zl(c[0],` `),href:s,title:h}}}table(r){var A;let c=this.rules.block.table.exec(r);if(!c||!this.rules.other.tableDelimiter.test(c[2]))return;let f=Sd(c[1]),s=c[2].replace(this.rules.other.tableAlignChars,"").split("|"),h=(A=c[3])!=null&&A.trim()?c[3].replace(this.rules.other.tableRowBlankLine,"").split(` `):[],v={type:"table",raw:Zl(c[0],` `),header:[],align:[],rows:[]};if(f.length===s.length){for(let j of s)this.rules.other.tableAlignRight.test(j)?v.align.push("right"):this.rules.other.tableAlignCenter.test(j)?v.align.push("center"):this.rules.other.tableAlignLeft.test(j)?v.align.push("left"):v.align.push(null);for(let j=0;j({text:g,tokens:this.lexer.inline(g),header:!1,align:v.align[b]})));return v}}lheading(r){let c=this.rules.block.lheading.exec(r);if(c){let f=c[1].trim();return{type:"heading",raw:Zl(c[0],` `),depth:c[2].charAt(0)==="="?1:2,text:f,tokens:this.lexer.inline(f)}}}paragraph(r){let c=this.rules.block.paragraph.exec(r);if(c){let f=c[1].charAt(c[1].length-1)===` `?c[1].slice(0,-1):c[1];return{type:"paragraph",raw:c[0],text:f,tokens:this.lexer.inline(f)}}}text(r){let c=this.rules.block.text.exec(r);if(c)return{type:"text",raw:c[0],text:c[0],tokens:this.lexer.inline(c[0])}}escape(r){let c=this.rules.inline.escape.exec(r);if(c)return{type:"escape",raw:c[0],text:c[1]}}tag(r){let c=this.rules.inline.tag.exec(r);if(c)return!this.lexer.state.inLink&&this.rules.other.startATag.test(c[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(c[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(c[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(c[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:c[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:c[0]}}link(r){let c=this.rules.inline.link.exec(r);if(c){let f=c[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(f)){if(!this.rules.other.endAngleBracket.test(f))return;let v=Zl(f.slice(0,-1),"\\");if((f.length-v.length)%2===0)return}else{let v=Zg(c[2],"()");if(v===-2)return;if(v>-1){let A=(c[0].indexOf("!")===0?5:4)+c[1].length+v;c[2]=c[2].substring(0,v),c[0]=c[0].substring(0,A).trim(),c[3]=""}}let s=c[2],h="";if(this.options.pedantic){let v=this.rules.other.pedanticHrefTitle.exec(s);v&&(s=v[1],h=v[3])}else h=c[3]?c[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(f)?s=s.slice(1):s=s.slice(1,-1)),zd(c,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:h&&h.replace(this.rules.inline.anyPunctuation,"$1")},c[0],this.lexer,this.rules)}}reflink(r,c){let f;if((f=this.rules.inline.reflink.exec(r))||(f=this.rules.inline.nolink.exec(r))){let s=(f[2]||f[1]).replace(this.rules.other.multipleSpaceGlobal," "),h=c[s.toLowerCase()];if(!h){let v=f[0].charAt(0);return{type:"text",raw:v,text:v}}return zd(f,h,f[0],this.lexer,this.rules)}}emStrong(r,c,f=""){let s=this.rules.inline.emStrongLDelim.exec(r);if(!(!s||!s[1]&&!s[2]&&!s[3]&&!s[4]||s[4]&&f.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[3])||!f||this.rules.inline.punctuation.exec(f))){let h=[...s[0]].length-1,v,A,j=h,g=0,b=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(b.lastIndex=0,c=c.slice(-1*r.length+h);(s=b.exec(c))!==null;){if(v=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!v)continue;if(A=[...v].length,s[3]||s[4]){j+=A;continue}else if((s[5]||s[6])&&h%3&&!((h+A)%3)){g+=A;continue}if(j-=A,j>0)continue;A=Math.min(A,A+j+g);let E=[...s[0]][0].length,C=r.slice(0,h+s.index+E+A);if(Math.min(h,A)%2){let J=C.slice(1,-1);return{type:"em",raw:C,text:J,tokens:this.lexer.inlineTokens(J)}}let H=C.slice(2,-2);return{type:"strong",raw:C,text:H,tokens:this.lexer.inlineTokens(H)}}}}codespan(r){let c=this.rules.inline.code.exec(r);if(c){let f=c[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(f),h=this.rules.other.startingSpaceChar.test(f)&&this.rules.other.endingSpaceChar.test(f);return s&&h&&(f=f.substring(1,f.length-1)),{type:"codespan",raw:c[0],text:f}}}br(r){let c=this.rules.inline.br.exec(r);if(c)return{type:"br",raw:c[0]}}del(r,c,f=""){let s=this.rules.inline.delLDelim.exec(r);if(s&&(!s[1]||!f||this.rules.inline.punctuation.exec(f))){let h=[...s[0]].length-1,v,A,j=h,g=this.rules.inline.delRDelim;for(g.lastIndex=0,c=c.slice(-1*r.length+h);(s=g.exec(c))!==null;){if(v=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!v||(A=[...v].length,A!==h))continue;if(s[3]||s[4]){j+=A;continue}if(j-=A,j>0)continue;A=Math.min(A,A+j);let b=[...s[0]][0].length,E=r.slice(0,h+s.index+b+A),C=E.slice(h,-h);return{type:"del",raw:E,text:C,tokens:this.lexer.inlineTokens(C)}}}}autolink(r){let c=this.rules.inline.autolink.exec(r);if(c){let f,s;return c[2]==="@"?(f=c[1],s="mailto:"+f):(f=c[1],s=f),{type:"link",raw:c[0],text:f,href:s,tokens:[{type:"text",raw:f,text:f}]}}}url(r){var f;let c;if(c=this.rules.inline.url.exec(r)){let s,h;if(c[2]==="@")s=c[0],h="mailto:"+s;else{let v;do v=c[0],c[0]=((f=this.rules.inline._backpedal.exec(c[0]))==null?void 0:f[0])??"";while(v!==c[0]);s=c[0],c[1]==="www."?h="http://"+c[0]:h=c[0]}return{type:"link",raw:c[0],text:s,href:h,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(r){let c=this.rules.inline.text.exec(r);if(c){let f=this.lexer.state.inRawBlock;return{type:"text",raw:c[0],text:c[0],escaped:f}}}},Ze=class Js{constructor(c){Nt(this,"tokens");Nt(this,"options");Nt(this,"state");Nt(this,"inlineQueue");Nt(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=c||da,this.options.tokenizer=this.options.tokenizer||new zi,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let f={other:ue,block:bi.normal,inline:Fn.normal};this.options.pedantic?(f.block=bi.pedantic,f.inline=Fn.pedantic):this.options.gfm&&(f.block=bi.gfm,this.options.breaks?f.inline=Fn.breaks:f.inline=Fn.gfm),this.tokenizer.rules=f}static get rules(){return{block:bi,inline:Fn}}static lex(c,f){return new Js(f).lex(c)}static lexInline(c,f){return new Js(f).inlineTokens(c)}lex(c){c=c.replace(ue.carriageReturn,` `),this.blockTokens(c,this.tokens);for(let f=0;f(g=E.call({lexer:this},c,f))?(c=c.substring(g.raw.length),f.push(g),!0):!1))continue;if(g=this.tokenizer.space(c)){c=c.substring(g.raw.length);let E=f.at(-1);g.raw.length===1&&E!==void 0?E.raw+=` `:f.push(g);continue}if(g=this.tokenizer.code(c)){c=c.substring(g.raw.length);let E=f.at(-1);(E==null?void 0:E.type)==="paragraph"||(E==null?void 0:E.type)==="text"?(E.raw+=(E.raw.endsWith(` `)?"":` `)+g.raw,E.text+=` `+g.text,this.inlineQueue.at(-1).src=E.text):f.push(g);continue}if(g=this.tokenizer.fences(c)){c=c.substring(g.raw.length),f.push(g);continue}if(g=this.tokenizer.heading(c)){c=c.substring(g.raw.length),f.push(g);continue}if(g=this.tokenizer.hr(c)){c=c.substring(g.raw.length),f.push(g);continue}if(g=this.tokenizer.blockquote(c)){c=c.substring(g.raw.length),f.push(g);continue}if(g=this.tokenizer.list(c)){c=c.substring(g.raw.length),f.push(g);continue}if(g=this.tokenizer.html(c)){c=c.substring(g.raw.length),f.push(g);continue}if(g=this.tokenizer.def(c)){c=c.substring(g.raw.length);let E=f.at(-1);(E==null?void 0:E.type)==="paragraph"||(E==null?void 0:E.type)==="text"?(E.raw+=(E.raw.endsWith(` `)?"":` `)+g.raw,E.text+=` `+g.raw,this.inlineQueue.at(-1).src=E.text):this.tokens.links[g.tag]||(this.tokens.links[g.tag]={href:g.href,title:g.title},f.push(g));continue}if(g=this.tokenizer.table(c)){c=c.substring(g.raw.length),f.push(g);continue}if(g=this.tokenizer.lheading(c)){c=c.substring(g.raw.length),f.push(g);continue}let b=c;if((j=this.options.extensions)!=null&&j.startBlock){let E=1/0,C=c.slice(1),H;this.options.extensions.startBlock.forEach(J=>{H=J.call({lexer:this},C),typeof H=="number"&&H>=0&&(E=Math.min(E,H))}),E<1/0&&E>=0&&(b=c.substring(0,E+1))}if(this.state.top&&(g=this.tokenizer.paragraph(b))){let E=f.at(-1);s&&(E==null?void 0:E.type)==="paragraph"?(E.raw+=(E.raw.endsWith(` `)?"":` `)+g.raw,E.text+=` `+g.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=E.text):f.push(g),s=b.length!==c.length,c=c.substring(g.raw.length);continue}if(g=this.tokenizer.text(c)){c=c.substring(g.raw.length);let E=f.at(-1);(E==null?void 0:E.type)==="text"?(E.raw+=(E.raw.endsWith(` `)?"":` `)+g.raw,E.text+=` `+g.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=E.text):f.push(g);continue}if(c){this.infiniteLoopError(c.charCodeAt(0));break}}return this.state.top=!0,f}inline(c,f=[]){return this.inlineQueue.push({src:c,tokens:f}),f}inlineTokens(c,f=[]){var b,E,C,H,J;this.tokenizer.lexer=this;let s=c,h=null;if(this.tokens.links){let U=Object.keys(this.tokens.links);if(U.length>0)for(;(h=this.tokenizer.rules.inline.reflinkSearch.exec(s))!==null;)U.includes(h[0].slice(h[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,h.index)+"["+"a".repeat(h[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(h=this.tokenizer.rules.inline.anyPunctuation.exec(s))!==null;)s=s.slice(0,h.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let v;for(;(h=this.tokenizer.rules.inline.blockSkip.exec(s))!==null;)v=h[2]?h[2].length:0,s=s.slice(0,h.index+v)+"["+"a".repeat(h[0].length-v-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);s=((E=(b=this.options.hooks)==null?void 0:b.emStrongMask)==null?void 0:E.call({lexer:this},s))??s;let A=!1,j="",g=1/0;for(;c;){if(c.length(U=nt.call({lexer:this},c,f))?(c=c.substring(U.raw.length),f.push(U),!0):!1))continue;if(U=this.tokenizer.escape(c)){c=c.substring(U.raw.length),f.push(U);continue}if(U=this.tokenizer.tag(c)){c=c.substring(U.raw.length),f.push(U);continue}if(U=this.tokenizer.link(c)){c=c.substring(U.raw.length),f.push(U);continue}if(U=this.tokenizer.reflink(c,this.tokens.links)){c=c.substring(U.raw.length);let nt=f.at(-1);U.type==="text"&&(nt==null?void 0:nt.type)==="text"?(nt.raw+=U.raw,nt.text+=U.text):f.push(U);continue}if(U=this.tokenizer.emStrong(c,s,j)){c=c.substring(U.raw.length),f.push(U);continue}if(U=this.tokenizer.codespan(c)){c=c.substring(U.raw.length),f.push(U);continue}if(U=this.tokenizer.br(c)){c=c.substring(U.raw.length),f.push(U);continue}if(U=this.tokenizer.del(c,s,j)){c=c.substring(U.raw.length),f.push(U);continue}if(U=this.tokenizer.autolink(c)){c=c.substring(U.raw.length),f.push(U);continue}if(!this.state.inLink&&(U=this.tokenizer.url(c))){c=c.substring(U.raw.length),f.push(U);continue}let F=c;if((J=this.options.extensions)!=null&&J.startInline){let nt=1/0,Yt=c.slice(1),Qt;this.options.extensions.startInline.forEach(Ct=>{Qt=Ct.call({lexer:this},Yt),typeof Qt=="number"&&Qt>=0&&(nt=Math.min(nt,Qt))}),nt<1/0&&nt>=0&&(F=c.substring(0,nt+1))}if(U=this.tokenizer.inlineText(F)){c=c.substring(U.raw.length),U.raw.slice(-1)!=="_"&&(j=U.raw.slice(-1)),A=!0;let nt=f.at(-1);(nt==null?void 0:nt.type)==="text"?(nt.raw+=U.raw,nt.text+=U.text):f.push(U);continue}if(c){this.infiniteLoopError(c.charCodeAt(0));break}}return f}infiniteLoopError(c){let f="Infinite loop on byte: "+c;if(this.options.silent)console.error(f);else throw new Error(f)}},Ti=class{constructor(r){Nt(this,"options");Nt(this,"parser");this.options=r||da}space(r){return""}code({text:r,lang:c,escaped:f}){var v;let s=(v=(c||"").match(ue.notSpaceStart))==null?void 0:v[0],h=r.replace(ue.endingNewline,"")+` `;return s?'
'+(f?h:Fe(h,!0))+`
`:"
"+(f?h:Fe(h,!0))+`
`}blockquote({tokens:r}){return`
${this.parser.parse(r)}
`}html({text:r}){return r}def(r){return""}heading({tokens:r,depth:c}){return`${this.parser.parseInline(r)} `}hr(r){return`
`}list(r){let c=r.ordered,f=r.start,s="";for(let A=0;A `+s+" `}listitem(r){return`
  • ${this.parser.parse(r.tokens)}
  • `}checkbox({checked:r}){return" '}paragraph({tokens:r}){return`

    ${this.parser.parseInline(r)}

    `}table(r){let c="",f="";for(let h=0;h${s}`),` `+c+` `+s+`
    `}tablerow({text:r}){return` ${r} `}tablecell(r){let c=this.parser.parseInline(r.tokens),f=r.header?"th":"td";return(r.align?`<${f} align="${r.align}">`:`<${f}>`)+c+` `}strong({tokens:r}){return`${this.parser.parseInline(r)}`}em({tokens:r}){return`${this.parser.parseInline(r)}`}codespan({text:r}){return`${Fe(r,!0)}`}br(r){return"
    "}del({tokens:r}){return`${this.parser.parseInline(r)}`}link({href:r,title:c,tokens:f}){let s=this.parser.parseInline(f),h=bd(r);if(h===null)return s;r=h;let v='
    ",v}image({href:r,title:c,text:f,tokens:s}){s&&(f=this.parser.parseInline(s,this.parser.textRenderer));let h=bd(r);if(h===null)return Fe(f);r=h;let v=`${Fe(f)}{let g=A[j].flat(1/0);f=f.concat(this.walkTokens(g,c))}):A.tokens&&(f=f.concat(this.walkTokens(A.tokens,c)))}}return f}use(...r){let c=this.defaults.extensions||{renderers:{},childTokens:{}};return r.forEach(f=>{let s={...f};if(s.async=this.defaults.async||s.async||!1,f.extensions&&(f.extensions.forEach(h=>{if(!h.name)throw new Error("extension name required");if("renderer"in h){let v=c.renderers[h.name];v?c.renderers[h.name]=function(...A){let j=h.renderer.apply(this,A);return j===!1&&(j=v.apply(this,A)),j}:c.renderers[h.name]=h.renderer}if("tokenizer"in h){if(!h.level||h.level!=="block"&&h.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let v=c[h.level];v?v.unshift(h.tokenizer):c[h.level]=[h.tokenizer],h.start&&(h.level==="block"?c.startBlock?c.startBlock.push(h.start):c.startBlock=[h.start]:h.level==="inline"&&(c.startInline?c.startInline.push(h.start):c.startInline=[h.start]))}"childTokens"in h&&h.childTokens&&(c.childTokens[h.name]=h.childTokens)}),s.extensions=c),f.renderer){let h=this.defaults.renderer||new Ti(this.defaults);for(let v in f.renderer){if(!(v in h))throw new Error(`renderer '${v}' does not exist`);if(["options","parser"].includes(v))continue;let A=v,j=f.renderer[A],g=h[A];h[A]=(...b)=>{let E=j.apply(h,b);return E===!1&&(E=g.apply(h,b)),E||""}}s.renderer=h}if(f.tokenizer){let h=this.defaults.tokenizer||new zi(this.defaults);for(let v in f.tokenizer){if(!(v in h))throw new Error(`tokenizer '${v}' does not exist`);if(["options","rules","lexer"].includes(v))continue;let A=v,j=f.tokenizer[A],g=h[A];h[A]=(...b)=>{let E=j.apply(h,b);return E===!1&&(E=g.apply(h,b)),E}}s.tokenizer=h}if(f.hooks){let h=this.defaults.hooks||new In;for(let v in f.hooks){if(!(v in h))throw new Error(`hook '${v}' does not exist`);if(["options","block"].includes(v))continue;let A=v,j=f.hooks[A],g=h[A];In.passThroughHooks.has(v)?h[A]=b=>{if(this.defaults.async&&In.passThroughHooksRespectAsync.has(v))return(async()=>{let C=await j.call(h,b);return g.call(h,C)})();let E=j.call(h,b);return g.call(h,E)}:h[A]=(...b)=>{if(this.defaults.async)return(async()=>{let C=await j.apply(h,b);return C===!1&&(C=await g.apply(h,b)),C})();let E=j.apply(h,b);return E===!1&&(E=g.apply(h,b)),E}}s.hooks=h}if(f.walkTokens){let h=this.defaults.walkTokens,v=f.walkTokens;s.walkTokens=function(A){let j=[];return j.push(v.call(this,A)),h&&(j=j.concat(h.call(this,A))),j}}this.defaults={...this.defaults,...s}}),this}setOptions(r){return this.defaults={...this.defaults,...r},this}lexer(r,c){return Ze.lex(r,c??this.defaults)}parser(r,c){return Le.parse(r,c??this.defaults)}parseMarkdown(r){return(c,f)=>{let s={...f},h={...this.defaults,...s},v=this.onError(!!h.silent,!!h.async);if(this.defaults.async===!0&&s.async===!1)return v(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof c>"u"||c===null)return v(new Error("marked(): input parameter is undefined or null"));if(typeof c!="string")return v(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(c)+", string expected"));if(h.hooks&&(h.hooks.options=h,h.hooks.block=r),h.async)return(async()=>{let A=h.hooks?await h.hooks.preprocess(c):c,j=await(h.hooks?await h.hooks.provideLexer(r):r?Ze.lex:Ze.lexInline)(A,h),g=h.hooks?await h.hooks.processAllTokens(j):j;h.walkTokens&&await Promise.all(this.walkTokens(g,h.walkTokens));let b=await(h.hooks?await h.hooks.provideParser(r):r?Le.parse:Le.parseInline)(g,h);return h.hooks?await h.hooks.postprocess(b):b})().catch(v);try{h.hooks&&(c=h.hooks.preprocess(c));let A=(h.hooks?h.hooks.provideLexer(r):r?Ze.lex:Ze.lexInline)(c,h);h.hooks&&(A=h.hooks.processAllTokens(A)),h.walkTokens&&this.walkTokens(A,h.walkTokens);let j=(h.hooks?h.hooks.provideParser(r):r?Le.parse:Le.parseInline)(A,h);return h.hooks&&(j=h.hooks.postprocess(j)),j}catch(A){return v(A)}}}onError(r,c){return f=>{if(f.message+=` Please report this to https://github.com/markedjs/marked.`,r){let s="

    An error occurred:

    "+Fe(f.message+"",!0)+"
    ";return c?Promise.resolve(s):s}if(c)return Promise.reject(f);throw f}}},ha=new Kg;function Tt(r,c){return ha.parse(r,c)}Tt.options=Tt.setOptions=function(r){return ha.setOptions(r),Tt.defaults=ha.defaults,Td(Tt.defaults),Tt};Tt.getDefaults=Fs;Tt.defaults=da;Tt.use=function(...r){return ha.use(...r),Tt.defaults=ha.defaults,Td(Tt.defaults),Tt};Tt.walkTokens=function(r,c){return ha.walkTokens(r,c)};Tt.parseInline=ha.parseInline;Tt.Parser=Le;Tt.parser=Le.parse;Tt.Renderer=Ti;Tt.TextRenderer=uf;Tt.Lexer=Ze;Tt.lexer=Ze.lex;Tt.Tokenizer=zi;Tt.Hooks=In;Tt.parse=Tt;Tt.options;Tt.setOptions;Tt.use;Tt.walkTokens;Tt.parseInline;Le.parse;Ze.lex;function Jg(r){const c=new Date(r),f=new Date;return c.toDateString()===f.toDateString()?c.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):c.toLocaleDateString([],{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})}function $g(r){return r?r<1024?`${r} B`:r<1048576?`${(r/1024).toFixed(1)} KB`:`${(r/1048576).toFixed(1)} MB`:""}function Wg({file:r}){var f,s;const c=((s=(f=r.mime_type)==null?void 0:f.split("/").pop())==null?void 0:s.toUpperCase())||r.type;return m.jsxs("div",{className:"file-card",children:[m.jsx("span",{className:"file-icon",children:"📎"}),m.jsxs("div",{className:"file-info",children:[m.jsx("div",{className:"file-name",children:r.filename||"file"}),m.jsx("div",{className:"file-meta",children:[r.size?$g(r.size):"",c,r.type].filter(Boolean).join(" · ")})]}),r.download_url&&m.jsx("a",{className:"file-dl",href:r.download_url,download:r.filename,target:"_blank",rel:"noreferrer",children:"⬇ Скачать"})]})}function Fg({text:r,parse_mode:c}){const f=w.useMemo(()=>c==="markdown"?Tt.parse(r,{breaks:!0,gfm:!0}):null,[r,c]);return f?m.jsx("div",{className:"msg-text",dangerouslySetInnerHTML:{__html:f}}):m.jsx("div",{className:"msg-text",children:r})}function Ig({buttons:r,onClick:c}){return m.jsx("div",{className:"btns",children:r.map((f,s)=>m.jsx("button",{className:`btn btn-${f.style}`,onClick:()=>c(f),children:f.label},s))})}function Pg({messages:r,isTyping:c,onButtonClick:f}){const s=w.useRef(null);return w.useEffect(()=>{var h;(h=s.current)==null||h.scrollIntoView({behavior:"smooth"})},[r,c]),r.length===0&&!c?m.jsx("div",{className:"message-list empty",children:m.jsxs("div",{className:"empty-state",children:[m.jsx("p",{style:{fontSize:32,marginBottom:8},children:"💬"}),m.jsx("p",{children:"Чат пуст."}),m.jsx("p",{children:"Напишите что-нибудь, чтобы начать."})]})}):m.jsxs("div",{className:"message-list",children:[r.map(h=>m.jsxs("div",{className:`message message-${h.from}`,children:[m.jsxs("div",{className:"msg-hdr",children:[m.jsx("div",{className:`avatar avatar-${h.from}`,children:h.from==="user"?"U":"λ"}),m.jsx("span",{className:"msg-name",children:h.from==="user"?"Вы":"Lambda"})]}),m.jsx(Fg,{text:h.text,parse_mode:h.parse_mode}),h.attachments&&h.attachments.length>0&&m.jsx("div",{className:"attach-list",children:h.attachments.map((v,A)=>m.jsx(Wg,{file:v},A))}),h.buttons&&h.buttons.length>0&&m.jsx(Ig,{buttons:h.buttons,onClick:f}),m.jsx("div",{className:"msg-time",children:Jg(h.timestamp)})]},h.id)),c&&m.jsx("div",{className:"message message-agent",children:m.jsx("div",{className:"typing-indicator",children:"λ печатает"})}),m.jsx("div",{ref:s})]})}function tp({chatId:r,messages:c,isTyping:f,userId:s,onSend:h,onButtonClick:v,disabled:A}){const j=w.useCallback(g=>{v(r,g)},[r,v]);return m.jsxs("div",{className:"chat",children:[m.jsx(Pg,{messages:c,isTyping:f,onButtonClick:j}),m.jsx(ig,{onSend:h,disabled:A||!s,userId:s})]},r)}const cf="web_surface_session",sf="web_surface_user_id";function ep(){const r=localStorage.getItem(cf),c=localStorage.getItem(sf);return r&&c?{sessionToken:r,userId:c}:null}function lp(r,c){localStorage.setItem(cf,r),localStorage.setItem(sf,c)}function ap(){localStorage.removeItem(cf),localStorage.removeItem(sf)}function np(r){const[c,f]=w.useState("disconnected"),[s,h]=w.useState(null),v=w.useRef(null),A=w.useRef(ep());w.useRef(()=>{});const j=w.useCallback(()=>{var J;if(((J=v.current)==null?void 0:J.readyState)===WebSocket.OPEN)return;f("connecting");const C=`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}/ws`,H=new WebSocket(C);v.current=H,H.onopen=()=>{f("connected");const U=A.current,F={type:"auth"};U&&(F.session_token=U.sessionToken),H.send(JSON.stringify(F))},H.onmessage=U=>{try{const F=JSON.parse(U.data);F.type==="connected"&&(A.current={sessionToken:F.session_token,userId:F.user_id},lp(F.session_token,F.user_id),h(F.user_id)),r(F)}catch{}},H.onclose=()=>{f("disconnected"),v.current=null},H.onerror=()=>{H.close()}},[r]),g=w.useCallback(E=>{var C;((C=v.current)==null?void 0:C.readyState)===WebSocket.OPEN&&v.current.send(JSON.stringify(E))},[]),b=w.useCallback(()=>{ap(),A.current=null,h(null),j()},[j]);return w.useEffect(()=>(j(),()=>{var E;(E=v.current)==null||E.close()}),[j]),{status:c,userId:s,send:g,reconnect:b}}function Ll(){return{messages:[],isTyping:!1}}function up(){const[r,c]=w.useState({C1:Ll()}),[f,s]=w.useState("C1"),[h,v]=w.useState(["C1"]),[A,j]=w.useState({C1:"Чат 1"}),[g,b]=w.useState(new Set),[E,C]=w.useState(!1),[H,J]=w.useState(!1),[U,F]=w.useState(!1),[nt,Yt]=w.useState(!0),[Qt,Ct]=w.useState(null),[ft,Vt]=w.useState(null),[jt,$]=w.useState("main"),[le,Ae]=w.useState({"web-search":!0,"fetch-url":!0,email:!1,browser:!1,"image-gen":!1,files:!0}),[vl,Ne]=w.useState({"email-send":!0,"file-delete":!0,"social-post":!0}),[Wt,Ie]=w.useState(""),[je,ve]=w.useState(""),[D,q]=w.useState(null),[K,ot]=w.useState(!1),[St,y]=w.useState(!1),[M,B]=w.useState(""),[Q,W]=w.useState(null),[I,dt]=w.useState(""),[Kt,kt]=w.useState([]),Pe=w.useRef(null),Qe=w.useRef(null),ie=w.useCallback(T=>{q(T),Pe.current&&clearTimeout(Pe.current),Pe.current=setTimeout(()=>q(null),2500)},[]),re=w.useRef(0),Ve=w.useRef(!1),ma=w.useRef(f);w.useEffect(()=>{ma.current=f},[f]),w.useEffect(()=>{Ve.current=U},[U]),w.useEffect(()=>{const T=localStorage.getItem("web_side_width");if(T){const lt=parseInt(T,10);lt>=120&<<=400&&Ct(lt)}},[]),w.useEffect(()=>{!Qt||!Qe.current||(Qe.current.style.width=Qt+"px")},[Qt]);const ga=w.useCallback(T=>{const lt=Qe.current;if(!lt)return;const Y="touches"in T?T.touches[0].clientX:T.clientX,tt=lt.getBoundingClientRect().width,vt=ae=>{const se="touches"in ae?ae.touches[0].clientX:ae.clientX;let bl=tt+(se-Y);bl<120&&(bl=120),bl>400&&(bl=400),lt.style.width=bl+"px",Ct(bl)},mt=()=>{if(Qe.current){const ae=parseInt(Qe.current.style.width,10);ae>=120&&ae<=400&&localStorage.setItem("web_side_width",String(ae))}document.removeEventListener("mousemove",vt),document.removeEventListener("mouseup",mt),document.removeEventListener("touchmove",vt),document.removeEventListener("touchend",mt),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",vt),document.addEventListener("mouseup",mt),document.addEventListener("touchmove",vt),document.addEventListener("touchend",mt),T.preventDefault()},[]),Ai=w.useCallback(T=>{var lt;if(Ve.current&&(T.type==="message"||T.type==="ui")&&(T.chat_id||"C1")===ma.current){Vt({text:T.text,buttons:T.buttons});return}if(T.type==="history"){T.chat_names&&j(tt=>({...tt,...T.chat_names})),T.archived&&b(new Set(T.archived)),v(tt=>{const vt=new Set(tt);return Object.keys(T.chats).forEach(mt=>vt.add(mt)),Array.from(vt)});const Y={};Object.entries(T.chats).forEach(([tt,vt])=>{Y[tt]={messages:[],isTyping:!1},vt.forEach(mt=>{Y[tt].messages.push({id:`hist-${re.current++}`,chat_id:mt.chat_id||tt,text:mt.text,from:mt.from,timestamp:mt.timestamp*1e3,attachments:mt.attachments,buttons:mt.buttons})})}),c(tt=>({...tt,...Y}));return}if(T.type==="message"){const Y=T.chat_id||"C1";re.current+=1;const tt={id:`msg-${re.current}`,chat_id:Y,text:T.text,from:"agent",parse_mode:T.parse_mode,timestamp:Date.now(),attachments:(lt=T.attachments)==null?void 0:lt.filter(vt=>vt.download_url)};c(vt=>{const mt=vt[Y]||Ll();return{...vt,[Y]:{...mt,messages:[...mt.messages,tt],isTyping:!1}}})}else if(T.type==="chat_name")j(Y=>({...Y,[T.chat_id]:T.name})),v(Y=>Y.includes(T.chat_id)?Y:[...Y,T.chat_id]);else if(T.type==="chat_archived")b(Y=>new Set(Y).add(T.chat_id));else if(T.type==="chat_unarchived")b(Y=>{const tt=new Set(Y);return tt.delete(T.chat_id),tt});else if(T.type==="chat_new")v(Y=>Y.includes(T.chat_id)?Y:[...Y,T.chat_id]),s(T.chat_id);else if(T.type==="ui"){const Y=T.chat_id||"C1";re.current+=1,c(tt=>{const vt=tt[Y]||Ll();return{...tt,[Y]:{...vt,messages:[...vt.messages,{id:`msg-${re.current}`,chat_id:Y,text:T.text,from:"agent",buttons:T.buttons,timestamp:Date.now()}]}}})}else if(T.type==="typing"){const Y=T.chat_id||"C1";c(tt=>{const vt=tt[Y]||Ll();return{...tt,[Y]:{...vt,isTyping:T.is_typing}}})}else if(T.type==="notification"){const Y=T.chat_id||"C1";re.current+=1,c(tt=>{const vt=tt[Y]||Ll();return{...tt,[Y]:{...vt,messages:[...vt.messages,{id:`msg-${re.current}`,chat_id:Y,text:`[${T.level.toUpperCase()}] ${T.text}`,from:"agent",timestamp:Date.now()}]}}})}else T.type==="sessions"&&(kt(T.sessions.map(Y=>Y.name)),ot(!0))},[]),{status:Oe,userId:Z,send:gt,reconnect:pa}=np(Ai),Ni=w.useCallback((T,lt)=>{if(Z){if(T.startsWith("/")){const Y=T.slice(1).split(/\s+/),tt=Y[0].toLowerCase();if(tt==="settings"){F(!0),$("main"),Vt(null),gt({type:"command",user_id:Z,chat_id:f,command:"settings",args:Y.slice(1)});return}if(tt==="save"){if(!Y[1]){ie("⚠ Укажите имя: /save <имя>");return}ie("💾 Сохраняю контекст...")}else if(tt==="load"){if(!Y[1]){ie("📂 Используйте кнопку 📂 в хедере для выбора сессии");return}ie("📂 Загружаю контекст...")}else if(tt==="context")ie("📋 Информация о контексте...");else if(tt==="reset"){if(!window.confirm("Сбросить контекст? Агент забудет предыдущий разговор."))return;ie("🔄 Сброс контекста...")}re.current+=1,c(vt=>{const mt=vt[f]||Ll();return{...vt,[f]:{...mt,messages:[...mt.messages,{id:`msg-${re.current}`,chat_id:f,text:T,from:"user",timestamp:Date.now(),attachments:lt}]}}}),gt({type:"command",user_id:Z,chat_id:f,command:tt,args:Y.slice(1)});return}re.current+=1,c(Y=>{const tt=Y[f]||Ll();return{...Y,[f]:{...tt,messages:[...tt.messages,{id:`msg-${re.current}`,chat_id:f,text:T,from:"user",timestamp:Date.now(),attachments:lt}]}}}),gt({type:"message",user_id:Z,chat_id:f,text:T})}},[Z,f,gt]),tu=w.useCallback((T,lt)=>{Z&>({type:"callback",user_id:Z,chat_id:T,action:lt.action,payload:lt.payload})},[Z,gt]),ce=w.useCallback(T=>{if(!Z)return;if(g.has(T))gt({type:"command",user_id:Z,chat_id:T,command:"unarchive",args:[]}),b(Y=>{const tt=new Set(Y);return tt.delete(T),tt});else if(gt({type:"command",user_id:Z,chat_id:T,command:"archive",args:[]}),b(Y=>new Set(Y).add(T)),f===T){const Y=h.filter(tt=>tt!==T&&!g.has(tt));Y.length>0&&s(Y[0])}},[Z,gt,f,h,g]),ji=w.useCallback(T=>{if(Z&&window.confirm(`Удалить чат «${A[T]||T}»?`)&&(gt({type:"command",user_id:Z,chat_id:T,command:"delete",args:[]}),v(lt=>lt.filter(Y=>Y!==T)),j(lt=>{const Y={...lt};return delete Y[T],Y}),c(lt=>{const Y={...lt};return delete Y[T],Y}),b(lt=>{const Y=new Set(lt);return Y.delete(T),Y}),f===T)){const lt=h.filter(Y=>Y!==T);s(lt.length>0?lt[0]:"C1")}},[Z,gt,f,h,A]),eu=w.useCallback(()=>{Z&>({type:"command",user_id:Z,chat_id:f,command:"new",args:[]})},[Z,gt,f]),lu=E?[...h.filter(T=>!g.has(T)),...h.filter(T=>g.has(T))]:h.filter(T=>!g.has(T)),Vl=r[f]||Ll();return m.jsxs("div",{className:"app",children:[m.jsxs("header",{className:"app-header",children:[m.jsxs("div",{className:"header-left",children:[m.jsx("button",{className:"btn-icon",onClick:()=>Yt(T=>!T),title:nt?"Скрыть панель":"Показать панель",children:nt?"◀":"▶"}),m.jsx("button",{className:"btn-icon btn-help",onClick:()=>J(T=>!T),title:"Помощь",children:"?"}),m.jsx("h1",{children:"λ Lambda Chat"})]}),m.jsxs("div",{className:"header-right",children:[m.jsx("button",{className:"btn-icon btn-save",onClick:()=>{Z&&(B(""),y(!0))},title:"Сохранить контекст",children:"💾"}),m.jsx("button",{className:"btn-icon btn-load",onClick:()=>{Z&&(ot(!0),gt({type:"command",user_id:Z,chat_id:f,command:"load",args:[]}))},title:"Загрузить контекст",children:"📂"}),m.jsx("button",{className:"btn-icon btn-settings",onClick:()=>{const T=!U;F(T),T&&Z&&($("main"),Vt(null),gt({type:"command",user_id:Z,chat_id:f,command:"settings",args:[]}))},title:"Настройки",children:"⚙"}),m.jsxs("div",{className:"connection-status",children:[m.jsx("span",{className:`dot dot-${Oe}`}),Oe==="connected"?"Подключено":Oe==="connecting"?"Подключение...":"Отключено"]})]})]}),D&&m.jsx("div",{className:"toast",children:D}),St&&m.jsx("div",{className:"modal-overlay",onClick:()=>y(!1),children:m.jsxs("div",{className:"modal save-modal",onClick:T=>T.stopPropagation(),children:[m.jsx("button",{className:"modal-close",onClick:()=>y(!1),children:"×"}),m.jsx("h2",{children:"💾 Сохранить контекст"}),m.jsxs("div",{className:"save-input-row",children:[m.jsx("input",{className:"save-input",type:"text",placeholder:"Введите имя сессии...",value:M,onChange:T=>B(T.target.value),onKeyDown:T=>{if(T.key==="Enter"&&M.trim()){if(!Z)return;gt({type:"command",user_id:Z,chat_id:f,command:"save",args:[M.trim()]}),y(!1),ie(`💾 Сохраняю «${M.trim()}»...`)}},autoFocus:!0}),m.jsx("button",{className:"btn btn-primary save-confirm",disabled:!M.trim(),onClick:()=>{!Z||!M.trim()||(gt({type:"command",user_id:Z,chat_id:f,command:"save",args:[M.trim()]}),y(!1),ie(`💾 Сохраняю «${M.trim()}»...`))},children:"Сохранить"})]})]})}),K&&m.jsx("div",{className:"modal-overlay",onClick:()=>ot(!1),children:m.jsxs("div",{className:"modal load-modal",onClick:T=>T.stopPropagation(),children:[m.jsx("button",{className:"modal-close",onClick:()=>ot(!1),children:"×"}),m.jsx("h2",{children:"📂 Загрузить контекст"}),Kt.length===0?m.jsx("p",{className:"settings-muted",style:{textAlign:"center",padding:"16px 0"},children:"Нет сохранённых сессий"}):m.jsx("div",{className:"load-list",children:Kt.map(T=>m.jsx("button",{className:"load-item btn btn-secondary",onClick:()=>{Z&&(gt({type:"command",user_id:Z,chat_id:f,command:"load",args:[T]}),ot(!1),ie(`📂 Загружаю «${T}»...`))},children:T},T))})]})}),Q&&m.jsx("div",{className:"modal-overlay",onClick:()=>W(null),children:m.jsxs("div",{className:"modal rename-modal",onClick:T=>T.stopPropagation(),children:[m.jsx("button",{className:"modal-close",onClick:()=>W(null),children:"×"}),m.jsx("h2",{children:"✏️ Переименовать чат"}),m.jsxs("div",{className:"save-input-row",children:[m.jsx("input",{className:"save-input",type:"text",placeholder:"Новое название...",value:I,onChange:T=>dt(T.target.value),onKeyDown:T=>{if(T.key==="Enter"&&I.trim()){if(!Z)return;gt({type:"command",user_id:Z,chat_id:Q,command:"rename",args:[I.trim()]}),W(null),ie(`✏️ Переименован в «${I.trim()}»`)}},autoFocus:!0}),m.jsx("button",{className:"btn btn-primary save-confirm",disabled:!I.trim(),onClick:()=>{!Z||!I.trim()||(gt({type:"command",user_id:Z,chat_id:Q,command:"rename",args:[I.trim()]}),W(null),ie(`✏️ Переименован в «${I.trim()}»`))},children:"Переименовать"})]})]})}),H&&m.jsx("div",{className:"modal-overlay",onClick:()=>J(!1),children:m.jsxs("div",{className:"modal",onClick:T=>T.stopPropagation(),children:[m.jsx("button",{className:"modal-close",onClick:()=>J(!1),children:"×"}),m.jsx("h2",{children:"Команды"}),m.jsx("table",{children:m.jsxs("tbody",{children:[m.jsxs("tr",{children:[m.jsx("td",{children:"/start"}),m.jsx("td",{children:"Начать диалог заново"})]}),m.jsxs("tr",{children:[m.jsx("td",{children:"/new"}),m.jsx("td",{children:"Создать новый чат"})]}),m.jsxs("tr",{children:[m.jsx("td",{children:"/chats"}),m.jsx("td",{children:"Список чатов"})]}),m.jsxs("tr",{children:[m.jsx("td",{children:"/rename <имя>"}),m.jsx("td",{children:"Переименовать чат"})]}),m.jsxs("tr",{children:[m.jsx("td",{children:"/archive"}),m.jsx("td",{children:"Архивировать чат"})]}),m.jsxs("tr",{children:[m.jsx("td",{children:"/unarchive"}),m.jsx("td",{children:"Восстановить чат из архива"})]}),m.jsxs("tr",{children:[m.jsx("td",{children:"/settings"}),m.jsx("td",{children:"Настройки"})]}),m.jsxs("tr",{children:[m.jsx("td",{children:"/save [имя]"}),m.jsx("td",{children:"Сохранить контекст"})]}),m.jsxs("tr",{children:[m.jsx("td",{children:"/load [имя]"}),m.jsx("td",{children:"Загрузить сохранённый контекст"})]}),m.jsxs("tr",{children:[m.jsx("td",{children:"/context"}),m.jsx("td",{children:"Информация о контексте"})]}),m.jsxs("tr",{children:[m.jsx("td",{children:"/reset"}),m.jsx("td",{children:"Сбросить контекст"})]})]})})]})}),U&&m.jsx("div",{className:"modal-overlay",onClick:()=>F(!1),children:m.jsxs("div",{className:"modal settings-modal",onClick:T=>T.stopPropagation(),children:[m.jsx("button",{className:"modal-close",onClick:()=>F(!1),children:"×"}),jt==="main"&&m.jsxs(m.Fragment,{children:[m.jsx("h2",{children:"⚙ Настройки"}),m.jsxs("div",{className:"settings-section",children:[m.jsx("label",{children:"Статус:"}),m.jsx("span",{className:`settings-value ${Oe}`,children:Oe==="connected"?"Подключено":Oe==="connecting"?"Подключение...":"Отключено"}),Oe==="disconnected"&&m.jsx("button",{className:"btn btn-secondary settings-reconnect",onClick:pa,children:"Переподключиться"})]}),m.jsxs("div",{className:"settings-section",children:[m.jsx("label",{children:"Пользователь:"}),m.jsx("span",{className:"settings-value",children:Z||"—"})]}),m.jsxs("div",{className:"settings-section",children:[m.jsx("label",{children:"Активный чат:"}),m.jsx("span",{className:"settings-value",children:A[f]||f})]}),m.jsxs("div",{className:"settings-section",children:[m.jsx("label",{children:"Всего чатов:"}),m.jsx("span",{className:"settings-value",children:h.length})]}),ft&&m.jsxs("div",{className:"settings-agent",children:[m.jsx("div",{className:"settings-agent-text",children:ft.text}),ft.buttons&&ft.buttons.length>0&&m.jsx("div",{className:"btns settings-agent-btns",children:ft.buttons.map((T,lt)=>m.jsx("button",{className:`btn ${T.style==="danger"?"btn-danger":T.action==="callback"?"btn-primary":"btn-secondary"}`,onClick:()=>tu(f,T),children:T.label},lt))})]}),m.jsxs("div",{className:"settings-categories",children:[m.jsx("div",{className:"settings-cat-title",children:"Категории"}),m.jsxs("div",{className:"btns settings-cat-btns",children:[m.jsx("button",{className:"btn btn-secondary",onClick:()=>{$("skills"),Z&>({type:"callback",user_id:Z,chat_id:f,action:"settings_skills",payload:{}})},children:"🛠 Навыки"}),m.jsx("button",{className:"btn btn-secondary",onClick:()=>{$("safety"),Z&>({type:"callback",user_id:Z,chat_id:f,action:"settings_safety",payload:{}})},children:"🔒 Безопасность"}),m.jsx("button",{className:"btn btn-secondary",onClick:()=>{$("soul"),Z&>({type:"callback",user_id:Z,chat_id:f,action:"settings_soul",payload:{}})},children:"👤 Личность"}),m.jsx("button",{className:"btn btn-secondary",onClick:()=>{$("connectors"),Z&>({type:"callback",user_id:Z,chat_id:f,action:"settings_connectors",payload:{}})},children:"🔌 Интеграции"}),m.jsx("button",{className:"btn btn-secondary",onClick:()=>{$("plan"),Z&>({type:"callback",user_id:Z,chat_id:f,action:"settings_plan",payload:{}})},children:"📊 Тариф"})]})]})]}),jt==="skills"&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"settings-sub-header",children:[m.jsx("button",{className:"btn-icon",onClick:()=>$("main"),title:"Назад",children:"◀"}),m.jsx("h2",{children:"🛠 Навыки"})]}),ft&&ft.text&&m.jsx("div",{className:"settings-agent-text",children:ft.text}),m.jsx("div",{className:"settings-toggles",children:Object.entries(le).map(([T,lt])=>m.jsxs("label",{className:"toggle-row",children:[m.jsx("span",{className:"toggle-label",children:T}),m.jsx("span",{className:`toggle-switch ${lt?"on":"off"}`,onClick:()=>{Ae(Y=>({...Y,[T]:!Y[T]})),Z&>({type:"callback",user_id:Z,chat_id:f,action:"toggle_skill",payload:{skill:T,enabled:!lt}})},children:m.jsx("span",{className:"toggle-knob"})})]},T))})]}),jt==="safety"&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"settings-sub-header",children:[m.jsx("button",{className:"btn-icon",onClick:()=>$("main"),title:"Назад",children:"◀"}),m.jsx("h2",{children:"🔒 Безопасность"})]}),ft&&ft.text&&m.jsx("div",{className:"settings-agent-text",children:ft.text}),m.jsx("div",{className:"settings-toggles",children:Object.entries(vl).map(([T,lt])=>m.jsxs("label",{className:"toggle-row",children:[m.jsx("span",{className:"toggle-label",children:T}),m.jsx("span",{className:`toggle-switch ${lt?"on":"off"}`,onClick:()=>{Ne(Y=>({...Y,[T]:!Y[T]})),Z&>({type:"callback",user_id:Z,chat_id:f,action:"set_safety",payload:{trigger:T,enabled:!lt}})},children:m.jsx("span",{className:"toggle-knob"})})]},T))})]}),jt==="soul"&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"settings-sub-header",children:[m.jsx("button",{className:"btn-icon",onClick:()=>$("main"),title:"Назад",children:"◀"}),m.jsx("h2",{children:"👤 Личность"})]}),ft&&ft.text&&m.jsx("div",{className:"settings-agent-text",children:ft.text}),m.jsxs("div",{className:"settings-soul-form",children:[m.jsxs("label",{className:"soul-field",children:[m.jsx("span",{children:"Имя"}),m.jsx("input",{type:"text",value:Wt,onChange:T=>Ie(T.target.value),placeholder:"Имя агента"})]}),m.jsxs("label",{className:"soul-field",children:[m.jsx("span",{children:"Инструкции"}),m.jsx("textarea",{value:je,onChange:T=>ve(T.target.value),placeholder:"Опишите характер...",rows:3})]}),m.jsx("button",{className:"btn btn-primary",onClick:()=>{Z&>({type:"callback",user_id:Z,chat_id:f,action:"set_soul",payload:{name:Wt,instructions:je}})},children:"Сохранить"})]})]}),jt==="connectors"&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"settings-sub-header",children:[m.jsx("button",{className:"btn-icon",onClick:()=>$("main"),title:"Назад",children:"◀"}),m.jsx("h2",{children:"🔌 Интеграции"})]}),ft&&ft.text&&m.jsx("div",{className:"settings-agent-text",children:ft.text}),m.jsxs("div",{className:"settings-placeholder",children:[m.jsx("p",{children:"Подключение внешних сервисов через OAuth."}),m.jsx("p",{className:"settings-muted",children:"Скоро будет доступно"})]})]}),jt==="plan"&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"settings-sub-header",children:[m.jsx("button",{className:"btn-icon",onClick:()=>$("main"),title:"Назад",children:"◀"}),m.jsx("h2",{children:"📊 Тариф"})]}),ft&&ft.text&&m.jsx("div",{className:"settings-agent-text",children:ft.text}),m.jsxs("div",{className:"settings-plan",children:[m.jsxs("div",{className:"settings-section",children:[m.jsx("label",{children:"План:"}),m.jsx("span",{className:"settings-value",children:"Бесплатный"})]}),m.jsxs("div",{className:"settings-section",children:[m.jsx("label",{children:"Токенов использовано:"}),m.jsx("span",{className:"settings-value",children:"0 / 1000"})]})]})]})]})}),m.jsxs("div",{className:"app-body",children:[m.jsxs("aside",{className:`sidebar ${nt?"":"collapsed"}`,ref:Qe,children:[m.jsx("div",{className:"side-resizer",onMouseDown:ga,onTouchStart:ga}),m.jsxs("div",{className:"sidebar-header",children:[m.jsx("div",{className:"sidebar-header-left",children:m.jsx("span",{children:"Чаты"})}),m.jsx("button",{className:"btn-icon btn-add",onClick:eu,title:"Новый чат",children:"+"})]}),m.jsx("div",{className:"sidebar-tabs",children:lu.map(T=>m.jsxs("div",{className:`chat-tab-row ${T===f?"active":""} ${g.has(T)?"archived":""}`,onClick:()=>s(T),children:[m.jsx("span",{className:"chat-tab-label",children:A[T]||T}),m.jsxs("span",{className:"chat-tab-actions",onClick:lt=>lt.stopPropagation(),children:[m.jsx("button",{className:"tab-action archive-action",onClick:()=>ce(T),title:g.has(T)?"Разархивировать":"Архивировать",children:g.has(T)?"📂":"📁"}),m.jsx("button",{className:"tab-action rename-action",onClick:()=>{W(T),dt(A[T]||T)},title:"Переименовать",children:"✏️"}),m.jsx("button",{className:"tab-action delete-action",onClick:()=>ji(T),title:"Удалить чат",children:"🗑"})]})]},T))}),m.jsxs("div",{className:"sidebar-footer",children:[m.jsx("button",{className:"archive-toggle",onClick:g.size>0?()=>C(T=>!T):void 0,disabled:g.size===0,children:E?"Скрыть архив":g.size>0?`Показать архив (${g.size})`:"Архив"}),m.jsx("button",{className:"btn-reconnect",onClick:pa,style:{display:Oe==="disconnected"?"block":"none"},children:"Переподключиться"})]})]}),m.jsx("main",{className:"main",children:m.jsx(tp,{chatId:f,messages:Vl.messages,isTyping:Vl.isTyping,userId:Z,onSend:Ni,onButtonClick:tu,disabled:Oe!=="connected"})})]})]})}ug.createRoot(document.getElementById("root")).render(m.jsx(w.StrictMode,{children:m.jsx(up,{})}));